View Full Version : Ways to find ratio of macroblocks using encoder or decoder?
tchau83
10th March 2007, 04:14
Hi, I’m new to this area and I hope you experts would be able to help me out.
I’m a university student working on a hardware implementation of a H.264 decoder.
I would like to know the ratio of the macroblocks, e.g., 4x4P, 16x16B, used in a typical highly compressed video. Is there any software decoder that has an option to find out the total number of macroblocks used in a video stream? Also, where can I get raw H.264 files (main profile) for decoding?
The other way seems to be for me to encode video clips myself. Where can I get the optimal settings for encoding using the JM reference software encoder? Or is it better to use x264 encoder? I heard its one of the best encoders in terms of compression efficiency currently. Is there an option for x264 encoder to find out the number of macroblocks used?
Thanks alot for your advice!
foxyshadis
10th March 2007, 05:08
Not really # of macroblocks, but x264 always outputs basic statistical information on the encode:
avis [info]: 320x240 @ 23.98 fps (4959 frames)
x264 [info]: using cpu capabilities MMX MMXEXT SSE SSE2
x264 [info]: slice I:14 Avg QP:23.00 size: 9406
x264 [info]: slice P:2371 Avg QP:26.00 size: 2980
x264 [info]: slice B:2574 Avg QP:27.81 size: 825
x264 [info]: mb I I16..4: 25.7% 0.0% 74.3%
x264 [info]: mb P I16..4: 4.7% 0.0% 0.0% P16..4: 82.3% 0.0% 0.0% 0.0% 0.0% skip:13.0%
x264 [info]: mb B I16..4: 0.1% 0.0% 0.0% B16..8: 27.1% 0.0% 0.0% direct:10.3% skip:62.5%
x264 [info]: direct mvs spatial:96.7% temporal:3.3%
x264 [info]: ref P 79.5% 12.1% 5.2% 3.2%
x264 [info]: ref B 83.9% 9.8% 3.8% 2.5%
x264 [info]: SSIM Mean Y:0.9670150
x264 [info]: kb/s:360.6
So if you need an actual macroblock count, you have to calculate it from the percentages, taking into account their different sizes, and it'll be a bit inexact still. By recompiling x264 you could have it output a raw count, however.
From a decoded stream, not sure if anything could unless you wrote it, starting from existing tools (like h264_parse for ES).
akupenguin
11th March 2007, 09:12
There is no "different sizes" to take into account. Macroblocks are always 16x16. If it says "P16x16: 50%, P8x8: 50%", then half of the macroblocks (by area or by number, they're the same) are subdivided into 8x8 partitions and the other half are not subdivided.
foxyshadis
11th March 2007, 11:26
I thought I'd seen blocks with 8x16 and two 8x8 blocks in elecard, before the trial ran out. I guess not, it might have been referring to something else I wasn't up on.
Okay, I reinstalled and here's what confused me:
http://foxyshadis.slightlydark.com/random/seye.png
Usually they're all the same type (like 8x8) but sometimes others show up.
Sergey A. Sablin
12th March 2007, 12:51
I thought I'd seen blocks with 8x16 and two 8x8 blocks in elecard, before the trial ran out. I guess not, it might have been referring to something else I wasn't up on.
Okay, I reinstalled and here's what confused me:
http://foxyshadis.slightlydark.com/random/seye.png
Usually they're all the same type (like 8x8) but sometimes others show up.
what exactly confused you?
mb_type: Inter (P_8x8) means that macroblock is divided to 4 8x8 partitions and further two of them (left-up and down-right) are divided to 4x4 partitions (as one can see at sub_pmode).
akupenguin
12th March 2007, 16:32
In that case, x264's stats are weighted by area. One MB with two SubPart_8x8 and two SubPart_4x4 counts as half of a P8x8 MB and half of a P4x4 MB.
tchau83
18th March 2007, 09:54
Thanks for your info. I decided to use the JM reference software to encode raw YUV video files to get what I want since I'm more familiar with that software. It's very slow, but it works.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.