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

Diff of /branches/dev-api-3/xvidcore/src/quant/adapt_quant.c

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

revision 356, Sat Aug 3 05:36:18 2002 UTC revision 357, Sun Aug 4 17:28:50 2002 UTC
# Line 68  Line 68 
68          static float *quant;          static float *quant;
69          unsigned char *ptr;          unsigned char *ptr;
70          float *val;          float *val;
71          float global = 0., maxval = 0.;          float global = 0.;
72            uint32_t mid_range = 0;
73    
74          const float DarkThres = 0.25;          const float DarkAmpl = 14 / 2;
75          const float DarkAmpl = 7.0;          const float BrightAmpl = 10 / 2;
76            const float DarkThres = 70;
77            const float BrightThres = 200;
78    
79            const float GlobalDarkThres = 60;
80            const float GlobalBrightThres = 170;
81    
82            const float MidRangeThres = 20;
83            const float UpperLimit = 200;
84            const float LowerLimit = 25;
85    
         const float BrightThres = 4.0;  
         const float BrightAmpl = 5.0;  
   
         const char LowestVal = 10;  
   
         const float GlobalBrightThres = 220.0;  
         const float GlobalDarkThres = 20.0;  
         float global_quant = 1.0;  
86    
87          if (!quant)          if (!quant)
88                  if (!(quant = (float *) malloc(mb_width * mb_height * sizeof(float))))                  if (!(quant = (float *) malloc(mb_width * mb_height * sizeof(float))))
# Line 100  Line 102 
102    
103                          for (i = 0; i < 16; i++)                          for (i = 0; i < 16; i++)
104                                  for (j = 0; j < 16; j++)                                  for (j = 0; j < 16; j++)
                                 {  
                                         if( ptr[i * stride + j] < LowestVal )  
                                                 ptr[i * stride + j] = 0;  
105                                          val[k * mb_width + l] += ptr[i * stride + j];                                          val[k * mb_width + l] += ptr[i * stride + j];
                                 }  
106                          val[k * mb_width + l] /= 256.;                          val[k * mb_width + l] /= 256.;
107                          global += val[k * mb_width + l];                          global += val[k * mb_width + l];
108                          if( val[k * mb_width + l] > maxval )  
109                                  maxval = val[k * mb_width + l];                          if ((val[k * mb_width + l] > LowerLimit) &&
110                                    (val[k * mb_width + l] < UpperLimit))
111                                    mid_range++;
112                  }                  }
113          }          }
114    
115          global /= mb_width * mb_height;          global /= mb_width * mb_height;
         maxval /= global;  
         if( global < GlobalDarkThres )  
                 global_quant *= -1.0;  
         else if ( global < GlobalBrightThres )  
                 global_quant = 0.0;  
116    
117            if (((global <GlobalBrightThres) &&(global >GlobalDarkThres))
118                    || (mid_range < MidRangeThres)) {
119          for (k = 0; k < mb_height; k++) {          for (k = 0; k < mb_height; k++) {
120                  for (l = 0; l < mb_width; l++)  // do this for all macroblocks individually                  for (l = 0; l < mb_width; l++)  // do this for all macroblocks individually
121                  {                  {
                         val[k * mb_width + l] /= global;  
122                          if (val[k * mb_width + l] < DarkThres)                          if (val[k * mb_width + l] < DarkThres)
123                                  quant[k * mb_width + l] += global_quant +                                          quant[k * mb_width + l] +=
124                                          DarkAmpl * (DarkThres - val[k * mb_width + l]) / DarkThres;                                                  DarkAmpl * (DarkThres -
125                                                                            val[k * mb_width + l]) / DarkThres;
126                          else if (val[k * mb_width + l] > BrightThres)                          else if (val[k * mb_width + l] > BrightThres)
127                                  quant[k * mb_width + l] += global_quant +                                          quant[k * mb_width + l] +=
128                                          BrightAmpl * (val[k * mb_width + l] - BrightThres) / (maxval - BrightThres);                                                  BrightAmpl * (val[k * mb_width + l] -
129                                                                              BrightThres) / (255 - BrightThres);
130                            }
131                  }                  }
132          }          }
133          free(val);          free(val);

Legend:
Removed from v.356  
changed lines
  Added in v.357

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