首页 > 其他分享 >FFmpeg结构体:AVIOContext

FFmpeg结构体:AVIOContext

时间:2024-06-11 14:46:50浏览次数:16  
标签:AVIOContext FFmpeg int seek buffer read size buf 结构

1.描述

AVIOContext是FFmpeg管理输入输出数据的结构体,位于avio.h文件中。

2.结构体定义

  1 typedef struct AVIOContext {
  2     /**
  3      * A class for private options.
  4      *
  5      * If this AVIOContext is created by avio_open2(), av_class is set and
  6      * passes the options down to protocols.
  7      *
  8      * If this AVIOContext is manually allocated, then av_class may be set by
  9      * the caller.
 10      *
 11      * warning -- this field can be NULL, be sure to not pass this AVIOContext
 12      * to any av_opt_* functions in that case.
 13      */
 14     const AVClass *av_class;
 15 
 16     /*
 17      * The following shows the relationship between buffer, buf_ptr, buf_end, buf_size,
 18      * and pos, when reading and when writing (since AVIOContext is used for both):
 19      *
 20      **********************************************************************************
 21      *                                   READING
 22      **********************************************************************************
 23      *
 24      *                            |              buffer_size              |
 25      *                            |---------------------------------------|
 26      *                            |                                       |
 27      *
 28      *                         buffer          buf_ptr       buf_end
 29      *                            +---------------+-----------------------+
 30      *                            |/ / / / / / / /|/ / / / / / /|         |
 31      *  read buffer:              |/ / consumed / | to be read /|         |
 32      *                            |/ / / / / / / /|/ / / / / / /|         |
 33      *                            +---------------+-----------------------+
 34      *
 35      *                                                         pos
 36      *              +-------------------------------------------+-----------------+
 37      *  input file: |                                           |                 |
 38      *              +-------------------------------------------+-----------------+
 39      *
 40      *
 41      **********************************************************************************
 42      *                                   WRITING
 43      **********************************************************************************
 44      *
 45      *                                          |          buffer_size          |
 46      *                                          |-------------------------------|
 47      *                                          |                               |
 48      *
 49      *                                       buffer              buf_ptr     buf_end
 50      *                                          +-------------------+-----------+
 51      *                                          |/ / / / / / / / / /|           |
 52      *  write buffer:                           | / to be flushed / |           |
 53      *                                          |/ / / / / / / / / /|           |
 54      *                                          +-------------------+-----------+
 55      *
 56      *                                         pos
 57      *               +--------------------------+-----------------------------------+
 58      *  output file: |                          |                                   |
 59      *               +--------------------------+-----------------------------------+
 60      *
 61      */
 62     unsigned char *buffer;  /**< Start of the buffer. */
 63     int buffer_size;        /**< Maximum buffer size */
 64     unsigned char *buf_ptr; /**< Current position in the buffer */
 65     unsigned char *buf_end; /**< End of the data, may be less than
 66                                  buffer+buffer_size if the read function returned
 67                                  less data than requested, e.g. for streams where
 68                                  no more data has been received yet. */
 69     void *opaque;           /**< A private pointer, passed to the read/write/seek/...
 70                                  functions. */
 71     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
 72     int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
 73     int64_t (*seek)(void *opaque, int64_t offset, int whence);
 74     int64_t pos;            /**< position in the file of the current buffer */
 75     int must_flush;         /**< true if the next seek should flush */
 76     int eof_reached;        /**< true if eof reached */
 77     int write_flag;         /**< true if open for writing */
 78     int max_packet_size;
 79     unsigned long checksum;
 80     unsigned char *checksum_ptr;
 81     unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
 82     int error;              /**< contains the error code or 0 if no error happened */
 83     /**
 84      * Pause or resume playback for network streaming protocols - e.g. MMS.
 85      */
 86     int (*read_pause)(void *opaque, int pause);
 87     /**
 88      * Seek to a given timestamp in stream with the specified stream_index.
 89      * Needed for some network streaming protocols which don't support seeking
 90      * to byte position.
 91      */
 92     int64_t (*read_seek)(void *opaque, int stream_index,
 93                          int64_t timestamp, int flags);
 94     /**
 95      * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
 96      */
 97     int seekable;
 98 
 99     /**
100      * max filesize, used to limit allocations
101      * This field is internal to libavformat and access from outside is not allowed.
102      */
103     int64_t maxsize;
104 
105     /**
106      * avio_read and avio_write should if possible be satisfied directly
107      * instead of going through a buffer, and avio_seek will always
108      * call the underlying seek function directly.
109      */
110     int direct;
111 
112     /**
113      * Bytes read statistic
114      * This field is internal to libavformat and access from outside is not allowed.
115      */
116     int64_t bytes_read;
117 
118     /**
119      * seek statistic
120      * This field is internal to libavformat and access from outside is not allowed.
121      */
122     int seek_count;
123 
124     /**
125      * writeout statistic
126      * This field is internal to libavformat and access from outside is not allowed.
127      */
128     int writeout_count;
129 
130     /**
131      * Original buffer size
132      * used internally after probing and ensure seekback to reset the buffer size
133      * This field is internal to libavformat and access from outside is not allowed.
134      */
135     int orig_buffer_size;
136 
137     /**
138      * Threshold to favor readahead over seek.
139      * This is current internal only, do not use from outside.
140      */
141     int short_seek_threshold;
142 
143     /**
144      * ',' separated list of allowed protocols.
145      */
146     const char *protocol_whitelist;
147 
148     /**
149      * ',' separated list of disallowed protocols.
150      */
151     const char *protocol_blacklist;
152 
153     /**
154      * A callback that is used instead of write_packet.
155      */
156     int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size,
157                            enum AVIODataMarkerType type, int64_t time);
158     /**
159      * If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT,
160      * but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly
161      * small chunks of data returned from the callback).
162      */
163     int ignore_boundary_point;
164 
165     /**
166      * Internal, not meant to be used from outside of AVIOContext.
167      */
168     enum AVIODataMarkerType current_type;
169     int64_t last_time;
170 } AVIOContext;

3.常见变量及其作用

 1 unsigned char *buffer; //缓存开始位置。
 2 int buffer_size; //缓冲区的大小。
 3 unsigned char *buf_ptr;//当前指针在缓冲区中的位置,即当前指针读取到的位置。
 4 unsigned char *buf_end; //缓存结束的位置
 5 
 6 void *opaque;//一个私有指针,传递给read / write / seek / ...函数。
 7 opaque指向了URLContext。URLContext结构体中还有一个结构体URLProtocol。
 8 ps:每种协议(rtp,rtmp,file等)对应一个URLProtocol。
 9 
10 int64_t pos; //当前缓冲区在文件中的位置。
11 int must_flush;  //如果下一次seek需要刷新则为真。
12 int eof_reached;  //是否读到eof,文件结尾。
13 int (*read_pause)(void *opaque, int pause);//暂停或恢复播放网络流媒体协议 - 例如 MMS。
14 int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags);
15 //使用指定的stream_index查找流中给定的时间戳(对于不支持寻找字节位置的网络流协议)。

 

标签:AVIOContext,FFmpeg,int,seek,buffer,read,size,buf,结构
From: https://www.cnblogs.com/lizishaoye/p/18242003

相关文章

  • 数据结构---排序算法
    个人介绍hellohello~,这里是code袁~......
  • 开源高性能结构化日志模块NanoLog
      最近在写数据库程序,需要一个高性能的结构化日志记录组件,简单研究了一下Microsoft.Extensions.Logging和Serilog,还是决定重造一个轮子。一、使用方法  直接参考以下示例代码:NanoLogger.Start();DateTime?nullable=null;constboolboolValue=true;constcharch......
  • 【算法与数据结构】【数组篇】【题1-题5】
    1.数组基本知识点1.1概念数组就是一个集合。数组会用一些名为索引的数字来标识每项数据在数组中的位置,且在大多数编程语言中,索引是从0算起的。我们可以根据数组中的索引,快速访问数组中的元素。数组中的元素在内存中是连续存储的,且每个元素占用相同大小的内存。1.2相关操......
  • YOLOv10涨点改进:SPPF原创自研创新 | SPPF创新结构,重新设计全局平均池化层和全局最大池
    ......
  • Python数据结构——序列(超详细版)
    在计算机程序中会有很多数据,使用数据结构可以管理这些数据,Python中的数据结构主要有序列、集合和字典。常见的数据结构有:数组(array)、集合(set)、列表(list)、队列(queue)、链表(linkedlist)、树(tree)、堆(heap)、栈(stack)和字典(dictionary)。注意:Python中并没有数组结构,因为数组要求元素类......
  • FFmpeg结构体:AVOutputFormat
    1.描述AVOutpufFormat与AVInputFormat类似,是类似COM接口的数据结构,表示输出文件容器格式,着重于功能函数,位于Avoformat.h文件中。ffmpeg支持各种各样的输出文件格式,MP4,FLV,3GP等等。而AVOutputFormat结构体则保存了这些格式的信息和一些常规设置。每一种封装对应一个AVOutpu......
  • 【Python核心数据结构探秘】:元组与字典的完美协奏曲
    文章目录......
  • 保研复习——数据结构篇
    前言:本笔记是对《王道数据结构》中各章节涉及的基础知识进行整理。本笔记主要用以应对夏令营面试中可能会问到的数据结构方面的问题,比较泛泛而谈,如果您对这些内容感兴趣,建议参考原书。大佬可自行绕路材料来源:王道2025年《数据结构考研复习指导》https://pan.baidu.com/s......
  • 深入STL之 栈与队列:数据结构探索之旅
    ......
  • 【数据结构】前缀树(字典树)汇总
    基础{“a”,“abc”,“bac”,“bbc”,“ca”}的字典树如下图:最主用的应用:一,字符串编码。二,位运算。字符串编码相比利用哈希映射编码,优点如下:依次查询长度为n的字符串s的前缀时间复杂度是O(n)。查询完s[0…i],再查询s[0…i+1]的时间复杂度是O(1)。而哈希映射的时间复杂......