[FFmpeg-devel] [PATCH 3/3] lavfi/opencl: replace SHIFTUP with ROUNDED_RSHIFT.

Wei Gao highgod0401 at gmail.com
Thu May 9 02:07:20 CEST 2013


2013/5/7 Clément Bœsch <ubitux at gmail.com>

> ---
>  libavfilter/unsharp.h        | 3 ---
>  libavfilter/unsharp_opencl.c | 7 ++++---
>  libavfilter/vf_unsharp.c     | 6 +++---
>  3 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
> index 0add8aa..c225929 100644
> --- a/libavfilter/unsharp.h
> +++ b/libavfilter/unsharp.h
> @@ -30,9 +30,6 @@
>  #define MIN_MATRIX_SIZE 3
>  #define MAX_MATRIX_SIZE 63
>
> -/* right-shift and round-up */
> -#define SHIFTUP(x,shift) (-((-(x))>>(shift)))
> -
>  #if CONFIG_OPENCL
>
>  typedef struct {
> diff --git a/libavfilter/unsharp_opencl.c b/libavfilter/unsharp_opencl.c
> index 91a1292..47602f7 100644
> --- a/libavfilter/unsharp_opencl.c
> +++ b/libavfilter/unsharp_opencl.c
> @@ -24,6 +24,7 @@
>   */
>
>  #include "unsharp_opencl.h"
> +#include "libavutil/common.h"
>  #include "libavutil/opencl_internal.h"
>
>  #define PLANE_NUM 3
> @@ -152,8 +153,8 @@ int ff_opencl_apply_unsharp(AVFilterContext *ctx,
> AVFrame *in, AVFrame *out)
>      AVFilterLink *link = ctx->inputs[0];
>      UnsharpContext *unsharp = ctx->priv;
>      cl_int status;
> -    int cw = SHIFTUP(link->w, unsharp->hsub);
> -    int ch = SHIFTUP(link->h, unsharp->vsub);
> +    int cw = ROUNDED_RSHIFT(link->w, unsharp->hsub);
> +    int ch = ROUNDED_RSHIFT(link->h, unsharp->vsub);
>      const size_t global_work_size = link->w * link->h + 2 * ch * cw;
>      FFOpenclParam opencl_param = {0};
>
> @@ -245,7 +246,7 @@ int
> ff_opencl_unsharp_process_inout_buf(AVFilterContext *ctx, AVFrame *in, AVFra
>      int ret = 0;
>      AVFilterLink *link = ctx->inputs[0];
>      UnsharpContext *unsharp = ctx->priv;
> -    int ch = SHIFTUP(link->h, unsharp->vsub);
> +    int ch = ROUNDED_RSHIFT(link->h, unsharp->vsub);
>
>      if ((!unsharp->opencl_ctx.cl_inbuf) ||
> (!unsharp->opencl_ctx.cl_outbuf)) {
>          unsharp->opencl_ctx.in_plane_size[0]  = (in->linesize[0] *
> in->height);
> diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
> index 4ea4348..57dd99b 100644
> --- a/libavfilter/vf_unsharp.c
> +++ b/libavfilter/vf_unsharp.c
> @@ -114,9 +114,9 @@ static int apply_unsharp_c(AVFilterContext *ctx,
> AVFrame *in, AVFrame *out)
>      int i, plane_w[3], plane_h[3];
>      UnsharpFilterParam *fp[3];
>      plane_w[0] = inlink->w;
> -    plane_w[1] = plane_w[2] = SHIFTUP(inlink->w, unsharp->hsub);
> +    plane_w[1] = plane_w[2] = ROUNDED_RSHIFT(inlink->w, unsharp->hsub);
>      plane_h[0] = inlink->h;
> -    plane_h[1] = plane_h[2] = SHIFTUP(inlink->h, unsharp->vsub);
> +    plane_h[1] = plane_h[2] = ROUNDED_RSHIFT(inlink->h, unsharp->vsub);
>      fp[0] = &unsharp->luma;
>      fp[1] = fp[2] = &unsharp->chroma;
>      for (i = 0; i < 3; i++) {
> @@ -207,7 +207,7 @@ static int config_props(AVFilterLink *link)
>      ret = init_filter_param(link->dst, &unsharp->luma,   "luma",
> link->w);
>      if (ret < 0)
>          return ret;
> -    ret = init_filter_param(link->dst, &unsharp->chroma, "chroma",
> SHIFTUP(link->w, unsharp->hsub));
> +    ret = init_filter_param(link->dst, &unsharp->chroma, "chroma",
> ROUNDED_RSHIFT(link->w, unsharp->hsub));
>      if (ret < 0)
>          return ret;
>
> --
> 1.8.2.2
>
> LGTM, thanks

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list