Log in

View Full Version : Quantizer Values won't stick


steve77
7th January 2007, 19:58
Hello all,

I've been doing some experimenting with Quantizer Min/Max values (as found in the Quantization tab)...

Anyways, I'm encoding some DVD-type video, and for all the frames types I set min = 2 and max = 7

Then I proceed to do a 2-pass video encode, as it would be done normally in VirtualDub MOD.

However, viewing the graph in the "XviD Status" windows during the 2nd pass I see that some B-Frames are quantizers as high as 10.

Do the min/max values only apply to 1-pass target quantizer encodes? Because I did try setting min = 2 and max = 6 the other day with a target of 4.2, but was getting quatizers of 7 for some of the B frames.

I'm relatively new to this Quantizer business, but have read up on it as much as I possibly can.

I'm also using a custom quantization matrix, 6of9-HVS, if that changes anything. If it does, which matrix could I use to make sure my min/max settings actually get applied?

Regards,

steve77

foxyshadis
7th January 2007, 20:10
Min/Maximum quantizers are applied after the b-frame equation: p_frame*b_ratio+b_offset. So b-frame min/max will be higher than p-frame's. Don't worry, the presets already take this into account.

steve77
7th January 2007, 20:51
Min/Maximum quantizers are applied after the b-frame equation: p_frame*b_ratio+b_offset. So b-frame min/max will be higher than p-frame's. Don't worry, the presets already take this into account.

It's not that I'm worried that the B-Frames have higher quantizers (which from what I've read, is logical; B-Frames are inherently less quality than P-Frames)

It's that I specify that B-Frames should ALSO obey the max quantizer of 6 that I specify.

foxyshadis
7th January 2007, 21:00
They do, it's just that the box is misleading about it. If you set bmax to, say, 6, then bframes will never ever have a higher quantizer than 6*b_ratio+b_offset (with default settings, 10). It's odd, but it's how xvid was built. If you want it to max out at 6, you just have to reverse the algebra and set it to 3 or 4.

steve77
7th January 2007, 21:10
They do, it's just that the box is misleading about it. If you set bmax to, say, 6, then bframes will never ever have a higher quantizer than 6*b_ratio+b_offset (with default settings, 10). It's odd, but it's how xvid was built. If you want it to max out at 6, you just have to reverse the algebra and set it to 3 or 4.

Wow, that's confusing lol. However, I still have reason to belive something is wrong. Using DRFAnalyser, I get a value of ~5.1, however, I specified a DRF (or target quantizer) of 4.2.

Like now I'm not getting the point of the max value: if it's always like the formula you suggest, than the max/min values for the B-Frames are of no consequence, right?


EDIT: Wait, I understand. The question is why muck around with b_ratio and b_offset? What's the use of these values? Ultimatley I could set them both to 0 right?

DarkZell666
8th January 2007, 12:35
Wait, I understand. The question is why muck around with b_ratio and b_offset? What's the use of these values? Ultimatley I could set them both to 0 right?

You could to that, but you'd ruin the hole purpose of bframes, because bframes at Q4 look similar to pframes at Q2 (which means bframes take up much less space with the same visual quality).

In fact, I remember someone saying that Bframes are bigger than Pframes at the same quantizer, so setting those 2 values to 0 would ruin the encode more than anything else.

HeadBangeR77
8th January 2007, 18:52
@ steve77

1) The B-frames limits might sound confusing, but all that ratio&offset stuff is rather well explained in more advanced guides, as well as there is a hint in Xvid Vfw version. An average is drawn from quantizers of the neighbouring non-b frames and then multiplied by ratio. After that the offset is added. To make it simple: let's assume we have a single b-frame between two p-frames, each of them having a quant of 3. An average is 3 then, multiplied by the default ratio of 1.5 will give us 4.5, + offset = 5.5, most probably rounded up to 6 as the resulting b-frame quant.

Some info here (with further links):
http://forum.doom9.org/showthread.php?s=&threadid=70709

http://ronald.vslcatena.nl/docs/xvidfaq.html#C13

Directly here ... (http://ronald.vslcatena.nl/docs/xvidfaq.html#C3j)

For a tad better quality you could use ratio 1.62/1.63 and offset 0, as specified in Xvid presets. When applied to the above example that would give you always b-quant 5.

2) 6of9 HVS is a modified version of 6of9 matrix - both are considered to be high quality matrices (removing much less details, and thus reducing the compression). Try to make a small clip and run a one-pass encode at fixed quantizer (e.g. 3) : you will notice a huge difference in the resutling filesize between various matrices (I've done hundreds of tests like that, but been to shy to share them here ;) ). Try to search through this forum - I had been reading for months before experimenting on my own ;)

foxyshadis
8th January 2007, 21:18
Wow, that's confusing lol. However, I still have reason to belive something is wrong. Using DRFAnalyser, I get a value of ~5.1, however, I specified a DRF (or target quantizer) of 4.2.

Like now I'm not getting the point of the max value: if it's always like the formula you suggest, than the max/min values for the B-Frames are of no consequence, right?


EDIT: Wait, I understand. The question is why muck around with b_ratio and b_offset? What's the use of these values? Ultimatley I could set them both to 0 right?

It just means the real min/max are higher than what you type into those boxes (by the formula I gave), not that b_max and b_min are not being applied. The values you put in the box are put through the formula to get the real values the codec uses.

Average quant is the same way - If you specify 4, you'll get all I and P frames at 4, all B frames at 4*b_ratio+b_offset. That's why you get a higher avg quant than what you specify. If DRFanalyser counted only I/P you'd get 4.2, and if it counted only B you'd get ~6 or so.

steve77
10th January 2007, 21:08
Great, that is very useful....

I setup a super compressed encode (500kbps) and used Ratio=1.3 and offset of 0.75. I also set the max b-frame interval to 2.... the idea is I wanted to keep a relatively "uniform" level of quality while using the extra b-frames, which should help compressibility. I'm going for a 2 pass encode.

Does my reasoning work? I think so, but just want to be sure.... Encoded resolution is 416x312, 25fps. b/px should be around 0.16.

Using standard H.263 matrix.... probably better ones out there, but this is my first encode where size is more important that quality, and didn't really do my research for high compression matrices.

In any case, I now have a better understanding of what is going on, so that really helps.... like everthing, tweaking is the key to sucess!

Regards,

Steve

HeadBangeR77
10th January 2007, 23:20
In case of such a low-bitrate encoding the default H.263 matrix is indeed a reasonable choice. :) There are not many out there, that compress more: Sharktooth's V3 ULR, Soulhunter's V8, Jawor's 1CD matrix are the ones I've heard about.

B/px is an outdated quality indicator - do you encode with Gordian Knot, by chance? You could do a compressibility check, that will tell you more in terms of possible resulting quality. As always, much depends on the source. ;)

What do you mean by "the max b-frame interval"? Probably max. consecutive B-frames (i.e. how many b-frames can be put in a row, one after another) - if so, your choice (2) seems all right to me. :)

Let me wish you good luck!

PS. In my explanation above, I've left out one important thing! The original b-quant, which is calculated from neighbouring non-b-frames, is exactly the one you can limit. After that (multiplited by ratio) + offset, as foxyshadis wrote above. Hope that's clear to you now, isn't it? ;)

steve77
11th January 2007, 14:54
In case of such a low-bitrate encoding the default H.263 matrix is indeed a reasonable choice. :) There are not many out there, that compress more: Sharktooth's V3 ULR, Soulhunter's V8, Jawor's 1CD matrix are the ones I've heard about.

B/px is an outdated quality indicator - do you encode with Gordian Knot, by chance? You could do a compressibility check, that will tell you more in terms of possible resulting quality. As always, much depends on the source. ;)

What do you mean by "the max b-frame interval"? Probably max. consecutive B-frames (i.e. how many b-frames can be put in a row, one after another) - if so, your choice (2) seems all right to me. :)

Let me wish you good luck!

PS. In my explanation above, I've left out one important thing! The original b-quant, which is calculated from neighbouring non-b-frames, is exactly the one you can limit. After that (multiplited by ratio) + offset, as foxyshadis wrote above. Hope that's clear to you now, isn't it? ;)

I've always used VirtualDubMod for my encodes; I'm often using Avisynth and other tools/plugins to clean up and deinterlace video.

Yeah, I meant max consecutive B-Frames; still getting used to the lingo.

What do people generally use as a decent quality indicator?