Decoder: Cleaned up parse sps function. am: 4eb72f7c93 am: a0cec24429 am: fc2be1555c am: e8db799093 am: b0248db184

am: 5aea82620f

Change-Id: I066a5f89152554fbb14816eaec56dee2283b6d44
This commit is contained in:
Hamsalekha S 2017-06-06 22:26:26 +00:00 committed by android-build-merger
commit 13fab49281

View file

@ -484,7 +484,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer; UWORD32 *pu4_bitstrm_buf = ps_bitstrm->pu4_buffer;
UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst; UWORD32 *pu4_bitstrm_ofst = &ps_bitstrm->u4_ofst;
UWORD8 u1_frm, uc_constraint_set0_flag, uc_constraint_set1_flag; UWORD8 u1_frm, uc_constraint_set0_flag, uc_constraint_set1_flag;
WORD32 i4_cropped_ht, i4_cropped_wd;
UWORD32 u4_temp; UWORD32 u4_temp;
WORD32 pic_height_in_map_units_minus1 = 0; WORD32 pic_height_in_map_units_minus1 = 0;
UWORD32 u2_pic_wd = 0; UWORD32 u2_pic_wd = 0;
@ -566,8 +566,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
ps_seq = ps_dec->pv_scratch_sps_pps; ps_seq = ps_dec->pv_scratch_sps_pps;
*ps_seq = ps_dec->ps_sps[u1_seq_parameter_set_id]; *ps_seq = ps_dec->ps_sps[u1_seq_parameter_set_id];
if(NULL == ps_dec->ps_cur_sps)
ps_dec->ps_cur_sps = ps_seq;
if((ps_dec->i4_header_decoded & 1) && (ps_seq->u1_profile_idc != u1_profile_idc)) if((ps_dec->i4_header_decoded & 1) && (ps_seq->u1_profile_idc != u1_profile_idc))
{ {
@ -863,7 +861,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
UWORD16 u2_btm_ofst = 0; UWORD16 u2_btm_ofst = 0;
UWORD8 u1_frm_mbs_flag; UWORD8 u1_frm_mbs_flag;
UWORD8 u1_vert_mult_factor; UWORD8 u1_vert_mult_factor;
WORD32 i4_cropped_ht, i4_cropped_wd;
if(u1_frame_cropping_flag) if(u1_frame_cropping_flag)
{ {
@ -925,10 +922,6 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED; return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED;
} }
ps_dec->u2_disp_height = i4_cropped_ht;
ps_dec->u2_disp_width = i4_cropped_wd;
} }
/* Backup u4_num_reorder_frames if header is already decoded */ /* Backup u4_num_reorder_frames if header is already decoded */
@ -960,6 +953,19 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
return IVD_RES_CHANGED; return IVD_RES_CHANGED;
} }
/* In case bitstream read has exceeded the filled size, then
return an error */
if (ps_bitstrm->u4_ofst > ps_bitstrm->u4_max_ofst)
{
return ERROR_INV_SPS_PPS_T;
}
/*--------------------------------------------------------------------*/
/* All initializations to ps_dec are beyond this point */
/*--------------------------------------------------------------------*/
ps_dec->u2_disp_height = i4_cropped_ht;
ps_dec->u2_disp_width = i4_cropped_wd;
ps_dec->u2_pic_wd = u2_pic_wd; ps_dec->u2_pic_wd = u2_pic_wd;
ps_dec->u2_pic_ht = u2_pic_ht; ps_dec->u2_pic_ht = u2_pic_ht;
@ -978,14 +984,9 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm)
ps_dec->u2_crop_offset_y = u2_crop_offset_y; ps_dec->u2_crop_offset_y = u2_crop_offset_y;
ps_dec->u2_crop_offset_uv = u2_crop_offset_uv; ps_dec->u2_crop_offset_uv = u2_crop_offset_uv;
/* In case bitstream read has exceeded the filled size, then
return an error */
if(ps_bitstrm->u4_ofst > ps_bitstrm->u4_max_ofst)
{
return ERROR_INV_SPS_PPS_T;
}
ps_seq->u1_is_valid = TRUE; ps_seq->u1_is_valid = TRUE;
ps_dec->ps_sps[u1_seq_parameter_set_id] = *ps_seq; ps_dec->ps_sps[u1_seq_parameter_set_id] = *ps_seq;
ps_dec->ps_cur_sps = &ps_dec->ps_sps[u1_seq_parameter_set_id];
return OK; return OK;
} }