Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avfilter/tonemap*: add ICtCp based tonemap method #430

Merged
merged 2 commits into from
Aug 10, 2024
Merged

Conversation

gnattu
Copy link
Member

@gnattu gnattu commented Aug 8, 2024

This adds ICtCp based tonemap to OpenCL, Metal and CUDA based tonemap filters, and will use the mode as the new default. On GPUs with lower specs, OpenCL and CUDA implementation will default to relative luminance mode. The Metal implementation does not have a performance tradeoff mode and will always default to ICtCp mode.

This also fixed attachment related issue on Metal when output is 10bit by always setting the attachement values.

The ICtCp mode's desat algorithm is different from other modes. The coefficient applied to the chroma is defined by a Gaussian Function in the form:

$$f(I) = \exp\left(\frac{-\left(I-\frac{L_{\text{target}} - p_{\text{desat}}}{2}\right)^2}{2L_{\text{peak}}}\right)$$

Where $I$ is the ICtCp intensity linearized by ST2084 EOTF, $p_{\text{desat}}$ is the desat parameter, $L_{\text{target}}$ is the target peak luminance (1.0 for SDR) and $L_{\text{peak}}$ is the HDR peak luminance for current frame.

The current curve is tuned to preserve more color detail to preserve natural looking than to aggressively turning bright colors into white, and is different from the initial curve implemented in #429.

Original
image

desat=0.5 in #429
image

desat=0.5 current
desat_itp_g2

This curve is not a standardized practice and is purely my own creation, which means it could lead to unpleasant results for certain cases I've not tested on.

Changes

Issues

Fixes #429

This adds ICtCp based tonemap to OpenCL, Metal and CUDA based
tonemap filters, and will use the mode as the new default. On GPUs
with lower specs, OpenCL and CUDA implementation will default to
relative luminance mode. The Metal implementation does not have a
performance tradeoff mode and will always default to ICtCp mode.

This also fixed attachment related issue on Metal when output is
10bit by always setting the attachement values.
@gnattu gnattu requested a review from a team August 8, 2024 04:36
Co-authored-by: Nyanmisaka <nst799610810@gmail.com>
@gnattu gnattu merged commit 24345c4 into jellyfin-7.0 Aug 10, 2024
@gnattu gnattu deleted the tonemap-7.0 branch August 10, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants