--- trunk/xvidcore/src/motion/motion_est.c 2003/02/19 10:13:54 871 +++ trunk/xvidcore/src/motion/motion_est.c 2003/02/19 21:59:30 876 @@ -46,6 +46,26 @@ #include "../utils/emms.h" #include "../dct/fdct.h" +/***************************************************************************** + * Modified rounding tables -- declared in motion.h + * Original tables see ISO spec tables 7-6 -> 7-9 + ****************************************************************************/ + +const uint32_t roundtab[16] = +{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 }; + +/* K = 4 */ +const uint32_t roundtab_76[16] = +{ 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 }; + +/* K = 2 */ +const uint32_t roundtab_78[8] = +{ 0, 0, 1, 1, 0, 0, 0, 1 }; + +/* K = 1 */ +const uint32_t roundtab_79[4] = +{ 0, 1, 0, 0 }; + #define INITIAL_SKIP_THRESH (10) #define FINAL_SKIP_THRESH (50) #define MAX_SAD00_FOR_SKIP (20) @@ -54,6 +74,10 @@ #define CHECK_CANDIDATE(X,Y,D) { \ CheckCandidate((X),(Y), (D), &iDirection, data ); } +/***************************************************************************** + * Code + ****************************************************************************/ + static __inline uint32_t d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv) { @@ -2279,8 +2303,8 @@ // filter mask of all blocks - for (my = 1; my < MBh-1; my++) - for (mx = 1; mx < MBw-1; mx++) + for (my = 1; my < (uint32_t)MBh-1; my++) + for (mx = 1; mx < (uint32_t)MBw-1; mx++) { const int mbnum = mx + my * MBw; const MACROBLOCK *pMB = &pMBs[mbnum]; @@ -2296,8 +2320,8 @@ MBmask[mbnum]=1; } - for (my = 1; my < MBh-1; my++) - for (mx = 1; mx < MBw-1; mx++) + for (my = 1; my < (uint32_t)MBh-1; my++) + for (mx = 1; mx < (uint32_t)MBw-1; mx++) { const uint8_t *const pCur = current->image.y + 16*my*pParam->edged_width + 16*mx; @@ -2305,9 +2329,9 @@ if (!MBmask[mbnum]) continue; - if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= grad ) + if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= (uint32_t)grad ) MBmask[mbnum] = 0; - if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= grad ) + if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= (uint32_t)grad ) MBmask[mbnum] = 0; } @@ -2318,8 +2342,8 @@ a = b = c = n = 0; DtimesF[0] = DtimesF[1] = DtimesF[2] = DtimesF[3] = 0.; - for (my = 0; my < MBh; my++) - for (mx = 0; mx < MBw; mx++) + for (my = 0; my < (uint32_t)MBh; my++) + for (mx = 0; mx < (uint32_t)MBw; mx++) { const int mbnum = mx + my * MBw; const MACROBLOCK *pMB = &pMBs[mbnum]; @@ -2356,8 +2380,8 @@ meanx = meany = 0.; oldnum = 0; - for (my = 0; my < MBh; my++) - for (mx = 0; mx < MBw; mx++) + for (my = 0; my < (uint32_t)MBh; my++) + for (mx = 0; mx < (uint32_t)MBw; mx++) { const int mbnum = mx + my * MBw; const MACROBLOCK *pMB = &pMBs[mbnum]; @@ -2385,8 +2409,8 @@ fprintf(stderr,"meanx = %8.5f meany = %8.5f %d\n",meanx,meany, oldnum); */ num = 0; - for (my = 0; my < MBh; my++) - for (mx = 0; mx < MBw; mx++) + for (my = 0; my < (uint32_t)MBh; my++) + for (mx = 0; mx < (uint32_t)MBw; mx++) { const int mbnum = mx + my * MBw; const MACROBLOCK *pMB = &pMBs[mbnum];