From 142221a3f993adca0c7db7f4b65d76cd9fd72a38 Mon Sep 17 00:00:00 2001 From: Wonsik Kim Date: Tue, 12 Apr 2016 15:20:08 +0900 Subject: [PATCH 1/2] DO NOT MERGE Handle level/profile/num_ref_frames/num_reorder change at the same resolution Cherry pick of Change-Id: Ifa78c3125ab207ce5e39166f4891cba0d3a4e39c which went into master (post-n). This needed backporting to M so that the final fix for 35583675 could be integrated. Bug: 35583675 Test: ran POC without failure Change-Id: I0d248212aaf6635f34a70ad36657416a0c623d32 --- decoder/ih264d_parse_headers.c | 44 +++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/decoder/ih264d_parse_headers.c b/decoder/ih264d_parse_headers.c index bc4ace4..0bc4c3f 100644 --- a/decoder/ih264d_parse_headers.c +++ b/decoder/ih264d_parse_headers.c @@ -494,7 +494,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) UWORD32 u2_crop_offset_y = 0; UWORD32 u2_crop_offset_uv = 0; WORD32 ret; - + UWORD32 u4_num_reorder_frames; /* High profile related syntax element */ WORD32 i4_i; /* G050 */ @@ -567,6 +567,18 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) if(NULL == ps_dec->ps_cur_sps) ps_dec->ps_cur_sps = ps_seq; + if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_profile_idc != u1_profile_idc)) + { + ps_dec->u1_res_changed = 1; + return IVD_RES_CHANGED; + } + + if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_level_idc != u1_level_idc)) + { + ps_dec->u1_res_changed = 1; + return IVD_RES_CHANGED; + } + ps_seq->u1_profile_idc = u1_profile_idc; ps_seq->u1_level_idc = u1_level_idc; ps_seq->u1_seq_parameter_set_id = u1_seq_parameter_set_id; @@ -733,6 +745,14 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) { return ERROR_NUM_REF; } + + /* Compare with older num_ref_frames is header is already once */ + if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_num_ref_frames != u4_temp)) + { + ps_dec->u1_res_changed = 1; + return IVD_RES_CHANGED; + } + ps_seq->u1_num_ref_frames = u4_temp; COPYTHECONTEXT("SPS: num_ref_frames",ps_seq->u1_num_ref_frames); @@ -909,6 +929,17 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) } + /* Backup u4_num_reorder_frames if header is already decoded */ + if((3 == ps_dec->i4_header_decoded) && + (1 == ps_seq->u1_vui_parameters_present_flag) && + (1 == ps_seq->s_vui.u1_bitstream_restriction_flag)) + { + u4_num_reorder_frames = ps_seq->s_vui.u4_num_reorder_frames; + } + else + { + u4_num_reorder_frames = -1; + } if(1 == ps_seq->u1_vui_parameters_present_flag) { ret = ih264d_parse_vui_parametres(&ps_seq->s_vui, ps_bitstrm); @@ -916,6 +947,17 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) return ret; } + /* Compare older u4_num_reorder_frames with the new one if header is already decoded */ + if((3 == ps_dec->i4_header_decoded) && + (-1 != (WORD32)u4_num_reorder_frames) && + (1 == ps_seq->u1_vui_parameters_present_flag) && + (1 == ps_seq->s_vui.u1_bitstream_restriction_flag) && + (ps_seq->s_vui.u4_num_reorder_frames != u4_num_reorder_frames)) + { + ps_dec->u1_res_changed = 1; + return IVD_RES_CHANGED; + } + ps_dec->u2_pic_wd = u2_pic_wd; ps_dec->u2_pic_ht = u2_pic_ht; From 8454dbfccd4b558e880596f313d269a9083da86b Mon Sep 17 00:00:00 2001 From: Hamsalekha S Date: Tue, 21 Feb 2017 16:02:23 +0530 Subject: [PATCH 2/2] DO NOT MERGE Fixed bug in the case of resolution change. Modified the way i4_header_decoded in decoder context is used, to ensure that resolution change is detected even if PPS has not been decoded. Cherry pick of Change-Id: Ibb3f8dfbeb66a999fd81720a7d2a02dd951a55c4 which went into master post-N. Bug: 35583675 Test: ran POC, no longer hangs Change-Id: Ifd21ebe1827d6d0c13018983c46c4301c2bb1669 --- decoder/ih264d_parse_headers.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/decoder/ih264d_parse_headers.c b/decoder/ih264d_parse_headers.c index 0bc4c3f..58234f9 100644 --- a/decoder/ih264d_parse_headers.c +++ b/decoder/ih264d_parse_headers.c @@ -567,13 +567,13 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) if(NULL == ps_dec->ps_cur_sps) ps_dec->ps_cur_sps = ps_seq; - if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_profile_idc != u1_profile_idc)) + if((ps_dec->i4_header_decoded & 1) && (ps_seq->u1_profile_idc != u1_profile_idc)) { ps_dec->u1_res_changed = 1; return IVD_RES_CHANGED; } - if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_level_idc != u1_level_idc)) + if((ps_dec->i4_header_decoded & 1) && (ps_seq->u1_level_idc != u1_level_idc)) { ps_dec->u1_res_changed = 1; return IVD_RES_CHANGED; @@ -747,7 +747,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) } /* Compare with older num_ref_frames is header is already once */ - if((3 == ps_dec->i4_header_decoded) && (ps_seq->u1_num_ref_frames != u4_temp)) + if((ps_dec->i4_header_decoded & 1) && (ps_seq->u1_num_ref_frames != u4_temp)) { ps_dec->u1_res_changed = 1; return IVD_RES_CHANGED; @@ -897,12 +897,12 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) return ERROR_INV_SPS_PPS_T; } - if((3 == ps_dec->i4_header_decoded) && (ps_dec->u2_pic_wd != u2_pic_wd)) + if((ps_dec->i4_header_decoded & 1) && (ps_dec->u2_pic_wd != u2_pic_wd)) { ps_dec->u1_res_changed = 1; return IVD_RES_CHANGED; } - if((3 == ps_dec->i4_header_decoded) && (ps_dec->u2_pic_ht != u2_pic_ht)) + if((ps_dec->i4_header_decoded & 1) && (ps_dec->u2_pic_ht != u2_pic_ht)) { ps_dec->u1_res_changed = 1; return IVD_RES_CHANGED; @@ -930,7 +930,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) } /* Backup u4_num_reorder_frames if header is already decoded */ - if((3 == ps_dec->i4_header_decoded) && + if((ps_dec->i4_header_decoded & 1) && (1 == ps_seq->u1_vui_parameters_present_flag) && (1 == ps_seq->s_vui.u1_bitstream_restriction_flag)) { @@ -948,7 +948,7 @@ WORD32 ih264d_parse_sps(dec_struct_t *ps_dec, dec_bit_stream_t *ps_bitstrm) } /* Compare older u4_num_reorder_frames with the new one if header is already decoded */ - if((3 == ps_dec->i4_header_decoded) && + if((ps_dec->i4_header_decoded & 1) && (-1 != (WORD32)u4_num_reorder_frames) && (1 == ps_seq->u1_vui_parameters_present_flag) && (1 == ps_seq->s_vui.u1_bitstream_restriction_flag) &&