ffmpeg filger结构体

typedef struct FilterGraph {            //过滤器图
    int            index;
    const char    *graph_desc;
        
    AVFilterGraph *graph;
    int reconfiguration;
    
    InputFilter   **inputs;   //图的输入口
    int          nb_inputs;        //图的输入口个数
    OutputFilter **outputs;        //图的输出口
    int         nb_outputs;        //图的输出个数
} FilterGraph;



typedef struct AVFilterGraph {  //图的信息
    const AVClass *av_class;
    AVFilterContext **filters;            //过滤器数组
    unsigned nb_filters;               //过滤器个数
    
    char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
#if FF_API_LAVR_OPTS
    attribute_deprecated char *resample_lavr_opts;   ///< libavresample options to use for the auto-inserted resample filters
#endif

    AVFilterLink **sink_links;    //过滤器链表
    int sink_links_count;

    unsigned disable_auto_convert;
} AVFilterGraph;



/** An instance of a filter */
struct AVFilterContext {
    const AVClass *av_class;        ///< needed for av_log() and filters common options

    const AVFilter *filter;         ///< the AVFilter of which this is an instance

    char *name;                     ///< name of this filter instance

    AVFilterPad   *input_pads;      ///< array of input pads                    //该filter的输入pad
    AVFilterLink **inputs;          ///< array of pointers to input links        //每一个输入pad对应一个FilterLink
    unsigned    nb_inputs;          ///< number of input pads                    //输入pad个数

    AVFilterPad   *output_pads;     ///< array of output pads                    //该filter的输出pad
    AVFilterLink **outputs;         ///< array of pointers to output links        //每一个输出pad对应一个FilterLink
    unsigned    nb_outputs;         ///< number of output pads                    //输出pads个数
    
    void *priv;                     ///< private data for use by the filter        //filter上下文
    
    struct AVFilterGraph *graph;    ///< filtergraph this filter belongs to                 //每一个AVFilterContext中都维护一个AVFilterGraph指针
    unsigned ready;
};



/**
 * A filter pad used for either input or output.
 */
struct AVFilterPad {

    const char *name;
    enum AVMediaType type;
    AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h);
    AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples);
    int (*filter_frame)(AVFilterLink *link, AVFrame *frame);
    int (*poll_frame)(AVFilterLink *link);
    int (*request_frame)(AVFilterLink *link);
    int (*config_props)(AVFilterLink *link);
    int needs_fifo;
    int needs_writable;
};




typedef struct InputFilter {
    AVFilterContext    *filter;
    struct InputStream *ist;
    struct FilterGraph *graph;
    uint8_t            *name;
    enum AVMediaType    type;   // AVMEDIA_TYPE_SUBTITLE for sub2video
    
    AVFifoBuffer *frame_queue;
    
    // parameters configured for this input
    int format;

    int width, height;
    AVRational sample_aspect_ratio;
    
    int sample_rate;
    int channels;
    uint64_t channel_layout;

    AVBufferRef *hw_frames_ctx;

    int eof;
} InputFilter;




typedef struct OutputFilter {
    AVFilterContext     *filter;
    struct OutputStream *ost;
    struct FilterGraph  *graph;
    uint8_t             *name;

    /* temporary storage until stream maps are processed */
    AVFilterInOut       *out_tmp;
    enum AVMediaType     type;

    /* desired output stream properties */
    int width, height;
    AVRational frame_rate;
    int format;
    int sample_rate;
    uint64_t channel_layout;

    // those are only set if no format is specified and the encoder gives us multiple options
    int *formats;
    uint64_t *channel_layouts;
    int *sample_rates;
} OutputFilter;



ffmpeg 内部用
typedef struct AVFilterInOut {
    /** unique name for this input/output in the list */
    char *name;

    /** filter context associated to this input/output */
    AVFilterContext *filter_ctx;

    /** index of the filt_ctx pad to use for linking */
    int pad_idx;

    /** next input/input in the list, NULL if this is the last */
    struct AVFilterInOut *next;
} AVFilterInOut;







posted @ 2020-10-10 14:38  虾兵  阅读(105)  评论(0编辑  收藏  举报