From da3e4dfb6f2ed5fbf47e6fbaf5232b72dee29195 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 27 Apr 2017 10:57:09 -0700 Subject: [PATCH] use the exact constant for the gamma transfer function As found in BT2020 reference: https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!!PDF-E.pdf The difference in output-size/PSNR are under the noise level. Change-Id: I42c12000b61dca791226f3af772c5bd9d58201b8 --- src/enc/picture_csp_enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/enc/picture_csp_enc.c b/src/enc/picture_csp_enc.c index 02edfc8f..dfa04295 100644 --- a/src/enc/picture_csp_enc.c +++ b/src/enc/picture_csp_enc.c @@ -171,7 +171,7 @@ typedef uint16_t fixed_y_t; // unsigned type with extra SFIX precision for W #if defined(USE_GAMMA_COMPRESSION) // float variant of gamma-correction -// We use tables of different size and precision for the Rec709 +// We use tables of different size and precision for the Rec709 / BT2020 // transfer function. #define kGammaF (1./0.45) static float kGammaToLinearTabF[MAX_Y_T + 1]; // size scales with Y_FIX @@ -183,8 +183,8 @@ static WEBP_TSAN_IGNORE_FUNCTION void InitGammaTablesF(void) { int v; const double norm = 1. / MAX_Y_T; const double scale = 1. / kGammaTabSize; - const double a = 0.099; - const double thresh = 0.018; + const double a = 0.09929682680944; + const double thresh = 0.018053968510807; for (v = 0; v <= MAX_Y_T; ++v) { const double g = norm * v; if (g <= thresh * 4.5) {