Commit 7cd58a8a authored by Danil Iashchenko's avatar Danil Iashchenko Committed by Mark Thompson

lavfi/convolution_opencl: use CL_FAIL_ON_ERROR for error handling

Switch to use CL_FAIL_ON_ERROR for error handling
parent 3c26ce46
...@@ -67,12 +67,8 @@ static int convolution_opencl_init(AVFilterContext *avctx) ...@@ -67,12 +67,8 @@ static int convolution_opencl_init(AVFilterContext *avctx)
ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context, ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
ctx->ocf.hwctx->device_id, ctx->ocf.hwctx->device_id,
0, &cle); 0, &cle);
if (!ctx->command_queue) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create OpenCL "
av_log(avctx, AV_LOG_ERROR, "Failed to create OpenCL " "command queue %d.\n", cle);
"command queue: %d.\n", cle);
err = AVERROR(EIO);
goto fail;
}
if (!strcmp(avctx->filter->name, "convolution_opencl")) { if (!strcmp(avctx->filter->name, "convolution_opencl")) {
kernel_name = "convolution_global"; kernel_name = "convolution_global";
...@@ -84,11 +80,8 @@ static int convolution_opencl_init(AVFilterContext *avctx) ...@@ -84,11 +80,8 @@ static int convolution_opencl_init(AVFilterContext *avctx)
kernel_name = "roberts_global"; kernel_name = "roberts_global";
} }
ctx->kernel = clCreateKernel(ctx->ocf.program, kernel_name, &cle); ctx->kernel = clCreateKernel(ctx->ocf.program, kernel_name, &cle);
if (!ctx->kernel) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create "
av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle); "kernel %d.\n", cle);
err = AVERROR(EIO);
goto fail;
}
ctx->initialised = 1; ctx->initialised = 1;
return 0; return 0;
...@@ -243,12 +236,8 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input) ...@@ -243,12 +236,8 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL, cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
global_work, NULL, global_work, NULL,
0, NULL, NULL); 0, NULL, NULL);
if (cle != CL_SUCCESS) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue "
av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n", "kernel: %d.\n", cle);
cle);
err = AVERROR(EIO);
goto fail;
}
} else { } else {
if (!(ctx->planes & (1 << p))) { if (!(ctx->planes & (1 << p))) {
err = ff_opencl_filter_work_size_from_image(avctx, region, output, p, 0); err = ff_opencl_filter_work_size_from_image(avctx, region, output, p, 0);
...@@ -257,12 +246,8 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input) ...@@ -257,12 +246,8 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
cle = clEnqueueCopyImage(ctx->command_queue, src, dst, cle = clEnqueueCopyImage(ctx->command_queue, src, dst,
origin, origin, region, 0, NULL, NULL); origin, origin, region, 0, NULL, NULL);
if (cle != CL_SUCCESS) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to copy plane %d: %d.\n",
av_log(avctx, AV_LOG_ERROR, "Failed to copy plane %d: %d.\n", p, cle);
p, cle);
err = AVERROR(EIO);
goto fail;
}
} else { } else {
CL_SET_KERNEL_ARG(ctx->kernel, 0, cl_mem, &dst); CL_SET_KERNEL_ARG(ctx->kernel, 0, cl_mem, &dst);
CL_SET_KERNEL_ARG(ctx->kernel, 1, cl_mem, &src); CL_SET_KERNEL_ARG(ctx->kernel, 1, cl_mem, &src);
...@@ -280,23 +265,14 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input) ...@@ -280,23 +265,14 @@ static int convolution_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL, cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL,
global_work, NULL, global_work, NULL,
0, NULL, NULL); 0, NULL, NULL);
if (cle != CL_SUCCESS) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue "
av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n", "kernel: %d.\n", cle);
cle);
err = AVERROR(EIO);
goto fail;
}
} }
} }
} }
cle = clFinish(ctx->command_queue); cle = clFinish(ctx->command_queue);
if (cle != CL_SUCCESS) { CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to finish command queue: %d.\n", cle);
av_log(avctx, AV_LOG_ERROR, "Failed to finish command queue: %d.\n",
cle);
err = AVERROR(EIO);
goto fail;
}
err = av_frame_copy_props(output, input); err = av_frame_copy_props(output, input);
if (err < 0) if (err < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment