diff options
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/asrc_aevalsrc.c | 22 | ||||
-rw-r--r-- | libavfilter/avfilter.c | 19 |
2 files changed, 23 insertions, 18 deletions
diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c index 0dbfdd2..86e29cc 100644 --- a/libavfilter/asrc_aevalsrc.c +++ b/libavfilter/asrc_aevalsrc.c @@ -56,7 +56,7 @@ typedef struct { int nb_channels; int64_t pts; AVExpr *expr[8]; - char *expr_str[8]; + char *exprs; int nb_samples; ///< number of samples per requested frame char *duration_str; ///< total duration of the generated audio double duration; @@ -68,6 +68,7 @@ typedef struct { #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM static const AVOption aevalsrc_options[]= { + { "exprs", "set the '|'-separated list of channels expressions", OFFSET(exprs), AV_OPT_TYPE_STRING, {.str = NULL}, .flags = FLAGS }, { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS }, { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 0, INT_MAX, FLAGS }, { "sample_rate", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, CHAR_MIN, CHAR_MAX, FLAGS }, @@ -84,15 +85,12 @@ AVFILTER_DEFINE_CLASS(aevalsrc); static int init(AVFilterContext *ctx, const char *args) { EvalContext *eval = ctx->priv; - char *args1 = av_strdup(args); - char *expr, *buf, *bufptr; + char *args1 = av_strdup(eval->exprs); + char *expr, *buf; int ret, i; - eval->class = &aevalsrc_class; - av_opt_set_defaults(eval); - if (!args1) { - av_log(ctx, AV_LOG_ERROR, "Argument is empty\n"); + av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n"); ret = args ? AVERROR(ENOMEM) : AVERROR(EINVAL); goto end; } @@ -100,23 +98,15 @@ static int init(AVFilterContext *ctx, const char *args) /* parse expressions */ buf = args1; i = 0; - while (expr = av_strtok(buf, ":", &bufptr)) { + while (i < FF_ARRAY_ELEMS(eval->expr) && (expr = av_strtok(buf, "|", &buf))) { ret = av_expr_parse(&eval->expr[i], expr, var_names, NULL, NULL, NULL, NULL, 0, ctx); if (ret < 0) goto end; i++; - if (bufptr && *bufptr == ':') { /* found last expression */ - bufptr++; - break; - } - buf = NULL; } eval->nb_channels = i; - if (bufptr && (ret = av_set_options_string(eval, bufptr, "=", ":")) < 0) - goto end; - if (eval->chlayout_str) { int n; ret = ff_parse_channel_layout(&eval->chlayout, eval->chlayout_str, ctx); diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 3f69836..18efe80 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -674,7 +674,6 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, static const char *const filters_left_to_update[] = { "abuffer", "aconvert", - "aevalsrc", "amerge", "aresample", "atempo", @@ -757,7 +756,8 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "frei0r") || !strcmp(filter->filter->name, "frei0r_src") || !strcmp(filter->filter->name, "ocv") || - !strcmp(filter->filter->name, "pp")) { + !strcmp(filter->filter->name, "pp") || + !strcmp(filter->filter->name, "aevalsrc")) { /* a hack for compatibility with the old syntax * replace colons with |s */ char *copy = av_strdup(args); @@ -789,9 +789,24 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque "'|' to separate the list items.\n"); } + if (!strcmp(filter->filter->name, "aevalsrc")) { + while ((p = strchr(p, ':')) && p[1] != ':') { + const char *epos = strchr(p + 1, '='); + const char *spos = strchr(p + 1, ':'); + const int next_token_is_opt = epos && (!spos || epos < spos); + if (next_token_is_opt) { + p++; + break; + } + *p++ = '|'; + } + if (p && *p == ':') + memmove(p, p + 1, strlen(p)); + } else while ((p = strchr(p, ':'))) *p++ = '|'; + av_log(filter, AV_LOG_DEBUG, "compat: called with args=[%s]\n", copy); ret = process_options(filter, &options, copy); av_freep(©); |