BestFit()_v1.0.1 - mixing different aspect ratio's

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: BestFit() and mixing footage with different aspect ratio's

Post by Phantasmagoriat » Mon Jun 07, 2010 12:12 pm

Mister Hatt wrote:Why do you care about mod16?
The website above wrote:Modern digital video applications such as DV, DVD and digital television (DVB, ATSC) often use MPEG-1 or MPEG-2 formats (or their derivatives) which are all based on 16×16 pixel macroblocks. Having the height and width of the image readily divisible by 16 makes it easier and more efficient for an MPEG encoder to compress video.
Actually... I would say it's because in computing, 16 is a magical number :book:
so are 2, 4 , 8, 16, 32, 64, 128, 256, 512...


Mister Hatt wrote:Also, the DVD aspects are all wrong. You're not taking the active picture region into account.
The website above wrote:...the difference between the correct aspect ratio and a wrong aspect ratio is often small enough to go unnoticed unless you really start looking for it.
:aimkissyface:
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
mirkosp
The Absolute Mudman
Joined: Mon Apr 24, 2006 6:24 am
Status: (」・ワ・)」(⊃・ワ・)⊃
Location: Gallarate (VA), Italy
Contact:
Org Profile

Re: BestFit() and mixing footage with different aspect ratio's

Post by mirkosp » Mon Jun 07, 2010 12:20 pm

Phantasmagoriat wrote:
Mister Hatt wrote:Why do you care about mod16?
The website above wrote:Modern digital video applications such as DV, DVD and digital television (DVB, ATSC) often use MPEG-1 or MPEG-2 formats (or their derivatives) which are all based on 16×16 pixel macroblocks. Having the height and width of the image readily divisible by 16 makes it easier and more efficient for an MPEG encoder to compress video.
Actually... I would say it's because in computing, 16 is a magical number :book:
so are 2, 4 , 8, 16, 32, 64, 128, 256, 512...
mod8 and maybe even mod4 are more than fine with AVC though. Actually hell, even mod2 probably is. Anyway, for instance, 1920x1080 is mod8. x264 internally pads the image to mod16 (1088 in this case) and sets it so that those pixels get cropped over playback. Of course, letting x264 do this automatically gives better results that leaving the padding on or stretching the image to a mod16 resolution manually. So yes, resizing or cropping/letterboxing to mod16 is not nearly as much of a need as it used to be.
Mister Hatt wrote:Also, the DVD aspects are all wrong. You're not taking the active picture region into account.
The website above wrote:...the difference between the correct aspect ratio and a wrong aspect ratio is often small enough to go unnoticed unless you really start looking for it.
:aimkissyface:
This I can agree with... the difference is generally unnoticeable, unless you have some really wrong crop and resize parameters that make it obvious. Stuff that should be round but isn't quite right tends to be the giveaway for me... sometimes without the need to actually look for it.
Image

Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: BestFit() and mixing footage with different aspect ratio's

Post by Mister Hatt » Mon Jun 07, 2010 10:52 pm

Keep in mind how old that document is please. Mod16 is entirely useless with newer encoders due to them not being as horribly inefficient as DivX5 was. The whole mod16 thing became important due to MPEG2 and MPEG4-ASP codecs being pretty damn terrible, but with x264 it's not really a problem. As far as aspect differences go, you're right, very few people can notice it, but it DOES leave a rather large amount of aliasing on curving high-contrast lines which really isn't too difficult to see. If you're really going to go for the "nobody can tell the difference" angle, why not just ignore BestFit() altogether and just resize to whichever main AR you're gonna use on the project?

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: BestFit() and mixing footage with different aspect ratio's

Post by Phantasmagoriat » Tue Jun 08, 2010 1:50 am

That's kind of neat. I didn't know x264 adjusted for mod16 like that. But still, I think it's a nice option to have for backwards compatibility, and it's not difficult to implement either: It simply divides by 16, rounds, then multiplies by 16. (or whatever mod value you like).

Regarding this 'active picture region' thing... I'm gonna be honest with you-- I totally didn't read that. I started to... but it got a little absurd. Seriously how big of a difference are we talking about here? The 8 pixels from the left and right that I always crop off? For something that seems so small is there at least a simple algorithm for achieving the correct aspect without using those tables?

If you are worried about aliasing, try to keep in mind the purpose of BestFit()-- to mix footage of different shapes and sizes... so in the end no image will be in it's optimal resolution to begin with, which would likely contribute more to aliasing than a minute change in aspect. Not that I see this being a huge problem when using spline resizers by default.

Also, I'm not sure this issue is even relevant to BestFit(). It is assumed that the input aspect is correct to begin with. The original proportions of width/height are maintained regardless of resizing, cropping, or adding borders-- so I don't see how anything can go wrong, unless there was an error with the input video.
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by Phantasmagoriat » Fri Jun 11, 2010 10:08 pm

Script updated to v1.0.1 :)
-new parameter 'modb' should allow borders to be divisible by whatever integer you specify for modb (ex. modb=16)
-added lists to the first post: Changelog, TODO, and Known Bugs

Let me know if you have suggestions, or encounter any problems.
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Mol
Strawberry Pie
Joined: Thu Feb 22, 2007 2:28 am
Status: sutatS
Location: Sweden
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by Mol » Mon Jun 14, 2010 9:30 am

looks ar noob friendly :P , will try it out,... just wondering can if it cooperate with nnedi ;p
Still better than that MMO.
Image

User avatar
mirkosp
The Absolute Mudman
Joined: Mon Apr 24, 2006 6:24 am
Status: (」・ワ・)」(⊃・ワ・)⊃
Location: Gallarate (VA), Italy
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by mirkosp » Mon Jun 14, 2010 10:04 am

I don't think you can tell it to use nnedi/nnedi2/nnedi3... although you'd only need that when upscaling, and the way you upscale with nnedi filters is pretty much pointresize(width*2,height*2).nnedi2.turnleft.nnedi2.turnright so what you'd do is probably upscale to a bigger res with the nnedi filter you prefer (atm nnedi2 is the best one, nnedi3 can use improvements, especially for speed) and then use bestfit to downscale back.
Image

User avatar
Mol
Strawberry Pie
Joined: Thu Feb 22, 2007 2:28 am
Status: sutatS
Location: Sweden
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by Mol » Mon Jun 14, 2010 10:41 am

nah , too bad .. well i guess i will go with default and see the outcome first ; o.
Still better than that MMO.
Image

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by Phantasmagoriat » Mon Jun 14, 2010 12:26 pm

I believe nnedi works best for resizing by powers of 2, so it won't work unless you do what mirko suggested.

By default bestfit uses spline36resize, so you should still get good results ;)
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
mirkosp
The Absolute Mudman
Joined: Mon Apr 24, 2006 6:24 am
Status: (」・ワ・)」(⊃・ワ・)⊃
Location: Gallarate (VA), Italy
Contact:
Org Profile

Re: BestFit()_v1.0.1 - mixing different aspect ratio's

Post by mirkosp » Mon Jun 14, 2010 2:31 pm

Yeah, it's by powers of 2 and its usage is much different of the one of other resizers, so I don't think there's a way to really use it inside bestfit, unless it's somehow internally called when upscaling.
Image

Locked

Return to “AviSynth Help”