From 4493e90948347bc09c383e27742cff8fb4400897 Mon Sep 17 00:00:00 2001 From: GeekQAQ <217626997+GeekQAQ@users.noreply.github.com> Date: Fri, 23 Oct 2026 22:47:49 +0800 Subject: [PATCH] decoder: Clear recent reference fields on reset impeg2d_api_reset() clears aps_ref_pics[] but keeps as_recent_fld[][], which still points into the picture buffers of the previous stream. When the next stream starts with a P picture or an open-GOP B picture, impeg2d_pre_pic_dec_proc() takes the missing reference from as_recent_fld instead of the current picture buffer, so the decoded output mixes in pixels from the previous stream. With shared display buffers that the application replaced after the reset, the reference points into freed memory. Clear as_recent_fld in the reset so that the decoder behaves as a newly created instance. --- decoder/impeg2d_api_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/decoder/impeg2d_api_main.c b/decoder/impeg2d_api_main.c index b7b8a02..4f517e5 100644 --- a/decoder/impeg2d_api_main.c +++ b/decoder/impeg2d_api_main.c @@ -1074,6 +1074,7 @@ IV_API_CALL_STATUS_T impeg2d_api_reset(iv_obj_t *ps_dechdl, ps_dec_state->aps_ref_pics[0] = NULL; ps_dec_state->aps_ref_pics[1] = NULL; ps_dec_state->ps_deint_pic = NULL; + memset(ps_dec_state->as_recent_fld, 0, sizeof(ps_dec_state->as_recent_fld)); } } else