* [FFmpeg-devel] [PATCH] avfilter/vf_scale: overwrite the width and eight expressions with the original values
@ 2022-09-05 2:55 James Almer
2022-09-06 12:19 ` James Almer
0 siblings, 1 reply; 2+ messages in thread
From: James Almer @ 2022-09-05 2:55 UTC (permalink / raw)
To: ffmpeg-devel
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>
---
libavfilter/vf_scale.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 996f7aaa5b..2b12cf283c 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -491,19 +491,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;
@@ -718,9 +718,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);
--
2.37.2
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/vf_scale: overwrite the width and eight expressions with the original values
2022-09-05 2:55 [FFmpeg-devel] [PATCH] avfilter/vf_scale: overwrite the width and eight expressions with the original values James Almer
@ 2022-09-06 12:19 ` James Almer
0 siblings, 0 replies; 2+ messages in thread
From: James Almer @ 2022-09-06 12:19 UTC (permalink / raw)
To: ffmpeg-devel
On 9/4/2022 11:55 PM, James Almer wrote:
> 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>
> ---
> libavfilter/vf_scale.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index 996f7aaa5b..2b12cf283c 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -491,19 +491,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;
> @@ -718,9 +718,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);
Will apply.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-06 12:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 2:55 [FFmpeg-devel] [PATCH] avfilter/vf_scale: overwrite the width and eight expressions with the original values James Almer
2022-09-06 12:19 ` James Almer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git