From: Monty Date: Sat, 1 Sep 2001 06:14:52 +0000 (+0000) Subject: tuning on a branch. New noise metrics, noise bugfixes, postecho on. X-Git-Tag: v1.3.3~931 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eca3401e17af8b44d8777c3f7a5ae3e2e02e3065;p=platform%2Fupstream%2Flibvorbis.git tuning on a branch. New noise metrics, noise bugfixes, postecho on. svn path=/trunk/vorbis/; revision=1947 --- diff --git a/lib/floor1.c b/lib/floor1.c index 0a74296..3d5e73e 100644 --- a/lib/floor1.c +++ b/lib/floor1.c @@ -11,7 +11,7 @@ ******************************************************************** function: floor backend 1 implementation - last mod: $Id: floor1.c,v 1.14 2001/08/16 20:31:38 xiphmont Exp $ + last mod: $Id: floor1.c,v 1.15 2001/09/01 06:14:50 xiphmont Exp $ ********************************************************************/ @@ -940,7 +940,7 @@ static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in, { FILE *of; char buffer[80]; - sprintf(buffer,"line_%ldx%ld_class%d.vqd", + sprintf(buffer,"line_%dx%ld_class%d.vqd", vb->pcmend/2,posts-2,class); of=fopen(buffer,"a"); fprintf(of,"%d\n",cval); @@ -964,7 +964,7 @@ static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in, { FILE *of; char buffer[80]; - sprintf(buffer,"line_%ldx%ld_%dsub%d.vqd", + sprintf(buffer,"line_%dx%ld_%dsub%d.vqd", vb->pcmend/2,posts-2,class,bookas[k]); of=fopen(buffer,"a"); fprintf(of,"%d\n",fit_valueB[j+k]); diff --git a/lib/modes/mode_44c_A.h b/lib/modes/mode_44c_A.h index a88c171..68836fd 100644 --- a/lib/modes/mode_44c_A.h +++ b/lib/modes/mode_44c_A.h @@ -11,7 +11,7 @@ ******************************************************************** function: predefined encoding modes; 44kHz stereo ~64kbps true VBR - last mod: $Id: mode_44c_A.h,v 1.1 2001/08/13 07:43:15 xiphmont Exp $ + last mod: $Id: mode_44c_A.h,v 1.2 2001/09/01 06:14:52 xiphmont Exp $ ********************************************************************/ @@ -73,7 +73,7 @@ static vorbis_info_psy_global _psy_set_44c_AG={ 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, + 256, {26.f,26.f,26.f,30.f}, {-26.f,-26.f,-26.f,-30.f}, -90.f, -6.f, 0, @@ -82,36 +82,44 @@ static vorbis_info_psy_global _psy_set_44c_AG={ static struct vp_couple_pass _psy_pass_44c_A0[]={ {1.f,1.f, {{24, 0,0, 0,0, 0,0}, - {64, 0,0, 7.5f,12, 0,0}, - {9999, 0,0, 7.5f,12, 2.5f,0}} + {64, 0,0, 7.5f,12, 2.5f,0}, + {9999, 0,0, 7.5f,12, 4.5f,0}} }, }; static vp_couple_pass _psy_pass_44c_A[]={ {1.f,1.f, - {{288, 0,0, 0,0, 0,0}, + {{288, 0,0, 0,0, 0,0}, {512, 0,0, 7.5f,12, 0,0}, {9999, 0,0, 7.5f,12, 2.5f,0}} } }; +static float _psy_compand_44c_A[NOISE_COMPAND_LEVELS]={ + 0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, /* 7dB */ + 8.f, 8.f, 7.f, 6.f, 5.f, 4.f, 3.f, 2.f, /* 15dB */ + 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, /* 23dB */ + 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, /* 31dB */ + 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, /* 39dB */ +}; + static vorbis_info_psy _psy_set_44c_A0={ ATH_Bark_dB_lineaggressive, -100.,-140., /* tonemaskp */ - 0.f, -40.f,&_vp_tonemask_consbass_A, + 0.f, -26.f,&_vp_tonemask_consbass_A, /* peakattp, curvelimitp */ 1, 4, &_vp_peakatt_A, /*noisemaskp */ 1,-30.f, /* suppress any noise curve over maxspec+n */ .6f, .6f, /* low/high window */ - 5, 5, 10, + 2, 2, 15, /*63 125 250 500 1k 2k 4k 8k 16k*/ - {-30,-30,-30,-30,-30,-30,-20,-10, 0, 0, 0, 0, 0, 1, 1, 2, 3}, - {.9f,.9f,.9f,.9f,.9f,.8f,.8f,.6f,.6f,.6f,.6f,.6f,.7f,.8f,.89f,.9f,.9f}, + {-30,-30,-30,-30,-30,-30,-20,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + _psy_compand_44c_A, 95.f, /* even decade + 5 is important; saves an rint() later in a tight loop) */ @@ -124,18 +132,18 @@ static vorbis_info_psy _psy_set_44c_AT={ -100.f,-140.f, /* tonemask */ - 0.f,-40.f,&_vp_tonemask_consbass_A, + 0.f,-26.f,&_vp_tonemask_consbass_A, /* peakattp,curvelimitp */ 1, 4, &_vp_peakatt_A, /*noisemaskp */ - 1, -30.f, /* suppress any noise curve over maxspec+n */ - .4f,.4f, /* low/high window */ - 10,10,100, + 1, -40.f, /* suppress any noise curve over maxspec+n */ + .6f,.6f, /* low/high window */ + 4,4,100, /*63 125 250 500 1k 2k 4k 8k 16k*/ - {-30,-30,-30,-30,-30,-30,-30,-20, 0, 0, 0, 0, 0, 0, 0, 1, 2}, - {.7f,.7f,.7f,.7f,.7f,.6f,.5f,.5f,.5f,.5f,.5f,.5f,.7f,.75f,.8f,.8f,.85f}, + {-30,-30,-30,-30,-20,-20,-10,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + _psy_compand_44c_A, 95.f, /* even decade + 5 is important; saves an rint() later in a tight loop) */ @@ -147,18 +155,18 @@ static vorbis_info_psy _psy_set_44c_A={ -100.f, -140.f, /* tonemask */ - 0.f,-40.f,&_vp_tonemask_consbass_A, + 0.f,-26.f,&_vp_tonemask_consbass_A, /* peakattp, curvelimitp */ 1, 4, &_vp_peakatt_A, /*noisemaskp */ 1, -30.f, /* suppress any noise curve over maxspec+n */ - .4f,.4f, /* low/high window */ - 10,10,100, + .6f,.6f, /* low/high window */ + 4,4,100, /*63 125 250 500 1k 2k 4k 8k 16k*/ - {-20,-20,-20,-20,-20,-20,-10, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2}, - {.6f,.6f,.6f,.6f,.6f,.5f,.5f,.5f,.5f,.5f,.5f,.5f,.7f,.75f,.8f,.8f,.85f}, + {-20,-20,-20,-20,-20,-20,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + _psy_compand_44c_A, 95.f, /* even decade + 5 is important; saves an rint() later in a tight loop) */ @@ -219,7 +227,7 @@ static vorbis_info_floor1 _floor_set_44c_A={ 60,30,400, 20,8,1,18., 20,600, - 720}; + 960}; static vorbis_info_residue0 _residue_set_44c_A0={ 0,192, 8, 10,23, @@ -236,7 +244,7 @@ static vorbis_info_residue0 _residue_set_44c_A0={ {3}}; static vorbis_info_residue0 _residue_set_44c_A={ - 0,1536, 32,10,24, + 0,1920, 32,10,24, {0,1,1,1,1,1,1,3,3,7}, {25, 26, 27, 28, 29, 30, 31,32, 33,34, 35,36,37}, {9999,9999,9999,9999,9999,9999, diff --git a/lib/modes/modes.h b/lib/modes/modes.h index a42d6d4..ee5636e 100644 --- a/lib/modes/modes.h +++ b/lib/modes/modes.h @@ -11,7 +11,7 @@ ******************************************************************** function: predefined encoding modes - last mod: $Id: modes.h,v 1.13 2001/08/13 11:30:59 xiphmont Exp $ + last mod: $Id: modes.h,v 1.14 2001/09/01 06:14:52 xiphmont Exp $ ********************************************************************/ @@ -20,21 +20,21 @@ #include "masking.h" /* stereo (coupled) */ -#include "modes/mode_44c_Z.h" -#include "modes/mode_44c_Y.h" -#include "modes/mode_44c_X.h" +//#include "modes/mode_44c_Z.h" +//#include "modes/mode_44c_Y.h" +//#include "modes/mode_44c_X.h" #include "modes/mode_44c_A.h" -#include "modes/mode_44c_B.h" -#include "modes/mode_44c_C.h" -#include "modes/mode_44c_D.h" -#include "modes/mode_44c_E.h" +//#include "modes/mode_44c_B.h" +//#include "modes/mode_44c_C.h" +//#include "modes/mode_44c_D.h" +//#include "modes/mode_44c_E.h" /* mono/dual/multi */ -#include "modes/mode_44_Z.h" -#include "modes/mode_44_Y.h" -#include "modes/mode_44_X.h" -#include "modes/mode_44_A.h" -#include "modes/mode_44_B.h" -#include "modes/mode_44_C.h" +//#include "modes/mode_44_Z.h" +//#include "modes/mode_44_Y.h" +//#include "modes/mode_44_X.h" +//#include "modes/mode_44_A.h" +//#include "modes/mode_44_B.h" +//#include "modes/mode_44_C.h" #endif diff --git a/lib/psy.c b/lib/psy.c index 1d0b0ad..233ccf3 100644 --- a/lib/psy.c +++ b/lib/psy.c @@ -11,7 +11,7 @@ ******************************************************************** function: psychoacoustics not including preecho - last mod: $Id: psy.c,v 1.51 2001/08/16 22:52:54 xiphmont Exp $ + last mod: $Id: psy.c,v 1.52 2001/09/01 06:14:50 xiphmont Exp $ ********************************************************************/ @@ -214,7 +214,7 @@ static void setup_curve(float **c, void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, vorbis_info_psy_global *gi,int n,long rate){ - long i,j,k,lo=0,hi=0; + long i,j,k,lo=-99,hi=0; long maxoc; memset(p,0,sizeof(vorbis_look_psy)); @@ -246,7 +246,7 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, for(;hinoisewindowhimin || toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++); - p->bark[i]=(hi<<16)+lo; + p->bark[i]=(lo<<16)+hi; } @@ -368,9 +368,6 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, if(halfoc>=P_BANDS-1)halfoc=P_BANDS-1; inthalfoc=(int)halfoc; del=halfoc-inthalfoc; - - p->noisethresh[i]=((p->vi->noisethresh[inthalfoc]*(1.-del) + - p->vi->noisethresh[inthalfoc+1]*del))*2.f-1.f; p->noiseoffset[i]= p->vi->noiseoff[inthalfoc]*(1.-del) + p->vi->noiseoff[inthalfoc+1]*del; @@ -599,59 +596,40 @@ static void bark_noise_hybridmp(int n,const long *b, float *noise, const float offset, const int fixed){ - long i,hi=0,lo=0,hif=0,lof=0; + long i,hi=b[0]>>16,lo=b[0]>>16,hif=-fixed/2,lof=-fixed/2; double xa=0,xb=0; double ya=0,yb=0; double x2a=0,x2b=0; double y2a=0,y2b=0; double xya=0,xyb=0; double na=0,nb=0; - int first=-1,firstf=-1; - int last=0,lastf=0; - int rna=0,rnb=0; for(i=0;i>16; + int bi=b[i]&0xffffL; for(;hi0.f){ - double nn= bin*bin; - nn*=nn; - na += nn; - xa += hi*nn; - ya += bin*nn; - x2a += hi*hi*nn; - y2a += bin*bin*nn; - xya += hi*bin*nn; - last=hi; - rna++; - if(first==-1)first=hi; - } + int ii=(hi<0?-hi:hi); + double bin=(f[ii]<-offset?1.:f[ii]+offset); + double nn= bin*bin; + na += nn; + xa += hi*nn; + ya += bin*nn; + x2a += hi*hi*nn; + y2a += bin*bin*nn; + xya += hi*bin*nn; } - bi=b[i]&0xffff; + bi=b[i]>>16; for(;lo0.f){ - double nn= bin*bin; - nn*=nn; - na -= nn; - xa -= lo*nn; - ya -= bin*nn; - x2a -= lo*lo*nn; - y2a -= bin*bin*nn; - xya -= lo*bin*nn; - rna--; - } - if(first0.f)break; - if(first==hi)first=-1; - } + int ii=(lo<0?-lo:lo); + double bin=(f[ii]<-offset?1.:f[ii]+offset); + double nn= bin*bin; + na -= nn; + xa -= lo*nn; + ya -= bin*nn; + x2a -= lo*lo*nn; + y2a -= bin*bin*nn; + xya -= lo*bin*nn; } } @@ -660,74 +638,50 @@ static void bark_noise_hybridmp(int n,const long *b, if(bi>n)bi=n; for(;hif0.f){ - double nn= bin*bin; - nn*=nn; - nb += nn; - xb += hif*nn; - yb += bin*nn; - x2b += hif*hif*nn; - y2b += bin*bin*nn; - xyb += hif*bin*nn; - lastf=hif; - rnb++; - if(firstf==-1)firstf=hif; - } + int ii=(hif<0?-hif:hif); + double bin=(f[ii]<-offset?1.:f[ii]+offset); + double nn= bin*bin; + nb += nn; + xb += hif*nn; + yb += bin*nn; + x2b += hif*hif*nn; + y2b += bin*bin*nn; + xyb += hif*bin*nn; } bi=i-(fixed+1)/2; - if(bi<0)bi=0; for(;lof0.f){ - double nn= bin*bin; - nn*=nn; - nb -= nn; - xb -= lof*nn; - yb -= bin*nn; - x2b -= lof*lof*nn; - y2b -= bin*bin*nn; - xyb -= lof*bin*nn; - rnb--; - } - if(firstf0.f)break; - if(firstf==hif)firstf=-1; - } + int ii=(lof<0?-lof:lof); + double bin=(f[ii]<-offset?1.:f[ii]+offset); + double nn= bin*bin; + nb -= nn; + xb -= lof*nn; + yb -= bin*nn; + x2b -= lof*lof*nn; + y2b -= bin*bin*nn; + xyb -= lof*bin*nn; } } { - double va; + double va=0.f; - if(rna>2 && (last-first)*3/2>hi-lo){ + if(na>2){ double denom=1./(na*x2a-xa*xa); double a=(ya*x2a-xya*xa)*denom; double b=(na*xya-xa*ya)*denom; va=a+b*i; - }else{ - va=0.f; - if(na>.5)va=ya/na; } if(va<0.)va=0.; if(fixed>0){ - double vb; + double vb=0.f; - if(rnb>2 && (lastf-firstf)*3/2>hif-lof){ + if(nb>2){ double denomf=1./(nb*x2b-xb*xb); double af=(yb*x2b-xyb*xb)*denomf; double bf=(nb*xyb-xb*yb)*denomf; vb=af+bf*i; - }else{ - vb=0.f; - if(nb>.5)vb=yb/nb; } - if(vb<0.)vb=0.; if(va>vb && vb>0.)va=vb; @@ -790,11 +744,17 @@ void _vp_compute_mask(vorbis_look_psy *p, envelope line (1.) */ _analysis_output("median",seq,work,n,1,0); + + _analysis_output("medianenvelope",seq,logmask,n,1,0); + for(i=0;inoisethresh[i]*logmask[i]+p->noiseoffset[i]; + for(i=0;i=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1; + logmask[i]= work[i]+p->vi->noisecompand[dB]+p->noiseoffset[i]; + } _analysis_output("noise",seq,logmask,n,1,0); @@ -852,80 +812,168 @@ float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){ return(amp); } -static void couple_lossless(float A, float B, float *mag, float *ang){ +static void couple_lossless(float A, float B, + float granule,float igranule, + float *mag, float *ang){ + + A=rint(A*igranule)*granule; + B=rint(B*igranule)*granule; + if(fabs(A)>fabs(B)){ *mag=A; *ang=(A>0.f?A-B:B-A); }else{ *mag=B; *ang=(B>0.f?A-B:B-A); } + + if(*ang>fabs(*mag)*1.9999f)*ang=-fabs(*mag)*2.f; + } -static void couple_8phase(float A, float B, float *mag, float *ang){ - if(fabs(A)>fabs(B)){ - *mag=A; *ang=(A>0?A-B:B-A); - }else{ - *mag=B; *ang=(B>0?A-B:B-A); - } +static void couple_8phase(float A, float B, float fA, float fB, + float granule,float igranule, + float fmag, float *mag, float *ang){ + + float origmag=FAST_HYPOT(A*fA,B*fB),corr; - if(*mag!=0.f) - switch((int)(rint(*ang / *mag))){ + if(fmag!=0.f){ + float phase=rint((A-B)/fmag); + + if(fabs(A)>fabs(B)){ + *mag=A;phase=(A>0?phase:-phase); + }else{ + *mag=B;phase=(B>0?phase:-phase); + } + + switch((int)phase){ case 0: - *ang=0; - break; - case 2:case -2: - *ang=-2*fabs(*mag); + corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB); + *mag=rint(*mag*corr*igranule)*granule; + *ang=0.f; break; case 1: - *ang= *mag; + corr=origmag/(fmag*fA); + *mag=rint(A*corr*igranule)*granule; + *ang=fabs(*mag); break; case -1: - *ang= -*mag; + corr=origmag/(fmag*fB); + *mag=rint(B*corr*igranule)*granule; + *ang=-fabs(*mag); + break; + default: + corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB); + *mag=rint(*mag*corr*igranule)*granule; + *ang=-2.f*fabs(*mag); break; } + }else{ + *mag=0.f; + *ang=0.f; + } } -static void couple_6phase(float A, float B, float *mag, float *ang){ - if(fabs(A)>fabs(B)){ - *mag=A; *ang=(A>0?A-B:B-A); - }else{ - *mag=B; *ang=(B>0?A-B:B-A); - } +static void couple_6phase(float A, float B, float fA, float fB, + float granule,float igranule, + float fmag, float *mag, float *ang){ + + float origmag=FAST_HYPOT(A*fA,B*fB),corr; - if(*mag!=0.f) - switch((int)(rint(*ang / *mag))){ - case -2:case 2: - *mag=0; - /*fall*/ + if(fmag!=0.f){ + float phase=rint((A-B)/fmag); + + if(fabs(A)>fabs(B)){ + *mag=A;phase=(A>0?phase:-phase); + }else{ + *mag=B;phase=(B>0?phase:-phase); + } + + switch((int)phase){ case 0: - *ang=0; + corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB); + *mag=rint(*mag*corr*igranule)*granule; + *ang=0.f; break; - case 1: - *ang= *mag; + case 1:case 2: + corr=origmag/(fmag*fA); + *mag=rint(A*corr*igranule)*granule; + *ang=fabs(*mag); break; - case -1: - *ang= -*mag; + case -1:case -2: + corr=origmag/(fmag*fB); + *mag=rint(B*corr*igranule)*granule; + *ang=-fabs(*mag); break; } + }else{ + *mag=0.f; + *ang=0.f; + } } -static void couple_point(float A, float B, float *mag, float *ang){ - if(fabs(A)>fabs(B)){ - *mag=A; *ang=(A>0?A-B:B-A); - }else{ - *mag=B; *ang=(B>0?A-B:B-A); - } +static void couple_4phase(float A, float B, float fA, float fB, + float granule,float igranule, + float fmag, float *mag, float *ang){ - if(*mag!=0.f) - switch((int)(rint(*ang / *mag))){ - case -2:case 2: - *mag=0; - /* fall */ - case 0:case 1: case -1: - *ang=0; + float origmag=FAST_HYPOT(A*fA,B*fB),corr; + + if(fmag!=0.f){ + float phase=rint((A-B)*.5/fmag); + + if(fabs(A)>fabs(B)){ + *mag=A;phase=(A>0?phase:-phase); + }else{ + *mag=B;phase=(B>0?phase:-phase); + } + + corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB); + *mag=rint(*mag*corr*igranule)*granule; + switch((int)phase){ + case 0: + *ang=0.f; + break; + default: + *ang=-2.f*fabs(*mag); break; } + }else{ + *mag=0.f; + *ang=0.f; + } +} + +static void couple_point(float A, float B, float fA, float fB, + float granule,float igranule, + float fmag, float *mag, float *ang){ + + float origmag=FAST_HYPOT(A*fA,B*fB),corr; + + if(fmag!=0.f){ + float phase=rint((A-B)*.5/fmag); + + if(fabs(A)>fabs(B)){ + *mag=A;phase=(A>0?phase:-phase); + }else{ + *mag=B;phase=(B>0?phase:-phase); + } + + //switch((int)phase){ + //case 0: + corr=origmag/FAST_HYPOT(fmag*fA,fmag*fB); + *mag=rint(*mag*corr*igranule)*granule; + *ang=0.f; + //break; + //default: + //*mag=0.f; + //*ang=0.f; + //break; + //} + }else{ + *mag=0.f; + *ang=0.f; + } } + void _vp_quantize_couple(vorbis_look_psy *p, vorbis_info_mapping0 *vi, float **pcm, @@ -949,6 +997,8 @@ void _vp_quantize_couple(vorbis_look_psy *p, float *pcmM=pcm[vi->coupling_mag[i]]; float *pcmA=pcm[vi->coupling_ang[i]]; + float *floorM=pcm[vi->coupling_mag[i]]+n; + float *floorA=pcm[vi->coupling_ang[i]]+n; float *sofarM=sofar[vi->coupling_mag[i]]; float *sofarA=sofar[vi->coupling_ang[i]]; float *qM=quantized[vi->coupling_mag[i]]; @@ -963,26 +1013,25 @@ void _vp_quantize_couple(vorbis_look_psy *p, for(;jlimit && jn;j++){ /* partition by partition; k is our by-location partition class counter */ + float ang,mag,fmag=max(fabs(pcmM[j]),fabs(pcmA[j])); - float Am=rint(pcmM[j]*igranulem)*granulem; - float Bm=rint(pcmA[j]*igranulem)*granulem; - float ang,mag,fmag=max(fabs(Am),fabs(Bm)); - if(fmagamppost_point){ - couple_point(Am,Bm,&mag,&ang); + couple_point(pcmM[j],pcmA[j],floorM[j],floorA[j], + granulem,igranulem,fmag,&mag,&ang); }else{ if(fmagamppost_6phase){ - couple_6phase(Am,Bm,&mag,&ang); + couple_6phase(pcmM[j],pcmA[j],floorM[j],floorA[j], + granulem,igranulem,fmag,&mag,&ang); }else{ if(fmagamppost_8phase){ - couple_8phase(Am,Bm,&mag,&ang); + couple_8phase(pcmM[j],pcmA[j],floorM[j],floorA[j], + granulem,igranulem,fmag,&mag,&ang); }else{ - couple_lossless(Am,Bm,&mag,&ang); + couple_lossless(pcmM[j],pcmA[j], + granulem,igranulem,&mag,&ang); } } } - fmag=rint(fmag); - if(ang>fmag*1.9999f)ang=-fmag*2.f; qM[j]=mag-sofarM[j]; qA[j]=ang-sofarA[j]; diff --git a/lib/psy.h b/lib/psy.h index 6c97dea..6bca7cb 100644 --- a/lib/psy.h +++ b/lib/psy.h @@ -11,7 +11,7 @@ ******************************************************************** function: random psychoacoustics (not including preecho) - last mod: $Id: psy.h,v 1.22 2001/08/13 01:36:57 xiphmont Exp $ + last mod: $Id: psy.h,v 1.23 2001/09/01 06:14:50 xiphmont Exp $ ********************************************************************/ @@ -61,16 +61,13 @@ typedef struct vp_attenblock{ float block[P_BANDS][P_LEVELS]; } vp_attenblock; +#define NOISE_COMPAND_LEVELS 40 typedef struct vorbis_info_psy{ float *ath; float ath_adjatt; float ath_maxatt; - /* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 */ - /* x: 63 88 125 175 250 350 500 700 1k 1.4k 2k 2.8k 4k 5.6k 8k 11.5k 16k Hz */ - /* y: 0 10 20 30 40 50 60 70 80 90 100 dB */ - float tone_masteratt; float tone_maxatt; vp_attenblock *toneatt; @@ -87,7 +84,7 @@ typedef struct vorbis_info_psy{ int noisewindowhimin; int noisewindowfixed; float noiseoff[P_BANDS]; - float noisethresh[P_BANDS]; + float *noisecompand; float max_curve_dB; diff --git a/lib/res0.c b/lib/res0.c index d2b29a6..a82ca27 100644 --- a/lib/res0.c +++ b/lib/res0.c @@ -11,7 +11,7 @@ ******************************************************************** function: residue backend 0, 1 and 2 implementation - last mod: $Id: res0.c,v 1.35 2001/08/13 11:33:39 xiphmont Exp $ + last mod: $Id: res0.c,v 1.36 2001/09/01 06:14:50 xiphmont Exp $ ********************************************************************/ @@ -71,10 +71,10 @@ void res0_free_look(vorbis_look_residue *i){ vorbis_look_residue0 *look=(vorbis_look_residue0 *)i; - /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n", + fprintf(stderr,"residue bit usage %f:%f (%f total)\n", (float)look->phrasebits/look->frames, (float)look->postbits/look->frames, - (float)(look->postbits+look->phrasebits)/look->frames);*/ + (float)(look->postbits+look->phrasebits)/look->frames); /*vorbis_info_residue0 *info=look->info; @@ -531,8 +531,8 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl, /* training hack */ if(valphrasebook->entries) ret=vorbis_book_encode(look->phrasebook,val,&vb->opb); - /*else - fprintf(stderr,"!");*/ + else + fprintf(stderr,"!"); look->phrasebits+=ret; @@ -567,7 +567,7 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl, 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); }*/ diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c index 710daae..da36ac4 100644 --- a/lib/vorbisenc.c +++ b/lib/vorbisenc.c @@ -11,7 +11,7 @@ ******************************************************************** function: simple programmatic interface for encoder mode setup - last mod: $Id: vorbisenc.c,v 1.13 2001/08/21 19:05:06 giles Exp $ + last mod: $Id: vorbisenc.c,v 1.14 2001/09/01 06:14:50 xiphmont Exp $ ********************************************************************/ @@ -133,6 +133,7 @@ int vorbis_encode_init(vorbis_info *vi, /* copy a mode into our allocated storage */ bpch=nominal_bitrate/channels; +#if 0 switch(channels){ case 2: /* if(rate>40000){ */ @@ -174,6 +175,9 @@ int vorbis_encode_init(vorbis_info *vi, } break; } +#endif + + mode=&info_44c_A; /* now we have to deepcopy */ codec_setup_partialcopy(ci,mode);