summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-12-06 10:26:11 +0100
committerStefano Sabatini <stefasab@gmail.com>2013-12-06 10:51:12 +0100
commit405b3eb535a8dd8375e0cf54a8ba43cde0bafd16 (patch)
tree130a0bc7f49608912290a6292415b68b6a505ae7 /libavfilter
parent5b073da7a11f0cdcf173c4da98299ed9743e62a3 (diff)
lavfi/aevalsrc: duplicate last expression for the missing channels
Use last expression for the missing channel expressions in case the channel layout was specified. Enhance flexibility.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/asrc_aevalsrc.c34
-rw-r--r--libavfilter/version.h2
2 files changed, 24 insertions, 12 deletions
diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c
index 41ad632145..9bf9675363 100644
--- a/libavfilter/asrc_aevalsrc.c
+++ b/libavfilter/asrc_aevalsrc.c
@@ -85,7 +85,7 @@ static av_cold int init(AVFilterContext *ctx)
{
EvalContext *eval = ctx->priv;
char *args1 = av_strdup(eval->exprs);
- char *expr, *buf;
+ char *expr, *last_expr, *buf;
int ret;
if (!args1) {
@@ -94,27 +94,39 @@ static av_cold int init(AVFilterContext *ctx)
goto end;
}
+#define ADD_EXPRESSION(expr_) do { \
+ if (!av_dynarray2_add((void **)&eval->expr, &eval->nb_channels, \
+ sizeof(*eval->expr), NULL)) { \
+ ret = AVERROR(ENOMEM); \
+ goto end; \
+ } \
+ eval->expr[eval->nb_channels-1] = NULL; \
+ ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr_, \
+ var_names, NULL, NULL, \
+ NULL, NULL, 0, ctx); \
+ if (ret < 0) \
+ goto end; \
+ } while (0)
+
/* parse expressions */
buf = args1;
while (expr = av_strtok(buf, "|", &buf)) {
- if (!av_dynarray2_add((void **)&eval->expr, &eval->nb_channels, sizeof(*eval->expr), NULL)) {
- ret = AVERROR(ENOMEM);
- goto end;
- }
- eval->expr[eval->nb_channels-1] = NULL;
- ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr, var_names,
- NULL, NULL, NULL, NULL, 0, ctx);
- if (ret < 0)
- goto end;
+ ADD_EXPRESSION(expr);
+ last_expr = expr;
}
if (eval->chlayout_str) {
- int n;
+ int i, n;
ret = ff_parse_channel_layout(&eval->chlayout, NULL, eval->chlayout_str, ctx);
if (ret < 0)
goto end;
n = av_get_channel_layout_nb_channels(eval->chlayout);
+ if (n > eval->nb_channels) {
+ for (i = eval->nb_channels; i < n; i++)
+ ADD_EXPRESSION(last_expr);
+ }
+
if (n != eval->nb_channels) {
av_log(ctx, AV_LOG_ERROR,
"Mismatch between the specified number of channels '%d' "
diff --git a/libavfilter/version.h b/libavfilter/version.h
index bbc1208eaf..17c656362e 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 91
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \