我有一个结构AVFilter,
typedef struct AVFilter
{
const char *name;
const char *description;
const AVClass *priv_class;
int priv_size;
int (*init)(AVFilterContext *ctx);
void (*uninit)(AVFilterContext *ctx);
int (*query_formats)(AVFilterContext *);
const AVFilterPad *inputs;
const AVFilterPad *outputs;
int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
} AVFilter;
我正在访问诸如
之类的sturctur变量AVFilter avfilter_vsrc_color = {
avfilter_vsrc_color.name = "color",
avfilter_vsrc_color.description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
avfilter_vsrc_color.priv_class = &color_class, // error here
avfilter_vsrc_color.priv_size = sizeof(TestSourceContext),// error here
avfilter_vsrc_color.init = color_init,// error here
avfilter_vsrc_color.uninit = uninit,// error here
avfilter_vsrc_color.query_formats = color_query_formats,// error here
avfilter_vsrc_color.inputs = NULL,// error here
avfilter_vsrc_color.outputs = color_outputs,// error here
avfilter_vsrc_color.process_command = color_process_command // error here
};
我不知道如何访问priv_class。请帮我解决这个问题
如果我喜欢这样,
AVFilter avfilter_vsrc_color=
{
.name = "color", //error
.description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
.priv_class = &color_class,
.priv_size = sizeof(TestSourceContext),
.init = color_init,
.uninit = uninit,
.query_formats = color_query_formats,
.inputs = NULL,
.outputs = color_outputs,
.process_command = color_process_command
};
我得到错误,
2>c:\users\awki6\desktop\ffmpeg\libavfilter\vsrc_testsrc.cpp(271): error C2143: syntax error : missing '}' before '.'
2>c:\users\awki6\desktop\ffmpeg\libavfilter\vsrc_testsrc.cpp(271): error C2143: syntax error : missing ';' before '.'
答案 0 :(得分:2)
两种方式:
AVFilter avfilter_vsrc_color=
{
"color",
NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
&color_class,
...
};
或更详细,但也可能更具可读性(因为你有很多字段):
AVFilter avfilter_vsrc_color;
avfilter_vsrc_color.name = color;
avfilter_vsrc_color.description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input.");
avfilter_vsrc_color.priv_class = &color_class;
...