Reputation: 1575
I am confused between linesize
, height
, width
in AVFrame.
As per my understanding, linesize
is the strides, which ideally should be the width of the image, right ?
However, the value of width
and linesize
are not matching.
AVFrame pFrame;
cout<<"PFrame Linesize :"<<pFrame->data.linesize[0]<<endl;
cout<<"PFrame Width :"<<pFrame->width<<endl;
Output :
PFrame Linesize : 64
PFrame width : 12
My frame is of dimension 12*12.
According to answers to this post, linesize should be same as width. But I am unable to understand why they are different here.
Upvotes: 4
Views: 1720
Reputation: 1068
EDIT: Why the downvotes? If this is wrong, please correct me.
I'm citing the docs here:
* For video, size in bytes of each picture line.
* For audio, size in bytes of each plane.
*
* For audio, only linesize[0] may be set. For planar audio, each channel
* plane must be the same size.
*
* For video the linesizes should be multiples of the CPUs alignment
* preference, this is 16 or 32 for modern desktop CPUs.
* Some code requires such alignment other code can be slower without
* correct alignment, for yet other it makes no difference.
*
* @note The linesize may be larger than the size of usable data -- there
* may be extra padding present for performance reasons.
So linesize for video is
width * bytes per pixel + line padding
It takes you from the start of one row of image / frame data to the start of the next row.
Upvotes: 0