/src/libhevc/decoder/ihevcd_ref_list.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 | | * ihevcd_api.c |
22 | | * |
23 | | * @brief |
24 | | * Contains functions definitions for reference list generation |
25 | | * |
26 | | * @author |
27 | | * Srinivas T |
28 | | * |
29 | | * @par List of Functions:\ |
30 | | * - ihevcd_ref_pic |
31 | | * |
32 | | * @remarks |
33 | | * None |
34 | | * |
35 | | ******************************************************************************* |
36 | | */ |
37 | | |
38 | | /*****************************************************************************/ |
39 | | /* File Includes */ |
40 | | /*****************************************************************************/ |
41 | | #include <stdio.h> |
42 | | #include <stddef.h> |
43 | | #include <stdlib.h> |
44 | | #include <string.h> |
45 | | #include <assert.h> |
46 | | |
47 | | #include "ihevc_typedefs.h" |
48 | | #include "iv.h" |
49 | | #include "ivd.h" |
50 | | #include "ihevcd_cxa.h" |
51 | | |
52 | | #include "ihevc_defs.h" |
53 | | #include "ihevc_debug.h" |
54 | | #include "ihevc_defs.h" |
55 | | #include "ihevc_macros.h" |
56 | | #include "ihevc_platform_macros.h" |
57 | | #include "ihevc_structs.h" |
58 | | #include "ihevc_buf_mgr.h" |
59 | | #include "ihevc_dpb_mgr.h" |
60 | | |
61 | | #include "ihevcd_trace.h" |
62 | | #include "ihevcd_defs.h" |
63 | | #include "ihevc_cabac_tables.h" |
64 | | #include "ihevcd_function_selector.h" |
65 | | #include "ihevcd_structs.h" |
66 | | #include "ihevcd_error.h" |
67 | | #include "ihevcd_nal.h" |
68 | | #include "ihevcd_bitstream.h" |
69 | | #include "ihevcd_debug.h" |
70 | | #include "ihevcd_error.h" |
71 | | |
72 | | |
73 | | mv_buf_t* ihevcd_mv_mgr_get_poc(buf_mgr_t *ps_mv_buf_mgr, UWORD32 abs_poc) |
74 | 29.7k | { |
75 | 29.7k | UWORD32 i; |
76 | 29.7k | mv_buf_t *ps_mv_buf = NULL; |
77 | | |
78 | | |
79 | | |
80 | 79.3k | for(i = 0; i < ps_mv_buf_mgr->u4_max_buf_cnt; i++) |
81 | 79.3k | { |
82 | 79.3k | ps_mv_buf = (mv_buf_t *)ps_mv_buf_mgr->apv_ptr[i]; |
83 | 79.3k | if(ps_mv_buf && (ps_mv_buf->i4_abs_poc == (WORD32)abs_poc)) |
84 | 29.7k | { |
85 | 29.7k | break; |
86 | 29.7k | } |
87 | 79.3k | } |
88 | | |
89 | 29.7k | return ps_mv_buf; |
90 | 29.7k | } |
91 | | |
92 | | |
93 | | WORD32 ihevcd_ref_list(codec_t *ps_codec, pps_t *ps_pps, sps_t *ps_sps, slice_header_t *ps_slice_hdr) |
94 | 5.78k | { |
95 | 5.78k | WORD32 i, j; |
96 | 5.78k | WORD32 st_rps_idx; |
97 | 5.78k | WORD32 num_neg_pics, num_pos_pics; |
98 | 5.78k | WORD8 *pi1_used; |
99 | 5.78k | WORD16 *pi2_delta_poc; |
100 | 5.78k | UWORD32 u4_max_poc_lsb; |
101 | 5.78k | pic_buf_t *ps_pic_buf; |
102 | 5.78k | mv_buf_t *ps_mv_buf; |
103 | 5.78k | UWORD32 r_idx; |
104 | | |
105 | 5.78k | dpb_mgr_t *ps_dpb_mgr = (dpb_mgr_t *)ps_codec->pv_dpb_mgr; |
106 | 5.78k | buf_mgr_t *ps_mv_buf_mgr = (buf_mgr_t *)ps_codec->pv_mv_buf_mgr; |
107 | | |
108 | 5.78k | WORD32 ai4_poc_st_curr_before[MAX_DPB_SIZE], ai4_poc_st_foll[MAX_DPB_SIZE], ai4_poc_st_curr_after[MAX_DPB_SIZE]; |
109 | 5.78k | WORD32 ai4_poc_lt_curr[MAX_DPB_SIZE], ai4_poc_lt_foll[MAX_DPB_SIZE]; |
110 | 5.78k | UWORD32 u4_num_st_curr_before, u4_num_st_foll, u4_num_st_curr_after, u4_num_lt_curr, u4_num_lt_foll; |
111 | 5.78k | UWORD32 u4_num_total_curr; |
112 | | |
113 | 5.78k | WORD8 ai1_curr_delta_poc_msb_present_flag[MAX_DPB_SIZE], ai1_foll_delta_poc_msb_present_flag[MAX_DPB_SIZE]; |
114 | | |
115 | 5.78k | pic_buf_t *as_ref_pic_lt_curr[MAX_DPB_SIZE]; |
116 | 5.78k | pic_buf_t *as_ref_pic_lt_foll[MAX_DPB_SIZE]; |
117 | 5.78k | pic_buf_t *as_ref_pic_st_curr_after[MAX_DPB_SIZE]; |
118 | 5.78k | pic_buf_t *as_ref_pic_st_curr_before[MAX_DPB_SIZE]; |
119 | 5.78k | pic_buf_t *as_ref_pic_st_foll[MAX_DPB_SIZE]; |
120 | | |
121 | 5.78k | pic_buf_t *as_ref_pic_list_temp0[MAX_DPB_SIZE], *as_ref_pic_list_temp1[MAX_DPB_SIZE]; |
122 | | |
123 | 5.78k | UWORD32 u4_num_rps_curr_temp_list0, u4_num_rps_curr_temp_list1; |
124 | | |
125 | 5.78k | WORD32 i4_pic_order_cnt_val; |
126 | 5.78k | WORD32 i4_poc_lt; |
127 | 5.78k | UNUSED(as_ref_pic_lt_foll); |
128 | 5.78k | UNUSED(as_ref_pic_st_foll); |
129 | 5.78k | UNUSED(ps_pps); |
130 | | |
131 | 5.78k | RETURN_IF_NAL_INFO; |
132 | | |
133 | 5.78k | u4_max_poc_lsb = (1 << ps_sps->i1_log2_max_pic_order_cnt_lsb); |
134 | | |
135 | 5.78k | i4_pic_order_cnt_val = ps_slice_hdr->i4_abs_pic_order_cnt; |
136 | | |
137 | 5.78k | if(1 == ps_slice_hdr->i1_short_term_ref_pic_set_sps_flag) |
138 | 5.73k | { |
139 | 5.73k | st_rps_idx = ps_slice_hdr->i1_short_term_ref_pic_set_idx; |
140 | 5.73k | num_neg_pics = ps_sps->as_stref_picset[st_rps_idx].i1_num_neg_pics; |
141 | 5.73k | num_pos_pics = ps_sps->as_stref_picset[st_rps_idx].i1_num_pos_pics; |
142 | 5.73k | pi1_used = ps_sps->as_stref_picset[st_rps_idx].ai1_used; |
143 | 5.73k | pi2_delta_poc = ps_sps->as_stref_picset[st_rps_idx].ai2_delta_poc; |
144 | 5.73k | } |
145 | 47 | else |
146 | 47 | { |
147 | 47 | st_rps_idx = ps_sps->i1_num_short_term_ref_pic_sets; |
148 | 47 | num_neg_pics = ps_slice_hdr->s_stref_picset.i1_num_neg_pics; |
149 | 47 | num_pos_pics = ps_slice_hdr->s_stref_picset.i1_num_pos_pics; |
150 | 47 | pi1_used = ps_slice_hdr->s_stref_picset.ai1_used; |
151 | 47 | pi2_delta_poc = ps_slice_hdr->s_stref_picset.ai2_delta_poc; |
152 | 47 | } |
153 | | |
154 | 5.78k | u4_num_st_curr_before = 0; |
155 | 5.78k | u4_num_st_foll = 0; |
156 | 18.5k | for(i = 0; i < num_neg_pics; i++) |
157 | 12.7k | { |
158 | 12.7k | if(pi1_used[i]) |
159 | 12.5k | { |
160 | 12.5k | ai4_poc_st_curr_before[u4_num_st_curr_before] = i4_pic_order_cnt_val + pi2_delta_poc[i]; |
161 | 12.5k | u4_num_st_curr_before++; |
162 | 12.5k | } |
163 | 187 | else |
164 | 187 | { |
165 | 187 | ai4_poc_st_foll[u4_num_st_foll] = i4_pic_order_cnt_val + pi2_delta_poc[i]; |
166 | 187 | u4_num_st_foll++; |
167 | 187 | } |
168 | 12.7k | } |
169 | 5.78k | u4_num_st_curr_after = 0; |
170 | 15.1k | for(i = num_neg_pics; i < num_neg_pics + num_pos_pics; i++) |
171 | 9.34k | { |
172 | 9.34k | if(pi1_used[i]) |
173 | 9.34k | { |
174 | 9.34k | ai4_poc_st_curr_after[u4_num_st_curr_after] = i4_pic_order_cnt_val + pi2_delta_poc[i]; |
175 | 9.34k | u4_num_st_curr_after++; |
176 | 9.34k | } |
177 | 0 | else |
178 | 0 | { |
179 | 0 | ai4_poc_st_foll[u4_num_st_foll] = i4_pic_order_cnt_val + pi2_delta_poc[i]; |
180 | 0 | u4_num_st_foll++; |
181 | 0 | } |
182 | 9.34k | } |
183 | | |
184 | 5.78k | u4_num_lt_curr = 0; |
185 | 5.78k | u4_num_lt_foll = 0; |
186 | 5.78k | for(i = 0; i < ps_slice_hdr->i1_num_long_term_sps + ps_slice_hdr->i1_num_long_term_pics; i++) |
187 | 0 | { |
188 | 0 | i4_poc_lt = ps_slice_hdr->ai4_poc_lsb_lt[i]; |
189 | 0 | if(ps_slice_hdr->ai1_delta_poc_msb_present_flag[i]) |
190 | 0 | { |
191 | 0 | i4_poc_lt += i4_pic_order_cnt_val - ps_slice_hdr->ai1_delta_poc_msb_cycle_lt[i] * (WORD32)u4_max_poc_lsb - ps_slice_hdr->i4_pic_order_cnt_lsb; |
192 | 0 | } |
193 | |
|
194 | 0 | if(ps_slice_hdr->ai1_used_by_curr_pic_lt_flag[i]) |
195 | 0 | { |
196 | 0 | ai4_poc_lt_curr[u4_num_lt_curr] = i4_poc_lt; |
197 | 0 | ai1_curr_delta_poc_msb_present_flag[u4_num_lt_curr] = ps_slice_hdr->ai1_delta_poc_msb_present_flag[i]; |
198 | 0 | u4_num_lt_curr++; |
199 | 0 | } |
200 | 0 | else |
201 | 0 | { |
202 | 0 | ai4_poc_lt_foll[u4_num_lt_foll] = i4_poc_lt; |
203 | 0 | ai1_foll_delta_poc_msb_present_flag[u4_num_lt_foll] = ps_slice_hdr->ai1_delta_poc_msb_present_flag[i]; |
204 | 0 | u4_num_lt_foll++; |
205 | 0 | } |
206 | 0 | } |
207 | | |
208 | 5.78k | u4_num_total_curr = u4_num_lt_curr + u4_num_st_curr_after + u4_num_st_curr_before; |
209 | | |
210 | | /* Bit stream conformance tests */ |
211 | | /* |
212 | | for(i = 0; i < u4_num_lt_curr; i++) |
213 | | { |
214 | | int j; |
215 | | if(ai1_curr_delta_poc_msb_present_flag[i]) |
216 | | { |
217 | | for(j = 0; j < u4_num_st_curr_before; j++) |
218 | | { |
219 | | ASSERT(ai4_poc_st_curr_before[j] != ai4_poc_lt_curr[i]); |
220 | | } |
221 | | for(j = 0; j < u4_num_st_curr_after; j++) |
222 | | { |
223 | | ASSERT(ai4_poc_st_curr_after[j] != ai4_poc_lt_curr[i]); |
224 | | } |
225 | | for(j = 0; j < u4_num_st_foll; j++) |
226 | | { |
227 | | ASSERT(ai4_poc_st_foll[j] != ai4_poc_lt_curr[i]); |
228 | | } |
229 | | for(j = 0; j < u4_num_lt_curr; j++) |
230 | | { |
231 | | ASSERT((ai4_poc_lt_curr[j] != ai4_poc_lt_curr[i]) || (j == i)); |
232 | | } |
233 | | } |
234 | | else |
235 | | { |
236 | | for(j = 0; j < u4_num_st_curr_before; j++) |
237 | | { |
238 | | ASSERT((ai4_poc_st_curr_before[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_curr[i]); |
239 | | } |
240 | | for(j = 0; j < u4_num_st_curr_after; j++) |
241 | | { |
242 | | ASSERT((ai4_poc_st_curr_after[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_curr[i]); |
243 | | } |
244 | | for(j = 0; j < u4_num_st_foll; j++) |
245 | | { |
246 | | ASSERT((ai4_poc_st_foll[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_curr[i]); |
247 | | } |
248 | | for(j = 0; j < u4_num_lt_curr; j++) |
249 | | { |
250 | | ASSERT(((ai4_poc_lt_curr[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_curr[i]) || (j == i)); |
251 | | } |
252 | | } |
253 | | } |
254 | | |
255 | | for(i = 0; i < u4_num_lt_foll; i++) |
256 | | { |
257 | | int j; |
258 | | if(ai1_foll_delta_poc_msb_present_flag[i]) |
259 | | { |
260 | | for(j = 0; j < u4_num_st_curr_before; j++) |
261 | | { |
262 | | ASSERT(ai4_poc_st_curr_before[j] != ai4_poc_lt_foll[i]); |
263 | | } |
264 | | for(j = 0; j < u4_num_st_curr_after; j++) |
265 | | { |
266 | | ASSERT(ai4_poc_st_curr_after[j] != ai4_poc_lt_foll[i]); |
267 | | } |
268 | | for(j = 0; j < u4_num_st_foll; j++) |
269 | | { |
270 | | ASSERT(ai4_poc_st_foll[j] != ai4_poc_lt_foll[i]); |
271 | | } |
272 | | for(j = 0; j < u4_num_lt_curr; j++) |
273 | | { |
274 | | ASSERT(ai4_poc_lt_curr[j] != ai4_poc_lt_foll[i]); |
275 | | } |
276 | | for(j = 0; j < u4_num_lt_foll; j++) |
277 | | { |
278 | | ASSERT((ai4_poc_lt_foll[j] != ai4_poc_lt_foll[i]) || (j == i)); |
279 | | } |
280 | | } |
281 | | else |
282 | | { |
283 | | for(j = 0; j < u4_num_st_curr_before; j++) |
284 | | { |
285 | | ASSERT((ai4_poc_st_curr_before[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_foll[i]); |
286 | | } |
287 | | for(j = 0; j < u4_num_st_curr_after; j++) |
288 | | { |
289 | | ASSERT((ai4_poc_st_curr_after[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_foll[i]); |
290 | | } |
291 | | for(j = 0; j < u4_num_st_foll; j++) |
292 | | { |
293 | | ASSERT((ai4_poc_st_foll[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_foll[i]); |
294 | | } |
295 | | for(j = 0; j < u4_num_lt_curr; j++) |
296 | | { |
297 | | ASSERT((ai4_poc_lt_curr[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_foll[i]); |
298 | | } |
299 | | for(j = 0; j < u4_num_lt_foll; j++) |
300 | | { |
301 | | ASSERT(((ai4_poc_lt_foll[j] & (u4_max_poc_lsb - 1)) != ai4_poc_lt_foll[i]) || (j == i)); |
302 | | } |
303 | | } |
304 | | } |
305 | | */ |
306 | | |
307 | | |
308 | | /* Reference Pic sets creation */ |
309 | | |
310 | | /* Set all the DPB buffers to UNUSED_FOR_REF */ |
311 | 5.78k | if(0 == ps_codec->i4_pic_present) |
312 | 949 | { |
313 | 61.6k | for(i = 0; i < MAX_DPB_BUFS; i++) |
314 | 60.7k | { |
315 | 60.7k | if(ps_dpb_mgr->as_dpb_info[i].ps_pic_buf) |
316 | 3.79k | ps_dpb_mgr->as_dpb_info[i].ps_pic_buf->u1_used_as_ref = UNUSED_FOR_REF; |
317 | 60.7k | } |
318 | 949 | } |
319 | | |
320 | 5.78k | for(i = 0; i < (WORD32)u4_num_lt_curr; i++) |
321 | 0 | { |
322 | 0 | if(0 == ai1_curr_delta_poc_msb_present_flag[i]) |
323 | 0 | { |
324 | 0 | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc_lsb(ps_dpb_mgr, ai4_poc_lt_curr[i]); |
325 | 0 | if(NULL != ps_pic_buf) |
326 | 0 | ps_pic_buf->u1_used_as_ref = LONG_TERM_REF; |
327 | |
|
328 | 0 | as_ref_pic_lt_curr[i] = ps_pic_buf; |
329 | 0 | } |
330 | 0 | else |
331 | 0 | { |
332 | 0 | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc(ps_dpb_mgr, ai4_poc_lt_curr[i]); |
333 | 0 | if(NULL != ps_pic_buf) |
334 | 0 | ps_pic_buf->u1_used_as_ref = LONG_TERM_REF; |
335 | |
|
336 | 0 | as_ref_pic_lt_curr[i] = ps_pic_buf; |
337 | 0 | } |
338 | 0 | } |
339 | | |
340 | 5.78k | for(i = 0; i < (WORD32)u4_num_lt_foll; i++) |
341 | 0 | { |
342 | 0 | if(0 == ai1_foll_delta_poc_msb_present_flag[i]) |
343 | 0 | { |
344 | 0 | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc_lsb(ps_dpb_mgr, ai4_poc_lt_foll[i]); |
345 | 0 | if(NULL != ps_pic_buf) |
346 | 0 | ps_pic_buf->u1_used_as_ref = LONG_TERM_REF; |
347 | |
|
348 | 0 | as_ref_pic_lt_foll[i] = ps_pic_buf; |
349 | 0 | } |
350 | 0 | else |
351 | 0 | { |
352 | 0 | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc(ps_dpb_mgr, ai4_poc_lt_foll[i]); |
353 | 0 | if(NULL != ps_pic_buf) |
354 | 0 | ps_pic_buf->u1_used_as_ref = LONG_TERM_REF; |
355 | |
|
356 | 0 | as_ref_pic_lt_foll[i] = ps_pic_buf; |
357 | 0 | } |
358 | 0 | } |
359 | | |
360 | | |
361 | 18.3k | for(i = 0; i < (WORD32)u4_num_st_curr_before; i++) |
362 | 12.5k | { |
363 | | |
364 | 12.5k | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc(ps_dpb_mgr, ai4_poc_st_curr_before[i]); |
365 | 12.5k | if(NULL != ps_pic_buf) |
366 | 11.3k | ps_pic_buf->u1_used_as_ref = SHORT_TERM_REF; |
367 | | |
368 | 12.5k | as_ref_pic_st_curr_before[i] = ps_pic_buf; |
369 | 12.5k | } |
370 | | |
371 | 15.1k | for(i = 0; i < (WORD32)u4_num_st_curr_after; i++) |
372 | 9.34k | { |
373 | 9.34k | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc(ps_dpb_mgr, ai4_poc_st_curr_after[i]); |
374 | 9.34k | if(NULL != ps_pic_buf) |
375 | 8.91k | ps_pic_buf->u1_used_as_ref = SHORT_TERM_REF; |
376 | | |
377 | 9.34k | as_ref_pic_st_curr_after[i] = ps_pic_buf; |
378 | 9.34k | } |
379 | | |
380 | 5.96k | for(i = 0; i < (WORD32)u4_num_st_foll; i++) |
381 | 187 | { |
382 | 187 | ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc(ps_dpb_mgr, ai4_poc_st_foll[i]); |
383 | 187 | if(NULL != ps_pic_buf) |
384 | 172 | ps_pic_buf->u1_used_as_ref = SHORT_TERM_REF; |
385 | | |
386 | 187 | as_ref_pic_st_foll[i] = ps_pic_buf; |
387 | 187 | } |
388 | | |
389 | | //TODO: Bit stream conformance tests to be included |
390 | | |
391 | 5.78k | u4_num_rps_curr_temp_list0 = (WORD32)u4_num_total_curr > ps_slice_hdr->i1_num_ref_idx_l0_active ? (WORD32)u4_num_total_curr : ps_slice_hdr->i1_num_ref_idx_l0_active; |
392 | | |
393 | 5.78k | r_idx = 0; |
394 | 5.78k | if((PSLICE == ps_slice_hdr->i1_slice_type) || |
395 | 5.78k | (BSLICE == ps_slice_hdr->i1_slice_type)) |
396 | 5.72k | { |
397 | 11.4k | while(r_idx < u4_num_rps_curr_temp_list0) |
398 | 5.72k | { |
399 | 18.2k | for(i = 0; (i < (WORD32)u4_num_st_curr_before) && (r_idx < u4_num_rps_curr_temp_list0); r_idx++, i++) |
400 | 12.5k | { |
401 | 12.5k | if(NULL == as_ref_pic_st_curr_before[i]) |
402 | 1.19k | { |
403 | 1.19k | as_ref_pic_st_curr_before[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_st_curr_before[i]); |
404 | 1.19k | } |
405 | 12.5k | as_ref_pic_list_temp0[r_idx] = as_ref_pic_st_curr_before[i]; |
406 | 12.5k | } |
407 | | |
408 | 15.0k | for(i = 0; (i < (WORD32)u4_num_st_curr_after) && (r_idx < u4_num_rps_curr_temp_list0); r_idx++, i++) |
409 | 9.33k | { |
410 | 9.33k | if(NULL == as_ref_pic_st_curr_after[i]) |
411 | 422 | { |
412 | 422 | as_ref_pic_st_curr_after[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_st_curr_after[i]); |
413 | 422 | } |
414 | 9.33k | as_ref_pic_list_temp0[r_idx] = as_ref_pic_st_curr_after[i]; |
415 | 9.33k | } |
416 | | |
417 | 5.72k | for(i = 0; (i < (WORD32)u4_num_lt_curr) && (r_idx < u4_num_rps_curr_temp_list0); r_idx++, i++) |
418 | 0 | { |
419 | 0 | if(NULL == as_ref_pic_lt_curr[i]) |
420 | 0 | { |
421 | 0 | as_ref_pic_lt_curr[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_lt_curr[i]); |
422 | 0 | } |
423 | 0 | as_ref_pic_list_temp0[r_idx] = as_ref_pic_lt_curr[i]; |
424 | 0 | } |
425 | 5.72k | } |
426 | | |
427 | 17.7k | for(r_idx = 0; (WORD32)r_idx < ps_slice_hdr->i1_num_ref_idx_l0_active; r_idx++) |
428 | 12.0k | { |
429 | 12.0k | pic_buf_t *ps_pic_buf; |
430 | 12.0k | ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf = ps_slice_hdr->s_rplm.i1_ref_pic_list_modification_flag_l0 ? (void *)as_ref_pic_list_temp0[ps_slice_hdr->s_rplm.i1_list_entry_l0[r_idx]] : (void *)as_ref_pic_list_temp0[r_idx]; |
431 | 12.0k | ps_pic_buf = (pic_buf_t *)ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf; |
432 | | |
433 | 12.0k | if(ps_pic_buf == NULL) |
434 | 68 | return IHEVCD_REF_PIC_NOT_FOUND; |
435 | | |
436 | 12.0k | ps_mv_buf = ihevcd_mv_mgr_get_poc(ps_mv_buf_mgr, ps_pic_buf->i4_abs_poc); |
437 | 12.0k | ps_slice_hdr->as_ref_pic_list0[r_idx].pv_mv_buf = ps_mv_buf; |
438 | 12.0k | } |
439 | | |
440 | | |
441 | 5.65k | if(ps_slice_hdr->i1_slice_type == BSLICE) |
442 | 5.65k | { |
443 | 5.65k | u4_num_rps_curr_temp_list1 = (WORD32)u4_num_total_curr > ps_slice_hdr->i1_num_ref_idx_l1_active ? (WORD32)u4_num_total_curr : ps_slice_hdr->i1_num_ref_idx_l1_active; |
444 | | |
445 | 5.65k | r_idx = 0; |
446 | 11.3k | while(r_idx < u4_num_rps_curr_temp_list1) |
447 | 5.65k | { |
448 | 14.8k | for(i = 0; (i < (WORD32)u4_num_st_curr_after) && (r_idx < u4_num_rps_curr_temp_list1); r_idx++, i++) |
449 | 9.24k | { |
450 | 9.24k | if(NULL == as_ref_pic_st_curr_after[i]) |
451 | 0 | { |
452 | 0 | as_ref_pic_st_curr_after[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_st_curr_after[i]); |
453 | 0 | } |
454 | 9.24k | as_ref_pic_list_temp1[r_idx] = as_ref_pic_st_curr_after[i]; |
455 | 9.24k | } |
456 | | |
457 | 18.0k | for(i = 0; (i < (WORD32)u4_num_st_curr_before) && (r_idx < u4_num_rps_curr_temp_list1); r_idx++, i++) |
458 | 12.3k | { |
459 | 12.3k | if(NULL == as_ref_pic_st_curr_before[i]) |
460 | 0 | { |
461 | 0 | as_ref_pic_st_curr_before[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_st_curr_before[i]); |
462 | 0 | } |
463 | 12.3k | as_ref_pic_list_temp1[r_idx] = as_ref_pic_st_curr_before[i]; |
464 | 12.3k | } |
465 | | |
466 | 5.65k | for(i = 0; (i < (WORD32)u4_num_lt_curr) && (r_idx < u4_num_rps_curr_temp_list1); r_idx++, i++) |
467 | 0 | { |
468 | 0 | if(NULL == as_ref_pic_lt_curr[i]) |
469 | 0 | { |
470 | 0 | as_ref_pic_lt_curr[i] = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ai4_poc_lt_curr[i]); |
471 | 0 | } |
472 | 0 | as_ref_pic_list_temp1[r_idx] = as_ref_pic_lt_curr[i]; |
473 | 0 | } |
474 | 5.65k | } |
475 | | |
476 | 17.6k | for(r_idx = 0; (WORD32)r_idx < ps_slice_hdr->i1_num_ref_idx_l1_active; r_idx++) |
477 | 11.9k | { |
478 | 11.9k | pic_buf_t *ps_pic_buf; |
479 | 11.9k | ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf = ps_slice_hdr->s_rplm.i1_ref_pic_list_modification_flag_l1 ? (void *)as_ref_pic_list_temp1[ps_slice_hdr->s_rplm.i1_list_entry_l1[r_idx]] : (void *)as_ref_pic_list_temp1[r_idx]; |
480 | 11.9k | ps_pic_buf = (pic_buf_t *)ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf; |
481 | | |
482 | 11.9k | if(ps_pic_buf == NULL) |
483 | 0 | return IHEVCD_REF_PIC_NOT_FOUND; |
484 | | |
485 | 11.9k | ps_mv_buf = ihevcd_mv_mgr_get_poc(ps_mv_buf_mgr, ps_pic_buf->i4_abs_poc); |
486 | 11.9k | ps_slice_hdr->as_ref_pic_list1[r_idx].pv_mv_buf = ps_mv_buf; |
487 | 11.9k | } |
488 | 5.65k | } |
489 | 5.65k | } |
490 | | |
491 | 5.71k | DEBUG_PRINT_REF_LIST_POCS(i4_pic_order_cnt_val, ps_slice_hdr, ps_dpb_mgr, u4_num_st_curr_before, u4_num_st_curr_after, u4_num_st_foll, u4_num_lt_curr, u4_num_lt_foll, ai4_poc_st_curr_before, ai4_poc_st_curr_after, ai4_poc_st_foll, ai4_poc_lt_curr, ai4_poc_lt_foll); |
492 | | /* Buffers that are still marked as UNUSED_FOR_REF are released from dpb (internally dpb calls release from pic buf manager)*/ |
493 | 371k | for(i = 0; i < MAX_DPB_BUFS; i++) |
494 | 365k | { |
495 | 365k | if((ps_dpb_mgr->as_dpb_info[i].ps_pic_buf) && (UNUSED_FOR_REF == ps_dpb_mgr->as_dpb_info[i].ps_pic_buf->u1_used_as_ref)) |
496 | 831 | { |
497 | 831 | pic_buf_t *ps_pic_buf = ps_dpb_mgr->as_dpb_info[i].ps_pic_buf; |
498 | 831 | mv_buf_t *ps_mv_buf; |
499 | | |
500 | | /* Long term index is set to MAX_DPB_BUFS to ensure it is not added as LT */ |
501 | 831 | ihevc_dpb_mgr_del_ref(ps_dpb_mgr, (buf_mgr_t *)ps_codec->pv_pic_buf_mgr, ps_pic_buf->i4_abs_poc); |
502 | | |
503 | | |
504 | | /* Find buffer id of the MV bank corresponding to the buffer being freed (Buffer with POC of u4_abs_poc) */ |
505 | 831 | ps_mv_buf = (mv_buf_t *)ps_codec->ps_mv_buf; |
506 | 2.80k | for(j = 0; j < ps_codec->i4_max_dpb_size; j++) |
507 | 2.80k | { |
508 | 2.80k | if(ps_mv_buf && ps_mv_buf->i4_abs_poc == ps_pic_buf->i4_abs_poc) |
509 | 831 | { |
510 | 831 | ihevc_buf_mgr_release((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, j, BUF_MGR_REF); |
511 | 831 | break; |
512 | 831 | } |
513 | 1.97k | ps_mv_buf++; |
514 | 1.97k | } |
515 | 831 | } |
516 | | |
517 | 365k | } |
518 | | |
519 | 5.71k | return IHEVCD_SUCCESS; |
520 | 5.78k | } |