[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 1095, Thu Jul 24 13:09:27 2003 UTC revision 1107, Sat Aug 2 15:08:48 2003 UTC
# Line 21  Line 21 
21   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
24   * $Id: motion_est.c,v 1.58.2.23 2003-07-24 13:09:01 Isibaar Exp $   * $Id: motion_est.c,v 1.58.2.24 2003-08-02 15:08:39 edgomez Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 1010  Line 1010 
1010    
1011          pMB->mcsel = 0;          pMB->mcsel = 0;
1012    
1013          if (!(VopFlags & XVID_VOP_MODEDECISION_BITS)) { /* normal, fast, SAD-based mode decision */          if (!(VopFlags & XVID_VOP_MODEDECISION_RD)) { /* normal, fast, SAD-based mode decision */
1014                  int sad;                  int sad;
1015                  int InterBias = MV16_INTER_BIAS;                  int InterBias = MV16_INTER_BIAS;
1016                  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 1186  Line 1186 
1186          int32_t quant = current->quant, sad00;          int32_t quant = current->quant, sad00;
1187          int skip_thresh = INITIAL_SKIP_THRESH * \          int skip_thresh = INITIAL_SKIP_THRESH * \
1188                  (current->vop_flags & XVID_VOP_REDUCED ? 4:1) * \                  (current->vop_flags & XVID_VOP_REDUCED ? 4:1) * \
1189                  (current->vop_flags & XVID_VOP_MODEDECISION_BITS ? 2:1);                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
1190    
1191          /* some pre-initialized thingies for SearchP */          /* some pre-initialized thingies for SearchP */
1192          int32_t temp[8];          int32_t temp[8];
# Line 1204  Line 1204 
1204          Data.iFcode = current->fcode;          Data.iFcode = current->fcode;
1205          Data.rounding = pParam->m_rounding_type;          Data.rounding = pParam->m_rounding_type;
1206          Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);          Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);
1207          Data.chroma = MotionFlags & XVID_ME_CHROMA16;          Data.chroma = MotionFlags & XVID_ME_CHROMA_PVOP;
1208          Data.rrv = (current->vop_flags & XVID_VOP_REDUCED) ? 1:0;          Data.rrv = (current->vop_flags & XVID_VOP_REDUCED) ? 1:0;
1209          Data.dctSpace = dct_space;          Data.dctSpace = dct_space;
1210          Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);          Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);
# Line 1400  Line 1400 
1400          Data->iMinSAD[3] = pMB->sad8[2];          Data->iMinSAD[3] = pMB->sad8[2];
1401          Data->iMinSAD[4] = pMB->sad8[3];          Data->iMinSAD[4] = pMB->sad8[3];
1402    
1403          if ((!(VopFlags & XVID_VOP_MODEDECISION_BITS)) && (x | y)) {          if ((!(VopFlags & XVID_VOP_MODEDECISION_RD)) && (x | y)) {
1404                  threshA = Data->temp[0]; /* that's where we keep this SAD atm */                  threshA = Data->temp[0]; /* that's where we keep this SAD atm */
1405                  if (threshA < 512) threshA = 512;                  if (threshA < 512) threshA = 512;
1406                  else if (threshA > 1024) threshA = 1024;                  else if (threshA > 1024) threshA = 1024;
# Line 1499  Line 1499 
1499                  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);
1500                  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);
1501    
1502                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_BITS))) {                  if ((Data->chroma) && (!(VopFlags & XVID_VOP_MODEDECISION_RD))) {
1503                          /* chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, it will not be used */                          /* chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, it will not be used */
1504                          int sumx = 0, sumy = 0;                          int sumx = 0, sumy = 0;
1505    
# Line 1565  Line 1565 
1565                  if (!Data->rrv) CheckCandidate = CheckCandidate8;                  if (!Data->rrv) CheckCandidate = CheckCandidate8;
1566                  else CheckCandidate = CheckCandidate16no4v;                  else CheckCandidate = CheckCandidate16no4v;
1567    
1568                  if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_BITS))) {                  if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_RD))) {
1569                          int32_t temp_sad = *(Data->iMinSAD); /* store current MinSAD */                          int32_t temp_sad = *(Data->iMinSAD); /* store current MinSAD */
1570    
1571                          MainSearchFunc *MainSearchPtr;                          MainSearchFunc *MainSearchPtr;
# Line 2114  Line 2114 
2114          Data.lambda16 = lambda_vec16[frame->quant];          Data.lambda16 = lambda_vec16[frame->quant];
2115          Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL;          Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL;
2116          Data.rounding = 0;          Data.rounding = 0;
2117          Data.chroma = frame->motion_flags & XVID_ME_CHROMA8;          Data.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP;
2118          Data.temp = temp;          Data.temp = temp;
2119    
2120          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 2382  Line 2382 
2382                  Data->qpel_precision = 1;                  Data->qpel_precision = 1;
2383                  CheckCandidateBits16(Data->currentQMV[0].x, Data->currentQMV[0].y, 255, &iDirection, Data);                  CheckCandidateBits16(Data->currentQMV[0].x, Data->currentQMV[0].y, 255, &iDirection, Data);
2384    
2385                  if (MotionFlags & (XVID_ME_HALFPELREFINE16_BITS | XVID_ME_EXTSEARCH_BITS)) { /* we have to prepare for halfpixel-precision search */                  if (MotionFlags & (XVID_ME_HALFPELREFINE16_RD | XVID_ME_EXTSEARCH_RD)) { /* we have to prepare for halfpixel-precision search */
2386                          for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i];                          for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i];
2387                          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,
2388                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv);                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv);
# Line 2396  Line 2396 
2396                  CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data);                  CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data);
2397          }          }
2398    
2399          if (MotionFlags&XVID_ME_EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection);          if (MotionFlags&XVID_ME_EXTSEARCH_RD) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
2400    
2401          if (MotionFlags&XVID_ME_HALFPELREFINE16_BITS) SubpelRefine(Data);          if (MotionFlags&XVID_ME_HALFPELREFINE16_RD) SubpelRefine(Data);
2402    
2403          if (Data->qpel) {          if (Data->qpel) {
2404                  if (MotionFlags&(XVID_ME_EXTSEARCH_BITS | XVID_ME_HALFPELREFINE16_BITS)) { /* there was halfpel-precision search */                  if (MotionFlags&(XVID_ME_EXTSEARCH_RD | XVID_ME_HALFPELREFINE16_RD)) { /* there was halfpel-precision search */
2405                          for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) {                          for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) {
2406                                  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 */
2407                                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;                                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;
# Line 2412  Line 2412 
2412                          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,
2413                                          pParam->width, pParam->height, Data->iFcode, 1, 0);                                          pParam->width, pParam->height, Data->iFcode, 1, 0);
2414                  }                  }
2415                  if (MotionFlags&XVID_ME_QUARTERPELREFINE16_BITS) SubpelRefine(Data);                  if (MotionFlags&XVID_ME_QUARTERPELREFINE16_RD) SubpelRefine(Data);
2416          }          }
2417    
2418          if (MotionFlags&XVID_ME_CHECKPREDICTION_BITS) { /* let's check vector equal to prediction */          if (MotionFlags&XVID_ME_CHECKPREDICTION_RD) { /* let's check vector equal to prediction */
2419                  VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV;                  VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV;
2420                  if (!(Data->predMV.x == v->x && Data->predMV.y == v->y))                  if (!(Data->predMV.x == v->x && Data->predMV.y == v->y))
2421                          CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data);                          CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data);
# Line 2477  Line 2477 
2477                  }                  }
2478    
2479                  if (Data8->qpel) {                  if (Data8->qpel) {
2480                          if (MotionFlags&XVID_ME_HALFPELREFINE8_BITS || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_BITS)) { /* halfpixel motion search follows */                          if (MotionFlags&XVID_ME_HALFPELREFINE8_RD || (MotionFlags&XVID_ME_EXTSEARCH8 && MotionFlags&XVID_ME_EXTSEARCH_RD)) { /* halfpixel motion search follows */
2481                                  int32_t s = *Data8->iMinSAD;                                  int32_t s = *Data8->iMinSAD;
2482                                  Data8->currentMV->x = Data8->currentQMV->x/2;                                  Data8->currentMV->x = Data8->currentQMV->x/2;
2483                                  Data8->currentMV->y = Data8->currentQMV->y/2;                                  Data8->currentMV->y = Data8->currentQMV->y/2;
# Line 2488  Line 2488 
2488                                  if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1)                                  if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1)
2489                                          CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8);                                          CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8);
2490    
2491                                  if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS)                                  if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_RD)
2492                                          SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);                                          SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);
2493    
2494                                  if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS)                                  if (MotionFlags & XVID_ME_HALFPELREFINE8_RD)
2495                                          SubpelRefine(Data8);                                          SubpelRefine(Data8);
2496    
2497                                  if(s > *Data8->iMinSAD) { /* we have found a better match */                                  if(s > *Data8->iMinSAD) { /* we have found a better match */
# Line 2504  Line 2504 
2504                                                          pParam->width, pParam->height, Data8->iFcode, 1, 0);                                                          pParam->width, pParam->height, Data8->iFcode, 1, 0);
2505    
2506                          }                          }
2507                          if (MotionFlags & XVID_ME_QUARTERPELREFINE8_BITS) SubpelRefine(Data8);                          if (MotionFlags & XVID_ME_QUARTERPELREFINE8_RD) SubpelRefine(Data8);
2508    
2509                  } else { /* not qpel */                  } else { /* not qpel */
2510    
2511                          if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_BITS) /* extsearch */                          if (MotionFlags & XVID_ME_EXTSEARCH8 && MotionFlags & XVID_ME_EXTSEARCH_RD) /* extsearch */
2512                                  SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);                                  SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);
2513    
2514                          if (MotionFlags & XVID_ME_HALFPELREFINE8_BITS)                          if (MotionFlags & XVID_ME_HALFPELREFINE8_RD)
2515                                  SubpelRefine(Data8); /* halfpel refinement */                                  SubpelRefine(Data8); /* halfpel refinement */
2516                  }                  }
2517    
2518                  /* checking vector equal to predicion */                  /* checking vector equal to predicion */
2519                  if (i != 0 && MotionFlags & XVID_ME_CHECKPREDICTION_BITS) {                  if (i != 0 && MotionFlags & XVID_ME_CHECKPREDICTION_RD) {
2520                          const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV;                          const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV;
2521                          if (!MVequal(*v, Data8->predMV))                          if (!MVequal(*v, Data8->predMV))
2522                                  CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8);                                  CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8);
# Line 2908  Line 2908 
2908  */  */
2909                  gmc.duv[0].x= gmc.duv[0].y= gmc.duv[1].x= gmc.duv[1].y= gmc.duv[2].x= gmc.duv[2].y=0;                  gmc.duv[0].x= gmc.duv[0].y= gmc.duv[1].x= gmc.duv[1].y= gmc.duv[2].x= gmc.duv[2].y=0;
2910    
2911                  if (!(current->motion_flags & XVID_GME_REFINE))                  if (!(current->motion_flags & XVID_ME_GME_REFINE))
2912                          return gmc;                          return gmc;
2913    
2914                  for (my = 1; my < (uint32_t)MBh-1; my++) /* ignore boundary blocks */                  for (my = 1; my < (uint32_t)MBh-1; my++) /* ignore boundary blocks */

Legend:
Removed from v.1095  
changed lines
  Added in v.1107

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