PR #20690 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20690
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20690.patch

The previously used gamma value of 1.961 was derived from the BT.709
OETF, which does not define an EOTF. The proper EOTF was later specified
in BT.1886. This patch updates the approximation to match the BT.1886
EOTF assuming a perfect black level, which corresponds to a pure power
gamma of 2.4.

Fixes: https://github.com/mpv-player/mpv/issues/13438


From 6c6cb15777ae5d4005d2397fb088bffce899ee41 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sun, 3 Aug 2025 20:15:21 +0200
Subject: [PATCH] avutil/csp: correct gamma approximation to match BT.1886 EOTF

The previously used gamma value of 1.961 was derived from the BT.709
OETF, which does not define an EOTF. The proper EOTF was later specified
in BT.1886. This patch updates the approximation to match the BT.1886
EOTF assuming a perfect black level, which corresponds to a pure power
gamma of 2.4.

Fixes: https://github.com/mpv-player/mpv/issues/13438
---
 libavutil/csp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavutil/csp.c b/libavutil/csp.c
index 75ac871616..52a8f01ab1 100644
--- a/libavutil/csp.c
+++ b/libavutil/csp.c
@@ -133,12 +133,12 @@ enum AVColorPrimaries av_csp_primaries_id_from_desc(const 
AVColorPrimariesDesc *
 }
 
 static const double approximate_gamma[AVCOL_TRC_NB] = {
-    [AVCOL_TRC_BT709] = 1.961,
-    [AVCOL_TRC_SMPTE170M] = 1.961,
-    [AVCOL_TRC_SMPTE240M] = 1.961,
-    [AVCOL_TRC_BT1361_ECG] = 1.961,
-    [AVCOL_TRC_BT2020_10] = 1.961,
-    [AVCOL_TRC_BT2020_12] = 1.961,
+    [AVCOL_TRC_BT709] = 2.4,
+    [AVCOL_TRC_SMPTE170M] = 2.4,
+    [AVCOL_TRC_SMPTE240M] = 2.4,
+    [AVCOL_TRC_BT1361_ECG] = 2.4,
+    [AVCOL_TRC_BT2020_10] = 2.4,
+    [AVCOL_TRC_BT2020_12] = 2.4,
     [AVCOL_TRC_GAMMA22] = 2.2,
     [AVCOL_TRC_IEC61966_2_1] = 2.2,
     [AVCOL_TRC_GAMMA28] = 2.8,
-- 
2.49.1

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

Reply via email to