[FFmpeg-cvslog] af_pan: switch to an AVOptions-based shorthand system.

Michael Niedermayer git at videolan.org
Fri Apr 12 10:43:37 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Apr 12 10:32:41 2013 +0200| [3c821e7550866129ad19d4bba0f84dc4648ceb5a] | committer: Michael Niedermayer

af_pan: switch to an AVOptions-based shorthand system.

TODO: The first argument can be seperated into its own AVOption

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

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

 libavfilter/af_pan.c   |   21 +++++++++++++++++----
 libavfilter/avfilter.c |    2 +-
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 4fa81ab..338cc6e 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -40,6 +40,8 @@
 #define MAX_CHANNELS 63
 
 typedef struct PanContext {
+    const AVClass *class;
+    char *args;
     int64_t out_channel_layout;
     double gain[MAX_CHANNELS][MAX_CHANNELS];
     int64_t need_renorm;
@@ -99,12 +101,12 @@ static void skip_spaces(char **arg)
 static av_cold int init(AVFilterContext *ctx, const char *args0)
 {
     PanContext *const pan = ctx->priv;
-    char *arg, *arg0, *tokenizer, *args = av_strdup(args0);
+    char *arg, *arg0, *tokenizer, *args = av_strdup(pan->args);
     int out_ch_id, in_ch_id, len, named, ret;
     int nb_in_channels[2] = { 0, 0 }; // number of unnamed and named input channels
     double gain;
 
-    if (!args0) {
+    if (!pan->args) {
         av_log(ctx, AV_LOG_ERROR,
                "pan filter needs a channel layout and a set "
                "of channels definitions as parameter\n");
@@ -112,14 +114,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args0)
     }
     if (!args)
         return AVERROR(ENOMEM);
-    arg = av_strtok(args, ":", &tokenizer);
+    arg = av_strtok(args, "|", &tokenizer);
     ret = ff_parse_channel_layout(&pan->out_channel_layout, arg, ctx);
     if (ret < 0)
         goto fail;
     pan->nb_output_channels = av_get_channel_layout_nb_channels(pan->out_channel_layout);
 
     /* parse channel specifications */
-    while ((arg = arg0 = av_strtok(NULL, ":", &tokenizer))) {
+    while ((arg = arg0 = av_strtok(NULL, "|", &tokenizer))) {
         /* channel name */
         if (parse_channel_name(&arg, &out_ch_id, &named)) {
             av_log(ctx, AV_LOG_ERROR,
@@ -379,6 +381,16 @@ static av_cold void uninit(AVFilterContext *ctx)
     swr_free(&pan->swr);
 }
 
+#define OFFSET(x) offsetof(PanContext, x)
+
+static const AVOption pan_options[] = {
+    { "args", NULL, OFFSET(args), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM },
+    { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(pan);
+
+
 static const AVFilterPad pan_inputs[] = {
     {
         .name         = "default",
@@ -401,6 +413,7 @@ AVFilter avfilter_af_pan = {
     .name          = "pan",
     .description   = NULL_IF_CONFIG_SMALL("Remix channels with coefficients (panning)."),
     .priv_size     = sizeof(PanContext),
+    .priv_class    = &pan_class,
     .init          = init,
     .uninit        = uninit,
     .query_formats = query_formats,
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index cf0aefe..6c76c89 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -686,7 +686,6 @@ static const char *const filters_left_to_update[] = {
 #if FF_API_ACONVERT_FILTER
     "aconvert",
 #endif
-    "pan",
 };
 
 static int filter_use_deprecated_init(const char *name)
@@ -772,6 +771,7 @@ 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, "pan")        ||
                    !strcmp(filter->filter->name, "pp")         ||
                    !strcmp(filter->filter->name, "aevalsrc")) {
             /* a hack for compatibility with the old syntax



More information about the ffmpeg-cvslog mailing list