DDogg
21st August 2003, 14:45
The Semi-Auto Script of gerti67's for DVD2SVCD will no longer work with the August 20 build.
This script:
mpeg2source("C:\PROGRA~1\DVD2SVCD\TEMP\preview.d2v")
DetectedTop=6 DetectedHeight=468
BlocksToCropHorizontal=2 BlocksToCropVertical=2 BlockOptimization=16
ResizeMethod=3 Bicubic_b_Value=0.0 Bicubic_c_Value=0.55
GammaCorrection=1.0 Hue=0 Saturation=1.0 Brightness=5.0 Contrast=1.0
DebugMode=0
DestinationWidth=480
DestinationHeight=360
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SimpleResize.dll")
Import("C:\Program Files\AviSynth 2.5\plugins\autocrop\SemiAutoCropAndResize.avs")
Which imports the script below fails at the section titled "#### Output the clip
correctly cropped and resized and with borders added". If you Comment out the
resizing line in the script below that is specified in the script above,
the script will play.
#### SemiAutoCropAndResize Script - v1.05 - by gerti67
#### Parameter definitions and (useful) ranges
# -- Used internally by the script
# -- DestinationSystemHeight : {480, 576}
# -- DestinationSubSystemHeight : {240, 288}
# -- DestinationWidth : {352, 480, 720}
# -- DestinationHeight : {180, 216, 240, 288, 360, 432, 480, 576}
# -- HorizontalFactor : {0.500000, 0.666666, 1.000000}
# -- VerticalFactor : {0.375000, 0.500000, 0.750000, 1.000000}
# -- Correct704Factor : {0.977777, 1.000000}
# -- Editable by user via DVD2SVCD's "Frameserver" tab
# -- DetectedTop : {0 ..}
# -- DetectedHeight . {0 ..}
# -- BlocksToCropHorizontal : {0, 1, 2}
# -- BlocksToCropVertical : {0, 1, 2}
# -- BlockOptimization : {1, 2, 4, 8, 16}
# -- ResizeMethod : {1, 2, 3, 4}
# -- Bicubic_b_Value : {0.00 .. 1.00}
# -- Bicubic_c_Value : {0.00 .. 1.00}
# -- GammaCorrection : {0.50 .. 1.50}
# -- Hue : {-180 .. 180}
# -- Saturation : {0.0 .. 10.0}
# -- Brightness : {-255 .. 255}
# -- Contrast : {0.0 .. 10.0}
# -- DebugMode : {0, 1, 2}
#### Calculate some important base parameters
DestinationSystemHeight = (DestinationHeight % 5 > 0) ? 576 : 480
DestinationSubSystemHeight = (DestinationHeight / 360. < 1) ? DestinationSystemHeight / 2 : DestinationSystemHeight
HorizontalFactor = (DestinationWidth < 480) ? 0.5 : DestinationWidth / 720.
VerticalFactor = DestinationHeight / DestinationSystemHeight * 1.
Correct704Factor = (DestinationWidth == 352) ? 0.977777 : 1.
#### Correct DetectedHeight according to BlocksToCrop value if necessary
CropTop = (DetectedTop < BlocksToCropVertical * 8) ? BlocksToCropVertical * 8 : Round(DetectedTop / 2.) * 2
DetectedHeight = (DetectedTop < CropTop) ? DetectedHeight - CropTop + DetectedTop : DetectedHeight
DetectedHeight = ((CropTop + DetectedHeight) > (DestinationSystemHeight - BlocksToCropVertical * 8)) ? DetectedHeight - (CropTop + DetectedHeight - DestinationSystemHeight + BlocksToCropVertical * 8) : DetectedHeight
#### Calculate rest of the crop values and make sure they're YUV12 aware
CropLeft = Round((BlocksToCropHorizontal * 4.) / (HorizontalFactor * 1.)) * 2
CropWidth = Round((Width - 2 * CropLeft) / 2.) * 2
CropHeight = Round(DetectedHeight / 2.) * 2
#### Calculate destination width and height and make sure they're YUV12 aware
NewDestinationWidth = Round((DestinationWidth - BlocksToCropHorizontal * 16) / 4.) * 4
NewDestinationHeight = Round(CropHeight * VerticalFactor * Correct704Factor) - Round(CropHeight * VerticalFactor * Correct704Factor) % 2
#### If going for VCD then we have to do some backward calculations to get the desired minimal borders due to VCD resolution based on 704x480/576
VCDCorrection = ((DestinationSubSystemHeight - NewDestinationHeight) < (BlocksToCropVertical * 16)) ? 1 : 0
NewDestinationHeight = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? DestinationSubSystemHeight - BlocksToCropVertical * 16 : NewDestinationHeight
CropHeight = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? Round(NewDestinationHeight * 1.022727) * 2 : CropHeight
CropTop = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? Round((DestinationSystemHeight - CropHeight) / 4.) * 2 : CropTop
#### Calculate borders to reach the system destination size
BorderLeft = Round((DestinationWidth - NewDestinationWidth) / 4.) * 2
BorderRight = DestinationWidth - NewDestinationWidth - BorderLeft
#### Optimize TopBorder to be aligned on desired multiples of BlockOptimization
BorderTop = Round((DestinationSubSystemHeight - NewDestinationHeight) / (2. * BlockOptimization)) * BlockOptimization
BorderBottom = DestinationSubSystemHeight - NewDestinationHeight - BorderTop
#### Output the clip correctly cropped and resized and with borders added
Crop(CropLeft, CropTop, CropWidth, CropHeight)
#######***************************************************
#######***************************************************
#######************* SCRIPT FAILS HERE *******************
(ResizeMethod == 1) ? BilinearResize(NewDestinationWidth, NewDestinationHeight) : NOP()
(ResizeMethod == 2) ? BicubicResize(NewDestinationWidth, NewDestinationHeight, Bicubic_b_Value, Bicubic_c_Value) : NOP()
(ResizeMethod == 3) ? LanczosResize(NewDestinationWidth, NewDestinationHeight) : NOP()
(ResizeMethod == 4) ? SimpleResize(NewDestinationWidth, NewDestinationHeight) : NOP()
######*****************************************************
#######****************************************************
#######****************************************************
((Hue <> 0) || (Saturation <> 1) || (Brightness <> 0) || (Contrast <> 1)) ? Tweak(Hue, Saturation, Brightness, Contrast) : NOP()
(GammaCorrection <> 1) ? Levels(0, GammaCorrection, 255, 0, 255) : NOP()
Last=AddBorders(BorderLeft, BorderTop, BorderRight, BorderBottom)
#### Output debug values
(DebugMode > 0) ? Subtitle("Crop", 20, 20) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(CropLeft) + "," + String(CropTop) + "," + String(CropWidth) + "," + String(CropHeight) + ")", 90, 20) : NOP()
(DebugMode > 0) ? Subtitle("Resize", 20, 40) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(NewDestinationWidth) + "," + String(NewDestinationHeight) + ")", 90, 40) : NOP()
(DebugMode > 0) ? Subtitle("Borders", 20, 60) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(BorderLeft) + "," + String(BorderTop) + "," + String(BorderRight) + "," + String(BorderBottom) + ")", 90, 60) : NOP()
(DebugMode > 1) ? Subtitle("Detected", 20, 100) : NOP()
(DebugMode > 1) ? Subtitle(": T " + String(DetectedTop) + " / H " + String(DetectedHeight), 90, 100) : NOP()
(DebugMode > 1) ? Subtitle("System", 20, 120) : NOP()
(DebugMode > 1) ? Subtitle(": H " + String(DestinationSystemHeight) + " / S " + String(DestinationSubSystemHeight), 90, 120) : NOP()
(DebugMode > 1) ? Subtitle("Factors", 20, 140) : NOP()
(DebugMode > 1) ? Subtitle(": H " + LeftStr(String(HorizontalFactor), 6) + " / V " + LeftStr(String(VerticalFactor), 6)+ " / C " + LeftStr(String(Correct704Factor), 6), 90, 140) : NOP()
#### Return a Clip or it will crash!
Return(last)
Reference Thread:http://forum.doom9.org/showthread.php?s=&threadid=55641
This script:
mpeg2source("C:\PROGRA~1\DVD2SVCD\TEMP\preview.d2v")
DetectedTop=6 DetectedHeight=468
BlocksToCropHorizontal=2 BlocksToCropVertical=2 BlockOptimization=16
ResizeMethod=3 Bicubic_b_Value=0.0 Bicubic_c_Value=0.55
GammaCorrection=1.0 Hue=0 Saturation=1.0 Brightness=5.0 Contrast=1.0
DebugMode=0
DestinationWidth=480
DestinationHeight=360
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SimpleResize.dll")
Import("C:\Program Files\AviSynth 2.5\plugins\autocrop\SemiAutoCropAndResize.avs")
Which imports the script below fails at the section titled "#### Output the clip
correctly cropped and resized and with borders added". If you Comment out the
resizing line in the script below that is specified in the script above,
the script will play.
#### SemiAutoCropAndResize Script - v1.05 - by gerti67
#### Parameter definitions and (useful) ranges
# -- Used internally by the script
# -- DestinationSystemHeight : {480, 576}
# -- DestinationSubSystemHeight : {240, 288}
# -- DestinationWidth : {352, 480, 720}
# -- DestinationHeight : {180, 216, 240, 288, 360, 432, 480, 576}
# -- HorizontalFactor : {0.500000, 0.666666, 1.000000}
# -- VerticalFactor : {0.375000, 0.500000, 0.750000, 1.000000}
# -- Correct704Factor : {0.977777, 1.000000}
# -- Editable by user via DVD2SVCD's "Frameserver" tab
# -- DetectedTop : {0 ..}
# -- DetectedHeight . {0 ..}
# -- BlocksToCropHorizontal : {0, 1, 2}
# -- BlocksToCropVertical : {0, 1, 2}
# -- BlockOptimization : {1, 2, 4, 8, 16}
# -- ResizeMethod : {1, 2, 3, 4}
# -- Bicubic_b_Value : {0.00 .. 1.00}
# -- Bicubic_c_Value : {0.00 .. 1.00}
# -- GammaCorrection : {0.50 .. 1.50}
# -- Hue : {-180 .. 180}
# -- Saturation : {0.0 .. 10.0}
# -- Brightness : {-255 .. 255}
# -- Contrast : {0.0 .. 10.0}
# -- DebugMode : {0, 1, 2}
#### Calculate some important base parameters
DestinationSystemHeight = (DestinationHeight % 5 > 0) ? 576 : 480
DestinationSubSystemHeight = (DestinationHeight / 360. < 1) ? DestinationSystemHeight / 2 : DestinationSystemHeight
HorizontalFactor = (DestinationWidth < 480) ? 0.5 : DestinationWidth / 720.
VerticalFactor = DestinationHeight / DestinationSystemHeight * 1.
Correct704Factor = (DestinationWidth == 352) ? 0.977777 : 1.
#### Correct DetectedHeight according to BlocksToCrop value if necessary
CropTop = (DetectedTop < BlocksToCropVertical * 8) ? BlocksToCropVertical * 8 : Round(DetectedTop / 2.) * 2
DetectedHeight = (DetectedTop < CropTop) ? DetectedHeight - CropTop + DetectedTop : DetectedHeight
DetectedHeight = ((CropTop + DetectedHeight) > (DestinationSystemHeight - BlocksToCropVertical * 8)) ? DetectedHeight - (CropTop + DetectedHeight - DestinationSystemHeight + BlocksToCropVertical * 8) : DetectedHeight
#### Calculate rest of the crop values and make sure they're YUV12 aware
CropLeft = Round((BlocksToCropHorizontal * 4.) / (HorizontalFactor * 1.)) * 2
CropWidth = Round((Width - 2 * CropLeft) / 2.) * 2
CropHeight = Round(DetectedHeight / 2.) * 2
#### Calculate destination width and height and make sure they're YUV12 aware
NewDestinationWidth = Round((DestinationWidth - BlocksToCropHorizontal * 16) / 4.) * 4
NewDestinationHeight = Round(CropHeight * VerticalFactor * Correct704Factor) - Round(CropHeight * VerticalFactor * Correct704Factor) % 2
#### If going for VCD then we have to do some backward calculations to get the desired minimal borders due to VCD resolution based on 704x480/576
VCDCorrection = ((DestinationSubSystemHeight - NewDestinationHeight) < (BlocksToCropVertical * 16)) ? 1 : 0
NewDestinationHeight = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? DestinationSubSystemHeight - BlocksToCropVertical * 16 : NewDestinationHeight
CropHeight = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? Round(NewDestinationHeight * 1.022727) * 2 : CropHeight
CropTop = ((DestinationSubSystemHeight <= 288) && (VCDCorrection == 1)) ? Round((DestinationSystemHeight - CropHeight) / 4.) * 2 : CropTop
#### Calculate borders to reach the system destination size
BorderLeft = Round((DestinationWidth - NewDestinationWidth) / 4.) * 2
BorderRight = DestinationWidth - NewDestinationWidth - BorderLeft
#### Optimize TopBorder to be aligned on desired multiples of BlockOptimization
BorderTop = Round((DestinationSubSystemHeight - NewDestinationHeight) / (2. * BlockOptimization)) * BlockOptimization
BorderBottom = DestinationSubSystemHeight - NewDestinationHeight - BorderTop
#### Output the clip correctly cropped and resized and with borders added
Crop(CropLeft, CropTop, CropWidth, CropHeight)
#######***************************************************
#######***************************************************
#######************* SCRIPT FAILS HERE *******************
(ResizeMethod == 1) ? BilinearResize(NewDestinationWidth, NewDestinationHeight) : NOP()
(ResizeMethod == 2) ? BicubicResize(NewDestinationWidth, NewDestinationHeight, Bicubic_b_Value, Bicubic_c_Value) : NOP()
(ResizeMethod == 3) ? LanczosResize(NewDestinationWidth, NewDestinationHeight) : NOP()
(ResizeMethod == 4) ? SimpleResize(NewDestinationWidth, NewDestinationHeight) : NOP()
######*****************************************************
#######****************************************************
#######****************************************************
((Hue <> 0) || (Saturation <> 1) || (Brightness <> 0) || (Contrast <> 1)) ? Tweak(Hue, Saturation, Brightness, Contrast) : NOP()
(GammaCorrection <> 1) ? Levels(0, GammaCorrection, 255, 0, 255) : NOP()
Last=AddBorders(BorderLeft, BorderTop, BorderRight, BorderBottom)
#### Output debug values
(DebugMode > 0) ? Subtitle("Crop", 20, 20) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(CropLeft) + "," + String(CropTop) + "," + String(CropWidth) + "," + String(CropHeight) + ")", 90, 20) : NOP()
(DebugMode > 0) ? Subtitle("Resize", 20, 40) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(NewDestinationWidth) + "," + String(NewDestinationHeight) + ")", 90, 40) : NOP()
(DebugMode > 0) ? Subtitle("Borders", 20, 60) : NOP()
(DebugMode > 0) ? Subtitle(": (" + String(BorderLeft) + "," + String(BorderTop) + "," + String(BorderRight) + "," + String(BorderBottom) + ")", 90, 60) : NOP()
(DebugMode > 1) ? Subtitle("Detected", 20, 100) : NOP()
(DebugMode > 1) ? Subtitle(": T " + String(DetectedTop) + " / H " + String(DetectedHeight), 90, 100) : NOP()
(DebugMode > 1) ? Subtitle("System", 20, 120) : NOP()
(DebugMode > 1) ? Subtitle(": H " + String(DestinationSystemHeight) + " / S " + String(DestinationSubSystemHeight), 90, 120) : NOP()
(DebugMode > 1) ? Subtitle("Factors", 20, 140) : NOP()
(DebugMode > 1) ? Subtitle(": H " + LeftStr(String(HorizontalFactor), 6) + " / V " + LeftStr(String(VerticalFactor), 6)+ " / C " + LeftStr(String(Correct704Factor), 6), 90, 140) : NOP()
#### Return a Clip or it will crash!
Return(last)
Reference Thread:http://forum.doom9.org/showthread.php?s=&threadid=55641