diff mbox series

[FFmpeg-devel,3/3] nvenc: check sdk 10.0 ptrs at runtime

Message ID 20200715143402.18582-3-wbsecg1@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] nvenc: use runtime api version to support old drivers | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Wang Bin July 15, 2020, 2:34 p.m. UTC
From: wang-bin <wbsecg1@gmail.com>

---
 libavcodec/nvenc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Timo Rothenpieler July 15, 2020, 3:19 p.m. UTC | #1
On 15.07.2020 16:34, wangbin wrote:
> From: wang-bin <wbsecg1@gmail.com>
> 
> ---
>   libavcodec/nvenc.c | 11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index cec59f02f3..c421c292c8 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -1248,11 +1248,12 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
>   #ifdef NVENC_HAVE_NEW_PRESETS
>           ctx->init_encode_params.tuningInfo = ctx->tuning_info;
>   
> -        nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
> -            ctx->init_encode_params.encodeGUID,
> -            ctx->init_encode_params.presetGUID,
> -            ctx->init_encode_params.tuningInfo,
> -            &preset_config);
> +        if (p_nvenc->nvEncGetEncodePresetConfigEx)
> +            nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
> +                ctx->init_encode_params.encodeGUID,
> +                ctx->init_encode_params.presetGUID,
> +                ctx->init_encode_params.tuningInfo,
> +                &preset_config);
>   #endif
>       } else {
>   #ifdef NVENC_HAVE_NEW_PRESETS
> 

Same here. Just not calling that function will lead to weird behaviour 
down the chain.
Needs proper handling plus error message.

This will also be the case for a lot of failure cases where non-existent 
parameters for the old version are passed to the older driver.
Like, newer profiles, entire new options, ...
Wang Bin July 16, 2020, 2:29 a.m. UTC | #2
Timo Rothenpieler <timo@rothenpieler.org> 于2020年7月15日周三 下午11:19写道:

> On 15.07.2020 16:34, wangbin wrote:
> > From: wang-bin <wbsecg1@gmail.com>
> >
> > ---
> >   libavcodec/nvenc.c | 11 ++++++-----
> >   1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> > index cec59f02f3..c421c292c8 100644
> > --- a/libavcodec/nvenc.c
> > +++ b/libavcodec/nvenc.c
> > @@ -1248,11 +1248,12 @@ static av_cold int
> nvenc_setup_encoder(AVCodecContext *avctx)
> >   #ifdef NVENC_HAVE_NEW_PRESETS
> >           ctx->init_encode_params.tuningInfo = ctx->tuning_info;
> >
> > -        nv_status =
> p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
> > -            ctx->init_encode_params.encodeGUID,
> > -            ctx->init_encode_params.presetGUID,
> > -            ctx->init_encode_params.tuningInfo,
> > -            &preset_config);
> > +        if (p_nvenc->nvEncGetEncodePresetConfigEx)
> > +            nv_status =
> p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
> > +                ctx->init_encode_params.encodeGUID,
> > +                ctx->init_encode_params.presetGUID,
> > +                ctx->init_encode_params.tuningInfo,
> > +                &preset_config);
> >   #endif
> >       } else {
> >   #ifdef NVENC_HAVE_NEW_PRESETS
> >
>
> Same here. Just not calling that function will lead to weird behaviour
> down the chain.
> Needs proper handling plus error message.
>
> This will also be the case for a lot of failure cases where non-existent
> parameters for the old version are passed to the older driver.
> Like, newer profiles, entire new options, ...
>
> If a new parameter is not zero, or a new parameter value is set, check
driver version and on old drivers give a warning about a new driver is
required.
diff mbox series

Patch

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index cec59f02f3..c421c292c8 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1248,11 +1248,12 @@  static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
 #ifdef NVENC_HAVE_NEW_PRESETS
         ctx->init_encode_params.tuningInfo = ctx->tuning_info;
 
-        nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
-            ctx->init_encode_params.encodeGUID,
-            ctx->init_encode_params.presetGUID,
-            ctx->init_encode_params.tuningInfo,
-            &preset_config);
+        if (p_nvenc->nvEncGetEncodePresetConfigEx)
+            nv_status = p_nvenc->nvEncGetEncodePresetConfigEx(ctx->nvencoder,
+                ctx->init_encode_params.encodeGUID,
+                ctx->init_encode_params.presetGUID,
+                ctx->init_encode_params.tuningInfo,
+                &preset_config);
 #endif
     } else {
 #ifdef NVENC_HAVE_NEW_PRESETS