[XviD-devel] Request for ideas/comments about 2pass
Edouard Gomez
ed.gomez at free.fr
Sun May 25 15:52:47 CEST 2003
Christoph Lampert (chl at math.uni-bonn.de) wrote:
> Twopass sets the quants of bframes directly and doesn't calculated it
> from surrounding P-frames??? That can't be good...
Yes that's more or less what happens now.
> I'm sure B-frames scale differently than Pframes, so they should
> either get their own routine or their values just calculated by
> offset/ratio.
Yep, B Frames do not scale like pframes, but the code is making this
assumption in the way it computes the quantizer for bframes.
Here's what i understood from the code (call this reverse engineering
;-):
1/ some scaling (valid for all frame types)
2/ if(frame type == bframe) frame length *= avg_pframe_length/avg_bframe_length;
3/ apply old algorithm for pframes
4/ if(frame type == bframe) frame length *= avg_bframe_length/avg_pframe_length;
5/ compute quant from scaled length in 4 and original quant.
Well it's not that simple and depends on the code path (alt cc,
over/under avg frame size conditions etc etc) but this is teh overall
idea behind our current 2pass code.
I think the adaptation of bframes length is the culprit in our
algorithm. I suspect it to be the one that makes the bquants are so
high. In the first pass, we had this formula:
(1) bquant = ((quant + ref_quant)*ratio/2) + offset (ratio and offset in %)
Our 2pass code uses:
(2) scaled_quant/scaled_length = pass1_quant/pass1_length;
And then the encoder loop applies (1) again. This is the most noticeable
bug, but i suspect the step 2/ in the algorithm hurts too.
I'm currently trying to apply (1)^-1 before returning the quant to the
encoder. This way we would apply (1) only once. I keep you informed of
my progress.
--
Edouard Gomez-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://edu.bnhof.de/pipermail/xvid-devel/attachments/20030525/0d3ffd88/attachment.bin
More information about the XviD-devel
mailing list