• 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 *  impeg2_buf_mgr.h
24 *
25 * @brief
26 *  Function declarations used for buffer management
27 *
28 * @author
29 *  Srinivas T
30 *
31 * @remarks
32 *  None
33 *
34 *******************************************************************************
35 */
36 #ifndef _IMPEG2_BUF_MGR_H_
37 #define _IMPEG2_BUF_MGR_H_
38 
39 #define BUF_MGR_MAX_CNT 64
40 
41 #define BUF_MGR_DEC         1
42 #define BUF_MGR_REF         (1 << 1)
43 #define BUF_MGR_DISP        (1 << 2)
44 
45 typedef struct
46 {
47     /**
48      * max_buf_cnt
49      */
50     UWORD32 u4_max_buf_cnt;
51 
52     /**
53      * active_buf_cnt
54      */
55     UWORD32 u4_active_buf_cnt;
56     /**
57      *  au4_status[BUF_MGR_MAX_CNT]
58      */
59     UWORD32 au4_status[BUF_MGR_MAX_CNT];
60     /* The last three bit of status are:    */
61     /* Bit 0 - DEC                          */
62     /* Bit 1 - REF                          */
63     /* Bit 2 - DISP                         */
64 
65     void    *apv_ptr[BUF_MGR_MAX_CNT];
66 }buf_mgr_t;
67 
68 // intializes the buffer API structure
69 void impeg2_buf_mgr_init(
70                 buf_mgr_t *ps_buf_mgr);
71 
72 // Add buffer to buffer manager. 0: success, -1: fail (u4_active_buf_cnt has reached u4_max_buf_cnt)
73 WORD32 impeg2_buf_mgr_add(
74                 buf_mgr_t *ps_buf_mgr,
75                 void *pv_ptr,
76                 WORD32 buf_id);
77 
78 // this function will set the buffer status to DEC
79 void* impeg2_buf_mgr_get_next_free(
80                 buf_mgr_t *ps_buf_mgr,
81                 WORD32 *pi4_id);
82 
83 // this function will check if there are any free buffers
84 WORD32 impeg2_buf_mgr_check_free(
85                 buf_mgr_t *ps_buf_mgr);
86 
87 // mask will have who released it: DISP:REF:DEC
88 WORD32 impeg2_buf_mgr_release(
89                 buf_mgr_t *ps_buf_mgr,
90                 WORD32 id,
91                 UWORD32 mask);
92 
93 // sets the status to one or all of DISP:REF:DEC
94 WORD32 impeg2_buf_mgr_set_status(
95                 buf_mgr_t *ps_buf_mgr,
96                 WORD32 id,
97                 UWORD32 mask);
98 
99 // Gets status of the buffer
100 UWORD32 impeg2_buf_mgr_get_status(
101                 buf_mgr_t *ps_buf_mgr,
102                 WORD32 id);
103 
104 // pass the ID - buffer will be returned
105 void* impeg2_buf_mgr_get_buf(
106                 buf_mgr_t *ps_buf_mgr,
107                 WORD32 id);
108 
109 // will return number of active buffers
110 UWORD32 impeg2_buf_mgr_get_num_active_buf(
111                 buf_mgr_t *ps_buf_mgr);
112 
113 
114 
115 #endif  //_IMPEG2_BUF_MGR_H_
116