[XviD-devel] dark blocks in b-frames

Radek Czyz radoslaw at syskin.cjb.net
Fri Feb 14 21:03:08 CET 2003


Hello,

> Now, I'll buy a pack of beer for a person who will tell me what
> macroblock mode is used in the macroblocks with dark blocks.

I guess that would be me :))

The dark blocks appear in direct mode macroblocks. I've created a
horrible debug-output system, and this is what I've found:

Everything works correctly. Except that I don't know why it works this
way.

Strange?

The dark blocks appear because after motion compensation (in encoder),
transquant functions notice that motion compensated image is too
bright. To counter this, DC value of luma blocks in all macroblocks
(or maybe only direct macroblocks?) is negative. This value is not very
big, and it's usually quatized to zero. However, it's sometimes bigger
and quantized to 1.
This creates a dark block.
fDCT function is right - the average of all 64 16-bit data from
transfer8to16sub2 is indeed negative. transfer8to16sub2 also seems to
be working correctly, I checked (and used) c-version several times.

So the question is - WHY COMPENSATED IMAGE IS TOO BRIGHT _or_ WHY
"current" image is too dark. And also, why motion estimation doesn't
do anything about it - we all know that sad-based ME is very sensitive
to mean luminance.

This shift only applies to luma blocks, mean error of compensated
chroma blocks is zero+gaussian distribution, as it should be.

Also, this doesn't happen to forward or backward mode. I also failed
to find any problems with interpolate mode, but then again it's not
very common and I might have not noticed.

At the very end of my tests I've also conducted this experiment:
After fDCT, if macroblock's mode is direct, set DC value of all four
luma blocks to zero.
Guess what. Even though it was completely wrong, the image was looking
perfect - no flickering, no artifacts, nothing...

This is all very strange. Please notice that DC value is usually zero.
All 'bad' blocks I found had quantized DC = -1 and all other
coefficients = 0 (coeff[0] == -1 ; sum == 1;). This does not happen.

Any comments? Am I missing something? Are we all missing something?...

Best Regards,
Radek



More information about the XviD-devel mailing list