[XviD-devel] Quantizer Distribution in Second pass

Christoph Lampert xvid-devel@xvid.org
Thu, 19 Sep 2002 10:11:47 +0200 (CEST)


Hi,

twopass for Linux had been fixed and results are very good. 

Now I have a question about quantizer distribution: 
Result for GomGom's Matrix Test was: 

# quant 1 : 0
# quant 2 : 8309
# quant 3 : 116522
# quant 4 : 58538
# quant 5 : 2983
# quant 6 : 45
# quant 7 : 4

Which gives an average quant of 3.3. Very good, of course. 
Now I would like to have the Quant=6 and Quant=7 frames "removed" and 
replaced by Quant=5. It won't noticably change filesize and might reduce
the risk of single frames with visible blocks. Even more if the average
wasn't 3.x but say 5.x and there are a few blocks with quant 9 instead of
7. 

My idea would be: Either detect those high quantizers which are used 
in less than 0.1% (or any other threshhold) of frames 
(e.g. 45 is only 0.02% of all frames, 4 is only 0.002%) 
and replace their quant with the next better one. As I said the influence
of changing 1/1000th of frame by 1 quant or 2 quant won't be big. 

The problem is that quantizers are calculated on the fly (which I would
like to be changed into an intermediate step, too, but this is not
trivial.) so when encode a quant 7 frame we don't know who often will will
appear later. 

So my alternative is to specify a range of +/-2 (or asymetric like
+2/-3) which are allowed values for difference of quant against _average_
quant. Interval of +/-2 would give [1.3,5.3] --> [1,5] in this example and
therefore result in just what I want. 

The [minquant,maxquant] should not be removed, of course, but a relative
measure would be easier to adapt in advance, I guess. 

Any oppinion on that? Or is it possible already in the VfW-version? 

gruel