Merge "Decoder: Initialize ps_cur_slice->u1_mbaff_frame_flag correctly for error cases" into mnc-dev
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index efc5220..8d73fbe 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -2210,7 +2210,8 @@
u4_mem_size += (sizeof(UWORD32) * 3 * (MAX_REF_BUFS * MAX_REF_BUFS)) << 3;
u4_mem_size = ALIGN64(u4_mem_size);
- u4_mem_size += sizeof(UWORD32) * 2 * 3 * (MAX_REF_BUFS * MAX_REF_BUFS);
+ u4_mem_size += sizeof(UWORD32) * 2 * 3
+ * ((MAX_FRAMES << 1) * (MAX_FRAMES << 1));
u4_mem_size = ALIGN64(u4_mem_size);
memTab[MEM_REC_INTERNAL_SCRATCH].u4_mem_alignment =
@@ -3035,6 +3036,7 @@
{
/* a start code has already been found earlier in the same process call*/
frame_data_left = 0;
+ header_data_left = 0;
continue;
}
@@ -3115,8 +3117,9 @@
WORD32 prev_slice_err;
pocstruct_t temp_poc;
WORD32 ret1;
-
- num_mb_skipped = (ps_dec->u2_frm_ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
+ WORD32 ht_in_mbs;
+ ht_in_mbs = ps_dec->u2_pic_ht >> (4 + ps_dec->ps_cur_slice->u1_field_pic_flag);
+ num_mb_skipped = (ht_in_mbs * ps_dec->u2_frm_wd_in_mbs)
- ps_dec->u2_total_mbs_coded;
if(ps_dec->u4_first_slice_in_pic && (ps_dec->u4_pic_buf_got == 0))
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index d6bea99..a33a03f 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1663,11 +1663,15 @@
return 0;
}
- // Inserting new slice
- ps_dec->u2_cur_slice_num++;
- ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
- ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
- ps_dec->ps_parse_cur_slice++;
+ /* Inserting new slice only if the current slice has atleast 1 MB*/
+ if(ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice <
+ (UWORD32)(ps_dec->u2_total_mbs_coded >> ps_slice->u1_mbaff_frame_flag))
+ {
+ ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
+ ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
+ ps_dec->u2_cur_slice_num++;
+ ps_dec->ps_parse_cur_slice++;
+ }
}
else
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index 1155a4c..880f3a8 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -1070,8 +1070,7 @@
/*we currently don not support ASO*/
if(((u2_first_mb_in_slice << ps_cur_slice->u1_mbaff_frame_flag)
- <= ps_dec->u2_cur_mb_addr) && (ps_dec->u2_cur_mb_addr != 0)
- && (ps_dec->u4_first_slice_in_pic != 0))
+ <= ps_dec->u2_cur_mb_addr) && (ps_dec->u4_first_slice_in_pic == 0))
{
return ERROR_CORRUPTED_SLICE;
}
diff --git a/decoder/ih264d_sei.c b/decoder/ih264d_sei.c
index 14ffcd6..800f2c9 100644
--- a/decoder/ih264d_sei.c
+++ b/decoder/ih264d_sei.c
@@ -80,7 +80,7 @@
UNUSED(ps_buf_prd);
u1_seq_parameter_set_id = ih264d_uev(pu4_bitstrm_ofst,
pu4_bitstrm_buf);
- if(u1_seq_parameter_set_id > MAX_NUM_SEQ_PARAMS)
+ if(u1_seq_parameter_set_id >= MAX_NUM_SEQ_PARAMS)
return ERROR_INVALID_SEQ_PARAM;
ps_seq = &ps_dec->ps_sps[u1_seq_parameter_set_id];
if(TRUE != ps_seq->u1_is_valid)
diff --git a/decoder/ih264d_tables.c b/decoder/ih264d_tables.c
index d49de14..c45525a 100644
--- a/decoder/ih264d_tables.c
+++ b/decoder/ih264d_tables.c
@@ -855,7 +855,8 @@
{ 0, 0 /* Junk */, /* 16x16 */
0, 8, /* 16x8 */
0, 2, /* 8x16 */
- 0, 2, 8, 10 /* 8x8 */
+ 0, 2, 8, 10 /* 8x8 */,
+ 0 /* One extra entry is read at the end of loop, but not used */
};
/*!
diff --git a/decoder/ih264d_utils.c b/decoder/ih264d_utils.c
index 3567785..d457aa8 100644
--- a/decoder/ih264d_utils.c
+++ b/decoder/ih264d_utils.c
@@ -2197,7 +2197,7 @@
ps_dec->pu4_wts_ofsts_mat = (UWORD32 *)(pu1_scratch_mem_base + u4_scratch_mem_used);
u4_scratch_mem_used += sizeof(UWORD32) * 2 * 3
- * (MAX_FRAMES * MAX_FRAMES);
+ * ((MAX_FRAMES << 1) * (MAX_FRAMES << 1));
u4_scratch_mem_used = ALIGN64(u4_scratch_mem_used);
}
/********************************************************************/