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

Diff of /branches/dev-api-4/xvidcore/src/motion/motion_est.h

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

revision 1022, Wed May 14 18:46:39 2003 UTC revision 1023, Wed May 14 20:23:02 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.3.2.6 2003-05-14 18:46:39 edgomez Exp $   *  $Id: motion_est.h,v 1.3.2.7 2003-05-14 20:23:02 edgomez 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 301  Line 303 
303    
304  int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);  int CodeCoeffIntra_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);
305  int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);  int CodeCoeffInter_CalcBits(const int16_t qcoeff[64], const uint16_t * zigzag);
306  /*  
307  static int  #define LAMBDA          ( (int)(1.0*BITS_MULT) )
308  CountDistortionSkip(const SearchData * const Data);  
 */  
309  static __inline unsigned int  static __inline unsigned int
310  Block_CalcBits(uint16_t * const coeff,  Block_CalcBits( int16_t * const coeff,
311                                          uint16_t * const data,                                  int16_t * const data,
312                                          const uint32_t quant, const int quant_type,                                          const uint32_t quant, const int quant_type,
313                                          uint32_t * cbp,                                          uint32_t * cbp,
314                                          const int block,                                  const int block)
                                         const int RD)  
315  {  {
316          int sum;          int sum;
317            int bits;
318            const int lambda = LAMBDA*quant*quant;
319            int distortion = 0;
320            int i;
321    
322          fdct(data);          fdct(data);
323    
# Line 322  Line 326 
326    
327          if (sum > 0) {          if (sum > 0) {
328                  *cbp |= 1 << (5 - block);                  *cbp |= 1 << (5 - block);
329                  return CodeCoeffInter_CalcBits(coeff, scan_tables[0]);                  bits = BITS_MULT * CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
330          } else return 0;          } else bits = 0;
331    
332            if (quant_type == 0) dequant_inter(coeff, coeff, quant);
333            else dequant4_inter(coeff, coeff, quant);
334    
335            for (i = 0; i < 64; i++) {
336                    distortion += (data[i] - coeff[i])*(data[i] - coeff[i]);
337            }
338            bits += (BITS_MULT*BITS_MULT*distortion)/lambda;
339    
340    
341            return bits;
342    }
343    
344    static __inline unsigned int
345    Block_CalcBitsIntra(int16_t * const coeff,
346                                            int16_t * const data,
347                                            const uint32_t quant, const int quant_type,
348                                            uint32_t * cbp,
349                                            const int block,
350                                            int * dcpred)
351    {
352            int bits, i;
353            const int lambda = LAMBDA*quant*quant;
354            int distortion = 0;
355            uint32_t iDcScaler = get_dc_scaler(quant, block > 3);
356            int b_dc;
357    
358            fdct(data);
359            data[0] -= 1024;
360    
361            if (quant_type == 0) quant_intra(coeff, data, quant, iDcScaler);
362            else quant4_intra(coeff, data, quant, iDcScaler);
363    
364            b_dc = coeff[0];
365            if (block < 4) {
366                    coeff[0] -= *dcpred;
367                    *dcpred = b_dc;
368            }
369    
370            *cbp |= 1 << (5 - block);
371            bits = BITS_MULT*CodeCoeffIntra_CalcBits(coeff, scan_tables[0]);
372            bits += BITS_MULT*dcy_tab[coeff[0] + 255].len;
373            if (bits != 0) *cbp |= 1 << (5 - block);
374    
375            coeff[0] = b_dc;
376            if (quant_type == 0) dequant_intra(coeff, coeff, quant, iDcScaler);
377            else dequant4_intra(coeff, coeff, quant, iDcScaler);
378    
379            for (i = 0; i < 64; i++) {
380                    distortion += (data[i] - coeff[i])*(data[i] - coeff[i]);
381            }
382    
383            bits += (BITS_MULT*BITS_MULT*distortion)/lambda;
384    
385            return bits;
386  }  }
387    
388  #endif                                                  /* _MOTION_EST_H_ */  #endif                                                  /* _MOTION_EST_H_ */

Legend:
Removed from v.1022  
changed lines
  Added in v.1023

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