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成員中。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章