diff options
author | James Almer <jamrial@gmail.com> | 2022-09-04 23:43:04 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-09-07 20:37:54 -0300 |
commit | 068faf4f74ec51f0717a8cf5d11341dbfa807b78 (patch) | |
tree | 7f3de1cfced4c3a1a30d763eabc9cedffaa90768 | |
parent | 3bc28e9d1ab33627cea3c632dd6b0c33e22e93ba (diff) | |
download | ffmpeg-068faf4f74ec51f0717a8cf5d11341dbfa807b78.tar.gz |
avfilter/vf_scale: overwrite the width and height expressions with the original values
Instead of the potentially adjusted ones. Otherwise, if config_props() is
called again and if using force_original_aspect_ratio, the already adjusted
values could be altered again.
Example command line
scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2
user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame
change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the
very first frame.
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit d9e3cb7e73c77ccddc4d29ed5c1be3920f72c226)
-rw-r--r-- | libavfilter/vf_scale.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 44f85cb019..542b000730 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -488,19 +488,19 @@ static int config_props(AVFilterLink *outlink) if ((ret = scale_eval_dimensions(ctx)) < 0) goto fail; - ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h, + outlink->w = scale->w; + outlink->h = scale->h; + + ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h, scale->force_original_aspect_ratio, scale->force_divisible_by); - if (scale->w > INT_MAX || - scale->h > INT_MAX || - (scale->h * inlink->w) > INT_MAX || - (scale->w * inlink->h) > INT_MAX) + if (outlink->w > INT_MAX || + outlink->h > INT_MAX || + (outlink->h * inlink->w) > INT_MAX || + (outlink->w * inlink->h) > INT_MAX) av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); - outlink->w = scale->w; - outlink->h = scale->h; - /* TODO: make algorithm configurable */ scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL; @@ -705,9 +705,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) goto scale; if (scale->eval_mode == EVAL_MODE_INIT) { - snprintf(buf, sizeof(buf)-1, "%d", outlink->w); + snprintf(buf, sizeof(buf) - 1, "%d", scale->w); av_opt_set(scale, "w", buf, 0); - snprintf(buf, sizeof(buf)-1, "%d", outlink->h); + snprintf(buf, sizeof(buf) - 1, "%d", scale->h); av_opt_set(scale, "h", buf, 0); ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", scale->w_expr); |