[FFmpeg-cvslog] lavfi/aevalsrc: remove hard limit on number of channels

Paul B Mahol git at videolan.org
Fri Jul 12 17:52:12 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jul 12 01:23:02 2013 +0000| [937cfebd72d30e617591c666ea4854a3898a64b2] | committer: Paul B Mahol

lavfi/aevalsrc: remove hard limit on number of channels

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=937cfebd72d30e617591c666ea4854a3898a64b2
---

 libavfilter/asrc_aevalsrc.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c
index 7d9979d..6dd1368 100644
--- a/libavfilter/asrc_aevalsrc.c
+++ b/libavfilter/asrc_aevalsrc.c
@@ -55,7 +55,7 @@ typedef struct {
     char *chlayout_str;
     int nb_channels;
     int64_t pts;
-    AVExpr *expr[8];
+    AVExpr **expr;
     char *exprs;
     int nb_samples;             ///< number of samples per requested frame
     int64_t duration;
@@ -86,7 +86,7 @@ static int init(AVFilterContext *ctx)
     EvalContext *eval = ctx->priv;
     char *args1 = av_strdup(eval->exprs);
     char *expr, *buf;
-    int ret, i;
+    int ret;
 
     if (!args1) {
         av_log(ctx, AV_LOG_ERROR, "Channels expressions list is empty\n");
@@ -96,15 +96,16 @@ static int init(AVFilterContext *ctx)
 
     /* parse expressions */
     buf = args1;
-    i = 0;
-    while (i < FF_ARRAY_ELEMS(eval->expr) && (expr = av_strtok(buf, "|", &buf))) {
-        ret = av_expr_parse(&eval->expr[i], expr, var_names,
+    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;
+        }
+        ret = av_expr_parse(&eval->expr[eval->nb_channels - 1], expr, var_names,
                             NULL, NULL, NULL, NULL, 0, ctx);
         if (ret < 0)
             goto end;
-        i++;
     }
-    eval->nb_channels = i;
 
     if (eval->chlayout_str) {
         int n;
@@ -146,10 +147,11 @@ static av_cold void uninit(AVFilterContext *ctx)
     EvalContext *eval = ctx->priv;
     int i;
 
-    for (i = 0; i < 8; i++) {
+    for (i = 0; i < eval->nb_channels; i++) {
         av_expr_free(eval->expr[i]);
         eval->expr[i] = NULL;
     }
+    av_freep(&eval->expr);
 }
 
 static int config_props(AVFilterLink *outlink)



More information about the ffmpeg-cvslog mailing list