what is 'linesize alignment' meaning?

后端 未结 3 1298
挽巷
挽巷 2021-02-05 07:35

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

3条回答
  •  感情败类
    2021-02-05 08:05

    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.

提交回复
热议问题