[XviD-devel] _real_ adaptive quantization
skal
xvid-devel@xvid.org
01 Oct 2002 15:55:29 +0200
Hi,
On Tue, 2002-10-01 at 12:10, Christoph Lampert wrote:
>
> >
> > How to you decide the q vs q+1 quant? Do you call a round
> > of quant(q)/dequant(q)/quant(q+1)/dequant(q+1)/choose best ?
>
> Currently it's brute force, as you describe, but not only for Q and Q+1,
> but also Q+2 (not more, because it wouldn't always be possible to return
> to Q in next step). It really calculated MSE of DCT-coefficients.
> And yes, it's veeeery slow ;-)
>
> I thought of using more advanced routine, like cycling through
> coefficients, calculating several distorsion in one step, but all this is
> "only" speedup and at the moment, I'm after the theory what can be gained
> at all.
> >
> > (a*256 + b)%q = ( (a*256)%q + b%q ) % q. = (b+Offset(a))%q
> >
> > (quant error is not exactly (a%q), but that's the idea)
>
> Approximation is always good...
(it was just an approximation for the mail's clarity (!). Code snippet
contains the real expression...)
>
> But I just got another idea: There are 4096 possible DCT values per coeff.
> There are possible 31 quantizers. If I create a table of
> resulting distorsions, when quantizing any coeff with any quant it would
> "only" be 126976 entries, right?
Yup, it's just that the hashing reduces the table to a
more reasonable 6Kb size...
> Now, the most frequently used values will become constant anyway, because
> the quantized coefficient becomes zero. If that happens for one quant,
> its the same for all higher quants, too. So there is a huge potential
> for saving space, if it's really needed.
Hem... measuring quantization distortion, one is interested by
the *remainder* of the division Coeff / q, not the quotient
(sent to bitstream coding later on, when Q is decided).
Btw, my primary idea for this stuff was performing a global
pass on the whole image to decide the VOL's quant value,
raising it if the (lower) PSNR still falls within a user-
specified acceptable range. But it may also apply to the
q/q+1/q+2 macroblock-based tests you're conducting...
bye,
Skal