SIGN IN SIGN UP

Fix PQ tone-mapping NaNs by clamping in GLSL.

Wide-gamut PQ colors can map to negative BT.709 components during tone-mapping.
Passing negative values to non-linear OETFs (like Gamma 2.2) causes NaNs in GLSL.
This change clamps the lower bound to 0.0 to prevent NaNs, and clamps the upper bound to 1.0 when tone-mapping to SDR.

Also added a pixel test to verify tone-mapping of out-of-gamut PQ colors matches the golden image.

Fixes https://github.com/androidx/media/issues/3314

PiperOrigin-RevId: 944394967
(cherry picked from commit 00352c583fc76b7ab14dd4ad1628a5ccb0512e56)
D
dancho committed
d328bd072097e23976ef224d43188070a5306eee
Parent: b47fe29
Committed by Tianyi Feng <tianyifeng@google.com> on 7/8/2026, 10:20:36 AM