一、AVPacket

  1. /**
  2. * AVPacket 作为解码器的输入 或 编码器的输出。
  3. * 当作为解码器的输入时,它由demuxer生成,然后传递给解码器
  4. * 当作为编码器的输出时,由编码器生成,然后传递给muxer
  5. * 在视频中,AVPacket 只能包含不大于1帧的内容,而视频的1帧可能要包含在多个AVPacket中,AVPacket < AVFrame
  6. *
  7. *
  8. * AVPacket 是ffmpeg中少数的几个公共ABI,它只能被libavcodec和libformat在栈上分配
  9. *
  10. * The side data is always allocated with av_malloc() and is freed in
  11. * av_free_packet().
  12. */
  13. typedef struct AVPacket {
  14. /**
  15. * packet的内存空间来自于一个叫做“引用计数缓冲区”的地方,这个指针就指向一块引用计数缓冲区
  16. */
  17. AVBufferRef *buf;
  18. /**
  19. * 显示时间戳 单位是 AVStream->time_base units
  20. */
  21. int64_t pts;
  22. /**
  23. * 解压时间戳,在这个时刻该包需要被解码
  24. */
  25. int64_t dts;
  26. uint8_t *data;
  27. int   size;
  28. int   stream_index;
  29. /**
  30. * A combination of AV_PKT_FLAG values
  31. */
  32. int   flags;
  33. /**
  34. * 存放额外的包信息
  35. */
  36. struct {
  37. uint8_t *data;
  38. int      size;
  39. enum AVPacketSideDataType type;
  40. } *side_data;
  41. int side_data_elems;
  42. /**
  43. * 这个包的时间长度 in AVStream->time_base units, 设置0 表示未知.
  44. * duration = next_pts - this_pts i.
  45. */
  46. int   duration;
  47. int64_t pos;                            ///< 在数据流中的字节偏移量, -1 if unknown
  48. int64_t convergence_duration;
  49. } AVPacket;

二、AVPicture

  1. typedef struct AVPicture {
  2. uint8_t *data[AV_NUM_DATA_POINTERS];    ///< pointers to the image data planes
  3. int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
  4. }

三、AVFrame

  1. /**
  2. * AVFrame表示解码过后的一个数据帧
  3. *
  4. * AVFrame 通过使用 av_frame_alloc()来创建. 这个函数只是创建了AVFrame结构本身,在结构
  5. * 中定义的指向其他内存块的缓冲区指针要用其他方法来分配
  6. * 使用 av_frame_free()来释放AVFrame.
  7. *
  8. */
  9. typedef struct AVFrame {
  10. #define AV_NUM_DATA_POINTERS 8
  11. /**
  12. * pointer to the picture/channel planes.
  13. */
  14. uint8_t *data[AV_NUM_DATA_POINTERS];
  15. /**
  16. * For video, size in bytes of each picture line.
  17. * For audio, size in bytes of each plane.
  18. */
  19. int linesize[AV_NUM_DATA_POINTERS];
  20. /**
  21. * pointers to the data planes/channels.
  22. */
  23. uint8_t **extended_data;
  24. /**
  25. * width and height of the video frame
  26. */
  27. int width, height;
  28. /**
  29. * number of audio samples (per channel) described by this frame
  30. */
  31. int nb_samples;
  32. /**
  33. * format of the frame, -1 if unknown or unset
  34. */
  35. int format;
  36. /**
  37. * 1 -> keyframe, 0-> not
  38. */
  39. int key_frame;
  40. /**
  41. * Picture type of the frame.
  42. */
  43. enum AVPictureType pict_type;
  44. /**
  45. * Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
  46. */
  47. AVRational sample_aspect_ratio;
  48. /**
  49. * Presentation timestamp in time_base units (time when frame should be shown to user).
  50. */
  51. int64_t pts;
  52. /**
  53. * PTS copied from the AVPacket that was decoded to produce this frame.
  54. */
  55. int64_t pkt_pts;
  56. /**
  57. * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isnt used)
  58. * This is also the Presentation time of this AVFrame calculated from
  59. * only AVPacket.dts values without pts values.
  60. */
  61. int64_t pkt_dts;
  62. /**
  63. * picture number in bitstream order
  64. */
  65. int coded_picture_number;
  66. /**
  67. * picture number in display order
  68. */
  69. int display_picture_number;
  70. /**
  71. * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
  72. */
  73. int quality;
  74. /**
  75. * for some private data of the user
  76. */
  77. void *opaque;
  78. /**
  79. * error
  80. */
  81. uint64_t error[AV_NUM_DATA_POINTERS];
  82. /**
  83. * When decoding, this signals how much the picture must be delayed.
  84. * extra_delay = repeat_pict / (2*fps)
  85. */
  86. int repeat_pict;
  87. /**
  88. * The content of the picture is interlaced.
  89. */
  90. int interlaced_frame;
  91. /**
  92. * If the content is interlaced, is top field displayed first.
  93. */
  94. int top_field_first;
  95. /**
  96. * Tell user application that palette has changed from previous frame.
  97. */
  98. int palette_has_changed;
  99. /**
  100. * Sample rate of the audio data.
  101. */
  102. int sample_rate;
  103. /**
  104. * Channel layout of the audio data.
  105. */
  106. uint64_t channel_layout;
  107. /**
  108. * 指向这个帧要用到的AVBuffer中的数据缓冲区.
  109. *
  110. * 一般每个图像位面(就时data[0],data[1] data[2])只有一个指向AVBuffer的缓冲区, so for video this array
  111. * always contains all the references. For planar audio with more than
  112. * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in
  113. * this array. Then the extra AVBufferRef pointers are stored in the
  114. * extended_buf array.
  115. */
  116. AVBufferRef *buf[AV_NUM_DATA_POINTERS];
  117. /**
  118. * For planar audio which requires more than AV_NUM_DATA_POINTERS
  119. * AVBufferRef pointers, this array will hold all the references which
  120. * cannot fit into AVFrame.buf.
  121. */
  122. AVBufferRef **extended_buf;
  123. /**
  124. * Number of elements in extended_buf.
  125. */
  126. int        nb_extended_buf;
  127. AVFrameSideData **side_data;
  128. int            nb_side_data;
  129. /**
  130. * 可能因为解码错误,数据帧Frame会成为无效的帧,下面的结构就是当数据帧无效时使用的
  131. */
  132. #define AV_FRAME_FLAG_CORRUPT       (1 << 0)
  133. /**
  134. * Frame flags, a combination of AV_FRAME_FLAG_*
  135. */
  136. int flags;
  137. int64_t best_effort_timestamp;
  138. int64_t pkt_pos;
  139. int64_t pkt_duration;
  140. AVDictionary *metadata;
  141. int decode_error_flags;
  142. #define FF_DECODE_ERROR_INVALID_BITSTREAM   1
  143. #define FF_DECODE_ERROR_MISSING_REFERENCE   2
  144. int channels;
  145. int pkt_size;
  146. enum AVColorSpace colorspace;
  147. enum AVColorRange color_range;
  148. /**
  149. * Not to be accessed directly from outside libavutil
  150. */
  151. AVBufferRef *qp_table_buf;
  152. } AVFrame;

from:http://blog.csdn.net/chance_yin/article/details/16817957

ffmpeg 基本数据结构和对象: AVPacket、AVPicture、AVFrame的更多相关文章

  1. [转载] ffmpeg 基本数据结构和对象: AVPacket、AVPicture、AVFrame

    一.AVPacket /** * AVPacket 作为解码器的输入 或 编码器的输出. * 当作为解码器的输入时,它由demuxer生成,然后传递给解码器 * 当作为编码器的输出时,由编码器生成,然 ...

  2. ffmpeg 基本数据结构和对象(一): AVPacket、AVPicture、AVFrame

    来源:http://blog.csdn.net/chance_yin/article/details/16817957 一.AVPacket /** * AVPacket 作为解码器的输入 或 编码器 ...

  3. FFMPEG结构体分析:AVPacket

    注:写了一系列的结构体的分析的文章,在这里列一个列表: FFMPEG结构体分析:AVFrame FFMPEG结构体分析:AVFormatContext FFMPEG结构体分析:AVCodecConte ...

  4. Redis学习笔记一:数据结构与对象

    1. String(SDS) Redis使用自定义的一种字符串结构SDS来作为字符串的表示. 127.0.0.1:6379> set name liushijie OK 在如上操作中,name( ...

  5. ES6 set和map数据结构对对象数组去重简单实现

    自从有了es6的set数据结构,数组的去重可以简单用一行代码实现,比如下面的方式 let arr = [1, 2, 2, 3, 4] function unique (arr) { return [. ...

  6. [redis读书笔记] 第一部分 数据结构与对象 对象类型

    - 从前面redis的基本数据结构来看,可以看出,redis都是在基本结构(string)的基础上,封装了一层统计的结构(SDS),这样让对基本结构的访问能够更快更准确,提高可控制度. - redis ...

  7. Redis数据结构和对象三

    1.Redis 对象系统 Redis用到的所有主要数据结构,简单动态字符串(SDS).双端链表.字典.压缩列表.整数集合.跳跃表. Redis并没有直接使用这些数据结构来实现键值对数据库,而是基于这些 ...

  8. Redis | 第一部分:数据结构与对象 上篇《Redis设计与实现》

    目录 前言 1. 简单动态字符串 1.1 SDS的定义 1.2 空间预分配与惰性空间释放 1.3 SDS的API 2. 链表 2.1 链表与节点的定义 2.2 链表的API 3. 字典 3.1 哈希表 ...

  9. Redis | 第一部分:数据结构与对象 下篇《Redis设计与实现》

    目录 前言 1. Redis对象概述 1.1 对象的定义 2. 字符串对象 3. 列表对象 3.1 quicklist 快速链表 4. 哈希对象 5. 集合对象 6. 有序集合对象 7. Redis对 ...

随机推荐

  1. C#使用Docx操作word文档

    C#使用Docx编写word表格 最近接手了一个小Demo,要求使用Docx,将Xml文件中的数据转换为word文档,组织数据形成表格. 写了已经一周,网络上的知识太零碎,就想自己先统计整理出来,方便 ...

  2. C# ASP.NET 验证码

    使用C# ASP.NET 获取 验证码的代码书写 一般都采用异步 点击 前台验证码图片 请求一次 : 前台图片代码: <img id="imgvalidatecode" sr ...

  3. log4cpp之Appender

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  4. 原生js 保存图片到本地

    <template> <div> <!--创建一个cavas 用来存放图片--> <canvas id="cavasimg" width= ...

  5. Familia:百度NLP开源的中文主题模型应用工具包

    参考:Familia的Github项目地址.百度NLP专栏介绍 Familia 开源项目包含文档主题推断工具.语义匹配计算工具以及基于工业级语料训练的三种主题模型:Latent Dirichlet A ...

  6. 实战maven私有仓库三部曲之二:上传到私有仓库

    在上一章<实战maven私有仓库三部曲之一:搭建和使用>我们搭建了maven私有仓库,并体验了私有仓库缓存jar包的能力,避免了局域网内开发人员去远程中央仓库下载的痛苦等待,本章我们再来体 ...

  7. redhat7学习笔记之从零到部署javaweb项目

    REDHAT7学习笔记 1. 安装vmware10 安装过程略,下载地址:链接: https://pan.baidu.com/s/16odKKkRYBxGWDVo1cz_wxA 注意,10以上版本不在 ...

  8. LOJ107. 维护全序集【树状数组维护全序集】

    题目描述 这是一道模板题,其数据比「普通平衡树」更强. 如未特别说明,以下所有数据均为整数. 维护一个多重集 S ,初始为空,有以下几种操作: 把 x 加入 S 删除 S 中的一个 x,保证删除的 x ...

  9. BZOJ2243 SDOI2011 染色 【树链剖分】

    BZOJ2243 SDOI2011 染色 Description 给定一棵有n个节点的无根树和m个操作,操作有2类: 1.将节点a到节点b路径上所有点都染成颜色c: 2.询问节点a到节点b路径上的颜色 ...

  10. 【requirejs】JS模块化工具requirejs教程

    初识requirejs 随着网站功能逐渐丰富,网页中的js也变得越来越复杂和臃肿,原有通过script标签来导入一个个的js文件这种方式已经不能满足现在互联网开发模式,我们需要团队协作.模块复用.单元 ...