Commit 4c36dae9 by huangdarwin Committed by microkatz

HDR: Clamp YUV to RGB conversion.

Manually tested using transformer demo HLG videos. Before this CL, RGB values after the YUV to RGB conversion reached up to 1.025. After this CL, RGB values correctly clamp at 1.0.

PiperOrigin-RevId: 468426092
(cherry picked from commit 32ee4480)
parent c65acc04
...@@ -63,7 +63,7 @@ highp vec4 hlgOetf(highp vec4 hlgColor) { ...@@ -63,7 +63,7 @@ highp vec4 hlgOetf(highp vec4 hlgColor) {
/** Convert YUV to RGBA. */ /** Convert YUV to RGBA. */
vec4 yuvToRgba(vec3 yuv) { vec4 yuvToRgba(vec3 yuv) {
const vec3 yuvOffset = vec3(0.0625, 0.5, 0.5); const vec3 yuvOffset = vec3(0.0625, 0.5, 0.5);
vec3 rgb = uYuvToRgbColorTransform * (yuv - yuvOffset); vec3 rgb = clamp(uYuvToRgbColorTransform * (yuv - yuvOffset), 0.0, 1.0);
return vec4(rgb, 1.0); return vec4(rgb, 1.0);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment