[FFmpeg-cvslog] af_aresample: support all swresample parameters.

Michael Niedermayer git at videolan.org
Thu May 17 13:16:42 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 17 13:10:14 2012 +0200| [e3c6b612635b32d2de4ffac1c198fb5a76dd95d3] | committer: Michael Niedermayer

af_aresample: support all swresample parameters.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavfilter/af_aresample.c |   30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index b9af42e..aea5e5e 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -24,6 +24,8 @@
  * resampling audio filter
  */
 
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
 #include "libswresample/swresample.h"
 #include "avfilter.h"
 #include "audio.h"
@@ -38,16 +40,33 @@ typedef struct {
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     AResampleContext *aresample = ctx->priv;
-    int ret;
+    int ret = 0;
+    char *argd = av_strdup(args);
+
+    aresample->swr = swr_alloc();
+    if (!aresample->swr)
+        return AVERROR(ENOMEM);
 
     if (args) {
-        if ((ret = ff_parse_sample_rate(&aresample->out_rate, args, ctx)) < 0)
-            return ret;
+        char *ptr=argd, *token;
+
+        while(token = av_strtok(ptr, ":", &ptr)) {
+            char *value;
+            av_strtok(token, "=", &value);
+
+            if(value) {
+                if((ret=av_opt_set(aresample->swr, token, value, 0)) < 0)
+                    goto end;
+            } else if ((ret = ff_parse_sample_rate(&aresample->out_rate, token, ctx)) < 0)
+                goto end;
+        }
+
     } else {
         aresample->out_rate = -1;
     }
-
-    return 0;
+end:
+    av_free(argd);
+    return ret;
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -105,7 +124,6 @@ static int config_output(AVFilterLink *outlink)
         outlink->sample_rate = aresample->out_rate;
     outlink->time_base = (AVRational) {1, aresample->out_rate};
 
-    //TODO: make the resampling parameters (filter size, phrase shift, linear, cutoff) configurable
     aresample->swr = swr_alloc_set_opts(aresample->swr,
                                         outlink->channel_layout, outlink->format, outlink->sample_rate,
                                         inlink->channel_layout, inlink->format, inlink->sample_rate,



More information about the ffmpeg-cvslog mailing list