Log in

View Full Version : QuEnc adaptive quantization?


drcl
1st April 2005, 21:56
Is there a reason why QuEnc doesnt make use of the adaptive quantization available in libavcodec?

Nic
2nd April 2005, 11:04
Hmmm,
I don't remember a switch to turn on adaptive quant. Is it useful? Would you have it on by default? If it's not an obvious parameter let me know it's name.

edit: Adaptive Quant is turned on if other parameters are turned on. I.e the code for it is:

s->adaptive_quant= ( s->avctx->lumi_masking
|| s->avctx->dark_masking
|| s->avctx->temporal_cplx_masking
|| s->avctx->spatial_cplx_masking
|| s->avctx->p_masking
|| s->avctx->border_masking
|| (s->flags&CODEC_FLAG_QP_RD))
&& !s->fixed_qscale;



Cheers,
-Nic

ps
Thinking about releasing a new QuEnc very soon. Spotted a bug yesterday, that meant when creating a multiplexed MPEG (either DVD or SVCD stream) that the timestamps (DTS/PTS & SCR) wouldn't be standards compliant. It's an easy fix, but an important one.

drcl
2nd April 2005, 17:17
sorry, i should have converted the lingo. Its lumi/dark masking. The only way i know its not enabled is when i use DGdecode with infos on. The min/max/avg quants for each fram are allways the same ie 5/5/5. but CCE will give 3/4/8 or something on the same given frame.

Nic
2nd April 2005, 17:48
Do you mean DGDecode with ShowQ=true? When I'm testing it with the current pre-release version (I don't know about Beta2) I see different Quants used for the same frame.....What are your settings?

drcl
2nd April 2005, 19:56
no, i was using (info=1) with DGindex/dgdecode 1.2.1

i cropped the clip so it just displays the quants
http://files.bighosting.net/sk19865.avi (908kb xvid)

Quenc0.59b2 settings are
2-pass
2000kbit
trellis
high quality
VBR
15 GOP
2 b-frame
scene detection
8 bit DC
video only
standard matrix
9800 max bitrate

Nic
2nd April 2005, 20:44
With those settings, you are right, always the same quant is used. I'll try and narrow it down to what setting causes it.

-Nic

edit:
ps
Ok, maybe there's always no adaptive quant. Normally, masking isn't recommended...... http://mplayerhq.hu/DOCS/HTML-single/en/MPlayer.html So not sure whether to add an option. Opinions?

dragongodz
3rd April 2005, 02:48
hmm well if it does the same as adaptive quant matrices that CCE does i would not make it default on thats for sure.
http://forum.doom9.org/showthread.php?threadid=92430

whats really needed is a comparison of it on and off to see if it even really warrants being used. that is can anyone actually see a difference most of the time when playing(NOT still frames and NOT comparing quants) ?
if they cant then it is pointless to even add.

maybe a blind test with a few clips with it forced on and forced off, with people saying which looks better and by how much etc. may be the best idea to decide whether to even make it an option.

drcl
3rd April 2005, 07:15
its not the same thing. all im talking about is lumi/dark masking - adaptive quantisation with a frame (ie dark macroblocks have higher quants than the rest of the picture), not like the option of adjusting the quantizer matrix temporally like you could in the old xvid builds.

dragongodz
3rd April 2005, 07:31
well i dont have a problem really with it being an option, with default turned off, with set settings(so people cant screw around and blame QuEnc for using bad values).

Nic
3rd April 2005, 09:31
Hmmm, Maybe. I'm not sure. I'm thinking of adding PSNR results in a messagebox after encoding as an option. I suppose that will make things easier.

Does anyone have any good "values" for lumi/dark masking for ffmpeg? The values i'm using are very low and shouldn't hurt anything much (but they do lower PSNR, although I guess that's to be expected)

-Nic

dragongodz
3rd April 2005, 14:48
I'm thinking of adding PSNR results in a messagebox after encoding as an option. I suppose that will make things easier.
NO, NO, NO, PLEASE HEAVENS NOOOOOOOO!
that may give the impression PSNR is actually reliable. take the time Makira made a change to the Requant engine that increased PSNR but actually turned the resulting output pictures to crap. its not to be trusted IMHO.

The values i'm using are very low and shouldn't hurt anything much (but they do lower PSNR, although I guess that's to be expected)
but how did it look ? was there any seeable difference ? thats why i said maybe a small blind test with a few clips at different bitrates etc would be worth doing to help decide if its worth it or not.

drcl
3rd April 2005, 14:58
not sure if the values correspond to mencoder's but they suggest maximum lumi/dark masking of 0.3. I have used 0.3 and not noticed anything bad but then again some ppl will notice artifacts on dark areas if they turn the brightness up on the display.

http://www.lab.inf.uc3m.es/cgi-bin/man2html?fibmap_mplayer+1

Nic
3rd April 2005, 22:15
@dgz: Maybe you're right. Although it's not a bad guideline some of the time. I'll leave the code in, so coders can try it, but can't be turned on from the GUI.

@drcl: I'm using very low values, I really can't tell a difference. So, i'm not going to add it. So many parameters with libavcodec with no explanation or concrete evidence of their practical use. I'm going to stick to my original decision with QuEnc and only add parameters that can obviously make a difference.

-Nic

ps
Should have fixed the audio only encoding from a stream with audio and video....

pps
Still wondering whether to include MPEG-4 Video, AAC and MP3 support. Might over complicate things, but it would be kinda cool ;) (I know dgz won't be impressed ;) )

dragongodz
4th April 2005, 03:10
Although it's not a bad guideline some of the time. I'll leave the code in, so coders can try it, but can't be turned on from the GUI.
yes its been discussed to death in the past about PSNR and even today you have people that think it is totally reliable. when told they should believe their eyes before something like PSNR they still dont always understand why and just want to believe the numbers. definatly not newbie freindly so a good call. :)

Still wondering whether to include MPEG-4 Video, AAC and MP3 support. Might over complicate things, but it would be kinda cool ;)(I know dgz won't be impressed ;))
HAHAHA you know me too well. as i said in the past though why not make that a seperate program ? so it would be QuEnc for mpeg 1/2 encoding and **Enc(i wont even guess what bizzare name you would come up with ;)) for other codecs such as snow, mp4, mp3 etc etc etc. all the basic framework would still be the same, all that would need to be changed is the CLI options, the gui windows (main and options) and settings used internally. since you would have to change them for QuEnc anyway its not like it would be a lot of extra work. :D