View Full Version : A (probably) stupid question regarding mod16
MetalPhreak
20th November 2005, 15:17
I'm currently backing up one of my DVDs. It's a 4:3 PAL disc, now at a few places during the movie (certain scenes) it switches to 16:9 encoded as 4:3 - black borders top and bottom encoded.
I was busy adding my own borders (to remove that soft "feathered" effect at the edges) when I started wonder whether in cases like this if it mattered if the the actual video area is a mod16 resolution.
I'm guessing it doesn't matter, but would just like someone to put my worries to rest.
Thanks.
Anonymouses
20th November 2005, 16:45
As long as the whole frame is mod16 it doesn't matter if those sections of the video inside the black bars aren't.
MetalPhreak
20th November 2005, 16:49
Ok thanks, that's what I figured. I just have the tendancy to get paranoid sometimes and then stuff like this bothers me to no end.
Didée
20th November 2005, 17:21
You might want to make sure that in those letterboxed sequences the border boundaries are aligned to the codec's blocks, i.e. that the letterbox borders have a mod8 height.
If this is not the case, the border boundaries will go "through" codec blocks, and you'll likely get mosquito noise around those border boundaries.
MetalPhreak
20th November 2005, 19:13
Thanks for pointing this out Didée, I'll be sure to have a look at this.
Manao
20th November 2005, 22:08
mod8 is a must. mod16 would be better IF you can do it, because that way borders will be entirely skipped ( else, they'll be most likely encoded with 4 mvs, two of them being useless, which takes more bits ). But it's only some bits lost, whereas non mod8 implies a real quality loss.
MetalPhreak
21st November 2005, 09:11
Manao
Thank you (man I've been saying that a lot). Your explanation made even a n00b like me understand exactly what's going on.
smallbrain
15th April 2007, 11:07
When deleting x garbage lines at the bottom of a digitzed analogue video with
#Crop(clip clip, int left, int top, int -right, int -bottom, bool align)
cropped=crop(video,0,0,0,x)
does the above imply
y=(x modulo 8)
blown=addborders(cropped,0,0,0,y) to preserve the quality of the remaining video?
I assume vertical line cutting requires the same treatment.
Regards
foxyshadis
19th April 2007, 08:33
If it's not interlaced, then no, you're better off resizing with lanczos or spline36. Black borders will harm compression significantly. If it's interlaced you can't resize, so you should clone the lowest remaining x lines onto the bottom (minus 1 for odd x, to repect field order). That'll be less trouble for the DCT encoding.
akupenguin
19th April 2007, 21:37
If for whatever reason you can't scale to mod16 (e.g. interlace), do not use addborders nor clone the remaining lines in avisynth, unless you have some hardware requirement for a specific resolution. You get better quality per bitrate by cropping off all the letterbox, and leaving the height non-mod16. The codec itself will clone the bottom lines in order to internally fill mod16, and that way the codec knows which pixels will be displayed and which are virtual.
chipzoller
22nd April 2007, 15:23
@akupenguin
In your above post, does x264 work the same way regarding a non-mod16 being ok because the encoder will clone the bottom lines...even if the source is progressive film? In my previous and some current DVD encodes I'm doing, I've been putting addborders at the end to achieve a mod16 rather than overcropping to reach a mod16.
akupenguin
23rd April 2007, 07:31
Yes, it's true of x264, xvid, lavc, and probably all mpeg-like codecs you've ever heard of (though I can't directly vouch for the closed-source ones).
chipzoller
23rd April 2007, 16:19
Does the height need to constrain to at least mod8 in this case, or for best bitrate efficiency do you advocate simply cropping off all mattes without regard for final 'active' frame size? This is a new concept to me so I'm very curious about this.
akupenguin
24th April 2007, 06:21
Yes, you get a penalty to compression ratio if the height of the active picture is not mod16, and that penalty is slightly alleviated (though not by much) if it's mod8.
But the point is: adding mattes, or leaving mattes if they came with the source, does not help in any way, and only compounds the penalty. non-mod16 is bad, but non-mod16 plus a black border to bring it up to mod16 is even worse.
There are only three sane choices if your content is not inherently mod16: (1) let the codec deal with it. (2) scale it to the nearest multiple of 16. (3) crop off some of the picture.
If you were going to downscale it anyway, then of course scaling to mod16 is better. But if you wanted to keep the whole input resolution, then I honestly don't know which is better. (1) causes the codec to introduce distortion to compensate for the wasted bits. (2) introduces distortion during the scaling because no scaler is perfect. (3) introduces distortion by losing some pixels entirely. The tradeoff probably depends on resolution and bitrate, with higher resolution and higher bitrate favoring (1) and lower resolution and lower bitrate favoring (2). But I have no idea what the threshold is, and it's hard to benchmark because there's no good metric to compare the quality of two encodes at slightly different resolutions. (3) isn't even possible to compare objectively, since it's a very different type of distortion, so that's purely an aesthetic choice.
chipzoller
24th April 2007, 15:09
I was asking this with downscaling in mind but understand your clear explanation. Basically the problem is two-fold in coming up with a maximum compressibility scheme (from a resolution modulus standpoint): First, when downscaling (standard DVD source assumed) you have to determine the exact PAR of the original and resize with that in mind (if you're a perfectionist), and second to achieve a final resolution (after any cropping and resizing) that would ideally constrain to mod16. Often times the active pixel portion is not natively mod16 and therefore will not be when downsized. The options in this case are to leave (or add) mattes after resizing or overcrop to mod16. I'm very hesitant to overcrop any active pixels even though this loss of 2 or 4 is seemingly minor in the overall picture but find it's often better to resort to this rather than add mattes back into the frame.
After reading this, would you still feel that in my case it is most efficient for bitrate to overcrop to reach mod16, or to simply resize based on the exact PAR (but still leaving no mattes) and thus potentially not have a mod16 resolution?
akupenguin
24th April 2007, 18:17
In that case, you should encode it slightly anamorphic. e.g. instead of res=640:360 par=1:1, use res=640:368 par=46:45.
henryho_hk
25th April 2007, 02:06
If your players support DAR/PAR, you'd better NOT to resize.
chipzoller
25th April 2007, 03:09
I'm assuming backups created for computer playback only. But you bring up a good point-should one simply crop mattes from full DVD resolution and set the DAR for the stream when muxing (matroska assumed)? I'm still trying to figure out what would be...best...in my case.
henryho_hk
25th April 2007, 06:40
Actually, some ppls even suggest cropping mod8 (or 16?) to fit in the DVD MPEG2 macroblocks to maximize encoding performance. Indeed, I do not understand your original question at the 1st place. If those 16:9 scenes are intentional parts of the footage, why do you bother about them?
chipzoller
25th April 2007, 19:28
In my original question I was asking akupenguin if x264 behaved the same way as the previously-mentioned xvid when encoding a non-mod16 resolution. In my previous post I'm asking if it would perhaps be better in my case (again, PC archival and playback of DVD movies) to encode the full-frame (720x480) rather than downsize but to set in the container options 16:9 or 4:3 playback. I generally have been downsizing to 640xX and either overcropping or adding back mattes (which I now understand to be the worst thing to do) to reach mod16.
akupenguin
25th April 2007, 23:56
If your bitrate is high enough to deal with the full 720x480, then that's best.
If not, then downscale, but you can still set DAR after downscaling, so there's no need to compromise between mod16 and exact DAR.
chipzoller
27th April 2007, 05:43
But when downscaling it's still necessary to have the correct PAR in place by resizing with that in mind. The DAR may be something entirely different. I guess I don't quite understand what you mean by being able to downscale, retain the correct PAR and have DAR set in container.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.