From: Philipp Schafft Date: Sat, 22 Jul 2017 23:27:53 +0000 (+0000) Subject: Cleanup: Removed tailing white-spaces in C code files X-Git-Tag: v1.3.6~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed677ec711e9a95ae06365d076325232a3bc19a6;p=platform%2Fupstream%2Flibvorbis.git Cleanup: Removed tailing white-spaces in C code files Signed-off-by: Ralph Giles --- diff --git a/examples/decoder_example.c b/examples/decoder_example.c index 90ea63d..e264e40 100644 --- a/examples/decoder_example.c +++ b/examples/decoder_example.c @@ -74,7 +74,7 @@ int main(){ /********** Decode setup ************/ ogg_sync_init(&oy); /* Now we can read pages */ - + while(1){ /* we repeat if the bitstream is chained */ int eos=0; int i; @@ -88,60 +88,60 @@ int main(){ buffer=ogg_sync_buffer(&oy,4096); bytes=fread(buffer,1,4096,stdin); ogg_sync_wrote(&oy,bytes); - + /* Get the first page. */ if(ogg_sync_pageout(&oy,&og)!=1){ /* have we simply run out of data? If so, we're done. */ if(bytes<4096)break; - + /* error case. Must not be Vorbis data */ fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); exit(1); } - + /* Get the serial number and set up the rest of decode. */ /* serialno first; use it to set up a logical stream */ ogg_stream_init(&os,ogg_page_serialno(&og)); - + /* extract the initial header from the first page and verify that the Ogg bitstream is in fact Vorbis data */ - + /* I handle the initial header first instead of just having the code read all three Vorbis headers at once because reading the initial header is an easy way to identify a Vorbis bitstream and it's useful to see that functionality seperated out. */ - + vorbis_info_init(&vi); vorbis_comment_init(&vc); - if(ogg_stream_pagein(&os,&og)<0){ + if(ogg_stream_pagein(&os,&og)<0){ /* error; stream version mismatch perhaps */ fprintf(stderr,"Error reading first page of Ogg bitstream data.\n"); exit(1); } - - if(ogg_stream_packetout(&os,&op)!=1){ + + if(ogg_stream_packetout(&os,&op)!=1){ /* no page? must not be vorbis */ fprintf(stderr,"Error reading initial header packet.\n"); exit(1); } - - if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){ + + if(vorbis_synthesis_headerin(&vi,&vc,&op)<0){ /* error case; not a vorbis header */ fprintf(stderr,"This Ogg bitstream does not contain Vorbis " "audio data.\n"); exit(1); } - + /* At this point, we're sure we're Vorbis. We've set up the logical (Ogg) bitstream decoder. Get the comment and codebook headers and set up the Vorbis decoder */ - + /* The next two packets in order are the comment and codebook headers. They're likely large and may span multiple pages. Thus we read and submit data until we get our two packets, watching that no pages are missing. If a page is missing, error out; losing a header page is the only place where missing data is fatal. */ - + i=0; while(i<2){ while(i<2){ @@ -180,7 +180,7 @@ int main(){ } ogg_sync_wrote(&oy,bytes); } - + /* Throw the comments plus a few lines about the bitstream we're decoding */ { @@ -192,7 +192,7 @@ int main(){ fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi.channels,vi.rate); fprintf(stderr,"Encoded by: %s\n\n",vc.vendor); } - + convsize=4096/vi.channels; /* OK, got and parsed all three headers. Initialize the Vorbis @@ -203,7 +203,7 @@ int main(){ proceed in parallel. We could init multiple vorbis_block structures for vd here */ - + /* The rest is just a straight decode loop until end of stream */ while(!eos){ while(!eos){ @@ -217,7 +217,7 @@ int main(){ this point */ while(1){ result=ogg_stream_packetout(&os,&op); - + if(result==0)break; /* need more data */ if(result<0){ /* missing or corrupt data at this page position */ /* no reason to complain; already complained above */ @@ -225,21 +225,21 @@ int main(){ /* we have a packet. Decode it */ float **pcm; int samples; - + if(vorbis_synthesis(&vb,&op)==0) /* test for success! */ vorbis_synthesis_blockin(&vd,&vb); - /* - + /* + **pcm is a multichannel float vector. In stereo, for example, pcm[0] is left, and pcm[1] is right. samples is the size of each channel. Convert the float values (-1.<=range<=1.) to whatever PCM format and write it out */ - + while((samples=vorbis_synthesis_pcmout(&vd,&pcm))>0){ int j; int clipflag=0; int bout=(samplesvendor); } - + while(!eof){ long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,¤t_section); if (ret == 0) { @@ -85,7 +85,7 @@ int main(){ /* cleanup */ ov_clear(&vf); - + fprintf(stderr,"Done.\n"); return(0); } diff --git a/lib/psytune.c b/lib/psytune.c index 97e6893..6952136 100644 --- a/lib/psytune.c +++ b/lib/psytune.c @@ -40,11 +40,11 @@ static vorbis_info_psy_global _psy_set0G={ 0, /* decaydBpms */ 8, /* lines per eighth octave */ - + /* thresh sample period, preecho clamp trigger threshhold, range, minenergy */ 256, {26.f,26.f,26.f,30.f}, {-90.f,-90.f,-90.f,-90.f}, -90.f, - -6.f, - + -6.f, + 0, 0., @@ -67,7 +67,7 @@ static vp_couple _vp_couple0[]={ static vorbis_info_psy _psy_set0={ ATH_Bark_dB_lineaggressive, - + -100.f, -140.f, 6.f, /* floor master att */ @@ -147,7 +147,7 @@ static vorbis_info_psy _psy_set0={ .900f, 0.f, /*11500*/ .900f, 1.f, /*16000*/ }, - + 95.f, /* even decade + 5 is important; saves an rint() later in a tight loop) */ -44., @@ -158,7 +158,7 @@ static vorbis_info_psy _psy_set0={ static vorbis_info_floor1 _floor_set0={1, {0}, - + {32}, {0}, {0}, @@ -170,12 +170,12 @@ static vorbis_info_floor1 _floor_set0={1, 88,31,243, 14,54,143,460, - - 6,3,10, 22,18,26, 41,36,47, - 69,61,78, 112,99,126, 185,162,211, + + 6,3,10, 22,18,26, 41,36,47, + 69,61,78, 112,99,126, 185,162,211, 329,282,387, 672,553,825 }, - + 60,30,400, 20,8,1,18., 20,600, @@ -183,8 +183,8 @@ static vorbis_info_floor1 _floor_set0={1, static vorbis_info_mapping0 mapping_info={1,{0,1},{0},{0},{0},0, 1, {0},{1}}; -static codec_setup_info codec_setup0={ {0,0}, - 1,1,1,1,1,0,1, +static codec_setup_info codec_setup0={ {0,0}, + 1,1,1,1,1,0,1, {NULL}, {0},{&mapping_info}, {0},{NULL}, @@ -193,7 +193,7 @@ static codec_setup_info codec_setup0={ {0,0}, {NULL}, {&_psy_set0}, &_psy_set0G}; - + static int noisy=0; void analysis(char *base,int i,float *v,int n,int bark,int dB){ if(noisy){ @@ -211,7 +211,7 @@ void analysis(char *base,int i,float *v,int n,int bark,int dB){ fprintf(of,"%g ",toBARK(22050.f*j/n)); else fprintf(of,"%g ",(float)j); - + if(dB){ fprintf(of,"%g\n",todB(v+j)); }else{ @@ -268,7 +268,7 @@ int main(int argc,char *argv[]){ framesize=atoi(argv[0]); argv++; } - + vi.channels=2; vi.codec_setup=&codec_setup0; @@ -291,7 +291,7 @@ int main(int argc,char *argv[]){ /* we cheat on the WAV header; we just bypass 44 bytes and never verify that it matches 16bit/stereo/44.1kHz. */ - + fread(buffer,1,44,stdin); fwrite(buffer,1,44,stdout); memset(buffer,0,framesize*2); @@ -301,10 +301,10 @@ int main(int argc,char *argv[]){ fprintf(stderr,"Processing for frame size %d...\n",framesize); while(!eos){ - long bytes=fread(buffer2,1,framesize*2,stdin); + long bytes=fread(buffer2,1,framesize*2,stdin); if(byteslocal_ampmax[i])local_ampmax[i]=temp; } if(local_ampmax[i]>ampmax)ampmax=local_ampmax[i]; - + mdct_forward(&m_look,pcm[i],mdct); for(j=0;j1500) fprintf(stderr,"%ld ",frameno+i); - + analysis("res",frameno+i,pcm[i],framesize/2,1,0); analysis("codedflr",frameno+i,flr[i],framesize/2,1,1); } @@ -415,7 +415,7 @@ int main(int argc,char *argv[]){ &vi, pcm, nonzero); - + for(i=0;i<2;i++) analysis("quant",frameno+i,pcm[i],framesize/2,1,0); @@ -425,7 +425,7 @@ int main(int argc,char *argv[]){ &mapping_info, pcm, nonzero); - + for(i=0;i<2;i++) analysis("coupled",frameno+i,pcm[i],framesize/2,1,0); @@ -433,11 +433,11 @@ int main(int argc,char *argv[]){ for(i=mapping_info.coupling_steps-1;i>=0;i--){ float *pcmM=pcm[mapping_info.coupling_mag[i]]; float *pcmA=pcm[mapping_info.coupling_ang[i]]; - + for(j=0;j0) if(ang>0){ pcmM[j]=mag; @@ -456,7 +456,7 @@ int main(int argc,char *argv[]){ } } } - + for(i=0;i<2;i++) analysis("decoupled",frameno+i,pcm[i],framesize/2,1,0); @@ -478,7 +478,7 @@ int main(int argc,char *argv[]){ } - + /* write data. Use the part of buffer we're about to shift out */ for(i=0;i<2;i++){ char *ptr=buffer+i*2; @@ -502,7 +502,7 @@ int main(int argc,char *argv[]){ ptr+=4; } } - + fprintf(stderr,"*"); fwrite(buffer,1,framesize*2,stdout); memmove(buffer,buffer2,framesize*2); diff --git a/lib/synthesis.c b/lib/synthesis.c index 46fc1b8..5f6092c 100644 --- a/lib/synthesis.c +++ b/lib/synthesis.c @@ -116,7 +116,7 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ if(!ci->mode_param[mode]){ return(OV_EBADPACKET); } - + vb->W=ci->mode_param[mode]->blockflag; if(vb->W){ vb->lW=oggpack_read(opb,1); diff --git a/lib/tone.c b/lib/tone.c index 73afc67..5b8b020 100644 --- a/lib/tone.c +++ b/lib/tone.c @@ -12,7 +12,7 @@ int main (int argc,char *argv[]){ int i,j; double *f; double *amp; - + if(argc<2)usage(); f=alloca(sizeof(*f)*(argc-1)); @@ -21,7 +21,7 @@ int main (int argc,char *argv[]){ i=0; while(argv[i+1]){ char *pos=strchr(argv[i+1],','); - + f[i]=atof(argv[i+1]); if(pos) amp[i]=atof(pos+1)*32767.f; diff --git a/vq/bookutil.c b/vq/bookutil.c index 3aba9b9..3046410 100644 --- a/vq/bookutil.c +++ b/vq/bookutil.c @@ -90,7 +90,7 @@ char *get_line(FILE *in){ while(!gotline){ if(sofar+1>=lbufsize){ - if(!lbufsize){ + if(!lbufsize){ lbufsize=1024; linebuffer=_ogg_malloc(lbufsize); }else{ @@ -115,7 +115,7 @@ char *get_line(FILE *in){ } } } - + if(linebuffer[0]=='#'){ sofar=0; }else{ @@ -196,7 +196,7 @@ int get_vector(codebook *b,FILE *in,int start, int n,float *a){ for(i=1;idim;i++) if(get_line_value(in,a+i)) break; - + if(i==c->dim){ float temp=a[c->dim-1]; for(i=0;idim;i++)a[i]-=sequence_base; @@ -260,7 +260,7 @@ codebook *codebook_load(char *filename){ fprintf(stderr,"1: syntax in %s in line:\t %s",filename,line); exit(1); } - + switch(c->maptype){ case 0: quant_to_read=0; @@ -272,7 +272,7 @@ codebook *codebook_load(char *filename){ quant_to_read=c->entries*c->dim; break; } - + /* load the quantized entries */ find_seek_to(in,"static const long _vq_quantlist_"); reset_next_value(); @@ -282,7 +282,7 @@ codebook *codebook_load(char *filename){ fprintf(stderr,"out of data while reading codebook %s\n",filename); exit(1); } - + /* load the lengthlist */ find_seek_to(in,"_lengthlist"); reset_next_value(); @@ -295,7 +295,7 @@ codebook *codebook_load(char *filename){ /* got it all */ fclose(in); - + vorbis_book_init_encode(b,c); b->valuelist=_book_unquantize(c,c->entries,NULL); @@ -347,9 +347,9 @@ void build_tree_from_lengths(int vals, long *hist, long *lengths){ for(i=vals;i>1;i--){ int first=-1,second=-1; long least=-1; - + spinnit("building... ",i); - + /* find the two nodes to join */ for(j=0;j0) @@ -460,9 +460,9 @@ void write_codebook(FILE *out,char *name,const static_codebook *c){ fprintf(out,"};\n\n"); /* tie it all together */ - + fprintf(out,"static const static_codebook %s = {\n",name); - + fprintf(out,"\t%ld, %ld,\n",c->dim,c->entries); fprintf(out,"\t(char *)_vq_lengthlist_%s,\n",name); fprintf(out,"\t%d, %ld, %ld, %d, %d,\n", diff --git a/vq/distribution.c b/vq/distribution.c index e15f5aa..132b5b9 100644 --- a/vq/distribution.c +++ b/vq/distribution.c @@ -107,7 +107,7 @@ int main(int argc,char *argv[]){ if(c->lengthlist[j]){ int indexdiv=1; printf("%4d: ",j); - for(k=0;kdim;k++){ + 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)); @@ -137,7 +137,7 @@ int main(int argc,char *argv[]){ long maxcount=0,i,j; for(i=0;imaxcount)maxcount=countarray[i]; - + for(i=0;iquantlist; int stars=rint(50./maxcount*countarray[ptr]); @@ -160,30 +160,30 @@ int main(int argc,char *argv[]){ /* do it the simple way; two pass. */ line=setup_line(in); - while(line){ + while(line){ float code; char buf[80]; lines++; sprintf(buf,"getting min/max (%.2f::%.2f). lines...",min,max); if(!(lines&0xff))spinnit(buf,lines); - + while(!flag && sscanf(line,"%f",&code)==1){ line=strchr(line,','); min=max=code; flag=1; } - + while(line && sscanf(line,"%f",&code)==1){ line=strchr(line,','); if(line)line++; if(codemax)max=code; } - + line=setup_line(in); } - + if(bins<1){ if((int)(max-min)==min-max){ bins=max-min; @@ -191,43 +191,43 @@ int main(int argc,char *argv[]){ bins=25; } } - + printf("\r \r"); printf("Minimum scalar value: %f\n",min); printf("Maximum scalar value: %f\n",max); if(argv[2]){ - + printf("\n counting hits into %ld bins...\n",bins+1); countarray=calloc(bins+1,sizeof(long)); - + rewind(in); line=setup_line(in); - while(line){ + 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;i.vqd | [noguard]\n" " where begin,n,group is first scalar, \n" " number of scalars of each in line,\n" @@ -117,7 +117,7 @@ int main(int argc, char *argv[]){ long v; if(get_next_ivalue(file,&v))break; if(v>maxval)maxval=v; - + if(!(i++&0xff))spinnit("loading... ",i); } rewind(file); @@ -128,9 +128,9 @@ int main(int argc, char *argv[]){ long vals=pow(maxval,subn); long *hist=_ogg_calloc(vals,sizeof(long)); long *lengths=_ogg_calloc(vals,sizeof(long)); - + for(j=loval;j ... - + a threshmap (or pigeonmap) struct is generated by latticehint; there are fun tricks one can do with the threshmap and cascades, but the utils don't know them... @@ -81,7 +81,7 @@ int main(int argc,char *argv[]){ fprintf(stderr,"Could not open input file %s\n",filename); exit(1); } - + ptr=strrchr(filename,'.'); if(ptr){ *ptr='\0'; @@ -91,7 +91,7 @@ int main(int argc,char *argv[]){ } } - + /* read the description */ line=get_line(in); if(sscanf(line,"%d %d %d %d",&quantvals,&dim,&addmul,&sequencep)!=4){ @@ -115,7 +115,7 @@ int main(int argc,char *argv[]){ reset_next_value(); line=setup_line(in); - for(j=0;jc); - + ptr=strrchr(filename,'.'); if(ptr){ *ptr='\0'; @@ -93,11 +93,11 @@ int main(int argc,char *argv[]){ if(!strrcmp_i(argv[0],"latticetune")){ long lines=0; line=setup_line(in); - while(line){ + while(line){ long code; lines++; if(!(lines&0xfff))spinnit("codewords so far...",lines); - + if(sscanf(line,"%ld",&code)==1) hits[code]++; @@ -118,7 +118,7 @@ int main(int argc,char *argv[]){ char *pos=strchr(line,':'); if(pos){ long code=atol(line); - long val=atol(pos+1); + long val=atol(pos+1); hits[code]+=val; } @@ -132,19 +132,19 @@ int main(int argc,char *argv[]){ build_tree_from_lengths0(entries,hits,lengths); c->lengthlist=lengths; - write_codebook(stdout,name,c); + write_codebook(stdout,name,c); { long bins=_book_maptype1_quantvals(c); long i,k,base=c->lengthlist[0]; for(i=0;ilengthlist[i]>base)base=c->lengthlist[i]; - + for(j=0;jlengthlist[j]){ int indexdiv=1; fprintf(stderr,"%4ld: ",j); - for(k=0;kdim;k++){ + for(k=0;kdim;k++){ int index= (j/indexdiv)%bins; fprintf(stderr,"%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+ _float32_unpack(c->q_min)); @@ -156,7 +156,7 @@ int main(int argc,char *argv[]){ } } } - + fprintf(stderr,"\r " "\nDone.\n"); exit(0); diff --git a/vq/metrics.c b/vq/metrics.c index 327c0fd..e74831a 100644 --- a/vq/metrics.c +++ b/vq/metrics.c @@ -23,7 +23,7 @@ /* collect the following metrics: mean and mean squared amplitude - mean and mean squared error + mean and mean squared error mean and mean squared error (per sample) by entry worst case fit by entry entry cell size @@ -31,7 +31,7 @@ total bits total samples (average bits per sample)*/ - + /* set up metrics */ @@ -57,7 +57,7 @@ int books=0; void process_preprocess(codebook **bs,char *basename){ int i; while(bs[books])books++; - + if(books){ histogram=_ogg_calloc(books,sizeof(float *)); histogram_error=_ogg_calloc(books,sizeof(float *)); @@ -106,7 +106,7 @@ void cell_spacing(codebook *c){ localmin=this; } } - + if(min==-1 || localminmax)max=localmin; mean+=sqrt(localmin); @@ -114,7 +114,7 @@ void cell_spacing(codebook *c){ total++; } } - + fprintf(stderr,"\tminimum cell spacing (closest side): %g\n",sqrt(min)); fprintf(stderr,"\tmaximum cell spacing (closest side): %g\n",sqrt(max)); fprintf(stderr,"\tmean closest side spacing: %g\n",mean/total); @@ -160,7 +160,7 @@ void process_postprocess(codebook **bs,char *basename){ fprintf(stderr,"Could not open file %s for writing\n",buffer); exit(1); } - + for(i=0;i0){ if(v->assigned[k] && (localmin==-1 || thismax[j]+localmin/2; /* this gives us rough diameter */ if(min==-1 || localminmax)max=localmin; @@ -142,7 +142,7 @@ void vqgen_cellmetric(vqgen *v){ for(i=0;ientries;j++){ float last=0.f; for(k=0;kelements;k++){ @@ -200,7 +200,7 @@ void vqgen_quantize(vqgen *v,quant_meta *q){ for(k=0;kelements;k++){ float val=_now(v,j)[k]; float now=rint((val-last-mindel)/delta); - + _now(v,j)[k]=now; if(now<0){ /* be paranoid; this should be impossible */ @@ -281,7 +281,7 @@ void vqgen_addpoint(vqgen *v, float *p,float *a){ memcpy(_point(v,v->points),p,sizeof(float)*v->elements); if(v->aux)memcpy(_point(v,v->points)+v->elements,a,sizeof(float)*v->aux); - + /* quantize to the density mesh if it's selected */ if(v->mindist>0.f){ /* quantize to the mesh */ @@ -354,7 +354,7 @@ float vqgen_iterate(vqgen *v,int biasp){ sprintf(buff,"bias%d.m",v->it); bias=fopen(buff,"w"); #endif - + if(v->entries<2){ fprintf(stderr,"generation requires at least two entries\n"); @@ -383,9 +383,9 @@ float vqgen_iterate(vqgen *v,int biasp){ float secondmetric=v->metric_func(v,_now(v,1),ppt)+v->bias[1]; long firstentry=0; long secondentry=1; - + if(!(i&0xff))spinnit("biasing... ",v->points+v->points+v->entries-i); - + if(firstmetric>secondmetric){ float temp=firstmetric; firstmetric=secondmetric; @@ -393,7 +393,7 @@ float vqgen_iterate(vqgen *v,int biasp){ firstentry=1; secondentry=0; } - + for(j=2;jentries;j++){ float thismetric=v->metric_func(v,_now(v,j),ppt)+v->bias[j]; if(thismetricentries;j++){ - + float thismetric,localmetric; float *nearbiasptr=nearbias+desired2*j; long k=nearcount[j]; - + localmetric=v->metric_func(v,_now(v,j),ppt); /* 'thismetric' is to be the bias value necessary in the current arrangement for entry j to capture point i */ @@ -426,11 +426,11 @@ float vqgen_iterate(vqgen *v,int biasp){ /* use the primary entry as the threshhold */ thismetric=firstmetric-localmetric; } - + /* support the idea of 'minimum distance'... if we want the cells in a codebook to be roughly some minimum size (as with the low resolution residue books) */ - + /* a cute two-stage delayed sorting hack */ if(kpoints+v->points+v->entries-i); qsort(nearbiasptr,desired,sizeof(float),directdsort); } - + }else if(thismetric>nearbiasptr[desired-1]){ nearbiasptr[k]=thismetric; k++; @@ -452,14 +452,14 @@ float vqgen_iterate(vqgen *v,int biasp){ nearcount[j]=k; } } - + /* inflate/deflate */ - + for(i=0;ientries;i++){ float *nearbiasptr=nearbias+desired2*i; - + spinnit("biasing... ",v->points+v->entries-i); - + /* due to the delayed sorting, we likely need to finish it off....*/ if(nearcount[i]>desired) qsort(nearbiasptr,nearcount[i],sizeof(float),directdsort); @@ -467,7 +467,7 @@ float vqgen_iterate(vqgen *v,int biasp){ v->bias[i]=nearbiasptr[desired-1]; } - }else{ + }else{ memset(v->bias,0,v->entries*sizeof(float)); } @@ -488,7 +488,7 @@ float vqgen_iterate(vqgen *v,int biasp){ } j=firstentry; - + #ifdef NOISY fprintf(cells,"%g %g\n%g %g\n\n", _now(v,j)[0],_now(v,j)[1], @@ -552,7 +552,7 @@ float vqgen_iterate(vqgen *v,int biasp){ fprintf(stderr,": dist %g(%g) metric error=%g \n", asserror,fdesired,meterror/v->points); v->it++; - + free(new); free(nearcount); free(nearbias);