avcodec/cuviddec: properly take deinterlacing and display delay into account for...
authorTimo Rothenpieler <timo@rothenpieler.org>
Sat, 13 Oct 2018 21:44:30 +0000 (23:44 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Sun, 14 Oct 2018 16:09:00 +0000 (18:09 +0200)
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
libavcodec/cuviddec.c

index 4d3caf9..f21273c 100644 (file)
@@ -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)