avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk

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 <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow
2025-10-13 02:37:40 +02:00
parent 00e43619cd
commit a2b47ccfbf
2 changed files with 2 additions and 2 deletions

View File

@@ -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;

View File

@@ -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) {