Re: [FFmpeg-devel] [PATCH 1/2] lavfi/opencl: add macro for opencl error handling.
> -Original Message- > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of > Mark Thompson > Sent: Monday, July 2, 2018 3:40 PM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavfi/opencl: add macro for opencl > error handling. > > On 02/07/18 21:55, Ruiling Song wrote: > > Signed-off-by: Ruiling Song > > --- > > libavfilter/opencl.h| 4 ++-- > > libavfilter/vf_avgblur_opencl.c | 45 +-- > > libavfilter/vf_overlay_opencl.c | 29 +-- > > libavfilter/vf_program_opencl.c | 14 ++- > > libavfilter/vf_tonemap_opencl.c | 33 +- > > libavfilter/vf_unsharp_opencl.c | 52 > > + > > 6 files changed, 38 insertions(+), 139 deletions(-) > > This doesn't apply - it seems like it's on top of another patch? I am really sorry that I based on the patch on the old version and forget to merge them into one. Have been fixed and sent to the mailing list again. Thanks! Ruiling > > Code looks good to me. > > Thanks, > > - Mark > > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavfi/opencl: add macro for opencl error handling.
On 02/07/18 21:55, Ruiling Song wrote: > Signed-off-by: Ruiling Song > --- > libavfilter/opencl.h| 4 ++-- > libavfilter/vf_avgblur_opencl.c | 45 +-- > libavfilter/vf_overlay_opencl.c | 29 +-- > libavfilter/vf_program_opencl.c | 14 ++- > libavfilter/vf_tonemap_opencl.c | 33 +- > libavfilter/vf_unsharp_opencl.c | 52 > + > 6 files changed, 38 insertions(+), 139 deletions(-) This doesn't apply - it seems like it's on top of another patch? Code looks good to me. Thanks, - Mark > diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h > index fd76f72..0ed360b 100644 > --- a/libavfilter/opencl.h > +++ b/libavfilter/opencl.h > @@ -116,9 +116,9 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext > *avctx, > * A helper macro to handle OpenCL error. It will assign errcode to > * variable err, log error msg, and jump to fail label on error. > */ > -#define OCL_FAIL_ON_ERR(logctx, cle, errcode, ...) do {\ > +#define CL_FAIL_ON_ERROR(errcode, ...) do {\ > if (cle != CL_SUCCESS) {\ > -av_log(logctx, AV_LOG_ERROR, __VA_ARGS__);\ > +av_log(avctx, AV_LOG_ERROR, __VA_ARGS__);\ > err = errcode;\ > goto fail;\ > }\ > diff --git a/libavfilter/vf_avgblur_opencl.c b/libavfilter/vf_avgblur_opencl.c > index d1d3eb1..bc6bcab 100644 > --- a/libavfilter/vf_avgblur_opencl.c > +++ b/libavfilter/vf_avgblur_opencl.c > @@ -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, ); > -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", > ); > -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", ); > -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; > @@ -236,12 +226,8 @@ static int avgblur_opencl_filter_frame(AVFilterLink > *inlink, AVFrame *input) > 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; > -} > +CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue horizontal " > + "kernel: %d.\n", cle); > cle = clFinish(ctx->command_queue); > > err = ff_opencl_filter_work_size_from_image(avctx, global_work, > @@ -259,22 +245,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) > diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c > index 556ce35..e9c8532 100644 > ---
[FFmpeg-devel] [PATCH 1/2] lavfi/opencl: add macro for opencl error handling.
Signed-off-by: Ruiling Song --- libavfilter/opencl.h| 4 ++-- libavfilter/vf_avgblur_opencl.c | 45 +-- libavfilter/vf_overlay_opencl.c | 29 +-- libavfilter/vf_program_opencl.c | 14 ++- libavfilter/vf_tonemap_opencl.c | 33 +- libavfilter/vf_unsharp_opencl.c | 52 + 6 files changed, 38 insertions(+), 139 deletions(-) diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h index fd76f72..0ed360b 100644 --- a/libavfilter/opencl.h +++ b/libavfilter/opencl.h @@ -116,9 +116,9 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, * A helper macro to handle OpenCL error. It will assign errcode to * variable err, log error msg, and jump to fail label on error. */ -#define OCL_FAIL_ON_ERR(logctx, cle, errcode, ...) do {\ +#define CL_FAIL_ON_ERROR(errcode, ...) do {\ if (cle != CL_SUCCESS) {\ -av_log(logctx, AV_LOG_ERROR, __VA_ARGS__);\ +av_log(avctx, AV_LOG_ERROR, __VA_ARGS__);\ err = errcode;\ goto fail;\ }\ diff --git a/libavfilter/vf_avgblur_opencl.c b/libavfilter/vf_avgblur_opencl.c index d1d3eb1..bc6bcab 100644 --- a/libavfilter/vf_avgblur_opencl.c +++ b/libavfilter/vf_avgblur_opencl.c @@ -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, ); -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", ); -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", ); -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; @@ -236,12 +226,8 @@ static int avgblur_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input) 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; -} +CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue horizontal " + "kernel: %d.\n", cle); cle = clFinish(ctx->command_queue); err = ff_opencl_filter_work_size_from_image(avctx, global_work, @@ -259,22 +245,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) diff --git a/libavfilter/vf_overlay_opencl.c b/libavfilter/vf_overlay_opencl.c index 556ce35..e9c8532 100644 --- a/libavfilter/vf_overlay_opencl.c +++ b/libavfilter/vf_overlay_opencl.c @@ -100,19 +100,11 @@ static int overlay_opencl_load(AVFilterContext *avctx, ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context, ctx->ocf.hwctx->device_id, 0, ); -if (!ctx->command_queue) { -