diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-04-11 21:59:53 +0200 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-04-11 22:05:03 +0200 |
commit | 71ef1ec7b482d7222717faae0a51f2fd4ef3bdf2 (patch) | |
tree | 541abb032c77f2a99faf6d69807fcc9b32b6cb0c /libavfilter/vf_aspect.c | |
parent | 647fe2e77733edf6e3a15c490056211bc38ccc20 (diff) | |
download | ffmpeg-71ef1ec7b482d7222717faae0a51f2fd4ef3bdf2.tar.gz |
lavfi/aspect: switch to an AVOptions-based system.
This is heavily based on 2831b307 by Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavfilter/vf_aspect.c')
-rw-r--r-- | libavfilter/vf_aspect.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c index ab41becf68..4e7db56e9e 100644 --- a/libavfilter/vf_aspect.c +++ b/libavfilter/vf_aspect.c @@ -38,7 +38,6 @@ typedef struct { const AVClass *class; AVRational aspect; - char *ratio_str; int max; #if FF_API_OLD_FILTER_OPTS float aspect_num, aspect_den; @@ -49,26 +48,11 @@ typedef struct { static av_cold int init(AVFilterContext *ctx, const char *args) { AspectContext *s = ctx->priv; - static const char *shorthand[] = { "ratio", "max", NULL }; - char c; - int ret; - AVRational q; - if (args && sscanf(args, "%d:%d%c", &q.num, &q.den, &c) == 2) { - s->ratio_str = av_strdup(args); + if (s->aspect_num > 0 && s->aspect_den > 0) { av_log(ctx, AV_LOG_WARNING, "num:den syntax is deprecated, please use num/den or named options instead\n"); - } else if ((ret = av_opt_set_from_string(s, args, shorthand, "=", ":")) < 0) { - return ret; - } - - if (s->ratio_str) { - ret = av_parse_ratio(&s->aspect, s->ratio_str, s->max, 0, ctx); - if (ret < 0 || s->aspect.num < 0 || s->aspect.den <= 0) { - av_log(ctx, AV_LOG_ERROR, - "Invalid string '%s' for aspect ratio\n", args); - return AVERROR(EINVAL); - } + s->aspect = av_d2q(s->aspect_num / s->aspect_den, INT_MAX); } return 0; @@ -111,11 +95,15 @@ static int setdar_config_props(AVFilterLink *inlink) } static const AVOption setdar_options[] = { - {"max", "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS }, - {"ratio", "display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {"r", "display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {"dar", "display aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {NULL} +#if FF_API_OLD_FILTER_OPTS + { "dar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS }, + { "dar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS }, +#endif + { "dar", "set display aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "ratio", "set display aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "r", "set display aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "max", "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS }, + { NULL } }; AVFILTER_DEFINE_CLASS(setdar); @@ -170,11 +158,15 @@ static int setsar_config_props(AVFilterLink *inlink) } static const AVOption setsar_options[] = { - {"max", "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS }, - {"ratio", "sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {"r", "sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {"sar", "sample (pixel) aspect ratio", OFFSET(ratio_str), AV_OPT_TYPE_STRING, {.str="0"}, 0, 0, FLAGS }, - {NULL} +#if FF_API_OLD_FILTER_OPTS + { "sar_num", NULL, OFFSET(aspect_num), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS }, + { "sar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS }, +#endif + { "sar", "set sample (pixel) aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "ratio", "set sample (pixel) aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "r", "set sample (pixel) aspect ratio", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl=0}, 0, INT_MAX, FLAGS }, + { "max", "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS }, + { NULL } }; AVFILTER_DEFINE_CLASS(setsar); |