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

frc_amf's profile has to be chosen for each input, although the option help 
already recommends high up to 1440p and super above. mpv's own AMF FRC filter 
picks the profile from the input height. mpv is replacing that filter with 
frc_amf through lavfi (mpv-player/mpv#18686), and this is the one option 
frc_amf lacks.

- `avfilter/vf_frc_amf: add profile=auto`: selects super for inputs of 1440 
lines or more and high otherwise. The default stays high.

24 frames of software NV12 input: profile=auto gives the same framemd5 as 
profile=super at 3840x2160 and as profile=high at 1920x1080; high and super 
differ at both sizes, and reruns are identical. 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 0152adad665dc3962032e91256ca1fafe9452c8f Mon Sep 17 00:00:00 2001
From: Julius Bairaktaris <[email protected]>
Date: Sun, 25 Oct 2026 16:19:36 +0100
Subject: [PATCH] avfilter/vf_frc_amf: add profile=auto

The option help already recommends high up to 1440p and super above,
but the caller has to pick the profile by hand for each input. Add an
auto value that selects super for inputs of 1440 lines or more and high
otherwise, from the input height at configuration time. The default
stays high.

Tested on Windows 11, RX 9070 XT, driver 32.0.32015.7029, 24 frames of
software NV12 input: profile=auto gives the same framemd5 as
profile=super at 3840x2160 and as profile=high at 1920x1080; high and
super differ from each other at both sizes, and reruns are identical.

Assisted-by: Claude Opus 5.5
Signed-off-by: Julius Bairaktaris <[email protected]>
---
 doc/filters.texi         | 4 ++++
 libavfilter/vf_frc_amf.c | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 37f9123df49..dd8616b81e7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15028,6 +15028,10 @@ Boolean value: show FRC indicator square in the top 
left corner of the video
 @item profile
 Level of hierarchical motion search.
 @table @samp
+@item auto
+Select the profile from the input height: @samp{super} for 1440 lines or
+more, @samp{high} otherwise.
+
 @item low
 Less levels of hierarchical motion search.
 Only recommended for extremely low resolutions.
diff --git a/libavfilter/vf_frc_amf.c b/libavfilter/vf_frc_amf.c
index c7ef58b4294..d393db19d6d 100644
--- a/libavfilter/vf_frc_amf.c
+++ b/libavfilter/vf_frc_amf.c
@@ -129,7 +129,10 @@ static int amf_frc_filter_config_output(AVFilterLink 
*outlink)
 
     AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_INDICATOR, 
frc_ctx->indicator);
 
-    AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_PROFILE, 
frc_ctx->profile);
+    AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, AMF_FRC_PROFILE,
+                                        frc_ctx->profile != -1   ? 
frc_ctx->profile  :
+                                        inlink->h >= 1440        ? 
FRC_PROFILE_SUPER :
+                                                                   
FRC_PROFILE_HIGH);
 
     AMF_FRC_ASSIGN_PROPERTY_INT64_CHECK(avctx, amf_filter, 
AMF_FRC_MV_SEARCH_MODE, frc_ctx->mv_search_mode);
 
@@ -159,7 +162,9 @@ static const AVOption frc_amf_options[] = {
 
     { "indicator",      "Show FRC indicator square in the top left corner of 
the video.", OFFSET(indicator), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = 
FLAGS },
 
-    { "profile",        "Level of hierarchical motion search",  
OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FRC_PROFILE_HIGH }, FRC_PROFILE_LOW, 
FRC_PROFILE_SUPER, FLAGS, "profile" },
+    { "profile",        "Level of hierarchical motion search",  
OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FRC_PROFILE_HIGH }, -1, 
FRC_PROFILE_SUPER, FLAGS, "profile" },
+    { "auto",           "Select the profile from the input height: "
+                        "super for 1440 lines or more, high otherwise.",    0, 
 AV_OPT_TYPE_CONST, { .i64 = -1 },                  0, 0, FLAGS, "profile" },
     { "low",            "Less levels of hierarchical motion search. "
                         "Only recommended for extremely low resolutions.",  0, 
 AV_OPT_TYPE_CONST, { .i64 = FRC_PROFILE_LOW },    0, 0, FLAGS, "profile" },
     { "high",           "Recommended for any resolution up to 1440p.",      0, 
 AV_OPT_TYPE_CONST, { .i64 = FRC_PROFILE_HIGH },   0, 0, FLAGS, "profile" },
-- 
2.54.0

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

Reply via email to