[FFmpeg-devel] [PATCH] vf_unsharp_opencl: Do not apply kernel to locations outside images
Mark Thompson
sw at jkqxz.net
Fri Mar 9 02:47:46 EET 2018
---
(Oops.)
libavfilter/vf_unsharp_opencl.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_unsharp_opencl.c b/libavfilter/vf_unsharp_opencl.c
index 6a453c014b..3ee1b5b4ae 100644
--- a/libavfilter/vf_unsharp_opencl.c
+++ b/libavfilter/vf_unsharp_opencl.c
@@ -236,6 +236,7 @@ static int unsharp_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
size_t global_work[2];
size_t local_work[2];
cl_mem src, dst;
+ size_t plane_width, plane_height;
int err, p;
av_log(ctx, AV_LOG_DEBUG, "Filter input: %s, %ux%u (%"PRId64").\n",
@@ -268,6 +269,21 @@ static int unsharp_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
if (!dst)
break;
+ cle = clGetImageInfo(src, CL_IMAGE_WIDTH,
+ sizeof(plane_width), &plane_width, NULL);
+ if (cle != CL_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to get plane %d "
+ "width: %d.\n", p, cle);
+ goto fail;
+ }
+ cle = clGetImageInfo(src, CL_IMAGE_HEIGHT,
+ sizeof(plane_height), &plane_height, NULL);
+ if (cle != CL_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to get plane %d "
+ "height: %d.\n", p, cle);
+ goto fail;
+ }
+
cle = clSetKernelArg(ctx->kernel, 0, sizeof(cl_mem), &dst);
if (cle != CL_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
@@ -321,11 +337,11 @@ static int unsharp_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
}
if (ctx->global) {
- global_work[0] = output->width;
- global_work[1] = output->height;
+ global_work[0] = plane_width;
+ global_work[1] = plane_height;
} else {
- global_work[0] = FFALIGN(output->width, 16);
- global_work[1] = FFALIGN(output->height, 16);
+ global_work[0] = FFALIGN(plane_width, 16);
+ global_work[1] = FFALIGN(plane_height, 16);
local_work[0] = 16;
local_work[1] = 16;
}
--
2.16.1
More information about the ffmpeg-devel
mailing list