Browse code

af_join: switch to an AVOptions-based system.

Change the mappings separator from comma to '|' to avoid excessive
escaping, since comma is already used for separating filters in the
filtergraph description.

Anton Khirnov authored on 2013/02/26 05:21:29
Showing 2 changed files
... ...
@@ -347,7 +347,7 @@ Number of input streams. Defaults to 2.
347 347
 Desired output channel layout. Defaults to stereo.
348 348
 
349 349
 @item map
350
-Map channels from inputs to output. The argument is a comma-separated list of
350
+Map channels from inputs to output. The argument is a '|'-separated list of
351 351
 mappings, each in the @code{@var{input_idx}.@var{in_channel}-@var{out_channel}}
352 352
 form. @var{input_idx} is the 0-based index of the input stream. @var{in_channel}
353 353
 can be either the name of the input channel (e.g. FL for front left) or its
... ...
@@ -367,7 +367,7 @@ avconv -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex join=inputs=3 OUTPUT
367 367
 To build a 5.1 output from 6 single-channel streams:
368 368
 @example
369 369
 avconv -i fl -i fr -i fc -i sl -i sr -i lfe -filter_complex
370
-'join=inputs=6:channel_layout=5.1:map=0.0-FL\,1.0-FR\,2.0-FC\,3.0-SL\,4.0-SR\,5.0-LFE'
370
+'join=inputs=6:channel_layout=5.1:map=0.0-FL|1.0-FR|2.0-FC|3.0-SL|4.0-SR|5.0-LFE'
371 371
 out
372 372
 @end example
373 373
 
... ...
@@ -102,14 +102,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
102 102
 static int parse_maps(AVFilterContext *ctx)
103 103
 {
104 104
     JoinContext *s = ctx->priv;
105
+    char separator = '|';
105 106
     char *cur      = s->map;
106 107
 
108
+#if FF_API_OLD_FILTER_OPTS
109
+    if (cur && strchr(cur, ',')) {
110
+        av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "
111
+               "separate the mappings.\n");
112
+        separator = ',';
113
+    }
114
+#endif
115
+
107 116
     while (cur && *cur) {
108 117
         char *sep, *next, *p;
109 118
         uint64_t in_channel = 0, out_channel = 0;
110 119
         int input_idx, out_ch_idx, in_ch_idx;
111 120
 
112
-        next = strchr(cur, ',');
121
+        next = strchr(cur, separator);
113 122
         if (next)
114 123
             *next++ = 0;
115 124
 
... ...
@@ -182,13 +191,6 @@ static int join_init(AVFilterContext *ctx, const char *args)
182 182
     JoinContext *s = ctx->priv;
183 183
     int ret, i;
184 184
 
185
-    s->class = &join_class;
186
-    av_opt_set_defaults(s);
187
-    if ((ret = av_set_options_string(s, args, "=", ":")) < 0) {
188
-        av_log(ctx, AV_LOG_ERROR, "Error parsing options string '%s'.\n", args);
189
-        return ret;
190
-    }
191
-
192 185
     if (!(s->channel_layout = av_get_channel_layout(s->channel_layout_str))) {
193 186
         av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout '%s'.\n",
194 187
                s->channel_layout_str);
... ...
@@ -512,6 +514,7 @@ AVFilter avfilter_af_join = {
512 512
     .description    = NULL_IF_CONFIG_SMALL("Join multiple audio streams into "
513 513
                                            "multi-channel output"),
514 514
     .priv_size      = sizeof(JoinContext),
515
+    .priv_class     = &join_class,
515 516
 
516 517
     .init           = join_init,
517 518
     .uninit         = join_uninit,