diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c index 25f03da..20cba70 100644 --- a/decoder/ih264d_api.c +++ b/decoder/ih264d_api.c @@ -1185,6 +1185,7 @@ void ih264d_init_decoder(void * ps_dec_params) memset(ps_dec->pv_mv_buf_mgr, 0, size); /* Free any dynamic buffers that are allocated */ + PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_dynamic); ih264d_free_dynamic_bufs(ps_dec); { @@ -3649,6 +3650,7 @@ WORD32 ih264d_delete(iv_obj_t *dec_hdl, void *pv_api_ip, void *pv_api_op) ps_dec = (dec_struct_t *)(dec_hdl->pv_codec_handle); UNUSED(ps_ip); ps_op->s_ivd_delete_op_t.u4_error_code = 0; + PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_dynamic); ih264d_free_dynamic_bufs(ps_dec); ih264d_free_static_bufs(dec_hdl); return IV_SUCCESS; diff --git a/decoder/ih264d_utils.c b/decoder/ih264d_utils.c index 1f0e13f..4b07ec3 100644 --- a/decoder/ih264d_utils.c +++ b/decoder/ih264d_utils.c @@ -1931,6 +1931,10 @@ WORD16 ih264d_allocate_dynamic_bufs(dec_struct_t * ps_dec) UWORD32 u4_luma_size, u4_chroma_size; void *pv_mem_ctxt = ps_dec->pv_mem_ctxt; + /* Free any dynamic buffers that are allocated earlier. As ps_dec is memset to zero */ + /* at the beginning, it is safe to call this even if no memory was allocated earlier */ + ih264d_free_dynamic_bufs(ps_dec); + size = u4_total_mbs; pv_buf = ps_dec->pf_aligned_alloc(pv_mem_ctxt, 128, size); RETURN_IF((NULL == pv_buf), IV_FAIL); @@ -2285,8 +2289,6 @@ WORD16 ih264d_allocate_dynamic_bufs(dec_struct_t * ps_dec) */ WORD16 ih264d_free_dynamic_bufs(dec_struct_t * ps_dec) { - PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_dynamic); - PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->ps_deblk_pic); PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_dec_mb_map); PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_recon_mb_map); diff --git a/decoder/svc/isvcd_utils.c b/decoder/svc/isvcd_utils.c index 94661c5..19bd88a 100644 --- a/decoder/svc/isvcd_utils.c +++ b/decoder/svc/isvcd_utils.c @@ -85,6 +85,7 @@ WORD16 isvcd_free_dynamic_bufs(svc_dec_lyr_struct_t *ps_svc_lyr_dec) WORD32 i; dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec; /* Free any avc dynamic buffers that are allocated */ + PS_DEC_ALIGNED_FREE(ps_dec, ps_dec->pu1_bits_buf_dynamic); ih264d_free_dynamic_bufs(ps_dec); PS_DEC_ALIGNED_FREE(ps_dec, ps_svc_lyr_dec->pu1_crop_wnd_flag); PS_DEC_ALIGNED_FREE(ps_dec, ps_svc_lyr_dec->ps_inter_lyr_mb_prms_base);