[svn] / trunk / xvidcore / src / motion / estimation_bvop.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/motion/estimation_bvop.c

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

revision 1478, Thu Jul 8 07:12:54 2004 UTC revision 1515, Wed Jul 21 12:50:30 2004 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.7 2004-07-08 07:12:54 syskin Exp $   * $Id: estimation_bvop.c,v 1.11 2004-07-21 12:50:30 syskin Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 375  Line 375 
375          Data_d->CurU = Data_f->CurU = Data_b->CurU = Data_i->CurU = Cur[1];          Data_d->CurU = Data_f->CurU = Data_b->CurU = Data_i->CurU = Cur[1];
376          Data_d->CurV = Data_f->CurV = Data_b->CurV = Data_i->CurV = Cur[2];          Data_d->CurV = Data_f->CurV = Data_b->CurV = Data_i->CurV = Cur[2];
377    
378          Data_d->lambda16 = lambda/4;          Data_d->lambda16 = Data_f->lambda16 = Data_b->lambda16 = Data_i->lambda16 = lambda;
         Data_f->lambda16 = Data_b->lambda16 = Data_i->lambda16 = lambda;  
379    
380          /* reset chroma-sad cache */          /* reset chroma-sad cache */
381          Data_d->b_chromaX = Data_d->b_chromaY = Data_d->chromaX = Data_d->chromaY = Data_d->chromaSAD = 256*4096;          Data_d->b_chromaX = Data_d->b_chromaY = Data_d->chromaX = Data_d->chromaY = Data_d->chromaSAD = 256*4096;
# Line 401  Line 400 
400                                                          const uint32_t mode_curr,                                                          const uint32_t mode_curr,
401                                                          const VECTOR hint)                                                          const VECTOR hint)
402  {  {
   
403          /* [0] is prediction */          /* [0] is prediction */
404          pmv[0].x = (pmv[0].x); pmv[0].y = (pmv[0].y);          /* [1] is zero */
405            pmv[1].x = pmv[1].y = 0;
         pmv[1].x = pmv[1].y = 0; /* [1] is zero */  
406    
407          pmv[2].x = hint.x; pmv[2].y = hint.y;          pmv[2].x = hint.x; pmv[2].y = hint.y;
408    
# Line 525  Line 522 
522  {  {
523          int k;          int k;
524    
525            pMB->mode = MODE_DIRECT; /* just to initialize it */
526    
527          if (!Data->chroma) {          if (!Data->chroma) {
528                  int dx = 0, dy = 0, b_dx = 0, b_dy = 0;                  int dx = 0, dy = 0, b_dx = 0, b_dy = 0;
529                  int32_t sum;                  int32_t sum;
# Line 556  Line 555 
555                                                  stride);                                                  stride);
556    
557                  if (sum >= MAX_CHROMA_SAD_FOR_SKIP * (int)Data->iQuant) return; /* no skip */                  if (sum >= MAX_CHROMA_SAD_FOR_SKIP * (int)Data->iQuant) return; /* no skip */
558            } else {
559                    int sum = Data->chromaSAD; /* chroma-sad SAD caching keeps it there */
560    
561                    if (sum >= MAX_CHROMA_SAD_FOR_SKIP * (int)Data->iQuant) return; /* no skip */
562          }          }
563    
564          /* skip */          /* skip */
# Line 611  Line 614 
614    
615          CheckCandidateDirect(0, 0, Data, 255);  /* will also fill iMinSAD[1..4] with 8x8 SADs */          CheckCandidateDirect(0, 0, Data, 255);  /* will also fill iMinSAD[1..4] with 8x8 SADs */
616    
   
617          /* initial (fast) skip decision */          /* initial (fast) skip decision */
618          if (Data->iMinSAD[1] < (int)Data->iQuant * INITIAL_SKIP_THRESH          if (Data->iMinSAD[1] < (int)Data->iQuant * INITIAL_SKIP_THRESH
619                  && Data->iMinSAD[2] < (int)Data->iQuant * INITIAL_SKIP_THRESH                  && Data->iMinSAD[2] < (int)Data->iQuant * INITIAL_SKIP_THRESH
# Line 869  Line 871 
871                          *f_predMV = Data_f->currentMV[0];                          *f_predMV = Data_f->currentMV[0];
872                  }                  }
873                  pMB->mvs[0] = *Data_f->currentMV;                  pMB->mvs[0] = *Data_f->currentMV;
874                    pMB->b_mvs[0] = *Data_b->currentMV; /* hint for future searches */
875                  break;                  break;
876    
877          case MODE_BACKWARD:          case MODE_BACKWARD:
# Line 883  Line 886 
886                          *b_predMV = Data_b->currentMV[0];                          *b_predMV = Data_b->currentMV[0];
887                  }                  }
888                  pMB->b_mvs[0] = *Data_b->currentMV;                  pMB->b_mvs[0] = *Data_b->currentMV;
889                    pMB->mvs[0] = *Data_f->currentMV; /* hint for future searches */
890                  break;                  break;
891    
892    
# Line 938  Line 942 
942    
943          const int32_t TRB = time_pp - time_bp;          const int32_t TRB = time_pp - time_bp;
944          const int32_t TRD = time_pp;          const int32_t TRD = time_pp;
945            DECLARE_ALIGNED_MATRIX(dct_space, 3, 64, int16_t, CACHE_LINE);
946    
947          /* some pre-inintialized data for the rest of the search */          /* some pre-inintialized data for the rest of the search */
948          SearchData Data_d, Data_f, Data_b, Data_i;          SearchData Data_d, Data_f, Data_b, Data_i;
# Line 948  Line 953 
953          Data_d.rounding = 0;          Data_d.rounding = 0;
954          Data_d.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP;          Data_d.chroma = frame->motion_flags & XVID_ME_CHROMA_BVOP;
955          Data_d.iQuant = frame->quant;          Data_d.iQuant = frame->quant;
956            Data_d.dctSpace = dct_space;
957            Data_d.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);
958            Data_d.mpeg_quant_matrices = pParam->mpeg_quant_matrices;
959    
960          Data_d.RefQ = f_refV->u; /* a good place, also used in MC (for similar purpose) */          Data_d.RefQ = f_refV->u; /* a good place, also used in MC (for similar purpose) */
961    
# Line 966  Line 974 
974                  for (i = 0; i < pParam->mb_width; i++) {                  for (i = 0; i < pParam->mb_width; i++) {
975                          MACROBLOCK * const pMB = frame->mbs + i + j * pParam->mb_width;                          MACROBLOCK * const pMB = frame->mbs + i + j * pParam->mb_width;
976                          const MACROBLOCK * const b_mb = b_mbs + i + j * pParam->mb_width;                          const MACROBLOCK * const b_mb = b_mbs + i + j * pParam->mb_width;
                         int interpol_search = 0;  
                         int bf_search = 0;  
                         int bf_thresh = 0;  
977                          pMB->mode = -1;                          pMB->mode = -1;
978    
979                          initialize_searchData(&Data_d, &Data_f, &Data_b, &Data_i,                          initialize_searchData(&Data_d, &Data_f, &Data_b, &Data_i,
# Line 1003  Line 1008 
1008    
1009                          sad2 = best_sad;                          sad2 = best_sad;
1010    
1011                          if (Data_f.iMinSAD[0] < 2*sad2+1500)                          if (Data_f.iMinSAD[0] < 2*sad2+2000)
1012                                  SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_f);                                  SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_f);
1013    
1014                          if (Data_b.iMinSAD[0] < 2*sad2+1500)                          if (Data_b.iMinSAD[0] < 2*sad2+2000)
1015                                  SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_b);                                  SearchBF_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_b);
1016    
1017                          SearchInterpolate_initial(i, j, frame->motion_flags, pParam, &f_predMV, &b_predMV, &best_sad,                          SearchInterpolate_initial(i, j, frame->motion_flags, pParam, &f_predMV, &b_predMV, &best_sad,
1018                                                                    &Data_i, Data_f.currentMV[0], Data_b.currentMV[0]);                                                                    &Data_i, Data_f.currentMV[0], Data_b.currentMV[0]);
1019    
1020                          if (((Data_i.iMinSAD[0] < 2*best_sad+2000) && (!(frame->motion_flags&XVID_ME_FAST_MODEINTERPOLATE))                          if (((Data_i.iMinSAD[0] < 2*best_sad+2000) && !(frame->motion_flags&XVID_ME_FAST_MODEINTERPOLATE))
1021                                  || Data_i.iMinSAD[0] <= best_sad))                                  || Data_i.iMinSAD[0] <= best_sad)
1022    
1023                                  SearchInterpolate_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_i);                                  SearchInterpolate_final(i, j, frame->motion_flags, pParam, &best_sad, &Data_i);
1024    
1025                            if ((Data_d.iMinSAD[0] <= 2*best_sad) && (!frame->motion_flags&XVID_ME_SKIP_DELTASEARCH))
                         if ((Data_d.iMinSAD[0] <= best_sad) && (!(frame->motion_flags&XVID_ME_SKIP_DELTASEARCH)))  
1026                                  SearchDirect_final(frame->motion_flags, b_mb, &best_sad, &Data_d);                                  SearchDirect_final(frame->motion_flags, b_mb, &best_sad, &Data_d);
1027    
1028    
# Line 1033  Line 1037 
1037                                  }                                  }
1038                          }                          }
1039    
1040                            if (frame->vop_flags & XVID_VOP_RD_BVOP)
1041                                    ModeDecision_BVOP_RD(&Data_d, &Data_b, &Data_f, &Data_i,
1042                                            pMB, b_mb, &f_predMV, &b_predMV, frame->motion_flags, pParam, i, j);
1043                            else
1044                          ModeDecision_BVOP_SAD(&Data_d, &Data_b, &Data_f, &Data_i, pMB, b_mb, &f_predMV, &b_predMV);                          ModeDecision_BVOP_SAD(&Data_d, &Data_b, &Data_f, &Data_i, pMB, b_mb, &f_predMV, &b_predMV);
1045    
1046                  }                  }

Legend:
Removed from v.1478  
changed lines
  Added in v.1515

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