[cvs] / xvidcore / src / motion / motion_est.c Repository:
ViewVC logotype

Diff of /xvidcore/src/motion/motion_est.c

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

revision 1.58.2.9, Tue Apr 8 15:35:52 2003 UTC revision 1.64, Tue Apr 8 11:12:07 2003 UTC
# Line 984  Line 984 
984          uint32_t mb_width = pParam->mb_width;          uint32_t mb_width = pParam->mb_width;
985          uint32_t mb_height = pParam->mb_height;          uint32_t mb_height = pParam->mb_height;
986          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
987          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->global_flags);
988    
989          uint32_t x, y;          uint32_t x, y;
990          uint32_t iIntra = 0;          uint32_t iIntra = 0;
991          int32_t quant = current->quant, sad00;          int32_t quant = current->quant, sad00;
992          int skip_thresh = \          int skip_thresh = INITIAL_SKIP_THRESH *
993                  INITIAL_SKIP_THRESH * \                  (current->global_flags & XVID_REDUCED ? 4:1) *
994                  (current->vop_flags & XVID_VOP_REDUCED ? 4:1) * \                  (current->global_flags & XVID_MODEDECISION_BITS ? 2:1);
                 (current->vop_flags & XVID_VOP_MODEDECISION_BITS ? 2:1);  
995    
996          // some pre-initialized thingies for SearchP          // some pre-initialized thingies for SearchP
997          int32_t temp[8];          int32_t temp[8];
# Line 1009  Line 1008 
1008          Data.temp = temp;          Data.temp = temp;
1009          Data.iFcode = current->fcode;          Data.iFcode = current->fcode;
1010          Data.rounding = pParam->m_rounding_type;          Data.rounding = pParam->m_rounding_type;
1011          Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);          Data.qpel = pParam->m_quarterpel;
1012          Data.chroma = MotionFlags & XVID_ME_CHROMA16;          Data.chroma = MotionFlags & PMV_CHROMA16;
1013          Data.rrv = (current->vop_flags & XVID_VOP_REDUCED ? 1:0);          Data.rrv = current->global_flags & XVID_REDUCED;
1014          Data.dctSpace = dct_space;          Data.dctSpace = dct_space;
1015    
1016          if ((current->vop_flags & XVID_VOP_REDUCED)) {          if ((current->global_flags & XVID_REDUCED)) {
1017                  mb_width = (pParam->width + 31) / 32;                  mb_width = (pParam->width + 31) / 32;
1018                  mb_height = (pParam->height + 31) / 32;                  mb_height = (pParam->height + 31) / 32;
1019                  Data.qpel = 0;                  Data.qpel = 0;
# Line 1047  Line 1046 
1046    
1047                          sad00 = pMB->sad16;                          sad00 = pMB->sad16;
1048    
1049                          if (pMB->dquant != 0) {                          if (!(current->global_flags & XVID_LUMIMASKING)) {
1050                                    pMB->dquant = NO_CHANGE;
1051                            } else {
1052                                    if (pMB->dquant != NO_CHANGE) {
1053                                  quant += DQtab[pMB->dquant];                                  quant += DQtab[pMB->dquant];
1054                                  if (quant > 31) quant = 31;                                  if (quant > 31) quant = 31;
1055                                  else if (quant < 1) quant = 1;                                  else if (quant < 1) quant = 1;
1056                          }                          }
1057                            }
1058                          pMB->quant = current->quant;                          pMB->quant = current->quant;
1059    
1060  //initial skip decision  //initial skip decision
1061  /* no early skip for GMC (global vector = skip vector is unknown!)  */  /* no early skip for GMC (global vector = skip vector is unknown!)  */
1062                          if (!(current->vol_flags & XVID_VOL_GMC))       { /* no fast SKIP for S(GMC)-VOPs */                          if (!(current->global_flags & XVID_GMC))        { /* no fast SKIP for S(GMC)-VOPs */
1063                                  if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh)                                  if (pMB->dquant == NO_CHANGE && sad00 < pMB->quant * skip_thresh)
1064                                          if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {                                          if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {
1065                                                  SkipMacroblockP(pMB, sad00);                                                  SkipMacroblockP(pMB, sad00);
1066                                                  continue;                                                  continue;
# Line 1066  Line 1068 
1068                          }                          }
1069    
1070                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
1071                                                  y, MotionFlags, current->vol_flags, pMB->quant,                                                  y, MotionFlags, current->global_flags, pMB->quant,
1072                                                  &Data, pParam, pMBs, reference->mbs,                                                  &Data, pParam, pMBs, reference->mbs,
1073                                                  current->vop_flags & XVID_VOP_INTER4V, pMB);                                                  current->global_flags & XVID_INTER4V, pMB);
1074    
1075  /* final skip decision, a.k.a. "the vector you found, really that good?" */  /* final skip decision, a.k.a. "the vector you found, really that good?" */
1076                          if (!(current->vol_flags & XVID_VOL_GMC || current->vop_flags & XVID_VOP_MODEDECISION_BITS)) {                          if (!(current->global_flags & XVID_GMC || current->global_flags & XVID_MODEDECISION_BITS)) {
1077                                  if ( pMB->dquant == 0 && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) {                                  if ( pMB->dquant == NO_CHANGE && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) {
1078                                          if ( (100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1) )                                          if ( (100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1) )
1079                                                  if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv))                                                  if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv))
1080                                                          SkipMacroblockP(pMB, sad00);                                                          SkipMacroblockP(pMB, sad00);
# Line 1083  Line 1085 
1085                  }                  }
1086          }          }
1087    
1088          if (current->vol_flags & XVID_VOL_GMC ) /* GMC only for S(GMC)-VOPs */          if (current->global_flags & XVID_GMC )  /* GMC only for S(GMC)-VOPs */
1089            {
1090                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);
1091            }
1092          return 0;          return 0;
1093  }  }
1094    
# Line 1157  Line 1160 
1160                  const int x, const int y,                  const int x, const int y,
1161                  const MBParam * const pParam,                  const MBParam * const pParam,
1162                  const uint32_t MotionFlags,                  const uint32_t MotionFlags,
1163                  const uint32_t VopFlags)                  const uint32_t GlobalFlags)
1164  {  {
1165    
1166          int mode = MODE_INTER;          int mode = MODE_INTER;
1167    
1168          if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision          if (!(GlobalFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision
1169                  int sad;                  int sad;
1170                  int InterBias = MV16_INTER_BIAS;                  int InterBias = MV16_INTER_BIAS;
1171                  if (inter4v == 0 || Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] +                  if (inter4v == 0 || Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] +
# Line 1204  Line 1207 
1207                  int bits, intra, i;                  int bits, intra, i;
1208                  VECTOR backup[5], *v;                  VECTOR backup[5], *v;
1209                  Data->lambda16 = iQuant;                  Data->lambda16 = iQuant;
1210          Data->lambda8 = (pParam->vol_flags & XVID_VOL_MPEGQUANT)?1:0;                  Data->lambda8 = pParam->m_quant_type;
1211    
1212                  v = Data->qpel ? Data->currentQMV : Data->currentMV;                  v = Data->qpel ? Data->currentQMV : Data->currentMV;
1213                  for (i = 0; i < 5; i++) {                  for (i = 0; i < 5; i++) {
# Line 1238  Line 1241 
1241                  const int x,                  const int x,
1242                  const int y,                  const int y,
1243                  const uint32_t MotionFlags,                  const uint32_t MotionFlags,
1244                  const uint32_t VopFlags,                  const uint32_t GlobalFlags,
1245                  const uint32_t iQuant,                  const uint32_t iQuant,
1246                  SearchData * const Data,                  SearchData * const Data,
1247                  const MBParam * const pParam,                  const MBParam * const pParam,
# Line 1273  Line 1276 
1276          Data->lambda8 = lambda_vec8[iQuant];          Data->lambda8 = lambda_vec8[iQuant];
1277          Data->qpel_precision = 0;          Data->qpel_precision = 0;
1278    
1279          if (pMB->dquant != 0) inter4v = 0;          if (pMB->dquant != NO_CHANGE) inter4v = 0;
1280    
1281          memset(Data->currentMV, 0, 5*sizeof(VECTOR));          memset(Data->currentMV, 0, 5*sizeof(VECTOR));
1282    
# Line 1287  Line 1290 
1290          Data->iMinSAD[3] = pMB->sad8[2];          Data->iMinSAD[3] = pMB->sad8[2];
1291          Data->iMinSAD[4] = pMB->sad8[3];          Data->iMinSAD[4] = pMB->sad8[3];
1292    
1293          if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) || (x | y)) {          if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) || (x | y)) {
1294                  threshA = Data->temp[0]; // that's where we keep this SAD atm                  threshA = Data->temp[0]; // that's where we keep this SAD atm
1295                  if (threshA < 512) threshA = 512;                  if (threshA < 512) threshA = 512;
1296                  else if (threshA > 1024) threshA = 1024;                  else if (threshA > 1024) threshA = 1024;
# Line 1313  Line 1316 
1316          if ((Data->iMinSAD[0] <= threshA) ||          if ((Data->iMinSAD[0] <= threshA) ||
1317                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&
1318                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) {                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) {
1319                  if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) inter4v = 0;      }                  if (!(GlobalFlags & XVID_MODEDECISION_BITS)) inter4v = 0;       }
1320          else {          else {
1321    
1322                  MainSearchFunc * MainSearchPtr;                  MainSearchFunc * MainSearchPtr;
1323                  if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch;                  if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch;
1324                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1325                          else MainSearchPtr = DiamondSearch;                          else MainSearchPtr = DiamondSearch;
1326    
1327                  MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);                  MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
# Line 1327  Line 1330 
1330          note that this search is/might be done in halfpel positions,          note that this search is/might be done in halfpel positions,
1331          which makes it more different than the diamond above */          which makes it more different than the diamond above */
1332    
1333                  if (MotionFlags & XVID_ME_EXTSEARCH16) {                  if (MotionFlags & PMV_EXTSEARCH16) {
1334                          int32_t bSAD;                          int32_t bSAD;
1335                          VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0];                          VECTOR startMV = Data->predMV, backupMV = Data->currentMV[0];
1336                          if (Data->rrv) {                          if (Data->rrv) {
# Line 1358  Line 1361 
1361                  }                  }
1362          }          }
1363    
1364          if (MotionFlags & XVID_ME_HALFPELREFINE16)          if (MotionFlags & PMV_HALFPELREFINE16)
1365                  if ((!(MotionFlags & XVID_ME_HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant)                  if ((!(MotionFlags & HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant)
1366                          SubpelRefine(Data);                          SubpelRefine(Data);
1367    
1368          for(i = 0; i < 5; i++) {          for(i = 0; i < 5; i++) {
# Line 1367  Line 1370 
1370                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;
1371          }          }
1372    
1373          if (MotionFlags & XVID_ME_QUARTERPELREFINE16) {          if (MotionFlags & PMV_QUARTERPELREFINE16) {
1374    
1375                  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,
1376                                  pParam->width, pParam->height, Data->iFcode, 1, 0);                                  pParam->width, pParam->height, Data->iFcode, 1, 0);
1377    
1378                  if ((!(MotionFlags & XVID_ME_QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) {                  if ((!(MotionFlags & QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) {
1379                          Data->qpel_precision = 1;                          Data->qpel_precision = 1;
1380                          SubpelRefine(Data);                          SubpelRefine(Data);
1381                  }                  }
1382          }          }
1383    
1384          if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;          if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;
1385    
1386          if (inter4v && (!(VopFlags & XVID_VOP_MODEDECISION_BITS) ||          if (inter4v && (!(GlobalFlags & XVID_MODEDECISION_BITS) ||
1387                          (!(MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS)) || (!(MotionFlags & XVID_ME_HALFPELREFINE8_BITS)) ||                          (!(MotionFlags & QUARTERPELREFINE8_BITS)) || (!(MotionFlags & HALFPELREFINE8_BITS)) ||
1388                          ((!(MotionFlags & XVID_ME_EXTSEARCH_BITS)) && (!(MotionFlags&XVID_ME_EXTSEARCH8)) ))) {                          ((!(MotionFlags & EXTSEARCH_BITS)) && (!(MotionFlags&PMV_EXTSEARCH8)) ))) {
1389                  // if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop                  // if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop
1390    
1391                  SearchData Data8;                  SearchData Data8;
# Line 1393  Line 1396 
1396                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8);                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8);
1397                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8);                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8);
1398    
1399                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) {                  if ((Data->chroma) && (!(GlobalFlags & XVID_MODEDECISION_BITS))) {
1400                          // 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
1401                          int sumx = 0, sumy = 0;                          int sumx = 0, sumy = 0;
1402                          const int div = 1 + Data->qpel;                          const int div = 1 + Data->qpel;
# Line 1409  Line 1412 
1412                  }                  }
1413          }          }
1414    
1415          inter4v = ModeDecision(iQuant, Data, inter4v, pMB, pMBs, x, y, pParam, MotionFlags, VopFlags);          inter4v = ModeDecision(iQuant, Data, inter4v, pMB, pMBs, x, y, pParam, MotionFlags, GlobalFlags);
1416    
1417          if (Data->rrv) {          if (Data->rrv) {
1418                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);
# Line 1468  Line 1471 
1471    
1472          *(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10;          *(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10;
1473    
1474          if (MotionFlags & (XVID_ME_EXTSEARCH8|XVID_ME_HALFPELREFINE8|XVID_ME_QUARTERPELREFINE8)) {          if (MotionFlags & (PMV_EXTSEARCH8|PMV_HALFPELREFINE8|PMV_QUARTERPELREFINE8)) {
1475    
1476                  if (Data->rrv) i = 16; else i = 8;                  if (Data->rrv) i = 16; else i = 8;
1477    
# Line 1486  Line 1489 
1489                  if (!Data->rrv) CheckCandidate = CheckCandidate8;                  if (!Data->rrv) CheckCandidate = CheckCandidate8;
1490                  else CheckCandidate = CheckCandidate16no4v;                  else CheckCandidate = CheckCandidate16no4v;
1491    
1492                  if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_BITS))) {                  if (MotionFlags & PMV_EXTSEARCH8 && (!(MotionFlags & EXTSEARCH_BITS))) {
1493                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD
1494    
1495                          MainSearchFunc *MainSearchPtr;                          MainSearchFunc *MainSearchPtr;
1496                          if (MotionFlags & XVID_ME_USESQUARES8) MainSearchPtr = SquareSearch;                          if (MotionFlags & PMV_USESQUARES8) MainSearchPtr = SquareSearch;
1497                                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch;                                  else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch;
1498                                          else MainSearchPtr = DiamondSearch;                                          else MainSearchPtr = DiamondSearch;
1499    
1500                          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255);                          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255);
# Line 1502  Line 1505 
1505                          }                          }
1506                  }                  }
1507    
1508                  if (MotionFlags & XVID_ME_HALFPELREFINE8) {                  if (MotionFlags & PMV_HALFPELREFINE8) {
1509                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD
1510    
1511                          SubpelRefine(Data); // perform halfpel refine of current best vector                          SubpelRefine(Data); // perform halfpel refine of current best vector
# Line 1513  Line 1516 
1516                          }                          }
1517                  }                  }
1518    
1519                  if (Data->qpel && MotionFlags & XVID_ME_QUARTERPELREFINE8) {                  if (Data->qpel && MotionFlags & PMV_QUARTERPELREFINE8) {
1520                                  Data->qpel_precision = 1;                                  Data->qpel_precision = 1;
1521                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8,                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8,
1522                                          pParam->width, pParam->height, Data->iFcode, 1, 0);                                          pParam->width, pParam->height, Data->iFcode, 1, 0);
# Line 1637  Line 1640 
1640                  CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data);                  CheckCandidate16no4v(pmv[i].x, pmv[i].y, mask, &iDirection, Data);
1641          }          }
1642    
1643          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch;          if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch;
1644          else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;          else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1645                  else MainSearchPtr = DiamondSearch;                  else MainSearchPtr = DiamondSearch;
1646    
1647          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
# Line 1821  Line 1824 
1824  //      DIRECT MODE DELTA VECTOR SEARCH.  //      DIRECT MODE DELTA VECTOR SEARCH.
1825  //      This has to be made more effective, but at the moment I'm happy it's running at all  //      This has to be made more effective, but at the moment I'm happy it's running at all
1826    
1827          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = SquareSearch;          if (MotionFlags & PMV_USESQUARES16) MainSearchPtr = SquareSearch;
1828                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1829                          else MainSearchPtr = DiamondSearch;                          else MainSearchPtr = DiamondSearch;
1830    
1831          MainSearchPtr(0, 0, Data, 255);          MainSearchPtr(0, 0, Data, 255);
# Line 2031  Line 2034 
2034          Data.currentMV = currentMV; Data.currentQMV = currentQMV;          Data.currentMV = currentMV; Data.currentQMV = currentQMV;
2035          Data.iMinSAD = &iMinSAD;          Data.iMinSAD = &iMinSAD;
2036          Data.lambda16 = lambda_vec16[frame->quant];          Data.lambda16 = lambda_vec16[frame->quant];
2037          Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL;          Data.qpel = pParam->m_quarterpel;
2038          Data.rounding = 0;          Data.rounding = 0;
2039          Data.chroma = frame->motion_flags & XVID_ME_CHROMA8;          Data.chroma = frame->motion_flags & PMV_CHROMA8;
2040          Data.temp = temp;          Data.temp = temp;
2041    
2042          Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose)          Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose)
# Line 2141  Line 2144 
2144  {  {
2145    
2146          int i, mask;          int i, mask;
         int quarterpel = (pParam->vol_flags & XVID_VOL_QUARTERPEL)? 1: 0;  
2147          VECTOR pmv[3];          VECTOR pmv[3];
2148          MACROBLOCK * const pMB = &pMBs[x + y * pParam->mb_width];          MACROBLOCK * const pMB = &pMBs[x + y * pParam->mb_width];
2149    
# Line 2157  Line 2159 
2159                          else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median                          else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median
2160    
2161          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,
2162          pParam->width, pParam->height, Data->iFcode - quarterpel, 0, 0);                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel, 0, 0);
2163    
2164          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;
2165          Data->RefP[0] = pRef + (x + y * pParam->edged_width) * 16;          Data->RefP[0] = pRef + (x + y * pParam->edged_width) * 16;
# Line 2480  Line 2482 
2482                  if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0)                  if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0)
2483                          return 0; //quick stop                          return 0; //quick stop
2484    
2485                  if (MotionFlags & (XVID_ME_HALFPELREFINE16_BITS | XVID_ME_EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search                  if (MotionFlags & (HALFPELREFINE16_BITS | EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search
2486                          for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i];                          for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i];
2487                          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,
2488                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv);                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv);
# Line 2498  Line 2500 
2500                  }                  }
2501          }          }
2502    
2503          if (MotionFlags&XVID_ME_EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection);          if (MotionFlags&EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
2504    
2505          if (MotionFlags&XVID_ME_HALFPELREFINE16_BITS) SubpelRefine(Data);          if (MotionFlags&HALFPELREFINE16_BITS) SubpelRefine(Data);
2506    
2507          if (Data->qpel) {          if (Data->qpel) {
2508                  if (MotionFlags&(XVID_ME_EXTSEARCH_BITS | XVID_ME_HALFPELREFINE16_BITS)) { // there was halfpel-precision search                  if (MotionFlags&(EXTSEARCH_BITS | HALFPELREFINE16_BITS)) { // there was halfpel-precision search
2509                          for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) {                          for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) {
2510                                  Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match                                  Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match
2511                                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;                                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;
# Line 2514  Line 2516 
2516                          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,
2517                                          pParam->width, pParam->height, Data->iFcode, 1, 0);                                          pParam->width, pParam->height, Data->iFcode, 1, 0);
2518                  }                  }
2519                  if (MotionFlags&XVID_ME_QUARTERPELREFINE16_BITS) SubpelRefine(Data);                  if (MotionFlags&QUARTERPELREFINE16_BITS) SubpelRefine(Data);
2520          }          }
2521    
2522          if (MotionFlags&XVID_ME_CHECKPREDICTION_BITS) { //let's check vector equal to prediction          if (MotionFlags&CHECKPREDICTION_BITS) { //let's check vector equal to prediction
2523                  VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV;                  VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV;
2524                  if (!(Data->predMV.x == v->x && Data->predMV.y == v->y))                  if (!(Data->predMV.x == v->x && Data->predMV.y == v->y))
2525                          CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data);                          CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data);
# Line 2578  Line 2580 
2580                  }                  }
2581    
2582                  if (Data8->qpel) {                  if (Data8->qpel) {
2583                          if (MotionFlags&XVID_ME_HALFPELREFINE8_BITS || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_BITS)) { // halfpixel motion search follows                          if (MotionFlags&HALFPELREFINE8_BITS || (MotionFlags&PMV_EXTSEARCH8 && MotionFlags&EXTSEARCH_BITS)) { // halfpixel motion search follows
2584                                  int32_t s = *Data8->iMinSAD;                                  int32_t s = *Data8->iMinSAD;
2585                                  Data8->currentMV->x = Data8->currentQMV->x/2;                                  Data8->currentMV->x = Data8->currentQMV->x/2;
2586                                  Data8->currentMV->y = Data8->currentQMV->y/2;                                  Data8->currentMV->y = Data8->currentQMV->y/2;
# Line 2589  Line 2591 
2591                                  if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1)                                  if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1)
2592                                          CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8);                                          CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8);
2593    
2594                                  if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS)                                  if (MotionFlags & PMV_EXTSEARCH8 && MotionFlags & EXTSEARCH_BITS)
2595                                          SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);                                          SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);
2596    
2597                                  if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) SubpelRefine(Data8);                                  if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8);
2598    
2599                                  if(s > *Data8->iMinSAD) { //we have found a better match                                  if(s > *Data8->iMinSAD) { //we have found a better match
2600                                          Data8->currentQMV->x = 2*Data8->currentMV->x;                                          Data8->currentQMV->x = 2*Data8->currentMV->x;
# Line 2604  Line 2606 
2606                                                          pParam->width, pParam->height, Data8->iFcode, 1, 0);                                                          pParam->width, pParam->height, Data8->iFcode, 1, 0);
2607    
2608                          }                          }
2609                          if (MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS) SubpelRefine(Data8);                          if (MotionFlags & QUARTERPELREFINE8_BITS) SubpelRefine(Data8);
2610    
2611                  } else // not qpel                  } else // not qpel
2612                          if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS) SubpelRefine(Data8); //halfpel mode, halfpel refinement                          if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8); //halfpel mode, halfpel refinement
2613    
2614                  //checking vector equal to predicion                  //checking vector equal to predicion
2615                  if (i != 0 && MotionFlags & XVID_ME_CHECKPREDICTION_BITS) {                  if (i != 0 && MotionFlags & CHECKPREDICTION_BITS) {
2616                          const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV;                          const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV;
2617                          if (!(Data8->predMV.x == v->x && Data8->predMV.y == v->y))                          if (!(Data8->predMV.x == v->x && Data8->predMV.y == v->y))
2618                                  CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8);                                  CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8);

Legend:
Removed from v.1.58.2.9  
changed lines
  Added in v.1.64

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