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

Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 8th May 2021, 11:55   #1  |  Link
Registered User
Join Date: Nov 2009
Posts: 1,950
Transforms Pack v1.0 RC18

Transforms Pack

GitHub: TransformsPack.v1.0.RC18.avsi

As a color geek myself I waited and waited through the years for AviSynth to catch up, but dissapointed to see almost no progress on the area aside from the old cretindesalpes' Dither tools I decided to create and port part of my work from last year.
The Transform Pack is a set of functions for color managing AviSynth+. From function transforms like proper and performant piecewise gamma functions (EOTF, OETF) to color gamut conversion and white point mapping with kelvin temperature inputs (this last in Grade pack).
While on it I also created YUV<->RGB conversion functions to expand on its possibilities like new matrix coefficients or chroma resamplers, and an array of building block Matrix operators.

So what differentiates this from the Dither tools or other solutions like avsresize?
To start with it has no dependencies, everything is done with internal expressions so it's faster than say the Dither tools along supporting HBD out of the box.
Compared to avsresize, it's 38% the speed of it for this first version, but in opposition it's easier to use, more straight forward, the code is simple to understand and fix, includes more color spaces and finally more accurate conversions (derivations and higher float precision constants).

v1.0 focuses on SDR color spaces, v2.0 will target HDR and tonemappers.

Description of the main functions:

ColorSpace(): Full featured color space conversion filter. Includes novel spaces like DCI-P3 (Theater), ACES2065 or ACEScg aside from AdobeRGB. Automatically does gamut and gamma conversions and matrix strings use a lazy mode input so you don't have to remember exactly the string name to use.

Display_Referred(): Very similar to ColorSpace() except it's designed to convert the video working space into your display space, with an option to input a .cube 3D LUT from your calibration software. Also includes arguments to control the up format conversion kernel along the b, c, and p coefficients for the upsampler.

ConvertFormat(): If you don't pretend to change colorimetry and only want to convert formats like RGB<->YUV or YUV <->YUV this function is best suited. It supports a fast version of feisty2's chroma reconstruction filter and allows to set resampling kernel with aliases; catrom, mitchell, hermite, etc. It's planned to replace LinearResize(), so upscaling/downscaling in HBD and linear light (or other spaces) can be achieved while reconstructing chroma at the same time optionally.

moncurve_f/moncurve_r: EOTF, OETF. Optimized piecewise gamma transfer functions from AMPAS that only require the alpha coefficient, beta and phi are properly derived in float precision.

Also includes YUV_to_RGB(), RGB_to_YUV(), YcCbcCrc_to_RGB(), RGB_to_YcCbcCrc(), RGB_to_XYZ(), XYZ_to_RGB(), matrix operators (invert, transpose, divide, multiply, dot, cross...) and some more helper functions.

Speed comparison on a i7-4790K non-OC (only gamut conversion) with Prefetch(6):

The main performance limiter in ColorSpace() is the use of 7 lutxyz and 2 lutxy expressions. Any improvement in speed in said AviSynth+ internal expression function or even its support for GPU processing will translate in a massive increase in speed.

Dither tools (but no color space/primaries conversion)
Dither_convert_yuv_to_rgb (matrix="601", output="rgb48y", lsb_in=true, tv_range=true)
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv (r, g, b, matrix="709", tv_range=true, lsb=true, mode=6, output="YV12")
HDRTools (scarce in options, not user friendly)
ConvertXYZtoYUV(Color=2,pColor=2) # Color=3 was noop, strange logic
62fps (Prefetch 8) (33fps in 32-bit)
ConvertFormat(1,1,"420","601","709",true,true,true,noring=false, scale_space="gamma",kernel="mitchell")
FrancesBB LUTs
82fps (scarce in options)
Cube("C:\Program Files (x86)\AviSynth+\LUTs\BT601_NTSC_to_BT709.cube")
# LinearTransformation("Linear_BT601_NTSC", "Linear_BT709") # AIO pack for above, but misses the format conversion matrices.
avsresize (not 32-bit or RGB friendly)
160fps (version r7 not working with AVSmeter)
z_ConvertFormat(pixel_type="YUV420P16",colorspace_op="601:601:170M:l=>709:601:709:l", dither_type="none")
HDR Core
244fps (also scarce in options)
Matrix(from=601, to=709, rg=1.0, gg=1.0, bg=1.0, a=16, b=235, ao=16, bo=235, bitdepth=16)

YUV 420 to RGB conversion benchmark:
300 fps z_ConvertFormat(pixel_type="RGBP16",colorspace_op="709:auto:auto:l=>rgb:same:same:f",resample_filter ="bicubic",filter_param_a=0.333,filter_param_b=0.333)
188 fps ConvertToPlanarRGB(matrix="Rec709")
164 fps YUV_to_RGB("709",kernel="mitchell")
135 fps ConvertYUVtoLinearRGB(Color=2) # no gamma reencode output

  • Fix/assess chroma placement
  • v2.0. Update AP1 and AP0 transformation matrices and include the RRT
  • v2.0. Add PQ and HLG functions and tonemappers (2446, Log flavours, Hable, Hejl, etc)

Last edited by Dogway; 28th June 2021 at 21:46.
Dogway is offline   Reply With Quote

colorspace, conversion, format, matrix, temperature

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 02:13.

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