Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avfilter/vf_libplacebo: default to normalize_sar=0
@ 2022-11-18 14:25 Niklas Haas
  2022-11-18 14:25 ` [FFmpeg-devel] [PATCH 2/2] avfilter/vf_libplacebo: fix normalize_sar calculation Niklas Haas
  0 siblings, 1 reply; 2+ messages in thread
From: Niklas Haas @ 2022-11-18 14:25 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

As a result of a typo in the source code, this option was completely
non-functional. In order to fix it, without breaking the current default
(and, upon reconsideration, probably preferred) behavior, explicitly
change this default to 0.
---
 doc/filters.texi            | 7 ++++---
 libavfilter/version.h       | 2 +-
 libavfilter/vf_libplacebo.c | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e4da63cf48..d576e46d79 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15581,9 +15581,10 @@ will be performed.
 Work the same as the identical @ref{scale} filter options.
 
 @item normalize_sar
-If enabled (the default), output frames will always have a pixel aspect ratio
-of 1:1. If disabled, any aspect ratio mismatches, including those from e.g.
-anamorphic video sources, are forwarded to the output pixel aspect ratio.
+If enabled, output frames will always have a pixel aspect ratio of 1:1. This
+will introduce padding/cropping as necessary. If disabled (the default), any
+aspect ratio mismatches, including those from e.g. anamorphic video sources,
+are forwarded to the output pixel aspect ratio.
 
 @item pad_crop_ratio
 Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 436c2b8b17..1553e7fecf 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -32,7 +32,7 @@
 #include "version_major.h"
 
 #define LIBAVFILTER_VERSION_MINOR  50
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index fa9a7675d1..d52833263d 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -626,7 +626,7 @@ static const AVOption libplacebo_options[] = {
         { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" },
         { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" },
     { "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, STATIC },
-    { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, STATIC },
+    { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC },
     { "pad_crop_ratio", "ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, 1.0, DYNAMIC },
 
     {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"},
-- 
2.38.1

_______________________________________________
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

* [FFmpeg-devel] [PATCH 2/2] avfilter/vf_libplacebo: fix normalize_sar calculation
  2022-11-18 14:25 [FFmpeg-devel] [PATCH 1/2] avfilter/vf_libplacebo: default to normalize_sar=0 Niklas Haas
@ 2022-11-18 14:25 ` Niklas Haas
  0 siblings, 0 replies; 2+ messages in thread
From: Niklas Haas @ 2022-11-18 14:25 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas

From: Niklas Haas <git@haasn.dev>

This previous expression multiplied a constant (outlink->h) that was
guaranteed to be 0 at this point, thus making it always a no-op.

Fix the calculation, and also properly reset the SAR to 1:1 as is now
necessary (the failure to do so previously hid this bug's existence).
---
 libavfilter/vf_libplacebo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index d52833263d..921cdb36fd 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -576,12 +576,13 @@ static int libplacebo_config_output(AVFilterLink *outlink)
                                s->force_original_aspect_ratio,
                                s->force_divisible_by);
 
-    scale_sar = (AVRational){outlink->h * inlink->w, *out_w * *out_h};
+    scale_sar = (AVRational){*out_h * inlink->w, *out_w * inlink->h};
     if (inlink->sample_aspect_ratio.num)
         scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio);
 
     if (s->normalize_sar) {
         /* Apply all SAR during scaling, so we don't need to set the out SAR */
+        outlink->sample_aspect_ratio = (AVRational){ 1, 1 };
         s->target_sar = scale_sar;
     } else {
         /* This is consistent with other scale_* filters, which only
-- 
2.38.1

_______________________________________________
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-11-18 14:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 14:25 [FFmpeg-devel] [PATCH 1/2] avfilter/vf_libplacebo: default to normalize_sar=0 Niklas Haas
2022-11-18 14:25 ` [FFmpeg-devel] [PATCH 2/2] avfilter/vf_libplacebo: fix normalize_sar calculation Niklas Haas

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