diff mbox series

[FFmpeg-devel] lavc/decode: do not clear the frame discard flag in ff_decode_frame_props_from_pkt()

Message ID 20240916093211.10441-1-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel] lavc/decode: do not clear the frame discard flag in ff_decode_frame_props_from_pkt() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Sept. 16, 2024, 9:28 a.m. UTC
Only do it in reget_buffer().

The purpose of this clearing this flag is to prevent it for
unintentionally persisting across multiple invocations of this function
on one frame, however that is only a problem if the frame is not
unreffed between uses, which is only the case with reget_buffer().

In other cases the caller may legitimately want to set the discard flag
and should have the option of doing so.
---
Either this, or the v2 of 15/23 fixes the issue, but I think both
changes should be done.
---
 libavcodec/decode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 5f6646ea4d..1f2fbda6ad 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1474,8 +1474,6 @@  FF_ENABLE_DEPRECATION_WARNINGS
 
     if (pkt->flags & AV_PKT_FLAG_DISCARD) {
         frame->flags |= AV_FRAME_FLAG_DISCARD;
-    } else {
-        frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD);
     }
 
     if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
@@ -1675,6 +1673,9 @@  static int reget_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flag
 
     av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
 
+    // make sure the discard flag does not persist
+    frame->flags &= ~AV_FRAME_FLAG_DISCARD;
+
     if (frame->data[0] && (frame->width != avctx->width || frame->height != avctx->height || frame->format != avctx->pix_fmt)) {
         av_log(avctx, AV_LOG_WARNING, "Picture changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s in reget buffer()\n",
                frame->width, frame->height, av_get_pix_fmt_name(frame->format), avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt));