diff options
Diffstat (limited to 'drivers/vorbis/res0.c')
-rw-r--r-- | drivers/vorbis/res0.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/drivers/vorbis/res0.c b/drivers/vorbis/res0.c index fa0ad97561..ec11488c2f 100644 --- a/drivers/vorbis/res0.c +++ b/drivers/vorbis/res0.c @@ -11,7 +11,7 @@ ******************************************************************** function: residue backend 0, 1 and 2 implementation - last mod: $Id: res0.c 17556 2010-10-21 18:25:19Z tterribe $ + last mod: $Id: res0.c 19441 2015-01-21 01:17:41Z xiphmont $ ********************************************************************/ @@ -152,15 +152,6 @@ void res0_free_look(vorbis_look_residue *i){ } } -static int ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - static int icount(unsigned int v){ int ret=0; while(v){ @@ -186,7 +177,7 @@ void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){ bitmask of one indicates this partition class has bits to write this pass */ for(j=0;j<info->partitions;j++){ - if(ilog(info->secondstages[j])>3){ + if(ov_ilog(info->secondstages[j])>3){ /* yes, this is a minor hack due to not thinking ahead */ oggpack_write(opb,info->secondstages[j],3); oggpack_write(opb,1,1); @@ -284,7 +275,7 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd, look->partbooks=_ogg_calloc(look->parts,sizeof(*look->partbooks)); for(j=0;j<look->parts;j++){ - int stages=ilog(info->secondstages[j]); + int stages=ov_ilog(info->secondstages[j]); if(stages){ if(stages>maxstage)maxstage=stages; look->partbooks[j]=_ogg_calloc(stages,sizeof(*look->partbooks[j])); @@ -390,8 +381,13 @@ static int local_book_besterror(codebook *book,int *a){ return(index); } +#ifdef TRAIN_RES static int _encodepart(oggpack_buffer *opb,int *vec, int n, codebook *book,long *acc){ +#else +static int _encodepart(oggpack_buffer *opb,int *vec, int n, + codebook *book){ +#endif int i,bits=0; int dim=book->dim; int step=n/dim; @@ -534,12 +530,18 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in, } static int _01forward(oggpack_buffer *opb, - vorbis_block *vb,vorbis_look_residue *vl, + vorbis_look_residue *vl, int **in,int ch, long **partword, +#ifdef TRAIN_RES int (*encode)(oggpack_buffer *,int *,int, codebook *,long *), - int submap){ + int submap +#else + int (*encode)(oggpack_buffer *,int *,int, + codebook *) +#endif +){ long i,j,k,s; vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; vorbis_info_residue0 *info=look->info; @@ -609,9 +611,8 @@ static int _01forward(oggpack_buffer *opb, codebook *statebook=look->partbooks[partword[j][i]][s]; if(statebook){ int ret; - long *accumulator=NULL; - #ifdef TRAIN_RES + long *accumulator=NULL; accumulator=look->training_data[s][partword[j][i]]; { int l; @@ -623,10 +624,12 @@ static int _01forward(oggpack_buffer *opb, look->training_max[s][partword[j][i]]=samples[l]; } } -#endif - ret=encode(opb,in[j]+offset,samples_per_partition, statebook,accumulator); +#else + ret=encode(opb,in[j]+offset,samples_per_partition, + statebook); +#endif look->postbits+=ret; resbits[partword[j][i]]+=ret; @@ -637,19 +640,6 @@ static int _01forward(oggpack_buffer *opb, } } - /*{ - long total=0; - long totalbits=0; - fprintf(stderr,"%d :: ",vb->mode); - for(k=0;k<possible_partitions;k++){ - fprintf(stderr,"%ld/%1.2g, ",resvals[k],(float)resbits[k]/resvals[k]); - total+=resvals[k]; - totalbits+=resbits[k]; - } - - fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total); - }*/ - return(0); } @@ -729,12 +719,18 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl, int **in,int *nonzero,int ch, long **partword, int submap){ int i,used=0; + (void)vb; for(i=0;i<ch;i++) if(nonzero[i]) in[used++]=in[i]; if(used){ - return _01forward(opb,vb,vl,in,used,partword,_encodepart,submap); +#ifdef TRAIN_RES + return _01forward(opb,vl,in,used,partword,_encodepart,submap); +#else + (void)submap; + return _01forward(opb,vl,in,used,partword,_encodepart); +#endif }else{ return(0); } @@ -795,7 +791,12 @@ int res2_forward(oggpack_buffer *opb, } if(used){ - return _01forward(opb,vb,vl,&work,1,partword,_encodepart,submap); +#ifdef TRAIN_RES + return _01forward(opb,vl,&work,1,partword,_encodepart,submap); +#else + (void)submap; + return _01forward(opb,vl,&work,1,partword,_encodepart); +#endif }else{ return(0); } |