ffmpeg重要结构体之AVFrame
ffmpeg重要结构体之AVFormatContext
ffmpeg重要结构体之AVCodecContext
ffmpeg重要结构体之AVCodec
ffmpeg重要结构体之AVIOContext
ffmpeg重要结构体之AVStream
ffmpeg重要结构体之AVPacket
AVIOContext是有关输入输出数据的结构体,其定义位于文件libavformat\avio.h中。
在结构体AVFormatCtx中有AVIOContext类型的成员。
定义代码如下:
typedef struct AVIOContext { /** * A class for private options. * * If this AVIOContext is created by avio_open2(), av_class is set and * passes the options down to protocols. * * If this AVIOContext is manually allocated, then av_class may be set by * the caller. * * warning -- this field can be NULL, be sure to not pass this AVIOContext * to any av_opt_* functions in that case. */ const AVClass *av_class; unsigned char *buffer; /**< Start of the buffer. */ int buffer_size; /**< Maximum buffer size */ unsigned char *buf_ptr; /**< Current position in the buffer */ unsigned char *buf_end; /**< End of the data, may be less than buffer+buffer_size if the read function returned less data than requested, e.g. for streams where no more data has been received yet. */ void *opaque; /**< A private pointer, passed to the read/write/seek/... functions. */ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); int64_t (*seek)(void *opaque, int64_t offset, int whence); int64_t pos; /**< position in the file of the current buffer */ int must_flush; /**< true if the next seek should flush */ int eof_reached; /**< true if eof reached */ int write_flag; /**< true if open for writing */ int max_packet_size; unsigned long checksum; unsigned char *checksum_ptr; unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); int error; /**< contains the error code or 0 if no error happened */ /** * Pause or resume playback for network streaming protocols - e.g. MMS. */ int (*read_pause)(void *opaque, int pause); /** * Seek to a given timestamp in stream with the specified stream_index. * Needed for some network streaming protocols which don't support seeking * to byte position. */ int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); /** * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. */ int seekable; /** * max filesize, used to limit allocations * This field is internal to libavformat and access from outside is not allowed. */ int64_t maxsize; /** * avio_read and avio_write should if possible be satisfied directly * instead of going through a buffer, and avio_seek will always * call the underlying seek function directly. */ int direct; /** * Bytes read statistic * This field is internal to libavformat and access from outside is not allowed. */ int64_t bytes_read; /** * seek statistic * This field is internal to libavformat and access from outside is not allowed. */ int seek_count; /** * writeout statistic * This field is internal to libavformat and access from outside is not allowed. */ int writeout_count; /** * Original buffer size * used internally after probing and ensure seekback to reset the buffer size * This field is internal to libavformat and access from outside is not allowed. */ int orig_buffer_size; /** * Threshold to favor readahead over seek. * This is current internal only, do not use from outside. */ int short_seek_threshold; } AVIOContext;
unsigned char *buffer:指向数据开始的位置。一般就是指向文件的开头。如上图中的buffer,其前几个数据为00 00 01 b0,正是此mpeg-4文件的开头。
int buffer_size:buffer的最大值,一般为0x8000即32768.
unsigned char *buf_ptr:当前在buffer中的位置
unsigned char *buf_end:buffer结尾的位置。
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size):读一个packet。
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size):写一个packet。
int64_t (*seek)(void *opaque, int64_t offset, int whence):seek到某一位置。
int (*read_pause)(void *opaque, int pause):对于网络流媒体,暂停(pause)或者恢复(resume)。
int64_t (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags):seek到某个时间戳。
int seekable:当前的流是否可以seek。