[FFmpeg-devel] [PATCH] libavfilter image transformations

Michael Niedermayer michaelni
Fri Apr 23 16:47:58 CEST 2010

On Thu, Apr 22, 2010 at 09:58:02AM -0400, Daniel G. Taylor wrote:
> Hey,
> Fixed everything mentioned by Bobby (it is indeed significantly faster to 
> not do the floor/ceil all those times and I added interpolation of edge 
> pixels as suggested), replying to rest here inline.
> On 04/20/2010 10:26 PM, Alexander Strange wrote:
>> On Apr 20, 2010, at 5:03 PM, Daniel G. Taylor wrote:
>>> Hey,
>>> Attached is a patch to add matrix transformation utility methods to 
>>> libavfilter. These are useful for translation, rotation, scaling, etc of 
>>> input pictures and can be easily used from any filter.
>>> This code was originally part of my work on the deshake/stabilize filter 
>>> and the work of Georg Martius from his transcode transform filter.
>>> Example usage:
>>> #include "transform.h"
>>> ...
>>> double matrix[9];
>>> avfilter_get_matrix(shift_x, shift_y, radians, scale, (double *)&matrix);
>>> avfilter_transform(src, dst, src_stride, dst_stride, width, 
>>> ...
>>> The code supports creating simple matrices from translation, rotation, 
>>> and scaling parameters, adding/subtracting matrices, multiplying a matrix 
>>> by a scalar, and doing the actual picture transform. It supports several 
>>> types of interpolation and edge fill methods.
>>> This is useful for any filter that might want to transform video frames 
>>> in any way in the future. I have at least one filter that will use this 
>>> but is waiting on motion estimation stuff (deshake/stabilize video).
>> First, are these transforms separable? I'm not familiar with affine 
>> rotations to know how to split them into 1D.

i think they can be implemented through several 1D operations if you
allow sheer operations (that is apply different translation to each line)

> I don't know to be honest.
>> Second, can they be done in fixed-point?
> I believe so, and given some extra time I will try to port it to be e.g. 
> 16.16 fixed point arithmetic.
>> Third, can it be merged with swscale? Though that looks hard, filters 
>> should be using it for scaling and transformation if possible.
> I'm not at all familiar with swscale and the code looks a bit daunting. I'd 
> rather keep it simple and in libavfilter if possible unless someone is 
> willing to step up and make it all work with swscale!

i agree, about keeping this seperate from swscale currently

also i should probably point out the existence of 

which do somewhat related things

in that sense allowing libmpcodec filters from mplayer to be used
directly in libavfilter would be great ...

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100423/ce938ec2/attachment.pgp>

More information about the ffmpeg-devel mailing list