[cvs] / xvidcore / src / motion / estimation_pvop.c Repository:
ViewVC logotype

Diff of /xvidcore/src/motion/estimation_pvop.c

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

revision 1.8, Thu Jul 8 07:12:54 2004 UTC revision 1.9, Sun Dec 5 04:53:01 2004 UTC
# Line 80  Line 80 
80          }          }
81    
82          sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp);          sad = sad16v(data->Cur, Reference, data->iEdgedWidth, data->temp);
83          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);
84    
85          sad += (data->lambda16 * t * sad)>>10;          sad += (data->lambda16 * t * sad)>>10;
86          data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10;          data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10;
# Line 127  Line 127 
127          }          }
128    
129          sad = sad8(data->Cur, Reference, data->iEdgedWidth);          sad = sad8(data->Cur, Reference, data->iEdgedWidth);
130          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision);
131    
132          sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10;          sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10;
133    
# Line 138  Line 138 
138          }          }
139  }  }
140    
 static void  
 CheckCandidate32(const int x, const int y, SearchData * const data, const unsigned int Direction)  
 {  
         uint32_t t;  
         const uint8_t * Reference;  
         int sad;  
   
         if ( (!(x&1) && x !=0) || (!(y&1) && y !=0) || /* non-zero even value */  
                 (x > data->max_dx) || (x < data->min_dx)  
                 || (y > data->max_dy) || (y < data->min_dy) ) return;  
   
         Reference = GetReference(x, y, data);  
         t = d_mv_bits(x, y, data->predMV, data->iFcode, 0, 1);  
   
         sad = sad32v_c(data->Cur, Reference, data->iEdgedWidth, data->temp);  
   
         sad += (data->lambda16 * t * sad) >> 10;  
         data->temp[0] += (data->lambda8 * t * (data->temp[0] + NEIGH_8X8_BIAS))>>10;  
   
         if (sad < data->iMinSAD[0]) {  
                 data->iMinSAD[0] = sad;  
                 data->currentMV[0].x = x; data->currentMV[0].y = y;  
                 data->dir = Direction;  
         }  
   
         if (data->temp[0] < data->iMinSAD[1]) {  
                 data->iMinSAD[1] = data->temp[0]; data->currentMV[1].x = x; data->currentMV[1].y = y; }  
         if (data->temp[1] < data->iMinSAD[2]) {  
                 data->iMinSAD[2] = data->temp[1]; data->currentMV[2].x = x; data->currentMV[2].y = y; }  
         if (data->temp[2] < data->iMinSAD[3]) {  
                 data->iMinSAD[3] = data->temp[2]; data->currentMV[3].x = x; data->currentMV[3].y = y; }  
         if (data->temp[3] < data->iMinSAD[4]) {  
                 data->iMinSAD[4] = data->temp[3]; data->currentMV[4].x = x; data->currentMV[4].y = y; }  
 }  
   
141  int  int
142  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,
143                                                          const int x, const int y,                                                          const int x, const int y,
144                                                          const uint32_t stride, const uint32_t iQuant, int rrv)                                                          const uint32_t stride, const uint32_t iQuant)
145  {  {
146          int offset = (x + y*stride)*8;          int offset = (x + y*stride)*8;
         if(!rrv) {  
147                  uint32_t sadC = sad8(current->u + offset,                  uint32_t sadC = sad8(current->u + offset,
148                                                  reference->u + offset, stride);                                                  reference->u + offset, stride);
149                  if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP) return 0;                  if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP) return 0;
# Line 187  Line 151 
151                                                  reference->v + offset, stride);                                                  reference->v + offset, stride);
152                  if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP) return 0;                  if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP) return 0;
153                  return 1;                  return 1;
   
         } else {  
                 uint32_t sadC = sad16(current->u + 2*offset,  
                                                 reference->u + 2*offset, stride, 256*4096);  
                 if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP*4) return 0;  
                 sadC += sad16(current->v + 2*offset,  
                                                 reference->v + 2*offset, stride, 256*4096);  
                 if (sadC > iQuant * MAX_CHROMA_SAD_FOR_SKIP*4) return 0;  
                 return 1;  
         }  
154  }  }
155    
156          /*          /*
# Line 341  Line 295 
295          /* 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?" */
296          if (skip_possible && (skip_sad < (int)iQuant * MAX_SAD00_FOR_SKIP))          if (skip_possible && (skip_sad < (int)iQuant * MAX_SAD00_FOR_SKIP))
297                  if ( (100*skip_sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH)                  if ( (100*skip_sad)/(pMB->sad16+1) > FINAL_SKIP_THRESH)
298                          if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant, Data->rrv)) {                          if (Data->chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, Data->iEdgedWidth/2, iQuant)) {
299                                  mode = MODE_NOT_CODED;                                  mode = MODE_NOT_CODED;
300                                  sad = 0;                                  sad = 0;
301                          }                          }
# Line 373  Line 327 
327                  if ((pMB - 1)->mode == MODE_INTRA ) InterBias -= 80;                  if ((pMB - 1)->mode == MODE_INTRA ) InterBias -= 80;
328    
329          if (Data->chroma) InterBias += 50; /* dev8(chroma) ??? <-- yes, we need dev8 (no big difference though) */          if (Data->chroma) InterBias += 50; /* dev8(chroma) ??? <-- yes, we need dev8 (no big difference though) */
         if (Data->rrv) InterBias *= 4;  
330    
331          if (InterBias < sad) {          if (InterBias < sad) {
332                  int32_t deviation;                  int32_t deviation = dev16(Data->Cur, Data->iEdgedWidth);
                 if (!Data->rrv)  
                         deviation = dev16(Data->Cur, Data->iEdgedWidth);  
                 else  
                         deviation = dev16(Data->Cur, Data->iEdgedWidth) + /* dev32() */  
                                                 dev16(Data->Cur+16, Data->iEdgedWidth) +  
                                                 dev16(Data->Cur + 16*Data->iEdgedWidth, Data->iEdgedWidth) +  
                                                 dev16(Data->Cur+16+16*Data->iEdgedWidth, Data->iEdgedWidth);  
   
333                  if (deviation < (sad - InterBias)) mode = MODE_INTRA;                  if (deviation < (sad - InterBias)) mode = MODE_INTRA;
334          }          }
335    
336          pMB->cbp = 63;          pMB->cbp = 63;
337          pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = sad;          pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = sad;
338    
         if (Data->rrv) {  
                         Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);  
                         Data->currentMV[0].y = RRV_MV_SCALEDOWN(Data->currentMV[0].y);  
         }  
   
339          if (mode == MODE_INTER && mcsel == 0) {          if (mode == MODE_INTER && mcsel == 0) {
340                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = Data->currentMV[0];                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = Data->currentMV[0];
341    
# Line 429  Line 369 
369    
370  static __inline void  static __inline void
371  PreparePredictionsP(VECTOR * const pmv, int x, int y, int iWcount,  PreparePredictionsP(VECTOR * const pmv, int x, int y, int iWcount,
372                          int iHcount, const MACROBLOCK * const prevMB, int rrv)                          int iHcount, const MACROBLOCK * const prevMB)
373  {  {
         /* this function depends on get_pmvdata which means that it sucks. It should get the predictions by itself */  
         if (rrv) { iWcount /= 2; iHcount /= 2; }  
374    
375          if ( (y != 0) && (x < (iWcount-1)) ) {          /* [5] top-right neighbour */          if ( (y != 0) && (x < (iWcount-1)) ) {          /* [5] top-right neighbour */
376                  pmv[5].x = EVEN(pmv[3].x);                  pmv[5].x = EVEN(pmv[3].x);
# Line 457  Line 395 
395                  pmv[6].x = EVEN((prevMB+1+iWcount)->mvs[0].x); /* [6] right-down neighbour in last frame */                  pmv[6].x = EVEN((prevMB+1+iWcount)->mvs[0].x); /* [6] right-down neighbour in last frame */
396                  pmv[6].y = EVEN((prevMB+1+iWcount)->mvs[0].y);                  pmv[6].y = EVEN((prevMB+1+iWcount)->mvs[0].y);
397          } else pmv[6].x = pmv[6].y = 0;          } else pmv[6].x = pmv[6].y = 0;
   
         if (rrv) {  
                 int i;  
                 for (i = 0; i < 7; i++) {  
                         pmv[i].x = RRV_MV_SCALEUP(pmv[i].x);  
                         pmv[i].y = RRV_MV_SCALEUP(pmv[i].y);  
                 }  
         }  
398  }  }
399    
400  static void  static void
# Line 479  Line 409 
409  {  {
410          int i = 0;          int i = 0;
411          VECTOR vbest_q; int32_t sbest_q;          VECTOR vbest_q; int32_t sbest_q;
         CheckFunc * CheckCandidate;  
412          *Data->iMinSAD = *(OldData->iMinSAD + 1 + block);          *Data->iMinSAD = *(OldData->iMinSAD + 1 + block);
413          *Data->currentMV = *(OldData->currentMV + 1 + block);          *Data->currentMV = *(OldData->currentMV + 1 + block);
414          *Data->currentQMV = *(OldData->currentQMV + 1 + block);          *Data->currentQMV = *(OldData->currentQMV + 1 + block);
# Line 487  Line 416 
416          if(Data->qpel) {          if(Data->qpel) {
417                  Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);                  Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);
418                  if (block != 0) i = d_mv_bits(  Data->currentQMV->x, Data->currentQMV->y,                  if (block != 0) i = d_mv_bits(  Data->currentQMV->x, Data->currentQMV->y,
419                                                                                  Data->predMV, Data->iFcode, 0, 0);                                                                                  Data->predMV, Data->iFcode, 0);
420          } else {          } else {
421                  Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);                  Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x/2, y/2, block);
422                  if (block != 0) i = d_mv_bits(  Data->currentMV->x, Data->currentMV->y,                  if (block != 0) i = d_mv_bits(  Data->currentMV->x, Data->currentMV->y,
423                                                                                  Data->predMV, Data->iFcode, 0, Data->rrv);                                                                                  Data->predMV, Data->iFcode, 0);
424          }          }
425    
426          *(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10;          *(Data->iMinSAD) += (Data->lambda8 * i * (*Data->iMinSAD + NEIGH_8X8_BIAS))>>10;
# Line 501  Line 430 
430                  vbest_q = Data->currentQMV[0];                  vbest_q = Data->currentQMV[0];
431                  sbest_q = Data->iMinSAD[0];                  sbest_q = Data->iMinSAD[0];
432    
                 if (Data->rrv) i = 16; else i = 8;  
433    
434                  Data->RefP[0] = OldData->RefP[0] + i * ((block&1) + Data->iEdgedWidth*(block>>1));                  Data->RefP[0] = OldData->RefP[0] + 8 * ((block&1) + Data->iEdgedWidth*(block>>1));
435                  Data->RefP[1] = OldData->RefP[1] + i * ((block&1) + Data->iEdgedWidth*(block>>1));                  Data->RefP[1] = OldData->RefP[1] + 8 * ((block&1) + Data->iEdgedWidth*(block>>1));
436                  Data->RefP[2] = OldData->RefP[2] + i * ((block&1) + Data->iEdgedWidth*(block>>1));                  Data->RefP[2] = OldData->RefP[2] + 8 * ((block&1) + Data->iEdgedWidth*(block>>1));
437                  Data->RefP[3] = OldData->RefP[3] + i * ((block&1) + Data->iEdgedWidth*(block>>1));                  Data->RefP[3] = OldData->RefP[3] + 8 * ((block&1) + Data->iEdgedWidth*(block>>1));
438    
439                  Data->Cur = OldData->Cur + i * ((block&1) + Data->iEdgedWidth*(block>>1));                  Data->Cur = OldData->Cur + 8 * ((block&1) + Data->iEdgedWidth*(block>>1));
440                  Data->qpel_precision = 0;                  Data->qpel_precision = 0;
441    
442                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,
443                                          pParam->width, pParam->height, Data->iFcode - Data->qpel, 1, Data->rrv);                                          pParam->width, pParam->height, Data->iFcode - Data->qpel, 1);
   
                 if (!Data->rrv) CheckCandidate = CheckCandidate8;  
                 else CheckCandidate = CheckCandidate16no4v;  
444    
445                  if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_RD))) {                  if (MotionFlags & XVID_ME_EXTSEARCH8 && (!(MotionFlags & XVID_ME_EXTSEARCH_RD))) {
446    
# Line 524  Line 449 
449                                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND8) MainSearchPtr = xvid_me_AdvDiamondSearch;                                  else if (MotionFlags & XVID_ME_ADVANCEDDIAMOND8) MainSearchPtr = xvid_me_AdvDiamondSearch;
450                                          else MainSearchPtr = xvid_me_DiamondSearch;                                          else MainSearchPtr = xvid_me_DiamondSearch;
451    
452                          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidate);                          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255, CheckCandidate8);
453                  }                  }
454    
455                  if(!Data->qpel) {                  if(!Data->qpel) {
456                          /* halfpel mode */                          /* halfpel mode */
457                          if (MotionFlags & XVID_ME_HALFPELREFINE8)                          if (MotionFlags & XVID_ME_HALFPELREFINE8)
458                                  /* perform halfpel refine of current best vector */                                  /* perform halfpel refine of current best vector */
459                                  xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate, 0);                                  xvid_me_SubpelRefine(Data->currentMV[0], Data, CheckCandidate8, 0);
460                  } else {                  } else {
461                          /* qpel mode */                          /* qpel mode */
462                          Data->currentQMV->x = 2*Data->currentMV->x;                          Data->currentQMV->x = 2*Data->currentMV->x;
# Line 540  Line 465 
465                          if(MotionFlags & XVID_ME_FASTREFINE8) {                          if(MotionFlags & XVID_ME_FASTREFINE8) {
466                                  /* fast */                                  /* fast */
467                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,
468                                          pParam->width, pParam->height, Data->iFcode, 2, 0);                                          pParam->width, pParam->height, Data->iFcode, 2);
469                                  FullRefine_Fast(Data, CheckCandidate8, 0);                                  FullRefine_Fast(Data, CheckCandidate8, 0);
470                          } else if(MotionFlags & XVID_ME_QUARTERPELREFINE8) {                          } else if(MotionFlags & XVID_ME_QUARTERPELREFINE8) {
471                                  /* full */                                  /* full */
# Line 551  Line 476 
476                                  }                                  }
477    
478                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 3,
479                                          pParam->width, pParam->height, Data->iFcode, 2, 0);                                          pParam->width, pParam->height, Data->iFcode, 2);
480                                  Data->qpel_precision = 1;                                  Data->qpel_precision = 1;
481    
482                                  xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate8, 0); /* qpel part */                                  xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate8, 0); /* qpel part */
# Line 563  Line 488 
488    
489          }          }
490    
491          if (Data->rrv) {          if(Data->qpel) {
                         Data->currentMV->x = RRV_MV_SCALEDOWN(Data->currentMV->x);  
                         Data->currentMV->y = RRV_MV_SCALEDOWN(Data->currentMV->y);  
         } else if(Data->qpel) {  
492                  pMB->pmvs[block].x = Data->currentQMV->x - Data->predMV.x;                  pMB->pmvs[block].x = Data->currentQMV->x - Data->predMV.x;
493                  pMB->pmvs[block].y = Data->currentQMV->y - Data->predMV.y;                  pMB->pmvs[block].y = Data->currentQMV->y - Data->predMV.y;
494                  pMB->qmvs[block] = *Data->currentQMV;                  pMB->qmvs[block] = *Data->currentQMV;
# Line 608  Line 530 
530          CheckFunc * CheckCandidate;          CheckFunc * CheckCandidate;
531    
532          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,
533                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 1, Data->rrv);                                                  pParam->width, pParam->height, Data->iFcode - Data->qpel, 1);
534    
535          get_pmvdata2(pMBs, pParam->mb_width, 0, x, y, pmv, Data->temp);          get_pmvdata2(pMBs, pParam->mb_width, 0, x, y, pmv, Data->temp);
536    
537          Data->chromaX = Data->chromaY = 0; /* chroma-sad cache */          Data->chromaX = Data->chromaY = 0; /* chroma-sad cache */
538          i = Data->rrv ? 2 : 1;          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16;
539          Data->Cur = pCur->y + (x + y * Data->iEdgedWidth) * 16*i;          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8;
540          Data->CurV = pCur->v + (x + y * (Data->iEdgedWidth/2)) * 8*i;          Data->CurU = pCur->u + (x + y * (Data->iEdgedWidth/2)) * 8;
541          Data->CurU = pCur->u + (x + y * (Data->iEdgedWidth/2)) * 8*i;  
542            Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16;
543          Data->RefP[0] = pRef->y + (x + Data->iEdgedWidth*y) * 16*i;          Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16;
544          Data->RefP[2] = pRefH + (x + Data->iEdgedWidth*y) * 16*i;          Data->RefP[1] = pRefV + (x + Data->iEdgedWidth*y) * 16;
545          Data->RefP[1] = pRefV + (x + Data->iEdgedWidth*y) * 16*i;          Data->RefP[3] = pRefHV + (x + Data->iEdgedWidth*y) * 16;
546          Data->RefP[3] = pRefHV + (x + Data->iEdgedWidth*y) * 16*i;          Data->RefP[4] = pRef->u + (x + y * (Data->iEdgedWidth/2)) * 8;
547          Data->RefP[4] = pRef->u + (x + y * (Data->iEdgedWidth/2)) * 8*i;          Data->RefP[5] = pRef->v + (x + y * (Data->iEdgedWidth/2)) * 8;
         Data->RefP[5] = pRef->v + (x + y * (Data->iEdgedWidth/2)) * 8*i;  
548    
549          Data->lambda16 = xvid_me_lambda_vec16[pMB->quant];          Data->lambda16 = xvid_me_lambda_vec16[pMB->quant];
550          Data->lambda8 = xvid_me_lambda_vec8[pMB->quant];          Data->lambda8 = xvid_me_lambda_vec8[pMB->quant];
# Line 635  Line 556 
556          if (Data->qpel) Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, 0);          if (Data->qpel) Data->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, 0);
557          else Data->predMV = pmv[0];          else Data->predMV = pmv[0];
558    
559          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0, 0);          i = d_mv_bits(0, 0, Data->predMV, Data->iFcode, 0);
560          Data->iMinSAD[0] = pMB->sad16 + ((Data->lambda16 * i * pMB->sad16)>>10);          Data->iMinSAD[0] = pMB->sad16 + ((Data->lambda16 * i * pMB->sad16)>>10);
561          Data->iMinSAD[1] = pMB->sad8[0] + ((Data->lambda8 * i * (pMB->sad8[0]+NEIGH_8X8_BIAS)) >> 10);          Data->iMinSAD[1] = pMB->sad8[0] + ((Data->lambda8 * i * (pMB->sad8[0]+NEIGH_8X8_BIAS)) >> 10);
562          Data->iMinSAD[2] = pMB->sad8[1];          Data->iMinSAD[2] = pMB->sad8[1];
# Line 650  Line 571 
571                  threshA = 512;                  threshA = 512;
572    
573          PreparePredictionsP(pmv, x, y, pParam->mb_width, pParam->mb_height,          PreparePredictionsP(pmv, x, y, pParam->mb_width, pParam->mb_height,
574                                          prevMBs + x + y * pParam->mb_width, Data->rrv);                                          prevMBs + x + y * pParam->mb_width);
575    
         if (!Data->rrv) {  
576                  if (inter4v) CheckCandidate = CheckCandidate16;                  if (inter4v) CheckCandidate = CheckCandidate16;
577                          else CheckCandidate = CheckCandidate16no4v; /* for extra speed */                          else CheckCandidate = CheckCandidate16no4v; /* for extra speed */
         } else CheckCandidate = CheckCandidate32;  
578    
579  /* main loop. checking all predictions (but first, which is 0,0 and has been checked in MotionEstimation())*/  /* main loop. checking all predictions (but first, which is 0,0 and has been checked in MotionEstimation())*/
580    
# Line 690  Line 609 
609                          if (Data->qpel) {                          if (Data->qpel) {
610                                  startMV.x /= 2;                                  startMV.x /= 2;
611                                  startMV.y /= 2;                                  startMV.y /= 2;
                         } else if (Data->rrv) {  
                                 startMV.x = RRV_MV_SCALEUP(startMV.x);  
                                 startMV.y = RRV_MV_SCALEUP(startMV.y);  
612                          }                          }
613                          if (!(MVequal(startMV, backupMV))) {                          if (!(MVequal(startMV, backupMV))) {
614                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;
# Line 701  Line 617 
617                                  xvid_me_DiamondSearch(startMV.x, startMV.y, Data, 255, CheckCandidate);                                  xvid_me_DiamondSearch(startMV.x, startMV.y, Data, 255, CheckCandidate);
618                                  if (bSAD < Data->iMinSAD[0]) {                                  if (bSAD < Data->iMinSAD[0]) {
619                                          Data->currentMV[0] = backupMV;                                          Data->currentMV[0] = backupMV;
620                                          Data->iMinSAD[0] = bSAD; }                                          Data->iMinSAD[0] = bSAD;
621                                    }
622                          }                          }
623    
624                          backupMV = Data->currentMV[0];                          backupMV = Data->currentMV[0];
# Line 734  Line 651 
651                  if(MotionFlags & XVID_ME_FASTREFINE16 && MotionFlags & XVID_ME_QUARTERPELREFINE16) {                  if(MotionFlags & XVID_ME_FASTREFINE16 && MotionFlags & XVID_ME_QUARTERPELREFINE16) {
652                          /* fast */                          /* fast */
653                          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,                          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,
654                                                  pParam->width, pParam->height, Data->iFcode, 2, 0);                                                  pParam->width, pParam->height, Data->iFcode, 2);
655                          FullRefine_Fast(Data, CheckCandidate, 0);                          FullRefine_Fast(Data, CheckCandidate, 0);
656                  } else {                  } else {
657                          if(MotionFlags & (XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE16_RD)) {                          if(MotionFlags & (XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE16_RD)) {
# Line 747  Line 664 
664                                          }                                          }
665                                  }                                  }
666                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,                                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 4,
667                                                          pParam->width, pParam->height, Data->iFcode, 2, 0);                                                          pParam->width, pParam->height, Data->iFcode, 2);
668                                  Data->qpel_precision = 1;                                  Data->qpel_precision = 1;
669                                  if(MotionFlags & XVID_ME_QUARTERPELREFINE16)                                  if(MotionFlags & XVID_ME_QUARTERPELREFINE16)
670                                          xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate, 0); /* qpel part */                                          xvid_me_SubpelRefine(Data->currentQMV[0], Data, CheckCandidate, 0); /* qpel part */
# Line 822  Line 739 
739          if (!(VopFlags & XVID_VOP_HALFPEL))          if (!(VopFlags & XVID_VOP_HALFPEL))
740                  Flags &= ~(XVID_ME_EXTSEARCH16+XVID_ME_HALFPELREFINE16+XVID_ME_HALFPELREFINE8+XVID_ME_HALFPELREFINE16_RD+XVID_ME_HALFPELREFINE8_RD);                  Flags &= ~(XVID_ME_EXTSEARCH16+XVID_ME_HALFPELREFINE16+XVID_ME_HALFPELREFINE8+XVID_ME_HALFPELREFINE16_RD+XVID_ME_HALFPELREFINE8_RD);
741    
742          if ((VopFlags & XVID_VOP_GREYSCALE) || (VopFlags & XVID_VOP_REDUCED))          if (VopFlags & XVID_VOP_GREYSCALE)
743                  Flags &= ~(XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP);                  Flags &= ~(XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP);
744    
745          if (Flags & XVID_ME_FASTREFINE8)          if (Flags & XVID_ME_FASTREFINE8)
# Line 848  Line 765 
765          const IMAGE *const pCurrent = &current->image;          const IMAGE *const pCurrent = &current->image;
766          const IMAGE *const pRef = &reference->image;          const IMAGE *const pRef = &reference->image;
767    
768          uint32_t mb_width = pParam->mb_width;          const uint32_t mb_width = pParam->mb_width;
769          uint32_t mb_height = pParam->mb_height;          const uint32_t mb_height = pParam->mb_height;
770          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
771          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);          const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->vop_flags, current->vol_flags);
772          int stat_thresh = 0;          int stat_thresh = 0;
773    
774          uint32_t x, y;          uint32_t x, y;
         uint32_t iIntra = 0;  
775          int32_t sad00;          int32_t sad00;
776          int skip_thresh = INITIAL_SKIP_THRESH * \          int skip_thresh = INITIAL_SKIP_THRESH * \
                 (current->vop_flags & XVID_VOP_REDUCED ? 4:1) * \  
777                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);                  (current->vop_flags & XVID_VOP_MODEDECISION_RD ? 2:1);
778    
779          /* some pre-initialized thingies for SearchP */          /* some pre-initialized thingies for SearchP */
# Line 870  Line 785 
785          Data.rounding = pParam->m_rounding_type;          Data.rounding = pParam->m_rounding_type;
786          Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);          Data.qpel = (current->vol_flags & XVID_VOL_QUARTERPEL ? 1:0);
787          Data.chroma = MotionFlags & XVID_ME_CHROMA_PVOP;          Data.chroma = MotionFlags & XVID_ME_CHROMA_PVOP;
         Data.rrv = (current->vop_flags & XVID_VOP_REDUCED) ? 1:0;  
788          Data.dctSpace = dct_space;          Data.dctSpace = dct_space;
789          Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);          Data.quant_type = !(pParam->vol_flags & XVID_VOL_MPEGQUANT);
790          Data.mpeg_quant_matrices = pParam->mpeg_quant_matrices;          Data.mpeg_quant_matrices = pParam->mpeg_quant_matrices;
791    
         if ((current->vop_flags & XVID_VOP_REDUCED)) {  
                 mb_width = (pParam->width + 31) / 32;  
                 mb_height = (pParam->height + 31) / 32;  
                 Data.qpel = 0;  
         }  
   
792          Data.RefQ = pRefV->u; /* a good place, also used in MC (for similar purpose) */          Data.RefQ = pRefV->u; /* a good place, also used in MC (for similar purpose) */
793          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
794    
# Line 889  Line 797 
797                          MACROBLOCK *pMB = &pMBs[x + y * pParam->mb_width];                          MACROBLOCK *pMB = &pMBs[x + y * pParam->mb_width];
798                          MACROBLOCK *prevMB = &reference->mbs[x + y * pParam->mb_width];                          MACROBLOCK *prevMB = &reference->mbs[x + y * pParam->mb_width];
799    
800                          if (!Data.rrv) pMB->sad16 =                          pMB->sad16 =
801                                  sad16v(pCurrent->y + (x + y * iEdgedWidth) * 16,                                  sad16v(pCurrent->y + (x + y * iEdgedWidth) * 16,
802                                                          pRef->y + (x + y * iEdgedWidth) * 16,                                                          pRef->y + (x + y * iEdgedWidth) * 16,
803                                                          pParam->edged_width, pMB->sad8 );                                                          pParam->edged_width, pMB->sad8 );
804    
                         else pMB->sad16 =  
                                 sad32v_c(pCurrent->y + (x + y * iEdgedWidth) * 32,  
                                                         pRef->y + (x + y * iEdgedWidth) * 32,  
                                                         pParam->edged_width, pMB->sad8 );  
   
805                          sad00 = 4*MAX(MAX(pMB->sad8[0], pMB->sad8[1]), MAX(pMB->sad8[2], pMB->sad8[3]));                          sad00 = 4*MAX(MAX(pMB->sad8[0], pMB->sad8[1]), MAX(pMB->sad8[2], pMB->sad8[3]));
806    
807                          if (Data.chroma) {                          if (Data.chroma) {
# Line 911  Line 814 
814                          }                          }
815    
816                          /* initial skip decision */                          /* initial skip decision */
                         /* no early skip for GMC (global vector = skip vector is unknown!)  */  
817                          if (current->coding_type != S_VOP)      { /* no fast SKIP for S(GMC)-VOPs */                          if (current->coding_type != S_VOP)      { /* no fast SKIP for S(GMC)-VOPs */
818                                  if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh)                                  if (pMB->dquant == 0 && sad00 < pMB->quant * skip_thresh)
819                                          if (Data.chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {                                          if (Data.chroma || xvid_me_SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant)) {
820                                                  ZeroMacroblockP(pMB, sad00);                                                  ZeroMacroblockP(pMB, sad00);
821                                                  pMB->mode = MODE_NOT_CODED;                                                  pMB->mode = MODE_NOT_CODED;
822                                                  continue;                                                  continue;
# Line 966  Line 868 
868                                                                  pCurrent, pRef, pGMC, current->coding_type, sad00);                                                                  pCurrent, pRef, pGMC, current->coding_type, sad00);
869    
870    
                         if (pMB->mode == MODE_INTRA)  
                                 if (++iIntra > iLimit) return 1;  
871                  }                  }
872          }          }
873          return 0;          return 0;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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