DoW
17th October 2003, 11:31
I have been banging my head against a problem that I have been having for about 2 weeks now. As far as I can tell, there is in the very least a practical limit to the number of trim functions that can be called in a script before Avisynth throws an exception due to memory access violations. The script that Im using that is causing this is: SetMemoryMax(384)
LoadPlugin("D:/Filters/mpeg2dec3.dll")
LoadPlugin("D:/Filters/decomb500.dll")
LoadPlugin("D:/Filters/awarpsharp.dll")
LoadPlugin("D:/Filters/vaguedenoiser.dll")
LoadPlugin("D:/Filters/dctfilter.dll")
LoadPlugin("D:/Filters/vsfilter.dll")
LoadPlugin("D:/Filters/LoadPluginEx.dll")
LoadPlugin("D:/Filters/convolution3d.dll")
LoadPlugin("D:/Filters/dustv5.dll")
function min(val a, val b) { return (a < b) ? a : b }
function max(val a, val b) { return (a > b) ? a : b }
function NullClip(clip "template") { return BlankClip(template, length=0) }
function JDL_ApplyRange(clip c, int start, int end, string thunk)
{
#stickboy is the man, thanks for writing the JDL functions and trims.
assert(start >= 0 && start < c.FrameCount(), "JDL_ApplyRange: start frame out of
bounds")
assert(end >= start && end < c.FrameCount(), "JDL_ApplyRange: invalid end frame")
seg1 = c.Trim2(0, start)
seg2 = c.Trim3(start, end + 1)
seg3 = c.Trim2(end + 1)
return seg1 + Eval("seg2." + thunk) + seg3
}
function JDL_ApplyFrame(clip c, int frame, string thunk)
{
return JDL_ApplyRange(c, frame, frame, thunk)
}
function Trim2(clip c, int start, int "end", int "length")
{
assert(!(defined(end) && defined(length)),
\ "Trim2: end and length parameters cannot be used together")
assert(!defined(length) || length >= 0,
\ "Trim2: invalid length: " + String(length))
end = defined(end)
\ ? ((end < 0) ? (c.FrameCount() + end) : end)
\ : max(start, c.FrameCount())
end = defined(length) ? (start + length) : end
assert(start >= 0, "Trim2: start frame out of bounds: " + String(start))
assert(end >= start, "Trim2: end frame out of bounds: " + String(end))
start = min(start, c.FrameCount())
end = min(end, c.FrameCount())
# we can't use Trim(start, end - 1) in case end == 1
return (start == end)
\ ? c.NullClip()
\ : c.Trim(start, -(end - start))
}
function Trim3(clip c, int start, int "end", int "length")
{
assert(!(defined(end) && defined(length)),
\ "Trim3: end and length parameters cannot be used together")
assert(!defined(length) || length > 0,
\ "Trim3: invalid length: " + String(length))
end = defined(length) ? (start + length) : default(end, c.FrameCount())
end = (end < 0) ? (c.FrameCount() + end) : end
assert(start >= 0 && start < c.FrameCount(),
\ "Trim3: start frame out of bounds: " + String(start))
assert(end > start && end <= c.FrameCount(),
\ "Trim3: end frame out of bounds:" + String(end))
return c.Trim2(start, end)
}
function TempApply(clip c, int narf)
{
#fools ApplyRange into not being a pain
return c.TemporalSoften(3,3,8,mode=2)
}
Mpeg2Source("D:/Love Hina DVD1/Ep 1/Love Hina Ep 1.d2v")
Telecide(order=1, post=2, back=2, nt=20, blend=true, chroma=true,
ovr="D:/Love Hina DVD1/Ep 1/override.tel")
Good1=Trim(0,10912)
Replace1=Trim(10901,10901)
Replace3=Trim(10901,10903)
Good2=Trim(10920,26918)
Replace4=Trim(26915,26918)
Good3=Trim(26927,38928)
last=Good1 + Replace3 + Replace3 + Replace1 + Good2 + Replace4 + Replace4 + Good3
Decimate(cycle=5, mode=2, quality=3)
#VagueDenoiser(threshold=1.5,method=1,nsteps=6,chroma=true)
aWarpsharp(depth=10, blurlevel=1)
Crop(6, 0, -6, 0)
BicubicResize(640,480)
ApplyRange(0, 2154, "DctFilter", 1, 1, 1, 1, .888, .777, .666, .555)
ApplyRange(29799, 31000, "DctFilter", 1, 1, 1, 1, .888, .777, .666, .555)
ConvertToYUY2()
Convolution3d(preset="animeHQ")
JDL_Applyrange(0, 566, "PixieDust(6)")
Applyrange(567, 576, "TempApply", 6)
JDL_Applyrange(577, 1057, "PixieDust(6)")
Applyrange(1058, 1431, "TempApply", 6)
JDL_Applyrange(1432, 2154, "PixieDust(6)")
Applyrange(2155, 3315, "TempApply", 6)
JDL_Applyrange(3316, 4812, "PixieDust(6)")
Applyrange(4813, 4847, "TempApply", 6)
JDL_Applyrange(4848, 5738, "PixieDust(6)")
Applyrange(5739, 5978, "TempApply", 6)
JDL_Applyrange(5979, 8289, "PixieDust(6)")
Applyrange(8290, 8594, "TempApply", 6)
JDL_Applyrange(8595, 11933, "PixieDust(6)")
Applyrange(11934, 12103, "TempApply", 6)
JDL_Applyrange(12104, 21018, "PixieDust(6)")
Applyrange(21019, 21291, "TempApply", 6)
JDL_Applyrange(21292, 23379, "PixieDust(6)")
Applyrange(23380, 23542, "TempApply", 6)
JDL_Applyrange(23543, 23602, "PixieDust(6)")
Applyrange(23603, 23677, "TempApply", 6)
JDL_Applyrange(23677, 25361, "PixieDust(6)")
Applyrange(25362, 25596, "TempApply", 6)
JDL_Applyrange(25597, 26929, "PixieDust(6)")
Applyrange(26930, 26948, "TempApply", 6)
JDL_Applyrange(26949, 28469, "PixieDust(6)")
Applyrange(28470, 29135, "TempApply", 6)
JDL_Applyrange(29136, 29263, "PixieDust(6)")
Applyrange(29264, 29646, "TempApply", 6)
JDL_Applyrange(29647, 29775, "PixieDust(6)")
Applyrange(29776, 29809, "TempApply", 6)
JDL_Applyrange(29810, 30164, "PixieDust(6)")
Applyrange(30165, 30187, "TempApply", 6)
JDL_Applyrange(30188, 30579, "PixieDust(6)")
Applyrange(30580, 30602, "TempApply", 6)
JDL_Applyrange(30603, 30974, "PixieDust(6)")
Applyrange(30975, 30996, "TempApply", 6)
ConvertToYV12()
Please note that the error occurs only when Virtual dub (it mearly reports the Avisynth error) is dubbing. When seeking though the video, it does not occur. Origenally I was using all JDL_Applyranges, but that would make the error occur at the ~25000 frame mark. This new script makes it occur at the 30976 or so mark.
Im really at my wits end, and could use some assitance from a much smarter higher power (hint hint Sh0dan).
LoadPlugin("D:/Filters/mpeg2dec3.dll")
LoadPlugin("D:/Filters/decomb500.dll")
LoadPlugin("D:/Filters/awarpsharp.dll")
LoadPlugin("D:/Filters/vaguedenoiser.dll")
LoadPlugin("D:/Filters/dctfilter.dll")
LoadPlugin("D:/Filters/vsfilter.dll")
LoadPlugin("D:/Filters/LoadPluginEx.dll")
LoadPlugin("D:/Filters/convolution3d.dll")
LoadPlugin("D:/Filters/dustv5.dll")
function min(val a, val b) { return (a < b) ? a : b }
function max(val a, val b) { return (a > b) ? a : b }
function NullClip(clip "template") { return BlankClip(template, length=0) }
function JDL_ApplyRange(clip c, int start, int end, string thunk)
{
#stickboy is the man, thanks for writing the JDL functions and trims.
assert(start >= 0 && start < c.FrameCount(), "JDL_ApplyRange: start frame out of
bounds")
assert(end >= start && end < c.FrameCount(), "JDL_ApplyRange: invalid end frame")
seg1 = c.Trim2(0, start)
seg2 = c.Trim3(start, end + 1)
seg3 = c.Trim2(end + 1)
return seg1 + Eval("seg2." + thunk) + seg3
}
function JDL_ApplyFrame(clip c, int frame, string thunk)
{
return JDL_ApplyRange(c, frame, frame, thunk)
}
function Trim2(clip c, int start, int "end", int "length")
{
assert(!(defined(end) && defined(length)),
\ "Trim2: end and length parameters cannot be used together")
assert(!defined(length) || length >= 0,
\ "Trim2: invalid length: " + String(length))
end = defined(end)
\ ? ((end < 0) ? (c.FrameCount() + end) : end)
\ : max(start, c.FrameCount())
end = defined(length) ? (start + length) : end
assert(start >= 0, "Trim2: start frame out of bounds: " + String(start))
assert(end >= start, "Trim2: end frame out of bounds: " + String(end))
start = min(start, c.FrameCount())
end = min(end, c.FrameCount())
# we can't use Trim(start, end - 1) in case end == 1
return (start == end)
\ ? c.NullClip()
\ : c.Trim(start, -(end - start))
}
function Trim3(clip c, int start, int "end", int "length")
{
assert(!(defined(end) && defined(length)),
\ "Trim3: end and length parameters cannot be used together")
assert(!defined(length) || length > 0,
\ "Trim3: invalid length: " + String(length))
end = defined(length) ? (start + length) : default(end, c.FrameCount())
end = (end < 0) ? (c.FrameCount() + end) : end
assert(start >= 0 && start < c.FrameCount(),
\ "Trim3: start frame out of bounds: " + String(start))
assert(end > start && end <= c.FrameCount(),
\ "Trim3: end frame out of bounds:" + String(end))
return c.Trim2(start, end)
}
function TempApply(clip c, int narf)
{
#fools ApplyRange into not being a pain
return c.TemporalSoften(3,3,8,mode=2)
}
Mpeg2Source("D:/Love Hina DVD1/Ep 1/Love Hina Ep 1.d2v")
Telecide(order=1, post=2, back=2, nt=20, blend=true, chroma=true,
ovr="D:/Love Hina DVD1/Ep 1/override.tel")
Good1=Trim(0,10912)
Replace1=Trim(10901,10901)
Replace3=Trim(10901,10903)
Good2=Trim(10920,26918)
Replace4=Trim(26915,26918)
Good3=Trim(26927,38928)
last=Good1 + Replace3 + Replace3 + Replace1 + Good2 + Replace4 + Replace4 + Good3
Decimate(cycle=5, mode=2, quality=3)
#VagueDenoiser(threshold=1.5,method=1,nsteps=6,chroma=true)
aWarpsharp(depth=10, blurlevel=1)
Crop(6, 0, -6, 0)
BicubicResize(640,480)
ApplyRange(0, 2154, "DctFilter", 1, 1, 1, 1, .888, .777, .666, .555)
ApplyRange(29799, 31000, "DctFilter", 1, 1, 1, 1, .888, .777, .666, .555)
ConvertToYUY2()
Convolution3d(preset="animeHQ")
JDL_Applyrange(0, 566, "PixieDust(6)")
Applyrange(567, 576, "TempApply", 6)
JDL_Applyrange(577, 1057, "PixieDust(6)")
Applyrange(1058, 1431, "TempApply", 6)
JDL_Applyrange(1432, 2154, "PixieDust(6)")
Applyrange(2155, 3315, "TempApply", 6)
JDL_Applyrange(3316, 4812, "PixieDust(6)")
Applyrange(4813, 4847, "TempApply", 6)
JDL_Applyrange(4848, 5738, "PixieDust(6)")
Applyrange(5739, 5978, "TempApply", 6)
JDL_Applyrange(5979, 8289, "PixieDust(6)")
Applyrange(8290, 8594, "TempApply", 6)
JDL_Applyrange(8595, 11933, "PixieDust(6)")
Applyrange(11934, 12103, "TempApply", 6)
JDL_Applyrange(12104, 21018, "PixieDust(6)")
Applyrange(21019, 21291, "TempApply", 6)
JDL_Applyrange(21292, 23379, "PixieDust(6)")
Applyrange(23380, 23542, "TempApply", 6)
JDL_Applyrange(23543, 23602, "PixieDust(6)")
Applyrange(23603, 23677, "TempApply", 6)
JDL_Applyrange(23677, 25361, "PixieDust(6)")
Applyrange(25362, 25596, "TempApply", 6)
JDL_Applyrange(25597, 26929, "PixieDust(6)")
Applyrange(26930, 26948, "TempApply", 6)
JDL_Applyrange(26949, 28469, "PixieDust(6)")
Applyrange(28470, 29135, "TempApply", 6)
JDL_Applyrange(29136, 29263, "PixieDust(6)")
Applyrange(29264, 29646, "TempApply", 6)
JDL_Applyrange(29647, 29775, "PixieDust(6)")
Applyrange(29776, 29809, "TempApply", 6)
JDL_Applyrange(29810, 30164, "PixieDust(6)")
Applyrange(30165, 30187, "TempApply", 6)
JDL_Applyrange(30188, 30579, "PixieDust(6)")
Applyrange(30580, 30602, "TempApply", 6)
JDL_Applyrange(30603, 30974, "PixieDust(6)")
Applyrange(30975, 30996, "TempApply", 6)
ConvertToYV12()
Please note that the error occurs only when Virtual dub (it mearly reports the Avisynth error) is dubbing. When seeking though the video, it does not occur. Origenally I was using all JDL_Applyranges, but that would make the error occur at the ~25000 frame mark. This new script makes it occur at the 30976 or so mark.
Im really at my wits end, and could use some assitance from a much smarter higher power (hint hint Sh0dan).