FFMPEG中的lineSize,宽度,高度之间的关系

时间:2018-12-18 21:32:07

标签: c++11 ffmpeg codec libav

我在AVFrame中的linesizeheightwidth之间感到困惑。

根据我的理解,linesize是步幅,理想情况下应该是图像的宽度,对吧?

但是,widthlinesize的值不匹配。

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的回答,行大小应与宽度相同。但我不明白为什么它们在这里有所不同。

1 个答案:

答案 0 :(得分:0)

我在这里引用文档:

 * 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.

所以视频的行大小是

  

宽度*每个像素的字节数+填充行距

从第一行图像/帧数据的开始到下一行的开始。

相关问题