]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_avgblur_opencl.c
Revert "avutil/timecode: fix sscanf format string with garbage at the end"
[ffmpeg] / libavfilter / vf_avgblur_opencl.c
index d1d3eb19830c118e60851c2b883990e5f54d17cf..f0e5f01e045fa48e74c4bdc02448dea6a8275b7a 100644 (file)
@@ -64,26 +64,16 @@ static int avgblur_opencl_init(AVFilterContext *avctx)
     ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
                                               ctx->ocf.hwctx->device_id,
                                               0, &cle);
-    if (!ctx->command_queue) {
-        av_log(avctx, AV_LOG_ERROR, "Failed to create OpenCL "
-               "command queue: %d.\n", cle);
-        err = AVERROR(EIO);
-        goto fail;
-    }
+    CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create OpenCL "
+                     "command queue %d.\n", cle);
 
     ctx->kernel_horiz = clCreateKernel(ctx->ocf.program,"avgblur_horiz", &cle);
-    if (!ctx->kernel_horiz) {
-        av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle);
-        err = AVERROR(EIO);
-        goto fail;
-    }
+    CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create horizontal "
+                     "kernel %d.\n", cle);
 
     ctx->kernel_vert = clCreateKernel(ctx->ocf.program,"avgblur_vert", &cle);
-    if (!ctx->kernel_vert) {
-        av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle);
-        err = AVERROR(EIO);
-        goto fail;
-    }
+    CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create vertical "
+                     "kernel %d.\n", cle);
 
     ctx->initialised = 1;
     return 0;
@@ -215,10 +205,6 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
             radius_y = 0;
         }
 
-        av_log(avctx, AV_LOG_DEBUG, "Run kernel on plane %d "
-               "(%"SIZE_SPECIFIER"x%"SIZE_SPECIFIER").\n",
-               p, global_work[0], global_work[1]);
-
         for (i = 0; i < ctx->power[p]; i++) {
             CL_SET_KERNEL_ARG(ctx->kernel_horiz, 0, cl_mem, &inter);
             CL_SET_KERNEL_ARG(ctx->kernel_horiz, 1, cl_mem, i == 0 ? &src : &dst);
@@ -233,16 +219,15 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
             if (err < 0)
                 goto fail;
 
+            av_log(avctx, AV_LOG_DEBUG, "Run kernel on plane %d "
+                   "(%"SIZE_SPECIFIER"x%"SIZE_SPECIFIER").\n",
+                   p, global_work[0], global_work[1]);
+
             cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel_horiz, 2, NULL,
                                          global_work, NULL,
                                          0, NULL, NULL);
-            if (cle != CL_SUCCESS) {
-                av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n",
-                       cle);
-                err = AVERROR(EIO);
-                goto fail;
-            }
-            cle = clFinish(ctx->command_queue);
+            CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue horizontal "
+                             "kernel: %d.\n", cle);
 
             err = ff_opencl_filter_work_size_from_image(avctx, global_work,
                                                         i == 0 ? output : intermediate, p, 0);
@@ -259,22 +244,13 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
             cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel_vert, 2, NULL,
                                          global_work, NULL,
                                          0, NULL, NULL);
-            if (cle != CL_SUCCESS) {
-                av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n",
-                       cle);
-                err = AVERROR(EIO);
-                goto fail;
-            }
+            CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue vertical "
+                             "kernel: %d.\n", cle);
         }
     }
 
     cle = clFinish(ctx->command_queue);
-    if (cle != CL_SUCCESS) {
-        av_log(avctx, AV_LOG_ERROR, "Failed to finish command queue: %d.\n",
-               cle);
-        err = AVERROR(EIO);
-        goto fail;
-    }
+    CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to finish command queue: %d.\n", cle);
 
     err = av_frame_copy_props(output, input);
     if (err < 0)