mpv-player/mpv — pull request #616 by nandykins (2014-03-05 16:22:40+00:00)
Title: vo_opengl: Simplify, clarify and update color management

This commit:

- Changes some of the variable names for clarification and adds comments
where appropriate
- Unifies :srgb and :icc-profile, making them fit into the same step of
the decoding process and removing the weird interactions between both
of them.
- Makes :srgb and :icc-profile mutually exclusive. When both are used, a
warning is shown and :icc-profile takes precedence.
- Moves BT709 decompanding (approximate or actual) to the shader in all
cases, making it happen before upscaling (instead of the old 0.45
gamma function). This is the simpler and more proper way to do it.
- Enables the approx gamma function to work with :srgb as well as with
:icc-profile as a result of these changes (since they share the gamma
expansion code now).
- Renames :icc-approx-gamma to :approx-gamma since it is no longer tied
to the ICC options or LittleCMS.
- Uses gamma 2.4 as input space for the actual 3DLUT, this is now a
pretty arbitrary factor but I picked 2.4 mainly because a higher pure
power value here seems to produce visually better results with wide
gamut profiles, rather than the previous 1.95 or BT.709.
- Adds the input gamma curve to the 3dlut cache header in case we change
it more in the future, or even make it user customizable (though I
don't see why the latter would really be necessary)
- Fixes the OSD's gamma when using :srgb, which was previously using the
old (0.45) approximation in all cases.
- Updates documentation on :srgb and :icc-profile and :approx-gamma to
reflect their new usage and behavior. In particular, :srgb was still
referencing behavior from over a year ago.
- Updates gl_check_features to check for the presence of the correct
extensions, up to date with the new :srgb and :icc-profile feature
dependencies.

This commit should serve to make the CMS code somewhat more accessible
and less confusing/error-prone, and simultaneously also improve the
appearance of 3DLUTs with wide gamut color spaces. It might also
positively impact performance when using :srgb due to less intermediate
conversion steps.

I would have liked to make it more modular but almost all of these
changes are interdependent, save for the documentation updates.

Note: I'm not sure how well this works together with real-world
subtitles that may need to be color corrected as well. I'm not sure
whether :approx-gamma needs to apply to subtitles as well. I'll need to
test this on proper files later.