[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 1737, Fri Oct 13 15:16:25 2006 UTC revision 1743, Mon Oct 30 11:21:42 2006 UTC
# Line 62  Line 62 
62          uint8_t* errmap;          uint8_t* errmap;
63          */          */
64    
65            int grid;
66    
67          /*for average SSIM*/          /*for average SSIM*/
68          float ssim_sum;          float ssim_sum;
69          int frame_cnt;          int frame_cnt;
# Line 232  Line 234 
234  }  }
235    
236  /*calculate contrast and correlation of the two blocks*/  /*calculate contrast and correlation of the two blocks*/
237  void iconsim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr){  void consim_c(uint8_t* ptro, uint8_t* ptrc, int stride, int lumo, int lumc, int* pdevo, int* pdevc, int* pcorr){
238          int valo, valc, devo =0, devc=0, corr=0;          unsigned int valo, valc, devo=0, devc=0, corr=0,i,j,str;
239          int i,j;          str = stride - 8;
240          for(i=0;i< 8;i++){          for(i=0;i< 8;i++){
241                  for(j=0;j< 8;j++){                  for(j=0;j< 8;j++){
242                          valo = *ptro - lumo;                          valo = *ptro;
243                          valc = *ptrc - lumc;                          valc = *ptrc;
244                          devo += valo*valo;                          devo += valo*valo;
                         ptro++;  
245                          devc += valc*valc;                          devc += valc*valc;
                         ptrc++;  
246                          corr += valo*valc;                          corr += valo*valc;
247                            ptro++;
248                            ptrc++;
249                  }                  }
250          ptro += stride -8;          ptro += str;
251          ptrc += stride -8;          ptrc += str;
252          }          }
253          *pdevo = devo;  
254          *pdevc = devc;          *pdevo = devo - ((lumo*lumo + 32) >> 6);
255          *pcorr = corr;          *pdevc = devc - ((lumc*lumc + 32) >> 6);
256            *pcorr = corr - ((lumo*lumc + 32) >> 6);
257  };  };
258    
259  /*calculate the final ssim value*/  /*calculate the final ssim value*/
# Line 275  Line 278 
278          int meanc, meano;          int meanc, meano;
279          int devc, devo, corr;          int devc, devo, corr;
280    
         #define GRID 1  
   
281          width = data->width - 8;          width = data->width - 8;
282          height = data->height - 8;          height = data->height - 8;
283          str = data->original.stride[0];          str = data->original.stride[0];
284          if(str != data->current.stride[0]) printf("WARNING: Different strides in plugin_ssim original: %d current: %d\n",str,data->current.stride[0]);          if(str != data->current.stride[0]) printf("WARNING: Different strides in plugin_ssim original: %d current: %d\n",str,data->current.stride[0]);
285          ovr = str - width + (width % GRID);          ovr = str - width + (width % ssim->grid);
286    
287          ptr1 = (unsigned char*) data->original.plane[0];          ptr1 = (unsigned char*) data->original.plane[0];
288          ptr2 = (unsigned char*) data->current.plane[0];          ptr2 = (unsigned char*) data->current.plane[0];
# Line 289  Line 290 
290    
291    
292          /*TODO: Thread*/          /*TODO: Thread*/
293          for(i=0;i<height;i+=GRID){          for(i=0;i<height;i+=ssim->grid){
294                  /*begin of each row*/                  /*begin of each row*/
295                  meano = meanc = devc = devo = corr = 0;                  meano = meanc = devc = devo = corr = 0;
296                  meano = ssim->func8x8(ptr1,str);                  meano = ssim->func8x8(ptr1,str);
297                  meanc = ssim->func8x8(ptr2,str);                  meanc = ssim->func8x8(ptr2,str);
298                  ssim->consim(ptr1,ptr2,str,meano>>6,meanc>>6,&devo,&devc,&corr);                  ssim->consim(ptr1,ptr2,str,meano,meanc,&devo,&devc,&corr);
299                  emms();                  emms();
300    
301                  val = calc_ssim(meano,meanc,devo,devc,corr);                  val = calc_ssim(meano,meanc,devo,devc,corr);
# Line 305  Line 306 
306                          ssim->errmap[i*width] = (uint8_t) 127*val;                          ssim->errmap[i*width] = (uint8_t) 127*val;
307                  */                  */
308    
309    
310                  if(val < min) min = val;                  if(val < min) min = val;
311                  if(val > max) max = val;                  if(val > max) max = val;
312                  ptr1+=GRID;                  ptr1+=ssim->grid;
313                  ptr2+=GRID;                  ptr2+=ssim->grid;
314                  /*rest of each row*/                  /*rest of each row*/
315                  for(j=GRID;j<width;j+=GRID){                  for(j=ssim->grid;j<width;j+=ssim->grid){
316                          /* for grid = 1 use                          if(ssim->grid == 1){
317                          meano += ssim->func2x8(ptr1,str);                          meano += ssim->func2x8(ptr1,str);
318                          meanc += ssim->func2x8(ptr2,str);                          meanc += ssim->func2x8(ptr2,str);
319                          */                          } else {
320                          meano = ssim->func8x8(ptr1,str);                          meano = ssim->func8x8(ptr1,str);
321                          meanc = ssim->func8x8(ptr2,str);                          meanc = ssim->func8x8(ptr2,str);
322                          ssim->consim(ptr1,ptr2,str,meano>>6,meanc>>6,&devo,&devc,&corr);                          }
323                            ssim->consim(ptr1,ptr2,str,meano,meanc,&devo,&devc,&corr);
324                          emms();                          emms();
325    
326                          val = calc_ssim(meano,meanc,devo,devc,corr);                          val = calc_ssim(meano,meanc,devo,devc,corr);
# Line 329  Line 332 
332                          */                          */
333                          if(val < min) min = val;                          if(val < min) min = val;
334                          if(val > max) max = val;                          if(val > max) max = val;
335                          ptr1+=GRID;                          ptr1+=ssim->grid;
336                          ptr2+=GRID;                          ptr2+=ssim->grid;
337                  }                  }
338                  ptr1 +=ovr;                  ptr1 +=ovr;
339                  ptr2 +=ovr;                  ptr2 +=ovr;
# Line 368  Line 371 
371    
372          ssim->func8x8 = lum_8x8_c;          ssim->func8x8 = lum_8x8_c;
373          ssim->func2x8 = lum_2x8_c;          ssim->func2x8 = lum_2x8_c;
374          ssim->consim = iconsim_c;          ssim->consim = consim_c;
375    
376          ssim->param = param;          ssim->param = param;
377    
378            ssim->grid = param->acc;
379    
380            /*gaussian weigthing not implemented*/
381            if(ssim->grid == 0) ssim->grid = 1;
382            if(ssim->grid > 4) ssim->grid = 4;
383    
384            printf("Grid: %d\n",ssim->grid);
385    
386  #if defined(ARCH_IS_IA32)  #if defined(ARCH_IS_IA32)
387          if(cpu_flags & XVID_CPU_MMX){          if((cpu_flags & XVID_CPU_MMX) && (param->acc > 0)){
388                  ssim->func8x8 = lum_8x8_mmx;                  ssim->func8x8 = lum_8x8_mmx;
389                  ssim->consim = consim_mmx;                  ssim->consim = consim_mmx;
390          }          }
391          if(cpu_flags & XVID_CPU_SSE2){          if((cpu_flags & XVID_CPU_SSE2) && (param->acc > 0)){
392                  ssim->consim = consim_sse2;                  ssim->consim = consim_sse2;
393          }          }
394  #endif  #endif

Legend:
Removed from v.1737  
changed lines
  Added in v.1743

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