InputStream數(shù)據(jù)結(jié)構(gòu)示例解析_第1頁
InputStream數(shù)據(jù)結(jié)構(gòu)示例解析_第2頁
InputStream數(shù)據(jù)結(jié)構(gòu)示例解析_第3頁
InputStream數(shù)據(jù)結(jié)構(gòu)示例解析_第4頁
InputStream數(shù)據(jù)結(jié)構(gòu)示例解析_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

第InputStream數(shù)據(jù)結(jié)構(gòu)示例解析目錄正文structInputStream數(shù)據(jù)結(jié)構(gòu)定義各個字段的解析

正文

structInputStream是單個輸入流的管理器。是由add_input_stream()函數(shù)申請內(nèi)存,以及賦值InputStream的各個字段的。

而input_streams數(shù)組是一個全局變量,包含了所有輸入文件里面的所有輸入流。

nputStream**input_streams=NULL;

intnb_input_streams=0;

你在二次開發(fā)ffmpeg.exe的時候,可以用input_streams全局變量來獲取到所有的輸入流。

structInputStream數(shù)據(jù)結(jié)構(gòu)定義

typedefstructInputStream{

intfile_index;

AVStream*st;

intdiscard;/*trueifstreamdatashouldbediscarded*/

intuser_set_discard;

intdecoding_needed;/*nonzeroifthepacketsmustbedecodedin'raw_fifo',seeDECODING_FOR_**/

#defineDECODING_FOR_OST1

#defineDECODING_FOR_FILTER2

AVCodecContext*dec_ctx;

constAVCodec*dec;

AVFrame*decoded_frame;

AVFrame*filter_frame;/*arefofdecoded_frame,tobesenttofilters*/

AVPacket*pkt;

int64_tstart;/*timewhenreadstarted*/

/*predicteddtsofthenextpacketreadforthisstreamor(whenthereare

*severalframesinapacket)ofthenextframeincurrentpacket(inAV_TIME_BASEunits)*/

int64_tnext_dts;

int64_tdts;///dtsofthelastpacketreadforthisstream(inAV_TIME_BASEunits)

int64_tnext_pts;///syntheticptsforthenextdecodeframe(inAV_TIME_BASEunits)

int64_tpts;///currentptsofthedecodedframe(inAV_TIME_BASEunits)

intwrap_correction_done;

int64_tfilter_in_rescale_delta_last;

int64_tmin_pts;/*ptswiththesmallestvalueinacurrentstream*/

int64_tmax_pts;/*ptswiththehighervalueinacurrentstream*/

//whenforcingconstantinputframeratethrough-r,

//thiscontainstheptsthatwillbegiventothenextdecodedframe

int64_tcfr_next_pts;

int64_tnb_samples;/*numberofsamplesinthelastdecodedaudioframebeforelooping*/

doublets_scale;

intsaw_first_ts;

AVDictionary*decoder_opts;

AVRationalframerate;/*framerateforcedwith-r*/

inttop_field_first;

intguess_layout_max;

intautorotate;

...省略字幕相關(guān)字段...

intdr1;

/*decodeddatafromthisstreamgoesintoallthosefilters

*currentlyvideoandaudioonly*/

InputFilter**filters;

intnb_filters;

intreinit_filters;

/*hwacceloptions*/

...省略硬件解碼相關(guān)字段...

/*hwaccelcontext*/

...省略硬件解碼相關(guān)字段...

/*stats*/

//combinedsizeofallthepacketsread

uint64_tdata_size;

/*numberofpacketssuccessfullyreadforthisstream*/

uint64_tnb_packets;

//numberofframes/samplesretrievedfromthedecoder

uint64_tframes_decoded;

uint64_tsamples_decoded;

int64_t*dts_buffer;

intnb_dts_buffer;

intgot_output;

}InputStream;

各個字段的解析

(省略了字幕相關(guān)的字段):

1,intfile_index,input_files數(shù)組里面的下標,代表InputStream對應(yīng)的InputFile。

2,AVStream*st,AVFormatContext里面的AVStream。

3,intdiscard,如果是1會丟棄讀取到的AVPacket,剛開始的時候都是1。例如文件里面有多個視頻流,會全部都把discard設(shè)置為1,然后再從中選出質(zhì)量最好的視頻流,把它的discard設(shè)置為0。

或者當(dāng)輸出流需要這個輸入流的時候,也會置為0,如下:

if(source_index=0){

ost-sync_ist=input_streams[source_index];

input_streams[source_index]-discard=0;

input_streams[source_index]-st-discard=input_streams[source_index]-user_set_discard;

因此,如果你用ffmpeg.exe對一個有多個視頻流的文件進行轉(zhuǎn)換,默認只會輸出一個視頻流。

4,intuser_set_discard,命令行選項-discard的值,默認是AVDISCARD_NONE,可選的值在AVDiscard枚舉里面。

enumAVDiscard{

/*Weleavesomespacebetweenthemforextensions(dropsome

*keyframesforintra-onlyordropjustsomebidirframes).*/

AVDISCARD_NONE=-16,///discardnothing

AVDISCARD_DEFAULT=0,///discarduselesspacketslike0sizepacketsinavi

AVDISCARD_NONREF=8,///discardallnonreference

AVDISCARD_BIDIR=16,///discardallbidirectionalframes

AVDISCARD_NONINTRA=24,///discardallnonintraframes

AVDISCARD_NONKEY=32,///discardallframesexceptkeyframes

AVDISCARD_ALL=48,///discardall

5,intdecoding_needed,大于0代表輸入流需要進行解碼操作,有兩個值,DECODING_FOR_OST,DECODING_FOR_FILTER

6,AVCodecContext*dec_ctx,解碼器上下文/解碼器實例,輸入流的AVPacket會丟給解碼實例進行解碼。

7,constAVCodec*dec,解碼器信息

8,AVFrame*decoded_frame,從解碼器上下文解碼出來的AVFrame

9,AVFrame*filter_frame,這個字段主要是用來增加引用計數(shù)的,可能在調(diào)用av_buffersrc_add_frame_flags()之后,AVFrame的引用技術(shù)會減一,所以需要先復(fù)制一份引用,如下:

10,AVPacket*pkt,從av_read_frame()里面讀出來的AVPacket,只是復(fù)制了一下引用。

11,int64_tstart,記錄此流是什么時候開始處理的,主要是給-re選項使用的,模擬幀率速度,錄制視頻模擬直播用的。

12,int64_tnext_dts,下一幀的解碼時間,這是通過計算得到的預(yù)估值,如果讀取出來的AVPacket沒有dts,會用這個值代替。

13,int64_tdts,最近一次從av_read_frame()讀出來的AVPacket的dts

14,int64_tnext_pts,下一個AVFrame的pts,通過當(dāng)前AVFrame的pts加上duration計算出來的,應(yīng)該是給一些沒有pts值的AVFrame用的。

15,int64_tpts,最近一次從解碼器里面解碼出來的AVFrame的pts,記錄這個值主要是給send_filter_eof()用的,防止回滾。

15,int64_twrap_correction_done,在一些流格式,例如TS,會有時間戳環(huán)回的問題,int64是有大小限制的,超過這個大小會環(huán)回,ffmpeg.exe需要處理環(huán)回的邏輯。

16,int64_tfilter_in_rescale_delta_last,專門給音頻幀轉(zhuǎn)換時間基用的,因為音頻的連續(xù)性太強,如果有些許誤差需要保存下來,在下次轉(zhuǎn)換的時候進行補償。

17,int64_tmin_pts,從av_read_frame()讀出來的AVPacket的最小pts,不一定是第一幀的pts,因為命令行參數(shù)通過-ss選項,指定從哪里開始處理。

18,int64_tmax_pts,從av_read_frame()讀出來的AVPacket的最大pts,不一定是最后一幀的pts,因為命令行參數(shù)通過-t選項,指定只處理多久的時長。

19,int64_tcfr_next_pts,給-r選項用的。

20,int64_tnb_samples,記錄的是最近一次解碼出來的AVFrame里面的nb_samples。用途我也不清楚,后面補充。

21,doublets_scale,默認值是1.0,可通過命令行選項-itsscale進行改變,主要作用是將pts,dts進行放大,放大的方法是乘以ts_scale。

22,intsaw_first_ts,標記是不是已經(jīng)讀取到屬于該流的第一個AVPacket

23,AVDictionary*decoder_opts,從OptionsContext里面轉(zhuǎn)移過來的解碼器參數(shù)。

24,AVRationalframerate,命令行選項-r的值。

25,inttop_field_first,命令行選項-top的值,好像是給隔行掃描視頻用的。

26,intguess_layout_max,命令行選項-guess_layout_max的值,猜測的最大的聲道布局。

27,intautorotate,命令行選項-autorotate的值,是否插入糾正旋轉(zhuǎn)的filter濾鏡,有些視頻的畫面中途會上下旋轉(zhuǎn),設(shè)置這個選項可以自動糾正旋轉(zhuǎn),不會上下顛倒。

28,intdr1,用FindUseage找不到使用這個字段的代碼,所以是沒用的字段。

29,InputFilter**filters跟intnb_filters,輸入流綁定的入口濾鏡,可以是綁定

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論