<P>
<BR>
Hi All,<BR>
<BR>
I am new to this mailing list. My problem is to rotate a frame by 90, 180 and 270 degrees by adding/changing in FFMPEG code. For 180 degree rotation, I got the vf_vflip.c file under the libavfilter folder, which does the flipping, that means 180 degree rotation. But for 90 and 270 degree rotation we need to add in the ffmpeg code base.<BR>
For this purpose, I thought that vf_vflip.c would be the starting point to proceed. And I got that, the fliping part is done inside the start_frame() function of the vf_Vflip.c (am I wrong...?).<BR>
<BR>
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)<BR>
{<BR>
FlipContext *flip = link->dst->priv;<BR>
AVFilterPicRef *ref2 = avfilter_ref_pic(picref, ~0);<BR>
int i;<BR>
<BR>
ref2->data[0] += (ref2->h-1) * ref2->linesize[0];<BR>
ref2->linesize[0] = -ref2->linesize[0];<BR>
for(i = 1; i < 4; i ++) {<BR>
if(ref2->data[i]) {<BR>
ref2->data[i] += ((ref2->h >> flip->vsub)-1) * ref2->linesize[i];<BR>
ref2->linesize[i] = -ref2->linesize[i];<BR>
}<BR>
}<BR>
<BR>
avfilter_start_frame(link->dst->outputs[0], ref2);<BR>
}<BR>
<BR>
In the above code width becomes the negative of of the existing width, but what's the use of the two lines below ...<BR>
<BR>
if(ref2->data[i]) {<BR>
ref2->data[i] += ((ref2->h >> flip->vsub)-1) * ref2->linesize[i];<BR>
ref2->linesize[i] = -ref2->linesize[i];<BR>
}<BR>
<BR>
This algorithm is not clear to me.<BR>
<BR>
So my understanding for implementing rotation, is to add code in the start_frame() function. I need to rotate the frame in Y,U and V plane separately. But I saw that linesize[1] and linesize[2] does not represent the width of the frame exactly and I am confused about the exact rotation algorithm. For rotation in the Y plane, according to my understanding the rotation algorithm will be as follows ---<BR>
<BR>
void rotatePicture(AVFrame *fPicture, int w, int h, AVCodecContext *enc){<BR>
int i = 0, index, ai = 0, wi, hi ;<BR>
uint8_t *arr = av_malloc(w*h * sizeof(uint8_t));<BR>
uint8_t *arr1 = NULL;<BR>
uint8_t *arr2 = NULL;<BR>
memset(arr, 0, w*h*sizeof(uint8_t));<BR>
<BR>
// this is ONLY for the Y component<BR>
for(wi = 0; wi <= w-1; wi++){<BR>
for(hi = h - 1; hi >= 0; hi--){<BR>
//arr[ai++] = fPicture->data[0][hi*w + wi];<BR>
arr[ai++] = 0;<BR>
}<BR>
}<BR>
<BR>
What do you think - is it correct... ? And then what will be for U and V plane...? <BR>
<BR>
Please suggest...<BR>
<BR>
Thanks in Advance...<BR>
<BR>
Thanks and Regards<BR>
Tilak<BR>
<BR>
<BR>
</P>
*--
<br>
tilak<br><br>
<Table border=0 Width=644 Height=57 cellspacing=0 cellpadding=0 style='font-family:Verdana;font-size:11px;line-height:15px;'><TR><td><a href='http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/1050715198@Middle5/1960866_1953803/1960349/1?PARTNER=3&OAS_QUERY=null target=new '><img src =http://imadworks.rediff.com/cgi-bin/AdWorks/adimage.cgi/1960866_1953803/creative_1960349.gif alt='Reliance Mobile' border=0></a></td></TR></Table>