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 对齐'是什么意思?
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
