xref: /aosp_15_r20/external/libavc/common/ih264_buf_mgr.h (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
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 *******************************************************************************
23 * @file
24 *  ih264_buf_mgr.h
25 *
26 * @brief
27 *  Function declarations used for buffer management
28 *
29 * @author
30 *  ittiam
31 *
32 * @remarks
33 *  none
34 *
35 *******************************************************************************
36 */
37 
38 #ifndef _IH264_BUF_MGR_H_
39 #define _IH264_BUF_MGR_H_
40 
41 /*****************************************************************************/
42 /* Constant Macros                                                           */
43 /*****************************************************************************/
44 #define BUF_MGR_MAX_CNT 64
45 
46 /** Flag for current encoding decoder */
47 #define BUF_MGR_CODEC        (1 << 1)
48 
49 /** Flag for reference status */
50 #define BUF_MGR_REF          (1 << 2)
51 
52 /** Flag for I/O - Display/output in case of decoder, capture/input in case of encoder */
53 #define BUF_MGR_IO           (1 << 3)
54 
55 /*****************************************************************************/
56 /* Structure Definitions                                                     */
57 /*****************************************************************************/
58 typedef struct
59 {
60     /**
61      * Mutex used to keep the functions thread-safe
62      */
63     void *pv_mutex;
64 
65     /**
66      * max_buf_cnt
67      */
68     WORD32 i4_max_buf_cnt;
69 
70     /**
71      * active_buf_cnt
72      */
73     WORD32 i4_active_buf_cnt;
74 
75     /* The last three bit of status are:    */
76     /* Bit 0 - IN USE                       */
77     /* Bit 1 - CODEC                        */
78     /* Bit 2 - REF                          */
79     /* Bit 3 - DISP/IO/RECON                */
80     UWORD32 au4_status[BUF_MGR_MAX_CNT];
81 
82     /**
83      * pointer to buffer
84      */
85     void *apv_ptr[BUF_MGR_MAX_CNT];
86 
87 }buf_mgr_t;
88 
89 /*****************************************************************************/
90 /* Function Declarations                                                     */
91 /*****************************************************************************/
92 WORD32 ih264_buf_mgr_size(void);
93 
94 IH264_ERROR_T ih264_buf_mgr_free(buf_mgr_t *ps_buf_mgr);
95 
96 void *ih264_buf_mgr_init(void *pv_buf);
97 
98 void ih264_buf_mgr_reset(void *pv_buf_mgr);
99 
100 IH264_ERROR_T ih264_buf_mgr_add(buf_mgr_t *ps_buf_mgr, void *pv_ptr,
101                                 WORD32 buf_id);
102 
103 void* ih264_buf_mgr_get_next_free(buf_mgr_t *ps_buf_mgr, WORD32 *pi4_id);
104 
105 IH264_ERROR_T ih264_buf_mgr_check_free(buf_mgr_t *ps_buf_mgr);
106 
107 IH264_ERROR_T ih264_buf_mgr_release(buf_mgr_t *ps_buf_mgr, WORD32 id,
108                                     UWORD32 mask);
109 
110 IH264_ERROR_T ih264_buf_mgr_set_status(buf_mgr_t *ps_buf_mgr, WORD32 id,
111                                        UWORD32 mask);
112 
113 WORD32 ih264_buf_mgr_get_status(buf_mgr_t *ps_buf_mgr, WORD32 id);
114 
115 void* ih264_buf_mgr_get_buf(buf_mgr_t *ps_buf_mgr, WORD32 id);
116 
117 WORD32 ih264_buf_mgr_get_bufid(buf_mgr_t *ps_buf_mgr, void *pv_buf);
118 
119 UWORD32 ih264_buf_mgr_get_num_active_buf(buf_mgr_t *ps_buf_mgr);
120 
121 #endif  /* _IH264_BUF_MGR_H_ */
122