我一直在寻找强制 avcodec 对其 AVFrame 数据使用未对齐内存的选项。
根据像素格式,AVFrame->data 的水平平面可能会填充额外的数据以与内存对齐以提高性能。
例如:每像素 4 字节的 1920 * 1080 视频每个平面将有 1920 * 4 = 7680 字节。
使用 avcodec 如果您正在解码此视频,它将为每个平面创建 7808 个字节。
这增加了 7808 - 7680 = 128 字节的额外填充。
出于我的目的,我想强制 avcodec 使用未对齐的数据,这样我就可以复制整个连续的帧数据块,而不是一次将较小的块复制和格式化为连续块。
在标头中找到以下标志:
/* encoding support
These flags can be passed in AVCodecContext.flags before initialization.
Note: Not everything is supported yet.
*/
/**
* Allow decoders to produce frames with data planes that are not aligned
* to CPU requirements (e.g. due to cropping).
*/
#define CODEC_FLAG_UNALIGNED 0x0001
将此 AVCodecContext.flags 设置为 CODEC_FLAG_UNALIGNED,假设 AVFrame->data 现在未对齐,事实并非如此。
我不确定我是否正在寻找正确的位置或正确使用此标志。
问候,
好奇的乔治