[FFmpeg-devel] Need suggestion for ROTATION

Michel Bardiaux mbardiaux
Thu Nov 22 12:31:12 CET 2007


Tilak Adhya a ?crit :
>   
> Hi All,
> 
> I am new to this list. I am trying to add one feature to the
> ffmpeg code base regarding the rotation. FFmpeg does not have
> any support for frame level rotation. My requirement is to
> rotate(90, 180, 270 degrees ) a movie, before streaming.
> 
> Now, first we thought that, we would create a new AVPicture
> with the new data and linesize fields and rearrange the data[0],
> data[1] and data[2] pointers for the rotated movie. But while 
> doing this, we faced lot of problems regarding the modification
> of data and height and width fields. 
> So we decided to first convert this YUV format to RGB format
> using img_convert() fuction and then rotate the picture in the
> RGB level and then again convert it to the YUV format. But in
> this procedure the main concerns are how to rotate a picture in
> RGB format and how much feasible this approach is. Actually in 
> a 15fps movie the extra operations will be two image conversions
> (YUV -> RGB and RGB -> YUV) and rotation in the RGB plane for each
> frame. 
> 
> Now my question is, which procedure we will take to rotate a movie
> and what is the concept of rotation in the YUV plane for a movie.
> Need your suggestion in this regard...
> 
First of all, dont use "YUV", there are too many different meanings. 
ITIYM yuv420p, the most common format lavc decodes to.

Now, for YUV420P, you rotate the bytes in the Y plane (data[0]) just as 
if they were a sequence of greytone bytes. Then the same for the U and V 
planes, except they are 2x2 times smaller.

For YUV444P, the same except the 3 planes have the same size.

For YUV422P, you have a problem: U and V are averages on the line, and 
after rotation the lines would become columns, and the averages would 
have to be on different pixels. So you will have to go through YUV444P, 
but that is lighter than going through RGB.

Short version: if you can rotate greytone, you can rotate YUVxyzP.

Cheers,
-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list