AVPacket结构体内几个变量分析

uint8_t *data[AV_NUM_DATA_POINTERS]:指针数组,存放YUV数据的地方。如图所示,一般占用前3个指针,分别指向Y,U,V数据。
对于packed格式的数据(例如RGB24),会存到data[0]里面。
对于planar格式的数据(例如YUV420P),则会分开成data[0],data[1],data[2]…(YUV420P中data[0]存Y,data[1]存U,data[2]存V)
int linesize[AV_NUM_DATA_POINTERS]:图像各个分量数据在此结构体中的的宽度。注意这并不是图像的宽度。在此例子中图像的尺寸为672X272,而亮度分量的宽度为704,应该是图像宽度经过64对齐后的结果。
uint8_t **extended_data:指向了图像数据。
int width, height:图像的宽高。
int nb_samples:此帧音频的点数。
int format:像素类型(视频),样点类型(音频)
int key_frame:是否关键帧,此例中为视频的第一帧,当然是关键帧了。
enum AVPictureType pict_type:图像类型,I,P,B等,同样,第一帧是I帧。

补充: 以下宏直接写在代码里就好如, frame->pict_type = AV_PICTURE_TYPE_I;
enum AVPictureType {
AV_PICTURE_TYPE_NONE = 0, ///< Undefined
AV_PICTURE_TYPE_I, ///< Intra
AV_PICTURE_TYPE_P, ///< Predicted
AV_PICTURE_TYPE_B, ///< Bi-dir predicted
AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG-4
AV_PICTURE_TYPE_SI, ///< Switching Intra
AV_PICTURE_TYPE_SP, ///< Switching Predicted
AV_PICTURE_TYPE_BI, ///< BI type };

AVRational sample_aspect_ratio:像素的宽高比,注意不是图像的。
int64_t pts,pkt_pts,pkt_dts:和时间戳有关的变量,以后会详细介绍。
int coded_picture_number:编码顺序的图像num。
int display_picture_number:播放顺序的图像num。
int interlaced_frame:图像是否是隔行的。
int top_field_first:图像的top field first变量。
int64_t pkt_duration:对应packet的显示时长。
int pkt_size:对应packet的尺寸。
int8_t *qscale_table:据推测是存放qp(量化参数)的数组
AVBufferRef *qp_table_buf:成员data指向qscale_table。

以下可参考:
typedef struct AVMediaPacket
{
BYTE* m_data[TL_NUM_DATA_POINTERS];
int m_linesize[TL_NUM_DATA_POINTERS];
BYTE* m_pBuf;
int m_buf_size;
int m_max_size;
int m_cur_size;//ES包使用
int m_packet_type;//0ES包 1Frame
//enum AVPixelFormat for video frames
//enum AVSampleFormat for audio
int m_pixel_format;
int m_channel_count;
LONGLONG m_channel_layout;
int m_nb_samples; // 单个声道音频样本个数
int m_sample_rate; // 音频采样率
int m_width;
int m_height;
/**
* The content of the picture is interlaced.
* - encoding: Set by user.
* - decoding: Set by libavcodec. (default 0)
/
int m_interlaced_frame;//0逐行帧,1隔行帧
/
*
* If the content is interlaced, is top field displayed first.
* - encoding: Set by user.
* - decoding: Set by libavcodec.
*/
int m_top_field_first;//0偶底场优先,1上奇场优先
int m_pict_type;
int m_es_stream_type;//是视频帧还是音频帧
LONGLONG m_pos;
LONGLONG m_origin_size;//原始ES包的字节数
LONGLONG m_dts;//ES包使用
LONGLONG m_pts;
LONGLONG m_origin_ts;
LONGLONG m_sys_pts;//转换成系统时间的pts(毫秒)
LONGLONG m_duration;//帧时长
LONGLONG m_sys_duration;//转换成系统时间的长度(毫秒)
int m_align;//数据的对齐方式
int m_scale_mod;//视频帧用到的变换方式(该帧是经过该变换方式得来的)
int m_stream_index;//同AVPacket的stream_index
int m_flags;//同AVPacket的flags
}AVMediaPacket;

//源码:

typedef struct AVFrame {#define AV_NUM_DATA_POINTERS 8/*** pointer to the picture/channel planes.* This might be different from the first allocated byte** Some decoders access areas outside 0,0 - width,height, please* see avcodec_align_dimensions2(). Some filters and swscale can read* up to 16 bytes beyond the planes, if these filters are to be used,* then 16 extra bytes must be allocated.** NOTE: Except for hwaccel formats, pointers not needed by the format* MUST be set to NULL.*/uint8_t *data[AV_NUM_DATA_POINTERS];/*** For video, size in bytes of each picture line.* For audio, size in bytes of each plane.** For audio, only linesize[0] may be set. For planar audio, each channel* plane must be the same size.** For video the linesizes should be multiples of the CPUs alignment* preference, this is 16 or 32 for modern desktop CPUs.* Some code requires such alignment other code can be slower without* correct alignment, for yet other it makes no difference.** @note The linesize may be larger than the size of usable data -- there* may be extra padding present for performance reasons.*/int linesize[AV_NUM_DATA_POINTERS];/*** pointers to the data planes/channels.** For video, this should simply point to data[].** For planar audio, each channel has a separate data pointer, and* linesize[0] contains the size of each channel buffer.* For packed audio, there is just one data pointer, and linesize[0]* contains the total size of the buffer for all channels.** Note: Both data and extended_data should always be set in a valid frame,* but for planar audio with more channels that can fit in data,* extended_data must be used in order to access all channels.*/uint8_t **extended_data;/*** @name Video dimensions* Video frames only. The coded dimensions (in pixels) of the video frame,* i.e. the size of the rectangle that contains some well-defined values.** @note The part of the frame intended for display/presentation is further* restricted by the @ref cropping "Cropping rectangle".* @{*/int width, height;/*** @}*//*** number of audio samples (per channel) described by this frame*/int nb_samples;/*** format of the frame, -1 if unknown or unset* Values correspond to enum AVPixelFormat for video frames,* enum AVSampleFormat for audio)*/int format;/*** 1 -> keyframe, 0-> not*/int key_frame;/*** Picture type of the frame.*/enum AVPictureType pict_type;/*** Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.*/AVRational sample_aspect_ratio;/*** Presentation timestamp in time_base units (time when frame should be shown to user).*/int64_t pts;#if FF_API_PKT_PTS/*** PTS copied from the AVPacket that was decoded to produce this frame.* @deprecated use the pts field instead*/attribute_deprecatedint64_t pkt_pts;
#endif/*** DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used)* This is also the Presentation time of this AVFrame calculated from* only AVPacket.dts values without pts values.*/int64_t pkt_dts;/*** picture number in bitstream order*/int coded_picture_number;/*** picture number in display order*/int display_picture_number;/*** quality (between 1 (good) and FF_LAMBDA_MAX (bad))*/int quality;/*** for some private data of the user*/void *opaque;#if FF_API_ERROR_FRAME/*** @deprecated unused*/attribute_deprecateduint64_t error[AV_NUM_DATA_POINTERS];
#endif/*** When decoding, this signals how much the picture must be delayed.* extra_delay = repeat_pict / (2*fps)*/int repeat_pict;/*** The content of the picture is interlaced.*/int interlaced_frame;/*** If the content is interlaced, is top field displayed first.*/int top_field_first;/*** Tell user application that palette has changed from previous frame.*/int palette_has_changed;/*** reordered opaque 64 bits (generally an integer or a double precision float* PTS but can be anything).* The user sets AVCodecContext.reordered_opaque to represent the input at* that time,* the decoder reorders values as needed and sets AVFrame.reordered_opaque* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque*/int64_t reordered_opaque;/*** Sample rate of the audio data.*/int sample_rate;/*** Channel layout of the audio data.*/uint64_t channel_layout;/*** AVBuffer references backing the data for this frame. If all elements of* this array are NULL, then this frame is not reference counted. This array* must be filled contiguously -- if buf[i] is non-NULL then buf[j] must* also be non-NULL for all j < i.** There may be at most one AVBuffer per data plane, so for video this array* always contains all the references. For planar audio with more than* AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in* this array. Then the extra AVBufferRef pointers are stored in the* extended_buf array.*/AVBufferRef *buf[AV_NUM_DATA_POINTERS];/*** For planar audio which requires more than AV_NUM_DATA_POINTERS* AVBufferRef pointers, this array will hold all the references which* cannot fit into AVFrame.buf.** Note that this is different from AVFrame.extended_data, which always* contains all the pointers. This array only contains the extra pointers,* which cannot fit into AVFrame.buf.** This array is always allocated using av_malloc() by whoever constructs* the frame. It is freed in av_frame_unref().*/AVBufferRef **extended_buf;/*** Number of elements in extended_buf.*/int        nb_extended_buf;AVFrameSideData **side_data;int            nb_side_data;/*** @defgroup lavu_frame_flags AV_FRAME_FLAGS* @ingroup lavu_frame* Flags describing additional frame properties.** @{*//*** The frame data may be corrupted, e.g. due to decoding errors.*/
#define AV_FRAME_FLAG_CORRUPT       (1 << 0)
/*** A flag to mark the frames which need to be decoded, but shouldn't be output.*/
#define AV_FRAME_FLAG_DISCARD   (1 << 2)
/*** @}*//*** Frame flags, a combination of @ref lavu_frame_flags*/int flags;/*** MPEG vs JPEG YUV range.* - encoding: Set by user* - decoding: Set by libavcodec*/enum AVColorRange color_range;enum AVColorPrimaries color_primaries;enum AVColorTransferCharacteristic color_trc;/*** YUV colorspace type.* - encoding: Set by user* - decoding: Set by libavcodec*/enum AVColorSpace colorspace;enum AVChromaLocation chroma_location;/*** frame timestamp estimated using various heuristics, in stream time base* - encoding: unused* - decoding: set by libavcodec, read by user.*/int64_t best_effort_timestamp;/*** reordered pos from the last AVPacket that has been input into the decoder* - encoding: unused* - decoding: Read by user.*/int64_t pkt_pos;/*** duration of the corresponding packet, expressed in* AVStream->time_base units, 0 if unknown.* - encoding: unused* - decoding: Read by user.*/int64_t pkt_duration;/*** metadata.* - encoding: Set by user.* - decoding: Set by libavcodec.*/AVDictionary *metadata;/*** decode error flags of the frame, set to a combination of* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there* were errors during the decoding.* - encoding: unused* - decoding: set by libavcodec, read by user.*/int decode_error_flags;
#define FF_DECODE_ERROR_INVALID_BITSTREAM   1
#define FF_DECODE_ERROR_MISSING_REFERENCE   2
#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE  4
#define FF_DECODE_ERROR_DECODE_SLICES       8/*** number of audio channels, only used for audio.* - encoding: unused* - decoding: Read by user.*/int channels;/*** size of the corresponding packet containing the compressed* frame.* It is set to a negative value if unknown.* - encoding: unused* - decoding: set by libavcodec, read by user.*/int pkt_size;#if FF_API_FRAME_QP/*** QP table*/attribute_deprecatedint8_t *qscale_table;/*** QP store stride*/attribute_deprecatedint qstride;attribute_deprecatedint qscale_type;attribute_deprecatedAVBufferRef *qp_table_buf;
#endif/*** For hwaccel-format frames, this should be a reference to the* AVHWFramesContext describing the frame.*/AVBufferRef *hw_frames_ctx;/*** AVBufferRef for free use by the API user. FFmpeg will never check the* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when* the frame is unreferenced. av_frame_copy_props() calls create a new* reference with av_buffer_ref() for the target frame's opaque_ref field.** This is unrelated to the opaque field, although it serves a similar* purpose.*/AVBufferRef *opaque_ref;/*** @anchor cropping* @name Cropping* Video frames only. The number of pixels to discard from the the* top/bottom/left/right border of the frame to obtain the sub-rectangle of* the frame intended for presentation.* @{*/size_t crop_top;size_t crop_bottom;size_t crop_left;size_t crop_right;/*** @}*//*** AVBufferRef for internal use by a single libav* library.* Must not be used to transfer data between libraries.* Has to be NULL when ownership of the frame leaves the respective library.** Code outside the FFmpeg libs should never check or change the contents of the buffer ref.** FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.* av_frame_copy_props() calls create a new reference with av_buffer_ref()* for the target frame's private_ref field.*/AVBufferRef *private_ref;
} AVFrame;

AVFrame结构体中变量解释相关推荐

  1. 获取结构体中变量的偏移量

    C/C++获取结构体中变量的偏移量 1.某些特殊需求下,我们需要知道某个变量在其结构体中的偏移位置. 通常的做法就是定义一个宏变量,如下: #define OFFSET(structure, memb ...

  2. c语言给结构体指针申请空间,结构体中的指针变量申请空间问题

    本人声明了一个结构体包含id,age,name三个属性 struct studentInfo { int id; int age; char *name[20]; }; 本人又创建了一个双向循环链表, ...

  3. 【C语言】宏offsetof的模拟实现 (计算结构体中某变量相对于首地址的偏移)

    首先我们应该特别留意 : offsetof 是一个宏,并非是一个函数 ! 宏offsetof的介绍 : 参数:第一个是结构体类型名称,第二个是结构体成员名 返回类型:size_t无符号整形 引用的头文 ...

  4. MDK keil中在定义一个结构体的时候加点后面不出现结构体当中变量的提示

    MDK keil中在定义一个结构体的时候加点后面不出现结构体当中变量的提示 解决办法: 1.确保已经将顶层头文件stm32f10x.h添加至当前你所写的文件内: 2.检查你自己写的文件是否已经加载到工 ...

  5. C++57个入门知识点_17 类的访问权限及C语言模拟类的封装(类的私有权限突破方法:编译期进行权限检查,运行期通过指针修改类的私有成员变量;利用函数指针对结构体中成员变量进行修改;CPU大小尾排列)

    接上篇:C++57个入门知识点_16 类的标准写法(类名.成员变量.成员函数及对象命名规则:成员变量一般为私有,成员函数为公有并暴露给外部使用成员变量:防止类过大,声明写在.h,实现写在.cpp,调用 ...

  6. C语言中结构体成员变量前的点的作用

    /*  * 结构体中成员变量前的点: 结构体成员指定初始化  * 1.该结构体要先定义   * 2.一个成员变量赋值完后用逗号而不是分号   * 3.初始化语句的元素以固定的顺序出现,和被初始化的数组 ...

  7. c语言结构体成员变量私有化,C语言中结构体变量私有化详解

    C语言中结构体变量私有化详解 背景介绍 操作系统 : CentOS7.3.1611_x64 gcc版本 :4.8.5 什么是结构体? 在C语言中,结构体(struct)指的是一种数据结构,是C语言中聚 ...

  8. C语言中利用宏,实现一个整数的奇数位和偶数位交换,以及计算结构体中某变量相对于首地址的偏移

    C语言中的自定义宏 自定义宏,令其实现所需功能 1.写一个宏,可以将一个整数字的奇数位和偶数位交换. 2.写一个宏,计算结构体中某变量相对于首地址的偏移. 具体思路1: 首先取出当前数的奇数部分和偶数 ...

  9. file结构体中private_data指针的疑惑

    转:http://www.360doc.com/content/12/0506/19/1299815_209093142.shtml hi all and barry, 最近在学习字符设备驱动,不太明 ...

最新文章

  1. RocketMQ:Consumer概述及启动流程与消息拉取源码分析
  2. 题解西电OJ (Problem 1008 - 数星星)
  3. android camera 降低帧率_深入理解Camera 硬件抽象层
  4. 网页脚本基本java语法_JSP学习(一)JSP基础语法
  5. 21天学通c语言中用的编译器,21天学通C语言
  6. 学习《自己动手写网络爬虫》之记录1
  7. Android MeasureSpec理解
  8. AcWing 2005. 马蹄铁(DFS)
  9. 小白教程系列——C盘满了,将C盘扩容
  10. 微信JSAPI之V3版本支付踩坑
  11. 转:原来可以这样出书、写书?
  12. 多卡聚合路由器和普通路由器的区别
  13. VS2017 和 Matlab R2016b 混合编程配置问题解决!
  14. 数学建模——红酒品质分类
  15. 实体企业践行远程办公,云ERP是您变革利器
  16. easy_x是实现钟表
  17. 【论文阅读#1】Edge Computing: Vision and Challenges
  18. android 商品筛选view,FilterTabView 基于 Popupwindow 实现的筛选房源信息等相关的控件,可以自由排序 @codeKK Android开源站...
  19. typescript77-在CRA创建支持ts的项目
  20. cct计算机一级百度云,CCT计算机等级考试一级(也就是计算机一级考试)

热门文章

  1. UBUNTU 18.04 GPU + miniconda3 + pytorch + yolo v5 安装测试
  2. 车载以太网协议:SOME/IP (layer5-7)简介
  3. 什么是抖音SEO? 抖音SEO优化怎么做?如果做好抖音推广优化呢?
  4. 安卓app开发工具_四川智慧社区安卓手机app开发多少钱
  5. 数组与数字之间的转换
  6. 彻底删除oracle数据,彻底删除Oracle数据库的方法
  7. php反序列化--字符串逃逸
  8. springfox-swagger-ui 3.0.0 配置,springfox-boot-starter 配置
  9. Python Crypto.Cipher加密包
  10. 一款由c++开发的计时器