View Full Version : DCT implemented completely in avisynth
*.mp4 guy
30th March 2009, 11:05
Sub Functions:
Function BasisResize(Clip c, clip Basis, clip basisc)
{
basis = basis.height < c.height ? stackvertical(basis, basisc) : basis
return (basis.height == c.height) ? basis : BasisResize(c, basis, basisc)
}
Function Generate_AVC_DCT_AC_Component_Basis(clip c, bool p, int basisnumber)
{
SP255 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$FFFFFF)
SP252 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$FCFCFC)
SP242 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$F2F2F2)
SP234 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$EAEAEA)
SP218 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$DADADA)
SP191 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$BFBFBF)
SP185 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$B9B9B9)
SP160 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$A0A0A0)
SP159 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$9F9F9F)
SN97 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$616161)
SN96 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$606060)
SN71 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$474747)
SN64 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$404040)
SN37 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$252525)
SN22 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$161616)
SN14 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$0E0E0E)
SN4 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$040404)
SN0 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$000000)
VectorP1 = Stackvertical(SP255, SP234, SP191, SP160, SN96, SN64, SN22, SN0).converttoyv12()
VectorN1 = Stackvertical(SN0, SN22, SN64, SN96, SP160, SP191, SP234, SP255).converttoyv12()
VectorP2 = Stackvertical(SP252, SP159, SN97, SN4, SN4, SN97, SP159, SP252).converttoyv12()
VectorN2 = Stackvertical(SN4, SN97, SP159, SP252, SP252, SP159, SN97, SN4).converttoyv12()
VectorP3 = Stackvertical(SP234, SN96, SN0, SN64, SP191, SP255, SP160, SN22).converttoyv12()
VectorN3 = Stackvertical(SN22, SP160, SP255, SP191, SN64, SN0, SN96, SP234).converttoyv12()
VectorP4 = Stackvertical(SP218, SN37, SN37, SP218, SP218, SN37, SN37, SP218).converttoyv12()
VectorN4 = Stackvertical(SN37, SP218, SP218, SN37, SN37, SP218, SP218, SN37).converttoyv12()
VectorP5 = Stackvertical(SP191, SN0, SP160, SP191, SN64, SN96, SP255, SN64).converttoyv12()
VectorN5 = Stackvertical(SN64, SP255, SN96, SN64, SP191, SP160, SN0, SP160).converttoyv12()
VectorP5 = Stackvertical(SP191, SN0, SP160, SP191, SN64, SN96, SP255, SN64).converttoyv12()
VectorN5 = Stackvertical(SN64, SP255, SN96, SN64, SP191, SP160, SN0, SP160).converttoyv12()
VectorP6 = Stackvertical(SP185, SN14, SP242, SN71, SN71, SP242, SN14, SP185).converttoyv12()
VectorN6 = Stackvertical(SN71, SP242, SN14, SP185, SP185, SN14, SP242, SN71).converttoyv12()
VectorP7 = Stackvertical(SP160, SN64, SP234, SN0, SP255, SN22, SP191, SN96).converttoyv12()
VectorN7 = Stackvertical(SN64, SP191, SN22, SP255, SN0, SP234, SN64, SP160).converttoyv12()
choose_basis = c
choose_basis = basisnumber == 1? P == true ? VectorP1 : VectorN1 : choose_basis
choose_basis = basisnumber == 2? P == true ? VectorP2 : VectorN2 : choose_basis
choose_basis = basisnumber == 3? P == true ? VectorP3 : VectorN3 : choose_basis
choose_basis = basisnumber == 4? P == true ? VectorP4 : VectorN4 : choose_basis
choose_basis = basisnumber == 5? P == true ? VectorP5 : VectorN5 : choose_basis
choose_basis = basisnumber == 6? P == true ? VectorP6 : VectorN6 : choose_basis
choose_basis = basisnumber == 7? P == true ? VectorP7 : VectorN7 : choose_basis
basis = choose_basis
basis = BasisResize(c, basis, basis)
return basis
}
*.mp4 guy
30th March 2009, 11:06
Main Functions:
function AVC_DCT(clip c)
{
rounding = 1
rounding2 = 1
point0 = c.pointresize(c.width, c.height/8, 0, 0, c.width, c.height)
point1 = c.pointresize(c.width, c.height/8, 0, 1, c.width, c.height)
point2 = c.pointresize(c.width, c.height/8, 0, 2, c.width, c.height)
point3 = c.pointresize(c.width, c.height/8, 0, 3, c.width, c.height)
point4 = c.pointresize(c.width, c.height/8, 0, 4, c.width, c.height)
point5 = c.pointresize(c.width, c.height/8, 0, 5, c.width, c.height)
point6 = c.pointresize(c.width, c.height/8, 0, 6, c.width, c.height)
point7 = c.pointresize(c.width, c.height/8, 0, 7, c.width, c.height)
DC = Average(point0, 0.125, point1, 0.125, point2, 0.125, point3, 0.125, point4, 0.125, point5, 0.125, point6, 0.125, point7, 0.125).mt_lut(" x "+string(rounding2)+" / ", u=1, v=1).mt_lut(" x "+string(rounding2)+" * ", u=1, v=1)
AC1P = Average(point0, 0.3875, point1, 0.3222, point2, 0.1930, point3, 0.0973)
AC1N =Average(point4, 0.0973, point5, 0.1930, point6, 0.3222, point7, 0.3875)
AC2P = Average(point0, 0.4000, point1, 0.1000, point6, 0.1000, point7, 0.4000)
AC2N = Average(point2, 0.1000, point3, 0.4000, point4, 0.4000, point5, 0.1000)
AC3P = Average(point0, 0.3222, point4, 0.1930, point5, 0.3875, point6, 0.0973)
AC3N = Average(point1, 0.0973, point2, 0.3875, point3, 0.1930, point7, 0.3222)
AC4P = Average(point0, 0.2500, point3, 0.2500, point4, 0.2500, point7, 0.2500)
AC4N = Average(point1, 0.2500, point2, 0.2500, point5, 0.2500, point6, 0.2500)
AC5P = Average(point0, 0.2216, point2, 0.1117, point3, 0.2216, point6, 0.4451)
AC5N = Average(point1, 0.4451, point4, 0.2216, point5, 0.1117, point7, 0.2216)
AC6P = Average(point0, 0.1667, point2, 0.3333, point5, 0.3333, point7, 0.1667)
AC6N = Average(point1, 0.3333, point3, 0.1667, point4, 0.1667, point6, 0.3333)
AC7P = Average(point0, 0.0973, point2, 0.3222, point4, 0.3875, point6, 0.1930)
AC7N = Average(point1, 0.1930, point3, 0.3875, point5, 0.3222, point7, 0.0973)
AC1_1 = Mt_LutXY(AC1P, AC1N, " x y - 1.4142 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC2_1 = Mt_LutXY(AC2P, AC2N, " x y - 1.1892 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC3_1 = Mt_LutXY(AC3P, AC3N, " x y - 1.0905 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC4_1 = Mt_LutXY(AC4P, AC4N, " x y - 1.0442 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC5_1 = Mt_LutXY(AC5P, AC5N, " x y - 1.0218 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC6_1 = Mt_LutXY(AC6P, AC6N, " x y - 1.0108 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC7_1 = Mt_LutXY(AC7P, AC7N, " x y - 1.0054 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC1_2 = Mt_LutXY(AC1P, AC1N, " y x - 1.4142 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC2_2 = Mt_LutXY(AC2P, AC2N, " y x - 1.1892 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC3_2 = Mt_LutXY(AC3P, AC3N, " y x - 1.0905 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC4_2 = Mt_LutXY(AC4P, AC4N, " x y - 1.0442 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC5_2 = Mt_LutXY(AC5P, AC5N, " y x - 1.0218 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC6_2 = Mt_LutXY(AC6P, AC6N, " y x - 1.0108 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC7_2 = Mt_LutXY(AC7P, AC7N, " y x - 1.0054 *", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
stackvertical(DC, AC1_1, AC2_1, AC3_1, AC4_1, AC5_1, AC6_1, AC7_1, AC1_2, AC2_2, AC3_2, AC4_2, AC5_2, AC6_2, AC7_2)
}
Function AVC_IDCT(clip c)
{
inputclipproperties = c.pointresize(c.width, round(c.height/15)*8)
DC = crop(c, 0, (round(c.height/15)*0), 0, ((round(c.height/15)*1)))
AC1_1 = crop(c, 0, (round(c.height/15)*1), 0, ((round(c.height/15)*1)))
AC2_1 = crop(c, 0, (round(c.height/15)*2), 0, ((round(c.height/15)*1)))
AC3_1 = crop(c, 0, (round(c.height/15)*3), 0, ((round(c.height/15)*1)))
AC4_1 = crop(c, 0, (round(c.height/15)*4), 0, ((round(c.height/15)*1)))
AC5_1 = crop(c, 0, (round(c.height/15)*5), 0, ((round(c.height/15)*1)))
AC6_1 = crop(c, 0, (round(c.height/15)*6), 0, ((round(c.height/15)*1)))
AC7_1 = crop(c, 0, (round(c.height/15)*7), 0, ((round(c.height/15)*1)))
AC1_2 = crop(c, 0, (round(c.height/15)*8), 0, ((round(c.height/15)*1)))
AC2_2 = crop(c, 0, (round(c.height/15)*9), 0, ((round(c.height/15)*1)))
AC3_2 = crop(c, 0, (round(c.height/15)*10), 0, ((round(c.height/15)*1)))
AC4_2 = crop(c, 0, (round(c.height/15)*11), 0, ((round(c.height/15)*1)))
AC5_2 = crop(c, 0, (round(c.height/15)*12), 0, ((round(c.height/15)*1)))
AC6_2 = crop(c, 0, (round(c.height/15)*13), 0, ((round(c.height/15)*1)))
AC7_2 = crop(c, 0, (round(c.height/15)*14), 0, ((round(c.height/15)*1)))
AC1BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 1)
AC1BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 1)
AC2BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 2)
AC2BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 2)
AC3BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 3)
AC3BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 3)
AC4BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 4)
AC4BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 4)
AC5BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 5)
AC5BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 5)
AC6BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 6)
AC6BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 6)
AC7BasisP = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, true, 7)
AC7BasisN = Generate_AVC_DCT_AC_Component_Basis(inputclipproperties, false, 7)
neutral = BlankClip(length=inputclipproperties.framecount, width=inputclipproperties.width, height=inputclipproperties.height, pixel_type="rgb32", fps=inputclipproperties.framerate, fps_denominator=1, audio_rate=inputclipproperties.Audiorate, stereo=true, sixteen_bit=true, color=$828282).converttoyv12()
#neutral = BlankClip(length=c.framecount, width=c.width, height=c.height, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$828282).converttoyv12()
R1 = mt_adddiff(Mt_Merge(neutral, AC1BasisP, AC1_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), dc.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1)
R2 = mt_adddiff(Mt_Merge(neutral, AC1BasisN, AC1_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R1, u=1, v=1)
R3 = mt_adddiff(Mt_Merge(neutral, AC2BasisP, AC2_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R2, u=1, v=1)
R4 = mt_adddiff(Mt_Merge(neutral, AC2BasisN, AC2_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R3, u=1, v=1)
R5 = mt_adddiff(Mt_Merge(neutral, AC3BasisP, AC3_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R4, u=1, v=1)
R6 = mt_adddiff(Mt_Merge(neutral, AC3BasisN, AC3_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R5, u=1, v=1)
R7 = mt_adddiff(Mt_Merge(neutral, AC3BasisP, AC4_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R6, u=1, v=1)
R8 = mt_adddiff(Mt_Merge(neutral, AC3BasisN, AC4_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R7, u=1, v=1)
R9 = mt_adddiff(Mt_Merge(neutral, AC3BasisP, AC5_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R8, u=1, v=1)
R10 = mt_adddiff(Mt_Merge(neutral, AC3BasisN, AC5_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R9, u=1, v=1)
R11 = mt_adddiff(Mt_Merge(neutral, AC3BasisP, AC6_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R10, u=1, v=1)
R12 = mt_adddiff(Mt_Merge(neutral, AC3BasisN, AC6_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R11, u=1, v=1)
R13 = mt_adddiff(Mt_Merge(neutral, AC3BasisP, AC7_1.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R12, u=1, v=1)
R14 = mt_adddiff(Mt_Merge(neutral, AC3BasisN, AC7_2.pointresize(inputclipproperties.width, inputclipproperties.height), u=1, v=1), R13, u=1, v=1)
Return R14
}
It has limited precision, and works only on luma, exceptionally large coeficients will be truncated (though quality is reasonable), input must be a multiple of 32.
It uses a separable transform, here is example usage:
AVISource("K:\video.avi")
source = last
AVC_DCT.turnright.AVC_DCT
AVC_IDCT.turnleft.AVC_IDCT.mergechroma(source, 1)
[edit] I used two posts because I ran into the 16K character limit, also, if there is sufficient interest, I will explain how the functions work.
[edit2] Before someone smarter then me points it out, I would like to preemptively point out that this version is completely broken for 2 dimensional use, and thanks to my botched attempts to work around this, without fully understanding the problem, it is also broken for 1 dimensional use. I should have a fixed version up in a few days, which incidently will use an aproximation of the actual DCT (not the HCT), as aproximating an aproximation is fairly daft.
Mug Funky
3rd April 2009, 08:00
hahaha oh wow
that's pretty cool. what kind of speeds do you get? what sort of filters should we run on the transformed output to get something fun? actually, once you post the fixed version i'm going to see what temporalsoften does to it :)
Terka
3rd April 2009, 14:38
sorry for my ignorance, what is this good for?
Guest
3rd April 2009, 14:46
Nothing. It would make much more sense to implement it in fast optimized native code.
LoRd_MuldeR
3rd April 2009, 14:54
Script Error: There is no function named "Average"
That function is not defined in your "Sub Functions", so where do I get it? :confused:
Inspector.Gadget
3rd April 2009, 15:10
Hey *.mp4 guy, this sounds neat but it's over my head, technically. I get what DCT/iDCT functions do but I'm unclear on uses outside of quantization for video compression. What are some potential applications of this?
*.mp4 guy
3rd April 2009, 22:01
Alright, here is a version that works, though it will amplify noise, due to low precision.
Function BasisResize(Clip c, clip Basis, clip basisc)
{
basis = basis.height < c.height ? stackvertical(basis, basisc) : basis
return (basis.height == c.height) ? basis : BasisResize(c, basis, basisc)
}
Function Generate_DCT_AC_Component_Basis(clip c, bool p, int basisnumber)
{
SP255 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$FFFFFF)
SP248 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$F8F8F8)
SP236 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$ECECEC)
SP219 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$DBDBDB)
SP200 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$C8C8C8)
SP177 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$B1B1B1)
SP153 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$999999)
SN102 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$666666)
SN78 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$4E4E4E)
SN55 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$373737)
SN36 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$242424)
SN19 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$131313)
SN7 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$070707)
SN0 = BlankClip(length=c.framecount, width=c.width, height=1, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$000000)
VectorP1 = Stackvertical(SP255, SP236, SP200, SP153, SN102, SN55, SN19, SN0).converttoyv12()
VectorN1 = Stackvertical(SN0, SN19, SN55, SN102, SP153, SP200, SP236, SP255).converttoyv12()
VectorP2 = Stackvertical(SP248, SP177, SN78, SN7, SN7, SN78, SP177, SP248).converttoyv12()
VectorN2 = Stackvertical(SN7, SN78, SP177, SP248, SP248, SP177, SN78, SN7).converttoyv12()
VectorP3 = Stackvertical(SP236, SN102, SN0, SN55, SP200, SP255, SP153, SN19).converttoyv12()
VectorN3 = Stackvertical(SN19, SP153, SP255, SP200, SN55, SN0, SN102, SP236).converttoyv12()
VectorP4 = Stackvertical(SP219, SN36, SN36, SP219, SP219, SN36, SN36, SP219).converttoyv12()
VectorN4 = Stackvertical(SN36, SP219, SP219, SN36, SN36, SP219, SP219, SN36).converttoyv12()
VectorP5 = Stackvertical(SP200, SN0, SP153, SP236, SN19, SN102, SP255, SN55).converttoyv12()
VectorN5 = Stackvertical(SN55, SP255, SN102, SN19, SP236, SP153, SN0, SP200).converttoyv12()
VectorP6 = Stackvertical(SP177, SN19, SP236, SN78, SN78, SP236, SN19, SP177).converttoyv12()
VectorN6 = Stackvertical(SN78, SP236, SN19, SP177, SP177, SN19, SP236, SN78).converttoyv12()
VectorP7 = Stackvertical(SP153, SN55, SP236, SN0, SP255, SN19, SP200, SN102).converttoyv12()
VectorN7 = Stackvertical(SN102, SP200, SN19, SP255, SN0, SP236, SN55, SP153).converttoyv12()
VectorDCP = Stackvertical(SP255, SP255, SP255, SP255, SP255, SP255, SP255, SP255).converttoyv12()
VectorDCN = Stackvertical(SN0, SN0, SN0, SN0, SN0, SN0, SN0, SN0).converttoyv12()
choose_basis = c
choose_basis = basisnumber == 1? P == true ? VectorP1 : VectorN1 : choose_basis
choose_basis = basisnumber == 2? P == true ? VectorP2 : VectorN2 : choose_basis
choose_basis = basisnumber == 3? P == true ? VectorP3 : VectorN3 : choose_basis
choose_basis = basisnumber == 4? P == true ? VectorP4 : VectorN4 : choose_basis
choose_basis = basisnumber == 5? P == true ? VectorP5 : VectorN5 : choose_basis
choose_basis = basisnumber == 6? P == true ? VectorP6 : VectorN6 : choose_basis
choose_basis = basisnumber == 7? P == true ? VectorP7 : VectorN7 : choose_basis
choose_basis = basisnumber == 8? P == true ? VectorDCP : VectorDCN : choose_basis
basis = choose_basis
basis = BasisResize(c, basis, basis)
return basis
}
function DCT(clip c)
{
rounding = 1
rounding2 = 1
point0 = c.pointresize(c.width, c.height/8, 0, 0, c.width, c.height)
point1 = c.pointresize(c.width, c.height/8, 0, 1, c.width, c.height)
point2 = c.pointresize(c.width, c.height/8, 0, 2, c.width, c.height)
point3 = c.pointresize(c.width, c.height/8, 0, 3, c.width, c.height)
point4 = c.pointresize(c.width, c.height/8, 0, 4, c.width, c.height)
point5 = c.pointresize(c.width, c.height/8, 0, 5, c.width, c.height)
point6 = c.pointresize(c.width, c.height/8, 0, 6, c.width, c.height)
point7 = c.pointresize(c.width, c.height/8, 0, 7, c.width, c.height)
DC = Average(point0, 0.125, point1, 0.125, point2, 0.125, point3, 0.125, point4, 0.125, point5, 0.125, point6, 0.125, point7, 0.125).mt_lut(" x "+string(rounding2)+" / ", u=1, v=1).mt_lut(" x "+string(rounding2)+" * ", u=1, v=1)
AC1P = Average(point0, 0.3827, point1, 0.3244, point2, 0.2168, point3, 0.0761)
AC1N =Average(point4, 0.0761, point5, 0.2168, point6, 0.3244, point7, 0.3827)
AC2P = Average(point0, 0.3536, point1, 0.1464, point6, 0.1464, point7, 0.3536)
AC2N = Average(point2, 0.1464, point3, 0.3536, point4, 0.3536, point5, 0.1464)
AC3P = Average(point0, 0.3244, point4, 0.2168, point5, 0.3827, point6, 0.0761)
AC3N = Average(point1, 0.0761, point2, 0.3827, point3, 0.2168, point7, 0.3244)
AC4P = Average(point0, 0.2500, point3, 0.2500, point4, 0.2500, point7, 0.2500)
AC4N = Average(point1, 0.2500, point2, 0.2500, point5, 0.2500, point6, 0.2500)
AC5P = Average(point0, 0.2168, point2, 0.0761, point3, 0.3244, point6, 0.3827)
AC5N = Average(point1, 0.3827, point4, 0.3244, point5, 0.0761, point7, 0.2168)
AC6P = Average(point0, 0.1464, point2, 0.3536, point5, 0.3536, point7, 0.1464)
AC6N = Average(point1, 0.3536, point3, 0.1464, point4, 0.1464, point6, 0.3536)
AC7P = Average(point0, 0.0761, point2, 0.3244, point4, 0.3827, point6, 0.2168)
AC7N = Average(point1, 0.2168, point3, 0.3827, point5, 0.3244, point7, 0.0761)
AC1 = Mt_LutXY(AC1P, AC1N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC2 = Mt_LutXY(AC2P, AC2N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC3 = Mt_LutXY(AC3P, AC3N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC4 = Mt_LutXY(AC4P, AC4N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC5 = Mt_LutXY(AC5P, AC5N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC6 = Mt_LutXY(AC6P, AC6N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
AC7 = Mt_LutXY(AC7P, AC7N, " x y - 2 / 128 + ", u=1, v=1).mt_lut(" x "+string(rounding)+" / ", u=1, v=1).mt_lut(" x "+string(rounding)+" * ", u=1, v=1)
stackvertical(DC, AC1, AC2, AC3, AC4, AC5, AC6, AC7)
}
Function IDCT(clip c)
{
inputclipproperties = c.pointresize(c.width, round(c.height/8)*8)
DC = crop(c, 0, (round(c.height/8)*0), 0, ((round(c.height/8)*1)))
AC1 = crop(c, 0, (round(c.height/8)*1), 0, ((round(c.height/8)*1)))
AC2 = crop(c, 0, (round(c.height/8)*2), 0, ((round(c.height/8)*1)))
AC3 = crop(c, 0, (round(c.height/8)*3), 0, ((round(c.height/8)*1)))
AC4 = crop(c, 0, (round(c.height/8)*4), 0, ((round(c.height/8)*1)))
AC5 = crop(c, 0, (round(c.height/8)*5), 0, ((round(c.height/8)*1)))
AC6 = crop(c, 0, (round(c.height/8)*6), 0, ((round(c.height/8)*1)))
AC7 = crop(c, 0, (round(c.height/8)*7), 0, ((round(c.height/8)*1)))
BasisDCP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 8)
BasisDCN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 8)
AC1BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 1)
AC1BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 1)
AC2BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 2)
AC2BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 2)
AC3BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 3)
AC3BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 3)
AC4BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 4)
AC4BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 4)
AC5BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 5)
AC5BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 5)
AC6BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 6)
AC6BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 6)
AC7BasisP = Generate_DCT_AC_Component_Basis(inputclipproperties, true, 7)
AC7BasisN = Generate_DCT_AC_Component_Basis(inputclipproperties, false, 7)
neutral = BlankClip(length=inputclipproperties.framecount, width=inputclipproperties.width, height=inputclipproperties.height, pixel_type="rgb32", fps=inputclipproperties.framerate, fps_denominator=1, audio_rate=inputclipproperties.Audiorate, stereo=true, sixteen_bit=true, color=$828282).converttoyv12()
R1 = Mt_lutxy(Mt_lutxy(AC1BasisP, AC1.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), dc.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y + ", U=1, V=1)
R2 = Mt_lutxy(Mt_lutxy(AC2BasisP, AC2.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R1, " x 128 - y + ", U=1, V=1)
R3 = Mt_lutxy(Mt_lutxy(AC3BasisP, AC3.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R2, " x 128 - y + ", U=1, V=1)
R4 = Mt_lutxy(Mt_lutxy(AC4BasisP, AC4.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R3, " x 128 - y + ", U=1, V=1)
R5 = Mt_lutxy(Mt_lutxy(AC5BasisP, AC5.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R4, " x 128 - y + ", U=1, V=1)
R6 = Mt_lutxy(Mt_lutxy(AC6BasisP, AC6.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R5, " x 128 - y + ", U=1, V=1)
R7 = Mt_lutxy(Mt_lutxy(AC7BasisP, AC7.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R6, " x 128 - y + ", U=1, V=1)
Return R7
}
[edit] I had posted replies to everyone in this thread, but my internet cut out halfway through sending the post, I will re-edit this post with replies later.
hahaha oh wow
that's pretty cool. what kind of speeds do you get? what sort of filters should we run on the transformed output to get something fun? actually, once you post the fixed version i'm going to see what temporalsoften does to it :)
The forward transform runs at about 15fps for a 640*256 source on my relatively slow system, forward plus inverse is about 4fps, so its quite slow. Spatial filters are generally going to produce very bad/wierd results, but temporal might be interesting.
Nothing. It would make much more sense to implement it in fast optimized native code.
Because there aren't already an incredible number of those already? This is usefull/interesting specifically because it is implemented in avisynth and can therefore directly interact with all of the plugins and functions for avisynth.
That function is not defined in your "Sub Functions", so where do I get it? :confused:
Its a plugin, its here on the forum somewhere.
Hey *.mp4 guy, this sounds neat but it's over my head, technically. I get what DCT/iDCT functions do but I'm unclear on uses outside of quantization for video compression. What are some potential applications of this? DCT's can be used for a lot more then just compression, denoising, interpolations, and frequency band equalization are common enough. But this is usefull mostly because of its accessability, it will be much easier to fiddle with then just about any other implementation, atleast for me. The lattter along with a desire to better understand the DCT, and just to see If I could, are the main reasons why I wrote this.
Hopefully my recreated replies are intelligible enough, I have been pressed for time since I completed the working version.
*.mp4 guy
2nd November 2011, 07:27
This function is perhaps not obviously useful, however I recently reworked it a bit. On the off chance it might be helpful, or that someone else was actually doing something with the old version, here is the new one. It's more then twice as fast while using less memory.
Function BasisDoubleH(Clip c, clip Basis)
{
basis = basis.width < c.width / 2 ? stackhorizontal(basis, basis) : basis
return (basis.width <= c.width / 2) ? basis : BasisDoubleH(c, basis)
}
Function BasisResizeH(Clip c, clip Basis, clip basisc)
{
basis = basis.width < c.width ? stackhorizontal(basis, basisc) : basis
return (basis.width == c.width) ? basis : BasisResizeH(c, basis, basisc)
}
Function Generate_DCT_AC_Component_BasisH(clip c, bool p, int basisnumber)
{
SP255 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$FFFFFF)
SP248 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$F8F8F8)
SP236 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$ECECEC)
SP219 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$DBDBDB)
SP200 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$C8C8C8)
SP177 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$B1B1B1)
SP153 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$999999)
SN102 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$666666)
SN78 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$4E4E4E)
SN55 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$373737)
SN36 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$242424)
SN19 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$131313)
SN7 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$070707)
SN0 = BlankClip(length=c.framecount, width=1, height=2, pixel_type="rgb32", fps=c.framerate, fps_denominator=1, audio_rate=c.Audiorate, stereo=true, sixteen_bit=true, color=$000000)
VectorP1 = stackhorizontal(SP255, SP236, SP200, SP153, SN102, SN55, SN19, SN0).converttoyv12()
VectorN1 = stackhorizontal(SN0, SN19, SN55, SN102, SP153, SP200, SP236, SP255).converttoyv12()
VectorP2 = stackhorizontal(SP248, SP177, SN78, SN7, SN7, SN78, SP177, SP248).converttoyv12()
VectorN2 = stackhorizontal(SN7, SN78, SP177, SP248, SP248, SP177, SN78, SN7).converttoyv12()
VectorP3 = stackhorizontal(SP236, SN102, SN0, SN55, SP200, SP255, SP153, SN19).converttoyv12()
VectorN3 = stackhorizontal(SN19, SP153, SP255, SP200, SN55, SN0, SN102, SP236).converttoyv12()
VectorP4 = stackhorizontal(SP219, SN36, SN36, SP219, SP219, SN36, SN36, SP219).converttoyv12()
VectorN4 = stackhorizontal(SN36, SP219, SP219, SN36, SN36, SP219, SP219, SN36).converttoyv12()
VectorP5 = stackhorizontal(SP200, SN0, SP153, SP236, SN19, SN102, SP255, SN55).converttoyv12()
VectorN5 = stackhorizontal(SN55, SP255, SN102, SN19, SP236, SP153, SN0, SP200).converttoyv12()
VectorP6 = stackhorizontal(SP177, SN19, SP236, SN78, SN78, SP236, SN19, SP177).converttoyv12()
VectorN6 = stackhorizontal(SN78, SP236, SN19, SP177, SP177, SN19, SP236, SN78).converttoyv12()
VectorP7 = stackhorizontal(SP153, SN55, SP236, SN0, SP255, SN19, SP200, SN102).converttoyv12()
VectorN7 = stackhorizontal(SN102, SP200, SN19, SP255, SN0, SP236, SN55, SP153).converttoyv12()
VectorDCP = stackhorizontal(SP255, SP255, SP255, SP255, SP255, SP255, SP255, SP255).converttoyv12()
VectorDCN = stackhorizontal(SN0, SN0, SN0, SN0, SN0, SN0, SN0, SN0).converttoyv12()
choose_basis = c
choose_basis = basisnumber == 1? P == true ? VectorP1 : VectorN1 : choose_basis
choose_basis = basisnumber == 2? P == true ? VectorP2 : VectorN2 : choose_basis
choose_basis = basisnumber == 3? P == true ? VectorP3 : VectorN3 : choose_basis
choose_basis = basisnumber == 4? P == true ? VectorP4 : VectorN4 : choose_basis
choose_basis = basisnumber == 5? P == true ? VectorP5 : VectorN5 : choose_basis
choose_basis = basisnumber == 6? P == true ? VectorP6 : VectorN6 : choose_basis
choose_basis = basisnumber == 7? P == true ? VectorP7 : VectorN7 : choose_basis
choose_basis = basisnumber == 8? P == true ? VectorDCP : VectorDCN : choose_basis
basis = choose_basis
basis = BasisDoubleH(c, basis)
basis = BasisResizeH(c, basis, choose_basis)
basis = basis.pointresize(c.width, c.height)
basis = FreezeFrame(basis, 0, c.framecount, 0)
return basis
}
function DCT(clip c)
{
point0 = c.pointresize(c.width/8, c.height, 0, 0, c.width, c.height)
point1 = c.pointresize(c.width/8, c.height, 1, 0, c.width, c.height)
point2 = c.pointresize(c.width/8, c.height, 2, 0, c.width, c.height)
point3 = c.pointresize(c.width/8, c.height, 3, 0, c.width, c.height)
point4 = c.pointresize(c.width/8, c.height, 4, 0, c.width, c.height)
point5 = c.pointresize(c.width/8, c.height, 5, 0, c.width, c.height)
point6 = c.pointresize(c.width/8, c.height, 6, 0, c.width, c.height)
point7 = c.pointresize(c.width/8, c.height, 7, 0, c.width, c.height)
DC = Average(point0, 0.125, point1, 0.125, point2, 0.125, point3, 0.125, point4, 0.125, point5, 0.125, point6, 0.125, point7, 0.125)
AC1P = Average(point0, 0.3827, point1, 0.3244, point2, 0.2168, point3, 0.0761)
AC1N =Average(point4, 0.0761, point5, 0.2168, point6, 0.3244, point7, 0.3827)
AC2P = Average(point0, 0.3536, point1, 0.1464, point6, 0.1464, point7, 0.3536)
AC2N = Average(point2, 0.1464, point3, 0.3536, point4, 0.3536, point5, 0.1464)
AC3P = Average(point0, 0.3244, point4, 0.2168, point5, 0.3827, point6, 0.0761)
AC3N = Average(point1, 0.0761, point2, 0.3827, point3, 0.2168, point7, 0.3244)
AC4P = Average(point0, 0.2500, point3, 0.2500, point4, 0.2500, point7, 0.2500)
AC4N = Average(point1, 0.2500, point2, 0.2500, point5, 0.2500, point6, 0.2500)
AC5P = Average(point0, 0.2168, point2, 0.0761, point3, 0.3244, point6, 0.3827)
AC5N = Average(point1, 0.3827, point4, 0.3244, point5, 0.0761, point7, 0.2168)
AC6P = Average(point0, 0.1464, point2, 0.3536, point5, 0.3536, point7, 0.1464)
AC6N = Average(point1, 0.3536, point3, 0.1464, point4, 0.1464, point6, 0.3536)
AC7P = Average(point0, 0.0761, point2, 0.3244, point4, 0.3827, point6, 0.2168)
AC7N = Average(point1, 0.2168, point3, 0.3827, point5, 0.3244, point7, 0.0761)
AC1 = Mt_LutXY(AC1P, AC1N, " x y - 2 / 128 + ", u=1, v=1)
AC2 = Mt_LutXY(AC2P, AC2N, " x y - 2 / 128 + ", u=1, v=1)
AC3 = Mt_LutXY(AC3P, AC3N, " x y - 2 / 128 + ", u=1, v=1)
AC4 = Mt_LutXY(AC4P, AC4N, " x y - 2 / 128 + ", u=1, v=1)
AC5 = Mt_LutXY(AC5P, AC5N, " x y - 2 / 128 + ", u=1, v=1)
AC6 = Mt_LutXY(AC6P, AC6N, " x y - 2 / 128 + ", u=1, v=1)
AC7 = Mt_LutXY(AC7P, AC7N, " x y - 2 / 128 + ", u=1, v=1)
stackhorizontal(DC, AC1, AC2, AC3, AC4, AC5, AC6, AC7)
}
Function IDCT(clip c)
{
inputclipproperties = c.pointresize(c.width, c.height)
DC = crop(c, (round(c.width/8)*0), 0, ((round(c.width/8)*1)), 0)
AC1 = crop(c, (round(c.width/8)*1), 0, ((round(c.width/8)*1)), 0)
AC2 = crop(c, (round(c.width/8)*2), 0, ((round(c.width/8)*1)), 0)
AC3 = crop(c, (round(c.width/8)*3), 0, ((round(c.width/8)*1)), 0)
AC4 = crop(c, (round(c.width/8)*4), 0, ((round(c.width/8)*1)), 0)
AC5 = crop(c, (round(c.width/8)*5), 0, ((round(c.width/8)*1)), 0)
AC6 = crop(c, (round(c.width/8)*6), 0, ((round(c.width/8)*1)), 0)
AC7 = crop(c, (round(c.width/8)*7), 0, ((round(c.width/8)*1)), 0)
#BasisDCP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 8)
#BasisDCN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 8)
AC1BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 1)
AC1BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 1)
AC2BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 2)
AC2BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 2)
AC3BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 3)
AC3BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 3)
AC4BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 4)
AC4BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 4)
AC5BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 5)
AC5BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 5)
AC6BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 6)
AC6BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 6)
AC7BasisP = Generate_DCT_AC_Component_BasisH(inputclipproperties, true, 7)
AC7BasisN = Generate_DCT_AC_Component_BasisH(inputclipproperties, false, 7)
neutral = BlankClip(length=inputclipproperties.framecount, width=inputclipproperties.width, height=inputclipproperties.height, pixel_type="rgb32", fps=inputclipproperties.framerate, fps_denominator=1, audio_rate=inputclipproperties.Audiorate, stereo=true, sixteen_bit=true, color=$828282).converttoyv12()
R1 = Mt_lutxy(Mt_lutxy(AC1BasisP, AC1.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), dc.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y + ", U=1, V=1)
R2 = Mt_lutxy(Mt_lutxy(AC2BasisP, AC2.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R1, " x 128 - y + ", U=1, V=1)
R3 = Mt_lutxy(Mt_lutxy(AC3BasisP, AC3.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R2, " x 128 - y + ", U=1, V=1)
R4 = Mt_lutxy(Mt_lutxy(AC4BasisP, AC4.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R3, " x 128 - y + ", U=1, V=1)
R5 = Mt_lutxy(Mt_lutxy(AC5BasisP, AC5.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R4, " x 128 - y + ", U=1, V=1)
R6 = Mt_lutxy(Mt_lutxy(AC6BasisP, AC6.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R5, " x 128 - y + ", U=1, V=1)
R7 = Mt_lutxy(Mt_lutxy(AC7BasisP, AC7.pointresize(inputclipproperties.width, inputclipproperties.height), " x 128 - y 128 - * 90 / 128 + ", u=1, v=1), R6, " x 128 - y + ", U=1, V=1)
Return R7
}
jmac698
2nd November 2011, 16:27
I'm with you mp4, script is a lot more accessible than a plugin. I'd like to write a plugin that makes such computations easier, masktools is great but I need more features.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.