From 5c98f8d80a50fb012deb1e4e24864dd52372a367 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Sun, 14 Oct 2018 18:33:55 +0200 Subject: [PATCH] avcodec/cuviddec: properly take deinterlacing and display delay into account for buffer_full check Signed-off-by: Timo Rothenpieler --- libavcodec/cuvid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 916d7e9987..da31693036 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -367,13 +367,17 @@ static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt) AVPacket filter_packet = { 0 }; AVPacket filtered_packet = { 0 }; int ret = 0, eret = 0, is_flush = ctx->decoder_flushing; + int delay = ctx->cuparseinfo.ulMaxDisplayDelay; av_log(avctx, AV_LOG_TRACE, "cuvid_decode_packet\n"); if (is_flush && avpkt && avpkt->size) return AVERROR_EOF; - if ((av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + 2 > ctx->nb_surfaces && avpkt && avpkt->size) + if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave && !ctx->drop_second_field) + delay *= 2; + + if ((av_fifo_size(ctx->frame_queue) / sizeof(CuvidParsedFrame)) + delay >= ctx->nb_surfaces && avpkt && avpkt->size) return AVERROR(EAGAIN); if (ctx->bsf && avpkt && avpkt->size) {