PR #25454 opened by JuliusBairaktaris
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25454
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25454.patch

The AMF filters copy the input frame's sample aspect ratio to every output 
frame, while the output link's sample aspect ratio is computed for the output 
size. vpp_amf with reset_sar or with a non-proportional size therefore outputs 
frames tagged with the input's SAR.

- `avfilter/amf: set the output frames' sample aspect ratio`

On 720x480 input with SAR 32:27, the frame SAR now matches what scale outputs 
for the same parameters in each of these cases: vpp_amf with reset_sar, with 
w=720:h=240, with w=1280:h=720 and without scaling, and sr_amf. Tested on 
Windows 11, RX 9070 XT, driver 32.0.32015.7029.

Written with Claude Opus 5.5 in Claude Code; `Assisted-by` trailer on the 
commit.


>From 55494ec9644d0d9ff9dad7bc7c03c5a570a44c6e Mon Sep 17 00:00:00 2001
From: Julius Bairaktaris <[email protected]>
Date: Sun, 25 Oct 2026 16:46:57 +0100
Subject: [PATCH] avfilter/amf: set the output frames' sample aspect ratio

The AMF filters copy all properties of the input frame to the output
frame, including its sample aspect ratio, while the output link's
sample aspect ratio is computed for the output size. A scaled frame
therefore keeps the input's SAR: vpp_amf=w=1280:h=720:reset_sar=1 on
720x480 input with SAR 32:27 outputs frames tagged 32:27 instead of 1:1,
and w=720:h=240 outputs 32:27 instead of 16:27. Set the output frames'
SAR from the output link.

Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029: the frame SAR
of vpp_amf with reset_sar, with a non-proportional size, with a
proportional size and without scaling, and of sr_amf, now matches what
scale outputs for the same parameters.

Assisted-by: Claude Opus 5.5
Signed-off-by: Julius Bairaktaris <[email protected]>
---
 libavfilter/vf_amf_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/vf_amf_common.c b/libavfilter/vf_amf_common.c
index e1d0b42ee37..b8591451e7e 100644
--- a/libavfilter/vf_amf_common.c
+++ b/libavfilter/vf_amf_common.c
@@ -173,6 +173,7 @@ static int amf_deliver_output(AVFilterContext *avctx)
             return ret;
         }
         out->pts = pts;
+        out->sample_aspect_ratio = outlink->sample_aspect_ratio;
         if (ctx->outputs_per_input > 1)
             out->duration /= ctx->outputs_per_input;
 
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to