Decoder: Fixed an issue in handling flush

Fixed a NULL pointer reference, when flush is called before
decoding any pictures.

This was seen in following CTS test,
android.media.cts.DecoderTest#testCodecResetsH264WithSurface

Fixed code formatting issues in ih264d_set_flush_mode
Updated the testbench to call flush before decoding starts

Change-Id: Ib04e0b15573b2482c9d5b43c8bc7dd30d8f8efdd
This commit is contained in:
Harish Mahendrakar 2015-09-02 09:01:40 +05:30
parent fe2bfd392c
commit 39f8ae0a35
2 changed files with 14 additions and 14 deletions

View file

@ -2484,7 +2484,6 @@ WORD32 ih264d_set_display_frame(iv_obj_t *dec_hdl,
/*****************************************************************************/
WORD32 ih264d_set_flush_mode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op)
{
dec_struct_t * ps_dec;
ivd_ctl_flush_op_t *ps_ctl_op = (ivd_ctl_flush_op_t*)pv_api_op;
ps_ctl_op->u4_error_code = 0;
@ -2495,19 +2494,15 @@ WORD32 ih264d_set_flush_mode(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op
/* Signal flush frame control call */
ps_dec->u1_flushfrm = 1;
if( ps_dec->u1_init_dec_flag == 1)
if(ps_dec->u1_init_dec_flag == 1)
{
ih264d_release_pics_in_dpb((void *)ps_dec,
ps_dec->u1_pic_bufs);
ih264d_release_display_bufs(ps_dec);
ih264d_release_pics_in_dpb((void *)ps_dec, ps_dec->u1_pic_bufs);
ih264d_release_display_bufs(ps_dec);
}
ps_ctl_op->u4_error_code =
((ivd_ctl_flush_op_t*)ps_dec->pv_dec_out)->u4_error_code; //verify the value
ps_ctl_op->u4_error_code = 0;
return IV_SUCCESS;
}
/*****************************************************************************/

View file

@ -65,8 +65,8 @@
#endif
//#define ADAPTIVE_TEST
#define ADAPTIVE_MAX_WD 1920
#define ADAPTIVE_MAX_HT 1088
#define ADAPTIVE_MAX_WD 4096
#define ADAPTIVE_MAX_HT 2160
#define ALIGN8(x) ((((x) + 7) >> 3) << 3)
#define NUM_DISPLAY_BUFFERS 4
@ -1789,7 +1789,7 @@ int main(WORD32 argc, CHAR *argv[])
WORD32 ret;
CHAR ac_error_str[STRLENGTH];
vid_dec_ctx_t s_app_ctx;
UWORD8 *pu1_bs_buf;
UWORD8 *pu1_bs_buf = NULL;
ivd_out_bufdesc_t *ps_out_buf;
UWORD32 u4_num_bytes_dec = 0;
@ -2228,6 +2228,10 @@ int main(WORD32 argc, CHAR *argv[])
}
flush_output(codec_obj, &s_app_ctx, ps_out_buf,
pu1_bs_buf, &u4_op_frm_ts,
ps_op_file, ps_op_chksum_file,
u4_ip_frm_ts, u4_bytes_remaining);
/*****************************************************************************/
/* Decode header to get width and height and buffer sizes */
@ -2334,8 +2338,6 @@ int main(WORD32 argc, CHAR *argv[])
s_app_ctx.u4_pic_wd = s_video_decode_op.u4_pic_wd;
s_app_ctx.u4_pic_ht = s_video_decode_op.u4_pic_ht;
/* Allocate input buffer */
u4_ip_buf_len = 2048 * 2048;
free(pu1_bs_buf);
#if IOS_DISPLAY
@ -3139,5 +3141,8 @@ int main(WORD32 argc, CHAR *argv[])
free(ps_out_buf);
free(pu1_bs_buf);
if(s_app_ctx.display_thread_handle)
free(s_app_ctx.display_thread_handle);
return (0);
}