Browse code

Merge commit 'a42d6e6c4c19912b73cae8ca9133b4202667c303'

* commit 'a42d6e6c4c19912b73cae8ca9133b4202667c303':
vsrc_movie: switch to an AVOptions-based system.

Conflicts:
doc/filters.texi
libavfilter/src_movie.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/04/11 10:38:34
Showing 3 changed files
... ...
@@ -7156,15 +7156,12 @@ stream by default.
7156 7156
 
7157 7157
 Read audio and/or video stream(s) from a movie container.
7158 7158
 
7159
-It accepts the syntax: @var{movie_name}[:@var{options}] where
7160
-@var{movie_name} is the name of the resource to read (not necessarily
7161
-a file but also a device or a stream accessed through some protocol),
7162
-and @var{options} is an optional sequence of @var{key}=@var{value}
7163
-pairs, separated by ":".
7164
-
7165
-The description of the accepted options follows.
7159
+This filter accepts the following options:
7166 7160
 
7167 7161
 @table @option
7162
+@item filename
7163
+The name of the resource to read (not necessarily a file but also a device or a
7164
+stream accessed through some protocol).
7168 7165
 
7169 7166
 @item format_name, f
7170 7167
 Specifies the format assumed for the movie to read, and can be either
... ...
@@ -712,6 +712,8 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
712 712
         !strcmp(filter->filter->name, "lowpass"   ) ||
713 713
         !strcmp(filter->filter->name, "mandelbrot" ) ||
714 714
         !strcmp(filter->filter->name, "mptestsrc"  ) ||
715
+        !strcmp(filter->filter->name, "movie"      ) ||
716
+        !strcmp(filter->filter->name, "amovie"     ) ||
715 717
         !strcmp(filter->filter->name, "negate"     ) ||
716 718
         !strcmp(filter->filter->name, "noise"      ) ||
717 719
         !strcmp(filter->filter->name, "nullsrc"    ) ||
... ...
@@ -70,19 +70,20 @@ typedef struct {
70 70
 } MovieContext;
71 71
 
72 72
 #define OFFSET(x) offsetof(MovieContext, x)
73
-#define F AV_OPT_FLAG_FILTERING_PARAM
73
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
74 74
 
75 75
 static const AVOption movie_options[]= {
76
-{"format_name",  "set format name",         OFFSET(format_name),  AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MIN, CHAR_MAX, F },
77
-{"f",            "set format name",         OFFSET(format_name),  AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MIN, CHAR_MAX, F },
78
-{"streams",      "set streams",             OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, F },
79
-{"s",            "set streams",             OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, F },
80
-{"si",           "set stream index",        OFFSET(stream_index), AV_OPT_TYPE_INT,    {.i64 = -1},  -1,       INT_MAX, F },
81
-{"stream_index", "set stream index",        OFFSET(stream_index), AV_OPT_TYPE_INT,    {.i64 = -1},  -1,       INT_MAX, F },
82
-{"seek_point",   "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl =  0},  0,        (INT64_MAX-1) / 1000000, F },
83
-{"sp",           "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl =  0},  0,        (INT64_MAX-1) / 1000000, F },
84
-{"loop",         "set loop count",          OFFSET(loop_count),   AV_OPT_TYPE_INT,    {.i64 =  1},  0,        INT_MAX, F },
85
-{NULL},
76
+    { "filename",     NULL,                      OFFSET(file_name),    AV_OPT_TYPE_STRING,                                    .flags = FLAGS },
77
+    { "format_name",  "set format name",         OFFSET(format_name),  AV_OPT_TYPE_STRING,                                    .flags = FLAGS },
78
+    { "f",            "set format name",         OFFSET(format_name),  AV_OPT_TYPE_STRING,                                    .flags = FLAGS },
79
+    { "stream_index", "set stream index",        OFFSET(stream_index), AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX,                 FLAGS  },
80
+    { "si",           "set stream index",        OFFSET(stream_index), AV_OPT_TYPE_INT,    { .i64 = -1 }, -1, INT_MAX,                 FLAGS  },
81
+    { "seek_point",   "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, { .dbl =  0 },  0, (INT64_MAX-1) / 1000000, FLAGS },
82
+    { "sp",           "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, { .dbl =  0 },  0, (INT64_MAX-1) / 1000000, FLAGS },
83
+    { "streams",      "set streams",             OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, FLAGS },
84
+    { "s",            "set streams",             OFFSET(stream_specs), AV_OPT_TYPE_STRING, {.str =  0},  CHAR_MAX, CHAR_MAX, FLAGS },
85
+    { "loop",         "set loop count",          OFFSET(loop_count),   AV_OPT_TYPE_INT,    {.i64 =  1},  0,        INT_MAX, FLAGS },
86
+    { NULL },
86 87
 };
87 88
 
88 89
 static int movie_config_output_props(AVFilterLink *outlink);
... ...
@@ -186,7 +187,7 @@ static int guess_channel_layout(MovieStream *st, int st_index, void *log_ctx)
186 186
     return 0;
187 187
 }
188 188
 
189
-static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, const AVClass *class)
189
+static av_cold int movie_common_init(AVFilterContext *ctx)
190 190
 {
191 191
     MovieContext *movie = ctx->priv;
192 192
     AVInputFormat *iformat = NULL;
... ...
@@ -196,22 +197,11 @@ static av_cold int movie_common_init(AVFilterContext *ctx, const char *args, con
196 196
     char name[16];
197 197
     AVStream *st;
198 198
 
199
-    movie->class = class;
200
-    av_opt_set_defaults(movie);
201
-
202
-    if (args) {
203
-        movie->file_name = av_get_token(&args, ":");
204
-        if (!movie->file_name)
205
-            return AVERROR(ENOMEM);
206
-    }
207
-    if (!args || !*movie->file_name) {
199
+    if (!*movie->file_name) {
208 200
         av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
209 201
         return AVERROR(EINVAL);
210 202
     }
211 203
 
212
-    if (*args++ == ':' && (ret = av_set_options_string(movie, args, "=", ":")) < 0)
213
-        return ret;
214
-
215 204
     movie->seek_point = movie->seek_point_d * 1000000 + 0.5;
216 205
 
217 206
     stream_specs = movie->stream_specs;
... ...
@@ -332,7 +322,6 @@ static av_cold void movie_uninit(AVFilterContext *ctx)
332 332
         if (movie->st[i].st)
333 333
             avcodec_close(movie->st[i].st->codec);
334 334
     }
335
-    av_opt_free(movie);
336 335
     av_freep(&movie->file_name);
337 336
     av_freep(&movie->st);
338 337
     av_freep(&movie->out_index);
... ...
@@ -576,20 +565,20 @@ AVFILTER_DEFINE_CLASS(movie);
576 576
 
577 577
 static av_cold int movie_init(AVFilterContext *ctx, const char *args)
578 578
 {
579
-    return movie_common_init(ctx, args, &movie_class);
579
+    return movie_common_init(ctx);
580 580
 }
581 581
 
582 582
 AVFilter avfilter_avsrc_movie = {
583 583
     .name          = "movie",
584 584
     .description   = NULL_IF_CONFIG_SMALL("Read from a movie source."),
585 585
     .priv_size     = sizeof(MovieContext),
586
+    .priv_class    = &movie_class,
586 587
     .init          = movie_init,
587 588
     .uninit        = movie_uninit,
588 589
     .query_formats = movie_query_formats,
589 590
 
590 591
     .inputs    = NULL,
591 592
     .outputs   = NULL,
592
-    .priv_class = &movie_class,
593 593
 };
594 594
 
595 595
 #endif  /* CONFIG_MOVIE_FILTER */
... ...
@@ -601,7 +590,7 @@ AVFILTER_DEFINE_CLASS(amovie);
601 601
 
602 602
 static av_cold int amovie_init(AVFilterContext *ctx, const char *args)
603 603
 {
604
-    return movie_common_init(ctx, args, &amovie_class);
604
+    return movie_common_init(ctx);
605 605
 }
606 606
 
607 607
 AVFilter avfilter_avsrc_amovie = {