[svn] / branches / dev-api-4 / xvidcore / src / motion / motion_est.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/motion/motion_est.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 982, Thu Apr 10 13:05:54 2003 UTC revision 987, Mon Apr 14 15:42:19 2003 UTC
# Line 200  Line 200 
200  GetReferenceB(const int x, const int y, const uint32_t dir, const SearchData * const data)  GetReferenceB(const int x, const int y, const uint32_t dir, const SearchData * const data)
201  {  {
202  //      dir : 0 = forward, 1 = backward  //      dir : 0 = forward, 1 = backward
203          const uint8_t* const *direction = ( dir == 0 ? data->RefP : data->b_RefP );          const uint8_t *const *const direction = ( dir == 0 ? data->RefP : data->b_RefP );
204          const int picture = ((x&1)<<1) | (y&1);          const int picture = ((x&1)<<1) | (y&1);
205          const int offset = (x>>1) + (y>>1)*data->iEdgedWidth;          const int offset = (x>>1) + (y>>1)*data->iEdgedWidth;
206          return direction[picture] + offset;          return direction[picture] + offset;
# Line 351  Line 351 
351                  data->iMinSAD[3] = data->temp[3]; current[3].x = x; current[3].y = y; }                  data->iMinSAD[3] = data->temp[3]; current[3].x = x; current[3].y = y; }
352          if (data->temp[4] < data->iMinSAD[4]) {          if (data->temp[4] < data->iMinSAD[4]) {
353                  data->iMinSAD[4] = data->temp[4]; current[4].x = x; current[4].y = y; }                  data->iMinSAD[4] = data->temp[4]; current[4].x = x; current[4].y = y; }
   
354  }  }
355    
356  static void  static void
# Line 384  Line 383 
383          }          }
384  }  }
385    
   
386  static void  static void
387  CheckCandidate32(const int x, const int y, const int Direction, int * const dir, const SearchData * const data)  CheckCandidate32(const int x, const int y, const int Direction, int * const dir, const SearchData * const data)
388  {  {
# Line 465  Line 463 
463          if ( (x > data->max_dx) || (x < data->min_dx)          if ( (x > data->max_dx) || (x < data->min_dx)
464                  || (y > data->max_dy) || (y < data->min_dy) ) return;                  || (y > data->max_dy) || (y < data->min_dy) ) return;
465    
466          sad = sad32v_c(data->Cur, data->RefP[0] + x/2 + (y/2)*(data->iEdgedWidth),          sad = sad32v_c(data->Cur, data->RefP[0] + (x>>1) + (y>>1)*(data->iEdgedWidth),
467                                                          data->iEdgedWidth, data->temp+1);                                                          data->iEdgedWidth, data->temp+1);
468    
469          if (sad < *(data->iMinSAD)) {          if (sad < *(data->iMinSAD)) {
# Line 1052  Line 1050 
1050                                  if (quant > 31) quant = 31;                                  if (quant > 31) quant = 31;
1051                                  else if (quant < 1) quant = 1;                                  else if (quant < 1) quant = 1;
1052                          }                          }
   
1053                          pMB->quant = current->quant;                          pMB->quant = current->quant;
1054    
1055  //initial skip decision  //initial skip decision
# Line 1084  Line 1081 
1081          }          }
1082    
1083          if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */          if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */
1084            {
1085                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);
1086            }
1087          return 0;          return 0;
1088  }  }
1089    
# Line 1220  Line 1218 
1218                          if (bits_inter4v < bits) { Data->iMinSAD[0] = bits = bits_inter4v; mode = MODE_INTER4V; }                          if (bits_inter4v < bits) { Data->iMinSAD[0] = bits = bits_inter4v; mode = MODE_INTER4V; }
1219                  }                  }
1220    
   
1221                  intra = CountMBBitsIntra(Data);                  intra = CountMBBitsIntra(Data);
1222    
1223                  if (intra < bits) { *Data->iMinSAD = bits = intra; return MODE_INTRA; }                  if (intra < bits) { *Data->iMinSAD = bits = intra; return MODE_INTRA; }
# Line 1359  Line 1356 
1356          }          }
1357    
1358          if (MotionFlags & XVID_ME_HALFPELREFINE16)          if (MotionFlags & XVID_ME_HALFPELREFINE16)
                 if ((!(MotionFlags & XVID_ME_HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant)  
1359                          SubpelRefine(Data);                          SubpelRefine(Data);
1360    
1361          for(i = 0; i < 5; i++) {          for(i = 0; i < 5; i++) {
# Line 1371  Line 1367 
1367    
1368                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
1369                                  pParam->width, pParam->height, Data->iFcode, 1, 0);                                  pParam->width, pParam->height, Data->iFcode, 1, 0);
   
                 if ((!(MotionFlags & XVID_ME_QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) {  
1370                          Data->qpel_precision = 1;                          Data->qpel_precision = 1;
1371                          SubpelRefine(Data);                          SubpelRefine(Data);
1372                  }                  }
         }  
1373    
1374          if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;          if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;
1375    
1376          if (inter4v && (!(VopFlags & XVID_VOP_MODEDECISION_BITS) ||          if (inter4v) {
                         (!(MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS)) || (!(MotionFlags & XVID_ME_HALFPELREFINE8_BITS)) ||  
                         ((!(MotionFlags & XVID_ME_EXTSEARCH_BITS)) && (!(MotionFlags&XVID_ME_EXTSEARCH8)) ))) {  
                 // if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop  
   
1377                  SearchData Data8;                  SearchData Data8;
1378                  memcpy(&Data8, Data, sizeof(SearchData)); //quick copy of common data                  memcpy(&Data8, Data, sizeof(SearchData)); //quick copy of common data
1379    
# Line 1396  Line 1385 
1385                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) {                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) {
1386                          // chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it                          // chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it
1387                          int sumx = 0, sumy = 0;                          int sumx = 0, sumy = 0;
1388                          const int div = 1 + Data->qpel;                          const int div = Data->qpel ? 2 : 1;
1389                          const VECTOR * const mv = Data->qpel ? pMB->qmvs : pMB->mvs;                          const VECTOR * const mv = Data->qpel ? pMB->qmvs : pMB->mvs;
1390    
1391                          for (i = 0; i < 4; i++) {                          for (i = 0; i < 4; i++) {
# Line 2189  Line 2178 
2178          }          }
2179  }  }
2180    
2181  #define INTRA_THRESH    2400  #define INTRA_THRESH    2050
2182  #define INTER_THRESH    1300  #define INTER_THRESH    1200
2183    
2184  int  int
2185  MEanalysis(     const IMAGE * const pRef,  MEanalysis(     const IMAGE * const pRef,
# Line 2265  Line 2254 
2254          sSAD /= blocks;          sSAD /= blocks;
2255          s = (10*s) / blocks;          s = (10*s) / blocks;
2256    
2257          if (s > 4) sSAD += (s - 3) * (300 - 2*b_thresh); //static block - looks bad when in bframe...          if (s > 4) sSAD += (s - 2) * (160 - 2*b_thresh); //static block - looks bad when in bframe...
2258    
2259          if (sSAD > InterThresh ) return P_VOP;          if (sSAD > InterThresh ) return P_VOP;
2260          emms();          emms();
# Line 2569  Line 2558 
2558    
2559                  Data8->qpel_precision = Data8->qpel;                  Data8->qpel_precision = Data8->qpel;
2560                  // checking the vector which has been found by SAD-based 8x8 search (if it's different than the one found so far)                  // checking the vector which has been found by SAD-based 8x8 search (if it's different than the one found so far)
2561                  if (Data8->qpel) {                  {
2562                          if (!(Data8->currentQMV->x == backup[i+1].x && Data8->currentQMV->y == backup[i+1].y))                          VECTOR *v = Data8->qpel ? Data8->currentQMV : Data8->currentMV;
2563                                  CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8);                          if (!( (v->x == backup[i+1].x) && (v->y == backup[i+1].y) ))
                 } else {  
                         if (!(Data8->currentMV->x == backup[i+1].x && Data8->currentMV->y == backup[i+1].y))  
2564                                  CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8);                                  CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8);
2565                  }                  }
2566    

Legend:
Removed from v.982  
changed lines
  Added in v.987

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4