diff options
author | Philip Langdale <philipl@overt.org> | 2018-11-10 22:47:28 -0800 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2018-11-14 17:39:42 -0800 |
commit | 19d3d0c0570981ddc8a224f07d734ff75d76e234 (patch) | |
tree | 01f718e1878010605cd28d5947b676d42519dfc9 /libavcodec/cuviddec.c | |
parent | f0f2832a5ce93bad9b1d29f99df6bda2380fc41c (diff) | |
download | ffmpeg-19d3d0c0570981ddc8a224f07d734ff75d76e234.tar.gz |
avutil/hwcontext_cuda: Define and use common CHECK_CU()
We have a pattern of wrapping CUDA calls to print errors and
normalise return values that is used in a couple of places. To
avoid duplication and increase consistency, let's put the wrapper
implementation in a shared place and use it everywhere.
Affects:
* avcodec/cuviddec
* avcodec/nvdec
* avcodec/nvenc
* avfilter/vf_scale_cuda
* avfilter/vf_scale_npp
* avfilter/vf_thumbnail_cuda
* avfilter/vf_transpose_npp
* avfilter/vf_yadif_cuda
Diffstat (limited to 'libavcodec/cuviddec.c')
-rw-r--r-- | libavcodec/cuviddec.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index f21273c07e..03589367ce 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -25,6 +25,7 @@ #include "libavutil/mathematics.h" #include "libavutil/hwcontext.h" #include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/cuda_check.h" #include "libavutil/fifo.h" #include "libavutil/log.h" #include "libavutil/opt.h" @@ -95,29 +96,7 @@ typedef struct CuvidParsedFrame int is_deinterlacing; } CuvidParsedFrame; -static int check_cu(AVCodecContext *avctx, CUresult err, const char *func) -{ - CuvidContext *ctx = avctx->priv_data; - const char *err_name; - const char *err_string; - - av_log(avctx, AV_LOG_TRACE, "Calling %s\n", func); - - if (err == CUDA_SUCCESS) - return 0; - - ctx->cudl->cuGetErrorName(err, &err_name); - ctx->cudl->cuGetErrorString(err, &err_string); - - av_log(avctx, AV_LOG_ERROR, "%s failed", func); - if (err_name && err_string) - av_log(avctx, AV_LOG_ERROR, " -> %s: %s", err_name, err_string); - av_log(avctx, AV_LOG_ERROR, "\n"); - - return AVERROR_EXTERNAL; -} - -#define CHECK_CU(x) check_cu(avctx, (x), #x) +#define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, ctx->cudl, x) static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* format) { |