Commit b3e02ac13b for ffmpeg

commit b3e02ac13bcf54411fc7608abd0c8127a5366319
Author: James Almer <jamrial@gmail.com>
Date:   Tue Nov 24 11:12:49 2026 -0300

    avcodec/lcevcdec: flush pictures on decoder flush

    Assisted by Claude

    Signed-off-by: James Almer <jamrial@gmail.com>

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 2696f8f916..4f40b3677e 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -2426,6 +2426,11 @@ av_cold void ff_decode_flush_buffers(AVCodecContext *avctx)

     dc->nb_draining_errors = 0;
     dc->draining_started   = 0;
+
+#if CONFIG_LIBLCEVC_DEC
+    if (!avci->is_frame_mt)
+        ff_lcevc_flush(dc->lcevc.ctx);
+#endif
 }

 av_cold AVCodecInternal *ff_decode_internal_alloc(void)
diff --git a/libavcodec/lcevcdec.c b/libavcodec/lcevcdec.c
index e3d28c7a18..40bb3d246b 100644
--- a/libavcodec/lcevcdec.c
+++ b/libavcodec/lcevcdec.c
@@ -169,6 +169,17 @@ static int lcevc_flush_pictures(FFLCEVCContext *lcevc)
     return 0;
 }

+void ff_lcevc_flush(FFLCEVCContext *lcevc)
+{
+    if (!lcevc || lcevc->initialized != FF_LCEVCDEC_INIT)
+        return;
+
+    if (LCEVC_FlushDecoder(lcevc->decoder) != LCEVC_Success ||
+        LCEVC_SynchronizeDecoder(lcevc->decoder, 0) != LCEVC_Success ||
+        lcevc_flush_pictures(lcevc) < 0)
+        av_log(lcevc, AV_LOG_ERROR, "Failed to flush LCEVC decoder\n");
+}
+
 static int lcevc_send_frame(FFLCEVCFrame *frame_ctx, const AVFrame *in)
 {
     FFLCEVCContext *lcevc = frame_ctx->lcevc;
diff --git a/libavcodec/lcevcdec.h b/libavcodec/lcevcdec.h
index 91b58d15a5..0419a078b2 100644
--- a/libavcodec/lcevcdec.h
+++ b/libavcodec/lcevcdec.h
@@ -65,6 +65,7 @@ typedef struct FFLCEVCFrame {

 int ff_lcevc_alloc(FFLCEVCContext **plcevc, AVDictionary **options, int loglevel);
 int ff_lcevc_process(void *logctx, struct AVFrame *frame);
+void ff_lcevc_flush(FFLCEVCContext *lcevc);
 int ff_lcevc_parse_frame(FFLCEVCContext *lcevc, const struct AVFrame *frame,
                          enum AVPixelFormat *format, enum AVPixelFormat *base_format,
                          int *width, int *height);