Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emcodem/64e4b15588d7be21b39a0c9433070bea to your computer and use it in GitHub Desktop.
Save emcodem/64e4b15588d7be21b39a0c9433070bea to your computer and use it in GitHub Desktop.
loadplugin("C:\dev\FFAStrans\Processors\avs_plugins\ffms2\x64\ffms2.dll")
loadplugin("C:\AvsPmod\plugins\fmtconv.dll")
loadplugin("C:\AvsPmod\plugins\avsresize\x64\Release\avsresize.dll")
FFVideoSource("c:\temp\rgb2111.nut") #rgb2111.nut is BT2111 bgrp10le colorbar hlg,2020,2020 (vapoursynth: c = core.colorbars.ColorBars(format=vs.RGB30, resolution=5, hdr=1))
##SCENE REFERRED
#
# BT.2111 seems to work with rgb source and target, we do the same here (avoid any yuv-rgb-yuv conversion)
#
#convert hlg to linear light (scene referred) - and apply limited-full conversion
fmtc_transfer (transs="hlg",transd="linear",sceneref=true,fulls=false,fulld=true,debug=1) #also applies limited-full
##we are now RGB16bit full for calculations and stay like that until done
# apply matrix from simple linear matrix conversion BT.2407 2.2
fmtc_matrix (coef="1.6605 -0.5876 -0.0728 0 -0.1246 1.1329 -0.0083 0 -0.0182 -0.1006 1.1187 0",fulls=true,fulld=true)
#back from linear rgb to yuv but with 709 matrix - and apply full-limited conversion
fmtc_transfer (transs="linear",transd="709",sceneref=true,fulls=true,fulld=false,debug=2)
#change bits for measuring in avspmod and comparing to bt2111 table
fmtc_bitdepth(bits=10,dmode=1,fulls=false,fulld=false) #fmtc bitdepth gives same result as z_convertFormat
#z_ConvertFormat(pixel_type="rgbp10",colorspace_op="rgb:709:709:limited=>rgb:same:same:limited") #gives same result as fmtc_bitdepth(bits=10,dmode=1,fulls=false,fulld=false)
return last
#
#
#######
#####
# Display referred
#####
z_ConvertFormat(pixel_type="RGBPS",colorspace_op="RGB:std-b67:2020:limited=>rgb:same:same:limited") #to get full precision, we convert to float before we start calculations
fmtc_transfer (transs="hlg",transd="linear",sceneref=false,fulls=false,fulld=true)
fmtc_matrix (coef="1.6605 -0.5876 -0.0728 0 -0.1246 1.1329 -0.0083 0 -0.0182 -0.1006 1.1187 0",fulls=true,fulld=true) # matrix from BT.2407 2.2
#Last transform step also returns int instead of float
fmtc_transfer(transs="linear",transd="1886",sceneref=false,fulls=true,fulld=false,flt=false)
z_ConvertFormat(pixel_type="rgbp10",colorspace_op="rgb:709:709:limited=>rgb:same:same:limited") #full-limited and to 10 bit
####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment