diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-10 20:29:25 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-10 20:40:37 +0200 |
commit | 85f115b5d8d7d8f39d9a2934242b108f5b7c891e (patch) | |
tree | 4502b80cfcce9c082b5091a67022766222511f57 /libavfilter/vf_scale.c | |
parent | da3f89988f03ffb399879c5ffabed8b4111e548a (diff) | |
parent | c334c113d4d9e9a41bc38a3e4458d7ab21010401 (diff) |
Merge commit 'c334c113d4d9e9a41bc38a3e4458d7ab21010401'
* 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>
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r-- | libavfilter/vf_scale.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 4cc6aab5b8..5ca2078868 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -78,7 +78,6 @@ typedef struct { * -1 = keep original aspect */ int w, h; - char *flags_str; ///sws flags string char *size_str; unsigned int flags; ///sws flags @@ -90,35 +89,17 @@ typedef struct { char *w_expr; ///< width expression string char *h_expr; ///< height expression string + char *flags_str; } ScaleContext; -#define OFFSET(x) offsetof(ScaleContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM - -static const AVOption scale_options[] = { - { "w", "set width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, - { "width", "set width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, - { "h", "set height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, - { "height", "set height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, - { "flags", "set libswscale flags", OFFSET(flags_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, INT_MAX, FLAGS }, - { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, 1, FLAGS }, - { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, - { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, - { NULL }, -}; - -AVFILTER_DEFINE_CLASS(scale); - static av_cold int init(AVFilterContext *ctx, const char *args) { ScaleContext *scale = ctx->priv; +#if 1 static const char *shorthand[] = { "w", "h", NULL }; int ret; const char *args0 = args; - scale->class = &scale_class; - av_opt_set_defaults(scale); - if (args && (scale->size_str = av_get_token(&args, ":"))) { if (av_parse_video_size(&scale->w, &scale->h, scale->size_str) < 0) { av_freep(&scale->size_str); @@ -157,6 +138,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) scale->w_expr, scale->h_expr, (char *)av_x_if_null(scale->flags_str, ""), scale->interlaced); scale->flags = SWS_BILINEAR; +#endif if (scale->flags_str) { const AVClass *class = sws_get_class(); const AVOption *o = av_opt_find(&class, "sws_flags", NULL, 0, @@ -413,6 +395,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) return ff_filter_frame(outlink, out); } +#define OFFSET(x) offsetof(ScaleContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption scale_options[] = { + { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS }, + { "width", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS }, + { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS }, + { "height","Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS }, + { "flags", "Flags to pass to libswscale", OFFSET(flags_str), AV_OPT_TYPE_STRING, { .str = "bilinear" }, .flags = FLAGS }, + { "interl", "set interlacing", OFFSET(interlaced), AV_OPT_TYPE_INT, {.i64 = 0 }, -1, 1, FLAGS }, + { "size", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, + { "s", "set video size", OFFSET(size_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, FLAGS }, + { NULL }, +}; + +AVFILTER_DEFINE_CLASS(scale); + static const AVFilterPad avfilter_vf_scale_inputs[] = { { .name = "default", @@ -441,8 +440,8 @@ AVFilter avfilter_vf_scale = { .query_formats = query_formats, .priv_size = sizeof(ScaleContext), + .priv_class = &scale_class, .inputs = avfilter_vf_scale_inputs, .outputs = avfilter_vf_scale_outputs, - .priv_class = &scale_class, }; |