Skip to content

Commit

Permalink
gpu: fix loss of precision with HDR videos on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiou87 authored and sixones committed Feb 15, 2024
1 parent 2745a05 commit 15ca266
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions video/out/gpu/video_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,13 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc)
gl_sc_bvec(sc, 3));
break;
case MP_CSP_TRC_PQ:
GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", PQ_M2);
GLSLF("color.rgb = max(color.rgb - vec3(%f), vec3(0.0)) \n"
" / (vec3(%f) - vec3(%f) * color.rgb);\n",
gl_sc_paddf(sc, "highp vec3 pq_rgb;");
GLSLF("pq_rgb = color.rgb;\n");
GLSLF("pq_rgb = pow(pq_rgb, vec3(%f));\n", 1.0/PQ_M2);
GLSLF("pq_rgb = max(pq_rgb - vec3(%f), vec3(0.0)) \n"
" / (vec3(%f) - vec3(%f) * pq_rgb);\n",
PQ_C1, PQ_C2, PQ_C3);
GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", 1.0 / PQ_M1);
GLSLF("color.rgb = pow(pq_rgb, vec3(%f));\n", 1.0/PQ_M1);
// PQ's output range is 0-10000, but we need it to be relative to
// MP_REF_WHITE instead, so rescale
GLSLF("color.rgb *= vec3(%f);\n", 10000 / MP_REF_WHITE);
Expand Down

0 comments on commit 15ca266

Please sign in to comment.