Log in

View Full Version : Question Regarding H264 Resolution Requirements


Shoal
19th December 2008, 05:09
Hello all. Here's a basic question from a guy who knows a thing or two about DVDs but is playing catch-up on Blu-Ray and other high-definition material now that the format war is over.

My question is simple: if Blu-Ray's standard is MPEG-4 part 10 (H264/AVC), and this codec requires having resolution width and height be divisible by 16, how then does the high definition height of x1080 work? It's not divisible by 16!

I have no doubt there is a simple answer to this question, but I'm curious all the same. So, at the risk of seeming slow, I ask it.

Thanks!

Dark Shikari
19th December 2008, 05:16
Hello all. Here's a basic question from a guy who knows a thing or two about DVDs but is playing catch-up on Blu-Ray and other high-definition material now that the format war is over.

My question is simple: if Blu-Ray's standard is MPEG-4 part 10 (H264/AVC), and this codec requires having resolution width and height be divisible by 16H.264 has no such requirement.

ajp_anton
19th December 2008, 05:18
Not all of the picture needs to be visible. 1920x1088 is cropped to 1080 during playback.

Shoal
19th December 2008, 05:24
Ah, so the encoded resolution on a Blu-Ray disc is actually 1920x1088? I knew there had to be something like that going on...

And to reply to Dark Shikari, x264 required that videos have a width/height multiple of 16 last time I used it.

Dark Shikari
19th December 2008, 05:31
And to reply to Dark Shikari, x264 required that videos have a width/height multiple of 16 last time I used it.What? It's never had such a requirement, at least not since maybe early 2004 before such functionality was implemented.

Shoal
19th December 2008, 05:40
Only last year I tried to encode something with a height not divisible by 16 and it forced me to put black bars on the top and bottom of the frame to "fill it out" rather than resize the image.

Perhaps it was a /4 or /8 problem? It was last year... perhaps I'm not remembering which divisor it was.

Ranguvar
19th December 2008, 05:43
I don't think x264 requires anything more than mod2... Anything other than mod16 just has borders that are mirrors of the content already on each side placed around it for encoding purposes, to reach mod16, and then the extra is cropped off on playback.

Dark Shikari
19th December 2008, 05:44
I don't think x264 requires anything more than mod2... Anything other than mod16 just has borders that are mirrors of the content already on each side placed around it for encoding purposes, to reach mod16, and then the extra is cropped off on playback.x264 doesn't mirror, it pads with repeated lines. Mirroring makes more sense for JPEG and intra-only formats in general.

Ranguvar
19th December 2008, 05:49
As in it repeats the last line in the source however many times necessary as padding, or as in if it needs 4 lines added, you end up with the first four lines and then the first four lines again?

Shoal
19th December 2008, 05:59
Wait, wait, wait... so, technically, x264 does require mod16? So, if I put input a resolution of 1174x958 it will just pad/mirror/whatever it takes to reach mod16 and crop it off on playback?

...why couldn't you have just said that in the beginning? I mean, it makes sense given the actual x1088 resolution of HD material.

Ranguvar
19th December 2008, 06:08
It's said that x264 doesn't require mod16 because the efficiency lost by the padding is quite minor.

Dark Shikari
19th December 2008, 07:05
Wait, wait, wait... so, technically, x264 does require mod16? So, if I put input a resolution of 1174x958 it will just pad/mirror/whatever it takes to reach mod16 and crop it off on playback?

...why couldn't you have just said that in the beginning? I mean, it makes sense given the actual x1088 resolution of HD material.The resolution is not actually 1920x1088. It is 1920x1080, and that's what any stream analyzer worth its salt will tell you.

The internal coded resolution is 1920x1088. You don't care about this because it is completely internal to the format. For all the decoder cares, the video is 1920x1080, and that's what any media player will tell you.

By your logic, JPEG can't be mod2 or mod4 either (but in reality it works just fine).

Ranguvar
19th December 2008, 21:04
Slightly OT, but is it possible to view the video in its entire *real* resolution after encode? So you see the encoded padding?

/me thinks this might be a neat, if impractical, steganography exercise

Dark Shikari
19th December 2008, 21:24
Slightly OT, but is it possible to view the video in its entire *real* resolution after encode? So you see the encoded padding?Sure, just open the code to libavcodec and remove the cropping code (or just have it set crop flags to zero).

CruNcher
19th December 2008, 21:49
easier under windows it's enough to enable VMR7 or the Overlay Mixer for some Decoder and boom you gonna see the line ;)

Ranguvar
19th December 2008, 22:30
Actually, better yet... the amount to crop is passed in the bitstream of the encoded video at the beginning, right?

*thinks*

Guest
19th December 2008, 23:03
the amount to crop is passed in the bitstream of the encoded video at the beginning, right? It is passed in the SPS, which typically appears periodically throughout the bitstream. When containerized in MP4, however, it may appear once in the container metadata, IIRC.

bob0r
20th December 2008, 09:32
Ah, so the encoded resolution on a Blu-Ray disc is actually 1920x1088? I knew there had to be something like that going on...

And to reply to Dark Shikari, x264 required that videos have a width/height multiple of 16 last time I used it.

Some satellite videos are 1920x1088. All bluray discs are 1920x1080.

Kurtnoise
27th December 2008, 20:41
What? It's never had such a requirement, at least not since maybe early 2004 before such functionality was implemented.
you should drop the warning then...

x264 [warning]: width or height not divisible by 16 (720x520), compression will suffer.

ok, it's just a warning but I was scared when I saw this...:D