Log in

View Full Version : Average quantizer


Movie Maniac®
6th July 2003, 01:55
Hi everybody

In the "Xvid Options explayned" pdf it is written:

"If you're doing a 2pass encode, the settings should be the same for both passes. If you choose "Modulated" (only for 2nd pass! If used in first pass it'll result in MPEG quant type!), you have to check which quantizer will get used more often. If the average quantizer in 2nd pass is e.g. 3.7, you should use .h263 quantization type, if 2.5 it's better to use MPEG quant type on first pass."

In this post (http://forum.doom9.org/showthread.php?s=&postid=258145&highlight=h263+pass+mpeg#post258145) Koepi says about the same thing.

What I want to know now is:
How do I calculate this Average quantizer?

Thanx a lot

Aktan
6th July 2003, 02:53
"Xvid Options explayned" is a little outdated. If you want to keep within MPEG4 specs, you can't use Modulated at all. Heck most new featuers like b-frames and q-pel does not work with Modulated. So if your trying to find out what is the avg quant just for this, forget it. On the other hadn if you really want to know the avg quant, download dbgview and capture all the debug info from 2nd-pass. Then use moonwalker's dbgview analyzer and it will tell you the avg quant.

Movie Maniac®
6th July 2003, 08:27
Originally posted by Aktan
"Xvid Options explayned" is a little outdated. If you want to keep within MPEG4 specs, you can't use Modulated at all. Heck most new featuers like b-frames and q-pel does not work with Modulated. So if your trying to find out what is the avg quant just for this, forget it.

Does this mean that should be used strictly the same quantization for both passes? Or may I still use H.263 for the first pass and MPEG for the second?

On the other hadn if you really want to know the avg quant, download dbgview and capture all the debug info from 2nd-pass. Then use moonwalker's dbgview analyzer and it will tell you the avg quant.

Yes, his is what I wanted to do, I'll try this way :D

Thanks a lot.

Nibor
6th July 2003, 12:47
Originally posted by Movie Maniac®
Does this mean that should be used strictly the same quantization for both passes? Or may I still use H.263 for the first pass and MPEG for the second?
Yes. No.
:D :D

CruNcher
6th July 2003, 23:06
@Movie Maniac®

i think its calculated this way
quantvalue/frames

so for example 3 frames
1 frame = q2
2 frame = q4
3 frame = q3

2+4+3=9/3= 3 avg quant

please correct me somebody if im wrong :rolleyes:

Movie Maniac®
7th July 2003, 00:07
Originally posted by CruNcher
@Movie Maniac®

i think its calculated this way
quantvalue/frames


Yes obviously, like every average value :D

I was just wanderiung where to find those quant values, since in the first pass stats file every frame has quant=2.

Aktan gave me the answer. Seems I've got to print the debug infos and then read them...

Thanks a lot for your help ;)

Bye

Animaniac
7th July 2003, 01:06
I always Modulated decided betwenn H.263 and MPEG based the average quantizer for each frame. Certain marcoblocks would get quantized more than others, and when the average of all the blocks for each frame was > x H.263 would be used and when the average was <= x MPEG is used...

yaz
7th July 2003, 11:19
Originally posted by Animaniac
... Modulated decided betwenn H.263 and MPEG based the average quantizer for each frame. Certain marcoblocks would get quantized more than others, and when the average of all the blocks for each frame was > x H.263 would be used and when the average was <= x MPEG is used...
- afaik, there's no way of using more than a single quantizer within a frame. if so, all blocks must get the same. (afaik, it's a practical & not a theoretical restriction. -h dropped some wise words about it ~year ago)
- magic x = 4 (imho)

@m.m.
average quant can be approxd quite easily. xvid select quantizer for each frame like this :
f1*q1 = f2*q2
f1:framsize in the 1st pass, q1:quantizer used for the 1st pass (alway=2!), aso.
it gives an approx for the average like this:
F1*q1(avg) ~ F2*q2(avg) -> q2(avg) ~ (F1/F2)*q1(avg) ~ 2*(F1/F2)
F1: filesize in the 1st pass (given back any of the stat-file analyzer), F2: file size aimed by u.
add.1:
- it's just an approximation, cus the framesize equ is just a guess (never holds xactly), xvid corrects it with payback.
- the compressibility values (F2/F1!) given back by the stat-file analyzers, are also approx as all they are based on P-frames (afaik, no I & B)
add.2:
imho, it's not the way deciding on the quantizer matrix. search for the threads dealing with this topic.

the bests
y

OUTPinged_
7th July 2003, 12:22
I was just wanderiung where to find those quant values, since in the first pass stats file every frame has quant=2.

Aktan gave me the answer. Seems I've got to print the debug infos and then read them...



"DRFanalyzer" app can be found on the internet. Latest version shows quantizers in XviD streams

Animaniac
7th July 2003, 16:30
Originally posted by yaz
- afaik, there's no way of using more than a single quantizer within a frame. if so, all blocks must get the same. (afaik, it's a practical & not a theoretical restriction. -h dropped some wise words about it ~year ago)
- magic x = 4 (imho)


I meant the frame, not single blocks, gets either H.263 or MPEG quantization depending on the frame's average quantizer, which is determined by the quantization of each block. This is what I gathered when reading the great ones' threads on modulated quantization.

Shalcker
7th July 2003, 16:58
Actually, wasn't there one interesting thread somewhere where people discussed how can you know is it DivX or XviD regardless of fourcc by using ffdshow?

By looking at motion vector movement for example...
And I seem to remember that someone mentioned that for DivX quantizer can be non-uniform per frame, meaning that some blocks are quantized heavier then another and average frame quantizer (part of ffdshow OSD) is having non-zero values behind decimal point... so I thought it should be acceptable for mpeg4 to have macroblocks with different quantizers, although positive effect from that is questionable.

I can be totally wrong though since i can't find that thread now...

Movie Maniac®
7th July 2003, 17:35
Seems that my question wasn't perfectly clear. This post is going far from the point I wanted to discuss.

Xvid quantizes blocks depending on the quantization type you choose.

If you choose H.263 it quantizes each block using a unique quantizer, so it divides each pixel's DCT of a block for the same quant.

If you choose MPEG quantization, it uses the quant matrix, and each pixel's DCT gets divided by it's own quant...

Modulated switches quantizers between h263 and mpeg, and chooses from time to time which is the best...

I don't think Divx is able to do this...

Well, I perfectly know this and I'm going to write down a sort of guide (in italian at the moment) to xvid options, but taking a look to some theory on video compression and things like this.

I've asked my question becouse in the "Xvid options ecxplained" it is written that:

If you choose "Modulated", (...) you have to check which quantizer will get used more often. If the average quantizer in 2nd pass is e.g. 3.7, you should use .h263 quantization type, if 2.5 it's better to use MPEG quant type on first pass.

So here comes the question: where can I know if the average quant is below 3.7 or higher than this?

Aktan sayd that i can know it by looking into de debug info's...
Is there any way that you know? But please consider that I should be able to determine it before converting the whole file, so I cannot use DRF analyzer or other tools like this.

Best regards

Movie Maniac®

CruNcher
7th July 2003, 18:11
Movie Maniac®

i think you could find that out with some test encodes thats the way iam doing it, for example you want to encode a 3h movie then you would first make like 1 minute of film or more (the more the more precise) and do it like this 1 minute film= 7mb
3H=180 minutes*7mb=1260 mb avg quant 2

1260 mb = avg q2
aimedsize mb = avg qx

1260/aimedsize*2 = estimated avg quant

maybe someone has a better solution :D

Movie Maniac®
7th July 2003, 18:23
CruNcher

Your seems a very very very good trick.

I mean, when yoiu do the first pass, whith a stats reader such as mine, you can now how large the file would be with a fixed quant of two.

You know the aimed size...

So, as you say, the calculation is quickly done...

Thanks

Obviously I'll wait for someone to confirm "our theory".

Best regards

Movie Maniac®

drebel
7th July 2003, 18:52
Nitrogen's Xvid stats viewer 1.65 already has this option...

regards,
george

Movie Maniac®
7th July 2003, 19:05
Are you referring to the size of the movie encoded at q2?

Yes sure I know it, but my stats viewer has it too... so please forgive me if I use mine :D

I just wanted to know a way to calculate average quant from first pass stats file.. and seems we found it..

Can someone confirm this?

Thanks