Log in

View Full Version : Adaptative quantization


vinouz
14th May 2003, 22:24
Looking a Divx5.0.5 encode with ffdshow, I noticed the frame mean quantizer isn't always an integer.
So I suppose Divx uses dquants in certain cases. What about Xvid ?
Would it be so hard to implement ?

mf
14th May 2003, 23:32
It's called lumi masking and there is no good implementation of it on the planet for as far as I know.

vinouz
15th May 2003, 16:23
Well, why call it lumi masking ? Shouldn't it be related to as adaptative quantization ?
And, what are the main problems in having differently quantized blocks ? When successive frames having different general quantizers don't raise.

I discussed some time ago on these forums about usung dquants for moving foreground blurred objects on a detailed static background or situations of this kind. Wouldn't it be useful here ?

mf
15th May 2003, 18:06
Originally posted by vinouz
Well, why call it lumi masking ? Shouldn't it be related to as adaptative quantization ?
And, what are the main problems in having differently quantized blocks ? When successive frames having different general quantizers don't raise.

I discussed some time ago on these forums about usung dquants for moving foreground blurred objects on a detailed static background or situations of this kind. Wouldn't it be useful here ?
Everything has multiple terms. DX50 B-VOP compatibility should be called "Closed GOP". Who cares? :D

vinouz
15th May 2003, 21:41
anyways, thx for the answer.

but I wonder why using dquants would be related to TV luma range in some way (as IIRC lumi masking had to do with incorrect luma ranges. Correct me if I'm wrong).

mf
15th May 2003, 22:27
Originally posted by vinouz
anyways, thx for the answer.

but I wonder why using dquants would be related to TV luma range in some way (as IIRC lumi masking had to do with incorrect luma ranges. Correct me if I'm wrong).
It has to do with human visual perception. Luma ranges our eyes are less sensitive to are more compressed than the rest. Makes sense, but in practice it proves to be useless so far.

vinouz
19th May 2003, 11:29
but adaptative quantization could be used in many more situations, such as when there are fast moving parts. And there we'd gain more bits per heavier quantized MB, as these MB are these which often code in more bits (as their information is different from the other's and changes quickly from frame to frame).

And it probably should be feasible to detect these parts, when we see large consecutive MB with large MV, which changed from last frame (and/or will in next frame).

Has this idea already been explored and thrown out. Why then ?

mf
19th May 2003, 12:49
Adaptive quant can only be +something -something from base quant (an absolute number would make bitstream overhead too high, undoing your bitrate savings), and in most scenes you won't save much (if anything) from adaptive quant. You'll just notice that some parts will look ugly, like you do with lumimasking.

Devels feel free to correct me.

Suikun
19th May 2003, 13:28
Originally posted by mf
Adaptive quant can only be +something -something from base quant

No. One MB can change it's quantizer by [-2;-1;0;+1;+2] in relation to the previous MB.

vinouz
19th May 2003, 13:32
I know this. I'm not talking about overquantizing darker MB, but - at least big - areas containing almost unseen information. When someone pases in front of the cam for 2 frames, I don't care about macroblocks I won't even remark on this movement. I noticed this in a wmv9 encode, and until I didn't make attention or a pause on this frame, which is not the main goal of a video, I didn't notice the macroblocks.

Btw, when you say raise/lower the quant, it's not exactly from the base quant, but from the previous MB's quant, am I correct ? Of course, at the second MB, last quant = base quant, but after it can differ quite much.
[edit : Suikun, thanks for the notice, I didn't see your post at time of writing]

I remember the main problem with raising the quant locally raises a problem because of the artifacts you've got to remove later, losing bit to correct this. But for a moving object, as the information will quickly rechange, this is not as much of a problem. And when considering an area to overquantize, we can consider only the inside of the 'shape', leaving the border between the obstruction and the background normally quantized to allow the 'return' to background to be sufficiently quantized not to raise errors carried in following frames.

In fact, I'm looking at a divx encode right now, and although it used lumi masking (not even this idea of overquantizing fast moving parts) I don't see it raising that much artifacts.

I know the best way to deal with temporal obstruction would be multiple frame referenciation for MB, but as we're not in H.264, at least using dquants here would be a good idea.

V.

mf
19th May 2003, 14:12
Originally posted by Suikun
No. One MB can change it's quantizer by [-2;-1;0;+1;+2] in relation to the previous MB.
That's not no, that's yes. "Something" was simply because I didn't know the exact range. You're only narrowing down on what I said.

vinouz
19th May 2003, 14:53
I think he was mostly talking about the fact "from base quant", not the range.
So that's not narrowing down on, that's correcting.

Anyways, did someone try this (upper post) ?

mf
19th May 2003, 15:08
Originally posted by vinouz
I think he was mostly talking about the fact "from base quant", not the range.
So that's not narrowing down on, that's correcting.
2 macroblocks with -3 is still -6 (aka -something) from base quant. And it's also still relative and not absolute. If we're gonna be precise, be warned, I'm usually better at that :D.

vinouz
19th May 2003, 16:01
If you wanna be precise, just take into account you can't have macroblocks with -3, as Suikun mentioned it's in the [-2;+2] integer range. :D
But I think the point is not here. I didn't know this range yesterday, and am glad I learnt it today. Suikun can also be wrong, and me with it...
[and OK, it's still relative to base quant, and also to all the previous blocks. ;) ]

Sorry to recenter, but the point is : Did someone made tests trying to use anything other than luminosity range, and for example fast moving and/or blurred objects, to raise quantizers locally.
How did it perform ?
What problem could it have raised ?

V.

Kurosu
19th May 2003, 18:26
dquant for B-frames: [-2;0;2]
dquant for (I?)P-frames: [-2;-1;0;1;2]

There are several complexity masking in ffvfw. In particular, one is called temporal masking, another P-complexity masking: they sound like they account for motion (in case of inter macroblocks, that is), though I don't think they do.

Maybe posting to the ffmpeg devel list, or download ffmpeg source code would give you a better reply. I think very few on doom9's forum (for instance Syskin) have a deep enough insight, and this forum is more a tester's feedback forum than a developper one.

I wonder how it can perform, considering it would accumulate error (=information to code) on all frames till the next I frame...