[XviD-devel] adaptive quant improvement

Christoph Lampert xvid-devel@xvid.org
Tue, 28 Jan 2003 19:24:34 +0100 (CET)


On Tue, 28 Jan 2003, Marco "elcabesa" Belli wrote:

> i'm worknig on a new adaptive quant to give more bit to mblock where there are 
> more details or edge.
> i am testing it  and it seems to work.. but i doesn't know how to make enance 
> his performance.
> how can i enable psnr after extrastats has beeen added to cvs?

You have to pass XVID_GLOBAL_EXTRASTATS to param.global at  encoder 
creation (needed to allocate memory). 
Then pass XVID_EXTRASTATS as a general option when encoding the frame 
and it will return SSE values for Y,Cb,Cr in Statistics structure. If you
want PSNR from this, use to SSE_to_PSNR() function from image.c (I hope, 
I put it there... if not, it's just the usual formula: 

PSNR = 48.131 - 10*log10((float)sse/numpixels) ;  
//  where 48.131 = 10*log10(255*255) 

Sorry, I should have explained that earlier. 


> and ia question
> adaptive quant is done before of after motion estimaiton/compensation? or 
> better adaprive quant is done on original image or to the image that will be 
> quantized?

At the moment, it's done before estimation, which is useful in order to
have quant values ready for penalties of vector legnth during ME. 
It would however also be possible to use a fixed quant for that and do 
adaptive quant afterwards, using the information from ME (however that may
be useful). 

You can't do adaptive quant after MC, because MC is done with the
dequantized coefficients, so you have to know the quantizer before MC. 

gruel