[XviD-devel] Rounding

Michael Militzer xvid-devel@xvid.org
Tue, 29 Oct 2002 16:04:38 +0100


Hi,

I have been looking into the qpel rounding issues again today because
ms-fdam does not decode chroma of XVID qpel (as well as DivX5) correctly...

> here's the code I've been using for the Round  7-6 -> 7-9
> tables during computation of chroma MV:
>
>
>   // Table 7-6 (K=4)  (modified)
> const int SKL_MB::Rnd_Tab_76[16] = { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 1, 1 };
>   // Table 7-8 (K=2)  (modified)
> const int SKL_MB::Rnd_Tab_78[ 8] = { 0, 0, 1, 1, 0, 0, 0, 1  };
>   // Table 7-9 (K=1)  (modified)
> const int SKL_MB::Rnd_Tab_79[ 4] = { 0, 1, 1, 1 };
>
> typedef SKL_INT16 SKL_MV[2];
>
> #define DIV2RND(x) ( ((x)>>1) | ((x)&1) )
>
> void SKL_MB::Derive_uv_MV_From_1MV(int Quarter, SKL_MV *MV)
> {
>   int x = MV[0][0];
>   int y = MV[0][1];
>   if (Quarter) { x = DIV2RND(x); y = DIV2RND(y); }
>   uv_MV[0] = (x>>1) | Rnd_Tab_79[ x & 0x3];
>   uv_MV[1] = (y>>1) | Rnd_Tab_79[ y & 0x3];
> }

this is exactly how I've understood the standard and that's what we're
currently already doing. However ms-fdam (latest version I have: 001213)
does not properly decode our qpel vids: chroma becomes more and more
displaced until the next keyframe arrives.
I've tried using a simple x/2, y/2 instead of the DIV2RND(x) for motion
compensation (that was what Radek proposed since it solved problems with the
envivio decoder), however this does not help at all (I have the impression
that the colors are even "more wrong" if I decode such videos with
ms-fdam) - so fdam seems to do something completely different and I have no
clue what and why - any ideas what to do? Is the ms reference software
really bugfree/correct?

bye,
Michael