Log in

View Full Version : B-frames quantizer question


el_rico
12th July 2004, 08:00
Hello,

Maybe the answer is somewhere in the forum, but since involved keywords are very broad I have not been able to find it!

I was just wondering why a B-frame quantizer is deduced based on the quantizers of previous and next I/P-frame. Maybe is due to its nature and it is a nonsense to do something else, but why a B-frame could not get a quantizer determined by the codec as for other frames?

Thanks!

[edit] typo

Teegedeck
12th July 2004, 09:43
Because at the same quantizer b-frames are neither smaller nor better than p-frames, so there would be no reason to use them at all. But they can be compressed much stronger than p-frames and still look good.

EthanoliX
12th July 2004, 10:03
Originally posted by Teegedeck
...
But they can be compressed much stronger than p-frames and still look good.

One question: Whenever it is about b-frames you will hear this, but why?

Is it

a) because of their internal structure or

b) because no other frames are referring to them. And small, not visible inaccuracys might not accumulate to visible artifacts?

sh0dan
12th July 2004, 10:13
b) (by coincidence) ;)

Tommy Carrot
12th July 2004, 11:35
Originally posted by Teegedeck
Because at the same quantizer b-frames are neither smaller nor better than p-frames

This is not exactly true, they are slightly smaller at equivalent quantizer, but usually not smaller enough to compensate the size-increment of the p-frames (this was discussed here (http://forum.doom9.org/showthread.php?s=&threadid=78473)).

el_rico
12th July 2004, 14:13
Indeed, I understand B-frames have to be smaller (ie higher quantizer) Still, I do not see why the quantizer is bound to other frame (by ratio and treshold) instead of letting the codec decide as for other frames.

Didée
12th July 2004, 16:10
Well ... what would be the difference? What's the possible gain?

IF XviD would scale the B-frames "freely", instead of basing their quantization on the surrounding P-frames, then it would need a lot of hair-pulling calculations to get, in the ideal case, ... about the same as it is now ;)

It just is quite logical the way it is now. We know:

- B-frames should be compressed stronger than P-frames
- B-frames at the same quant as the P-frames don't give benefit
- B-frames compressed *much* stronger, such as P=q3, B=q12, obviously is a bad idea

So, B-frames are most effective in a certain range of compression. And this must be in relation to the surrounding P-frames, to get a consistent quality as the frames flow by.

>> Therefore, you won't get any befit by not basing B-quantization upon P-quantization. <<

And actually, XviD is *not* dumbly bound to those multiplier/offset values! :)

In fact, XviD adjusts the calculated B-quantizers up/down, if there are (small enough) bitrate deviations in the 2nd pass, that can be compensated by altering the pre-computed quantizers for some B-frames by a small amount (+/- 1 ?), instead of immediately altering P-frame quantization, which could lead to either unnessesary quality degradation, or an instant over/underflow.
This seems true for *small* bitrate deviations - if it gets big enough, of course P-quantization is adapted.


- Didée

el_rico
12th July 2004, 18:01
It was just a 'candid' question. But then, what I still cannot figure out is the very free B-frames settings. It seems according to your explanation that there is a kind of sweet spot for B-frames and it is related to surrounding P-frames. Then we could reword in "why not let the codec decide for ratio and treshold in place of the user" (except for users thet really know what they are doing - not my case!)

Or in other words again, setting other values than pre-defined ones (ratio=1.5 and treshold=1.0) should be reserved to those who rellay know what they are doing.

Koepi
12th July 2004, 18:25
What's wrong about the principle "don't touch what you don't understand"? It'll be a little hard for the codec to guess what each user has in mind there... so the defaults usually are your best bet.

Regards
Koepi

Teegedeck
12th July 2004, 18:29
el_rico, it's not like there is som kind of 'brain' inside the codec (;)), so whenever a codec (or any program for that matter) decides something 'by itself' this actually means that it uses a hardcoded value or formula (in this case) which it bases its 'decisions' on. The XviD devels could just hide that quantizer ratio i.e. hardcode it and say 'whoa, look: XviD's smart; it decides it all by itself'.

el_rico
12th July 2004, 18:59
That was the sense of my remark: I was just surprised that such a latitude was exposed to the user (and also, a lot of different B-frame settings are exposed as THE setting in many places)

Anyway, then for vulgum pecus we just have to stay with out-of-the box setting if I understand correctly.

Thanks for your patience.

malkion
12th July 2004, 23:09
Originally posted by el_rico
That was the sense of my remark: I was just surprised that such a latitude was exposed to the user (and also, a lot of different B-frame settings are exposed as THE setting in many places)

Anyway, then for vulgum pecus we just have to stay with out-of-the box setting if I understand correctly.

Thanks for your patience.

Perhaps until we are relaxed enough and have time to experiment with XviD for ourselves. That latitude is much appreciated later on when this happens. :p

lordadmira
13th July 2004, 00:28
Originally posted by Didée
IF XviD would scale the B-frames "freely", instead of basing their quantization on the surrounding P-frames, then it would need a lot of hair-pulling calculations to get, in the ideal case, ... about the same as it is now ;) Hmm, sounds like the much anticipated "BVOP VHQ mode". ;)

lordadmira
13th July 2004, 00:30
Originally posted by Koepi
What's wrong about the principle "don't touch what you don't understand"? Oh but Koepi ur forgetting about the primal human instinct to "press large unmarked red buttons". :o :cool:

LA

Prettz
14th July 2004, 00:17
Originally posted by Teegedeck
el_rico, it's not like there is som kind of 'brain' inside the codec (;)), so whenever a codec (or any program for that matter) decides something 'by itself' this actually means that it uses a hardcoded value or formula (in this case) which it bases its 'decisions' on. The XviD devels could just hide that quantizer ratio i.e. hardcode it and say 'whoa, look: XviD's smart; it decides it all by itself'.
Well, you could always add in some heuristics and graph-based solutions to your formulas. But if the xvid devs could invent such a solution that always produced good results, I think they would be worrying about what to do with all the money they're about to make rather than worrying about some free mpeg-4 codec.

Teegedeck
14th July 2004, 23:17
I guess you've overlooked the fact that we're talking about a codec which doesn't have much problems standing up to commercial solutions. I seem to recall that the code was good enough to be 'adopted' at some point by some company that hid away the more insider-ish settings... ;)

Isn't it nice to see free and open projects become better than their 'professional' competition?

sysKin
15th July 2004, 06:17
Originally posted by Prettz
Well, you could always add in some heuristics and graph-based solutions to your formulas. Actually, IMHO, "heuristics" is just a buzzword that means "a alghorithm that kinda works, but we don't know why".

It's still an alghorthm though, with hard-coded constants and formulas, just like any other ;)

el_rico
15th July 2004, 07:05
Well... we know how an heuristics works. We just don't know a more 'direct' way to determine the solution.

If we go that way, there is no 'artificial intelligence', that is actually true IMHO. Still we can distinguish between purely deterministic and computational algorithms and others.

BTW not sure it is totally related to the topic ! (Anyway I already have my answer)