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

Diff of /branches/dev-api-3/xvidcore/src/motion/motion_est.c

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

revision 748, Sun Dec 29 11:22:20 2002 UTC revision 754, Wed Jan 1 13:04:06 2003 UTC
# Line 84  Line 84 
84  {  {
85          int sad;          int sad;
86          const uint32_t stride = data->iEdgedWidth/2;          const uint32_t stride = data->iEdgedWidth/2;
         dx = (dx >> 1) + roundtab_79[dx & 0x3];  
         dy = (dy >> 1) + roundtab_79[dy & 0x3];  
87    
88          if (dx == data->temp[5] && dy == data->temp[6]) return data->temp[7]; //it has been checked recently          if (dx == data->temp[5] && dy == data->temp[6]) return data->temp[7]; //it has been checked recently
89          data->temp[5]  = dx; data->temp[6] = dy; // backup          data->temp[5]  = dx; data->temp[6] = dy; // backup
# Line 264  Line 262 
262          data->temp[0] += (data->lambda16 * t * data->temp[0])/1000;          data->temp[0] += (data->lambda16 * t * data->temp[0])/1000;
263          data->temp[1] += (data->lambda8 * t * (data->temp[1] + NEIGH_8X8_BIAS))/100;          data->temp[1] += (data->lambda8 * t * (data->temp[1] + NEIGH_8X8_BIAS))/100;
264    
265          if (data->chroma) data->temp[0] += ChromaSAD(xc, yc, data);          if (data->chroma) data->temp[0] += ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3],
266                                                                                                            (yc >> 1) + roundtab_79[yc & 0x3], data);
267    
268          if (data->temp[0] < data->iMinSAD[0]) {          if (data->temp[0] < data->iMinSAD[0]) {
269                  data->iMinSAD[0] = data->temp[0];                  data->iMinSAD[0] = data->temp[0];
# Line 754  Line 753 
753          uint32_t x, y;          uint32_t x, y;
754          uint32_t iIntra = 0;          uint32_t iIntra = 0;
755          int32_t InterBias, quant = current->quant, sad00;          int32_t InterBias, quant = current->quant, sad00;
         uint8_t *qimage;  
756    
757          // some pre-initialized thingies for SearchP          // some pre-initialized thingies for SearchP
758          int32_t temp[8];          int32_t temp[8];
# Line 780  Line 778 
778                  Data.qpel = Data.chroma = 0;                  Data.qpel = Data.chroma = 0;
779          }          }
780    
781          if((qimage = (uint8_t *) malloc(32 * pParam->edged_width)) == NULL)          Data.RefQ = pRefV->u; // a good place, also used in MC (for similar purpose)
                 return 1; // allocate some mem for qpel interpolated blocks  
                                   // somehow this is dirty since I think we shouldn't use malloc outside  
                                   // encoder_create() - so please fix me!  
         Data.RefQ = qimage;  
782          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
783    
784          for (y = 0; y < mb_height; y++) {          for (y = 0; y < mb_height; y++) {
# Line 876  Line 870 
870                                                    pParam->edged_width);                                                    pParam->edged_width);
871    
872                                          if (deviation < (pMB->sad16 - InterBias)) {                                          if (deviation < (pMB->sad16 - InterBias)) {
873                                          if (++iIntra >= iLimit) { free(qimage); return 1; }                                          if (++iIntra >= iLimit) return 1;
874                                          pMB->mode = MODE_INTRA;                                          pMB->mode = MODE_INTRA;
875                                          pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] =                                          pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] =
876                                                          pMB->mvs[3] = zeroMV;                                                          pMB->mvs[3] = zeroMV;
# Line 888  Line 882 
882                          }                          }
883                  }                  }
884          }          }
         free(qimage);  
885    
886          if (current->coding_type == S_VOP)      /* first GMC step only for S(GMC)-VOPs */          if (current->coding_type == S_VOP)      /* first GMC step only for S(GMC)-VOPs */
887                  current->GMC_MV = GlobalMotionEst( pMBs, pParam, current->fcode );                  current->GMC_MV = GlobalMotionEst( pMBs, pParam, current->fcode );
# Line 1124  Line 1117 
1117                  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);
1118    
1119                  if (Data->chroma) {                  if (Data->chroma) {
1120                          int sumx, sumy, dx, dy;                          int sumx, sumy;
1121    
1122                          if(pParam->m_quarterpel) {                          if(pParam->m_quarterpel) {
1123                                  sumx= pMB->qmvs[0].x/2 + pMB->qmvs[1].x/2 + pMB->qmvs[2].x/2 + pMB->qmvs[3].x/2;                                  sumx= pMB->qmvs[0].x/2 + pMB->qmvs[1].x/2 + pMB->qmvs[2].x/2 + pMB->qmvs[3].x/2;
# Line 1133  Line 1126 
1126                                  sumx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;                                  sumx = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x;
1127                                  sumy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;                                  sumy = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y;
1128                          }                          }
                         dx = (sumx >> 3) + roundtab_76[sumx & 0xf];  
                         dy = (sumy >> 3) + roundtab_76[sumy & 0xf];  
1129    
1130                          Data->iMinSAD[1] += ChromaSAD(dx, dy, Data);                          Data->iMinSAD[1] += ChromaSAD(  (sumx >> 3) + roundtab_76[sumx & 0xf],
1131                                                                                            (sumy >> 3) + roundtab_76[sumy & 0xf], Data);
1132                  }                  }
1133          }          }
1134    
# Line 1762  Line 1754 
1754    
1755          const int32_t TRB = time_pp - time_bp;          const int32_t TRB = time_pp - time_bp;
1756          const int32_t TRD = time_pp;          const int32_t TRD = time_pp;
         uint8_t * qimage;  
1757    
1758  // some pre-inintialized data for the rest of the search  // some pre-inintialized data for the rest of the search
1759    
# Line 1779  Line 1770 
1770          Data.qpel = pParam->m_quarterpel;          Data.qpel = pParam->m_quarterpel;
1771          Data.rounding = 0;          Data.rounding = 0;
1772    
1773          if((qimage = (uint8_t *) malloc(32 * pParam->edged_width)) == NULL)          Data.RefQ = f_refV->u; // a good place, also used in MC (for similar purpose)
                 return; // allocate some mem for qpel interpolated blocks  
                                   // somehow this is dirty since I think we shouldn't use malloc outside  
                                   // encoder_create() - so please fix me!  
         Data.RefQ = qimage;  
   
1774          // note: i==horizontal, j==vertical          // note: i==horizontal, j==vertical
1775          for (j = 0; j < pParam->mb_height; j++) {          for (j = 0; j < pParam->mb_height; j++) {
1776    
# Line 1881  Line 1867 
1867                          }                          }
1868                  }                  }
1869          }          }
         free(qimage);  
1870  }  }
1871    
1872  static __inline void  static __inline void

Legend:
Removed from v.748  
changed lines
  Added in v.754

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