summaryrefslogtreecommitdiff
path: root/libavcodec/cuviddec.c
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2018-11-10 22:47:28 -0800
committerPhilip Langdale <philipl@overt.org>2018-11-14 17:39:42 -0800
commit19d3d0c0570981ddc8a224f07d734ff75d76e234 (patch)
tree01f718e1878010605cd28d5947b676d42519dfc9 /libavcodec/cuviddec.c
parentf0f2832a5ce93bad9b1d29f99df6bda2380fc41c (diff)
downloadffmpeg-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.c25
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)
{