Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th July 2023, 08:56   #141  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Hi everyone,
as a little update, sekrit made a new commit here: https://github.com/sekrit-twc/timecu...4dfd3e75216741
in which he committed the manually written intrinsics in assembly for SSE4.1, AVX2 and AVX512, so that the new tetrahedral interpolation method is no longer limited to the slow C++ code only.
I tested it on my Intel Xeon Gold 6238R and it seems to be working ok, but please test, 'cause the more feedback we can give him, the better.

Here's the new build I made with sekrit's latest changes: vscube_07072023.zip

just like before, inside the package you'll find the normal vscube_x86.dll and vscube_x64.dll compiled with v143 and of course the "special" v141_xp /Zc:threadSafeInit msvc compiled version called "_XP":

- vscube_x86.dll
- vscube_x64.dll
- vscube_XP_x86.dll
- vscube_XP_x64.dll


It's still VapourSynth only, for now, but you can see the development of the thread here and that sekrit is willing to incorporate the Avisynth version into the main repository as soon as someone (perhaps Donald, who also commented on the thread) commits the latest changes required. Anyway, looks like we're finally getting somewhere.

Please test and report back if you find any issues.
FranceBB is offline   Reply With Quote
Old 7th July 2023, 09:38   #142  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,160
Very pleasure if you port it to avs+
kedautinh12 is offline   Reply With Quote
Old 7th July 2023, 12:25   #143  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Quote:
Originally Posted by kedautinh12 View Post
Very pleasure if you port it to avs+
If you're talking to Donald, I'm not sure he regularly checks here, so it might take a while before he sees your post; I was under the impression that he was willing to do it just like the other versions, though, but I'm not him, so I don't know what his intentions are.
If you're talking to me, instead, well, if and only if no one is willing to do it, then I'll try to do it myself ('cause I don't wanna have two people doing the same thing twice xD).
We'll see, but it would be better if everyone was here on Doom9 regularly, so that we didn't have to speculate
FranceBB is offline   Reply With Quote
Old 8th July 2023, 20:14   #144  |  Link
gonca
Registered User
 
Join Date: Jul 2012
Posts: 1,214
I believe he has a test version ready
gonca is offline   Reply With Quote
Old 8th July 2023, 22:04   #145  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Quote:
Originally Posted by gonca View Post
I believe he has a test version ready
You're correct. Donald just released an Avisynth test version: Link

I'll test it on Monday morning as soon as I get back to work and see if the results are consistent with the VapourSynth version.


The new syntax accepts:

Code:
interp: int, 0 = linear, 1 = tetrahedral
like in the VapourSynth version.


By the way, this is applied to a real life football content to go from UHD XAVC Intra Class 300 50p BT2020 HLG 1000 nits to an FULL HD XDCAM-50 25i BT709 SDR 100 nits:


Quote:
#Indexing UHD 50p BT2020 HLG 1000 nits live feed
LWLibavVideoSource("Test_HLG.mxf")

#Screw frame properties
propclearall()

#From 4:2:2 10bit planar Narrow Range to RGB Planar 16bit Narrow Range
z_ConvertFormat(pixel_type="RGBP16", colorspace_op="2020:std-b67:2020:limited=>rgb:std-b67:2020:limited", resample_filter_uv="spline64", dither_type="error_diffusion",
use_props=0)

#From HLG to BT709 with 16bit precision
Cube("A:\LUTs\9c_HLG_BT709_Type3_Display_DownMapping_SuperWhite_nocomp-v1_5.cube", interp=1, fullrange=1)

#From RGB 16bit planar Narrow Range to YUV422 8bit planar Narrow Range with dithering
z_ConvertFormat(pixel_type="YUV422", colorspace_op="rgb:709:709:limited=>709:709:709:limited", resample_filter_uv="spline64", dither_type="error_diffusion", use_props=0)

#Downscaling to FULL HD
SinPowResizeMT(1920, 1080)

#Interlace to 25i
assumeTFF()
separatefields()
selectevery(4,0,3)
weave()

if tests go fine, I'll report back.
Speaking of which, I hope he'll release the source code given that I'll compile the x86 version as well to include it in FFAStrans as I have to support both 64bit and 32bit users as always

Last edited by FranceBB; 11th July 2023 at 16:18.
FranceBB is offline   Reply With Quote
Old 9th July 2023, 00:15   #146  |  Link
kedautinh12
Registered User
 
Join Date: Jan 2018
Posts: 2,160
Latest DGCube
https://www.rationalqm.us/misc/?C=M;O=D
kedautinh12 is offline   Reply With Quote
Old 11th July 2023, 17:01   #147  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Something doesn't feel right.

Quote:
LWLibavVideoSource("K:\4K_Ama\05_DI SERVIZIO - EBU UHD HDR COLOR BARS\EBU_HDR_COLOUR_BARS_2160p_v210.mov")

propClearAll()

z_ConvertFormat(pixel_type="RGBP16", colorspace_op="2020:std-b67:2020:limited=>rgb:std-b67:2020:limited", resample_filter_uv="Spline64", dither_type="error_diffusion", use_props=0)

tetrahedral=Cube("B:\avdb\Server\encoder\encoder\Processors\avs_plugins\LUTs\9c_HLG_BT709_Type3_Display_DownMapping_SuperWhite_nocomp-v1_5.cube", interp=1, fullrange=1).VideoTek()
trilinear=Cube("B:\avdb\Server\encoder\encoder\Processors\avs_plugins\LUTs\9c_HLG_BT709_Type3_Display_DownMapping_SuperWhite_nocomp-v1_5.cube", interp=0, fullrange=1).VideoTek()
donald=DGCube("B:\avdb\Server\encoder\encoder\Processors\avs_plugins\LUTs\9c_HLG_BT709_Type3_Display_DownMapping_SuperWhite_nocomp-v1_5.cube", in="full", out="full", lut="full", interp="tetrahedral").VideoTek()

StackVertical(trilinear, tetrahedral, donald)
They produce three VERY different results.



What I don't understand is why Cube() tetrahedral and DGCube() tetrahedral are so much different.

Souce: https://we.tl/t-xqG6XosULK
Cube_Tetrahedral: https://we.tl/t-GLjsVvJ6Ad
DGCube_Tetrahedral: https://we.tl/t-5L8KCVRfmg
Cube_Trilinear: https://we.tl/t-iBhR03kbFP

Last edited by FranceBB; 11th July 2023 at 17:09.
FranceBB is offline   Reply With Quote
Old 11th July 2023, 17:09   #148  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
Also, DGCube with Tetrahedral is actually the one that gets it right.
In the Cube version, however, it looks like a bit of both versions is applied. You can see the ripples of the trilinear and also the smoothness of the tetrahedral. Why?

Cube Trilinear (rightly showing ripples):


DGCube Tetrahedral (no ripples, actually correct):


Cube Tetrahedral (something in-between, NOT correct):


Cube Tetrahedral is something in between...? O_O
FranceBB is offline   Reply With Quote
Old 11th July 2023, 17:18   #149  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 5,409
Do you get the same results with the vpy vscube version ?
poisondeathray is offline   Reply With Quote
Old 11th July 2023, 18:42   #150  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
@poisondeathray I found the culprit. It's the manually written assembly code for AVX2. I reported it back to both Donald and Sekrit.

The normal C++ code is actually correct.


The SSE4.1 assembly code is also correct.


The AVX2 assembly code is wrong.


The AVX512 assembly code is correct.


So it looks like there's something wrong only in the AVX2 code.
FranceBB is offline   Reply With Quote
Old 14th July 2023, 08:45   #151  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,958
new version by Donald and Sekrit for Avisynth with the AVX2 code fixed: Link

Quote:
Changelog

v1.4
2023/07/12
Added tetrahedral interpolation.

v1.3
2022/01/21
Updated to timecube version 1.3 base code.
Added frame properties passthrough.
Updated the help document.

v1.1
2019/01/25
Rather than upgrade to r2a I ported the fullrange fix only.

v1.0
2018/08/16
Initial release
Usage:

Quote:
Cube (clip, string "cube", int "cpu", int "interp", int "fullrange")

clip =
Input clip; the filter receives and delivers the RGBP16 color space.

string cube = ""
Full path of the 3D LUT file. This must be an Adobe *.cube file.

int cpu = INT_MAX
cpu: default INT_MAX, which selects best SIMD.
0 : SIMD_NONE
1 : SIMD_SSE41
2 : SIMD_AVX2
3 : SIMD_AVX512

int interp = 0
interp: default 0 selects the worse interpolation method for backwards compatibility reasons.
0 : trilinear interpolation
1 : tetrahedral interpolation


int fullrange = 1
0 : limited range
1 : full range

Trilinear vs Tetrahedral:

Trilinear interpolation is used by default only for historical reasons.
When Cube() was first developed it only had one interpolation method, namely trilinear.
Although this was far from ideal as it can produce ripples, plenty of people used it (as they were using this function), therefore when tetrahedral was introduced it was agreed to leave trilinear as default to allow people to still obtain the same results when upgrading the version.
However, in practice, tetrahedral should always be used and it's the suggested method.

Source (left) - Trilinear (center) - Tetrahedral (right):




As you can see, in the right hand side waveform (tetrahedral) there are no ripples, unlike the ones you can see in the trilinear interpolation at the center.



Usage example:

Example 1:


Quote:
#Indexing
LWLibavVideoSource("Z:\00_INGEST_MAM\ENCODER\BACKUP LIVIO\SAMPLE-NEW\Sky UK HDR HLG Test Pattern\T3_LUT_LP_UHD_BT2020_50_v210.mov")

propClearAll()

#From Limited Range 10bit YUV422 to 16bit Limited Range Planar RGB
z_ConvertFormat(pixel_type="RGBP16", colorspace_op="2020:std-b67:2020:limited=>rgb:std-b67:2020:limited", resample_filter_uv="Spline64", dither_type="error_diffusion", use_props=0)

#From BT2020 HLG to BT709 SDR
Cube("\\avdb\Server\encoder\encoder\Processors\avs_plugins\LUTs\9c_HLG_BT709_Type3_Display_DownMapping_SuperWhite_nocomp-v1_5.cube", interp=1, fullrange=1)

#From 16bit Limited Range Planar RGB to Limited Range 10bit YUV422 with dithering
z_ConvertFormat(pixel_type="YUV422P10", colorspace_op="rgb:709:709:limited=>709:709:709:limited", resample_filter_uv="Spline64", dither_type="error_diffusion", use_props=0)


Example 2:


Quote:
# Source
DGSource("THE GREAT WALL.dgi")

# From Limited Range 10bit YUV420 to 16bit Full Range Planar RGB
z_ConvertFormat(pixel_type="RGBP16", colorspace_op="2020:st2084:2020:limited=>rgb:st2084:2020:full", dither_type="error_diffusion")

# From PQ to HLG
Cube("PQ_to_HLG.cube", fullrange=1, interp=1)

# From 16bit Full Range Planar RGB to Limited Range 10bit YUV420 with dithering
z_ConvertFormat(pixel_type="YUV420P10", colorspace_op="rgb:std-b67:2020:full=>2020:std-b67:2020:limited", dither_type="error_diffusion")

Last edited by FranceBB; 14th July 2023 at 08:48.
FranceBB is offline   Reply With Quote
Reply

Tags
3dl, cube, hdr, lut, sdr

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.