* [FFmpeg-devel] [PATCH] avfilter/vf_libplacebo: always pass through SAR when stretching (PR #21038)
@ 2025-11-28 12:46 Niklas Haas via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Niklas Haas via ffmpeg-devel @ 2025-11-28 12:46 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Niklas Haas
PR #21038 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21038
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21038.patch
The current logic assumes `s->reset_sar` always resets the SAR, but this
is only true if `force_oar` is actually true as well, meaning that in the
case of `s->reset_sar && !force_oar`, the SAR is incorrectly set to 1:1.
While we could fix this by also forcing `force_oar` for multiple inputs,
that would have unintended consequences when the user explicitly sets the
desired resolution. Instead, pass-through the SAR in this case; matching
the intended behavior of inheriting the SAR from the base layer input.
>From 0ab721603cd708327d70ac9721950778fe2d7b5c Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Fri, 28 Nov 2025 13:43:27 +0100
Subject: [PATCH] avfilter/vf_libplacebo: always pass through SAR when
stretching
The current logic assumes `s->reset_sar` always resets the SAR, but this
is only true if `force_oar` is actually true as well, meaning that in the
case of `s->reset_sar && !force_oar`, the SAR is incorrectly set to 1:1.
While we could fix this by also forcing `force_oar` for multiple inputs,
that would have unintended consequences when the user explicitly sets the
desired resolution. Instead, pass-through the SAR in this case; matching
the intended behavior of inheriting the SAR from the base layer input.
---
libavfilter/vf_libplacebo.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 42501c51f2..c5085aa7e9 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -1507,10 +1507,7 @@ static int libplacebo_config_output(AVFilterLink *outlink)
}
}
- if (s->reset_sar) {
- /* SAR is normalized, or we have multiple inputs, set out to 1:1 */
- outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
- } else if (inlink->sample_aspect_ratio.num && s->fit_mode == FIT_FILL) {
+ if (inlink->sample_aspect_ratio.num && s->fit_mode == FIT_FILL) {
/* This is consistent with other scale_* filters, which only
* set the outlink SAR to be equal to the scale SAR iff the input SAR
* was set to something nonzero */
@@ -1518,6 +1515,9 @@ static int libplacebo_config_output(AVFilterLink *outlink)
const AVRational ar_out = { outlink->w, outlink->h };
const AVRational stretch = av_div_q(ar_in, ar_out);
outlink->sample_aspect_ratio = av_mul_q(inlink->sample_aspect_ratio, stretch);
+ } else if (s->reset_sar) {
+ /* SAR is normalized, or we have multiple inputs, set out to 1:1 */
+ outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
} else {
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-28 12:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-28 12:46 [FFmpeg-devel] [PATCH] avfilter/vf_libplacebo: always pass through SAR when stretching (PR #21038) Niklas Haas via ffmpeg-devel
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