• 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 // Reset the buffer manager
86 void ih264_buf_mgr_reset(void *pv_buf_mgr);
87 
88 // Initializes the buffer API structure
89 void *ih264_buf_mgr_init(void *pv_buf);
90 
91 // Add buffer to buffer manager. 0: success, -1: fail (u4_active_buf_cnt has reached u4_max_buf_cnt)
92 IH264_ERROR_T ih264_buf_mgr_add(buf_mgr_t *ps_buf_mgr,
93                                 void *pv_ptr,
94                                 WORD32 buf_id);
95 
96 // this function will set the buffer status to DEC
97 void* ih264_buf_mgr_get_next_free(buf_mgr_t *ps_buf_mgr, WORD32 *pi4_id);
98 
99 // this function will check if there are any free buffers
100 IH264_ERROR_T ih264_buf_mgr_check_free(buf_mgr_t *ps_buf_mgr);
101 
102 // mask will have who released it: DISP:REF:DEC
103 IH264_ERROR_T ih264_buf_mgr_release(buf_mgr_t *ps_buf_mgr,
104                                     WORD32 id,
105                                     UWORD32 mask);
106 
107 // sets the status to one or all of DISP:REF:DEC
108 IH264_ERROR_T ih264_buf_mgr_set_status(buf_mgr_t *ps_buf_mgr,
109                                        WORD32 id,
110                                        UWORD32 mask);
111 
112 // Gets status of the buffer
113 WORD32 ih264_buf_mgr_get_status(buf_mgr_t *ps_buf_mgr, WORD32 id);
114 
115 // pass the ID - buffer will be returned
116 void* ih264_buf_mgr_get_buf(buf_mgr_t *ps_buf_mgr, WORD32 id);
117 //Pass buffer to get ID
118 WORD32 ih264_buf_mgr_get_bufid(buf_mgr_t *ps_buf_mgr, void *pv_buf);
119 
120 // will return number of active buffers
121 UWORD32 ih264_buf_mgr_get_num_active_buf(buf_mgr_t *ps_buf_mgr);
122 
123 
124 
125 #endif  /* _IH264_BUF_MGR_H_ */
126