Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is `linesize` in LibAV

I am playing with video encoding using LibAV and unable to understand the purpose of linesize.

For e.g., declaration of av_image_alloc function in LibAV takes linesizes as arguments:

int av_image_alloc  (   uint8_t *   pointers[4],
      int   linesizes[4],
      int   w,
      int   h,
      enum AVPixelFormat    pix_fmt,
      int   align 
   )        

I am new to LibAV and video encoding. Feel free to provide any link which can also give me little background of video encoding.

like image 952
pseudo_teetotaler Avatar asked Oct 13 '25 05:10

pseudo_teetotaler


1 Answers

This function will allocate a buffer large enough to hold image data splitting it into one or more component arrays (planes). Depending on format, size of the line of the each picture component will have its own width (in bytes) (which may be much smaller or much larger than image width) and will also be padded to achieve the specified alignment (16 bytes typically to make vector instructions work). For example with typical YCbCr image with 4:2:0 subsampling there will be 3 planes (that is 3 non-null pointers stored in pointers) and width of the luma plane line will be (padded) image width, width of the each chroma component lines will be (padded) half image width.

Also note that both pointers and linesizes in this function are out pointer parameters, not arrays.

like image 68
user7860670 Avatar answered Oct 14 '25 21:10

user7860670