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

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

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

revision 665, Wed Nov 20 20:11:09 2002 UTC revision 700, Sun Dec 8 14:57:09 2002 UTC
# Line 54  Line 54 
54    
55  #define iDiamondSize 2  #define iDiamondSize 2
56    
57    static VECTOR
58    GlobalMotionEst(const MACROBLOCK * const pMBs,
59                                    const MBParam * const pParam, const uint32_t iFcode);
60    
61    
62  static __inline int  static __inline int
63  d_mv_bits(int x, int y, const uint32_t iFcode)  d_mv_bits(int x, int y, const uint32_t iFcode)
64  {  {
# Line 137  Line 142 
142  Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data)  Interpolate8x8qpel(const int x, const int y, const int block, const int dir, const SearchData * const data)
143  {  {
144  // create or find a qpel-precision reference picture; return pointer to it  // create or find a qpel-precision reference picture; return pointer to it
145          uint8_t * Reference = (uint8_t *)data->RefQ;          uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir;
146          const int32_t iEdgedWidth = data->iEdgedWidth;          const int32_t iEdgedWidth = data->iEdgedWidth;
147          const uint32_t rounding = data->rounding;          const uint32_t rounding = data->rounding;
148          const int halfpel_x = x/2;          const int halfpel_x = x/2;
# Line 182  Line 187 
187  Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data)  Interpolate16x16qpel(const int x, const int y, const int dir, const SearchData * const data)
188  {  {
189  // create or find a qpel-precision reference picture; return pointer to it  // create or find a qpel-precision reference picture; return pointer to it
190          uint8_t * Reference = (uint8_t *)data->RefQ;          uint8_t * Reference = (uint8_t *)data->RefQ + 16*dir;
191          const int32_t iEdgedWidth = data->iEdgedWidth;          const int32_t iEdgedWidth = data->iEdgedWidth;
192          const uint32_t rounding = data->rounding;          const uint32_t rounding = data->rounding;
193          const int halfpel_x = x/2;          const int halfpel_x = x/2;
# Line 902  Line 907 
907    
908          get_pmvdata2(pMBs, pParam->mb_width, 0, x, y, 0, pmv, Data->temp);  //has to be changed to get_pmv(2)()          get_pmvdata2(pMBs, pParam->mb_width, 0, x, y, 0, pmv, Data->temp);  //has to be changed to get_pmv(2)()
909          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,
910                                  pParam->width, pParam->height, Data->iFcode, pParam->m_quarterpel);                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel);
911    
912          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;
913          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8;          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8;
# Line 1017  Line 1022 
1022          if((pParam->m_quarterpel) && (MotionFlags & PMV_QUARTERPELREFINE16)) {          if((pParam->m_quarterpel) && (MotionFlags & PMV_QUARTERPELREFINE16)) {
1023    
1024                  Data->qpel_precision = 1;                  Data->qpel_precision = 1;
1025                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,                  get_range_qpel(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
1026                                  pParam->width, pParam->height, Data->iFcode, 0);                                  pParam->width, pParam->height, Data->iFcode);
1027    
1028                  SubpelRefine(Data);                  SubpelRefine(Data);
1029          }          }
# Line 1120  Line 1125 
1125                  Data->qpel_precision = 0;                  Data->qpel_precision = 0;
1126    
1127                  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,
1128                                  pParam->width, pParam->height, OldData->iFcode, pParam->m_quarterpel);                                  pParam->width, pParam->height, OldData->iFcode - pParam->m_quarterpel);
1129                  CheckCandidate = CheckCandidate8;                  CheckCandidate = CheckCandidate8;
1130    
1131                  if (MotionFlags & PMV_EXTSEARCH8) {                  if (MotionFlags & PMV_EXTSEARCH8) {
# Line 1154  Line 1159 
1159                          if((!(Data->currentQMV->x & 1)) && (!(Data->currentQMV->y & 1)) &&                          if((!(Data->currentQMV->x & 1)) && (!(Data->currentQMV->y & 1)) &&
1160                                  (MotionFlags & PMV_QUARTERPELREFINE8)) {                                  (MotionFlags & PMV_QUARTERPELREFINE8)) {
1161                          Data->qpel_precision = 1;                          Data->qpel_precision = 1;
1162                          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8,                          get_range_qpel(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 8,
1163                                  pParam->width, pParam->height, OldData->iFcode, 0);                                  pParam->width, pParam->height, OldData->iFcode);
1164                          SubpelRefine(Data);                          SubpelRefine(Data);
1165                          }                          }
1166                  }                  }
# Line 1259  Line 1264 
1264          Data->predMV = *predMV;          Data->predMV = *predMV;
1265    
1266          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,
1267                                  pParam->width, pParam->height, iFcode, pParam->m_quarterpel);                                  pParam->width, pParam->height, iFcode - pParam->m_quarterpel);
1268    
1269          pmv[0] = Data->predMV;          pmv[0] = Data->predMV;
1270          if (Data->qpel) { pmv[0].x /= 2; pmv[0].y /= 2; }          if (Data->qpel) { pmv[0].x /= 2; pmv[0].y /= 2; }
# Line 1288  Line 1293 
1293                  Data->currentQMV->x = 2*Data->currentMV->x;                  Data->currentQMV->x = 2*Data->currentMV->x;
1294                  Data->currentQMV->y = 2*Data->currentMV->y;                  Data->currentQMV->y = 2*Data->currentMV->y;
1295                  Data->qpel_precision = 1;                  Data->qpel_precision = 1;
1296                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,                  get_range_qpel(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
1297                                          pParam->width, pParam->height, iFcode, 0);                                          pParam->width, pParam->height, iFcode);
1298                  SubpelRefine(Data);                  SubpelRefine(Data);
1299          }          }
1300    
# Line 1368  Line 1373 
1373                  Data->min_dy *= 2;                  Data->min_dy *= 2;
1374                  Data->referencemv = b_mb->qmvs;                  Data->referencemv = b_mb->qmvs;
1375          } else Data->referencemv = b_mb->mvs;          } else Data->referencemv = b_mb->mvs;
1376          Data->qpel_precision = 0; // it'm a trick. it's 1 not 0, but we need 0 here          Data->qpel_precision = 0; // it's a trick. it's 1 not 0, but we need 0 here
1377    
1378          for (k = 0; k < 4; k++) {          for (k = 0; k < 4; k++) {
1379                  pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD);                  pMB->mvs[k].x = Data->directmvF[k].x = ((TRB * Data->referencemv[k].x) / TRD);
# Line 1455  Line 1460 
1460    
1461          SubpelRefine(Data);          SubpelRefine(Data);
1462    
1463          *Data->iMinSAD +=  1 * Data->lambda16; // one bit is needed to code direct mode  //      *Data->iMinSAD +=  1 * Data->lambda16; // one bit is needed to code direct mode
1464          *best_sad = *Data->iMinSAD;          *best_sad = *Data->iMinSAD;
1465    
1466  //      if (b_mb->mode == MODE_INTER4V)          if (b_mb->mode == MODE_INTER4V)
1467                  pMB->mode = MODE_DIRECT;                  pMB->mode = MODE_DIRECT;
1468  //      else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation          else pMB->mode = MODE_DIRECT_NO4V; //for faster compensation
1469    
1470          pMB->pmvs[3] = *Data->currentMV;          pMB->pmvs[3] = *Data->currentMV;
1471    
# Line 1535  Line 1540 
1540          bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16;          bData.RefV = fData->bRefV = b_RefV + (x + y * iEdgedWidth) * 16;
1541          bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16;          bData.RefHV = fData->bRefHV = b_RefHV + (x + y * iEdgedWidth) * 16;
1542          bData.RefQ = fData->RefQ;          bData.RefQ = fData->RefQ;
1543          fData->qpel_precision = bData.qpel_precision = 0;          fData->qpel_precision = bData.qpel_precision = 0; bData.qpel = fData->qpel;
1544          bData.rounding = 0;          bData.rounding = 0;
1545    
1546          bData.bpredMV = fData->predMV = *f_predMV;          bData.bpredMV = fData->predMV = *f_predMV;
1547          fData->bpredMV = bData.predMV = *b_predMV;          fData->bpredMV = bData.predMV = *b_predMV;
1548    
1549          fData->currentMV[0] = fData->currentMV[2];          fData->currentMV[0] = fData->currentMV[2];
1550          get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode, pParam->m_quarterpel);          get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode - pParam->m_quarterpel);
1551          get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, pParam->m_quarterpel);          get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode - pParam->m_quarterpel);
1552    
1553          if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx;          if (fData->currentMV[0].x > fData->max_dx) fData->currentMV[0].x = fData->max_dx;
1554          if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dy;          if (fData->currentMV[0].x < fData->min_dx) fData->currentMV[0].x = fData->min_dx;
1555          if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dx;          if (fData->currentMV[0].y > fData->max_dy) fData->currentMV[0].y = fData->max_dy;
1556          if (fData->currentMV[0].y > fData->min_dy) fData->currentMV[0].y = fData->min_dy;          if (fData->currentMV[0].y < fData->min_dy) fData->currentMV[0].y = fData->min_dy;
1557    
1558          if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx;          if (fData->currentMV[1].x > bData.max_dx) fData->currentMV[1].x = bData.max_dx;
1559          if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dy;          if (fData->currentMV[1].x < bData.min_dx) fData->currentMV[1].x = bData.min_dx;
1560          if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dx;          if (fData->currentMV[1].y > bData.max_dy) fData->currentMV[1].y = bData.max_dy;
1561          if (fData->currentMV[1].y > bData.min_dy) fData->currentMV[1].y = bData.min_dy;          if (fData->currentMV[1].y < bData.min_dy) fData->currentMV[1].y = bData.min_dy;
1562    
1563          CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData);          CheckCandidateInt(fData->currentMV[0].x, fData->currentMV[0].y, 255, &iDirection, fData);
1564    
# Line 1579  Line 1584 
1584    
1585          } while (!(iDirection));          } while (!(iDirection));
1586    
         *fData->iMinSAD +=  2 * fData->lambda16; // two bits are needed to code interpolate mode.  
   
1587          if (fData->qpel) {          if (fData->qpel) {
1588                    CheckCandidate = CheckCandidateInt;
1589                  fData->qpel_precision = bData.qpel_precision = 1;                  fData->qpel_precision = bData.qpel_precision = 1;
1590                  get_range(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode, 0);                  get_range_qpel(&fData->min_dx, &fData->max_dx, &fData->min_dy, &fData->max_dy, x, y, 16, pParam->width, pParam->height, fcode);
1591                  get_range(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode, 0);                  get_range_qpel(&bData.min_dx, &bData.max_dx, &bData.min_dy, &bData.max_dy, x, y, 16, pParam->width, pParam->height, bcode);
1592                  fData->currentQMV[2].x = fData->currentQMV[0].x = 2 * fData->currentMV[0].x;                  fData->currentQMV[2].x = fData->currentQMV[0].x = 2 * fData->currentMV[0].x;
1593                  fData->currentQMV[2].y = fData->currentQMV[0].y = 2 * fData->currentMV[0].y;                  fData->currentQMV[2].y = fData->currentQMV[0].y = 2 * fData->currentMV[0].y;
1594                  fData->currentQMV[1].x = 2 * fData->currentMV[1].x;                  fData->currentQMV[1].x = 2 * fData->currentMV[1].x;
# Line 1594  Line 1598 
1598                  SubpelRefine(&bData);                  SubpelRefine(&bData);
1599          }          }
1600    
1601            *fData->iMinSAD +=  2 * fData->lambda16; // two bits are needed to code interpolate mode.
1602    
1603          if (*fData->iMinSAD < *best_sad) {          if (*fData->iMinSAD < *best_sad) {
1604                  *best_sad = *fData->iMinSAD;                  *best_sad = *fData->iMinSAD;
1605                  pMB->mvs[0] = fData->currentMV[0];                  pMB->mvs[0] = fData->currentMV[0];
# Line 1654  Line 1660 
1660          Data.iEdgedWidth = pParam->edged_width;          Data.iEdgedWidth = pParam->edged_width;
1661          Data.currentMV = currentMV; Data.currentQMV = currentQMV;          Data.currentMV = currentMV; Data.currentQMV = currentQMV;
1662          Data.iMinSAD = &iMinSAD;          Data.iMinSAD = &iMinSAD;
1663          Data.lambda16 = lambda_vec16[frame->quant];          Data.lambda16 = lambda_vec16[frame->quant] + 2;
1664          Data.qpel = pParam->m_quarterpel;          Data.qpel = pParam->m_quarterpel;
1665          Data.rounding = 0;          Data.rounding = 0;
1666    
# Line 1751  Line 1757 
1757                                  case MODE_DIRECT:                                  case MODE_DIRECT:
1758                                  case MODE_DIRECT_NO4V:                                  case MODE_DIRECT_NO4V:
1759                                          d_count++;                                          d_count++;
                                         break;  
1760                                  default:                                  default:
1761                                          break;                                          break;
1762                          }                          }
# Line 1783  Line 1788 
1788          MainSearchFunc * MainSearchPtr;          MainSearchFunc * MainSearchPtr;
1789    
1790          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,
1791                                  pParam->width, pParam->height, Data->iFcode, pParam->m_quarterpel);                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel);
1792    
1793          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;
1794          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8;          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8;
# Line 1846  Line 1851 
1851          }          }
1852    
1853          if((pParam->m_quarterpel) && (MotionFlags & PMV_QUARTERPELREFINE16)) {          if((pParam->m_quarterpel) && (MotionFlags & PMV_QUARTERPELREFINE16)) {
1854                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,                  get_range_qpel(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
1855                                  pParam->width, pParam->height, Data->iFcode, 0);                                  pParam->width, pParam->height, Data->iFcode);
1856                  Data->qpel_precision = 1;                  Data->qpel_precision = 1;
1857                  SubpelRefine(Data);                  SubpelRefine(Data);
1858          }          }
# Line 2003  Line 2008 
2008                          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
2009    
2010          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,
2011                                  pParam->width, pParam->height, Data->iFcode, pParam->m_quarterpel);                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel);
2012    
2013          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;
2014          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;
# Line 2037  Line 2042 
2042  }  }
2043    
2044  #define INTRA_THRESH    1350  #define INTRA_THRESH    1350
2045  #define INTER_THRESH    900  #define INTER_THRESH    1200
2046    
2047    
2048  int  int
# Line 2070  Line 2075 
2075                          IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra;                          IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra;
2076    
2077    
2078          InterThresh += 300 * (1 - bCount);          InterThresh += 400 * (1 - bCount);
2079          if (InterThresh < 200) InterThresh = 200;          if (InterThresh < 200) InterThresh = 200;
2080    
2081          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();

Legend:
Removed from v.665  
changed lines
  Added in v.700

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