X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=vq%2Fdistribution.c;h=76beee4d2bdc3fdd3720e49790c3dee3d1faf260;hb=130e20f76254404157111598716617555d266acf;hp=adabcb682f9d5f9cb1437eabe91fb6b269461751;hpb=8d96e574de435ef69c82a34be48f257606f0a2e6;p=platform%2Fupstream%2Flibvorbis.git diff --git a/vq/distribution.c b/vq/distribution.c index adabcb6..76beee4 100644 --- a/vq/distribution.c +++ b/vq/distribution.c @@ -6,12 +6,12 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the XIPHOPHORUS Company http://www.xiph.org/ * - + * by the Xiph.Org Foundation http://www.xiph.org/ * + * * ******************************************************************** function: utility for finding the distribution in a data set - last mod: $Id: distribution.c,v 1.6 2001/06/15 21:15:43 xiphmont Exp $ + last mod: $Id$ ********************************************************************/ @@ -90,69 +90,69 @@ int main(int argc,char *argv[]){ switch(c->maptype){ case 1: { - /* lattice codebook. dump it. */ - int j,k; - long maxcount=0; - long **sort=calloc(bins,sizeof(long *)); - long base=c->lengthlist[0]; - countarray=calloc(bins,sizeof(long)); - - for(i=0;iquantlist+i; - qsort(sort,bins,sizeof(long *),ascend); - - for(i=0;ientries;i++) - if(c->lengthlist[i]>base)base=c->lengthlist[i]; - - /* dump a full, correlated count */ - for(j=0;jentries;j++){ - if(c->lengthlist[j]){ - int indexdiv=1; - printf("%4ld: ",j); - for(k=0;kdim;k++){ - int index= (j/indexdiv)%bins; - printf("%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+ - _float32_unpack(c->q_min)); - indexdiv*=bins; - } - printf("\t|",(1<<(base-c->lengthlist[j]))); - for(k=0;klengthlist[j];k++)printf("*"); - printf("\n"); - } - } - - /* do a rough count */ - for(j=0;jentries;j++){ - int indexdiv=1; - for(k=0;kdim;k++){ - if(c->lengthlist[j]){ - int index= (j/indexdiv)%bins; - countarray[index]+=(1<<(base-c->lengthlist[j])); - indexdiv*=bins; - } - } - } - - /* dump the count */ - - { - long maxcount=0,i,j; - for(i=0;imaxcount)maxcount=countarray[i]; + /* lattice codebook. dump it. */ + int j,k; + long maxcount=0; + long **sort=calloc(bins,sizeof(long *)); + long base=c->lengthlist[0]; + countarray=calloc(bins,sizeof(long)); + + for(i=0;iquantlist+i; + qsort(sort,bins,sizeof(long *),ascend); + + for(i=0;ientries;i++) + if(c->lengthlist[i]>base)base=c->lengthlist[i]; + + /* dump a full, correlated count */ + for(j=0;jentries;j++){ + if(c->lengthlist[j]){ + int indexdiv=1; + printf("%4d: ",j); + for(k=0;kdim;k++){ + int index= (j/indexdiv)%bins; + printf("%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+ + _float32_unpack(c->q_min)); + indexdiv*=bins; + } + printf("\t|"); + for(k=0;klengthlist[j];k++)printf("*"); + printf("\n"); + } + } + + /* do a rough count */ + for(j=0;jentries;j++){ + int indexdiv=1; + for(k=0;kdim;k++){ + if(c->lengthlist[j]){ + int index= (j/indexdiv)%bins; + countarray[index]+=(1<<(base-c->lengthlist[j])); + indexdiv*=bins; + } + } + } + + /* dump the count */ + + { + long maxcount=0,i,j; + for(i=0;imaxcount)maxcount=countarray[i]; - for(i=0;iquantlist; - int stars=rint(50./maxcount*countarray[ptr]); - printf("%+08f (%8ld) |",c->quantlist[ptr]*delta+min,countarray[ptr]); - for(j=0;jquantlist; + int stars=rint(50./maxcount*countarray[ptr]); + printf("%+08f (%8ld) |",c->quantlist[ptr]*delta+min,countarray[ptr]); + for(j=0;jmax)max=code; + line=strchr(line,','); + if(line)line++; + if(codemax)max=code; } line=setup_line(in); @@ -184,57 +187,61 @@ int main(int argc,char *argv[]){ if(bins<1){ if((int)(max-min)==min-max){ - bins=max-min; + bins=max-min; }else{ - bins=25; + bins=25; } } printf("\r \r"); printf("Minimum scalar value: %f\n",min); printf("Maximum scalar value: %f\n",max); - - printf("\n counting hits into %d bins...\n",bins+1); - countarray=calloc(bins+1,sizeof(long)); - - rewind(in); - line=setup_line(in); - while(line){ - float code; - lines--; - if(!(lines&0xff))spinnit("counting distribution. lines so far...",lines); + + if(argv[2]){ - while(line && sscanf(line,"%f",&code)==1){ - line=strchr(line,','); - if(line)line++; - - code-=min; - code/=(max-min); - code*=bins; - countarray[(int)rint(code)]++; - total++; - } + printf("\n counting hits into %ld bins...\n",bins+1); + countarray=calloc(bins+1,sizeof(long)); + rewind(in); line=setup_line(in); - } - - fclose(in); + while(line){ + float code; + lines--; + if(!(lines&0xff))spinnit("counting distribution. lines so far...",lines); + + while(line && sscanf(line,"%f",&code)==1){ + line=strchr(line,','); + if(line)line++; + + code-=min; + code/=(max-min); + code*=bins; + countarray[(int)rint(code)]++; + total++; + } + + line=setup_line(in); + } - /* make a pretty graph */ - { - long maxcount=0,i,j; - for(i=0;imaxcount)maxcount=countarray[i]; - - printf("\r \r"); - printf("Total scalars: %ld\n",total); - for(i=0;imaxcount)maxcount=countarray[i]; + + printf("\r \r"); + printf("Total scalars: %ld\n",total); + for(i=0;i