15

I get the general idea that the frame.data[] is interpreted depending on which pixel format is the video (RGB or YUV). But is there any general way to get all the pixel data from the frame? I just want to compute the hash of the frame data, without interpret it to display the image.

According to AVFrame.h:

uint8_t* AVFrame::data[AV_NUM_DATA_POINTERS]

pointer to the picture/channel planes.

int AVFrame::linesize[AV_NUM_DATA_POINTERS]

For video, size in bytes of each picture line.

Does this mean that if I just extract from data[i] for linesize[i] bytes then I get the full pixel information about the frame?

4

2 回答 2

15

linesize[i]包含i第 -th 平面的步幅。

要获取整个缓冲区,请使用以下函数avcodec.h

/**
 * Copy pixel data from an AVPicture into a buffer, always assume a
 * linesize alignment of 1. */   
int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
                 int width, int height,
                 unsigned char *dest, int dest_size);

利用

int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);

计算所需的缓冲区大小。

于 2013-10-15T12:03:18.257 回答
0

avpicture_*API 已弃用。现在您可以使用av_image_copy_to_buffer() andav_image_get_buffer_size()来获取图像缓冲区。

您还可以av_image_copy_to_buffer()通过使用AVFrame::data[]可以从av_image_fill_plane_sizes(). 仅当您清楚地了解像素格式时才执行此操作。

在这里找到更多:https ://www.ffmpeg.org/doxygen/trunk/group__lavu__picture.html

于 2022-02-05T05:43:42.183 回答