--- mbcoding.c 2003/01/04 04:23:53 1.25.2.8 +++ mbcoding.c 2003/01/11 14:59:24 1.25.2.10 @@ -41,7 +41,7 @@ * * * Revision history: * * * - * 28.10.2002 GMC support - gruel * + * 04.01.2003 GMC support - gruel * * 28.06.2002 added check_resync_marker() * * 14.04.2002 bframe encoding * * 08.03.2002 initial version; isibaar * @@ -49,9 +49,10 @@ ******************************************************************************/ - +#include #include #include "../portab.h" +#include "../global.h" #include "bitstream.h" #include "zigzag.h" #include "vlc_codes.h" @@ -59,9 +60,6 @@ #include "../utils/mbfunctions.h" -#define ABS(X) (((X)>0)?(X):-(X)) -#define CLIP(X,A) (X > A) ? (A) : (X) - VLC intra_table[4*2048*64]; VLC inter_table[4*2048*64]; @@ -408,7 +406,6 @@ int32_t i; uint32_t bits, mcbpc, cbpy; - int mcsel=0; mcbpc = (pMB->mode & 7) | ((pMB->cbp & 3) << 3); cbpy = 15 - (pMB->cbp >> 2); @@ -419,14 +416,8 @@ if ( (frame->coding_type == S_VOP) && (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q) ) { - if (frame->quarterpel) { - if ( (pMB->qmvs[0].x == frame->GMC_MV.x) && (pMB->qmvs[0].y == frame->GMC_MV.y) ) - mcsel=1; - } else { - if ( (pMB->mvs[0].x == frame->GMC_MV.x) && (pMB->mvs[0].y == frame->GMC_MV.y) ) - mcsel=1; - } - BitstreamPutBit(bs, mcsel); // mcsel: '0'=local motion, '1'=GMC + /* decision on GMC is done in encoder.c now */ + BitstreamPutBit(bs, pMB->mcsel); // mcsel: '0'=local motion, '1'=GMC } // write cbpy @@ -456,7 +447,7 @@ } } // code motion vector(s) if motion is local - if (mcsel==0) + if (!pMB->mcsel) for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { CodeVector(bs, pMB->pmvs[i].x, frame->fcode, pStat); CodeVector(bs, pMB->pmvs[i].y, frame->fcode, pStat); @@ -683,7 +674,7 @@ uint32_t index; - index = CLIP(BitstreamShowBits(bs, 9), 256); + index = MIN(BitstreamShowBits(bs, 9), 256); BitstreamSkip(bs, mcbpc_inter_table[index].len);