ffmpeg---命令分组中几个关键结构体的关系

来源:互联网 发布:万网域名whois 编辑:程序博客网 时间:2024/06/01 23:55

命令分组中涉及到到几个结构体,下面简单梳理一下它们之间的关系

主结构体,管理着其他结构体typedef struct OptionParseContext {    OptionGroup global_opts;     //全局命令分组    OptionGroupList *groups;     //输入和输出的命令分组     int           nb_groups;    // 一般情况下是2    /* parsing state */    OptionGroup cur_group;} OptionParseContext;
管理输入源和输出源相关的命令typedef struct OptionGroupList {    const OptionGroupDef *group_def;    OptionGroup *groups;    int       nb_groups;} OptionGroupList;
关键结构体,几乎所有命令参数都保存在这个结构体typedef struct OptionGroup {    const OptionGroupDef *group_def;    const char *arg;    Option *opts;   // 保存const OptionDef options[]    的命令参数                 int  nb_opts;    //记录参数个数    /* 保存av_format_context_class av_codec_context_class的options以及其他命令*/    AVDictionary *codec_opts;       AVDictionary *format_opts;    AVDictionary *resample_opts;    AVDictionary *sws_dict;    AVDictionary *swr_opts;} OptionGroup;
 这个结构体会起到标志的作用,就是参数该分配到哪一组typedef struct OptionGroupDef {    const char *name;        const char *sep;       int flags;} OptionGroupDef;static const OptionGroupDef global_group = { "global" };static const OptionGroupDef groups[] = {    [GROUP_OUTFILE] = { "output file",  NULL, OPT_OUTPUT },    [GROUP_INFILE]  = { "input file",   "i",  OPT_INPUT },};    

保存结构体AVDictionary的命令参数
struct AVDictionary {
int count; //命令参数数量
AVDictionaryEntry *elems; //保存key 和value
};

管理命令的各类属性保存const OptionDef options[]  的命令参数typedef struct Option {    const OptionDef  *opt;    const char       *key;    const char       *val;} Option;
ffmpeg_opt.c中options的封装:OptionDef options[]typedef struct OptionDef {    const char *name; //参数名字    int flags;//标志,区分命令的分组等#define HAS_ARG    0x0001......省略了很多宏的定义      union {        void *dst_ptr;  //全局变量有关        int (*func_arg)(void *, const char *, const char *);//函数,用来处理特殊的命令或者复杂的命令。如-filter_complex        size_t off; //OptionsContext的相对地址偏移    } u;    const char *help;    const char *argname;} OptionDef;

这里写图片描述

0 0
原创粉丝点击