[转载] ffmpeg 基本数据结构和对象: AVPacket、AVPicture、AVFrame
一、AVPacket
- /**
- * AVPacket 作为解码器的输入 或 编码器的输出。
- * 当作为解码器的输入时,它由demuxer生成,然后传递给解码器
- * 当作为编码器的输出时,由编码器生成,然后传递给muxer
- * 在视频中,AVPacket 只能包含不大于1帧的内容,而视频的1帧可能要包含在多个AVPacket中,AVPacket < AVFrame
- *
- *
- * AVPacket 是ffmpeg中少数的几个公共ABI,它只能被libavcodec和libformat在栈上分配
- *
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet().
- */
- typedef struct AVPacket {
- /**
- * packet的内存空间来自于一个叫做“引用计数缓冲区”的地方,这个指针就指向一块引用计数缓冲区
- */
- AVBufferRef *buf;
- /**
- * 显示时间戳 单位是 AVStream->time_base units
- */
- int64_t pts;
- /**
- * 解压时间戳,在这个时刻该包需要被解码
- */
- int64_t dts;
- uint8_t *data;
- int size;
- int stream_index;
- /**
- * A combination of AV_PKT_FLAG values
- */
- int flags;
- /**
- * 存放额外的包信息
- */
- struct {
- uint8_t *data;
- int size;
- enum AVPacketSideDataType type;
- } *side_data;
- int side_data_elems;
- /**
- * 这个包的时间长度 in AVStream->time_base units, 设置0 表示未知.
- * duration = next_pts - this_pts i.
- */
- int duration;
- int64_t pos; ///< 在数据流中的字节偏移量, -1 if unknown
- int64_t convergence_duration;
- } AVPacket;
二、AVPicture
- typedef struct AVPicture {
- uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes
- int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
- }
三、AVFrame
- /**
- * AVFrame表示解码过后的一个数据帧
- *
- * AVFrame 通过使用 av_frame_alloc()来创建. 这个函数只是创建了AVFrame结构本身,在结构
- * 中定义的指向其他内存块的缓冲区指针要用其他方法来分配
- * 使用 av_frame_free()来释放AVFrame.
- *
- */
- typedef struct AVFrame {
- #define AV_NUM_DATA_POINTERS 8
- /**
- * pointer to the picture/channel planes.
- */
- uint8_t *data[AV_NUM_DATA_POINTERS];
- /**
- * For video, size in bytes of each picture line.
- * For audio, size in bytes of each plane.
- */
- int linesize[AV_NUM_DATA_POINTERS];
- /**
- * pointers to the data planes/channels.
- */
- uint8_t **extended_data;
- /**
- * width and height of the video frame
- */
- 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
- */
- 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;
- /**
- * PTS copied from the AVPacket that was decoded to produce this frame.
- */
- int64_t pkt_pts;
- /**
- * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isnt 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;
- /**
- * error
- */
- uint64_t error[AV_NUM_DATA_POINTERS];
- /**
- * 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;
- /**
- * Sample rate of the audio data.
- */
- int sample_rate;
- /**
- * Channel layout of the audio data.
- */
- uint64_t channel_layout;
- /**
- * 指向这个帧要用到的AVBuffer中的数据缓冲区.
- *
- * 一般每个图像位面(就时data[0],data[1] data[2])只有一个指向AVBuffer的缓冲区, 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.
- */
- AVBufferRef **extended_buf;
- /**
- * Number of elements in extended_buf.
- */
- int nb_extended_buf;
- AVFrameSideData **side_data;
- int nb_side_data;
- /**
- * 可能因为解码错误,数据帧Frame会成为无效的帧,下面的结构就是当数据帧无效时使用的
- */
- #define AV_FRAME_FLAG_CORRUPT (1 << 0)
- /**
- * Frame flags, a combination of AV_FRAME_FLAG_*
- */
- int flags;
- int64_t best_effort_timestamp;
- int64_t pkt_pos;
- int64_t pkt_duration;
- AVDictionary *metadata;
- int decode_error_flags;
- #define FF_DECODE_ERROR_INVALID_BITSTREAM 1
- #define FF_DECODE_ERROR_MISSING_REFERENCE 2
- int channels;
- int pkt_size;
- enum AVColorSpace colorspace;
- enum AVColorRange color_range;
- /**
- * Not to be accessed directly from outside libavutil
- */
- AVBufferRef *qp_table_buf;
- } AVFrame;
转自:http://blog.csdn.net/chance_yin/article/details/16817957
[转载] ffmpeg 基本数据结构和对象: AVPacket、AVPicture、AVFrame的更多相关文章
- ffmpeg 基本数据结构和对象: AVPacket、AVPicture、AVFrame
一.AVPacket /** * AVPacket 作为解码器的输入 或 编码器的输出. * 当作为解码器的输入时,它由demuxer生成,然后传递给解码器 * 当作为编码器的输出时,由编码器生成,然 ...
- ffmpeg 基本数据结构和对象(一): AVPacket、AVPicture、AVFrame
来源:http://blog.csdn.net/chance_yin/article/details/16817957 一.AVPacket /** * AVPacket 作为解码器的输入 或 编码器 ...
- [转载] ffmpeg摄像头视频采集-采集步骤概述并采集一帧视频
近期由于工作任务,需要开发一个跨平台视频聊天系统,其中就用到了ffmpeg进行采集与编码,网上找了一大堆的资料,虽然都有一些有用的东西,但实在太碎片化了,这几天一直在整理和实验这些资料,边整理,边做一 ...
- [转载] FFmpeg API 变更记录
最近一两年内FFmpeg项目发展的速度很快,本来是一件好事.但是随之而来的问题就是其API(接口函数)一直在发生变动.这么一来基于旧一点版本的FFmpeg的程序的代码在最新的类库上可能就跑不通了. 例 ...
- Redis | 第一部分:数据结构与对象 上篇《Redis设计与实现》
目录 前言 1. 简单动态字符串 1.1 SDS的定义 1.2 空间预分配与惰性空间释放 1.3 SDS的API 2. 链表 2.1 链表与节点的定义 2.2 链表的API 3. 字典 3.1 哈希表 ...
- Redis | 第一部分:数据结构与对象 下篇《Redis设计与实现》
目录 前言 1. Redis对象概述 1.1 对象的定义 2. 字符串对象 3. 列表对象 3.1 quicklist 快速链表 4. 哈希对象 5. 集合对象 6. 有序集合对象 7. Redis对 ...
- Redis | 第一部分:数据结构与对象 中篇《Redis设计与实现》
目录 前言 1. 跳跃表 1.1 跳跃表与其节点的定义 1.2 跳跃表的API 2. 整数集合 2.1 整数集合的实现 2.2 整数集合的类型升级 2.3 整数集合的API 3. 压缩列表 3.1 压 ...
- Redis学习笔记一:数据结构与对象
1. String(SDS) Redis使用自定义的一种字符串结构SDS来作为字符串的表示. 127.0.0.1:6379> set name liushijie OK 在如上操作中,name( ...
- FFMPEG结构体分析:AVPacket
注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...
随机推荐
- oracle 数据泵
Oracle数据库导入导出工具,可以使用exp/imp,但这是比较早期的工具.本文主要介绍数据泵expdp/impdp工具的使用. 1.建立数据泵目录 使用数据泵需要先建directory c ...
- 哆啦A梦里的某一首诗
<哆啦A梦>长篇<宇宙开拓>主题曲<放松心情>作词:武田铁矢 我终于发现, /昨日失去的一切, /虽然还无法完全意会, /可是对我却非常重要. /加紧脚步追赶, / ...
- Django学习笔记之Ajax入门
AJAX准备知识:JSON 什么是 JSON ? JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式 JS ...
- [pixhawk笔记]3-架构概览
本文主要内容翻译自:https://dev.px4.io/en/concept/architecture.html 总体架构: PX4代码由两层组成:PX4飞行栈和PX4中间件.其中,前者是一套飞行控 ...
- NOIP 能量项链
描述 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定等于 ...
- Autofac register and resolve
Passing Parameters to Register When you register components you have the ability to provide a set of ...
- mkfs.ext4 磁盘分区
在linux上格式化一个磁盘分区时,出现如下错误 root@d:~# mkfs.ext4 /dev/sdb1 mke2fs 1.41.12 (11-May-2015) mkfs.ext4: inode ...
- Minimum Window Substring, 包含子串的最小窗口,双指针
问题描述:给定字符串S,子串T,求S中包含T的最小窗口 Given a string S and a string T, find the minimum window in S which will ...
- java可变参数列表的实现
参数就是我们调用一个方法时需要传入得数据,在方法中可能需要参数协助处理数据或者对参数进行解析处理以达到我们希望得到的数据和结果. 平常我们在写一个方法时,我们能确定需要传入什么样的参数以及参数的个数, ...
- tyvj 1056 能量项链 区间dp
P1056 能量项链 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 NOIP2006 提高组 第一道 描述 在Mars星球上,每个Mars人都随身佩 ...