FFmpeg架构之其他重要数据结构的初始化

 1 AVStream

AVStream结构保存与数据流相关的编解码器,数据段等信息。比较重要的有如下二个成员:

AVCodecContext *codec; /**< codec context */

void *priv_data;

其中codec指针保存的就是上节所述的encoder或decoder结构。priv_data指针保存的是和具体编解码流相关的数据,如下代码所示,在ASF的解码过程中,priv_data保存的就是ASFStream结构的数据。

AVStream *st; ASFStream *asf_st;

st->priv_data = asf_st;

2 AVInputStream/ AVOutputStream

根据输入和输出流的不同,前述的AVStream结构都是封装在AVInputStream和AVOutputStream结构中,在av_encode( )函数中使用。AVInputStream中还保存的有与时间有关的信息。AVOutputStream中还保存有与音视频同步等相关的信息。

3 AVPacket

AVPacket结构定义如下,其是用于保存读取的packet数据。

  
  
  
  
1
2
3
4
5
6
7
8
9
10
11
12
13
typedef  struct AVPacket 
{ 
int64_t pts ;  ///< presentation time stamp in time_base units
int64_t dts ;  ///< decompression time stamp in time_base units 
uint8_t  *data ; 
int size ; 
int stream_index ; 
int flags ; 
int duration ;  ///< presentation duration in time_base units 
void  ( *destruct ) ( struct AVPacket  * ) ; 
void  *priv ; 
int64_t pos ;  ///< byte position in stream, -1 if unknown 
} AVPacket ;

在av_encode()函数中,调用AVInputFormat的 (*read_packet)(struct AVFormatContext *, AVPacket *pkt)接口,读取输入文件的一帧数据保存在当前输入AVFormatContext的AVPacket成员中。

你可能感兴趣的:(ffmpeg)