问题描述
我正在),并找到替换 av_image_get_buffer_size
。
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
.
但是我不明白 align
参数含义'linesize对齐'......
But I can't understand align
parameter meaning 'linesize alignment'......
什么是这意味着?
推荐答案
FFmpeg的一些部分,特别是libavcodec,需要对齐的linesizes [],这意味着它需要: p>
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);
这允许它使用快速/对齐的SIMD例程(例如SSE2 / AVX2 movdqa
或 vmovdqa
指令)用于数据访问,而不是较慢的未对齐的对应。
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.
align
参数到这个 av_image_get_buffer_size
函数是这个行对齐,你需要它,因为缓冲区的大小是受它影响。例如,YUV缓冲区中的Y平面的大小实际上不是width * height,它是linesize [0] * height。你会看到(特别是图像尺寸不是16或32的倍数),因为你将 align
增加到2的更高的权力,返回值缓慢增加。
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.
实际上,如果要将此图片用作调用的输出缓冲区,例如 avcodec_decode_video2
,这应该是32.对于swscale / avfilter,我相信没有绝对的要求,但是你建议仍然要32。
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.
这篇关于什么是“线条对齐”的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!