summaryrefslogtreecommitdiffstats
path: root/video/out/hwdec/hwdec_cuda.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/hwdec/hwdec_cuda.c')
-rw-r--r--video/out/hwdec/hwdec_cuda.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c
index 895fb07d61..57e4fb40e3 100644
--- a/video/out/hwdec/hwdec_cuda.c
+++ b/video/out/hwdec/hwdec_cuda.c
@@ -57,7 +57,7 @@ int check_cu(const struct ra_hwdec *hw, CUresult err, const char *func)
#define CHECK_CU(x) check_cu(hw, (x), #x)
-const static cuda_interop_init interop_inits[] = {
+static const cuda_interop_init interop_inits[] = {
#if HAVE_GL
cuda_gl_init,
#endif
@@ -74,10 +74,11 @@ static int cuda_init(struct ra_hwdec *hw)
int ret = 0;
struct cuda_hw_priv *p = hw->priv;
CudaFunctions *cu;
+ int level = hw->probing ? MSGL_V : MSGL_ERR;
ret = cuda_load_functions(&p->cu, NULL);
if (ret != 0) {
- MP_VERBOSE(hw, "Failed to load CUDA symbols\n");
+ MP_MSG(hw, level, "Failed to load CUDA symbols\n");
return -1;
}
cu = p->cu;
@@ -94,7 +95,8 @@ static int cuda_init(struct ra_hwdec *hw)
}
if (!p->ext_init || !p->ext_uninit) {
- MP_VERBOSE(hw, "CUDA hwdec only works with OpenGL or Vulkan backends.\n");
+ MP_MSG(hw, level,
+ "CUDA hwdec only works with OpenGL or Vulkan backends.\n");
return -1;
}
@@ -109,7 +111,7 @@ static int cuda_init(struct ra_hwdec *hw)
ret = av_hwdevice_ctx_init(hw_device_ctx);
if (ret < 0) {
- MP_ERR(hw, "av_hwdevice_ctx_init failed\n");
+ MP_MSG(hw, level, "av_hwdevice_ctx_init failed\n");
goto error;
}
@@ -120,6 +122,7 @@ static int cuda_init(struct ra_hwdec *hw)
p->hwctx = (struct mp_hwdec_ctx) {
.driver_name = hw->driver->name,
.av_device_ref = hw_device_ctx,
+ .hw_imgfmt = IMGFMT_CUDA,
};
hwdec_devices_add(hw->devs, &p->hwctx);
return 0;
@@ -253,16 +256,22 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
if (p_owner->do_full_sync)
CHECK_CU(cu->cuStreamSynchronize(0));
+ // fall through
error:
- eret = CHECK_CU(cu->cuCtxPopCurrent(&dummy));
- if (eret < 0)
- return eret;
- return ret;
+ // Regardless of success or failure, we no longer need the source image,
+ // because this hwdec makes an explicit memcpy into the mapper textures
+ mp_image_unrefp(&mapper->src);
+
+ eret = CHECK_CU(cu->cuCtxPopCurrent(&dummy));
+ if (eret < 0)
+ return eret;
+
+ return ret;
}
const struct ra_hwdec_driver ra_hwdec_cuda = {
- .name = "cuda-nvdec",
+ .name = "cuda",
.imgfmts = {IMGFMT_CUDA, 0},
.priv_size = sizeof(struct cuda_hw_priv),
.init = cuda_init,