Hi Leon! Good question, it needs an explanation. Let's take as example the CopyBlock function with Horizontal interpolation. The MPEG-4 standard specify something like this: void CopyBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride) { int dy, dx; for (dy = 0; dy < 8; dy++) { for (dx = 0; dx < 8; dx++) { Dst[dx] = (Src[dx] + Src[dx+1] + 1 - rounding) >> 1; // hor interpolation with rounding } Src += Stride; Dst += Stride; } } Where rounding could be 0 or 1. This value is present in a field of the VOP header (see function getvophdr(), mp4_state->hdr.vop_rounding_type). So, when there's the rounding (rounding == 1), I can simplify and write: void CopyBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride) { int dy, dx; for (dy = 0; dy < 8; dy++) { for (dx = 0; dx < 8; dx++) { Dst[dx] = (Src[dx] + Src[dx+1]) >> 1; // hor interpolation with rounding } Src += Stride; Dst += Stride; } } When the rounding is not present, instead: void CopyBlockHor(unsigned char * Src, unsigned char * Dst, int Stride) { int dy, dx; for (dy = 0; dy < 8; dy++) { for (dx = 0; dx < 8; dx++) { Dst[dx] = (Src[dx] + Src[dx+1]+1) >> 1; // hor interpolation with rounding } Src += Stride; Dst += Stride; } } I hope it helps, Andrea ----- Original Message ----- From: "Leon van Stuivenberg" <[email protected]> To: "opendivx" <[email protected]> Sent: Saturday, May 19, 2001 3:41 AM Subject: [OpenDivX] rounding > Hi, > > A question about basic_prediction: are the CopyBlockX functions meant to > do rounding (they all do a +1 or +2 before the shift) and the > CopyBlockXRound functions not (they simply truncate with a shift) (well, > except HorVerRound, where there's a +1 followed by a >>2). > Naming suggests the other way around.. i'm confused ;-) > > <leon/> > > _______________________________________________ > OpenDivX mailing list > [email protected] > http://lists.projectmayo.com/mailman/listinfo/opendivx |