• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /**
21 *******************************************************************************
22 * @file
23 *  ih264_buf_mgr.h
24 *
25 * @brief
26 *  Function declarations used for buffer management
27 *
28 * @remarks
29 *  None
30 *
31 *******************************************************************************
32 */
33 #ifndef _IH264_BUF_MGR_H_
34 #define _IH264_BUF_MGR_H_
35 
36 #define BUF_MGR_MAX_CNT 64
37 
38 /** Flag for current encoding decoder */
39 #define BUF_MGR_CODEC        (1 << 1)
40 
41 /** Flag for reference status */
42 #define BUF_MGR_REF          (1 << 2)
43 
44 /** Flag for I/O - Display/output in case of decoder, capture/input in case of encoder */
45 #define BUF_MGR_IO           (1 << 3)
46 
47 typedef struct
48 {
49     /**
50      * Mutex used to keep the functions thread-safe
51      */
52     void *pv_mutex;
53 
54     /**
55      * max_buf_cnt
56      */
57     WORD32 i4_max_buf_cnt;
58 
59     /**
60      * active_buf_cnt
61      */
62     WORD32 i4_active_buf_cnt;
63 
64     /**
65      *  au4_status[BUF_MGR_MAX_CNT]
66      */
67     UWORD32 au4_status[BUF_MGR_MAX_CNT];
68 
69     /* The last three bit of status are:    */
70 
71     /* Bit 0 - IN USE                       */
72     /* Bit 1 - CODEC                        */
73     /* Bit 2 - REF                          */
74     /* Bit 3 - DISP/IO/RECON                */
75     void    *apv_ptr[BUF_MGR_MAX_CNT];
76 
77 }buf_mgr_t;
78 
79 // Returns size of the buffer manager context
80 WORD32 ih264_buf_mgr_size(void);
81 
82 //Free buffer manager
83 IH264_ERROR_T ih264_buf_mgr_free(buf_mgr_t *ps_buf_mgr);
84 
85 // Initializes the buffer API structure
86 void *ih264_buf_mgr_init(void *pv_buf);
87 
88 // Add buffer to buffer manager. 0: success, -1: fail (u4_active_buf_cnt has reached u4_max_buf_cnt)
89 IH264_ERROR_T ih264_buf_mgr_add(buf_mgr_t *ps_buf_mgr,
90                                 void *pv_ptr,
91                                 WORD32 buf_id);
92 
93 // this function will set the buffer status to DEC
94 void* ih264_buf_mgr_get_next_free(buf_mgr_t *ps_buf_mgr, WORD32 *pi4_id);
95 
96 // this function will check if there are any free buffers
97 IH264_ERROR_T ih264_buf_mgr_check_free(buf_mgr_t *ps_buf_mgr);
98 
99 // mask will have who released it: DISP:REF:DEC
100 IH264_ERROR_T ih264_buf_mgr_release(buf_mgr_t *ps_buf_mgr,
101                                     WORD32 id,
102                                     UWORD32 mask);
103 
104 // sets the status to one or all of DISP:REF:DEC
105 IH264_ERROR_T ih264_buf_mgr_set_status(buf_mgr_t *ps_buf_mgr,
106                                        WORD32 id,
107                                        UWORD32 mask);
108 
109 // Gets status of the buffer
110 WORD32 ih264_buf_mgr_get_status(buf_mgr_t *ps_buf_mgr, WORD32 id);
111 
112 // pass the ID - buffer will be returned
113 void* ih264_buf_mgr_get_buf(buf_mgr_t *ps_buf_mgr, WORD32 id);
114 //Pass buffer to get ID
115 WORD32 ih264_buf_mgr_get_bufid(buf_mgr_t *ps_buf_mgr, void *pv_buf);
116 
117 // will return number of active buffers
118 UWORD32 ih264_buf_mgr_get_num_active_buf(buf_mgr_t *ps_buf_mgr);
119 
120 
121 
122 #endif  /* _IH264_BUF_MGR_H_ */
123