blob: 054dd62b5177c0f5a752ca4e06b6132acf139d49 [file] [log] [blame]
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301/******************************************************************************
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 ih264d_parse_slice.c
23 *
24 * \brief
25 * Contains routines that decodes a slice NAL unit
26 *
27 * \date
28 * 19/12/2002
29 *
30 * \author AI
31 **************************************************************************
32 */
33#include <string.h>
34#include "ih264_typedefs.h"
35#include "ih264_macros.h"
36#include "ih264_platform_macros.h"
37#include "ithread.h"
38#include "ih264d_structs.h"
39#include "ih264d_debug.h"
40#include "ih264d_bitstrm.h"
41#include "ih264d_parse_mb_header.h"
42#include "ih264d_process_bslice.h"
43#include "ih264d_process_pslice.h"
44#include "ih264d_parse_cavlc.h"
45#include "ih264d_utils.h"
46#include "ih264d_deblocking.h"
47#include "ih264d_defs.h"
48#include "ih264d_error_handler.h"
49#include "ih264d_tables.h"
50#include "ih264d_defs.h"
51#include "ih264d_mem_request.h"
52#include "ih264d_parse_islice.h"
53#include "ih264d_parse_slice.h"
54#include "ih264d_mvpred.h"
55#include "ih264d_mb_utils.h"
56
57#include "ih264d_defs.h"
58#include "ih264d_quant_scaling.h"
59
60#include "ih264d_inter_pred.h"
61
62#include "ih264d_sei.h"
63#include "ih264d.h"
64#include "ih264_error.h"
65#include "ih264_disp_mgr.h"
66#include "ih264_buf_mgr.h"
67
68#include "ih264d_thread_parse_decode.h"
69#include "ih264d_thread_compute_bs.h"
70#include "ih264d_dpb_manager.h"
71#include <assert.h>
72#include "ih264d_parse_islice.h"
73#define RET_LAST_SKIP 0x80000000
74
75/*!
76 **************************************************************************
77 * \if Function name : ih264d_form_pred_weight_matrix \endif
78 *
79 * \brief
80 * Forms pred weight matrix.
81 *
82 * \return
83 * None
84 *
85 **************************************************************************
86 */
87
88void ih264d_form_pred_weight_matrix(dec_struct_t *ps_dec)
89{
90 dec_slice_params_t *ps_cur_slice;
91 UWORD8 uc_num_ref_idx_l0_active, uc_num_ref_idx_l1_active;
92 UWORD8 i, j;
93 UWORD32 *pu4_mat_iwt_ofst;
94 UWORD16 i2_idx;
95 UWORD32 *pui32_weight_offset_l0, *pui32_weight_offset_l1;
96 UWORD32 u4_temp;
97
98 ps_cur_slice = ps_dec->ps_cur_slice;
99 uc_num_ref_idx_l0_active = ps_cur_slice->u1_num_ref_idx_lx_active[0];
100 uc_num_ref_idx_l1_active = ps_cur_slice->u1_num_ref_idx_lx_active[1];
101
102 pu4_mat_iwt_ofst = ps_dec->pu4_wts_ofsts_mat;
103
104 if(ps_cur_slice->u1_slice_type == B_SLICE)
105 {
106 for(i = 0; i < uc_num_ref_idx_l0_active; i++)
107 {
108 pui32_weight_offset_l0 = ps_cur_slice->u4_wt_ofst_lx[0][i];
109 for(j = 0; j < uc_num_ref_idx_l1_active; j++)
110 {
111 pui32_weight_offset_l1 = ps_cur_slice->u4_wt_ofst_lx[1][j];
112 i2_idx = i * uc_num_ref_idx_l0_active + j;
113 i2_idx = X3(i2_idx);
114 /* u4_temp = (pui32_weight_offset_l0[0] | (pui32_weight_offset_l1[0] << 16));
115 pu4_mat_iwt_ofst[0] = u4_temp;
116 u4_temp = (pui32_weight_offset_l0[1] | (pui32_weight_offset_l1[1] << 16));
117 pu4_mat_iwt_ofst[1] = u4_temp;
118 u4_temp = (pui32_weight_offset_l0[2] | (pui32_weight_offset_l1[2] << 16));
119 pu4_mat_iwt_ofst[2] = u4_temp;
120 pu4_mat_iwt_ofst += 3;*/
121 pu4_mat_iwt_ofst[0] = pui32_weight_offset_l0[0];
122 pu4_mat_iwt_ofst[1] = pui32_weight_offset_l1[0];
123 pu4_mat_iwt_ofst[2] = pui32_weight_offset_l0[1];
124 pu4_mat_iwt_ofst[3] = pui32_weight_offset_l1[1];
125 pu4_mat_iwt_ofst[4] = pui32_weight_offset_l0[2];
126 pu4_mat_iwt_ofst[5] = pui32_weight_offset_l1[2];
127 pu4_mat_iwt_ofst += 6;
128 }
129 }
130 }
131 else
132 {
133 for(i = 0; i < uc_num_ref_idx_l0_active; i++)
134 {
135 pui32_weight_offset_l0 = ps_cur_slice->u4_wt_ofst_lx[0][i];
136 i2_idx = X3(i);
137 u4_temp = (UWORD32)pui32_weight_offset_l0[0];
138 pu4_mat_iwt_ofst[0] = u4_temp;
139 u4_temp = (UWORD32)pui32_weight_offset_l0[1];
140 pu4_mat_iwt_ofst[2] = u4_temp;
141 u4_temp = (UWORD32)pui32_weight_offset_l0[2];
142 pu4_mat_iwt_ofst[4] = u4_temp;
143 pu4_mat_iwt_ofst += 6;
144 }
145 }
146}
147
148
149/*!
150 **************************************************************************
151 * \if Function name : init_firstSliceParam \endif
152 *
153 * \brief
154 * Initialize the Parameter required for all the slices for a picture
155 *
156 * \return : Nothing
157 *
158 **************************************************************************
159 */
160
161WORD32 ih264d_start_of_pic(dec_struct_t *ps_dec,
162 WORD32 i4_poc,
163 pocstruct_t *ps_temp_poc,
164 UWORD16 u2_frame_num,
165 dec_pic_params_t *ps_pps)
166{
167 pocstruct_t *ps_prev_poc = &ps_dec->s_cur_pic_poc;
168 pocstruct_t *ps_cur_poc = ps_temp_poc;
169
170 pic_buffer_t *pic_buf;
171
172 ivd_video_decode_op_t * ps_dec_output =
173 (ivd_video_decode_op_t *)ps_dec->pv_dec_out;
174 dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice;
175 dec_seq_params_t *ps_seq = ps_pps->ps_sps;
176 UWORD8 u1_bottom_field_flag = ps_cur_slice->u1_bottom_field_flag;
177 UWORD8 u1_field_pic_flag = ps_cur_slice->u1_field_pic_flag;
178 /* high profile related declarations */
179 high_profile_tools_t s_high_profile;
180 WORD32 ret;
181
182 H264_MUTEX_LOCK(&ps_dec->process_disp_mutex);
183
184 ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb;
185 ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb;
186 ps_prev_poc->i4_delta_pic_order_cnt_bottom =
187 ps_cur_poc->i4_delta_pic_order_cnt_bottom;
188 ps_prev_poc->i4_delta_pic_order_cnt[0] =
189 ps_cur_poc->i4_delta_pic_order_cnt[0];
190 ps_prev_poc->i4_delta_pic_order_cnt[1] =
191 ps_cur_poc->i4_delta_pic_order_cnt[1];
192 ps_prev_poc->u1_bot_field = ps_dec->ps_cur_slice->u1_bottom_field_flag;
193 ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst;
194 ps_prev_poc->u2_frame_num = u2_frame_num;
195 ps_dec->i1_prev_mb_qp_delta = 0;
196 ps_dec->i1_next_ctxt_idx = 0;
197
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530198
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700199 ps_dec->u4_nmb_deblk = 0;
200 if(ps_dec->u4_num_cores == 1)
201 ps_dec->u4_nmb_deblk = 1;
202
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530203
204
205 if(ps_seq->u1_mb_aff_flag == 1)
206 {
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700207 ps_dec->u4_nmb_deblk = 0;
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530208 if(ps_dec->u4_num_cores > 2)
209 ps_dec->u4_num_cores = 2;
210 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700211
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530212 ps_dec->u4_use_intrapred_line_copy = 0;
213
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700214
215
216 if (ps_seq->u1_mb_aff_flag == 0)
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530217 {
218 ps_dec->u4_use_intrapred_line_copy = 1;
219 }
220
221 ps_dec->u4_app_disable_deblk_frm = 0;
222 /* If degrade is enabled, set the degrade flags appropriately */
223 if(ps_dec->i4_degrade_type && ps_dec->i4_degrade_pics)
224 {
225 WORD32 degrade_pic;
226 ps_dec->i4_degrade_pic_cnt++;
227 degrade_pic = 0;
228
229 /* If degrade is to be done in all frames, then do not check further */
230 switch(ps_dec->i4_degrade_pics)
231 {
232 case 4:
233 {
234 degrade_pic = 1;
235 break;
236 }
237 case 3:
238 {
239 if(ps_cur_slice->u1_slice_type != I_SLICE)
240 degrade_pic = 1;
241
242 break;
243 }
244 case 2:
245 {
246
247 /* If pic count hits non-degrade interval or it is an islice, then do not degrade */
248 if((ps_cur_slice->u1_slice_type != I_SLICE)
249 && (ps_dec->i4_degrade_pic_cnt
250 != ps_dec->i4_nondegrade_interval))
251 degrade_pic = 1;
252
253 break;
254 }
255 case 1:
256 {
257 /* Check if the current picture is non-ref */
258 if(0 == ps_cur_slice->u1_nal_ref_idc)
259 {
260 degrade_pic = 1;
261 }
262 break;
263 }
264
265 }
266 if(degrade_pic)
267 {
268 if(ps_dec->i4_degrade_type & 0x2)
269 ps_dec->u4_app_disable_deblk_frm = 1;
270
271 /* MC degrading is done only for non-ref pictures */
272 if(0 == ps_cur_slice->u1_nal_ref_idc)
273 {
274 if(ps_dec->i4_degrade_type & 0x4)
275 ps_dec->i4_mv_frac_mask = 0;
276
277 if(ps_dec->i4_degrade_type & 0x8)
278 ps_dec->i4_mv_frac_mask = 0;
279 }
280 }
281 else
282 ps_dec->i4_degrade_pic_cnt = 0;
283 }
284
285 {
286 dec_err_status_t * ps_err = ps_dec->ps_dec_err_status;
287 if(ps_dec->u1_sl_typ_5_9
288 && ((ps_cur_slice->u1_slice_type == I_SLICE)
289 || (ps_cur_slice->u1_slice_type
290 == SI_SLICE)))
291 ps_err->u1_cur_pic_type = PIC_TYPE_I;
292 else
293 ps_err->u1_cur_pic_type = PIC_TYPE_UNKNOWN;
294
295 if(ps_err->u1_pic_aud_i == PIC_TYPE_I)
296 {
297 ps_err->u1_cur_pic_type = PIC_TYPE_I;
298 ps_err->u1_pic_aud_i = PIC_TYPE_UNKNOWN;
299 }
300
301 if(ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL)
302 {
303 if(ps_err->u1_err_flag)
304 ih264d_reset_ref_bufs(ps_dec->ps_dpb_mgr);
305 ps_err->u1_err_flag = ACCEPT_ALL_PICS;
306 }
307 }
308
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530309 if(ps_dec->u1_init_dec_flag && ps_dec->s_prev_seq_params.u1_eoseq_pending)
310 {
311 /* Reset the decoder picture buffers */
312 WORD32 j;
313 for(j = 0; j < MAX_DISP_BUFS_NEW; j++)
314 {
315
316 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
317 j,
318 BUF_MGR_REF);
319 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
320 ps_dec->au1_pic_buf_id_mv_buf_id_map[j],
321 BUF_MGR_REF);
322 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
323 j,
324 BUF_MGR_IO);
325 }
326
327 /* reset the decoder structure parameters related to buffer handling */
328 ps_dec->u1_second_field = 0;
329 ps_dec->i4_cur_display_seq = 0;
330
331 /********************************************************************/
332 /* indicate in the decoder output i4_status that some frames are being */
333 /* dropped, so that it resets timestamp and wait for a new sequence */
334 /********************************************************************/
335
336 ps_dec->s_prev_seq_params.u1_eoseq_pending = 0;
337 }
338 ret = ih264d_init_pic(ps_dec, u2_frame_num, i4_poc, ps_pps);
339 if(ret != OK)
340 return ret;
341
342 ps_dec->pv_parse_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data;
343 ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_pic_tu_coeff_data;
344 ps_dec->ps_nmb_info = ps_dec->ps_frm_mb_info;
345 if(ps_dec->u1_separate_parse)
346 {
347 UWORD16 pic_wd = ps_dec->u4_width_at_init;
348 UWORD16 pic_ht = ps_dec->u4_height_at_init;
349 UWORD32 num_mbs;
350
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700351 if((NULL != ps_dec->ps_cur_sps) && (1 == (ps_dec->ps_cur_sps->u1_is_valid)))
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530352 {
353 pic_wd = ps_dec->u2_pic_wd;
354 pic_ht = ps_dec->u2_pic_ht;
355 }
356 num_mbs = (pic_wd * pic_ht) >> 8;
357
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530358 if(ps_dec->pu1_dec_mb_map)
359 {
360 memset((void *)ps_dec->pu1_dec_mb_map, 0, num_mbs);
361 }
362
363 if(ps_dec->pu1_recon_mb_map)
364 {
365
366 memset((void *)ps_dec->pu1_recon_mb_map, 0, num_mbs);
367 }
368
369 if(ps_dec->pu2_slice_num_map)
370 {
371 memset((void *)ps_dec->pu2_slice_num_map, 0,
372 (num_mbs * sizeof(UWORD16)));
373 }
374
375 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530376
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700377 ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
378 ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
379 ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
Harish Mahendrakar5e4f64c2016-06-01 13:31:45 +0530380 ps_dec->u2_cur_slice_num = 0;
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530381
382 /* Initialize all the HP toolsets to zero */
383 ps_dec->s_high_profile.u1_scaling_present = 0;
384 ps_dec->s_high_profile.u1_transform8x8_present = 0;
385
386 /* Get Next Free Picture */
387 if(1 == ps_dec->u4_share_disp_buf)
388 {
389 UWORD32 i;
390 /* Free any buffer that is in the queue to be freed */
391 for(i = 0; i < MAX_DISP_BUFS_NEW; i++)
392 {
393 if(0 == ps_dec->u4_disp_buf_to_be_freed[i])
394 continue;
395 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr, i,
396 BUF_MGR_IO);
397 ps_dec->u4_disp_buf_to_be_freed[i] = 0;
398 ps_dec->u4_disp_buf_mapping[i] = 0;
399
400 }
401 }
402 if(!(u1_field_pic_flag && 0 != ps_dec->u1_top_bottom_decoded)) //ps_dec->u1_second_field))
403 {
404 pic_buffer_t *ps_cur_pic;
405 WORD32 cur_pic_buf_id, cur_mv_buf_id;
406 col_mv_buf_t *ps_col_mv;
407 while(1)
408 {
409 ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free(
410 (buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
411 &cur_pic_buf_id);
412 if(ps_cur_pic == NULL)
413 {
414 ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T;
415 return ERROR_UNAVAIL_PICBUF_T;
416 }
417 if(0 == ps_dec->u4_disp_buf_mapping[cur_pic_buf_id])
418 {
419 break;
420 }
421
422 }
423 ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
424 &cur_mv_buf_id);
425 if(ps_col_mv == NULL)
426 {
427 ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T;
428 return ERROR_UNAVAIL_MVBUF_T;
429 }
430
431 ps_dec->ps_cur_pic = ps_cur_pic;
432 ps_dec->u1_pic_buf_id = cur_pic_buf_id;
433 ps_cur_pic->u4_ts = ps_dec->u4_ts;
434
435
436 ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id;
437 ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id;
438
439 ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag;
440 ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv;
441 ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700442 if(ps_dec->u1_first_slice_in_stream)
443 {
444 /*make first entry of list0 point to cur pic,so that if first Islice is in error, ref pic struct will have valid entries*/
445 ps_dec->ps_ref_pic_buf_lx[0] = ps_dec->ps_dpb_mgr->ps_init_dpb[0];
446 *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][0]) = *ps_cur_pic;
Harish Mahendrakarbc71ad22016-09-17 17:00:37 +0530447 /* Initialize for field reference as well */
448 *(ps_dec->ps_dpb_mgr->ps_init_dpb[0][MAX_REF_BUFS]) = *ps_cur_pic;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700449 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530450
451 if(!ps_dec->ps_cur_pic)
452 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530453 WORD32 j;
Martin Storsjo086dd8e2015-06-13 00:35:01 +0300454 H264_DEC_DEBUG_PRINT("------- Display Buffers Reset --------\n");
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530455 for(j = 0; j < MAX_DISP_BUFS_NEW; j++)
456 {
457
458 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
459 j,
460 BUF_MGR_REF);
461 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
462 ps_dec->au1_pic_buf_id_mv_buf_id_map[j],
463 BUF_MGR_REF);
464 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
465 j,
466 BUF_MGR_IO);
467 }
468
469 ps_dec->i4_cur_display_seq = 0;
470 ps_dec->i4_prev_max_display_seq = 0;
471 ps_dec->i4_max_poc = 0;
472
473 ps_cur_pic = (pic_buffer_t *)ih264_buf_mgr_get_next_free(
474 (buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
475 &cur_pic_buf_id);
476 if(ps_cur_pic == NULL)
477 {
478 ps_dec->i4_error_code = ERROR_UNAVAIL_PICBUF_T;
479 return ERROR_UNAVAIL_PICBUF_T;
480 }
481
482 ps_col_mv = (col_mv_buf_t *)ih264_buf_mgr_get_next_free((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
483 &cur_mv_buf_id);
484 if(ps_col_mv == NULL)
485 {
486 ps_dec->i4_error_code = ERROR_UNAVAIL_MVBUF_T;
487 return ERROR_UNAVAIL_MVBUF_T;
488 }
489
490 ps_dec->ps_cur_pic = ps_cur_pic;
491 ps_dec->u1_pic_buf_id = cur_pic_buf_id;
492 ps_cur_pic->u4_ts = ps_dec->u4_ts;
493 ps_dec->apv_buf_id_pic_buf_map[cur_pic_buf_id] = (void *)ps_cur_pic;
494
495 ps_cur_pic->u1_mv_buf_id = cur_mv_buf_id;
496 ps_dec->au1_pic_buf_id_mv_buf_id_map[cur_pic_buf_id] = cur_mv_buf_id;
497
498 ps_cur_pic->pu1_col_zero_flag = (UWORD8 *)ps_col_mv->pv_col_zero_flag;
499 ps_cur_pic->ps_mv = (mv_pred_t *)ps_col_mv->pv_mv;
500 ps_dec->au1_pic_buf_ref_flag[cur_pic_buf_id] = 0;
501
502 }
503
504 ps_dec->ps_cur_pic->u1_picturetype = u1_field_pic_flag;
505 ps_dec->ps_cur_pic->u4_pack_slc_typ = SKIP_NONE;
506 H264_DEC_DEBUG_PRINT("got a buffer\n");
507 }
508 else
509 {
510 H264_DEC_DEBUG_PRINT("did not get a buffer\n");
511 }
512
513 ps_dec->u4_pic_buf_got = 1;
514
515 ps_dec->ps_cur_pic->i4_poc = i4_poc;
516 ps_dec->ps_cur_pic->i4_frame_num = u2_frame_num;
517 ps_dec->ps_cur_pic->i4_pic_num = u2_frame_num;
518 ps_dec->ps_cur_pic->i4_top_field_order_cnt = ps_pps->i4_top_field_order_cnt;
519 ps_dec->ps_cur_pic->i4_bottom_field_order_cnt =
520 ps_pps->i4_bottom_field_order_cnt;
521 ps_dec->ps_cur_pic->i4_avg_poc = ps_pps->i4_avg_poc;
522 ps_dec->ps_cur_pic->u4_time_stamp = ps_dec->u4_pts;
523
524 ps_dec->s_cur_pic = *(ps_dec->ps_cur_pic);
525 if(u1_field_pic_flag && u1_bottom_field_flag)
526 {
527 WORD32 i4_temp_poc;
528 WORD32 i4_top_field_order_poc, i4_bot_field_order_poc;
529 /* Point to odd lines, since it's bottom field */
530 ps_dec->s_cur_pic.pu1_buf1 += ps_dec->s_cur_pic.u2_frm_wd_y;
531 ps_dec->s_cur_pic.pu1_buf2 += ps_dec->s_cur_pic.u2_frm_wd_uv;
532 ps_dec->s_cur_pic.pu1_buf3 += ps_dec->s_cur_pic.u2_frm_wd_uv;
533 ps_dec->s_cur_pic.ps_mv +=
534 ((ps_dec->u2_pic_ht * ps_dec->u2_pic_wd) >> 5);
535 ps_dec->s_cur_pic.pu1_col_zero_flag += ((ps_dec->u2_pic_ht
536 * ps_dec->u2_pic_wd) >> 5);
537 ps_dec->ps_cur_pic->u1_picturetype |= BOT_FLD;
538 i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt;
539 i4_bot_field_order_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt;
540 i4_temp_poc = MIN(i4_top_field_order_poc,
541 i4_bot_field_order_poc);
542 ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc;
543 }
544
545 ps_cur_slice->u1_mbaff_frame_flag = ps_seq->u1_mb_aff_flag
546 && (!u1_field_pic_flag);
547
548 ps_dec->ps_cur_pic->u1_picturetype |= (ps_cur_slice->u1_mbaff_frame_flag
549 << 2);
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530550
551 ps_dec->ps_cur_mb_row = ps_dec->ps_nbr_mb_row; //[0];
552 ps_dec->ps_cur_mb_row++; //Increment by 1 ,so that left mb will always be valid
553 ps_dec->ps_top_mb_row =
554 ps_dec->ps_nbr_mb_row
555 + ((ps_dec->u2_frm_wd_in_mbs + 1)
556 << (1
557 - ps_dec->ps_cur_sps->u1_frame_mbs_only_flag));
558 ps_dec->ps_top_mb_row++; //Increment by 1 ,so that left mb will always be valid
559
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530560 ps_dec->pu1_y = ps_dec->pu1_y_scratch[0];
561 ps_dec->pu1_u = ps_dec->pu1_u_scratch[0];
562 ps_dec->pu1_v = ps_dec->pu1_v_scratch[0];
563 ps_dec->u1_yuv_scratch_idx = 0;
564 /* CHANGED CODE */
565 ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv;
566 ps_dec->ps_mv_top = ps_dec->ps_mv_top_p[0];
567 /* CHANGED CODE */
568 ps_dec->u1_mv_top_p = 0;
569 ps_dec->u1_mb_idx = 0;
570 /* CHANGED CODE */
571 ps_dec->ps_mv_left = ps_dec->s_cur_pic.ps_mv;
572 ps_dec->pu1_yleft = 0;
573 ps_dec->pu1_uleft = 0;
574 ps_dec->pu1_vleft = 0;
575 ps_dec->u1_not_wait_rec = 2;
576 ps_dec->u2_total_mbs_coded = 0;
577 ps_dec->i4_submb_ofst = -(SUB_BLK_SIZE);
578 ps_dec->u4_pred_info_idx = 0;
579 ps_dec->u4_pred_info_pkd_idx = 0;
580 ps_dec->u4_dma_buf_idx = 0;
581 ps_dec->ps_mv = ps_dec->s_cur_pic.ps_mv;
582 ps_dec->ps_mv_bank_cur = ps_dec->s_cur_pic.ps_mv;
583 ps_dec->pu1_col_zero_flag = ps_dec->s_cur_pic.pu1_col_zero_flag;
584 ps_dec->ps_part = ps_dec->ps_parse_part_params;
585 ps_dec->i2_prev_slice_mbx = -1;
586 ps_dec->i2_prev_slice_mby = 0;
587 ps_dec->u2_mv_2mb[0] = 0;
588 ps_dec->u2_mv_2mb[1] = 0;
589 ps_dec->u1_last_pic_not_decoded = 0;
590
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530591 ps_dec->u2_cur_slice_num_dec_thread = 0;
592 ps_dec->u2_cur_slice_num_bs = 0;
593 ps_dec->u4_intra_pred_line_ofst = 0;
594 ps_dec->pu1_cur_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line;
595 ps_dec->pu1_cur_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line;
596 ps_dec->pu1_cur_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line;
597
598 ps_dec->pu1_cur_y_intra_pred_line_base = ps_dec->pu1_y_intra_pred_line;
599 ps_dec->pu1_cur_u_intra_pred_line_base = ps_dec->pu1_u_intra_pred_line;
600 ps_dec->pu1_cur_v_intra_pred_line_base = ps_dec->pu1_v_intra_pred_line;
601
602
603
604
605
606 ps_dec->pu1_prev_y_intra_pred_line = ps_dec->pu1_y_intra_pred_line
607 + (ps_dec->u2_frm_wd_in_mbs * MB_SIZE);
608
609 ps_dec->pu1_prev_u_intra_pred_line = ps_dec->pu1_u_intra_pred_line
610 + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE * YUV420SP_FACTOR;
611 ps_dec->pu1_prev_v_intra_pred_line = ps_dec->pu1_v_intra_pred_line
612 + ps_dec->u2_frm_wd_in_mbs * BLK8x8SIZE;
613
614 ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic;
615 ps_dec->ps_deblk_mbn_curr = ps_dec->ps_deblk_mbn;
616 ps_dec->ps_deblk_mbn_prev = ps_dec->ps_deblk_mbn + ps_dec->u1_recon_mb_grp;
617 /* Initialize The Function Pointer Depending Upon the Entropy and MbAff Flag */
618 {
619 if(ps_cur_slice->u1_mbaff_frame_flag)
620 {
621 ps_dec->pf_compute_bs = ih264d_compute_bs_mbaff;
622 ps_dec->pf_mvpred = ih264d_mvpred_mbaff;
623 }
624 else
625 {
626 ps_dec->pf_compute_bs = ih264d_compute_bs_non_mbaff;
627 ps_dec->u1_cur_mb_fld_dec_flag = ps_cur_slice->u1_field_pic_flag;
628 }
629 }
630 /* Set up the Parameter for DMA transfer */
631 {
632 UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
633
634 UWORD8 u1_mbaff = ps_cur_slice->u1_mbaff_frame_flag;
635
636 UWORD8 uc_lastmbs = (((ps_dec->u2_pic_wd) >> 4)
637 % (ps_dec->u1_recon_mb_grp >> u1_mbaff));
638 UWORD16 ui16_lastmbs_widthY =
639 (uc_lastmbs ? (uc_lastmbs << 4) : ((ps_dec->u1_recon_mb_grp
640 >> u1_mbaff) << 4));
641 UWORD16 ui16_lastmbs_widthUV =
642 uc_lastmbs ? (uc_lastmbs << 3) : ((ps_dec->u1_recon_mb_grp
643 >> u1_mbaff) << 3);
644
645 ps_dec->s_tran_addrecon.pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1;
646 ps_dec->s_tran_addrecon.pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2;
647 ps_dec->s_tran_addrecon.pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3;
648
649 ps_dec->s_tran_addrecon.u2_frm_wd_y = ps_dec->u2_frm_wd_y
650 << u1_field_pic_flag;
651 ps_dec->s_tran_addrecon.u2_frm_wd_uv = ps_dec->u2_frm_wd_uv
652 << u1_field_pic_flag;
653
654 if(u1_field_pic_flag)
655 {
656 ui16_lastmbs_widthY += ps_dec->u2_frm_wd_y;
657 ui16_lastmbs_widthUV += ps_dec->u2_frm_wd_uv;
658 }
659
660 /* Normal Increment of Pointer */
661 ps_dec->s_tran_addrecon.u4_inc_y[0] = ((ps_dec->u1_recon_mb_grp << 4)
662 >> u1_mbaff);
663 ps_dec->s_tran_addrecon.u4_inc_uv[0] = ((ps_dec->u1_recon_mb_grp << 4)
664 >> u1_mbaff);
665
666 /* End of Row Increment */
667 ps_dec->s_tran_addrecon.u4_inc_y[1] = (ui16_lastmbs_widthY
668 + (PAD_LEN_Y_H << 1)
669 + ps_dec->s_tran_addrecon.u2_frm_wd_y
670 * ((15 << u1_mbaff) + u1_mbaff));
671 ps_dec->s_tran_addrecon.u4_inc_uv[1] = (ui16_lastmbs_widthUV
672 + (PAD_LEN_UV_H << 2)
673 + ps_dec->s_tran_addrecon.u2_frm_wd_uv
674 * ((15 << u1_mbaff) + u1_mbaff));
675
676 /* Assign picture numbers to each frame/field */
677 /* only once per picture. */
678 ih264d_assign_pic_num(ps_dec);
679 ps_dec->s_tran_addrecon.u2_mv_top_left_inc = (ps_dec->u1_recon_mb_grp
680 << 2) - 1 - (u1_mbaff << 2);
681 ps_dec->s_tran_addrecon.u2_mv_left_inc = ((ps_dec->u1_recon_mb_grp
682 >> u1_mbaff) - 1) << (4 + u1_mbaff);
683 }
684 /**********************************************************************/
685 /* High profile related initialization at pictrue level */
686 /**********************************************************************/
687 if(ps_seq->u1_profile_idc == HIGH_PROFILE_IDC)
688 {
689 if((ps_seq->i4_seq_scaling_matrix_present_flag)
690 || (ps_pps->i4_pic_scaling_matrix_present_flag))
691 {
692 ih264d_form_scaling_matrix_picture(ps_seq, ps_pps, ps_dec);
693 ps_dec->s_high_profile.u1_scaling_present = 1;
694 }
695 else
696 {
697 ih264d_form_default_scaling_matrix(ps_dec);
698 }
699
700 if(ps_pps->i4_transform_8x8_mode_flag)
701 {
702 ps_dec->s_high_profile.u1_transform8x8_present = 1;
703 }
704 }
705 else
706 {
707 ih264d_form_default_scaling_matrix(ps_dec);
708 }
709
710 /* required while reading the transform_size_8x8 u4_flag */
711 ps_dec->s_high_profile.u1_direct_8x8_inference_flag =
712 ps_seq->u1_direct_8x8_inference_flag;
713 ps_dec->s_high_profile.s_cavlc_ctxt = ps_dec->s_cavlc_ctxt;
714
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700715 ps_dec->i1_recon_in_thread3_flag = 1;
716 ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_addrecon;
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530717 if(ps_dec->u1_separate_parse)
718 {
719 memcpy(&ps_dec->s_tran_addrecon_parse, &ps_dec->s_tran_addrecon,
720 sizeof(tfr_ctxt_t));
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700721 if(ps_dec->u4_num_cores >= 3 && ps_dec->i1_recon_in_thread3_flag)
722 {
723 memcpy(&ps_dec->s_tran_iprecon, &ps_dec->s_tran_addrecon,
724 sizeof(tfr_ctxt_t));
725 ps_dec->ps_frame_buf_ip_recon = &ps_dec->s_tran_iprecon;
726 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530727 }
728
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700729
730 ih264d_init_deblk_tfr_ctxt(ps_dec,&(ps_dec->s_pad_mgr), &(ps_dec->s_tran_addrecon),
731 ps_dec->u2_frm_wd_in_mbs, 0);
732
733 ps_dec->ps_cur_deblk_mb = ps_dec->ps_deblk_pic;
734 ps_dec->u4_cur_deblk_mb_num = 0;
735
736 ps_dec->u4_deblk_mb_x = 0;
737 ps_dec->u4_deblk_mb_y = 0;
Harish Mahendrakar33db7a02016-04-20 16:13:52 +0530738 ps_dec->pu4_wt_ofsts = ps_dec->pu4_wts_ofsts_mat;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -0700739
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530740 H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex);
741 return OK;
742}
743
744/*!
745 **************************************************************************
746 * \if Function name : ih264d_deblock_display \endif
747 *
748 * \brief : The function callls the deblocking routine and manages
749 : the Recon buffers and displays .
750 * \return : Nothing
751 *
752 **************************************************************************
753 */
754WORD32 ih264d_end_of_pic_dispbuf_mgr(dec_struct_t * ps_dec)
755{
756 dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice;
757 UWORD8 u1_num_of_users = 0;
758 WORD32 ret;
759
760 H264_MUTEX_LOCK(&ps_dec->process_disp_mutex);
761 if(1)
762 {
763
764 {
765 ih264d_delete_nonref_nondisplay_pics(ps_dec->ps_dpb_mgr);
766 if(ps_cur_slice->u1_mmco_equalto5
767 || (ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL))
768 {
769 ps_dec->ps_cur_pic->i4_poc = 0;
770 if(ps_dec->u2_total_mbs_coded
771 == (ps_dec->ps_cur_sps->u2_max_mb_addr + 1))
772 ih264d_reset_ref_bufs(ps_dec->ps_dpb_mgr);
773 ih264d_release_display_bufs(ps_dec);
774 }
775 if(ps_dec->u4_num_reorder_frames_at_init != 0)
776 {
777 ret = ih264d_assign_display_seq(ps_dec);
778 if(ret != OK)
779 return ret;
780 }
781 }
782
783 if(ps_cur_slice->u1_nal_ref_idc)
784 {
785 /* Mark pic buf as needed for reference */
786 ih264_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
787 ps_dec->u1_pic_buf_id,
788 BUF_MGR_REF);
789 /* Mark mv buf as needed for reference */
790 ih264_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
791 ps_dec->au1_pic_buf_id_mv_buf_id_map[ps_dec->u1_pic_buf_id],
792 BUF_MGR_REF);
793 ps_dec->au1_pic_buf_ref_flag[ps_dec->u1_pic_buf_id] = 1;
794 }
795
796 /* 420 consumer */
797 /* Increment the number of users by 1 for display based upon */
798 /*the SEEK KEY FRAME control sent to decoder */
799 if(((0 == ps_dec->u1_last_pic_not_decoded)
800 && (0
801 == (ps_dec->ps_cur_pic->u4_pack_slc_typ
802 & ps_dec->u4_skip_frm_mask)))
803 || (ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL))
804 {
805 /* Mark pic buf as needed for display */
806 ih264_buf_mgr_set_status((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
807 ps_dec->u1_pic_buf_id,
808 BUF_MGR_IO);
809
810 }
811
812 if(!ps_cur_slice->u1_field_pic_flag
813 || ((TOP_FIELD_ONLY | BOT_FIELD_ONLY)
814 != ps_dec->u1_top_bottom_decoded))
815 {
816 pic_buffer_t *ps_cur_pic = ps_dec->ps_cur_pic;
817 ps_cur_pic->u2_disp_width = ps_dec->u2_disp_width;
818 ps_cur_pic->u2_disp_height = ps_dec->u2_disp_height >> 1;
819
820 ps_cur_pic->u2_crop_offset_y = ps_dec->u2_crop_offset_y;
821 ps_cur_pic->u2_crop_offset_uv = ps_dec->u2_crop_offset_uv;
822 ps_cur_pic->u1_pic_type = 0;
823
824 ret = ih264d_insert_pic_in_display_list(
825 ps_dec->ps_dpb_mgr,
826 ps_dec->u1_pic_buf_id,
827 ps_dec->i4_prev_max_display_seq
828 + ps_dec->ps_cur_pic->i4_poc,
829 ps_dec->ps_cur_pic->i4_frame_num);
830 if(ret != OK)
831 return ret;
832
833 {
834 ivd_video_decode_op_t * ps_dec_output =
835 (ivd_video_decode_op_t *)ps_dec->pv_dec_out;
836
837 ps_dec_output->u4_frame_decoded_flag = 1;
838 }
839 if(ps_dec->au1_pic_buf_ref_flag[ps_dec->u1_pic_buf_id] == 0)
840 {
841 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
842 ps_dec->au1_pic_buf_id_mv_buf_id_map[ps_dec->u1_pic_buf_id],
843 BUF_MGR_REF);
844 ps_dec->au1_pic_buf_ref_flag[ps_dec->u1_pic_buf_id] = 0;
845
846 }
847 }
848 else
849 {
850 H264_DEC_DEBUG_PRINT("pic not inserted display %d %d\n",
851 ps_cur_slice->u1_field_pic_flag,
852 ps_dec->u1_second_field);
853 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530854
855 if(!ps_cur_slice->u1_field_pic_flag
856 || ((TOP_FIELD_ONLY | BOT_FIELD_ONLY)
857 == ps_dec->u1_top_bottom_decoded))
858 {
859 if(ps_dec->u4_num_reorder_frames_at_init == 0)
860 {
861 ret = ih264d_assign_display_seq(ps_dec);
862 if(ret != OK)
863 return ret;
864 }
865 }
866 }
867
868 H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex);
869
870 return OK;
871}
872
873void ih264d_err_pic_dispbuf_mgr(dec_struct_t *ps_dec)
874{
875 dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice;
876 ivd_video_decode_op_t * ps_dec_output =
877 (ivd_video_decode_op_t *)ps_dec->pv_dec_out;
878
879 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
880 ps_dec->u1_pic_buf_id,
881 BUF_MGR_REF);
882 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_mv_buf_mgr,
883 ps_dec->au1_pic_buf_id_mv_buf_id_map[ps_dec->u1_pic_buf_id],
884 BUF_MGR_REF);
885 ih264_buf_mgr_release((buf_mgr_t *)ps_dec->pv_pic_buf_mgr,
886 ps_dec->u1_pic_buf_id,
887 BUF_MGR_IO);
888}
889
890void ih264d_deblock_picture(void *ptr)
891{
892 dec_struct_t *ps_dec = (dec_struct_t *)ptr;
893
894 {
895 /*Deblock picture only if all the mb's in the frame have been decoded*/
896 if(ps_dec->u1_pic_decode_done == 1)
897 {
898 if(ps_dec->ps_cur_slice->u1_mbaff_frame_flag
899 || ps_dec->ps_cur_slice->u1_field_pic_flag)
900 {
901 ps_dec->p_DeblockPicture[ps_dec->ps_cur_slice->u1_mbaff_frame_flag](
902 ps_dec);
903 }
904 else
905
906 {
907
908 ih264d_deblock_picture_progressive(ps_dec);
909 }
910
911 }
912 }
913
914}
915
916/*!
917 **************************************************************************
918 * \if Function name : ih264d_deblock_display \endif
919 *
920 * \brief : The function callls the deblocking routine and manages
921 : the Recon buffers and displays .
922 * \return : Nothing
923 *
924 **************************************************************************
925 */
926WORD32 ih264d_deblock_display(dec_struct_t *ps_dec)
927{
928 WORD32 ret;
929 /* Call deblocking */
930 ih264d_deblock_picture(ps_dec);
931
932 ret = ih264d_end_of_pic_dispbuf_mgr(ps_dec);
933 if(ret != OK)
934 return ret;
935
936 return OK;
937}
938
939/*
940 *!
941 **************************************************************************
942 * \if Function name : EndofPoc \endif
943 *
944 * \brief
945 * EndofPoc Processing
946 *
947 * \return
948 * 0 on Success and Error code otherwise
949 **************************************************************************
950 */
951
952WORD32 ih264d_end_of_pic(dec_struct_t *ps_dec,
953 UWORD8 u1_is_idr_slice,
954 UWORD16 u2_frame_num)
955{
956 dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice;
957 WORD32 ret;
958
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530959 ps_dec->u2_mbx = 0xffff;
960 ps_dec->u2_mby = 0;
961 {
962 dec_err_status_t * ps_err = ps_dec->ps_dec_err_status;
963 if(ps_err->u1_err_flag & REJECT_CUR_PIC)
964 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530965 ih264d_err_pic_dispbuf_mgr(ps_dec);
Hamsalekha S9f0dcba2015-06-09 15:54:31 +0530966 return ERROR_NEW_FRAME_EXPECTED;
Hamsalekha S8d3d3032015-03-13 21:24:58 +0530967 }
968 }
969
970 H264_MUTEX_LOCK(&ps_dec->process_disp_mutex);
971 ret = ih264d_end_of_pic_processing(ps_dec);
972 if(ret != OK)
973 return ret;
974 ps_dec->u2_total_mbs_coded = 0;
975 /*--------------------------------------------------------------------*/
976 /* ih264d_decode_pic_order_cnt - calculate the Pic Order Cnt */
977 /* Needed to detect end of picture */
978 /*--------------------------------------------------------------------*/
979 {
980 pocstruct_t *ps_prev_poc = &ps_dec->s_prev_pic_poc;
981 pocstruct_t *ps_cur_poc = &ps_dec->s_cur_pic_poc;
982 if((0 == u1_is_idr_slice) && ps_cur_slice->u1_nal_ref_idc)
983 ps_dec->u2_prev_ref_frame_num = ps_cur_slice->u2_frame_num;
984
985 if(u1_is_idr_slice || ps_cur_slice->u1_mmco_equalto5)
986 ps_dec->u2_prev_ref_frame_num = 0;
987
988 if(ps_dec->ps_cur_sps->u1_gaps_in_frame_num_value_allowed_flag)
989 {
990 ret = ih264d_decode_gaps_in_frame_num(ps_dec, u2_frame_num);
991 if(ret != OK)
992 return ret;
993 }
994
995 ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst;
996 ps_prev_poc->u2_frame_num = ps_cur_poc->u2_frame_num;
997 ps_prev_poc->u1_mmco_equalto5 = ps_cur_slice->u1_mmco_equalto5;
998 if(ps_cur_slice->u1_nal_ref_idc)
999 {
1000 ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb;
1001 ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb;
1002 ps_prev_poc->i4_delta_pic_order_cnt_bottom =
1003 ps_cur_poc->i4_delta_pic_order_cnt_bottom;
1004 ps_prev_poc->i4_delta_pic_order_cnt[0] =
1005 ps_cur_poc->i4_delta_pic_order_cnt[0];
1006 ps_prev_poc->i4_delta_pic_order_cnt[1] =
1007 ps_cur_poc->i4_delta_pic_order_cnt[1];
1008 ps_prev_poc->u1_bot_field = ps_cur_poc->u1_bot_field;
1009 }
1010 }
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301011
1012 H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex);
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301013
1014 return OK;
1015}
1016
1017/*!
1018 **************************************************************************
1019 * \if Function name : DecodeSlice \endif
1020 *
1021 * \brief
1022 * Parses a slice
1023 *
1024 * \return
1025 * 0 on Success and Error code otherwise
1026 **************************************************************************
1027 */
1028
1029WORD32 ih264d_parse_decode_slice(UWORD8 u1_is_idr_slice,
1030 UWORD8 u1_nal_ref_idc,
1031 dec_struct_t *ps_dec /* Decoder parameters */
1032 )
1033{
1034 dec_bit_stream_t * ps_bitstrm = ps_dec->ps_bitstrm;
1035 dec_pic_params_t *ps_pps;
1036 dec_seq_params_t *ps_seq;
1037 dec_slice_params_t *ps_cur_slice = ps_dec->ps_cur_slice;
1038 pocstruct_t s_tmp_poc;
1039 WORD32 i_delta_poc[2];
1040 WORD32 i4_poc = 0;
1041 UWORD16 u2_first_mb_in_slice, u2_frame_num;
1042 UWORD8 u1_field_pic_flag, u1_redundant_pic_cnt = 0, u1_slice_type;
1043 UWORD32 u4_idr_pic_id = 0;
1044 UWORD8 u1_bottom_field_flag, u1_pic_order_cnt_type;
1045
1046 UWORD8 u1_nal_unit_type;
1047 UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer;
1048 UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst;
1049 WORD8 i1_is_end_of_poc;
1050
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001051 WORD32 ret, end_of_frame;
1052 WORD32 prev_slice_err, num_mb_skipped;
1053 UWORD8 u1_mbaff;
1054 pocstruct_t *ps_cur_poc;
1055
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301056 UWORD32 u4_temp;
1057 WORD32 i_temp;
1058 UWORD32 u4_call_end_of_pic = 0;
1059
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301060 /* read FirstMbInSlice and slice type*/
1061 ps_dec->ps_dpb_cmds->u1_dpb_commands_read_slc = 0;
1062 u2_first_mb_in_slice = ih264d_uev(pu4_bitstrm_ofst,
1063 pu4_bitstrm_buf);
1064 if(u2_first_mb_in_slice
1065 > (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs))
1066 {
1067
1068 return ERROR_CORRUPTED_SLICE;
1069 }
1070
1071 /*we currently don not support ASO*/
1072 if(((u2_first_mb_in_slice << ps_cur_slice->u1_mbaff_frame_flag)
1073 <= ps_dec->u2_cur_mb_addr) && (ps_dec->u2_cur_mb_addr != 0)
1074 && (ps_dec->u4_first_slice_in_pic != 0))
1075 {
1076 return ERROR_CORRUPTED_SLICE;
1077 }
1078
1079 COPYTHECONTEXT("SH: first_mb_in_slice",u2_first_mb_in_slice);
1080
1081 u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf);
1082
1083 if(u4_temp > 9)
1084 return ERROR_INV_SLC_TYPE_T;
1085
1086 u1_slice_type = u4_temp;
1087 COPYTHECONTEXT("SH: slice_type",(u1_slice_type));
1088 ps_dec->u1_sl_typ_5_9 = 0;
1089 /* Find Out the Slice Type is 5 to 9 or not then Set the Flag */
1090 /* u1_sl_typ_5_9 = 1 .Which tells that all the slices in the Pic*/
1091 /* will be of same type of current */
1092 if(u1_slice_type > 4)
1093 {
1094 u1_slice_type -= 5;
1095 ps_dec->u1_sl_typ_5_9 = 1;
1096 }
1097
1098 {
1099 UWORD32 skip;
1100
1101 if((ps_dec->i4_app_skip_mode == IVD_SKIP_PB)
1102 || (ps_dec->i4_dec_skip_mode == IVD_SKIP_PB))
1103 {
1104 UWORD32 u4_bit_stream_offset = 0;
1105
1106 if(ps_dec->u1_nal_unit_type == IDR_SLICE_NAL)
1107 {
1108 skip = 0;
1109
1110 ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE;
1111 }
1112 else if((I_SLICE == u1_slice_type)
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001113 && (1 >= ps_dec->ps_cur_sps->u1_num_ref_frames))
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301114 {
1115 skip = 0;
1116
1117 ps_dec->i4_dec_skip_mode = IVD_SKIP_NONE;
1118 }
1119 else
1120 {
1121 skip = 1;
1122 }
1123
1124 /* If one frame worth of data is already skipped, do not skip the next one */
1125 if((0 == u2_first_mb_in_slice) && (1 == ps_dec->u4_prev_nal_skipped))
1126 {
1127 skip = 0;
1128 }
1129
1130 if(skip)
1131 {
1132 ps_dec->u4_prev_nal_skipped = 1;
1133 ps_dec->i4_dec_skip_mode = IVD_SKIP_PB;
1134 return 0;
1135 }
1136 else
1137 {
1138 /* If the previous NAL was skipped, then
1139 do not process that buffer in this call.
1140 Return to app and process it in the next call.
1141 This is necessary to handle cases where I/IDR is not complete in
1142 the current buffer and application intends to fill the remaining part of the bitstream
1143 later. This ensures we process only frame worth of data in every call */
1144 if(1 == ps_dec->u4_prev_nal_skipped)
1145 {
1146 ps_dec->u4_return_to_app = 1;
1147 return 0;
1148 }
1149 }
1150 }
1151
1152 }
1153
1154 u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf);
1155 if(u4_temp & MASK_ERR_PIC_SET_ID)
1156 return ERROR_INV_SPS_PPS_T;
1157 /* discard slice if pic param is invalid */
1158 COPYTHECONTEXT("SH: pic_parameter_set_id", u4_temp);
1159 ps_pps = &ps_dec->ps_pps[u4_temp];
1160 if(FALSE == ps_pps->u1_is_valid)
1161 {
1162 return ERROR_INV_SPS_PPS_T;
1163 }
1164 ps_seq = ps_pps->ps_sps;
1165 if(!ps_seq)
1166 return ERROR_INV_SPS_PPS_T;
1167 if(FALSE == ps_seq->u1_is_valid)
1168 return ERROR_INV_SPS_PPS_T;
1169
1170 /* Get the frame num */
1171 u2_frame_num = ih264d_get_bits_h264(ps_bitstrm,
1172 ps_seq->u1_bits_in_frm_num);
1173// H264_DEC_DEBUG_PRINT("FRAME %d First MB in slice: %d\n", u2_frame_num, u2_first_mb_in_slice);
1174
1175 COPYTHECONTEXT("SH: frame_num", u2_frame_num);
1176// H264_DEC_DEBUG_PRINT("Second field: %d frame num: %d prv_frame_num: %d \n", ps_dec->u1_second_field, u2_frame_num, ps_dec->u2_prv_frame_num);
1177
1178 /* Get the field related flags */
1179 if(!ps_seq->u1_frame_mbs_only_flag)
1180 {
1181
1182 u1_field_pic_flag = ih264d_get_bit_h264(ps_bitstrm);
1183 COPYTHECONTEXT("SH: field_pic_flag", u1_field_pic_flag);
1184 u1_bottom_field_flag = 0;
1185
1186 if(u1_field_pic_flag)
1187 {
1188 ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan_fld;
1189 u1_bottom_field_flag = ih264d_get_bit_h264(ps_bitstrm);
1190 COPYTHECONTEXT("SH: bottom_field_flag", u1_bottom_field_flag);
1191
1192 }
1193 else
1194 {
1195 ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan;
1196 }
1197 }
1198 else
1199 {
1200 u1_field_pic_flag = 0;
1201 u1_bottom_field_flag = 0;
1202
1203 ps_dec->pu1_inv_scan = (UWORD8 *)gau1_ih264d_inv_scan;
1204 }
1205
1206 u1_nal_unit_type = SLICE_NAL;
1207 if(u1_is_idr_slice)
1208 {
1209 if(0 == u1_field_pic_flag)
1210 {
1211 ps_dec->u1_top_bottom_decoded = TOP_FIELD_ONLY | BOT_FIELD_ONLY;
1212 }
1213 u1_nal_unit_type = IDR_SLICE_NAL;
1214 u4_idr_pic_id = ih264d_uev(pu4_bitstrm_ofst,
1215 pu4_bitstrm_buf);
1216 if(u4_idr_pic_id > 65535)
1217 return ERROR_INV_SPS_PPS_T;
1218 COPYTHECONTEXT("SH: ", u4_idr_pic_id);
1219 }
1220
1221 /* read delta pic order count information*/
1222 i_delta_poc[0] = i_delta_poc[1] = 0;
1223 s_tmp_poc.i4_pic_order_cnt_lsb = 0;
1224 s_tmp_poc.i4_delta_pic_order_cnt_bottom = 0;
1225 u1_pic_order_cnt_type = ps_seq->u1_pic_order_cnt_type;
1226 if(u1_pic_order_cnt_type == 0)
1227 {
1228 i_temp = ih264d_get_bits_h264(
1229 ps_bitstrm,
1230 ps_seq->u1_log2_max_pic_order_cnt_lsb_minus);
1231 if(i_temp < 0 || i_temp >= ps_seq->i4_max_pic_order_cntLsb)
1232 return ERROR_INV_SPS_PPS_T;
1233 s_tmp_poc.i4_pic_order_cnt_lsb = i_temp;
1234 COPYTHECONTEXT("SH: pic_order_cnt_lsb", s_tmp_poc.i4_pic_order_cnt_lsb);
1235
1236 if((ps_pps->u1_pic_order_present_flag == 1) && (!u1_field_pic_flag))
1237 {
1238 s_tmp_poc.i4_delta_pic_order_cnt_bottom = ih264d_sev(
1239 pu4_bitstrm_ofst, pu4_bitstrm_buf);
1240 //if(s_tmp_poc.i4_delta_pic_order_cnt_bottom > ps_seq->i4_max_pic_order_cntLsb)
1241 COPYTHECONTEXT("SH: delta_pic_order_cnt_bottom",
1242 s_tmp_poc.i4_delta_pic_order_cnt_bottom);
1243 }
1244 }
1245
1246 s_tmp_poc.i4_delta_pic_order_cnt[0] = 0;
1247 s_tmp_poc.i4_delta_pic_order_cnt[1] = 0;
1248 if(u1_pic_order_cnt_type == 1
1249 && (!ps_seq->u1_delta_pic_order_always_zero_flag))
1250 {
1251 s_tmp_poc.i4_delta_pic_order_cnt[0] = ih264d_sev(pu4_bitstrm_ofst,
1252 pu4_bitstrm_buf);
1253 COPYTHECONTEXT("SH: delta_pic_order_cnt[0]",
1254 s_tmp_poc.i4_delta_pic_order_cnt[0]);
1255
1256 if(ps_pps->u1_pic_order_present_flag && !u1_field_pic_flag)
1257 {
1258 s_tmp_poc.i4_delta_pic_order_cnt[1] = ih264d_sev(
1259 pu4_bitstrm_ofst, pu4_bitstrm_buf);
1260 COPYTHECONTEXT("SH: delta_pic_order_cnt[1]",
1261 s_tmp_poc.i4_delta_pic_order_cnt[1]);
1262 }
1263 }
1264
1265 if(ps_pps->u1_redundant_pic_cnt_present_flag)
1266 {
1267 u4_temp = ih264d_uev(pu4_bitstrm_ofst, pu4_bitstrm_buf);
1268 if(u4_temp > MAX_REDUNDANT_PIC_CNT)
1269 return ERROR_INV_SPS_PPS_T;
1270 u1_redundant_pic_cnt = u4_temp;
1271 COPYTHECONTEXT("SH: redundant_pic_cnt", u1_redundant_pic_cnt);
1272 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001273
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301274 /*--------------------------------------------------------------------*/
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001275 /* Check if the slice is part of new picture */
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301276 /*--------------------------------------------------------------------*/
1277 i1_is_end_of_poc = 0;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001278 if(!ps_dec->u1_first_slice_in_stream)
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301279 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301280 i1_is_end_of_poc = ih264d_is_end_of_pic(u2_frame_num, u1_nal_ref_idc,
1281 &s_tmp_poc, &ps_dec->s_cur_pic_poc,
1282 ps_cur_slice, u1_pic_order_cnt_type,
1283 u1_nal_unit_type, u4_idr_pic_id,
1284 u1_field_pic_flag,
1285 u1_bottom_field_flag);
1286
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301287 /* since we support only Full frame decode, every new process should
1288 * process a new pic
1289 */
1290 if((ps_dec->u4_first_slice_in_pic == 2) && (i1_is_end_of_poc == 0))
1291 {
1292 /* if it is the first slice is process call ,it should be a new frame. If it is not
1293 * reject current pic and dont add it to dpb
1294 */
1295 ps_dec->ps_dec_err_status->u1_err_flag |= REJECT_CUR_PIC;
1296 i1_is_end_of_poc = 1;
1297 }
1298 else
1299 {
1300 /* reset REJECT_CUR_PIC */
1301 ps_dec->ps_dec_err_status->u1_err_flag &= MASK_REJECT_CUR_PIC;
1302 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001303 }
1304
1305 /*--------------------------------------------------------------------*/
1306 /* Check for error in slice and parse the missing/corrupted MB's */
1307 /* as skip-MB's in an inserted P-slice */
1308 /*--------------------------------------------------------------------*/
1309 u1_mbaff = ps_seq->u1_mb_aff_flag && (!u1_field_pic_flag);
1310 prev_slice_err = 0;
1311
1312 if(i1_is_end_of_poc || ps_dec->u1_first_slice_in_stream)
1313 {
1314 if(u2_frame_num != ps_dec->u2_prv_frame_num
1315 && ps_dec->u1_top_bottom_decoded != 0
1316 && ps_dec->u1_top_bottom_decoded
1317 != (TOP_FIELD_ONLY | BOT_FIELD_ONLY))
1318 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301319 ps_dec->u1_dangling_field = 1;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001320 if(ps_dec->u4_first_slice_in_pic)
1321 {
1322 // first slice - dangling field
1323 prev_slice_err = 1;
1324 }
1325 else
1326 {
1327 // last slice - dangling field
1328 prev_slice_err = 2;
1329 }
1330
1331 if(ps_dec->u1_top_bottom_decoded ==TOP_FIELD_ONLY)
1332 ps_cur_slice->u1_bottom_field_flag = 1;
1333 else
1334 ps_cur_slice->u1_bottom_field_flag = 0;
1335
1336 num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
1337 - ps_dec->u2_total_mbs_coded;
1338 ps_cur_poc = &ps_dec->s_cur_pic_poc;
1339
1340 u1_is_idr_slice = ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL;
1341 }
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301342 else if(ps_dec->u4_first_slice_in_pic == 2)
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001343 {
1344 if(u2_first_mb_in_slice > 0)
1345 {
1346 // first slice - missing/header corruption
1347 prev_slice_err = 1;
1348 num_mb_skipped = u2_first_mb_in_slice << u1_mbaff;
1349 ps_cur_poc = &s_tmp_poc;
1350
1351 // initializing slice parameters
1352 ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id;
1353 ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag;
1354 ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag;
1355 ps_cur_slice->i4_pic_order_cnt_lsb =
1356 s_tmp_poc.i4_pic_order_cnt_lsb;
1357 ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type;
1358 ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt;
1359 ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc;
1360 ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type;
1361 }
1362 }
1363 else
1364 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301365
1366 if(ps_dec->u4_first_slice_in_pic)
1367 {
1368 /* if valid slice header is not decoded do start of pic processing
1369 * since in the current process call, frame num is not updated in the slice structure yet
1370 * ih264d_is_end_of_pic is checked with valid frame num of previous process call,
1371 * although i1_is_end_of_poc is set there could be more slices in the frame,
1372 * so conceal only till cur slice */
1373 prev_slice_err = 1;
1374 num_mb_skipped = u2_first_mb_in_slice << u1_mbaff;
1375 }
1376 else
1377 {
1378 /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame
1379 * completely */
1380 prev_slice_err = 2;
1381 num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
1382 - ps_dec->u2_total_mbs_coded;
1383 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001384 ps_cur_poc = &s_tmp_poc;
1385 }
1386 }
1387 else
1388 {
1389 if((u2_first_mb_in_slice << u1_mbaff) > ps_dec->u2_total_mbs_coded)
1390 {
1391 // previous slice - missing/corruption
1392 prev_slice_err = 2;
1393 num_mb_skipped = (u2_first_mb_in_slice << u1_mbaff)
1394 - ps_dec->u2_total_mbs_coded;
1395 ps_cur_poc = &s_tmp_poc;
1396 }
1397 else if((u2_first_mb_in_slice << u1_mbaff) < ps_dec->u2_total_mbs_coded)
1398 {
1399 return ERROR_CORRUPTED_SLICE;
1400 }
1401 }
1402
1403 if(prev_slice_err)
1404 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301405 ret = ih264d_mark_err_slice_skip(ps_dec, num_mb_skipped, u1_is_idr_slice, u2_frame_num, ps_cur_poc, prev_slice_err);
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001406
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301407 if(ps_dec->u1_dangling_field == 1)
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001408 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301409 ps_dec->u1_second_field = 1 - ps_dec->u1_second_field;
1410 ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag;
1411 ps_dec->u2_prv_frame_num = u2_frame_num;
1412 ps_dec->u1_first_slice_in_stream = 0;
1413 return ERROR_DANGLING_FIELD_IN_PIC;
1414 }
1415
1416 if(prev_slice_err == 2)
1417 {
1418 ps_dec->u1_first_slice_in_stream = 0;
1419 return ERROR_INCOMPLETE_FRAME;
1420 }
1421
1422 if(ps_dec->u2_total_mbs_coded
1423 >= ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
1424 {
1425 /* return if all MBs in frame are parsed*/
1426 ps_dec->u1_first_slice_in_stream = 0;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001427 return ERROR_IN_LAST_SLICE_OF_PIC;
1428 }
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301429
1430 if(ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC)
1431 {
1432 ih264d_err_pic_dispbuf_mgr(ps_dec);
1433 return ERROR_NEW_FRAME_EXPECTED;
1434 }
1435
1436 if(ret != OK)
1437 return ret;
1438
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001439 i1_is_end_of_poc = 0;
1440 }
1441
1442 if (ps_dec->u4_first_slice_in_pic == 0)
Harish Mahendrakar5e4f64c2016-06-01 13:31:45 +05301443 {
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001444 ps_dec->ps_parse_cur_slice++;
Harish Mahendrakar5e4f64c2016-06-01 13:31:45 +05301445 ps_dec->u2_cur_slice_num++;
1446 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001447
Harish Mahendrakarbc71ad22016-09-17 17:00:37 +05301448 // in the case of single core increment ps_decode_cur_slice
1449 if((ps_dec->u1_separate_parse == 0) && (ps_dec->u4_first_slice_in_pic == 0))
1450 {
1451 ps_dec->ps_decode_cur_slice++;
1452 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001453 ps_dec->u1_slice_header_done = 0;
1454
1455 /*--------------------------------------------------------------------*/
1456 /* If the slice is part of new picture, do End of Pic processing. */
1457 /*--------------------------------------------------------------------*/
1458 if(!ps_dec->u1_first_slice_in_stream)
1459 {
1460 UWORD8 uc_mbs_exceed = 0;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301461
1462 if(ps_dec->u2_total_mbs_coded
1463 == (ps_dec->ps_cur_sps->u2_max_mb_addr + 1))
1464 {
1465 /*u2_total_mbs_coded is forced to u2_max_mb_addr+ 1 at the end of decode ,so
1466 ,if it is first slice in pic dont consider u2_total_mbs_coded to detect new picture */
1467 if(ps_dec->u4_first_slice_in_pic == 0)
1468 uc_mbs_exceed = 1;
1469 }
1470
1471 if(i1_is_end_of_poc || uc_mbs_exceed)
1472 {
1473
1474 if(1 == ps_dec->u1_last_pic_not_decoded)
1475 {
1476 ret = ih264d_end_of_pic_dispbuf_mgr(ps_dec);
1477
1478 if(ret != OK)
1479 return ret;
1480
1481 ret = ih264d_end_of_pic(ps_dec, u1_is_idr_slice, u2_frame_num);
1482 if(ret != OK)
1483 return ret;
1484#if WIN32
1485 H264_DEC_DEBUG_PRINT(" ------ PIC SKIPPED ------\n");
1486#endif
1487 return RET_LAST_SKIP;
1488 }
1489 else
1490 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301491 ret = ih264d_end_of_pic(ps_dec, u1_is_idr_slice, u2_frame_num);
1492 if(ret != OK)
1493 return ret;
1494 }
1495
1496 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301497 }
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001498
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301499 if(u1_field_pic_flag)
1500 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301501 ps_dec->u2_prv_frame_num = u2_frame_num;
1502 }
1503
1504 if(ps_cur_slice->u1_mmco_equalto5)
1505 {
1506 WORD32 i4_temp_poc;
1507 WORD32 i4_top_field_order_poc, i4_bot_field_order_poc;
1508
1509 if(!ps_cur_slice->u1_field_pic_flag) // or a complementary field pair
1510 {
1511 i4_top_field_order_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt;
1512 i4_bot_field_order_poc =
1513 ps_dec->ps_cur_pic->i4_bottom_field_order_cnt;
1514 i4_temp_poc = MIN(i4_top_field_order_poc,
1515 i4_bot_field_order_poc);
1516 }
1517 else if(!ps_cur_slice->u1_bottom_field_flag)
1518 i4_temp_poc = ps_dec->ps_cur_pic->i4_top_field_order_cnt;
1519 else
1520 i4_temp_poc = ps_dec->ps_cur_pic->i4_bottom_field_order_cnt;
1521
1522 ps_dec->ps_cur_pic->i4_top_field_order_cnt = i4_temp_poc
1523 - ps_dec->ps_cur_pic->i4_top_field_order_cnt;
1524 ps_dec->ps_cur_pic->i4_bottom_field_order_cnt = i4_temp_poc
1525 - ps_dec->ps_cur_pic->i4_bottom_field_order_cnt;
1526 ps_dec->ps_cur_pic->i4_poc = i4_temp_poc;
1527 ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc;
1528 }
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301529 if(ps_dec->u4_first_slice_in_pic == 2)
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301530 {
1531 ret = ih264d_decode_pic_order_cnt(u1_is_idr_slice, u2_frame_num,
1532 &ps_dec->s_prev_pic_poc,
1533 &s_tmp_poc, ps_cur_slice, ps_pps,
1534 u1_nal_ref_idc,
1535 u1_bottom_field_flag,
1536 u1_field_pic_flag, &i4_poc);
1537 if(ret != OK)
1538 return ret;
1539 /* Display seq no calculations */
1540 if(i4_poc >= ps_dec->i4_max_poc)
1541 ps_dec->i4_max_poc = i4_poc;
1542 /* IDR Picture or POC wrap around */
1543 if(i4_poc == 0)
1544 {
1545 ps_dec->i4_prev_max_display_seq = ps_dec->i4_prev_max_display_seq
1546 + ps_dec->i4_max_poc
1547 + ps_dec->u1_max_dec_frame_buffering + 1;
1548 ps_dec->i4_max_poc = 0;
1549 }
1550 }
1551
1552 /*--------------------------------------------------------------------*/
1553 /* Copy the values read from the bitstream to the slice header and then*/
1554 /* If the slice is first slice in picture, then do Start of Picture */
1555 /* processing. */
1556 /*--------------------------------------------------------------------*/
1557 ps_cur_slice->i4_delta_pic_order_cnt[0] = i_delta_poc[0];
1558 ps_cur_slice->i4_delta_pic_order_cnt[1] = i_delta_poc[1];
1559 ps_cur_slice->u4_idr_pic_id = u4_idr_pic_id;
1560 ps_cur_slice->u2_first_mb_in_slice = u2_first_mb_in_slice;
1561 ps_cur_slice->u1_field_pic_flag = u1_field_pic_flag;
1562 ps_cur_slice->u1_bottom_field_flag = u1_bottom_field_flag;
1563 ps_cur_slice->u1_slice_type = u1_slice_type;
1564 ps_cur_slice->i4_pic_order_cnt_lsb = s_tmp_poc.i4_pic_order_cnt_lsb;
1565
1566 ps_cur_slice->u1_nal_unit_type = u1_nal_unit_type;
1567 ps_cur_slice->u1_redundant_pic_cnt = u1_redundant_pic_cnt;
1568 ps_cur_slice->u1_nal_ref_idc = u1_nal_ref_idc;
1569 ps_cur_slice->u1_pic_order_cnt_type = u1_pic_order_cnt_type;
1570
1571 if(ps_seq->u1_frame_mbs_only_flag)
1572 ps_cur_slice->u1_direct_8x8_inference_flag =
1573 ps_seq->u1_direct_8x8_inference_flag;
1574 else
1575 ps_cur_slice->u1_direct_8x8_inference_flag = 1;
1576
1577 if(u1_slice_type == B_SLICE)
1578 {
1579 ps_cur_slice->u1_direct_spatial_mv_pred_flag = ih264d_get_bit_h264(
1580 ps_bitstrm);
1581 COPYTHECONTEXT("SH: direct_spatial_mv_pred_flag",
1582 ps_cur_slice->u1_direct_spatial_mv_pred_flag);
1583
1584 if(ps_cur_slice->u1_direct_spatial_mv_pred_flag)
1585 ps_cur_slice->pf_decodeDirect = ih264d_decode_spatial_direct;
1586 else
1587 ps_cur_slice->pf_decodeDirect = ih264d_decode_temporal_direct;
1588 if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag)))
1589 ps_dec->pf_mvpred = ih264d_mvpred_nonmbaffB;
1590 }
1591 else
1592 {
1593 if(!((ps_pps->ps_sps->u1_mb_aff_flag) && (!u1_field_pic_flag)))
1594 ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff;
1595 }
1596
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301597 if(ps_dec->u4_first_slice_in_pic == 2)
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301598 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301599 if(u2_first_mb_in_slice == 0)
1600 {
1601 ret = ih264d_start_of_pic(ps_dec, i4_poc, &s_tmp_poc, u2_frame_num, ps_pps);
1602 if(ret != OK)
1603 return ret;
1604 }
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301605
1606 ps_dec->u4_output_present = 0;
1607
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301608 {
1609 ih264d_get_next_display_field(ps_dec,
1610 ps_dec->ps_out_buffer,
1611 &(ps_dec->s_disp_op));
1612 /* If error code is non-zero then there is no buffer available for display,
1613 hence avoid format conversion */
1614
1615 if(0 != ps_dec->s_disp_op.u4_error_code)
1616 {
1617 ps_dec->u4_fmt_conv_cur_row = ps_dec->s_disp_frame_info.u4_y_ht;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301618 }
1619 else
1620 ps_dec->u4_output_present = 1;
1621 }
1622 if(ps_dec->u1_separate_parse == 1)
1623 {
1624 if(ps_dec->u4_dec_thread_created == 0)
1625 {
1626 ithread_create(ps_dec->pv_dec_thread_handle, NULL,
1627 (void *)ih264d_decode_picture_thread,
1628 (void *)ps_dec);
1629
1630 ps_dec->u4_dec_thread_created = 1;
1631 }
1632
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001633 if((ps_dec->u4_num_cores == 3) &&
1634 ((ps_dec->u4_app_disable_deblk_frm == 0) || ps_dec->i1_recon_in_thread3_flag)
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301635 && (ps_dec->u4_bs_deblk_thread_created == 0))
1636 {
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001637 ps_dec->u4_start_recon_deblk = 0;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301638 ithread_create(ps_dec->pv_bs_deblk_thread_handle, NULL,
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001639 (void *)ih264d_recon_deblk_thread,
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301640 (void *)ps_dec);
1641 ps_dec->u4_bs_deblk_thread_created = 1;
1642 }
1643 }
1644
1645 }
1646
1647 /* INITIALIZATION of fn ptrs for MC and formMbPartInfo functions */
1648 {
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001649 UWORD8 uc_nofield_nombaff;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301650
1651
1652
1653 uc_nofield_nombaff = ((ps_dec->ps_cur_slice->u1_field_pic_flag == 0)
1654 && (ps_dec->ps_cur_slice->u1_mbaff_frame_flag == 0)
1655 && (u1_slice_type != B_SLICE)
1656 && (ps_dec->ps_cur_pps->u1_wted_pred_flag == 0));
1657
1658 /* Initialise MC and formMbPartInfo fn ptrs one time based on profile_idc */
1659
1660 if(uc_nofield_nombaff)
1661 {
1662 ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_bp;
1663 ps_dec->p_motion_compensate = ih264d_motion_compensate_bp;
1664 }
1665 else
1666 {
1667 ps_dec->p_form_mb_part_info = ih264d_form_mb_part_info_mp;
1668 ps_dec->p_motion_compensate = ih264d_motion_compensate_mp;
1669 }
1670
1671
1672 }
1673
1674 /*
1675 * Decide whether to decode the current picture or not
1676 */
1677 {
1678 dec_err_status_t * ps_err = ps_dec->ps_dec_err_status;
1679 if(ps_err->u4_frm_sei_sync == u2_frame_num)
1680 {
1681 ps_err->u1_err_flag = ACCEPT_ALL_PICS;
1682 ps_err->u4_frm_sei_sync = SYNC_FRM_DEFAULT;
1683 }
1684 ps_err->u4_cur_frm = u2_frame_num;
1685 }
1686
1687 /* Decision for decoding if the picture is to be skipped */
1688 {
1689 WORD32 i4_skip_b_pic, i4_skip_p_pic;
1690
1691 i4_skip_b_pic = (ps_dec->u4_skip_frm_mask & B_SLC_BIT)
1692 && (B_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc);
1693
1694 i4_skip_p_pic = (ps_dec->u4_skip_frm_mask & P_SLC_BIT)
1695 && (P_SLICE == u1_slice_type) && (0 == u1_nal_ref_idc);
1696
1697 /**************************************************************/
1698 /* Skip the B picture if skip mask is set for B picture and */
1699 /* Current B picture is a non reference B picture or there is */
1700 /* no user for reference B picture */
1701 /**************************************************************/
1702 if(i4_skip_b_pic)
1703 {
1704 ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT;
1705 /* Don't decode the picture in SKIP-B mode if that picture is B */
1706 /* and also it is not to be used as a reference picture */
1707 ps_dec->u1_last_pic_not_decoded = 1;
1708
1709 return OK;
1710 }
1711 /**************************************************************/
1712 /* Skip the P picture if skip mask is set for P picture and */
1713 /* Current P picture is a non reference P picture or there is */
1714 /* no user for reference P picture */
1715 /**************************************************************/
1716 if(i4_skip_p_pic)
1717 {
1718 ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT;
1719 /* Don't decode the picture in SKIP-P mode if that picture is P */
1720 /* and also it is not to be used as a reference picture */
1721 ps_dec->u1_last_pic_not_decoded = 1;
1722
1723 return OK;
1724 }
1725 }
1726
1727 {
1728 UWORD16 u2_mb_x, u2_mb_y;
1729
1730 ps_dec->i4_submb_ofst = ((u2_first_mb_in_slice
1731 << ps_cur_slice->u1_mbaff_frame_flag) * SUB_BLK_SIZE)
1732 - SUB_BLK_SIZE;
1733 if(u2_first_mb_in_slice)
1734 {
1735 UWORD8 u1_mb_aff;
1736 UWORD8 u1_field_pic;
1737 UWORD16 u2_frm_wd_in_mbs;
1738 u2_frm_wd_in_mbs = ps_seq->u2_frm_wd_in_mbs;
1739 u1_mb_aff = ps_cur_slice->u1_mbaff_frame_flag;
1740 u1_field_pic = ps_cur_slice->u1_field_pic_flag;
1741
1742 {
1743 UWORD32 x_offset;
1744 UWORD32 y_offset;
1745 UWORD32 u4_frame_stride;
1746 tfr_ctxt_t *ps_trns_addr; // = &ps_dec->s_tran_addrecon_parse;
1747
1748 if(ps_dec->u1_separate_parse)
1749 {
1750 ps_trns_addr = &ps_dec->s_tran_addrecon_parse;
1751 }
1752 else
1753 {
1754 ps_trns_addr = &ps_dec->s_tran_addrecon;
1755 }
1756 u2_mb_x = MOD(u2_first_mb_in_slice, u2_frm_wd_in_mbs);
1757 u2_mb_y = DIV(u2_first_mb_in_slice, u2_frm_wd_in_mbs);
1758
1759 u2_mb_y <<= u1_mb_aff;
1760
1761 if((u2_mb_x > u2_frm_wd_in_mbs - 1)
1762 || (u2_mb_y > ps_dec->u2_frm_ht_in_mbs - 1))
1763 {
1764 return ERROR_CORRUPTED_SLICE;
1765 }
1766
1767 u4_frame_stride = ps_dec->u2_frm_wd_y << u1_field_pic;
1768 x_offset = u2_mb_x << 4;
1769 y_offset = (u2_mb_y * u4_frame_stride) << 4;
1770
1771 ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1 + x_offset
1772 + y_offset;
1773
1774 u4_frame_stride = ps_dec->u2_frm_wd_uv << u1_field_pic;
1775 x_offset >>= 1;
1776 y_offset = (u2_mb_y * u4_frame_stride) << 3;
1777
1778 x_offset *= YUV420SP_FACTOR;
1779
1780 ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2 + x_offset
1781 + y_offset;
1782 ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3 + x_offset
1783 + y_offset;
1784
1785 ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y;
1786 ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u;
1787 ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v;
1788
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301789
1790 // assign the deblock structure pointers to start of slice
1791 if(ps_dec->u1_separate_parse == 1)
1792 {
1793 ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic
1794 + (u2_first_mb_in_slice << u1_mb_aff);
1795 }
1796 else
1797 {
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301798 ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic
1799 + (u2_first_mb_in_slice << u1_mb_aff);
1800 }
1801
1802 ps_dec->u2_cur_mb_addr = (u2_first_mb_in_slice << u1_mb_aff);
1803
1804 ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv
1805 + ((u2_first_mb_in_slice << u1_mb_aff) << 4);
1806 }
1807 }
1808 else
1809 {
1810 tfr_ctxt_t *ps_trns_addr;
1811
1812 if(ps_dec->u1_separate_parse)
1813 {
1814 ps_trns_addr = &ps_dec->s_tran_addrecon_parse;
1815 }
1816 else
1817 {
1818 ps_trns_addr = &ps_dec->s_tran_addrecon;
1819 }
1820
1821 u2_mb_x = 0xffff;
1822 u2_mb_y = 0;
1823 // assign the deblock structure pointers to start of slice
1824 ps_dec->u2_cur_mb_addr = 0;
1825 ps_dec->ps_deblk_mbn = ps_dec->ps_deblk_pic;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301826 ps_dec->ps_mv_cur = ps_dec->s_cur_pic.ps_mv;
1827 ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1;
1828 ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2;
1829 ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3;
1830
1831 ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y;
1832 ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u;
1833 ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v;
1834
1835 }
1836
1837 ps_dec->ps_part = ps_dec->ps_parse_part_params;
1838
1839 ps_dec->u2_mbx =
1840 (MOD(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs));
1841 ps_dec->u2_mby =
1842 (DIV(u2_first_mb_in_slice - 1, ps_seq->u2_frm_wd_in_mbs));
1843 ps_dec->u2_mby <<= ps_cur_slice->u1_mbaff_frame_flag;
1844 ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
1845 ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
1846 }
1847
1848 /* RBSP stop bit is used for CABAC decoding*/
1849 ps_bitstrm->u4_max_ofst += ps_dec->ps_cur_pps->u1_entropy_coding_mode;
1850
1851 ps_dec->u1_B = (u1_slice_type == B_SLICE);
1852 ps_dec->u4_next_mb_skip = 0;
1853
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301854 ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice =
1855 ps_dec->ps_cur_slice->u2_first_mb_in_slice;
1856 ps_dec->ps_parse_cur_slice->slice_type =
1857 ps_dec->ps_cur_slice->u1_slice_type;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301858
1859
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001860 ps_dec->u4_start_recon_deblk = 1;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301861 {
1862 WORD32 num_entries;
1863 WORD32 size;
1864 UWORD8 *pu1_buf;
1865
1866 num_entries = MIN(MAX_FRAMES, ps_dec->u4_num_ref_frames_at_init);
1867 num_entries = 2 * ((2 * num_entries) + 1);
1868
1869 size = num_entries * sizeof(void *);
1870 size += PAD_MAP_IDX_POC * sizeof(void *);
1871
1872 pu1_buf = (UWORD8 *)ps_dec->pv_map_ref_idx_to_poc_buf;
1873 pu1_buf += size * ps_dec->u2_cur_slice_num;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001874 ps_dec->ps_parse_cur_slice->ppv_map_ref_idx_to_poc = ( void *)pu1_buf;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301875 }
1876
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001877 if(ps_dec->u1_separate_parse)
1878 {
1879 ps_dec->ps_parse_cur_slice->pv_tu_coeff_data_start = ps_dec->pv_parse_tu_coeff_data;
1880 }
1881 else
1882 {
1883 ps_dec->pv_proc_tu_coeff_data = ps_dec->pv_parse_tu_coeff_data;
1884 }
1885
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301886 if(u1_slice_type == I_SLICE)
1887 {
1888 ps_dec->ps_cur_pic->u4_pack_slc_typ |= I_SLC_BIT;
1889
1890 ret = ih264d_parse_islice(ps_dec, u2_first_mb_in_slice);
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301891
1892 if(ps_dec->i4_pic_type != B_SLICE && ps_dec->i4_pic_type != P_SLICE)
1893 ps_dec->i4_pic_type = I_SLICE;
1894
1895 }
1896 else if(u1_slice_type == P_SLICE)
1897 {
1898 ps_dec->ps_cur_pic->u4_pack_slc_typ |= P_SLC_BIT;
1899 ret = ih264d_parse_pslice(ps_dec, u2_first_mb_in_slice);
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301900 ps_dec->u1_pr_sl_type = u1_slice_type;
1901 if(ps_dec->i4_pic_type != B_SLICE)
1902 ps_dec->i4_pic_type = P_SLICE;
1903 }
1904 else if(u1_slice_type == B_SLICE)
1905 {
1906 ps_dec->ps_cur_pic->u4_pack_slc_typ |= B_SLC_BIT;
1907 ret = ih264d_parse_bslice(ps_dec, u2_first_mb_in_slice);
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301908 ps_dec->u1_pr_sl_type = u1_slice_type;
1909 ps_dec->i4_pic_type = B_SLICE;
1910 }
1911 else
1912 return ERROR_INV_SLC_TYPE_T;
1913
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001914 if(ps_dec->u1_slice_header_done)
1915 {
Hamsalekha S9f0dcba2015-06-09 15:54:31 +05301916 /* set to zero to indicate a valid slice has been decoded */
1917 /* first slice header successfully decoded */
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001918 ps_dec->u4_first_slice_in_pic = 0;
1919 ps_dec->u1_first_slice_in_stream = 0;
1920 }
1921
1922 if(ret != OK)
1923 return ret;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301924
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301925 /* storing last Mb X and MbY of the slice */
1926 ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
1927 ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001928
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301929 /* End of Picture detection */
1930
1931 if(ps_dec->u2_total_mbs_coded >= (ps_seq->u2_max_mb_addr + 1))
1932 {
1933 ps_dec->u1_pic_decode_done = 1;
1934
1935 }
1936
1937 {
1938 dec_err_status_t * ps_err = ps_dec->ps_dec_err_status;
1939 if((ps_err->u1_err_flag & REJECT_PB_PICS)
1940 && (ps_err->u1_cur_pic_type == PIC_TYPE_I))
1941 {
1942 ps_err->u1_err_flag = ACCEPT_ALL_PICS;
1943 }
1944 }
1945
1946 PRINT_BIN_BIT_RATIO(ps_dec)
1947
Marco Nelissen8ef4c3f2015-06-03 07:26:32 -07001948 return ret;
Hamsalekha S8d3d3032015-03-13 21:24:58 +05301949}
1950