[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 889, Sat Feb 22 08:24:01 2003 UTC revision 890, Sat Feb 22 08:49:45 2003 UTC
# Line 995  Line 995 
995          uint32_t mb_width = pParam->mb_width;          uint32_t mb_width = pParam->mb_width;
996          uint32_t mb_height = pParam->mb_height;          uint32_t mb_height = pParam->mb_height;
997          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
998          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->global_flags);          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);
999    
1000          uint32_t x, y;          uint32_t x, y;
1001          uint32_t iIntra = 0;          uint32_t iIntra = 0;
# Line 1015  Line 1015 
1015          Data.temp = temp;          Data.temp = temp;
1016          Data.iFcode = current->fcode;          Data.iFcode = current->fcode;
1017          Data.rounding = pParam->m_rounding_type;          Data.rounding = pParam->m_rounding_type;
1018          Data.qpel = pParam->m_quarterpel;          Data.qpel = current->vol_flags & XVID_QUARTERPEL;
1019          Data.chroma = MotionFlags & PMV_CHROMA16;          Data.chroma = MotionFlags & PMV_CHROMA16;
1020          Data.rrv = current->global_flags & XVID_REDUCED;          Data.rrv = current->vop_flags & XVID_REDUCED;
1021    
1022          if ((current->global_flags & XVID_REDUCED)) {          if ((current->vop_flags & XVID_REDUCED)) {
1023                  mb_width = (pParam->width + 31) / 32;                  mb_width = (pParam->width + 31) / 32;
1024                  mb_height = (pParam->height + 31) / 32;                  mb_height = (pParam->height + 31) / 32;
1025                  Data.qpel = 0;                  Data.qpel = 0;
# Line 1052  Line 1052 
1052    
1053                          sad00 = pMB->sad16;                          sad00 = pMB->sad16;
1054    
1055                          if (!(current->global_flags & XVID_LUMIMASKING)) {                          if (!(current->vop_flags & XVID_LUMIMASKING)) {
1056                                  pMB->dquant = NO_CHANGE;                                  pMB->dquant = NO_CHANGE;
1057                          } else {                          } else {
1058                                  if (pMB->dquant != NO_CHANGE) {                                  if (pMB->dquant != NO_CHANGE) {
# Line 1065  Line 1065 
1065    
1066  //initial skip decision  //initial skip decision
1067  /* no early skip for GMC (global vector = skip vector is unknown!)  */  /* no early skip for GMC (global vector = skip vector is unknown!)  */
1068                          if (!(current->global_flags & XVID_GMC))        { /* no fast SKIP for S(GMC)-VOPs */                          if (!(current->vol_flags & XVID_GMC))   { /* no fast SKIP for S(GMC)-VOPs */
1069                                  if (pMB->dquant == NO_CHANGE && sad00 < pMB->quant * INITIAL_SKIP_THRESH * (Data.rrv ? 4:1) )                                  if (pMB->dquant == NO_CHANGE && sad00 < pMB->quant * INITIAL_SKIP_THRESH * (Data.rrv ? 4:1) )
1070                                          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)) {
1071                                                  SkipMacroblockP(pMB, sad00);                                                  SkipMacroblockP(pMB, sad00);
# Line 1074  Line 1074 
1074                          }                          }
1075    
1076                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
1077                                                  y, MotionFlags, current->global_flags, pMB->quant,                                                  y, MotionFlags, current->vol_flags, pMB->quant,
1078                                                  &Data, pParam, pMBs, reference->mbs,                                                  &Data, pParam, pMBs, reference->mbs,
1079                                                  current->global_flags & XVID_INTER4V, pMB);                                                  current->vop_flags & XVID_INTER4V, pMB);
1080    
1081  /* 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?" */
1082                          if (!(current->global_flags & XVID_GMC))        {                          if (!(current->vol_flags & XVID_GMC))   {
1083                                  if ( pMB->dquant == NO_CHANGE && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) {                                  if ( pMB->dquant == NO_CHANGE && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) {
1084                                          if (!(current->global_flags & XVID_MODEDECISION_BITS)) {                                          if (!(current->vop_flags & XVID_MODEDECISION_BITS)) {
1085                                                  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) )
1086                                                          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))
1087                                                                  SkipMacroblockP(pMB, sad00);                                                                  SkipMacroblockP(pMB, sad00);
# Line 1097  Line 1097 
1097                  }                  }
1098          }          }
1099    
1100          if (current->global_flags & XVID_GMC )  /* GMC only for S(GMC)-VOPs */          if (current->vol_flags & XVID_GMC )     /* GMC only for S(GMC)-VOPs */
1101          {          {
1102                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);
1103          }          }
# Line 1172  Line 1172 
1172                  const int x, const int y,                  const int x, const int y,
1173                  const MBParam * const pParam,                  const MBParam * const pParam,
1174                  const uint32_t MotionFlags,                  const uint32_t MotionFlags,
1175                  const uint32_t GlobalFlags)                  const uint32_t VopFlags)
1176  {  {
1177    
1178          int mode = MODE_INTER;          int mode = MODE_INTER;
1179    
1180          if (!(GlobalFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision          if (!(VopFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision
1181  //              int intra = 0;  //              int intra = 0;
1182                  int sad;                  int sad;
1183                  int InterBias = MV16_INTER_BIAS;                  int InterBias = MV16_INTER_BIAS;
# Line 1220  Line 1220 
1220                  int bits, intra, i;                  int bits, intra, i;
1221                  VECTOR backup[5], *v;                  VECTOR backup[5], *v;
1222                  Data->lambda16 = iQuant;                  Data->lambda16 = iQuant;
1223                  Data->lambda8 = pParam->m_quant_type;          Data->lambda8 = (pParam->vol_flags & XVID_MPEGQUANT)?1:0;
1224    
1225                  v = Data->qpel ? Data->currentQMV : Data->currentMV;                  v = Data->qpel ? Data->currentQMV : Data->currentMV;
1226                  for (i = 0; i < 5; i++) {                  for (i = 0; i < 5; i++) {
# Line 1254  Line 1254 
1254                  const int x,                  const int x,
1255                  const int y,                  const int y,
1256                  const uint32_t MotionFlags,                  const uint32_t MotionFlags,
1257                  const uint32_t GlobalFlags,                  const uint32_t VopFlags,
1258                  const uint32_t iQuant,                  const uint32_t iQuant,
1259                  SearchData * const Data,                  SearchData * const Data,
1260                  const MBParam * const pParam,                  const MBParam * const pParam,
# Line 1304  Line 1304 
1304          Data->iMinSAD[3] = pMB->sad8[2];          Data->iMinSAD[3] = pMB->sad8[2];
1305          Data->iMinSAD[4] = pMB->sad8[3];          Data->iMinSAD[4] = pMB->sad8[3];
1306    
1307          if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) || (x | y)) {          if ((!(VopFlags & XVID_MODEDECISION_BITS)) || (x | y)) {
1308                  threshA = Data->temp[0]; // that's where we keep this SAD atm                  threshA = Data->temp[0]; // that's where we keep this SAD atm
1309                  if (threshA < 512) threshA = 512;                  if (threshA < 512) threshA = 512;
1310                  else if (threshA > 1024) threshA = 1024;                  else if (threshA > 1024) threshA = 1024;
# Line 1330  Line 1330 
1330          if ((Data->iMinSAD[0] <= threshA) ||          if ((Data->iMinSAD[0] <= threshA) ||
1331                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&
1332                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) {                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) {
1333                  if (!(GlobalFlags & XVID_MODEDECISION_BITS)) inter4v = 0;       }                  if (!(VopFlags & XVID_MODEDECISION_BITS)) inter4v = 0;  }
1334          else {          else {
1335    
1336                  MainSearchFunc * MainSearchPtr;                  MainSearchFunc * MainSearchPtr;
# Line 1393  Line 1393 
1393                          SubpelRefine(Data);                          SubpelRefine(Data);
1394                  }                  }
1395    
1396          if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;          if ((!(VopFlags & XVID_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;
1397    
1398          if (inter4v && (!(GlobalFlags & XVID_MODEDECISION_BITS) ||          if (inter4v && (!(VopFlags & XVID_MODEDECISION_BITS) ||
1399                          (!(MotionFlags & QUARTERPELREFINE8_BITS)) || (!(MotionFlags & HALFPELREFINE8_BITS)) ||                          (!(MotionFlags & QUARTERPELREFINE8_BITS)) || (!(MotionFlags & HALFPELREFINE8_BITS)) ||
1400                          ((!(MotionFlags & EXTSEARCH_BITS)) && (!(MotionFlags&PMV_EXTSEARCH8)) ))) {                          ((!(MotionFlags & EXTSEARCH_BITS)) && (!(MotionFlags&PMV_EXTSEARCH8)) ))) {
1401                  // 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
# Line 1408  Line 1408 
1408                  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);
1409                  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);
1410    
1411                  if ((Data->chroma) && (!(GlobalFlags & XVID_MODEDECISION_BITS))) {                  if ((Data->chroma) && (!(VopFlags & XVID_MODEDECISION_BITS))) {
1412                          // 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
1413                          int sumx = 0, sumy = 0;                          int sumx = 0, sumy = 0;
1414                          const int div = 1 + Data->qpel;                          const int div = 1 + Data->qpel;
# Line 1424  Line 1424 
1424                  }                  }
1425          }          }
1426    
1427          inter4v = ModeDecision(iQuant, Data, inter4v, pMB, pMBs, x, y, pParam, MotionFlags, GlobalFlags);          inter4v = ModeDecision(iQuant, Data, inter4v, pMB, pMBs, x, y, pParam, MotionFlags, VopFlags);
1428    
1429          if (Data->rrv) {          if (Data->rrv) {
1430                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);
# Line 2038  Line 2038 
2038          Data.currentMV = currentMV; Data.currentQMV = currentQMV;          Data.currentMV = currentMV; Data.currentQMV = currentQMV;
2039          Data.iMinSAD = &iMinSAD;          Data.iMinSAD = &iMinSAD;
2040          Data.lambda16 = lambda_vec16[frame->quant];          Data.lambda16 = lambda_vec16[frame->quant];
2041          Data.qpel = pParam->m_quarterpel;          Data.qpel = pParam->vol_flags & XVID_QUARTERPEL;
2042          Data.rounding = 0;          Data.rounding = 0;
2043          Data.chroma = frame->motion_flags & PMV_CHROMA8;          Data.chroma = frame->motion_flags & PMV_CHROMA8;
2044          Data.temp = temp;          Data.temp = temp;
# Line 2163  Line 2163 
2163                          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
2164    
2165          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,
2166                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel, 0, Data->rrv);          pParam->width, pParam->height, Data->iFcode - (pParam->vol_flags&XVID_QUARTERPEL?1:0), 0, Data->rrv);
2167    
2168          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;
2169          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;
# Line 2220  Line 2220 
2220          Data.currentMV = currentMV;          Data.currentMV = currentMV;
2221          Data.iMinSAD = iMinSAD;          Data.iMinSAD = iMinSAD;
2222          Data.iFcode = Current->fcode;          Data.iFcode = Current->fcode;
2223          Data.rrv = Current->global_flags & XVID_REDUCED;          Data.rrv = Current->vop_flags & XVID_REDUCED;
2224          Data.temp = temp;          Data.temp = temp;
2225          CheckCandidate = CheckCandidate32I;          CheckCandidate = CheckCandidate32I;
2226    

Legend:
Removed from v.889  
changed lines
  Added in v.890

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