diff mbox series

[FFmpeg-devel,2/3] nvenc: check runtime 9.1 function ptrs before use

Message ID 20200715143402.18582-2-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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Timo Rothenpieler July 15, 2020, 3:17 p.m. UTC | #1
On 15.07.2020 16:34, wangbin wrote:
> From: wang-bin <wbsecg1@gmail.com>
> 
> ---
>   libavcodec/nvenc.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index ac35cb9f48..cec59f02f3 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -140,7 +140,7 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err,
>       NvencContext *ctx = avctx->priv_data;
>       NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs;
>   
> -    if (p_nvenc && ctx->nvencoder)
> +    if (p_nvenc && ctx->nvencoder && p_nvenc->nvEncGetLastErrorString)
>           details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder);
>   #endif
>   
> @@ -1353,7 +1353,7 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
>       }
>   
>   #ifdef NVENC_HAVE_CUSTREAM_PTR
> -    if (ctx->cu_context) {
> +    if (ctx->cu_context && p_nvenc->nvEncSetIOCudaStreams) {
>           nv_status = p_nvenc->nvEncSetIOCudaStreams(ctx->nvencoder, &ctx->cu_stream, &ctx->cu_stream);
>           if (nv_status != NV_ENC_SUCCESS) {
>               nvenc_pop_context(avctx);
> 

This will need a lot more handling of error cases to present a 
meaningful error.
diff mbox series

Patch

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ac35cb9f48..cec59f02f3 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -140,7 +140,7 @@  static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err,
     NvencContext *ctx = avctx->priv_data;
     NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &ctx->nvenc_dload_funcs.nvenc_funcs;
 
-    if (p_nvenc && ctx->nvencoder)
+    if (p_nvenc && ctx->nvencoder && p_nvenc->nvEncGetLastErrorString)
         details = p_nvenc->nvEncGetLastErrorString(ctx->nvencoder);
 #endif
 
@@ -1353,7 +1353,7 @@  static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
     }
 
 #ifdef NVENC_HAVE_CUSTREAM_PTR
-    if (ctx->cu_context) {
+    if (ctx->cu_context && p_nvenc->nvEncSetIOCudaStreams) {
         nv_status = p_nvenc->nvEncSetIOCudaStreams(ctx->nvencoder, &ctx->cu_stream, &ctx->cu_stream);
         if (nv_status != NV_ENC_SUCCESS) {
             nvenc_pop_context(avctx);