shaders/icc: set icc transfer to closest value
Merge request reports
Activity
264 264 pl_unreachable(); 265 265 } 266 266 267 float pl_color_transfer_approx_gamma(enum pl_color_transfer trc) I would prefer not exposing this publicly - it's very specific to ICC, both in its ignorance of how to handle this for HDR, and its general low usability outside the very specific context of needing to measure/estimate the gamma of a look-up table. It also invites using inaccurate approximations.
Edited by Niklas Haas
407 407 best = pl_raw_primaries_get(icc->containing_primaries); 408 408 } 409 409 410 icc->csp.transfer = PL_COLOR_TRC_GAMMA18; 411 for (enum pl_color_transfer trc = PL_COLOR_TRC_GAMMA18; trc <= PL_COLOR_TRC_GAMMA28; trc++) { 412 if (fabsf(icc->gamma - pl_color_transfer_approx_gamma(icc->csp.transfer)) > 413 fabsf(icc->gamma - pl_color_transfer_approx_gamma(trc))) 414 { 415 icc->csp.transfer = trc; True, but it's the price you pay for this feature actually being useful. 9 times out of 10, the most interesting thing about a profile is whether it's BT.1886, gamma 2.2 or sRGB. This methodology cannot even resolve that distinction because both are hard-coded to 2.2, so it'll use the numerically first one. Not good design IMO.
I think I'll just go ahead and make a C implementation of the TRCs, it's useful anyway
Well, if we want it to be able to apply the HLG OOTF, it needs to handle all three channels at the same time:
void pl_color_linearize(const struct pl_color_space *csp, float color[3]); void pl_color_delinearize(const struct pl_color_space *csp, float color[3]);
That way it can be the natural mirror of
pl_shader_(de)linearize
, with no unexpected surprises.
As a side note, you may be interested in this:
https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavcodec/fflcms2.c#l302
It might actually be easier to re-use the Little-CMS implementation of these transfer functions for our purposes as well. But I feel like a generic C function would be more interesting/useful long-term.
Edited by Niklas Haasmentioned in commit haasn/libplacebo@e0515e92
mentioned in commit haasn/libplacebo@e5151770
mentioned in commit haasn/libplacebo@cb228d74
mentioned in commit 2617a3c1