PR #20650 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20650
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20650.patch


>From 7f9a5438fe3589eb33189f3f91a32021f6b2326f Mon Sep 17 00:00:00 2001
From: Niklas Haas <[email protected]>
Date: Mon, 6 Oct 2025 14:06:30 +0200
Subject: [PATCH] libavfilter/vf_libplacebo: add `temperature` option

---
 doc/filters.texi            | 5 +++++
 libavfilter/vf_libplacebo.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 262e7ad009..5863041d1a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16795,6 +16795,11 @@ coefficients for RGB inputs.
 @item gamma
 Gamma adjustment, between @code{0.0} and @code{16.0}. Defaults to @code{1.0}.
 
+@item temperature
+Color temperature adjustment. Lower values make the output warmer/redder,
+down to @code{1667}, while higher values make the output cooler/bluer, up to
+@code{25000}. Defaults to @code{6500} (neutral white).
+
 @item cones
 Cone model to use for color blindness simulation. Accepts any combination of
 @code{l}, @code{m} and @code{s}. Here are some examples:
diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c
index 2b3738c8e0..2d8dd29be0 100644
--- a/libavfilter/vf_libplacebo.c
+++ b/libavfilter/vf_libplacebo.c
@@ -261,6 +261,7 @@ typedef struct LibplaceboContext {
     float saturation;
     float hue;
     float gamma;
+    float temperature;
 
     /* pl_peak_detect_params */
     int peakdetect;
@@ -446,6 +447,8 @@ static int update_settings(AVFilterContext *ctx)
         .saturation = s->saturation,
         .hue = s->hue,
         .gamma = s->gamma,
+        // libplacebo uses a normalized/relative scale for CCT
+        .temperature = (s->temperature - 6500.0) / 3500.0,
     };
 
     opts->peak_detect_params = *pl_peak_detect_params(
@@ -1723,6 +1726,7 @@ static const AVOption libplacebo_options[] = {
     { "saturation", "Saturation gain", OFFSET(saturation), AV_OPT_TYPE_FLOAT, 
{.dbl = 1.0}, 0.0, 16.0, DYNAMIC },
     { "hue", "Hue shift", OFFSET(hue), AV_OPT_TYPE_FLOAT, {.dbl = 0.0}, -M_PI, 
M_PI, DYNAMIC },
     { "gamma", "Gamma adjustment", OFFSET(gamma), AV_OPT_TYPE_FLOAT, {.dbl = 
1.0}, 0.0, 16.0, DYNAMIC },
+    { "temperature", "Color temperature adjustment (kelvin)", 
OFFSET(temperature), AV_OPT_TYPE_FLOAT, {.dbl = 6500.0}, 1667.0, 25000.0, 
DYNAMIC },
 
     { "peak_detect", "Enable dynamic peak detection for HDR tone-mapping", 
OFFSET(peakdetect), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DYNAMIC },
     { "smoothing_period", "Peak detection smoothing period", 
OFFSET(smoothing), AV_OPT_TYPE_FLOAT, {.dbl = 100.0}, 0.0, 1000.0, DYNAMIC },
-- 
2.49.1

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

Reply via email to