digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Video Encoding and Conversion (http://www.digitalfaq.com/archives/encode/)
-   -   Improved Replacement for GripFit (http://www.digitalfaq.com/archives/encode/8043-improved-replacement-gripfit.html)

vmesquita 02-05-2004 10:40 AM

Improved Replacement for GripFit
 
Hi everyone,

It took a while, but finally gripfit gave me that caught an access violation error.
EDIT: The function has been improved to do macroblock optimization and has been divided in two: DivXResize and divxborders. Replace gripcrop and gripsize by DivXresize, and gripborders by DivXBorders. Please note that the parameters are different from the Grip functions:

How to use:

DivXResize(width,height, overscan,resizer)
DivXBorders(height,overscan)

where width and height are the destination ones, and resizer is "bicubicresize","bilinearresize" or "lanczosresize"

#######
# Script
########
Function DivXResize(clip c, int WIDTH, int HEIGHT, int OVERSCAN, string RESIZER) {
halfheight43=(round(c.width()/1.33333)-c.height())/2

#What would be the height keeping the aspect ratio if width was 640/320-NTSC or 768/384-PAL(4:3)
no_borders_height1=c.height()
no_borders_height1=(HEIGHT == 480) ? (640*c.height())/(c.width()) : no_borders_height1
no_borders_height1=(HEIGHT == 240) ? (320*c.height())/(c.width()) : no_borders_height1

no_borders_height1=(HEIGHT == 576) ? (768*c.height())/(c.width()) : no_borders_height1
no_borders_height1=(HEIGHT == 288) ? (384*c.height())/(c.width()) : no_borders_height1

#Now how much we have to shrink to make it fit inside a macroblock?
mod16height=no_borders_height1 % 16

#If the rest is <=8, subtracts the rest, else, completes to 16.
completion= (mod16height <= 8) ? (-mod16height) : (16-mod16height)
no_borders_height2=no_borders_height1+completion

#finally resize
c=Eval( RESIZER + "(c," + string(WIDTH) + "," + string(no_borders_height2) + ")" )

#add lateral overscan
c=letterbox(c,0,0,overscan*8,overscan*8)
return(c)
}

Function DivXBorders(clip c, int HEIGHT, int OVERSCAN) {
halfheight43=(HEIGHT-c.height())/2
c=addborders(c,0,halfheight43,0,halfheight43)
#Add vertical overscan
c=letterbox(c,overscan*8,overscan*8,0,0)
return(c)
}

Edlund 02-07-2004 05:45 AM

So where can we download it from?

Boulder 02-07-2004 07:14 AM

No need to download anything, the needed function is in vmesquita's post. You can cut and paste it into Notepad and save it in your AVS2.5 plugins folder with the extension .avsi and it will be automatically loaded when it is called.

jonny_eh 02-09-2004 12:56 AM

I like how you put an emoticon in the script :)

I had one avi file that didn't quite work with it. The resulting aspect ratio was a little off, i.e. the people looked slightly squished.

The source dimensions: 640*320

It's a very cool function indeed. How does moviestacker calculate? Maybe you could have just borrowed from them?

vmesquita 02-09-2004 04:42 PM

Hi jonny_eh,

I don't know if this is the problem, but remember that actually 704x480 is not 4:3, people look squished when you play the mpeg in the monitor in a window, but in the TV it is squized to 4:3.
Actually I never used moviestacker. I just implemented in the function the calculation I used to do manually before I discovered gripfit. Basically. it first complements the image above and below with black borders to make it 4:3. Then it resizes to the final resolution.
So in your case:
640*320 if first complemented with 80 pixels of border above and 80 pixels of borders below, making it 640x480. Then the image is resized to 704x480.
One thing I did not implement is macroblock optimization. It's not hard to add this, but it's so much to do... :D

Dialhot 02-09-2004 05:20 PM

Don't bother yourself with that. use Moviestacker that's all :-)

vmesquita 02-09-2004 05:28 PM

Quote:

Originally Posted by Dialhot
Don't bother yourself with that. use Moviestacker that's all :-)

Dialhot,

Actually I wanted to develop this to use in DIKO :D But I'll download MovieStacker now and try to get some ideas from it.

vmesquita 02-15-2004 10:58 AM

I improved the function to work more like gripfit and do macroblock optimization! :D :D :D

Critter 02-21-2004 10:10 AM

Nice work ! But what about GripFits dest_anamorphic=true option.

I have done many skvcds (2 CD) with anamorphic picture. No need to play with TVs zoom button :)

vmesquita 02-21-2004 06:15 PM

Critter,

You can use this functions, just replace 1.33333 for 1.777 and you're all set. But I advise against doing this since you can get a better picture by zooming the TV instead of encoding anamorphic, since you're DivX A.R. 1:1 is much close to 1:333 than 1:7777, so you're enlarging artificially the picture, losing compressibility but not gaining any resolution. :wink:


All times are GMT -5. The time now is 02:49 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.