我在AVFrame中的linesize
,height
,width
之间感到困惑。
根据我的理解,linesize
是大步,理想情况下应该是图像的宽度,对吗?
但是,width
和linesize
的值不匹配。
AVFrame pFrame;
cout<<"PFrame Linesize :"<<pFrame->data.linesize[0]<<endl;
cout<<"PFrame Width :"<<pFrame->width<<endl;
输出:
PFrame Linesize : 64
PFrame width : 12
我的画面尺寸为12 * 12。
根据这个post的答案,lineize应该与宽度相同。但我无法理解他们为何与众不同。
我在这里引用文档:
* 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.
所以视频的线条化是
width * bytes per pixel + line padding
它会将您从一行图像/帧数据的开头带到下一行的开头。