[XviD-devel] GMC update

Christoph Lampert xvid-devel@xvid.org
Wed, 1 Jan 2003 23:49:57 +0100 (CET)


Hi,

implementing global motion estimation was a piece of cake, 
thanks to some very good papers on that stuff.

I didn't even need matrix operations because I was able to get a 
simple formula for the 4x4 inverse. 

The first (heavily non-optimized) version is
about 10% slower than ordinary in halfpel-non4mv-mode, but it catches
motion very well. Maybe I'll send some samples, later.

What's still missing is compensation (not too much work, since the
routines are more or less ready because of testing), calculation of
prediction vectors and the routines for mode decision. That might be a
little more tricky and is connected to SKIP-detection: Maybe a simple
SAD-check would be possible for a start.

Since we then need the full GM transformed image, maybe we should simply 
create a full new image plane and use ordinary SAD and compensation. 

Btw. creating the transformed image is integer-only again, but it's really
ugly "ISO standard"ish code: 

for (J=0;J<pEnc->mbParam.height;J++)
for (I=0;I<pEnc->mbParam.width;I++)
{
  int f= i0s + ( ((-r*i0s+i1ss)*I + (r*j0s-j1ss)*J + (1<<(alpha+rho-1))) >> (alpha+rho));
  int g= j0s + ( ((-r*j0s+j1ss)*I + (-r*i0s+i1ss)*J +(1<<(alpha+rho-1))) >> (alpha+rho));
	
  int Y00 = pEnc->reference->image.y[(g/s)*pEnc->mbParam.edged_width +(f/s) ];
  int Y01 = pEnc->reference->image.y[(g/s)*pEnc->mbParam.edged_width +(f/s+1) ];
  int Y10 = pEnc->reference->image.y[(g/s+1)*pEnc->mbParam.edged_width +(f/s) ];
  int Y11 = pEnc->reference->image.y[(g/s+1)*pEnc->mbParam.edged_width + (f/s+1) ];
  int Y;
  uint8_t val;
			
  int ri= f-(f/s)*s;
  int rj= g-(g/s)*s;

  if ( (f/s<0) || (f/s>=pEnc->mbParam.width) || (g/s<0) || (g/s>=pEnc->mbParam.height) )
    Y=128;
else
    Y = ( (s-rj)*((s-ri)*Y00 + ri*Y01) + rj*((s-rj)*Y10 + rj*Y11) 
            + s*s/2 - pEnc->current->rounding_type )/s/s;
}


(so global motion is 16th-pel resolution and is bilinearily interpolated)

Any ideas how to speed this stuff up, maybe even MMX? 

gruel