如何从AVFrame.data []和AVFrame.linesize []获取原始帧数据,而不指定像素格式? [英] How to get raw frame data from AVFrame.data[] and AVFrame.linesize[] without specifying the pixel format?
问题描述
我得出一般的想法,根据视频(RGB或YUV)的像素格式来解释 frame.data []
。但是有没有一种通常的方法来获取帧中的所有像素数据?我只想计算帧数据的哈希值,而不用解释它来显示图像。
根据AVFrame.h:
uint8_t * AVFrame :: data [AV_NUM_DATA_POINTERS]
int AVFrame :: linesize [AV_NUM_DATA_POINTERS]
对于视频,每个图片行的字节大小。
意味着如果我从 data [i]
中为 linesize [i]
字节提取,那么我将获得完整的像素信息关于框架?
linesize [i]
包含
要获取整个缓冲区,请使用 avcodec中的函数.h
/ **
*将像素数据从AVPicture复制到缓冲区,总是假设
* linesize对齐1. * /
int avpicture_layout(const AVP icture * src,enum AVPixelFormat pix_fmt,
int width,int height,
unsigned char * dest,int dest_size);
使用
int avpicture_get_size(枚举AVPixelFormat pix_fmt,int width,int height);
计算所需的缓冲区大小。
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?
linesize[i]
contains stride for the i
-th plane.
To obtain the whole buffer, use the function from 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);
Use
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
to calculate the required buffer size.
这篇关于如何从AVFrame.data []和AVFrame.linesize []获取原始帧数据,而不指定像素格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!