/src/libhevc/common/ihevc_disp_mgr.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore |
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 | | /** |
19 | | ******************************************************************************* |
20 | | * @file |
21 | | * ihevc_disp_mgr.c |
22 | | * |
23 | | * @brief |
24 | | * Contains function definitions for display management |
25 | | * |
26 | | * @author |
27 | | * Srinivas T |
28 | | * |
29 | | * @par List of Functions: |
30 | | * - ihevc_disp_mgr_init() |
31 | | * - ihevc_disp_mgr_add() |
32 | | * - ihevc_disp_mgr_get() |
33 | | * |
34 | | * @remarks |
35 | | * None |
36 | | * |
37 | | ******************************************************************************* |
38 | | */ |
39 | | #include <stdlib.h> |
40 | | #include "ihevc_typedefs.h" |
41 | | #include "ihevc_macros.h" |
42 | | #include "ihevc_func_selector.h" |
43 | | #include "ihevc_disp_mgr.h" |
44 | | |
45 | | |
46 | | /** |
47 | | ******************************************************************************* |
48 | | * |
49 | | * @brief |
50 | | * Initialization function for display buffer manager |
51 | | * |
52 | | * @par Description: |
53 | | * Initializes the display buffer management structure |
54 | | * |
55 | | * @param[in] ps_disp_mgr |
56 | | * Pointer to the display buffer management structure |
57 | | * |
58 | | * @returns none |
59 | | * |
60 | | * @remarks |
61 | | * None |
62 | | * |
63 | | ******************************************************************************* |
64 | | */ |
65 | | void ihevc_disp_mgr_init( |
66 | | disp_mgr_t *ps_disp_mgr) |
67 | 1.09k | { |
68 | 1.09k | WORD32 id; |
69 | | |
70 | 1.09k | ps_disp_mgr->u4_last_abs_poc = DEFAULT_POC; |
71 | | |
72 | 71.3k | for(id = 0; id < DISP_MGR_MAX_CNT; id++) |
73 | 70.2k | { |
74 | 70.2k | ps_disp_mgr->ai4_abs_poc[id] = DEFAULT_POC; |
75 | 70.2k | ps_disp_mgr->apv_ptr[id] = NULL; |
76 | 70.2k | } |
77 | 1.09k | } |
78 | | |
79 | | |
80 | | /** |
81 | | ******************************************************************************* |
82 | | * |
83 | | * @brief |
84 | | * Adds a buffer to the display manager |
85 | | * |
86 | | * @par Description: |
87 | | * Adds a buffer to the display buffer manager |
88 | | * |
89 | | * @param[in] ps_disp_mgr |
90 | | * Pointer to the diaplay buffer management structure |
91 | | * |
92 | | * @param[in] buf_id |
93 | | * ID of the display buffer |
94 | | * |
95 | | * @param[in] abs_poc |
96 | | * Absolute POC of the display buffer |
97 | | * |
98 | | * @param[in] pv_ptr |
99 | | * Pointer to the display buffer |
100 | | * |
101 | | * @returns 0 if success, -1 otherwise |
102 | | * |
103 | | * @remarks |
104 | | * None |
105 | | * |
106 | | ******************************************************************************* |
107 | | */ |
108 | | WORD32 ihevc_disp_mgr_add(disp_mgr_t *ps_disp_mgr, |
109 | | WORD32 buf_id, |
110 | | WORD32 abs_poc, |
111 | | void *pv_ptr) |
112 | 12.2k | { |
113 | 12.2k | if(buf_id >= DISP_MGR_MAX_CNT) |
114 | 0 | { |
115 | 0 | return (-1); |
116 | 0 | } |
117 | | |
118 | 12.2k | if(ps_disp_mgr->apv_ptr[buf_id] != NULL) |
119 | 0 | { |
120 | 0 | return (-1); |
121 | 0 | } |
122 | | |
123 | 12.2k | ps_disp_mgr->apv_ptr[buf_id] = pv_ptr; |
124 | 12.2k | ps_disp_mgr->ai4_abs_poc[buf_id] = abs_poc; |
125 | 12.2k | return 0; |
126 | 12.2k | } |
127 | | |
128 | | |
129 | | /** |
130 | | ******************************************************************************* |
131 | | * |
132 | | * @brief |
133 | | * Gets the next buffer |
134 | | * |
135 | | * @par Description: |
136 | | * Gets the next display buffer |
137 | | * |
138 | | * @param[in] ps_disp_mgr |
139 | | * Pointer to the display buffer structure |
140 | | * |
141 | | * @param[out] pi4_buf_id |
142 | | * Pointer to hold buffer id of the display buffer being returned |
143 | | * |
144 | | * @returns Pointer to the next display buffer |
145 | | * |
146 | | * @remarks |
147 | | * None |
148 | | * |
149 | | ******************************************************************************* |
150 | | */ |
151 | | void* ihevc_disp_mgr_get( |
152 | | disp_mgr_t *ps_disp_mgr, |
153 | | WORD32 *pi4_buf_id) |
154 | 11.6k | { |
155 | 11.6k | WORD32 id; |
156 | 11.6k | void *pv_ret_ptr; |
157 | 11.6k | WORD32 i4_min_poc; |
158 | 11.6k | WORD32 min_poc_id; |
159 | | |
160 | | |
161 | 11.6k | pv_ret_ptr = NULL; |
162 | 11.6k | i4_min_poc = 0x7FFFFFFF; |
163 | 11.6k | min_poc_id = -1; |
164 | | |
165 | | /* Find minimum POC */ |
166 | 755k | for(id = 0; id < DISP_MGR_MAX_CNT; id++) |
167 | 743k | { |
168 | 743k | if((DEFAULT_POC != ps_disp_mgr->ai4_abs_poc[id]) && |
169 | 743k | (ps_disp_mgr->ai4_abs_poc[id] <= i4_min_poc)) |
170 | 16.2k | { |
171 | 16.2k | i4_min_poc = ps_disp_mgr->ai4_abs_poc[id]; |
172 | 16.2k | min_poc_id = id; |
173 | 16.2k | } |
174 | 743k | } |
175 | 11.6k | *pi4_buf_id = min_poc_id; |
176 | | /* If all pocs are still default_poc then return NULL */ |
177 | 11.6k | if(-1 == min_poc_id) |
178 | 4 | { |
179 | 4 | return NULL; |
180 | 4 | } |
181 | | |
182 | 11.6k | pv_ret_ptr = ps_disp_mgr->apv_ptr[min_poc_id]; |
183 | | |
184 | | /* Set abs poc to default and apv_ptr to null so that the buffer is not returned again */ |
185 | 11.6k | ps_disp_mgr->apv_ptr[min_poc_id] = NULL; |
186 | 11.6k | ps_disp_mgr->ai4_abs_poc[min_poc_id] = DEFAULT_POC; |
187 | 11.6k | return pv_ret_ptr; |
188 | 11.6k | } |