Asd-g / avslibplacebo

AviSynth+ libplacebo.
GNU General Public License v3.0
25 stars 2 forks source link

Load RPU? #3

Closed Dogway closed 1 year ago

Dogway commented 1 year ago

I was playing with libplacebo_Tonemap() to convert a DVp5 to SDR 709. I got it to work by loading with FFMS2 and adding the DoViBaker plugin to AVS+ path:

ConvertBits(16)
ConverttoYUV444()
libplacebo_Tonemap(src_csp=3, dst_csp=0, tone_mapping_crosstalk=0.02, use_dovi=true, gamut_mode=3)
SMPTE_legal(true)
ConvertBits(8,dither=1)

But I'm still wondering, libplacebo_Tonemap() expects RPU related frame properties:

FFMS2 creates only the DolbyVisionRPU frameprop, with a value of "[][][]", but still loads, while DGIndexNV fails requiring said frameprop.

How do I load the above properties from the RPU? DoViBaker() fails loading the RPU with an error dialog saying "Expecting profile 7 RPU data". And MaxCLLFindAVS is an external tool.

EDIT: Looks like this only happens with certain clips while with others FFMS2 will load the above props. I was testing with these samples.

Asd-g commented 1 year ago

For DV profile 5 DoViBaker isn't required at all.

Using the latest lsmashsource is also working (there is DolbyVisionRPU prop).

libplacebo_Tonemap parses the RPU with dovi_tool. You can take a look at the dovi_tool.exe - to extract RPU.bin and then to parse the extracted file.

Dogway commented 1 year ago

libplacebo_Tonemap parses the RPU with dovi_tool. You can take a look at the dovi_tool.exe - to extract RPU.bin and then to parse the extracted file.

Yes, dovi_tool.exe parses the RPU but it's an external tool, so I can't populate frameprops

Using the latest lsmashsource is also working (there is DolbyVisionRPU prop).

Thank you. My goal was to use DGSource() since the intention was to decode at playback

Asd-g commented 1 year ago

I can take a look and eventually create a simple plugin that can just set the mentioned frame properties from the DolbyVisionRPU frame property. If I understand you correctly, this wouldn't help you because DGSource doesn't set DolbyVisionRPU frame property (I never used DGSource and don't know what frame properties are set)?

Dogway commented 1 year ago

Yes, CPU bound loaders are slow so with my CPU (4790-K) the whole decoding pipeline runs at about 24.35fps with some trickery. Maybe an option to directly parse the extracted RPU.bin from libplacebo_tonemap() could help, but I'm not sure how feasible it is.

Asd-g commented 1 year ago

Lsmashsource has an option to use hwdec. Did you try it?

Maybe an option to directly parse the extracted RPU.bin from libplacebo_tonemap() could help, but I'm not sure how feasible it is.

I'm still not sure what's your goal. You want those frame props after libplacebo_tonemap in order to perform some post filtering after it (libplacebo_tonemap) or you want them (those frame props) in order to replace libplacebo_tonemap with your own tonemapping?

Dogway commented 1 year ago

I wasn't aware of 'hwdec' arg, although as I read it relies on CUVID which is a deprecated API, then fallsback to QuickSync.

I only could open the file with LWLibavVideoSource("clp",prefer_hw=3) but then libplacebo_tonemap() errors out with the RPU flag missing. In any case, simply playing back the video with the source loader didn't feel too fast.

Currently my goal is to use a fast loader like DGSource() so I can play the video at least in real-time (IPTPQc2 decoding) in MPC-HC.

Also looking forward for a viable fast conversion/decoding in the future. I've been working on it for a year and a half with RGB_to_ICtCp()/ICtCp_to_RGB(), my implementation works fine now for some videos, but fails on others prolly due to missing NLQ (or MMR) reshaping. IPTPQc2 is the most advanced bitrate saving model (~10% when encoded at 12-bits HEVC) so I'm looking forward on using it heavily to reduce size on UHD material.

I'll be implementing my own HDR stats with ScenesPack so no need for the frameprops. No fuss, I will wait until DGDecNV implements RPU parsing.