haasn / libplacebo

Official mirror of libplacebo
http://libplacebo.org/
GNU Lesser General Public License v2.1
568 stars 72 forks source link

hdr tonemapping: auto desaturation patch breaks the image in dark scenes (scale down saturation when raising brightness) #304

Open geextahslex opened 4 days ago

geextahslex commented 4 days ago

Hi, I have this issue with hdr tonemapping tone-mapping=st2094-10 in dark scenes. Bright scenes look fine but very dark scenes get more and more desaturated which looks weird. Have someone found a fix for this? The only thing the fixes this is vf=format=sig-peak=4.926 but this also disables any dynamic of brightening and darkening the image accordingly to the nits information hdr-compute-peak=yes From my understanding this patch is causing this https://code.videolan.org/videolan/libplacebo/-/merge_requests/477/diffs

My suggestion would be to add an percantage option to this function, so you can turn it on, off or fine-tune it to your liking.

Thanks for any help :)

The image should look like this normal

but it looks like this, almost black and white broken

normal normal3

washed out washed out

haasn commented 4 days ago

Does --target-contrast=inf help at all?

geextahslex commented 4 days ago

With target-contrast=inf it looks even worse. You get more color but it messes up the contrast/black levels, it looks complete flat. target inf

geextahslex commented 3 days ago

Hey sorry for bothering you. Thanks for the patch that you have made, I have tested it and at this point I am a bit confused. After further testing there are scenes (very dark) that indeed profit from this desaturation function, but there are also scenes (like mentioned here above) that are desaturated unnecessarily. I'm not sure if the curve, threshold or the values would have to be finetuned. Let me know what you think about it. I would like to help with testing etc.

So affecting a dark scene like this would be good

without desaturation, the red on his face and the blacks overall is not so nice sat banks

with desaturation sat banks good

and leaving a brighter scene like this unaffected broken

geextahslex commented 2 days ago

I don't know which values are used internally but from an srgb perspective I would say put the threshold at 5/255srgb. This would desaturate the first scene and leave the 2nd scene saturated/normal I use target-peak=100 so I don't know how this srgb value would scale but you get the idea.

srgb threshold 5/255 srgb low2

srgb high

srgb low23

haasn commented 1 day ago

Internally we work in IPT intensity units (I), so there's unfortunately very little correlation with sRGB values.

geextahslex commented 1 day ago

Okay I understand, so for now please cancel the patch that you have made and you could look at the Feature Request that I have made. This could be a solution until there is a better way to handle this brightening issue. I would just like to disable the upward/brightening part of this function because downward/darkening looks fine.