一、ffmpeg中av_image_alloc()是这样定义的。此函数的功能是按照指定的宽、高、像素格式来分析图像内存。
参数说明
pointers[4]:保存图像通道的地址。如果是RGB,则前三个指针分别指向R,G,B的内存地址。第四个指针保留不用
linesizes[4]:保存图像每个通道的内存对齐的步长,即一行的对齐内存的宽度,此值大小等于图像宽度。
w: 要申请内存的图像宽度。
h: 要申请内存的图像高度。
pix_fmt: 要申请内存的图像的像素格式。
align: 用于内存对齐的值。
返回值:所申请的内存空间的总大小。如果是负值,表示申请失败。
/**
* Allocate an image with size w and h and pixel format pix_fmt, and
* fill pointers and linesizes accordingly.
* The allocated image buffer has to be freed by using
* av_freep(&pointers[0]).
*
* @param align the value to use for buffer size alignment
* @return the size in bytes required for the image buffer, a negative
* error code in case of failure
*/
int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
int w, int h, enum AVPixelFormat pix_fmt, int align);
Exanple1:
ret= av_i