what is #39;linesize alignment#39; meaning?(linesize 对齐是什么意思?)
问题描述
我正在关注 http://dranger.com/ffmpeg/tutorial01.html一>.
我刚刚发现 avpicture_get_size
函数已被弃用.
所以我检查了 ffmpeg 的文档(https://www.ffmpeg.org/doxygen/3.0/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694) 并找到替代品 av_image_get_buffer_size
.
但是我看不懂align
参数的意思是'linesizealignment'......
什么意思?
FFmpeg 的某些部分,尤其是 libavcodec,需要对齐的 linesizes[],这意味着它需要:
assert(linesize[0] % 32 == 0);断言(行大小 [1] % 32 == 0);断言(行大小 [2] % 32 == 0);
这允许它使用快速/对齐的 SIMD 例程(例如 SSE2/AVX2 movdqa
或 vmovdqa
指令)进行数据访问,而不是它们较慢的未对齐对应物.>
这个av_image_get_buffer_size
函数的align
参数就是这个行对齐方式,你需要它,因为缓冲区的大小受它影响.例如,YUV 缓冲区中 Y 平面的大小实际上不是宽度 * 高度,而是 linesize[0] * height.您会看到(特别是对于不是 16 或 32 的倍数的图像大小),当您将 align
增加到 2 的更高次幂时,返回值会缓慢增加.
实际上,如果您打算将此图片用作调用的输出缓冲区,例如avcodec_decode_video2
,这个应该是32.对于swscale/avfilter,我相信没有绝对的要求,但是建议你还是把它变成32.
I'm following ffmpeg tutorial in http://dranger.com/ffmpeg/tutorial01.html.
I have just found that avpicture_get_size
function is deprecated.
So I have checked ffmpeg's document(https://www.ffmpeg.org/doxygen/3.0/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694) and found substitute av_image_get_buffer_size
.
But I can't understand align
parameter meaning 'linesize alignment'......
What is it meaning?
Some parts of FFmpeg, notably libavcodec, require aligned linesizes[], which means that it requires:
assert(linesize[0] % 32 == 0);
assert(linesize[1] % 32 == 0);
assert(linesize[2] % 32 == 0);
This allows it to use fast/aligned SIMD routines (for example SSE2/AVX2 movdqa
or vmovdqa
instructions) for data access instead of their slower unaligned counterparts.
The align
parameter to this av_image_get_buffer_size
function is this line alignment, and you need it because the size of the buffer is affected by it. E.g., the size of a Y plane in a YUV buffer isn't actually width * height, it's linesize[0] * height. You'll see that (especially for image sizes that are not a multiple of 16 or 32), as you increase align
to higher powers of 2, the return value slowly increases.
Practically speaking, if you're going to use this picture as output buffer for calls to e.g. avcodec_decode_video2
, this should be 32. For swscale/avfilter, I believe there is no absolute requirement, but you're recommended to still make it 32.
这篇关于'linesize 对齐'是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:'linesize 对齐'是什么意思?


- 如何对自定义类的向量使用std::find()? 2022-11-07
- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 从python回调到c++的选项 2022-11-16