Commit dc5e26d6 authored by Stefano Sabatini's avatar Stefano Sabatini

lavfi: add rotate filter

Based on the libavfilter SOC filter by Vitor Sessak, with the following additions:
* integer arithmetic
* bilinear interpolation
* RGB path
* configurable parametric angle, output width and height

Address trac issue #1500.

See thread:
Subject: [FFmpeg-devel] [WIP] rotate filter(s)
Date: 2010-10-03 17:35:49 GMT
parent 0ec65aa1
...@@ -66,6 +66,7 @@ version <next>: ...@@ -66,6 +66,7 @@ version <next>:
- sab filter ported from libmpcodecs - sab filter ported from libmpcodecs
- ffprobe -show_chapters option - ffprobe -show_chapters option
- WavPack encoding through libwavpack - WavPack encoding through libwavpack
- rotate filter
version 1.2: version 1.2:
......
...@@ -5771,6 +5771,118 @@ much, but it will increase the amount of blurring needed to cover over ...@@ -5771,6 +5771,118 @@ much, but it will increase the amount of blurring needed to cover over
the image and will destroy more information than necessary, and extra the image and will destroy more information than necessary, and extra
pixels will slow things down on a large logo. pixels will slow things down on a large logo.
@section rotate
Rotate video by an arbitrary angle expressed in radians.
The filter accepts the following options:
A description of the optional parameters follows.
@table @option
@item angle, a
Set an expression for the angle by which to rotate the input video
clockwise, expressed as a number of radians. A negative value will
result in a counter-clockwise rotation. By default it is set to "0".
This expression is evaluated for each frame.
@item out_w, ow
Set the output width expression, default value is "iw".
This expression is evaluated just once during configuration.
@item out_h, oh
Set the output height expression, default value is "ih".
This expression is evaluated just once during configuration.
@item bilinear
Enable bilinear interpolation if set to 1, a value of 0 disables
it. Default value is 1.
@item fillcolor, c
Set the color used to fill the output area not covered by the rotated
image. If the special value "none" is selected then no background is
printed (useful for example if the background is never shown). Default
value is "black".
@end table
The expressions for the angle and the output size can contain the
following constants and functions:
@table @option
@item n
sequential number of the input frame, starting from 0. It is always NAN
before the first frame is filtered.
@item t
time in seconds of the input frame, it is set to 0 when the filter is
configured. It is always NAN before the first frame is filtered.
@item hsub
@item vsub
horizontal and vertical chroma subsample values. For example for the
pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
@item in_w, iw
@item in_h, ih
the input video width and heigth
@item out_w, ow
@item out_h, oh
the output width and heigth, that is the size of the padded area as
specified by the @var{width} and @var{height} expressions
@item rotw(a)
@item roth(a)
the minimal width/height required for completely containing the input
video rotated by @var{a} radians.
These are only available when computing the @option{out_w} and
@option{out_h} expressions.
@end table
@subsection Examples
@itemize
@item
Rotate the input by PI/6 radians clockwise:
@example
rotate=PI/6
@end example
@item
Rotate the input by PI/6 radians counter-clockwise:
@example
rotate=-PI/6
@end example
@item
Apply a constant rotation with period T, starting from an angle of PI/3:
@example
rotate=PI/3+2*PI*t/T
@end example
@item
Make the input video rotation oscillating with a period of T
seconds and an amplitude of A radians:
@example
rotate=A*sin(2*PI/T*t)
@end example
@item
Rotate the video, output size is choosen so that the whole rotating
input video is always completely contained in the output:
@example
rotate='2*PI*t:ow=hypot(iw,ih):oh=ow'
@end example
@item
Rotate the video, reduce the output size so that no background is ever
shown:
@example
rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow:c=none
@end example
@end itemize
@section sab @section sab
Apply Shape Adaptive Blur. Apply Shape Adaptive Blur.
......
...@@ -168,6 +168,7 @@ OBJS-$(CONFIG_PERMS_FILTER) += f_perms.o ...@@ -168,6 +168,7 @@ OBJS-$(CONFIG_PERMS_FILTER) += f_perms.o
OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o
OBJS-$(CONFIG_PP_FILTER) += vf_pp.o OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o lswsutils.o lavfutils.o vf_removelogo.o
OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o
OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o OBJS-$(CONFIG_SEPARATEFIELDS_FILTER) += vf_separatefields.o
OBJS-$(CONFIG_SAB_FILTER) += vf_sab.o OBJS-$(CONFIG_SAB_FILTER) += vf_sab.o
OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o
......
...@@ -163,6 +163,7 @@ void avfilter_register_all(void) ...@@ -163,6 +163,7 @@ void avfilter_register_all(void)
REGISTER_FILTER(PIXDESCTEST, pixdesctest, vf); REGISTER_FILTER(PIXDESCTEST, pixdesctest, vf);
REGISTER_FILTER(PP, pp, vf); REGISTER_FILTER(PP, pp, vf);
REGISTER_FILTER(REMOVELOGO, removelogo, vf); REGISTER_FILTER(REMOVELOGO, removelogo, vf);
REGISTER_FILTER(ROTATE, rotate, vf);
REGISTER_FILTER(SAB, sab, vf); REGISTER_FILTER(SAB, sab, vf);
REGISTER_FILTER(SCALE, scale, vf); REGISTER_FILTER(SCALE, scale, vf);
REGISTER_FILTER(SELECT, select, vf); REGISTER_FILTER(SELECT, select, vf);
......
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#include "libavutil/avutil.h" #include "libavutil/avutil.h"
#define LIBAVFILTER_VERSION_MAJOR 3 #define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 75 #define LIBAVFILTER_VERSION_MINOR 76
#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_MICRO 100
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \ LIBAVFILTER_VERSION_MINOR, \
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment