[FFmpeg-cvslog] avcodec/cuviddec: properly take deinterlacing and display delay into account for buffer_full check

Timo Rothenpieler git at videolan.org
Sun Oct 14 19:20:12 EEST 2018


ffmpeg | branch: release/4.0 | Timo Rothenpieler <timo at rothenpieler.org> | Sat Oct 13 23:44:30 2018 +0200| [7b23dd0f41bcfba216eb0d3827c9376fd4a6af10] | committer: Timo Rothenpieler

avcodec/cuviddec: properly take deinterlacing and display delay into account for buffer_full check

Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b23dd0f41bcfba216eb0d3827c9376fd4a6af10
---

 libavcodec/cuviddec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 122c28f6e8..38623806fe 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -378,7 +378,11 @@ static int cuvid_is_buffer_full(AVCodecContext *avctx)
 {
     CuvidContext *ctx = avctx->priv_data;
 
-    return (av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + 2 > ctx->nb_surfaces;
+    int delay = ctx->cuparseinfo.ulMaxDisplayDelay;
+    if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave && !ctx->drop_second_field)
+        delay *= 2;
+
+    return (av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + delay >= ctx->nb_surfaces;
 }
 
 static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)



More information about the ffmpeg-cvslog mailing list