-
-
Notifications
You must be signed in to change notification settings - Fork 134
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**: use more stable range and peak handling #472
Conversation
There’s a typo, it should be |
Can't believe the problem is that simple |
This particular demo is mastered in a way that abuses over-bright colors extensively which means the tone mapped intensity is that high and that's why the full HDR range 10000nit tone mapping looks more natural. In other words, not our issue, but the demo issue. Intel VPP and VideoToolbox will generate a high intensity tonemap as well. The blackout area looks like an overflow to me but I don't see it on my computer... Which code path is that? AVX, SSE, NEON or C? |
Then only the brightness detection like libplacebo can alleviate this problem. But that experience is not good for me either.
AVX/SSE + p010_2_p010 path. I found it with the NVENC encoder. (I haven't tested this on NEON yet)
|
Commercially available videos won't be mastered in such way or at least most of them won't. So this is a minor problem to me.
420p10 path is OK. I rarely test the p010 path though because it is almost useless for current use case. Will look at it later. |
So it is acceptable to me too.
Yeah, currently I only use the p010 path with the HW encoder to accelerate encoding test videos. |
Some code style cleanup to make tonemapx and gpgpu filters consistent. |
We can indeed give it a try. How long ago did they add this change? |
About last year, and is now the default value in gpu-next: haasn/libplacebo@4cadbe7#diff-2e046795c81fb2bcc2667705f88c6421fa988047f147ddb2333ec8da5f638b7bR503 |
Does 1.0 look good enough for most other videos? If so then there is no need to add an extra AVOption. |
We can borrow the |
9e3f40e
to
5126148
Compare
Need to perform bit shift before saturation move to prevent overflow
5126148
to
6cbbce0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove it then. P016 will get overflowed in SIMD registers if we are handling them as int variants. If we ever want to support this use case we need to do a full re-implement that convert it to float and normalize to [0.0,1.0] like the GPUs. |
Not worth the effort, only NVDEC decoding RExt can produce this pixel format, and it's only really 12bit effective. |
How hard would it be to have the reference sdr brightness user settable? |
We are already using 100nit as SDR brightness and we do not recommend users to alter that because players/monitors will apply its own transfer curve for SDR inputs and a higher target peak usually result in bad highlight appearance. |
that's cool to know!! |
The main goal of this PR is to fix the unstable range and peak handling in our current tonemap filters, both software and hardware.
For consistency, now all filters will use 203nit as SDR reference white when tone mapping, and all brightness will be normalized to the same
input / 10
scale. Previously both are only applied to BT.2390 which does not really make sense to make such differences.Software tonemapx filter now handles range better, the difference between TV range and PC range now is fully handled by yuv2rgb and rgb2yuv conversions and all intermediate steps handled are in full range, which both simplified the processing and producing more accurate results. The current yuv and rgb conversion still exhibits some precision loss at highlight areas where the color may appear to "desaturate" itself. To make a more accurate handling we might have to re-write the code path and may introduce extra performance cost, so I want to leave it for future versions.
I also noticed that our current GPU filter implementation handles limited and full range conversion in an unstable manner where the resulted video may look "greener" than it should be and this may be very noticeable on some monitors/tvs. I implemented a new range scaling method for VideoToolbox which does the scaling in RGB instead of in YUV which produces better results.
The port to CUDA and OpenCL is also on the way once I have better internet connection to verify it as I'm currently traveling.Now CUDA and OpenCL also uses this new stabler range conversionTo demonstrate the "green tint", look at the following example with
hable
TMO in maxRGB mode:This is our current implementation
This is the corrected implementation
You may need to have a good enough monitor to tell the greenish tone though.
Changes
Issues
Might fix https://forum.jellyfin.org/t-green-tint-on-some-movies when also ported to cuda and opencl.