[cvs] / xvidcore / src / quant / quant_mpeg.c Repository:
ViewVC logotype

Diff of /xvidcore/src/quant/quant_mpeg.c

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

revision 1.2, Mon Mar 22 22:36:24 2004 UTC revision 1.3, Mon Jul 10 08:09:59 2006 UTC
# Line 43  Line 43 
43   * Local data   * Local data
44   ****************************************************************************/   ****************************************************************************/
45    
 #define VM18P 3  
 #define VM18Q 4  
   
46  /* divide-by-multiply table  /* divide-by-multiply table
47   * needs 17 bit shift (16 causes slight errors when q > 19) */   * needs 17 bit shift (16 causes slight errors when q > 19) */
48    
 #define SCALEBITS 17  
49  #define FIX(X)    ((1UL << SCALEBITS) / (X) + 1)  #define FIX(X)    ((1UL << SCALEBITS) / (X) + 1)
50    
51  static const uint32_t multipliers[32] =  static const uint32_t multipliers[32] =
# Line 69  Line 65 
65   ****************************************************************************/   ****************************************************************************/
66    
67  /* quantize intra-block  /* quantize intra-block
  *  
  * const int32_t quantd = DIV_DIV(VM18P*quant, VM18Q);  
  * level = DIV_DIV(16 * data[i], default_intra_matrix[i]);  
  * coeff[i] = (level + quantd) / quant2;  
68   */   */
69    
70  uint32_t  uint32_t
# Line 82  Line 74 
74                                     const uint32_t dcscalar,                                     const uint32_t dcscalar,
75                                     const uint16_t * mpeg_quant_matrices)                                     const uint16_t * mpeg_quant_matrices)
76  {  {
77          const uint32_t quantd = ((VM18P * quant) + (VM18Q / 2)) / VM18Q;          const uint16_t * intra_matrix_rec = mpeg_quant_matrices + 1*64;
         const uint32_t mult = multipliers[quant];  
         const uint16_t *intra_matrix = get_intra_matrix(mpeg_quant_matrices);  
78          int i;          int i;
79            int rounding = 1<<(SCALEBITS-1-3);
80    
81          coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar);          coeff[0] = DIV_DIV(data[0], (int32_t) dcscalar);
82    
83          for (i = 1; i < 64; i++) {          for (i = 1; i < 64; i++) {
84                  if (data[i] < 0) {                  int level = data[i];
85                          uint32_t level = -data[i];                  level *= intra_matrix_rec[i];
86                    level = (level + rounding)>>(SCALEBITS-3);
                         level = ((level << 4) + (intra_matrix[i] >> 1)) / intra_matrix[i];  
                         level = ((level + quantd) * mult) >> SCALEBITS;  
                         coeff[i] = -(int16_t) level;  
                 } else if (data[i] > 0) {  
                         uint32_t level = data[i];  
   
                         level = ((level << 4) + (intra_matrix[i] >> 1)) / intra_matrix[i];  
                         level = ((level + quantd) * mult) >> SCALEBITS;  
87                          coeff[i] = level;                          coeff[i] = level;
                 } else {  
                         coeff[i] = 0;  
                 }  
88          }          }
89    
90          return(0);          return(0);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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