[FFmpeg-devel] AVFrame data alignment issues

Marton Balint cus at passwd.hu
Sun Jan 16 02:59:44 EET 2022


Hi,

I wonder if there are strict requirements for alignment of AVFrame 
buffers. Yes, it is usually aligned by default, but there are filters, 
like crop or pad which tries to avoid copying data even at the cost of 
breaking the alignment. This unfortunately causes crashes for code which 
requires it, some examples:

- the zscale filter only checks input buffer alignment but not output
   buffer alignment, therefore might crash if a later pad filter provides
   an unaligned get_buffer callback for a filter chain.

- the blend/tblend filter has a similar problem, it's ASM code is using
   aligned movs for output. (not for input however).

- the dnxhd encoder depends on aligment of its input buffers.

How this should be fixed?

- Change pad/crop filters to only do "smart" pad/crop if alignment can be 
guaranteed? Maybe a user option should be added to enable "unsafe" mode?

- Add checks for aligment where it is actually required, e.g. in dnxhd 
encoder or blend/zscale filter?

- Change blend code to use unaligned movs even for output?

Thanks,
Marton


More information about the ffmpeg-devel mailing list