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

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

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

revision 1230, Sun Nov 30 16:13:16 2003 UTC revision 1279, Thu Dec 18 17:49:28 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_pvop.c,v 1.1.2.9 2003-11-30 16:13:16 edgomez Exp $   * $Id: estimation_pvop.c,v 1.1.2.12 2003-12-18 17:49:28 Isibaar Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 173  Line 173 
173  }  }
174    
175  static void  static void
176    CheckCandidate8_qpel(const int x, const int y, SearchData * const data, const unsigned int Direction)
177    {
178            int32_t sad; uint32_t t;
179            const uint8_t * Reference;
180            VECTOR * current;
181    
182            if ( (x > data->max_dx) || (x < data->min_dx)
183                    || (y > data->max_dy) || (y < data->min_dy) ) return;
184    
185            /* x and y are in 1/4 precision */
186            Reference = xvid_me_interpolate8x8qpel(x, y, 0, 0, data);
187            current = data->currentQMV;
188    
189            sad = sad8(data->Cur, Reference, data->iEdgedWidth);
190            t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);
191    
192            sad += (data->lambda8 * t * (sad+NEIGH_8X8_BIAS))>>10;
193    
194            if (sad < *(data->iMinSAD)) {
195                    data->iMinSAD2 = *(data->iMinSAD);
196                    data->currentQMV2.x = data->currentQMV->x;
197                    data->currentQMV2.y = data->currentQMV->y;
198    
199                    *(data->iMinSAD) = sad;
200                    data->currentQMV->x = x; data->currentQMV->y = y;
201                    data->dir = Direction;
202            } else if (sad < data->iMinSAD2) {
203                    data->iMinSAD2 = sad;
204                    data->currentQMV2.x = x; data->currentQMV2.y = y;
205            }
206    }
207    
208    static void
209  CheckCandidate32(const int x, const int y, SearchData * const data, const unsigned int Direction)  CheckCandidate32(const int x, const int y, SearchData * const data, const unsigned int Direction)
210  {  {
211          uint32_t t;          uint32_t t;
# Line 207  Line 240 
240                  data->iMinSAD[4] = data->temp[3]; data->currentMV[4].x = x; data->currentMV[4].y = y; }                  data->iMinSAD[4] = data->temp[3]; data->currentMV[4].x = x; data->currentMV[4].y = y; }
241  }  }
242    
 static void  
 SubpelRefine_Fast(SearchData * data, CheckFunc * CheckCandidate)  
 {  
 /* Do a fast q-pel refinement */  
         VECTOR centerMV;  
         VECTOR second_best;  
         int best_sad = *data->iMinSAD;  
         int xo, yo, xo2, yo2;  
         int size = 2;  
         data->iMinSAD2 = 0;  
   
         /* check all halfpixel positions near our best halfpel position */  
         centerMV = *data->currentQMV;  
         *data->iMinSAD = 256 * 4096;  
   
         CHECK_CANDIDATE(centerMV.x, centerMV.y - size, 0);  
         CHECK_CANDIDATE(centerMV.x + size, centerMV.y - size, 0);  
         CHECK_CANDIDATE(centerMV.x + size, centerMV.y, 0);  
         CHECK_CANDIDATE(centerMV.x + size, centerMV.y + size, 0);  
   
         CHECK_CANDIDATE(centerMV.x, centerMV.y + size, 0);  
         CHECK_CANDIDATE(centerMV.x - size, centerMV.y + size, 0);  
         CHECK_CANDIDATE(centerMV.x - size, centerMV.y, 0);  
         CHECK_CANDIDATE(centerMV.x - size, centerMV.y - size, 0);  
   
         second_best = *data->currentQMV;  
   
         /* after second_best has been found, go back to the vector we began with */  
   
         data->currentQMV[0] = centerMV;  
         *data->iMinSAD = best_sad;  
   
         xo = centerMV.x;  
         yo = centerMV.y;  
         xo2 = second_best.x;  
         yo2 = second_best.y;  
   
         data->iMinSAD2 = 256 * 4096;  
   
         if (yo == yo2) {  
                 CHECK_CANDIDATE((xo+xo2)>>1, yo, 0);  
                 CHECK_CANDIDATE(xo, yo-1, 0);  
                 CHECK_CANDIDATE(xo, yo+1, 0);  
   
                 if(best_sad <= data->iMinSAD2) return;  
   
                 if(data->currentQMV[0].x == data->currentQMV2.x) {  
                         CHECK_CANDIDATE((xo+xo2)>>1, yo-1, 0);  
                         CHECK_CANDIDATE((xo+xo2)>>1, yo+1, 0);  
                 } else {  
                         CHECK_CANDIDATE((xo+xo2)>>1,  
                                 (data->currentQMV[0].x == xo) ? data->currentQMV[0].y : data->currentQMV2.y, 0);  
                 }  
                 return;  
         }  
   
         if (xo == xo2) {  
                 CHECK_CANDIDATE(xo, (yo+yo2)>>1, 0);  
                 CHECK_CANDIDATE(xo-1, yo, 0);  
                 CHECK_CANDIDATE(xo+1, yo, 0);  
   
                 if(best_sad < data->iMinSAD2) return;  
   
                 if(data->currentQMV[0].y == data->currentQMV2.y) {  
                         CHECK_CANDIDATE(xo-1, (yo+yo2)>>1, 0);  
                         CHECK_CANDIDATE(xo+1, (yo+yo2)>>1, 0);  
                 } else {  
                         CHECK_CANDIDATE((data->currentQMV[0].y == yo) ? data->currentQMV[0].x : data->currentQMV2.x, (yo+yo2)>>1, 0);  
                 }  
                 return;  
         }  
   
         CHECK_CANDIDATE(xo, (yo+yo2)>>1, 0);  
         CHECK_CANDIDATE((xo+xo2)>>1, yo, 0);  
   
         if(best_sad <= data->iMinSAD2) return;  
   
         CHECK_CANDIDATE((xo+xo2)>>1, (yo+yo2)>>1, 0);  
 }  
   
243  int  int
244  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,  xvid_me_SkipDecisionP(const IMAGE * current, const IMAGE * reference,
245                                                          const int x, const int y,                                                          const int x, const int y,
# Line 479  Line 432 
432    
433          /* intra decision */          /* intra decision */
434    
435          if (iQuant > 8) InterBias += 100 * (iQuant - 8); /* to make high quants work */          if (iQuant > 10) InterBias += 60 * (iQuant - 10); /* to make high quants work */
436          if (y != 0)          if (y != 0)
437                  if ((pMB - pParam->mb_width)->mode == MODE_INTRA ) InterBias -= 80;                  if ((pMB - pParam->mb_width)->mode == MODE_INTRA ) InterBias -= 80;
438          if (x != 0)          if (x != 0)
# Line 653  Line 606 
606                          }                          }
607                  }                  }
608    
609                  if (Data->qpel && MotionFlags & XVID_ME_QUARTERPELREFINE8) {                  if ((Data->qpel && MotionFlags & XVID_ME_QUARTERPELREFINE8)) {
610                                  Data->qpel_precision = 1;                                  Data->qpel_precision = 1;
611                                  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,
612                                          pParam->width, pParam->height, Data->iFcode, 2, 0);                                          pParam->width, pParam->height, Data->iFcode, 2, 0);
613    
614                                    if((MotionFlags & XVID_ME_FASTREFINE16) && (!Data->rrv))
615                                            SubpelRefine_Fast(Data, CheckCandidate8_qpel);
616                                    else
617                                  xvid_me_SubpelRefine(Data, CheckCandidate);                                  xvid_me_SubpelRefine(Data, CheckCandidate);
618                  }                  }
619          }          }
# Line 798  Line 755 
755                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;
756    
757                                  CheckCandidate(startMV.x, startMV.y, Data, 255);                                  CheckCandidate(startMV.x, startMV.y, Data, 255);
758                                  MainSearchPtr(startMV.x, startMV.y, Data, 255, CheckCandidate);                                  xvid_me_DiamondSearch(startMV.x, startMV.y, Data, 255, CheckCandidate);
759                                  if (bSAD < Data->iMinSAD[0]) {                                  if (bSAD < Data->iMinSAD[0]) {
760                                          Data->currentMV[0] = backupMV;                                          Data->currentMV[0] = backupMV;
761                                          Data->iMinSAD[0] = bSAD; }                                          Data->iMinSAD[0] = bSAD; }
# Line 810  Line 767 
767                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;
768    
769                                  CheckCandidate(startMV.x, startMV.y, Data, 255);                                  CheckCandidate(startMV.x, startMV.y, Data, 255);
770                                  MainSearchPtr(startMV.x, startMV.y, Data, 255, CheckCandidate);                                  xvid_me_DiamondSearch(startMV.x, startMV.y, Data, 255, CheckCandidate);
771                                  if (bSAD < Data->iMinSAD[0]) {                                  if (bSAD < Data->iMinSAD[0]) {
772                                          Data->currentMV[0] = backupMV;                                          Data->currentMV[0] = backupMV;
773                                          Data->iMinSAD[0] = bSAD;                                          Data->iMinSAD[0] = bSAD;
# Line 839  Line 796 
796                  }                  }
797          }          }
798    
799          if (Data->iMinSAD[0] < (int32_t)pMB->quant * 30)          if (Data->iMinSAD[0] < (int32_t)pMB->quant * 30*((MotionFlags & XVID_ME_FASTREFINE16) ? 8 : 1))
800                  inter4v = 0;                  inter4v = 0;
801    
802          if (inter4v) {          if (inter4v) {

Legend:
Removed from v.1230  
changed lines
  Added in v.1279

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