[FFmpeg-cvslog] avcodec/cuviddec: only flush cuvid when output queue is empty
Timo Rothenpieler
git at videolan.org
Wed May 21 02:22:19 EEST 2025
ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Wed May 21 01:16:19 2025 +0200| [d5a9f7bdd4d971029159975269a43480c92caf4d] | committer: Timo Rothenpieler
avcodec/cuviddec: only flush cuvid when output queue is empty
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5a9f7bdd4d971029159975269a43480c92caf4d
---
libavcodec/cuviddec.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index bb24fad3d4..3437ee2109 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -505,7 +505,12 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
ctx->decoder_flushing = 1;
}
- ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, &cupkt));
+ // When flushing, only actually flush cuvid when the output buffer has been fully emptied.
+ // CUVID happily dumps out a ton of frames with no regard for its own available surfaces.
+ if (!ctx->decoder_flushing || (ctx->decoder_flushing && !av_fifo_can_read(ctx->frame_queue)))
+ ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, &cupkt));
+ else
+ ret = 0;
if (ret < 0)
goto error;
More information about the ffmpeg-cvslog
mailing list