Caf source

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(source, from pastebin.com)
 
m (formatting)
Line 1: Line 1:
# http://pastebin.com/raw.php?i=Mt2M4CBB
+
source: http://pastebin.com/raw.php?i=Mt2M4CBB
/* Chromatic Aberration Fixer (original: http://pastebin.com/wEAp3tuM)
+
/* Chromatic Aberration Fixer (original: http://pastebin.com/wEAp3tuM)
rx/ry adjust how much to resize the red plane; bx/by is the same, but for blue.
+
rx/ry adjust how much to resize the red plane; bx/by is the same, but for blue.
warp adjusts warpsharp strength on red/blue planes.
+
warp adjusts warpsharp strength on red/blue planes.
clamp sets whether the chroma (after converting back to yv12) should be limited by the original chroma; this prevents introducing chromatic aberration on, for example, hardsubbed text without chromatic aberration.
+
clamp sets whether the chroma (after converting back to yv12) should be limited by the original chroma; this prevents introducing chromatic aberration on, for example, hardsubbed text without chromatic aberration.
*/
+
*/
 
+
function caf(clip src,float "rx",float "ry",float "bx",float "by",int "warp",bool "clamp")
+
function caf(clip src,float "rx",float "ry",float "bx",float "by",int "warp",bool "clamp")
{
+
{
src
+
src
rgb=ConvertToRGB32(matrix="rec709")
+
rgb=ConvertToRGB32(matrix="rec709")
w=width()
+
w=width()
h=height()
+
h=height()
rx=default(rx,-1.5)
+
rx=default(rx,-1.5)
ry=default(ry,rx)
+
ry=default(ry,rx)
bx=default(bx,-rx)
+
bx=default(bx,-rx)
by=default(by,bx)
+
by=default(by,bx)
warp=default(warp,4)
+
warp=default(warp,4)
clamp=default(clamp,true)
+
clamp=default(clamp,true)
edge=src.aSobel().aBlur(type=0,blur=4)
+
edge=src.aSobel().aBlur(type=0,blur=4)
r=rgb.ShowRed("yv12").Spline36Resize(w,h,rx,ry,w-rx*2,h-ry*2)
+
r=rgb.ShowRed("yv12").Spline36Resize(w,h,rx,ry,w-rx*2,h-ry*2)
b=rgb.ShowBlue("yv12").Spline36Resize(w,h,bx,by,w-bx*2,h-by*2)
+
b=rgb.ShowBlue("yv12").Spline36Resize(w,h,bx,by,w-bx*2,h-by*2)
rwarp=r.aWarp(edge,depth=warp,chroma=1)
+
rwarp=r.aWarp(edge,depth=warp,chroma=1)
bwarp=b.aWarp(edge,depth=warp,chroma=1)
+
bwarp=b.aWarp(edge,depth=warp,chroma=1)
warp==0?MergeRGB(r,rgb,b):MergeRGB(rwarp,rgb,bwarp)
+
warp==0?MergeRGB(r,rgb,b):MergeRGB(rwarp,rgb,bwarp)
ConvertToYV12(matrix="rec709")
+
ConvertToYV12(matrix="rec709")
clamp?mt_lutxy(src,last,"128 x y min x y max clip",y=2,u=3,v=3):MergeLuma(src)
+
clamp?mt_lutxy(src,last,"128 x y min x y max clip",y=2,u=3,v=3):MergeLuma(src)
}
+
}

Revision as of 07:16, 12 November 2015

source: http://pastebin.com/raw.php?i=Mt2M4CBB

/* Chromatic Aberration Fixer (original: http://pastebin.com/wEAp3tuM)
rx/ry adjust how much to resize the red plane; bx/by is the same, but for blue.
warp adjusts warpsharp strength on red/blue planes.
clamp sets whether the chroma (after converting back to yv12) should be limited by the original chroma; this prevents introducing chromatic aberration on, for example, hardsubbed text without chromatic aberration.
*/

function caf(clip src,float "rx",float "ry",float "bx",float "by",int "warp",bool "clamp")
{
src
rgb=ConvertToRGB32(matrix="rec709")
w=width()
h=height()
rx=default(rx,-1.5)
ry=default(ry,rx)
bx=default(bx,-rx)
by=default(by,bx)
warp=default(warp,4)
clamp=default(clamp,true)
edge=src.aSobel().aBlur(type=0,blur=4)
r=rgb.ShowRed("yv12").Spline36Resize(w,h,rx,ry,w-rx*2,h-ry*2)
b=rgb.ShowBlue("yv12").Spline36Resize(w,h,bx,by,w-bx*2,h-by*2)
rwarp=r.aWarp(edge,depth=warp,chroma=1)
bwarp=b.aWarp(edge,depth=warp,chroma=1)
warp==0?MergeRGB(r,rgb,b):MergeRGB(rwarp,rgb,bwarp)
ConvertToYV12(matrix="rec709")
clamp?mt_lutxy(src,last,"128 x y min x y max clip",y=2,u=3,v=3):MergeLuma(src)
}
Personal tools