summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/d3d11/hwdec_d3d11va.c3
-rw-r--r--video/out/gpu/hwdec.c2
-rw-r--r--video/out/hwdec/hwdec_cuda.c14
3 files changed, 15 insertions, 4 deletions
diff --git a/video/out/d3d11/hwdec_d3d11va.c b/video/out/d3d11/hwdec_d3d11va.c
index 02f796e003..3006e5c7d0 100644
--- a/video/out/d3d11/hwdec_d3d11va.c
+++ b/video/out/d3d11/hwdec_d3d11va.c
@@ -206,6 +206,9 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
.bottom = mapper->dst_params.h,
.back = 1,
}), D3D11_COPY_DISCARD);
+
+ // We no longer need the original texture after copying it.
+ mp_image_unrefp(&mapper->src);
} else {
D3D11_TEXTURE2D_DESC desc2d;
ID3D11Texture2D_GetDesc(tex, &desc2d);
diff --git a/video/out/gpu/hwdec.c b/video/out/gpu/hwdec.c
index 4fb6240651..dd2809f41e 100644
--- a/video/out/gpu/hwdec.c
+++ b/video/out/gpu/hwdec.c
@@ -186,6 +186,8 @@ void ra_hwdec_mapper_unmap(struct ra_hwdec_mapper *mapper)
{
if (mapper->driver->unmap)
mapper->driver->unmap(mapper);
+
+ // Clean up after the image if the mapper didn't already
mp_image_unrefp(&mapper->src);
}
diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c
index 895fb07d61..0fe0f7bda8 100644
--- a/video/out/hwdec/hwdec_cuda.c
+++ b/video/out/hwdec/hwdec_cuda.c
@@ -253,12 +253,18 @@ 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 = {