shaders/colorspace: introduce colorimetric gamut clipping
This change adds some smarter logic than the dumb per-channel clip. We first get rid of negative (e.g. super-red) components by mixing in enough gray until the result is no longer oversaturated, and then we linearly scale all components down to get rid of too-bright values. I experimented briefly with using e.g. BT.2390 tone-mapping instead of a linear scale for the second step, but the results were not significantly better enough to justify the performance hit of BT.2390. I tested this by inspecting the resulting gamut-clipped values on a Yxy chromaticity diagram and confirmed that the resulting color was indeed at the same angle (relative to the white point) as the original, but contained within the gamut (with Y preserved). Subjective comparisons using a wide gamut monitor between the original (unclipped) source and the clipped BT.709 versions of various test clips seem visually pleasing, so I enabled it by default. Fixes #101
Showing
- meson.build 1 addition, 1 deletionmeson.build
- src/colorspace.c 30 additions, 0 deletionssrc/colorspace.c
- src/include/libplacebo/colorspace.h 5 additions, 0 deletionssrc/include/libplacebo/colorspace.h
- src/include/libplacebo/shaders/colorspace.h 7 additions, 0 deletionssrc/include/libplacebo/shaders/colorspace.h
- src/shaders/colorspace.c 26 additions, 3 deletionssrc/shaders/colorspace.c
Loading
Please register or sign in to comment