PDA

View Full Version : Why does this script crash?


shoopdabloop
12th October 2009, 06:23
ImageSource("sm64.png",pixel_type="RGB32")

a = ShowAlpha("YV12")
r = ShowRed("YV12")
g = ShowGreen("YV12")
b = ShowBlue("YV12")

rf = 4
sh = 20

a = a.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
r = r.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
g = g.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
b = b.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)

MergeARGB(a,r,g,b)
function edgesharpen(clip clp, int "strength", bool "soothe", bool "secure", bool "dehalo") {
st = default(strength,100)
se = default(soothe,false)
sc = default(secure,false)
dh = default(dehalo,true)
a = clp
b = clp.lsfmod(smode=3,strength=st,soothe=se,secure=sc)
b = (dh==true) ? b.dehalo_alpha() : b
c = clp.mt_edge("laplace",0,1,0,1,u=3,v=3).blur(0.5)
return mt_merge(a,b,c,u=3,v=3)
}

The answer is probably very simple, but I do not see it..

IanB
12th October 2009, 08:13
Crash how?

Error message???

Leak
12th October 2009, 12:28
The answer is probably very simple, but I do not see it..
What's the size of your image?

I'd hazard a guess AviSynth simply runs out of address space (i.e. memory) and gets killed by Windows - keep an eye on the "Virtual size" column in Task Manager - as soon as it hits 2 GB it's usually bye-bye for 32-bit processes.

shoopdabloop
13th October 2009, 00:40
The source image is 16x16 and I am quadrupling it with nnedi2.

I've changed the script a little and it works now, but it still puts VirtualDubMod in a very "crashy" mood.

So I do not think I have done everything properly.

ImageSource("sm64.png",pixel_type="RGB32")

AddBorders(2,2,2,2)

a = ShowAlpha("YV12")
rgb = ConvertToYV12()

rf = 4
sh = 50

a = a.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
rgb = rgb.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh).ConvertToRGB32()

MergeARGB(a,rgb,rgb,rgb)
Crop(8,8,-8,-8)
function edgesharpen(clip clp, int "strength", bool "dehalo", float "dhradius", bool "secure", bool "soothe") {
st = default(strength,100)
dh = default(dehalo,true)
dr = default(dhradius,2.0)
sc = default(secure,false)
se = default(soothe,false)
a = clp
b = clp.lsfmod(smode=3,strength=st,soothe=se,secure=sc)
b = (dh==true) ? b.dehalo_alpha(rx=dr,ry=dr) : b
c = clp.mt_edge("laplace",0,1,0,1,u=3,v=3).blur(0.5)
return mt_merge(a,b,c,u=3,v=3)
}

Didée
13th October 2009, 00:47
Then it's most likely RemoveGrain() and/or Repair(), hidden in both LSFMod and dehalo_alpha. IIRC, RG and Repair require some minimum image sizes ... could've been 32x32 for SSE2 versions, 96x96 for SSE3 version ... perhaps other numbers, can't recall from memory. Whatever, 16x16 is too small. Try Addborders (better: padding, or border mirroring) to increase input size.
Try e.g. AddBorders(128,128,128,128) to quickly check for the suspect.

shoopdabloop
13th October 2009, 01:05
Thanks! It works now.

ImageSource("sm64.png",pixel_type="RGB32")

AddBorders(64,64,64,64)

a = ShowAlpha("YV12")
rgb = ConvertToYV12()

rf = 4
sh = 500

a = a.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
rgb = rgb.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh).ConvertToRGB32()

MergeARGB(a,rgb,rgb,rgb)
Crop(256,256,-256,-256)
function edgesharpen(clip clp, int "strength", bool "dehalo", float "dhradius", bool "secure", bool "soothe") {
st = default(strength,100)
dh = default(dehalo,true)
dr = default(dhradius,2.0)
sc = default(secure,false)
se = default(soothe,false)
a = clp
b = clp.lsfmod(smode=3,strength=st,soothe=se,secure=sc)
b = (dh==true) ? b.dehalo_alpha(rx=dr,ry=dr) : b
c = clp.mt_edge("laplace",0,1,0,1,u=3,v=3).blur(0.5)
return mt_merge(a,b,c,u=3,v=3)
}

Which script preserves the colors more accurately, that^ one or this one? Or does this script simply do the exact same thing as the other, but slower?

ImageSource("sm64.png",pixel_type="RGB32")

AddBorders(64,64,64,64)

a = ShowAlpha("YV12")
r = ShowRed("YV12")
g = ShowGreen("YV12")
b = ShowBlue("YV12")

rf = 4
sh = 500

a = a.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
r = r.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
g = g.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)
b = b.nnedi2_rpow2(rfactor=rf,cshift="spline36resize").edgesharpen(sh)

MergeARGB(a,r,g,b)
Crop(256,256,-256,-256)