[FFmpeg-devel] [PATCH 2/2] libavutil/libavfilter: deshake opencl filter based on comments on 20130329
Michael Niedermayer
michaelni at gmx.at
Fri Mar 29 22:30:38 CET 2013
On Fri, Mar 29, 2013 at 09:33:16PM +0800, Wei Gao wrote:
[...]
> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
> index 138c25d..9e06fd8 100644
> --- a/libavfilter/vf_deshake.c
> +++ b/libavfilter/vf_deshake.c
> @@ -1,6 +1,7 @@
> /*
> * Copyright (C) 2010 Georg Martius <georg.martius at web.de>
> * Copyright (C) 2010 Daniel G. Taylor <dan at programmer-art.org>
> + * Copyright (C) 2013 Wei Gao <weigao at multicorewareinc.com>
> *
> * This file is part of FFmpeg.
> *
> @@ -60,6 +61,11 @@
> #include "libavcodec/dsputil.h"
>
> #include "transform.h"
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> +#include "libavutil/opencl.h"
> +#include "libavutil/dict.h"
> +#include "transform_opencl.h"
> +#endif
>
> #define CHROMA_WIDTH(link) -((-link->w) >> av_pix_fmt_desc_get(link->format)->log2_chroma_w)
> #define CHROMA_HEIGHT(link) -((-link->h) >> av_pix_fmt_desc_get(link->format)->log2_chroma_h)
> @@ -86,6 +92,28 @@ typedef struct {
> double zoom; ///< Zoom percentage
> } Transform;
>
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> +typedef struct {
[...]
> +}DeshakeOpenclEnv;
> +#endif
> +
> typedef struct {
> const AVClass *class;
> AVFrame *ref; ///< Previous frame
> @@ -106,6 +134,10 @@ typedef struct {
> int cx;
> int cy;
> char *filename; ///< Motion search detailed log filename
> + int is_opencl;
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> + DeshakeOpenclEnv opencl_env;
> +#endif
> } DeshakeContext;
>
> #define OFFSET(x) offsetof(DeshakeContext, x)
> @@ -460,6 +492,51 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
> }
> av_frame_copy_props(out, in);
>
> +#if CONFIG_DESHAKE_OPENCL_FILTER
[...]
> + return ret;
> + }
> +#endif
> +
> if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) {
> // Find the most likely global motion for the current frame
> find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t);
> @@ -530,6 +607,38 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
> deshake->last.vector.y = t.vector.y;
> deshake->last.angle = t.angle;
> deshake->last.zoom = t.zoom;
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> + if (deshake->is_opencl && CONFIG_DESHAKE_OPENCL_FILTER) {
[...]
> + }
> +#endif
>
> // Generate a luma transformation matrix
> avfilter_get_matrix(t.vector.x, t.vector.y, t.angle, 1.0 + t.zoom / 100.0, matrix);
> @@ -553,6 +662,48 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>
> return ff_filter_frame(outlink, out);
> }
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> +static av_cold int init_opencl(AVFilterContext *ctx, const char *args)
> +{
[...]
> + uninit(ctx);
> +}
> +#endif
> +
>
> static const AVFilterPad deshake_inputs[] = {
> {
> @@ -583,3 +734,36 @@ AVFilter avfilter_vf_deshake = {
> .outputs = deshake_outputs,
> .priv_class = &deshake_class,
> };
> +
> +#if CONFIG_DESHAKE_OPENCL_FILTER
> +
[...]
> +};
> +#endif
The opencl code should be moved into a seperate file and called through
function pointers or other means not interleaved into the existing
filters.
Especially with more complex filters this would become really messy
[...]
Thanks
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.
-------------- 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/20130329/54172ff1/attachment.asc>
More information about the ffmpeg-devel
mailing list