Revert "Decoder: Fixed initialization of first_slice_in_pic"
This reverts commit 8994f345da7b814677b5121654fa4c4e9718b0b7.
Change-Id: I4ff897ae7a89f92bfaaad80bc869b86752cf2a19
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index a543e24..9d0f348 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -1927,7 +1927,7 @@
ps_dec->u2_cur_slice_num = 0;
ps_dec->cur_dec_mb_num = 0;
ps_dec->cur_recon_mb_num = 0;
- ps_dec->u4_first_slice_in_pic = 1;
+ ps_dec->u4_first_slice_in_pic = 2;
ps_dec->u1_first_pb_nal_in_pic = 1;
ps_dec->u1_slice_header_done = 0;
ps_dec->u1_dangling_field = 0;
diff --git a/decoder/ih264d_parse_headers.c b/decoder/ih264d_parse_headers.c
index 1403408..5fc38e3 100644
--- a/decoder/ih264d_parse_headers.c
+++ b/decoder/ih264d_parse_headers.c
@@ -1116,6 +1116,13 @@
== IDR_SLICE_NAL),
u1_nal_ref_idc, ps_dec);
+ if((ps_dec->u4_first_slice_in_pic != 0)&&
+ ((ps_dec->ps_dec_err_status->u1_err_flag & REJECT_CUR_PIC) == 0))
+ {
+ /* if the first slice header was not valid set to 1 */
+ ps_dec->u4_first_slice_in_pic = 1;
+ }
+
if(i_status != OK)
{
return i_status;
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index 96841b4..efb94ad 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1572,6 +1572,7 @@
}
}
}
+ ps_dec->u4_first_slice_in_pic = 0;
}
else
{
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index 6a96ffa..11a317b 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -723,7 +723,6 @@
ps_dec->u4_deblk_mb_y = 0;
ps_dec->pu4_wt_ofsts = ps_dec->pu4_wts_ofsts_mat;
- ps_dec->u4_first_slice_in_pic = 0;
H264_MUTEX_UNLOCK(&ps_dec->process_disp_mutex);
return OK;
}
@@ -1160,44 +1159,6 @@
COPYTHECONTEXT("SH: frame_num", u2_frame_num);
// 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);
- if(!ps_dec->u1_first_slice_in_stream && ps_dec->u4_first_slice_in_pic)
- {
- pocstruct_t *ps_prev_poc = &ps_dec->s_prev_pic_poc;
- pocstruct_t *ps_cur_poc = &ps_dec->s_cur_pic_poc;
-
- ps_dec->u2_mbx = 0xffff;
- ps_dec->u2_mby = 0;
-
- if((0 == u1_is_idr_slice) && ps_cur_slice->u1_nal_ref_idc)
- ps_dec->u2_prev_ref_frame_num = ps_cur_slice->u2_frame_num;
-
- if(u1_is_idr_slice || ps_cur_slice->u1_mmco_equalto5)
- ps_dec->u2_prev_ref_frame_num = 0;
-
- if(ps_dec->ps_cur_sps->u1_gaps_in_frame_num_value_allowed_flag)
- {
- ih264d_decode_gaps_in_frame_num(ps_dec, u2_frame_num);
- }
-
- ps_prev_poc->i4_prev_frame_num_ofst = ps_cur_poc->i4_prev_frame_num_ofst;
- ps_prev_poc->u2_frame_num = ps_cur_poc->u2_frame_num;
- ps_prev_poc->u1_mmco_equalto5 = ps_cur_slice->u1_mmco_equalto5;
- if(ps_cur_slice->u1_nal_ref_idc)
- {
- ps_prev_poc->i4_pic_order_cnt_lsb = ps_cur_poc->i4_pic_order_cnt_lsb;
- ps_prev_poc->i4_pic_order_cnt_msb = ps_cur_poc->i4_pic_order_cnt_msb;
- ps_prev_poc->i4_delta_pic_order_cnt_bottom =
- ps_cur_poc->i4_delta_pic_order_cnt_bottom;
- ps_prev_poc->i4_delta_pic_order_cnt[0] =
- ps_cur_poc->i4_delta_pic_order_cnt[0];
- ps_prev_poc->i4_delta_pic_order_cnt[1] =
- ps_cur_poc->i4_delta_pic_order_cnt[1];
- ps_prev_poc->u1_bot_field = ps_cur_poc->u1_bot_field;
- }
-
- ps_dec->u2_total_mbs_coded = 0;
- }
-
/* Get the field related flags */
if(!ps_seq->u1_frame_mbs_only_flag)
@@ -1298,11 +1259,8 @@
/*--------------------------------------------------------------------*/
/* Check if the slice is part of new picture */
/*--------------------------------------------------------------------*/
- /* First slice of a picture is always considered as part of new picture */
- i1_is_end_of_poc = 1;
- ps_dec->ps_dec_err_status->u1_err_flag &= MASK_REJECT_CUR_PIC;
-
- if(ps_dec->u4_first_slice_in_pic == 0)
+ i1_is_end_of_poc = 0;
+ if(!ps_dec->u1_first_slice_in_stream)
{
i1_is_end_of_poc = ih264d_is_end_of_pic(u2_frame_num, u1_nal_ref_idc,
&s_tmp_poc, &ps_dec->s_cur_pic_poc,
@@ -1366,7 +1324,7 @@
u1_is_idr_slice = ps_cur_slice->u1_nal_unit_type == IDR_SLICE_NAL;
}
- else if(ps_dec->u4_first_slice_in_pic)
+ else if(ps_dec->u4_first_slice_in_pic == 2)
{
if(u2_first_mb_in_slice > 0)
{
@@ -1391,12 +1349,25 @@
}
else
{
- /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame
- * completely */
- prev_slice_err = 2;
- num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs
- * ps_dec->u2_frm_wd_in_mbs)
- - ps_dec->u2_total_mbs_coded;
+
+ if(ps_dec->u4_first_slice_in_pic)
+ {
+ /* if valid slice header is not decoded do start of pic processing
+ * since in the current process call, frame num is not updated in the slice structure yet
+ * ih264d_is_end_of_pic is checked with valid frame num of previous process call,
+ * although i1_is_end_of_poc is set there could be more slices in the frame,
+ * so conceal only till cur slice */
+ prev_slice_err = 1;
+ num_mb_skipped = u2_first_mb_in_slice << u1_mbaff;
+ }
+ else
+ {
+ /* since i1_is_end_of_poc is set ,means new frame num is encountered. so conceal the current frame
+ * completely */
+ prev_slice_err = 2;
+ num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
+ - ps_dec->u2_total_mbs_coded;
+ }
ps_cur_poc = &s_tmp_poc;
}
}
@@ -1542,7 +1513,7 @@
ps_dec->ps_cur_pic->i4_poc = i4_temp_poc;
ps_dec->ps_cur_pic->i4_avg_poc = i4_temp_poc;
}
- if(ps_dec->u4_first_slice_in_pic)
+ if(ps_dec->u4_first_slice_in_pic == 2)
{
ret = ih264d_decode_pic_order_cnt(u1_is_idr_slice, u2_frame_num,
&ps_dec->s_prev_pic_poc,
@@ -1610,7 +1581,7 @@
ps_dec->pf_mvpred = ih264d_mvpred_nonmbaff;
}
- if(ps_dec->u4_first_slice_in_pic)
+ if(ps_dec->u4_first_slice_in_pic == 2)
{
if(u2_first_mb_in_slice == 0)
{
@@ -1939,6 +1910,8 @@
if(ps_dec->u1_slice_header_done)
{
/* set to zero to indicate a valid slice has been decoded */
+ /* first slice header successfully decoded */
+ ps_dec->u4_first_slice_in_pic = 0;
ps_dec->u1_first_slice_in_stream = 0;
}