[FFmpeg-user] A question about video_get_buffer function

Rhodri James rhodri at kynesim.co.uk
Tue Sep 25 14:27:30 CEST 2012


On Mon, 24 Sep 2012 15:02:53 +0100, jih488 <yanglm488 at hotmail.com> wrote:

>     I read  the ffmpeg code and have a question about video_get_buffer
> function.I find there is a statement " w += w & ~(w-1) " ,  and i have
> calculated 176,352 and 640 ,the results  are  192,384 and 768. why does
> ffmpeg   calculate w like this  and what is purpose?

There is (or was) a comment immediately above this line saying "increase  
alignment of w for next try (rhs gives the lowest bit set in w)".   
Unusually for a comment, it's true.  The next four lines of code appear to  
check if the picture lines are appropriately aligned.  If they aren't, the  
whole "do" loop repeats, calling av_image_fill_linesizes() with the new,  
bigger value of w.  Lather, rinse and repeat.  When the picture is aligned  
properly, that calculation with w was unnecessary (and won't be used), but  
it's cheap to do so no one cares.

-- 
Rhodri James
Kynesim Ltd


More information about the ffmpeg-user mailing list