[svn] / trunk / xvidcore / src / plugins / plugin_ssim.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/plugins/plugin_ssim.c

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

revision 1811, Thu Nov 27 19:45:28 2008 UTC revision 1812, Thu Nov 27 20:17:39 2008 UTC
# Line 39  Line 39 
39    
40  /*dev 1.0 gaussian weighting. the weight for the pixel x,y is w(x)*w(y)*/  /*dev 1.0 gaussian weighting. the weight for the pixel x,y is w(x)*w(y)*/
41  static float mask8[8] = {  static float mask8[8] = {
42          0.0069815, 0.1402264, 1.0361408, 2.8165226,          0.0069815f, 0.1402264f, 1.0361408f, 2.8165226f,
43          2.8165226, 1.0361408, 0.1402264, 0.0069815          2.8165226f, 1.0361408f, 0.1402264f, 0.0069815f
44  };  };
45    
46  /* integer version. Norm: coeffs sums up to 4096.  /* integer version. Norm: coeffs sums up to 4096.
# Line 248  Line 248 
248                  sum *=mask8[i];                  sum *=mask8[i];
249                  mean += sum;                  mean += sum;
250          }          }
251          return (int) mean + 0.5;          return (int) (mean + 0.5);
252  }  }
253    
254  int lum_8x8_gaussian_int(uint8_t* ptr, int stride){  int lum_8x8_gaussian_int(uint8_t* ptr, int stride){
# Line 304  Line 304 
304          ptrc += str;          ptrc += str;
305          }          }
306    
307          *pdevo = (int) (devo - ((lumo*lumo + 32) >> 6)) + 0.5;          *pdevo = (int) ((devo - ((lumo*lumo + 32) >> 6)) + 0.5);
308          *pdevc = (int) (devc - ((lumc*lumc + 32) >> 6)) + 0.5;          *pdevc = (int) ((devc - ((lumc*lumc + 32) >> 6)) + 0.5);
309          *pcorr = (int) (corr - ((lumo*lumc + 32) >> 6)) + 0.5;          *pcorr = (int) ((corr - ((lumo*lumc + 32) >> 6)) + 0.5);
310  };  };
311    
312  void consim_gaussian_int(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr)  void consim_gaussian_int(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr)
# Line 338  Line 338 
338          devo = GACCUM(devo);          devo = GACCUM(devo);
339          devc = GACCUM(devc);          devc = GACCUM(devc);
340          corr = GACCUM(corr);          corr = GACCUM(corr);
341          *pdevo = (int) (devo - ((lumo*lumo + 32) >> 6)) + 0.5;          *pdevo = (int) ((devo - ((lumo*lumo + 32) >> 6)) + 0.5);
342          *pdevc = (int) (devc - ((lumc*lumc + 32) >> 6)) + 0.5;          *pdevc = (int) ((devc - ((lumc*lumc + 32) >> 6)) + 0.5);
343          *pcorr = (int) (corr - ((lumo*lumc + 32) >> 6)) + 0.5;          *pcorr = (int) ((corr - ((lumo*lumc + 32) >> 6)) + 0.5);
344  };  };
345    
346  /*calculate contrast and correlation of the two blocks*/  /*calculate contrast and correlation of the two blocks*/
# Line 368  Line 368 
368    
369  /*calculate the final ssim value*/  /*calculate the final ssim value*/
370  static float calc_ssim(float meano, float meanc, float devo, float devc, float corr){  static float calc_ssim(float meano, float meanc, float devo, float devc, float corr){
371          static const float c1 = (0.01*255)*(0.01*255);          static const float c1 = (0.01f*255)*(0.01f*255);
372          static const float c2 = (0.03*255)*(0.03*255);          static const float c2 = (0.03f*255)*(0.03f*255);
373          /*printf("meano: %f meanc: %f devo: %f devc: %f corr: %f\n",meano,meanc,devo,devc,corr);*/          /*printf("meano: %f meanc: %f devo: %f devc: %f corr: %f\n",meano,meanc,devo,devc,corr);*/
374          return ((2.0*meano*meanc + c1)*(corr/32.0 + c2))/((meano*meano + meanc*meanc + c1)*(devc/64.0 + devo/64.0 + c2));          return ((2.0f*meano*meanc + c1)*(corr/32.0f + c2))/((meano*meano + meanc*meanc + c1)*(devc/64.0f + devo/64.0f + c2));
375  }  }
376    
377  static void ssim_after(xvid_plg_data_t* data, ssim_data_t* ssim){  static void ssim_after(xvid_plg_data_t* data, ssim_data_t* ssim){
# Line 480  Line 480 
480    
481  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)  #if defined(ARCH_IS_IA32) || defined(ARCH_IS_X86_64)
482          {          {
483                  int cpu_flags = check_cpu_features();          int cpu_flags = param->cpu_flags;
484    
485                  if((cpu_flags & XVID_CPU_MMX) && (param->acc > 0)){                  if((cpu_flags & XVID_CPU_MMX) && (param->acc > 0)){
486                          ssim->func8x8 = lum_8x8_mmx;                          ssim->func8x8 = lum_8x8_mmx;
487                          ssim->consim = consim_mmx;                          ssim->consim = consim_mmx;

Legend:
Removed from v.1811  
changed lines
  Added in v.1812

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