From a2b47ccfbf7fe68de9405e4a113ee4c2f05f1fc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 13 Oct 2025 02:37:40 +0200 Subject: [PATCH] avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is how images encoded with specific transfer function should be viewed. Image viewers that doesn't support named trc metadata, will fallback to simple gAMA value and both of those cases should produce the same image apperance for the viewer. Fixes: https://github.com/mpv-player/mpv/issues/13438 Signed-off-by: Kacper Michajłow --- libavcodec/pngenc.c | 2 +- libavformat/movenc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c index 07f5452157..96894bf7fd 100644 --- a/libavcodec/pngenc.c +++ b/libavcodec/pngenc.c @@ -323,7 +323,7 @@ static int png_get_chrm(enum AVColorPrimaries prim, uint8_t *buf) static int png_get_gama(enum AVColorTransferCharacteristic trc, uint8_t *buf) { - double gamma = av_csp_approximate_trc_gamma(trc); + double gamma = av_csp_approximate_eotf_gamma(trc); if (gamma <= 1e-6) return 0; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7d5d8f27e2..eabc1b95ca 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2523,7 +2523,7 @@ static int mov_write_gama_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra { uint32_t gama = 0; if (gamma <= 0.0) - gamma = av_csp_approximate_trc_gamma(track->par->color_trc); + gamma = av_csp_approximate_eotf_gamma(track->par->color_trc); av_log(s, AV_LOG_DEBUG, "gamma value %g\n", gamma); if (gamma > 1e-6) {