PDA

View Full Version : DebugView output of B-frame quantizer


sprit
9th February 2003, 20:44
I'm trying to understand the DebugView output from XviD, esp. the B-frame quantizers.
The tooltip in the VFW GUI states B-frames get a calculated quantizer, like "BVOP quant = (AVG(past VOP quant, future VOP quant) * quant ratio + quant offset) / 100". Reading the source[1] I find towards the end of encoder_encode_bframes in encoder.c "pEnc->current->quant = ((((pEnc->reference->quant + pEnc->current->quant) * pEnc->mbParam.bquant_ratio) / 2) + pEnc->mbParam.bquant_offset)/100;". The source is somewhat more informational as it's clear that integer semantics is used.

To check if my understanding of the B-frame quantizers was correct, I inserted some extra OutputDebugStrings to printf the reference and currect quant, immediately before the calculation. I also added a ODS after the DPRINTF when the final quantizer has been determined.

After having studied the output for 1000 frames from a second pass, qratio=150 qoffset=100, there are some things I don't understand (if a B-frame's quantizer is calculated from ref->quant and cur->quant).
For most of the B-frames, the values of ref->quant and cur->quant don't match the quantizers in the DebugView output from the surrounding P-frames. Example (without DV timestamps):

2nd-pass: quant:4 H.263 inter stats1:13452 scaled:6631 actual:5772 overflow:5068 movie
2nd-pass: quant:4 H.263 inter stats1:16854 scaled:8308 actual:5749 overflow:7622 movie
*** BFRAME<1 : ref.quant = 4 , cur.quant = 7
*** BFRAME : quant = 9
2nd-pass: quant:4 H.263 bframe stats1:3196 scaled:1575 actual:8393 overflow:799 movie
2nd-pass: quant:4 H.263 inter stats1:16959 scaled:8360 actual:1690 overflow:7464 movie

According to the formulas given in both the GUI and in the source that B-frame should have a quantizer = 7. The OSD when playing the file using ffdshow corresponds to the wrong quantizer (9 in the example).

So, what's going on? Am I looking at the wrong quantizers, and if so, where can I find the correct ones?


[1] cvs checkout of dev-api-3 branch, 20030207