* commit 'c334c113d4d9e9a41bc38a3e4458d7ab21010401':
vf_scale: switch to an AVOptions-based system.
Conflicts:
doc/filters.texi
libavfilter/avfilter.c
libavfilter/vf_scale.c
scale keeps using our shorthand system due to the alternative not
supporting the more complex syntactical things like 1 parameter
dimensions
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -4833,11 +4833,13 @@ A description of the accepted options follows. |
4833 | 4833 |
|
4834 | 4834 |
@table @option |
4835 | 4835 |
@item width, w |
4836 |
-Set the video width expression, default value is @code{iw}. See below |
|
4836 |
+Output video width. |
|
4837 |
+default value is @code{iw}. See below |
|
4837 | 4838 |
for the list of accepted constants. |
4838 | 4839 |
|
4839 | 4840 |
@item height, h |
4840 |
-Set the video heiht expression, default value is @code{ih}. |
|
4841 |
+Output video height. |
|
4842 |
+default value is @code{ih}. |
|
4841 | 4843 |
See below for the list of accepted constants. |
4842 | 4844 |
|
4843 | 4845 |
@item interl |
... | ... |
@@ -4900,12 +4902,12 @@ If the input image format is different from the format requested by |
4900 | 4900 |
the next filter, the scale filter will convert the input to the |
4901 | 4901 |
requested format. |
4902 | 4902 |
|
4903 |
-If the value for @var{width} or @var{height} is 0, the respective input |
|
4903 |
+If the value for @var{w} or @var{h} is 0, the respective input |
|
4904 | 4904 |
size is used for the output. |
4905 | 4905 |
|
4906 |
-If the value for @var{width} or @var{height} is -1, the scale filter will |
|
4907 |
-use, for the respective output size, a value that maintains the aspect |
|
4908 |
-ratio of the input image. |
|
4906 |
+If the value for @var{w} or @var{h} is -1, the scale filter will use, for the |
|
4907 |
+respective output size, a value that maintains the aspect ratio of the input |
|
4908 |
+image. |
|
4909 | 4909 |
|
4910 | 4910 |
@subsection Examples |
4911 | 4911 |
|
... | ... |
@@ -4913,7 +4915,7 @@ ratio of the input image. |
4913 | 4913 |
@item |
4914 | 4914 |
Scale the input video to a size of 200x100: |
4915 | 4915 |
@example |
4916 |
-scale=200:100 |
|
4916 |
+scale=w=200:h=100 |
|
4917 | 4917 |
@end example |
4918 | 4918 |
|
4919 | 4919 |
This is equivalent to: |
... | ... |
@@ -4940,7 +4942,7 @@ scale=size=qcif |
4940 | 4940 |
@item |
4941 | 4941 |
Scale the input to 2x: |
4942 | 4942 |
@example |
4943 |
-scale=2*iw:2*ih |
|
4943 |
+scale=w=2*iw:h=2*ih |
|
4944 | 4944 |
@end example |
4945 | 4945 |
|
4946 | 4946 |
@item |
... | ... |
@@ -4958,7 +4960,7 @@ scale=2*iw:2*ih:interl=1 |
4958 | 4958 |
@item |
4959 | 4959 |
Scale the input to half size: |
4960 | 4960 |
@example |
4961 |
-scale=iw/2:ih/2 |
|
4961 |
+scale=w=iw/2:h=ih/2 |
|
4962 | 4962 |
@end example |
4963 | 4963 |
|
4964 | 4964 |
@item |
... | ... |
@@ -4977,7 +4979,7 @@ scale=ih*PHI:ih |
4977 | 4977 |
@item |
4978 | 4978 |
Increase the height, and set the width to 3/2 of the height: |
4979 | 4979 |
@example |
4980 |
-scale=3/2*oh:3/5*ih |
|
4980 |
+scale=w=3/2*oh:h=3/5*ih |
|
4981 | 4981 |
@end example |
4982 | 4982 |
|
4983 | 4983 |
@item |
... | ... |
@@ -4991,7 +4993,7 @@ scale="trunc(3/2*iw/hsub)*hsub:trunc(3/2*ih/vsub)*vsub" |
4991 | 4991 |
Increase the width to a maximum of 500 pixels, keep the same input |
4992 | 4992 |
aspect ratio: |
4993 | 4993 |
@example |
4994 |
-scale='min(500\, iw*3/2):-1' |
|
4994 |
+scale=w='min(500\, iw*3/2):h=-1' |
|
4995 | 4995 |
@end example |
4996 | 4996 |
@end itemize |
4997 | 4997 |
|
... | ... |
@@ -671,7 +671,9 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque |
671 | 671 |
!strcmp(filter->filter->name, "frei0r_src") || |
672 | 672 |
!strcmp(filter->filter->name, "format") || |
673 | 673 |
!strcmp(filter->filter->name, "noformat") || |
674 |
- !strcmp(filter->filter->name, "resample") |
|
674 |
+ !strcmp(filter->filter->name, "resample") || |
|
675 |
+// !strcmp(filter->filter->name, "scale" ) || |
|
676 |
+ 0 |
|
675 | 677 |
; |
676 | 678 |
|
677 | 679 |
if (filter->filter->shorthand) { |
... | ... |
@@ -687,6 +689,36 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque |
687 | 687 |
} |
688 | 688 |
|
689 | 689 |
if (anton_options && args && *args && filter->filter->priv_class) { |
690 |
+#if FF_API_OLD_FILTER_OPTS |
|
691 |
+ if (!strcmp(filter->filter->name, "scale") && |
|
692 |
+ strchr(args, ':') < strchr(args, '=')) { |
|
693 |
+ /* old w:h:flags=<flags> syntax */ |
|
694 |
+ char *copy = av_strdup(args); |
|
695 |
+ char *p; |
|
696 |
+ |
|
697 |
+ av_log(filter, AV_LOG_WARNING, "The <w>:<h>:flags=<flags> option " |
|
698 |
+ "syntax is deprecated. Use either <w>:<h>:<flags> or " |
|
699 |
+ "w=<w>:h=<h>:flags=<flags>.\n"); |
|
700 |
+ |
|
701 |
+ if (!copy) { |
|
702 |
+ ret = AVERROR(ENOMEM); |
|
703 |
+ goto fail; |
|
704 |
+ } |
|
705 |
+ |
|
706 |
+ p = strrchr(copy, ':'); |
|
707 |
+ if (p) { |
|
708 |
+ *p++ = 0; |
|
709 |
+ ret = av_dict_parse_string(&options, p, "=", ":", 0); |
|
710 |
+ } |
|
711 |
+ if (ret >= 0) |
|
712 |
+ ret = process_unnamed_options(filter, &options, copy); |
|
713 |
+ av_freep(©); |
|
714 |
+ |
|
715 |
+ if (ret < 0) |
|
716 |
+ goto fail; |
|
717 |
+ } else |
|
718 |
+#endif |
|
719 |
+ |
|
690 | 720 |
if (strchr(args, '=')) { |
691 | 721 |
/* assume a list of key1=value1:key2=value2:... */ |
692 | 722 |
ret = av_dict_parse_string(&options, args, "=", ":", 0); |
... | ... |
@@ -78,7 +78,6 @@ typedef struct { |
78 | 78 |
* -1 = keep original aspect |
79 | 79 |
*/ |
80 | 80 |
int w, h; |
81 |
- char *flags_str; ///sws flags string |
|
82 | 81 |
char *size_str; |
83 | 82 |
unsigned int flags; ///sws flags |
84 | 83 |
|
... | ... |
@@ -90,35 +89,17 @@ typedef struct { |
90 | 90 |
|
91 | 91 |
char *w_expr; ///< width expression string |
92 | 92 |
char *h_expr; ///< height expression string |
93 |
+ char *flags_str; |
|
93 | 94 |
} ScaleContext; |
94 | 95 |
|
95 |
-#define OFFSET(x) offsetof(ScaleContext, x) |
|
96 |
-#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
|
97 |
- |
|
98 |
-static const AVOption scale_options[] = { |
|
99 |
- { "w", "set width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, |
|
100 |
- { "width", "set width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, |
|
101 |
- { "h", "set height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, |
|
102 |
- { "height", "set height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, |
|
103 |
- { "flags", "set libswscale flags", OFFSET(flags_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, INT_MAX, FLAGS }, |
|
104 |
- { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, 1, FLAGS }, |
|
105 |
- { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, |
|
106 |
- { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, |
|
107 |
- { NULL }, |
|
108 |
-}; |
|
109 |
- |
|
110 |
-AVFILTER_DEFINE_CLASS(scale); |
|
111 |
- |
|
112 | 96 |
static av_cold int init(AVFilterContext *ctx, const char *args) |
113 | 97 |
{ |
114 | 98 |
ScaleContext *scale = ctx->priv; |
99 |
+#if 1 |
|
115 | 100 |
static const char *shorthand[] = { "w", "h", NULL }; |
116 | 101 |
int ret; |
117 | 102 |
const char *args0 = args; |
118 | 103 |
|
119 |
- scale->class = &scale_class; |
|
120 |
- av_opt_set_defaults(scale); |
|
121 |
- |
|
122 | 104 |
if (args && (scale->size_str = av_get_token(&args, ":"))) { |
123 | 105 |
if (av_parse_video_size(&scale->w, &scale->h, scale->size_str) < 0) { |
124 | 106 |
av_freep(&scale->size_str); |
... | ... |
@@ -157,6 +138,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) |
157 | 157 |
scale->w_expr, scale->h_expr, (char *)av_x_if_null(scale->flags_str, ""), scale->interlaced); |
158 | 158 |
|
159 | 159 |
scale->flags = SWS_BILINEAR; |
160 |
+#endif |
|
160 | 161 |
if (scale->flags_str) { |
161 | 162 |
const AVClass *class = sws_get_class(); |
162 | 163 |
const AVOption *o = av_opt_find(&class, "sws_flags", NULL, 0, |
... | ... |
@@ -413,6 +395,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) |
413 | 413 |
return ff_filter_frame(outlink, out); |
414 | 414 |
} |
415 | 415 |
|
416 |
+#define OFFSET(x) offsetof(ScaleContext, x) |
|
417 |
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
|
418 |
+ |
|
419 |
+static const AVOption scale_options[] = { |
|
420 |
+ { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS }, |
|
421 |
+ { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS }, |
|
422 |
+ { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS }, |
|
423 |
+ { "height","Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS }, |
|
424 |
+ { "flags", "Flags to pass to libswscale", OFFSET(flags_str), AV_OPT_TYPE_STRING, { .str = "bilinear" }, .flags = FLAGS }, |
|
425 |
+ { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, 1, FLAGS }, |
|
426 |
+ { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, |
|
427 |
+ { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, |
|
428 |
+ { NULL }, |
|
429 |
+}; |
|
430 |
+ |
|
431 |
+AVFILTER_DEFINE_CLASS(scale); |
|
432 |
+ |
|
416 | 433 |
static const AVFilterPad avfilter_vf_scale_inputs[] = { |
417 | 434 |
{ |
418 | 435 |
.name = "default", |
... | ... |
@@ -441,8 +440,8 @@ AVFilter avfilter_vf_scale = { |
441 | 441 |
.query_formats = query_formats, |
442 | 442 |
|
443 | 443 |
.priv_size = sizeof(ScaleContext), |
444 |
+ .priv_class = &scale_class, |
|
444 | 445 |
|
445 | 446 |
.inputs = avfilter_vf_scale_inputs, |
446 | 447 |
.outputs = avfilter_vf_scale_outputs, |
447 |
- .priv_class = &scale_class, |
|
448 | 448 |
}; |