From 4d67ff8e8e3f8733ca2844143ebb2ac0ab34a9cd Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Mar 2013 18:21:27 +0100 Subject: [PATCH 1/2] AVOptions: fix using named constants with child contexts. The named constant needs to be searched for in the same object on which the option is set, i.e. target_obj. --- libavutil/opt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 661a61bca5..f3dcdeebf8 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -146,7 +146,7 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d opt->type == AV_OPT_TYPE_INT) ? \ opt->default_val.i64 : opt->default_val.dbl) -static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst) +static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) { int ret = 0, notfirst = 0; for (;;) { @@ -169,7 +169,7 @@ static int set_string_number(void *obj, const AVOption *o, const char *val, void buf[i] = 0; { - const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0); + const AVOption *o_named = av_opt_find(target_obj, buf, o->unit, 0, 0); if (o_named && o_named->type == AV_OPT_TYPE_CONST) d = DEFAULT_NUMVAL(o_named); else if (!strcmp(buf, "default")) d = DEFAULT_NUMVAL(o); @@ -224,7 +224,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) case AV_OPT_TYPE_INT64: case AV_OPT_TYPE_FLOAT: case AV_OPT_TYPE_DOUBLE: - case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, o, val, dst); + case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst); } av_log(obj, AV_LOG_ERROR, "Invalid option type.\n"); @@ -236,7 +236,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) {\ if (!o || o->type != opttype)\ return AVERROR(EINVAL);\ - return set_string_number(obj, o, val, name ## _out);\ + return set_string_number(obj, obj, o, val, name ## _out);\ } OPT_EVAL_NUMBER(flags, AV_OPT_TYPE_FLAGS, int) From e4a7b2177d14678ae240edcabaacfe2b14619b7b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Mar 2013 19:45:56 +0100 Subject: [PATCH 2/2] vf_showinfo: remove its useless init function Filter private data is memset to 0 so there is no point in explicitly initing anything to 0. --- libavfilter/vf_showinfo.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c index 7970810c5d..04b436d4b0 100644 --- a/libavfilter/vf_showinfo.c +++ b/libavfilter/vf_showinfo.c @@ -34,13 +34,6 @@ typedef struct { unsigned int frame; } ShowInfoContext; -static av_cold int init(AVFilterContext *ctx, const char *args) -{ - ShowInfoContext *showinfo = ctx->priv; - showinfo->frame = 0; - return 0; -} - static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; @@ -103,7 +96,6 @@ AVFilter avfilter_vf_showinfo = { .description = NULL_IF_CONFIG_SMALL("Show textual information for each video frame."), .priv_size = sizeof(ShowInfoContext), - .init = init, .inputs = avfilter_vf_showinfo_inputs,