1
0
Fork 0

multi-texture-format: Fix limited range quantization

And stop pre-computing values, making errors like this harder to spot.

The values 0.0625 (16/256) and 0.5 (128/256) were slightly off,
resulting e.g. in "black" not being #000000 but #010001 RGB instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3906>

(cherry picked from commit dfa5238bf9)
This commit is contained in:
Robert Mader 2024-07-25 19:13:27 +02:00
parent bb9a2f1ede
commit 1ccf2cfb56

View file

@ -29,9 +29,9 @@ static const char *shader_global_conversions =
"vec4 yuv_to_rgb(vec4 yuva) \n" "vec4 yuv_to_rgb(vec4 yuva) \n"
"{ \n" "{ \n"
" vec4 res; \n" " vec4 res; \n"
" float Y = 1.16438356 * (yuva.x - 0.0625); \n" " float Y = 255.0/219.0 * (yuva.x - 16.0/255.0); \n"
" float su = yuva.y - 0.5; \n" " float su = yuva.y - 128.0/255.0; \n"
" float sv = yuva.z - 0.5; \n" " float sv = yuva.z - 128.0/255.0; \n"
" res.r = Y + 1.59602678 * sv; \n" " res.r = Y + 1.59602678 * sv; \n"
" res.g = Y - 0.39176229 * su - 0.81296764 * sv; \n" " res.g = Y - 0.39176229 * su - 0.81296764 * sv; \n"
" res.b = Y + 2.01723214 * su; \n" " res.b = Y + 2.01723214 * su; \n"