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

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

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

revision 1215, Wed Nov 19 12:24:25 2003 UTC revision 1238, Wed Dec 3 19:46:50 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: estimation_bvop.c,v 1.1.2.5 2003-11-19 12:24:25 syskin Exp $   * $Id: estimation_bvop.c,v 1.1.2.7 2003-12-03 19:46:50 edgomez Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 361  Line 361 
361    
362          int i;          int i;
363          VECTOR pmv[7];          VECTOR pmv[7];
         MainSearchFunc *MainSearchPtr;  
364          *Data->iMinSAD = MV_MAX_ERROR;          *Data->iMinSAD = MV_MAX_ERROR;
365          Data->iFcode = iFcode;          Data->iFcode = iFcode;
366          Data->qpel_precision = 0;          Data->qpel_precision = 0;
367          Data->chromaX = Data->chromaX = Data->chromaSAD = 256*4096; /* reset chroma-sad cache */          Data->chromaX = Data->chromaY = Data->chromaSAD = 256*4096; /* reset chroma-sad cache */
368    
369          Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16;          Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16;
370          Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16;          Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16;
# Line 391  Line 390 
390                  if (!vector_repeats(pmv, i) )                  if (!vector_repeats(pmv, i) )
391                          CheckCandidate16no4v(pmv[i].x, pmv[i].y, Data, i);                          CheckCandidate16no4v(pmv[i].x, pmv[i].y, Data, i);
392    
393            if (*Data->iMinSAD > 512) {
394                    unsigned int mask = make_mask(pmv, 7, Data->dir);
395    
396                    MainSearchFunc *MainSearchPtr;
397          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = xvid_me_SquareSearch;          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = xvid_me_SquareSearch;
398          else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = xvid_me_AdvDiamondSearch;          else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = xvid_me_AdvDiamondSearch;
399                  else MainSearchPtr = xvid_me_DiamondSearch;                  else MainSearchPtr = xvid_me_DiamondSearch;
400    
         if (*Data->iMinSAD > 512) {  
                 unsigned int mask = make_mask(pmv, 7, Data->dir);  
401                  MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, mask, CheckCandidate16no4v);                  MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, mask, CheckCandidate16no4v);
402          }          }
403    
# Line 446  Line 447 
447                                  const uint32_t x, const uint32_t y,                                  const uint32_t x, const uint32_t y,
448                                  const SearchData * const Data)                                  const SearchData * const Data)
449  {  {
450            int k;
451    
452            if (!Data->chroma) {
453          int dx = 0, dy = 0, b_dx = 0, b_dy = 0;          int dx = 0, dy = 0, b_dx = 0, b_dy = 0;
454          int32_t sum;          int32_t sum;
         int k;  
455          const uint32_t stride = Data->iEdgedWidth/2;          const uint32_t stride = Data->iEdgedWidth/2;
456          /* this is not full chroma compensation, only it's fullpel approximation. should work though */          /* this is not full chroma compensation, only it's fullpel approximation. should work though */
457    
# Line 476  Line 479 
479                                          b_Ref->v + (y*8 + b_dy/2) * stride + x*8 + b_dx/2,                                          b_Ref->v + (y*8 + b_dy/2) * stride + x*8 + b_dx/2,
480                                          stride);                                          stride);
481    
482          if (sum < MAX_CHROMA_SAD_FOR_SKIP * (int)Data->iQuant) {                  if (sum >= MAX_CHROMA_SAD_FOR_SKIP * (int)Data->iQuant) return; /* no skip */
483            }
484    
485            /* skip */
486                  pMB->mode = MODE_DIRECT_NONE_MV; /* skipped */                  pMB->mode = MODE_DIRECT_NONE_MV; /* skipped */
487                  for (k = 0; k < 4; k++) {                  for (k = 0; k < 4; k++) {
488                          pMB->qmvs[k] = pMB->mvs[k] = Data->directmvF[k];                          pMB->qmvs[k] = pMB->mvs[k] = Data->directmvF[k];
489                          pMB->b_qmvs[k] = pMB->b_mvs[k] =  Data->directmvB[k];                          pMB->b_qmvs[k] = pMB->b_mvs[k] =  Data->directmvB[k];
490                  }                  }
491          }          }
 }  
492    
493  static uint32_t  static uint32_t
494  SearchDirect(const IMAGE * const f_Ref,  SearchDirect(const IMAGE * const f_Ref,
# Line 563  Line 568 
568          /* initial (fast) skip decision */          /* initial (fast) skip decision */
569          if (*Data->iMinSAD < (int)Data->iQuant * INITIAL_SKIP_THRESH * (Data->chroma?3:2)) {          if (*Data->iMinSAD < (int)Data->iQuant * INITIAL_SKIP_THRESH * (Data->chroma?3:2)) {
570                  /* possible skip */                  /* possible skip */
                 if (Data->chroma) {  
                         pMB->mode = MODE_DIRECT_NONE_MV;  
                         return *Data->iMinSAD; /* skip. */  
                 } else {  
571                          SkipDecisionB(pCur, f_Ref, b_Ref, pMB, x, y, Data);                          SkipDecisionB(pCur, f_Ref, b_Ref, pMB, x, y, Data);
572                          if (pMB->mode == MODE_DIRECT_NONE_MV) return *Data->iMinSAD; /* skip. */                  if (pMB->mode == MODE_DIRECT_NONE_MV) return *Data->iMinSAD; /* skipped */
                 }  
573          }          }
574    
575          *Data->iMinSAD += Data->lambda16;          *Data->iMinSAD += Data->lambda16;
576          skip_sad = *Data->iMinSAD;          skip_sad = *Data->iMinSAD;
577    
         /*  
          * DIRECT MODE DELTA VECTOR SEARCH.  
          * This has to be made more effective, but at the moment I'm happy it's running at all  
          */  
   
578          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = xvid_me_SquareSearch;          if (MotionFlags & XVID_ME_USESQUARES16) MainSearchPtr = xvid_me_SquareSearch;
579                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = xvid_me_AdvDiamondSearch;                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND16) MainSearchPtr = xvid_me_AdvDiamondSearch;
580                          else MainSearchPtr = xvid_me_DiamondSearch;                          else MainSearchPtr = xvid_me_DiamondSearch;
# Line 753  Line 748 
748                  SubpelRefine_dir(Data, CheckCandidateInt, 2);                  SubpelRefine_dir(Data, CheckCandidateInt, 2);
749          }          }
750    
751          *Data->iMinSAD += (2+3) * Data->lambda16; /* two bits are needed to code interpolate mode. */          *Data->iMinSAD += 2 * Data->lambda16; /* two bits are needed to code interpolate mode. */
752    
753          if (*Data->iMinSAD < *best_sad) {          if (*Data->iMinSAD < *best_sad) {
754                  *best_sad = *Data->iMinSAD;                  *best_sad = *Data->iMinSAD;
# Line 811  Line 806 
806          memset(&Data, 0, sizeof(SearchData));          memset(&Data, 0, sizeof(SearchData));
807    
808          Data.iEdgedWidth = pParam->edged_width;          Data.iEdgedWidth = pParam->edged_width;
         Data.lambda16 = xvid_me_lambda_vec16[MAX(frame->quant-2, 2)];  
809          Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL ? 1 : 0;          Data.qpel = pParam->vol_flags & XVID_VOL_QUARTERPEL ? 1 : 0;
810          Data.rounding = 0;          Data.rounding = 0;
811          Data.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP;          Data.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP;
# Line 836  Line 830 
830                                          continue;                                          continue;
831                                  }                                  }
832    
833                            Data.lambda16 = xvid_me_lambda_vec16[b_mb->quant];
834    
835                          Data.Cur = frame->image.y + (j * Data.iEdgedWidth + i) * 16;                          Data.Cur = frame->image.y + (j * Data.iEdgedWidth + i) * 16;
836                          Data.CurU = frame->image.u + (j * Data.iEdgedWidth/2 + i) * 8;                          Data.CurU = frame->image.u + (j * Data.iEdgedWidth/2 + i) * 8;
837                          Data.CurV = frame->image.v + (j * Data.iEdgedWidth/2 + i) * 8;                          Data.CurV = frame->image.v + (j * Data.iEdgedWidth/2 + i) * 8;
# Line 883  Line 879 
879                                                  &Data);                                                  &Data);
880    
881                          /* final skip decision */                          /* final skip decision */
882                          if ( (skip_sad < Data.iQuant * MAX_SAD00_FOR_SKIP * 2)                          if ( (skip_sad < Data.iQuant * MAX_SAD00_FOR_SKIP * (Data.chroma ? 3:2) )
883                                          && ((100*best_sad)/(skip_sad+1) > FINAL_SKIP_THRESH) )                                          && ((100*best_sad)/(skip_sad+1) > FINAL_SKIP_THRESH) )
884    
885                                  SkipDecisionB(&frame->image, f_ref, b_ref, pMB, i, j, &Data);                                  SkipDecisionB(&frame->image, f_ref, b_ref, pMB, i, j, &Data);
886    
887                          switch (pMB->mode) {                          switch (pMB->mode) {

Legend:
Removed from v.1215  
changed lines
  Added in v.1238

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