[XviD-devel] possible qpel direct chroma MV rounding bug

Michael Niedermayer michaelni at gmx.at
Tue Dec 20 05:44:16 CET 2005


Hi

after some heated flam .. ehh i mean disscussion about libavcodec ability
to decode xvid encoded files binary identically to xvid i found some
differences, when using qpel + b frames, one of these is caused by the
following code in xvid, which doesnt seem to match the mpeg4 spec but
its 5oclock in the morning so please forgive me if iam wrong

    uv_dx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;
    uv_dy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;
    b_uv_dx = pMB->b_mvs[0].x + pMB->b_mvs[1].x + pMB->b_mvs[2].x + pMB->b_mvs[3].x;
    b_uv_dy = pMB->b_mvs[0].y + pMB->b_mvs[1].y + pMB->b_mvs[2].y + pMB->b_mvs[3].y;

    if (dec->quarterpel) {
      if (dec->bs_version <= BS_VERSION_BUGGY_CHROMA_ROUNDING) {
                                uv_dx = (uv_dx>>1) | (uv_dx&1);
                                uv_dy = (uv_dy>>1) | (uv_dy&1);
                                b_uv_dx = (b_uv_dx>>1) | (b_uv_dx&1);
                                b_uv_dy = (b_uv_dy>>1) | (b_uv_dy&1);
                        }
                        else {
        uv_dx /= 2;
        uv_dy /= 2;
        b_uv_dx /= 2;
        b_uv_dy /= 2;
      }
    }

what i think is wrong on this is that the /2 should be done before the
summation of the 4 vectors

mpeg4 spec:
For the motion compensation of both chrominance blocks, the forward motion vector (MVFx_chro, MVFy_chro) is
calculated by the sum of K forward luminance motion vectors dividing by 2K and then rounding toward the nearest
half sample position as defined in Table 7-6 to Table 7-9. In quarter sample mode the vectors are divided by 2
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
before summation. The backward motion vector (MVBx_chro, MVBy_chro) is derived in the same way. The rest
^^^^^^^^^^^^^^^^
process is the same as the chrominance motion compensation of the bi-directional mode described in subclause

-- 
Michael


More information about the XviD-devel mailing list