[svn] / trunk / xvidcore / src / motion / motion_est.h Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/motion/motion_est.h

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

revision 1020, Wed May 14 12:10:11 2003 UTC revision 1021, Wed May 14 13:21:47 2003 UTC
# Line 26  Line 26 
26   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
27   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28   *   *
29   *  $Id: motion_est.h,v 1.7 2003-05-13 12:48:20 syskin Exp $   *  $Id: motion_est.h,v 1.8 2003-05-14 13:21:47 syskin Exp $
30   *   *
31   ***************************************************************************/   ***************************************************************************/
32    
# Line 50  Line 50 
50  #define NEIGH_TEND_8X8          40.0  #define NEIGH_TEND_8X8          40.0
51  #define NEIGH_8X8_BIAS          30  #define NEIGH_8X8_BIAS          30
52    
53    #define BITS_MULT                       16
54    
55  /* Parameters which control inter/inter4v decision */  /* Parameters which control inter/inter4v decision */
56  #define IMV16X16                        2  #define IMV16X16                        2
57    
# Line 135  Line 137 
137          VECTOR directmvF[4];          VECTOR directmvF[4];
138          VECTOR directmvB[4];          VECTOR directmvB[4];
139          const VECTOR * referencemv;          const VECTOR * referencemv;
140  // _BITS stuff  // BITS/R-D stuff
141          int16_t * dctSpace;          int16_t * dctSpace;
142          uint32_t iQuant;          uint32_t iQuant;
143          uint32_t quant_type;          uint32_t quant_type;
# Line 263  Line 265 
265          if (Flags & QUARTERPELREFINE8_BITS)          if (Flags & QUARTERPELREFINE8_BITS)
266                  Flags &= ~PMV_QUARTERPELREFINE8;                  Flags &= ~PMV_QUARTERPELREFINE8;
267    
268            if (Flags & QUARTERPELREFINE16_BITS)
269                    Flags &= ~PMV_QUARTERPELREFINE16;
270    
271          if (!(GlobalFlags & XVID_QUARTERPEL))          if (!(GlobalFlags & XVID_QUARTERPEL))
272                  Flags &= ~(PMV_QUARTERPELREFINE16+PMV_QUARTERPELREFINE8+QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS);                  Flags &= ~(PMV_QUARTERPELREFINE16+PMV_QUARTERPELREFINE8+QUARTERPELREFINE16_BITS+QUARTERPELREFINE8_BITS);
273    
# Line 301  Line 306 
306    
307  int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);  int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);
308  int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);  int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);
309  /*  
310  static int  #define LAMBDA          ( (int)(1.0*BITS_MULT) )
311  CountDistortionSkip(const SearchData * const Data);  
 */  
312  static __inline unsigned int  static __inline unsigned int
313  Block_CalcBits(uint16_t * const coeff,  Block_CalcBits( int16_t * const coeff,
314                                          uint16_t * const data,                                  int16_t * const data,
315                                          const uint32_t quant, const int quant_type,                                          const uint32_t quant, const int quant_type,
316                                          uint32_t * cbp,                                          uint32_t * cbp,
317                                          const int block,                                  const int block)
                                         const int RD)  
318  {  {
319          int sum;          int sum;
320            int bits;
321            const int lambda = LAMBDA*quant*quant;
322            int distortion = 0;
323            int i;
324    
325          fdct(data);          fdct(data);
326    
# Line 322  Line 329 
329    
330          if (sum > 0) {          if (sum > 0) {
331                  *cbp |= 1 << (5 - block);                  *cbp |= 1 << (5 - block);
332                  return CodeCoeffInter_CalcBits(coeff, scan_tables[0]);                  bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
333          } else return 0;          } else bits = 0;
334    
335            if (quant_type == 0) dequant_inter(coeff, coeff, quant);
336            else dequant4_inter(coeff, coeff, quant);
337    
338            for (i = 0; i < 64; i++) {
339                    distortion += (data[i] - coeff[i])*(data[i] - coeff[i]);
340            }
341            bits += (BITS_MULT*BITS_MULT*distortion)/lambda;
342    
343    
344            return bits;
345  }  }
346    
 /* RD experiment. ignore.  
347  static __inline unsigned int  static __inline unsigned int
348  Block_CalcBits( int16_t * const coeff,  Block_CalcBitsIntra(int16_t * const coeff,
349                                  int16_t * const data,                                  int16_t * const data,
350                                  const uint32_t quant, const int quant_type,                                  const uint32_t quant, const int quant_type,
351                                  uint32_t * cbp,                                  uint32_t * cbp,
352                                  const int block,                                  const int block,
353                                  const int RD)                                          int * dcpred)
354  {  {
355          int sum;          int bits, i;
356          int bits;          const int lambda = LAMBDA*quant*quant;
         const int lambda = quant*quant/2;  
357          int distortion = 0;          int distortion = 0;
358            uint32_t iDcScaler = get_dc_scaler(quant, block > 3);
359            int b_dc;
360    
361          fdct(data);          fdct(data);
362            data[0] -= 1024;
363    
364          if (quant_type == 0) sum = quant_inter(coeff, data, quant);          if (quant_type == 0) quant_intra(coeff, data, quant, iDcScaler);
365          else sum = quant4_inter(coeff, data, quant);          else quant4_intra(coeff, data, quant, iDcScaler);
366    
367          if (sum > 0) {          b_dc = coeff[0];
368                  *cbp |= 1 << (5 - block);          if (block < 4) {
369                  bits = CodeCoeffInter_CalcBits(coeff, scan_tables[0]);                  coeff[0] -= *dcpred;
370          } else bits = 0;                  *dcpred = b_dc;
371            }
372    
373          if (RD) {          *cbp |= 1 << (5 - block);
374                  int i;          bits = BITS_MULT*CodeCoeffIntra_CalcBits(coeff, scan_tables[0]);
375                  if (quant_type == 0) dequant_inter_c(coeff, coeff, quant);          bits += BITS_MULT*dcy_tab[coeff[0] + 255].len;
376                  else dequant4_inter_c(coeff, coeff, quant);          if (bits != 0) *cbp |= 1 << (5 - block);
377    
378            coeff[0] = b_dc;
379            if (quant_type == 0) dequant_intra(coeff, coeff, quant, iDcScaler);
380            else dequant4_intra(coeff, coeff, quant, iDcScaler);
381    
382                  for (i = 0; i < 64; i++) {                  for (i = 0; i < 64; i++) {
383                          distortion += (data[i] - coeff[i])*(data[i] - coeff[i]);                          distortion += (data[i] - coeff[i])*(data[i] - coeff[i]);
384                  }                  }
         }  
385    
386          bits += distortion/lambda;          bits += (BITS_MULT*BITS_MULT*distortion)/lambda;
387    
388          return bits;          return bits;
389  }  }
 */  
390    
391  #endif                                                  /* _MOTION_EST_H_ */  #endif                                                  /* _MOTION_EST_H_ */

Legend:
Removed from v.1020  
changed lines
  Added in v.1021

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