VB6Hobbyst7 / LinearTransformation

This script performs Linear Transformations based on a matrix conversion. Matrices are made by Francesco Bucciantini (FranceBB)

Home Page:https://forum.doom9.org/showthread.php?t=176091

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LinearTransformation

alt text This script performs Linear Transformations based on a matrix conversion.
The function has two mandatory parameters: Input and Output.
The function also has one optional parameter: Interpolation.
The interpolation parameter can either be set to "Trilinear" or "Tetrahedral" and by default it's set to Tetrahedral as it achieves better results.
Source (left) - Trilinear (center) - Tetrahedral (right): image 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.
Currently, only those conversions are supported:

LinearTransformation(Input="Linear_BT601_NTSC", Output="Linear_BT709")
LinearTransformation(Input="Linear_BT601_PAL", Output="Linear_BT709")
LinearTransformation(Input="Linear_BT709", Output="Linear_BT601_NTSC")
LinearTransformation(Input="Linear_BT709", Output="Linear_BT601_PAL")
LinearTransformation(Input="Linear_BT709", Output="BT2020_HLG")
LinearTransformation(Input="Linear_BT709", Output="BT2100_PQ")
LinearTransformation(Input="Linear_BT709", Output="DCI_XYZ")
LinearTransformation(Input="BT2100_PQ", Output="Linear_BT2020")
LinearTransformation(Input="BT2100_PQ", Output="Linear_BT709")
LinearTransformation(Input="BT2100_PQ", Output="BT2020_HLG")
LinearTransformation(Input="BT2100_PQ", Output="DCI_XYZ")
LinearTransformation(Input="CLog3", Output="Linear_BT709")
LinearTransformation(Input="CLog3", Output="BT2020_HLG")
LinearTransformation(Input="CLog3", Output="BT2100_PQ")
LinearTransformation(Input="SLog2", Output="Linear_BT709")
LinearTransformation(Input="SLog3", Output="Linear_BT709")
LinearTransformation(Input="BT2020_HLG", Output="Linear_BT709")
LinearTransformation(Input="BT2020_HLG", Output="BT2100_PQ")
LinearTransformation(Input="BT2020_HLG", Output="DCI_XYZ")
LinearTransformation(Input="DCI_XYZ", Output="Linear_BT709")
LinearTransformation(Input="DCI_XYZ", Output="BT2020_HLG")
LinearTransformation(Input="DCI_XYZ", Output="BT2100_PQ")
LinearTransformation(Input="LogC", Output="Linear_BT709")
LinearTransformation(Input="VLog", Output="Linear_BT709")
LinearTransformation(Input="ZLog", Output="Linear_BT709")
LinearTransformation(Input="ZLog2", Output="Linear_BT709")
LinearTransformation(Input="dvhe0509", Output="Linear_BT709")

A Linear Transformation is essentially a matrix that maps all points of a certain space to another, which includes of course points belonging to a certain curve to other in order to get a different curve.
Of course, a linear transformation can be used in encoding to map some values to some other values and therefore have conversions from curves like PQ to HLG and so on.
The transformation is performed with 16bit precision, which means that if your input source is lower, let's say, 8bit planar yv12, it will be brought to 16bit planar RGB internally, the linear transformation will be applied with 16bit planar precision and then the result will be brought down to 8bit planar yv12.
Planar RGB 16bit is strongly suggested as your source as it's gonna be faster, in fact 4:2:0, 4:2:2, 4:4:4 planar up to 16bit will be converted back and forth internally.
Inside the plugin, the path specified for the matrices is "mypath" and by default is: mypath = "C:\Program Files (x86)\AviSynth+\LUTs" which means that it's gonna look for my LUTs in a folder in such a location. It's not mandatory to have my LUTs there, you can have them in any location you want, provided that you do update that string.


How to use my LUTs in Avisynth without using the function "Linear Transformation()":
FFVideoSource("example.mxf")
ConvertBits(16)
ConvertToPlanarRGB()
Cube("C:\Programmi\AviSynth+\LUTs\example.cube")

How to use my LUTs in FFMpeg:
ffmpeg.exe -i "source.m2ts" -vf lut3d='example.cube' -c:v whatever -c:a whatever -f mkv "output.mkv"


Who made those LUTs?
Those matrices are made by Francesco Bucciantini (FranceBB), computer science engineer and Linear Algebra lover and Livio Aloja (aligia), former Senior Sky Editor and Encoder, using both free open source tools and closed source ones and cross-checking them with broadcast grade equipment (TVs, waveform monitors, scopes) provided by Sony, Canon and Tektronix.

Who uses those LUTs?
Those LUTs are used by everyone for free, from companies that deal with broadcasting video content in any way (Post-production, OTT, etc) like public and private broadcasters all around the world to regular people that want to convert their video archives.

Compatibility with third party programs:

  • Compatible with Avisynth+
  • Compatible with VapourSynth
  • Compatible with FFMpeg
  • Compatible with AVID Media Composer
  • Compatible with Davinci Resolve
  • Compatible with Adobe Premiere
  • Compatible with Colorfront Transkoder

Slog3 to BT709 SDR 100 nits

image
image image
image image

Slog2 to BT709 SDR 100 nits

image
image image
image image

LogC to BT709 SDR 100 nits

image
image image
image image

DCI P3 to BT709 SDR 100 nits

image
image image

Zlog2 to BT709 SDR 100 nits

alt text
image image

Clog3 to HLG HDR 1000 nits

image
image image

PQ HDR to BT2020 SDR 100 nits

image
image image

BT709 SDR to BT601 SDR

image
image image

Dolby Vision Version 1.0 IPTc2 dvhe0509 (left) to BT709 SDR 100 nits (right)

image
image
image
image
image
image
image
image
image

About

This script performs Linear Transformations based on a matrix conversion. Matrices are made by Francesco Bucciantini (FranceBB)

https://forum.doom9.org/showthread.php?t=176091