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 对齐'是什么意思?


基础教程推荐
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01