Lypheo / vs-placebo

libplacebo-based debanding, scaling and color mapping plugin for VapourSynth
GNU Lesser General Public License v2.1
73 stars 13 forks source link

tonemap: Add Dolby Vision support #15

Closed quietvoid closed 2 years ago

quietvoid commented 2 years ago

Note: This does break the placebo.Tonemap API, but it was done to simplify the source/destination colorspaces. So I'm making this a WIP for review, do what you will.

Normally the libdovi guard works fine, and requires https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision.

dovi_meta.h was shamelessly copied from libplacebo (though I did parts of the original code). Other changes include allowing both RGB/YUV 16 bits inputs.

Since the metadata changes by frame, I opted to pass it around in the function arguments. However this is bad because there's no guard for the pl_dovi_metadata struct, which is only available in v4.157.0.185.

So this is still a WIP.

quietvoid commented 2 years ago

Guards should be working fine now, and I refactored so that it builds on v4.157.0.

quietvoid commented 2 years ago

Will merge this after I figure out how to build for Windows.

alexdns1 commented 2 years ago

I can't get the same results with vs-placebo that i get with plplay demo app from libplacebo with any Dolby Vision source. Im doing a simple tonemap and the images are over-darkened and colours are highly saturated. Im doing a simple placebo.Tonemap(clip,src_csp=3,dst_csp=0,dynamic_peak_detection=False); Should i be adding anything else to get the same results as plplay ? My FFMPEG is from git. My FFMS2 is from this pull request. My libplacebo is from git. Libdovi is from git.

quietvoid commented 2 years ago

There are most likely differences in the defaults with plplay. Your description isn't really useful without comparing the same tonemapping params.

alexdns1 commented 2 years ago

There are most likely differences in the defaults with plplay. Your description isn't really useful without comparing the same tonemapping params.

How are you testing that it produces the right output then ? What do you match it against ? I tried every possible tonemapping parameter and i still get over-darkened and highly saturated colours

quietvoid commented 2 years ago

I compared the profile 5 PQ output to an existing HDR10 reference, both then tonemap to SDR the same. I'm definitely getting the same SDR output from both plplay and vs-placebo, so I don't know why you're getting significantly different results.

alexdns1 commented 2 years ago

Do you add any special params to placebo.Tonemap to get the same output as plplay ?

quietvoid commented 2 years ago

No. Here's my script:

clip = core.ffms2.Source("cosmos-p5.mkv")

clip = vsutil.depth(clip, 16)
clip = core.placebo.Tonemap(clip, dynamic_peak_detection=False, src_csp=3, dst_csp=0)
alexdns1 commented 2 years ago

That is exactly what im doing .... have you tried different files than cosmos-p5.mkv ? I tried multiple P5 both in mp4 and mkv and i get the same results It's like gamma is raised in plplay from 1 to 1.2 and saturation from 1 to 1.1 - that's the best i can describe what is happening to match vs-placebo's output These tests were performed on different linux machines and distros and they all are the same - over-darkened and over-saturated colours If its some plplay option that is not default in vs-placebo that is weird because you are getting the same output

alexdns1 commented 2 years ago

Hey can you give me a link to cosmos-p5.mkv so i can check with your source to make sure its not a source issue on my side ?

quietvoid commented 2 years ago

It's available in the zip archive from here: https://code.videolan.org/videolan/libplacebo/-/merge_requests/207#note_293893

alexdns1 commented 2 years ago

With your file cosmos-p5.mkv it looks the same vs-placebo and plplay. No clue why my sources don't work

quietvoid commented 2 years ago

Looks like I'll figure Windows out later. Gonna merge this so I can fix builds for libplacebo API 190.