[FFmpeg-devel] [PATCH 2/2] libavutil/libavfilter: deshake opencl filter based on comments on 20130330

Michael Niedermayer michaelni at gmx.at
Sat Mar 30 13:19:15 CET 2013


On Sat, Mar 30, 2013 at 06:48:21PM +0800, Wei Gao wrote:
> 

[...]
> +int ff_opencl_deshake_init(AVFilterContext *ctx, FFDeshakeOpenclEnv *opencl_env)
> +{
> +    int ret = 0;
> +    AVDictionary *options = NULL;
> +    av_dict_set(&options, "build_option", "-I.", 0);

> +    ret = av_opencl_init(options, NULL, NULL);
> +    av_dict_free(&options);
> +    ret = av_opencl_init(options, NULL, NULL);

duplicate av_opencl_init() calls


> +    if (ret < 0)
> +        return ret;
> +    memset(opencl_env, 0, sizeof(FFDeshakeOpenclEnv));
> +    opencl_env->matrix_size = 6;
> +    opencl_env->plane_num   = 3;
> +    opencl_env->ctx         = ctx;
> +    ret = av_opencl_buffer_create((cl_mem *)(&(opencl_env->cl_matrix_y)),
> +        opencl_env->matrix_size*sizeof(cl_float), CL_MEM_READ_ONLY, NULL);
> +    if (ret < 0)
> +        return ret;
> +    ret = av_opencl_buffer_create((cl_mem *)(&(opencl_env->cl_matrix_uv)),
> +        opencl_env->matrix_size*sizeof(cl_float), CL_MEM_READ_ONLY, NULL);

why is the type of cl_matrix void and not cl_mem ?
It would avoid some casts


[...]
> @@ -106,6 +108,13 @@ typedef struct {
>      int cx;
>      int cy;
>      char *filename;            ///< Motion search detailed log filename
> +    int is_opencl;
> +    FFDeshakeOpenclEnv opencl_env;
> +    int (* opencl_transform)(FFDeshakeOpenclEnv *, int, int, int, int, const float *, const float *,
> +               enum InterpolateMethod, enum FillMethod , AVFrame *, AVFrame *);
> +    int (* opencl_init)(AVFilterContext *, FFDeshakeOpenclEnv *);
> +    void (* opencl_uninit)(FFDeshakeOpenclEnv *);
> +    int (* opencl_process_inout_buf)(AVFrame *, AVFrame *, FFDeshakeOpenclEnv *);
>  } DeshakeContext;

this should be 

int (* transform)(...);

[...]
> @@ -531,6 +557,20 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>      deshake->last.angle = t.angle;
>      deshake->last.zoom = t.zoom;
>  
> +    if (deshake->is_opencl && CONFIG_OPENCL) {
> +        int ret = 0;
> +        float matrix_y_opencl[9];
> +        float matrix_uv_opencl[9];
> +        avfilter_get_matrix(t.vector.x, t.vector.y, t.angle, 1.0 + t.zoom / 100.0, matrix_y_opencl);
> +        avfilter_get_matrix(t.vector.x / (link->w / CHROMA_WIDTH(link)), t.vector.y / (link->h / CHROMA_HEIGHT(link)), t.angle, 1.0 + t.zoom / 100.0, matrix_uv_opencl);
> +
> +        ret = deshake->opencl_transform(&(deshake->opencl_env), link->w, link->h, CHROMA_WIDTH(link), CHROMA_HEIGHT(link),
> +                                    matrix_y_opencl, matrix_uv_opencl, INTERPOLATE_BILINEAR, deshake->edge, in, out);
> +        if (ret < 0)
> +            return ret;
> +        goto end;
> +    }

this should call transform()

which either then calls the normal C implementation or opencl or
maybe one day AVX

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130330/2f72f76b/attachment.asc>


More information about the ffmpeg-devel mailing list