Log in

View Full Version : UpSample or SuperSample 480p DVD to 720p HD


lubczyk
31st May 2008, 08:19
I need to know how to UpSample or SuperSample 480p DVD to 720p HD

Supposedly the best method involves Avisynth, FFDshow, and theLimited Sharpen function described here:

http://archive2.avsforum.com/avs-vb/showthread.php?t=606595

I need to resize 720 x 480 or 720 x 400 footage to 1232x688 with
addborders(24,16,24,16,color_black) to compensate for my HDTVs overscan.

Spline36Resize, LanczosResize, and Lanczos4Resize have given me some really bad results up upsizing.

Can someone walk me through it.

It is a general purpose method I'd like to use for all my DVDs. My TVs upscaler isn't the best.

LaTo
31st May 2008, 10:12
###
### function Ultimate Super Sample : USS()
### by LaTo INV.
###
### Need : nnedi, limitedsharpenfaster, gradfunkmirror, addgrain
###
### USS(input, ox, oy, PP1, PP2, PP3)
### ox = destination width
### oy = destination height
### PP1 = "Limited Sharpen Faster" post-processing
### PP2 = "GradFun2DB" post-processing
### PP3 = "Add Grain" post-processing
###
### Default : USS(last, 1280, 720, 100, 1.2, 5)
###

function USS(clip input, int "ox", int "oy", int "PP1", float "PP2", int "PP3") {
ox = default(ox, 1280)
oy = default(oy, 720)
PP1 = default(PP1, 100)
PP2 = default(PP2, 1.2)
PP3 = default(PP3, 5)
ix = input.width
iy = input.height
scaleX = ceil(float(ox)/float(2 * ix))*2
scaleY = ceil(float(oy)/float(2 * iy))*2
scale = scaleX > scaleY ? scaleX : scaleY
upscale2 = scale > 1 ? input
\ .nnedi(dh=true,Y=true,U=true,V=true,field=1).turnleft()
\ .nnedi(dh=true,Y=true,U=true,V=true,field=0).turnright()
\ : input
upscale4 = scale > 2 ? upscale2
\ .nnedi(dh=true,Y=true,U=true,V=true,field=1).turnleft()
\ .nnedi(dh=true,Y=true,U=true,V=true,field=0).turnright()
\ : upscale2
upscale8 = scale > 4 ? upscale4
\ .nnedi(dh=true,Y=true,U=true,V=true,field=1).turnleft()
\ .nnedi(dh=true,Y=true,U=true,V=true,field=0).turnright()
\ : upscale4
upscale16 = scale > 8 ? upscale8
\ .nnedi(dh=true,Y=true,U=true,V=true,field=1).turnleft()
\ .nnedi(dh=true,Y=true,U=true,V=true,field=0).turnright()
\ : upscale8
process = upscale16
\ .limitedsharpenfaster(ss_x=1.0,ss_y=1.0,strength=PP1)
\ .gradfunkmirror(PP2)
\ .addgrain(PP3,0,0)
output = process.spline36resize(ox,oy)
return output
}
###
For you:

USS(1232,688)
Addborders(24,16,24,16)

lubczyk
31st May 2008, 18:11
Can I also use the script to down sample a little bit? I've got some OTA HD footage at 1280 x 720 that I'd like to downsize a little bit to 1232 x 688? In the same manner can I use this script to Down Sample Blu-Ray footage from 1920 x 1080 to this resolution?

TiGR
31st May 2008, 21:14
Wouldn't be something like spline36resize(last.width,last.height*2).nnedi() better than nnedi(dh=true)?

LaTo
1st June 2008, 07:51
Can I also use the script to down sample a little bit? I've got some OTA HD footage at 1280 x 720 that I'd like to downsize a little bit to 1232 x 688? In the same manner can I use this script to Down Sample Blu-Ray footage from 1920 x 1080 to this resolution?
Yes you can, but nnedi work only for upsampling (if you downsample, only spline36resize+postprocess is effective)

lubczyk
1st June 2008, 07:52
Does anyone have a link to download the latest MVTools v1.9.3? Fizick's site seems to be down.

LaTo
1st June 2008, 07:52
Wouldn't be something like spline36resize(last.width,last.height*2).nnedi() better than nnedi(dh=true)?
I don't understand why you want to do that... :confused:

thetoof
1st June 2008, 09:21
Does anyone have a link to download the latest MVTools v1.9.3? Fizick's site seems to be down.
Off topic and no, it's not down.
Here (http://rapidshare.com/files/119251361/mvtools-v1.9.3.zip.html)'s what I just dled from his site if you still can't access it.

lubczyk
1st June 2008, 16:58
It's normal for the script to run at about 3 to 5 fps on DVD material right?

LaTo
1st June 2008, 18:09
It's normal for the script to run at about 3 to 5 fps on DVD material right?
yes... if you want realtime, simply try:

limitedsharpenfaster(dest_x=1232, dest_y=688)
addborders(24,16,24,16)

lubczyk
1st June 2008, 20:59
Both the scripts:

USS()

and

LimitedSharpenFaster()

load correctly but crash in megui and virtualdubmod shortly after.

I can get some videos encoded, but crashes happen constantly.

I'm using Windows Vista Business 32-bit.

I have to encode videos one at a time in VirturalDubMod (Megui crashes).

jeffy
1st June 2008, 21:14
Try SetMemoryMax(512) or less at the beginning of the script.

lubczyk
1st June 2008, 23:05
Try SetMemoryMax(512) or less at the beginning of the script.



Nope it still crashes. I have Administer Privileges BTW.

Here's My Entire Script:

SetMemoryMax(512)

LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\AddGrainC.dll")
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\nnedi.dll")
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\mt_masktools-25.dll")
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\mt_masktools-26.dll")
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\gradfun2db.dll")

mpeg2source("C:\Users\LUBCZYK\Desktop\Encoding\HiddenDragon.d2v

Import("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\LimitedSharpenFaster.avsi")
Import("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\GradFunkMirror.avsi")
Import("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\USS.avsi")

#USS(1232,688)
limitedsharpenfaster(dest_x=1232, dest_y=688)
Addborders(24,16,24,16)

jeffy
2nd June 2008, 06:12
Have you tried a lower value, eg. SetMemoryMax(128)? Does it still crash?

LaTo
2nd June 2008, 06:44
LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\mt_masktools-26.dll")
Remove this line!


LoadPlugin("F:\PS3 Encoding\Program Files\AviSynth 2.5\plugins\RemoveGrainSSE3.dll")
Your CPU is SSE3? If not, try RemoveGrain.dll


mpeg2source("C:\Users\LUBCZYK\Desktop\Encoding\HiddenDragon.d2v")
Don't forget the ") at the end

Delta2
2nd June 2008, 11:28
For you:

USS(1232,688)
Addborders(24,16,24,16)


I'm interested in this too, but it gives me this error :

Invalid arguments to function gradfunkmirror

And the function is :

##Standard gradfunk

function gradfunk(clip c, int strength) {
strength=default(strength,1.2)
return c.addborders(16,16,16,16).gradfun2db(strength).crop(16,16,-16,-16)
}

##Corners will be ignored

function gradfunkmirror(clip c, int strength) {
strength=default(strength,1.2)
vflip = c.FlipVertical()
hflip = c.FlipHorizontal()
return stackhorizontal(hflip.crop(c.width-16,0,16,c.height).addborders(0,16,0,16),stackvertical(vflip.crop(0,c.height-16,c.width,0),c,vflip.crop(0,0,c.width,16)),hflip.crop(0,0,16,c.height).addborders(0,16,0,16)).gradfun2db(strength).crop(16,16,-16,-16)
}

the script :

LoadPlugin("AddGrain.dll")
LoadPlugin("nnedi.dll")
LoadPlugin("gradfun2db.dll")
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("RemoveGrain.dll")


AVISource("F:\gcond\Munich.2005.DVDSCR.XviD-DVL\partes\dvl-munich1-1.avi")

Import("LimitedSharpenFaster.avsi")
Import("GradFunkMirror.avsi")
Import("USS.avsi")

USS(1232,688)
Addborders(24,16,24,16)

Didée
2nd June 2008, 11:49
It would be advisable to make changes to gradfunk/mirror as follows:

##Standard gradfunk

function gradfunk(clip c, float "strength") {
strength=default(strength,1.2)
[...]
}

##Corners will be ignored

function gradfunkmirror(clip c, float "strength") {
strength=default(strength,1.2)
vflip = c.FlipVertical()
[...]
}

Parameters without quotations are mandatory to be specified when doing the function call. It makes zero sense to have a Default() statement for mandatory parameters.

With quotation marks, the parameters are optional, and the Default() statement actually makes sense.

Delta2
2nd June 2008, 11:58
Parameters without quotations are mandatory to be specified when doing the function call.


thanks, I made that change but still get this error :

Script error: Invalid arguments to function "gradfunkmirror" USS.avsi, line 47

Seems to be gradfunkmirror(PP2) function call


----


##Standard gradfunk

function gradfunk(clip c, int "strength") {
strength=default(strength,1.2)
return c.addborders(16,16,16,16).gradfun2db(strength).crop(16,16,-16,-16)
}

##Corners will be ignored

function gradfunkmirror(clip c, int "strength") {
strength=default(strength,1.2)
vflip = c.FlipVertical()
hflip = c.FlipHorizontal()
return stackhorizontal(hflip.crop(c.width-16,0,16,c.height).addborders(0,16,0,16),stackvertical(vflip.crop(0,c.height-16,c.width,0),c,vflip.crop(0,0,c.width,16)),hflip.crop(0,0,16,c.height).addborders(0,16,0,16)).gradfun2db(strength).crop(16,16,-16,-16)
}

Didée
2nd June 2008, 12:04
Aaah, where did I have my eyes. Have a closer look at my edited post above. ;) (int => float)

Delta2
2nd June 2008, 12:18
Aaah, where did I have my eyes. Have a closer look at my edited post above. ;) (int => float)

gosh, and mine, lol :)

thanks

works fine now, seems to be a great upscaling method

Gavino
2nd June 2008, 17:34
Parameters without quotations are mandatory to be specified when doing the function call. It makes zero sense to have a Default() statement for mandatory parameters.

Your point is obviously valid here, but just for the record (and being very pedantic), this isn't strictly true. Default() checks whether a value is defined, not whether it has been supplied, and it is possible for a mandatory parameter to have an undefined value.

Consider the following (contrived) example:

function f1(string "x") {
f2(x)
}
function f2(val x) { # x mandatory
x = Default(x, "it works")
return x
}
BlankClip().Subtitle(f1())

:):):)

egrimisu
3rd July 2008, 17:49
When to use USS? before ivtc and denoiseing or after the crop at the end of the script?

Soulhunter
3rd July 2008, 19:04
It would be advisable to make changes to gradfunk/mirror as follows:


function gradfunkmirror(clip c, float "strength") {
strength=default(strength,1.2)
vflip = c.FlipVertical()
[...]
}

Actually thats like teh version I put in the gradfun2db zip (http://soulhunter.chronocrossdev.com/data/gradfun2db.zip) some time ago! :]


Bye

martino
3rd July 2008, 19:36
When to use USS? before ivtc and denoiseing or after the crop at the end of the script?
After IVTC.

egrimisu
4th July 2008, 06:16
I don;t know why but upscaling produce great video quality for anime, to bad is freaking slow 1fps(+ denoisers and stuff) for e6850@3600 4gb ram.