[FFmpeg-devel] [PATCH] avfilter: add displace video filter

Clément Bœsch u at pkh.me
Thu Nov 7 21:20:43 CET 2013


On Wed, Oct 23, 2013 at 09:14:28PM +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
>  doc/filters.texi          |  43 +++++
>  libavfilter/Makefile      |   1 +
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/vf_displace.c | 390 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 435 insertions(+)
>  create mode 100644 libavfilter/vf_displace.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 7783807..0ba4e51 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -3100,6 +3100,49 @@ delogo=x=0:y=0:w=100:h=77:band=10
>  
>  @end itemize
>  
> + at section displace
> +
> +Displace pixels as indicated by second and third input stream.
> +
> +It takes three input streams and output one stream, the first input is the

It takes ... and outputS ...

> +source and second and third input are displacement maps.

is the source, and second and third ...
             ^
> +
> +The second input specifies how much to displace pixels along the
> +x-axis, while the third input specifies how much to displace pixels
> +along the y-axis.
> +

Can you give an example with values? Assuming a pixel value between 0x00
and 0xFF, it will displace it by [-127;127]?

Can you use 10-bit maps to make larger displacement?

> +A description of the accepted options follows.
> +
> + at table @option
> + at item edge
> +Set displace behavior for pixels that are out of range.
> +
> +Available values are:
> + at table @samp
> + at item blank
> +Missing pixels are replaced by black pixels.
> +
> + at item smear
> +Adjacent pixels will spread out to replace missing pixels.
> +
> + at item wrap
> +Out of range pixels are wrapped so they point to pixels of other side.
> + at end table
> +
> +Default is @samp{smear}.
> +
> + at end table
> +
> + at subsection Examples
> +
> + at itemize
> + at item
> +Add ripple effect to input of video size hd720:
> + at example
> +ffmpeg -i INPUT -f lavfi -i nullsrc=s=hd720,geq='r=128+50*sin(2*PI*X/800):g=128+50*sin(2*PI*X/800):b=128+50*sin(2*PI*X/800)' -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 -lavfi '[0][2][1]displace' OUTPUT

I would suggest some annotation about the example. Also make it easier to
get a working version. Something like:

  ffmpeg -f lavfi -i testsrc=s=hd720 # your input video (here a filter source)
        -f lavfi  -i nullsrc=s=hd720,geq='r=128+50*sin(2*PI*X/800):g=128+50*sin(2*PI*X/800):b=128+50*sin(2*PI*X/800)' # sinusoidal deformation for y-axis
        -f lavfi -i nullsrc=s=hd720,lutrgb=128:128:128 # unchanged deformation source for x-axis
        -lavfi '[0][2][1]displace' OUTPUT

Q1: Can't you avoid the parameter copy for geq?

Q2: What's the benefit of source videos maps over evals?
    Maybe pre-computed maps to make it faster? If so, you should add
    another complete workflow example where you generate maybe two
    pictures pattern.

Q3: Won't it be nice to have a 't' parameter to make it wave between sine
    and original form?

[...]
> diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c
> new file mode 100644
> index 0000000..65ba8d2
> --- /dev/null
> +++ b/libavfilter/vf_displace.c
[...]
> +AVFilter avfilter_vf_displace = {

Don't forget to replace with ff_vf_displace.

Code looks fine to me.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131107/f168ba4d/attachment.asc>


More information about the ffmpeg-devel mailing list