1 回答

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個贊
AVFilter
所有我們寫的濾鏡都要用一個AVFilter結(jié)構(gòu)體講給ffmpeg聽。 這個結(jié)構(gòu)體里描述了ffmpeg從哪個方法進(jìn)入我們的濾鏡。 這個結(jié)構(gòu)體在libavfilter/avfilter.h里如下定義:
01 typedef struct
02 {
03 char *name; ///< 濾鏡名稱
04
05 int priv_size; ///< 給濾鏡分配的內(nèi)存大小
06
07 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
08 void (*uninit)(AVFilterContext *ctx);
09
10 int (*query_formats)(AVFilterContext *ctx);
11
12 const AVFilterPad *inputs; ///< 一系列輸入 NULL terminated list of inputs. NULL if none
13 const AVFilterPad *outputs; ///< 一系列輸出 NULL terminated list of outputs. NULL if none
14 } AVFilter;
“query_formats”方法用于設(shè)置可以接受的輸入圖像格式和輸出的圖像格式(用于濾鏡鏈分辨哪些濾鏡可以組合在一起用)。
AVFilterPad
這個濾鏡用于描述濾鏡的輸入輸出,在libavfilter/avfilter.h中定義如下:
01 typedef struct AVFilterPad
02 {
03 char *name;
04 int type;
05
06 int min_perms;
07 int rej_perms;
08
09 void (*start_frame)(AVFilterLink *link, AVFilterPicRef *picref);
10 AVFilterPicRef *(*get_video_buffer)(AVFilterLink *link, int perms);
11 void (*end_frame)(AVFilterLink *link);
12 void (*draw_slice)(AVFilterLink *link, int y, int height);
13
14 int (*request_frame)(AVFilterLink *link);
15
16 int (*config_props)(AVFilterLink *link);
17 } AVFilterPad;
頭文件里有十分具體的描述,這里大概解釋如下:
輸入輸出pad都可以用的元素:
name pad的名字,所有的輸入pad名字不能重復(fù),所有的輸出名字不能重復(fù);
type 此元素目前只能為“AV_PAD_VIDEO”值
config_props 鏈接此pad的配置方法的函數(shù)指針
僅限輸入pad使用的元素:
min_perms 接受輸入需要的最小權(quán)限
rej_perms 不接受的輸入權(quán)限
start_frame 一幀傳入時引用的方法的函數(shù)指針
draw_slice 每個slice已經(jīng)傳入后引用的方法的函數(shù)指針
end_frame 一幀完整結(jié)束后引用的方法的函數(shù)指針
get_video_buffer 前一個濾鏡調(diào)用,用以為一個圖像請求內(nèi)存
僅限輸出pad使用的元素:
request_frame 請求濾鏡輸出一幀
- 1 回答
- 0 關(guān)注
- 1266 瀏覽
添加回答
舉報(bào)