Asd-g / avslibplacebo

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

Accept 420 in tonemapping #7

Closed tormento closed 1 year ago

tormento commented 1 year ago

Would be possible to accept and output 420 too where 444 is needed?

As the player that uses libplacebo accepts it, perhaps it could be a fast implementation.

Internal GPU conversion and processing could be way faster, I suppose.

Thanks ;)

Asd-g commented 1 year ago

You can use 420 input. If you want 420 output and want the subsampling be done with GPU, try libplacebo_Resampling for chroma only.

I don't have a plan to implement internal 444->420 conversion.

tormento commented 1 year ago

You can use 420 input. If you want 420 output and want the subsampling be done with GPU, try libplacebo_Resampling for chroma

I am interested in 420 for tone mapping. Can I replace the two zlib with libplacebo resampling, forth and back? Can you please show me the proper usage for just 420 to 444 conversion and back?

Asd-g commented 1 year ago

The input of libplacebo_Tonemap can be 420. With the latest version 1.4.0 you can specify the used kernel for 420->444 with cscale.

The following scripts are two methods for 444->420 after libplacebo_Tonemap. You can benchmark them to see if you gain any fps.

libplacebo_Tonemap(...)
y=ExtractY()
a=libplacebo_Resample(Width()/2, Height()/2, filter=x, sx=-0.5) # sx for top_left->left chroma location
CombinePlanes(y, ExtractU(a), ExtractV(a), planes="yuv", pixel_type="yuv420p16")
libplacebo_Tonemap(...)
y=ExtractY()
u=libplacebo_Resample(ExtractU(), Width()/2, Height()/2, filter=x, sx=-0.5)
v=libplacebo_Resample(ExtractV(), Width()/2, Height()/2, filter=x, sx=-0.5)
CombinePlanes(y, u, v, planes="yuv", pixel_type="yuv420p16")
tormento commented 1 year ago

Will try ASAP and report results. Thank you!

Asd-g commented 1 year ago

The attached test version has additional parameter libplacebo_Tonemap(lut="path_to_cube_file") in order to use lut (.cube) for tonemapping. You can try it.

avs_libplacebo.zip

tormento commented 1 year ago

Wow! Does it use tetrahedral or trilinear interpolation?

Now, it would be REALLY GREAT to have the capability to directly apply to 420 in to 420 out, i.e. from UHD PQ to BD HLG, without having to use CPU at all for conversions. You would make a lot of people really happy.

Asd-g commented 1 year ago

It's tetrahedral.

tormento commented 1 year ago

Great!