Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Random Joe <ff.random.joe@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] avcodec/cuviddec: update parser ulMaxNumDecodeSurfaces
Date: Fri, 11 Aug 2023 20:16:09 +0300
Message-ID: <CAO1_vfQtxEKQAWjwrjqxavwM9w4fZyqeDpnWe01WzdRp=5_OqA@mail.gmail.com> (raw)

Fixes video output stutter caused by different number of buffers in
decoder vs parser introduced in 402d98c.

Signed-off-by: Random Joe <ff.random.joe@gmail.com>
---
 libavcodec/cuviddec.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 814bc53f70..1b62832eca 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -360,7 +360,14 @@ static int CUDAAPI cuvid_handle_video_sequence(void
*opaque, CUVIDEOFORMAT* form
         }
     }

-    return 1;
+    // make CUVIDDECODECREATEINFO::ulNumDecodeSurfaces =
CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces
+    // returning a value > 1  , will notify the driver to set the parser
ulMaxNumDecodeSurfaces
+    // to this return value .
+
+    if(ctx->cuparseinfo.ulMaxNumDecodeSurfaces !=
cuinfo.ulNumDecodeSurfaces)
+        return cuinfo.ulNumDecodeSurfaces;
+    else
+        return 1;
 }

 static int CUDAAPI cuvid_handle_picture_decode(void *opaque,
CUVIDPICPARAMS* picparams)
@@ -1022,7 +1029,9 @@ static av_cold int cuvid_decode_init(AVCodecContext
*avctx)
         goto error;
     }

-    ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
+    // set ulMaxNumDecodeSurfaces to a dummy value of 1 as recommended in
NVDEC Programming Guide
+    // set the optimal value in pfnSequenceCallback where
CUVIDEOFORMAT::min_num_decode_surfaces is reported
+    ctx->cuparseinfo.ulMaxNumDecodeSurfaces = 1;
     ctx->cuparseinfo.ulMaxDisplayDelay = (avctx->flags &
AV_CODEC_FLAG_LOW_DELAY) ? 0 : CUVID_MAX_DISPLAY_DELAY;
     ctx->cuparseinfo.pUserData = avctx;
     ctx->cuparseinfo.pfnSequenceCallback = cuvid_handle_video_sequence;
-- 
2.39.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

             reply	other threads:[~2023-08-11 17:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-11 17:16 Random Joe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-08-11 16:01 Random Joe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO1_vfQtxEKQAWjwrjqxavwM9w4fZyqeDpnWe01WzdRp=5_OqA@mail.gmail.com' \
    --to=ff.random.joe@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git