* [FFmpeg-devel] [PATCH] avfilter/vf_libplacebo: don't override existing rotation attribute (PR #20831)
@ 2025-11-03 17:33 Niklas Haas via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Niklas Haas via ffmpeg-devel @ 2025-11-03 17:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Niklas Haas
PR #20831 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20831
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20831.patch
This is a regression introduced by the addition of the rotation option,
which overrode the existing rotation attribute that may have been set to
the image.
To fix it, add the rotation istead of setting it - however we have to do this
directly when mapping, so as to not add it multiple times.
Fixes: 4f623b4c59
>From c42c4cd665d0d79b7ffe3d5a668fbccd8898c905 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Mon, 3 Nov 2025 18:18:33 +0100
Subject: [PATCH 1/2] avfilter/vf_libplacebo: don't override existing rotation
 attribute
This is a regression introduced by the addition of the rotation option,
which overrode the existing rotation attribute that may have been set to
the image.
To fix it, add the rotation istead of setting it - however we have to do this
directly when mapping, so as to not add it multiple times.
Fixes: 4f623b4c59c3c838f588e9def7b59dcc26dee7b9
---
 libavfilter/vf_libplacebo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 87d00519c3..393a0126c1 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -912,7 +912,6 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in,
         image->crop.y0 = av_expr_eval(s->crop_y_pexpr, s->var_values, NULL);
         image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W];
         image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H];
-        image->rotation = s->rotation;
         if (s->rotation % PL_ROTATION_180 == PL_ROTATION_90) {
             /* Libplacebo expects the input crop relative to the actual frame
              * dimensions, so un-transpose them here */
@@ -1150,6 +1149,7 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex,
     ));
     out->lut = s->lut;
     out->lut_type = s->lut_type;
+    out->rotation += s->rotation;
 
     if (!s->apply_filmgrain)
         out->film_grain.type = PL_FILM_GRAIN_NONE;
-- 
2.49.1
>From 9c6ffeaa08583d1b4d3f325876e4d16f9061bdaa Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Mon, 3 Nov 2025 18:23:31 +0100
Subject: [PATCH 2/2] avfilter/vf_libplacebo: make rotation check more robust
This currently does not make any difference, but it makes the check
more robust against possible future changes to the rotation parameter.
---
 libavfilter/vf_libplacebo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 393a0126c1..42501c51f2 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -912,7 +912,9 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in,
         image->crop.y0 = av_expr_eval(s->crop_y_pexpr, s->var_values, NULL);
         image->crop.x1 = image->crop.x0 + s->var_values[VAR_CROP_W];
         image->crop.y1 = image->crop.y0 + s->var_values[VAR_CROP_H];
-        if (s->rotation % PL_ROTATION_180 == PL_ROTATION_90) {
+
+        const pl_rotation rot_total = image->rotation - target->rotation;
+        if ((rot_total + PL_ROTATION_360) % PL_ROTATION_180 == PL_ROTATION_90) {
             /* Libplacebo expects the input crop relative to the actual frame
              * dimensions, so un-transpose them here */
             FFSWAP(float, image->crop.x0, image->crop.y0);
-- 
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-03 17:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-03 17:33 [FFmpeg-devel] [PATCH] avfilter/vf_libplacebo: don't override existing rotation attribute (PR #20831) 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