diff mbox series

[FFmpeg-devel] set ulMaxDisplayDelay cuvidec parser option to zero if low_delay flag is on

Message ID 20210219223325.216846-1-clime7@gmail.com
State New
Headers show
Series [FFmpeg-devel] set ulMaxDisplayDelay cuvidec parser option to zero if low_delay flag is on
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

clime Feb. 19, 2021, 10:33 p.m. UTC
From: Michal Novotny <michal.novotny@comprimato.com>

* zero is recommended value in Nvidia coding samples for low latency use-cases

Signed-off-by: Michal Novotny <michal.novotny@comprimato.com>
---
 libavcodec/cuviddec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Timo Rothenpieler Feb. 19, 2021, 11:29 p.m. UTC | #1
On 19.02.2021 23:33, clime wrote:
>       ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
> -    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
> +    ctx->cuparseinfo.ulMaxDisplayDelay = avctx->flags & AV_CODEC_FLAG_LOW_DELAY ? 0 : 4;

I'd prefer this with proper braces, to make sure no compiler gets the 
crazy idea to evaluate this as avctx->flags & 4.

Otherwise this is probably fine, but will severely gimp the performance, 
to the point that it might not even be able to sustain 60 FPS anymore.
Printing a warning might be in order.
clime Feb. 19, 2021, 11:38 p.m. UTC | #2
On Sat, 20 Feb 2021 at 00:29, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>
> On 19.02.2021 23:33, clime wrote:
> >       ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
> > -    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
> > +    ctx->cuparseinfo.ulMaxDisplayDelay = avctx->flags & AV_CODEC_FLAG_LOW_DELAY ? 0 : 4;
>
> I'd prefer this with proper braces, to make sure no compiler gets the
> crazy idea to evaluate this as avctx->flags & 4.
>
> Otherwise this is probably fine, but will severely gimp the performance,
> to the point that it might not even be able to sustain 60 FPS anymore.
> Printing a warning might be in order.

I have tested this with h264 2880x1620 120fps and some other use-cases
and performance was fine (on Quadro RTX 4000, that is).

Can I just send the fixed patch again to ffmpeg-devel@ffmpeg.org?

ctx->cuparseinfo.ulMaxDisplayDelay = (avctx->flags &
AV_CODEC_FLAG_LOW_DELAY) ? 0 : 4;

Like this?

Btw. there is a related ticket: https://trac.ffmpeg.org/ticket/6495

Best regards
Michal Novotny

>
> _______________________________________________
> 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".
clime Feb. 19, 2021, 11:58 p.m. UTC | #3
On Sat, 20 Feb 2021 at 00:38, clime <clime7@gmail.com> wrote:
>
> On Sat, 20 Feb 2021 at 00:29, Timo Rothenpieler <timo@rothenpieler.org> wrote:
> >
> > On 19.02.2021 23:33, clime wrote:
> > >       ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
> > > -    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
> > > +    ctx->cuparseinfo.ulMaxDisplayDelay = avctx->flags & AV_CODEC_FLAG_LOW_DELAY ? 0 : 4;
> >
> > I'd prefer this with proper braces, to make sure no compiler gets the
> > crazy idea to evaluate this as avctx->flags & 4.
> >
> > Otherwise this is probably fine, but will severely gimp the performance,
> > to the point that it might not even be able to sustain 60 FPS anymore.
> > Printing a warning might be in order.
>
> I have tested this with h264 2880x1620 120fps and some other use-cases
> and performance was fine (on Quadro RTX 4000, that is).
>
> Can I just send the fixed patch again to ffmpeg-devel@ffmpeg.org?

I have a typo in subject :( cuvidec -> cuviddec, I would like to fix
it as well if possible.
I struggled initially with sending a patch here but I think it should
be fine next time...

>
> ctx->cuparseinfo.ulMaxDisplayDelay = (avctx->flags &
> AV_CODEC_FLAG_LOW_DELAY) ? 0 : 4;
>
> Like this?
>
> Btw. there is a related ticket: https://trac.ffmpeg.org/ticket/6495
>
> Best regards
> Michal Novotny
>
> >
> > _______________________________________________
> > 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".
clime Feb. 22, 2021, 6:33 p.m. UTC | #4
I've sent the fixed version:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210222180546.136572-1-clime7@gmail.com/

Best Regards
Michal Novotny

On Sat, 20 Feb 2021 at 00:58, clime <clime7@gmail.com> wrote:
>
> On Sat, 20 Feb 2021 at 00:38, clime <clime7@gmail.com> wrote:
> >
> > On Sat, 20 Feb 2021 at 00:29, Timo Rothenpieler <timo@rothenpieler.org> wrote:
> > >
> > > On 19.02.2021 23:33, clime wrote:
> > > >       ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
> > > > -    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
> > > > +    ctx->cuparseinfo.ulMaxDisplayDelay = avctx->flags & AV_CODEC_FLAG_LOW_DELAY ? 0 : 4;
> > >
> > > I'd prefer this with proper braces, to make sure no compiler gets the
> > > crazy idea to evaluate this as avctx->flags & 4.
> > >
> > > Otherwise this is probably fine, but will severely gimp the performance,
> > > to the point that it might not even be able to sustain 60 FPS anymore.
> > > Printing a warning might be in order.
> >
> > I have tested this with h264 2880x1620 120fps and some other use-cases
> > and performance was fine (on Quadro RTX 4000, that is).
> >
> > Can I just send the fixed patch again to ffmpeg-devel@ffmpeg.org?
>
> I have a typo in subject :( cuvidec -> cuviddec, I would like to fix
> it as well if possible.
> I struggled initially with sending a patch here but I think it should
> be fine next time...
>
> >
> > ctx->cuparseinfo.ulMaxDisplayDelay = (avctx->flags &
> > AV_CODEC_FLAG_LOW_DELAY) ? 0 : 4;
> >
> > Like this?
> >
> > Btw. there is a related ticket: https://trac.ffmpeg.org/ticket/6495
> >
> > Best regards
> > Michal Novotny
> >
> > >
> > > _______________________________________________
> > > 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".
diff mbox series

Patch

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index 49775b5a09..ef5acb6b7b 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -999,7 +999,7 @@  static av_cold int cuvid_decode_init(AVCodecContext *avctx)
     }
 
     ctx->cuparseinfo.ulMaxNumDecodeSurfaces = ctx->nb_surfaces;
-    ctx->cuparseinfo.ulMaxDisplayDelay = 4;
+    ctx->cuparseinfo.ulMaxDisplayDelay = avctx->flags & AV_CODEC_FLAG_LOW_DELAY ? 0 : 4;
     ctx->cuparseinfo.pUserData = avctx;
     ctx->cuparseinfo.pfnSequenceCallback = cuvid_handle_video_sequence;
     ctx->cuparseinfo.pfnDecodePicture = cuvid_handle_picture_decode;