[xiph-cvs] cvs commit: vorbis/lib/modes mode_A.h
Monty
xiphmont at xiph.org
Tue Aug 7 12:50:03 PDT 2001
xiphmont 01/08/07 12:50:02
Modified: lib Tag: branch_monty_20010708 envelope.c psy.c psy.h
res0.c
lib/modes Tag: branch_monty_20010708 mode_A.h
Log:
Bugfixes, tweaks, minor coupling config rearrangement.
Monty
Revision Changes Path
No revision
No revision
1.36.2.2 +3 -3 vorbis/lib/envelope.c
Index: envelope.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.c,v
retrieving revision 1.36.2.1
retrieving revision 1.36.2.2
diff -u -r1.36.2.1 -r1.36.2.2
--- envelope.c 2001/07/08 08:48:01 1.36.2.1
+++ envelope.c 2001/08/07 19:50:00 1.36.2.2
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.36.2.1 2001/07/08 08:48:01 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.36.2.2 2001/08/07 19:50:00 xiphmont Exp $
Preecho calculation.
@@ -133,8 +133,8 @@
basing blocks on quantization noise that outweighs the signal
itself (for low power signals) */
- float min=ve->minenergy;
- float A=min*min*n;
+ float minV=ve->minenergy;
+ float A=minV*minV*n;
float B=A;
for(i=0;i<n;i++){
1.48.2.7 +66 -83 vorbis/lib/psy.c
Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.48.2.6
retrieving revision 1.48.2.7
diff -u -r1.48.2.6 -r1.48.2.7
--- psy.c 2001/08/07 03:47:22 1.48.2.6
+++ psy.c 2001/08/07 19:50:00 1.48.2.7
@@ -11,7 +11,7 @@
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.48.2.6 2001/08/07 03:47:22 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.48.2.7 2001/08/07 19:50:00 xiphmont Exp $
********************************************************************/
@@ -527,24 +527,24 @@
pos=p->octave[0]-p->firstoc-(linesper>>1);
while(linpos+1<p->n){
- float min=seed[pos];
+ float minV=seed[pos];
long end=((p->octave[linpos]+p->octave[linpos+1])>>1)-p->firstoc;
while(pos+1<=end){
pos++;
- if((seed[pos]>NEGINF && seed[pos]<min) || min==NEGINF)
- min=seed[pos];
+ if((seed[pos]>NEGINF && seed[pos]<minV) || minV==NEGINF)
+ minV=seed[pos];
}
/* seed scale is log. Floor is linear. Map back to it */
end=pos+p->firstoc;
for(;linpos<p->n && p->octave[linpos]<=end;linpos++)
- if(flr[linpos]<min)flr[linpos]=min;
+ if(flr[linpos]<minV)flr[linpos]=minV;
}
{
- float min=seed[p->total_octave_lines-1];
+ float minV=seed[p->total_octave_lines-1];
for(;linpos<p->n;linpos++)
- if(flr[linpos]<min)flr[linpos]=min;
+ if(flr[linpos]<minV)flr[linpos]=minV;
}
}
@@ -1005,110 +1005,84 @@
return(amp);
}
-static void couple_lossless(float A, float B, float *mag, float *ang,float t){
- float fmag;
-
+static void couple_lossless(float A, float B, float *mag, float *ang){
if(fabs(A)>fabs(B)){
- fmag=fabs(*mag=A); *ang=(A>0.f?A-B:B-A);
+ *mag=A; *ang=(A>0.f?A-B:B-A);
}else{
- fmag=fabs(*mag=B); *ang=(B>0.f?A-B:B-A);
+ *mag=B; *ang=(B>0.f?A-B:B-A);
}
-
- if(*ang>fmag*1.9999f)*ang=-fmag*2.f;
-
}
-static void couple_8phase(float A, float B, float *mag, float *ang,float t){
- float fmag;
+static void couple_Nphase(float A, float B, float Aa, float Ba,
+ float *mag, float *ang){
+ if(fabs(A)>fabs(B)){
+ *mag=A;*ang=(A>0.f?Aa-Ba:Ba-Aa);
+ }else{
+ *mag=B;*ang=(B>0.f?Aa-Ba:Ba-Aa);
+ }
+}
+static void couple_8phase(float A, float B, float *mag, float *ang){
if(fabs(A)>fabs(B)){
- fmag=fabs(*mag=A); *ang=(A>0?A-B:B-A);
+ *mag=A; *ang=(A>0?A-B:B-A);
}else{
- fmag=fabs(*mag=B); *ang=(B>0?A-B:B-A);
+ *mag=B; *ang=(B>0?A-B:B-A);
}
- if(fmag>0.f)
- switch((int)(rint(*ang/fmag))){
+ if(*mag!=0.f)
+ switch((int)(rint(*ang / *mag))){
case 0:
- if(fmag>t){
- if(*ang>fmag-t)*ang=fmag-t;
- if(*ang<t-fmag)*ang=t-fmag;
- }else{
- *ang=0;
- }
+ *ang=0;
break;
case 2:case -2:
- *ang=-2*fmag;
+ *ang=-2*fabs(*mag);
break;
case 1:
- *ang=fmag;
+ *ang= *mag;
break;
case -1:
- *ang=-fmag;
+ *ang= -*mag;
break;
}
}
-static void couple_6phase(float A, float B, float *mag, float *ang,float t){
- float fmag;
-
+static void couple_6phase(float A, float B, float *mag, float *ang){
if(fabs(A)>fabs(B)){
- fmag=fabs(*mag=A); *ang=(A>0?A-B:B-A);
+ *mag=A; *ang=(A>0?A-B:B-A);
}else{
- fmag=fabs(*mag=B); *ang=(B>0?A-B:B-A);
+ *mag=B; *ang=(B>0?A-B:B-A);
}
- if(fmag>0.f)
- switch((int)(rint(*ang/fmag))){
+ if(*mag!=0.f)
+ switch((int)(rint(*ang / *mag))){
case -2:case 2:
- *ang=0;
*mag=0;
- break;
+ /*fall*/
case 0:
- if(fmag>t){
- if(*ang>fmag-t)*ang=fmag-t;
- if(*ang<t-fmag)*ang=t-fmag;
- }else{
- *ang=0;
- }
+ *ang=0;
break;
case 1:
- *ang=fmag;
+ *ang= *mag;
break;
case -1:
- *ang=-fmag;
+ *ang= -*mag;
break;
}
}
-static void couple_point(float A, float B, float *mag, float *ang,float t){
- float fmag;
-
+static void couple_point(float A, float B, float *mag, float *ang){
if(fabs(A)>fabs(B)){
- fmag=fabs(*mag=A); *ang=(A>0?A-B:B-A);
+ *mag=A; *ang=(A>0?A-B:B-A);
}else{
- fmag=fabs(*mag=B); *ang=(B>0?A-B:B-A);
+ *mag=B; *ang=(B>0?A-B:B-A);
}
-
- if(fmag>0.f)
- switch((int)(rint(*ang/fmag))){
- case 0:
- if(fmag>t){
- if(*ang>fmag-t)*ang=fmag-t;
- if(*ang<t-fmag)*ang=t-fmag;
- }else{
- *ang=0;
- }
- break;
- case 1:
- case -1:
- *ang=0;
- break;
-
- case -2:
- case 2:
+ if(*mag!=0.f)
+ switch((int)(rint(*ang / *mag))){
+ case -2:case 2:
*mag=0;
+ /* fall */
+ case 0:case 1: case -1:
*ang=0;
break;
}
@@ -1124,8 +1098,6 @@
int i,j,k,n=p->n;
vorbis_info_psy *info=p->vi;
- float granule=info->couple_pass[passno].granule;
- float igranule=info->couple_pass[passno].igranule;
/* perform any requested channel coupling */
for(i=0;i<vi->coupling_steps;i++){
@@ -1146,28 +1118,39 @@
nonzero[vi->coupling_ang[i]]=1;
for(j=0,k=0;j<n;k++){
- vp_couple *part=info->couple_pass[passno].couple+k;
+ vp_couple *part=info->couple_pass[passno].couple_pass+k;
for(;j<part->limit && j<p->n;j++){
/* partition by partition; k is our by-location partition
class counter */
- float ang,mag=max(fabs(pcmM[j]),fabs(pcmA[j]));
- float M=rint(pcmM[j]*igranule)*granule;
- float A=rint(pcmA[j]*igranule)*granule;
+
+ float granulem=part->granulem;
+ float igranulem=part->igranulem;
+
+ float Am=rint(pcmM[j]*igranulem)*granulem;
+ float Bm=rint(pcmA[j]*igranulem)*granulem;
+ float ang,mag,fmag=max(fabs(Am),fabs(Bm));
- if(mag<part->couple_point.amppost){
- couple_point(M,A,&mag,&ang,part->couple_point.threshhold);
+ if(fmag<part->amppost_point){
+ couple_point(Am,Bm,&mag,&ang);
}else{
- if(mag<part->couple_sixphase.amppost){
- couple_6phase(M,A,&mag,&ang,part->couple_point.threshhold);
+ if(fmag<part->amppost_6phase){
+ couple_6phase(Am,Bm,&mag,&ang);
}else{
- if(mag<part->couple_eightphase.amppost){
- couple_8phase(M,A,&mag,&ang,part->couple_point.threshhold);
+ if(fmag<part->amppost_8phase){
+ couple_8phase(Am,Bm,&mag,&ang);
}else{
- couple_lossless(M,A,&mag,&ang,part->couple_point.threshhold);
+ if(fmag<part->amppost_Nphase){
+ float Aa=rint(pcmM[j]*part->igranulea)*part->granulea;
+ float Ba=rint(pcmA[j]*part->igranulea)*part->granulea;
+ couple_Nphase(Am,Bm,Aa,Ba,&mag,&ang);
+ }else{
+ couple_lossless(Am,Bm,&mag,&ang);
+ }
}
}
}
+ if(ang>fmag*1.9999f)ang=-fmag*2.f;
qM[j]=mag-sofarM[j];
qA[j]=ang-sofarA[j];
1.21.2.6 +12 -15 vorbis/lib/psy.h
Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.21.2.5
retrieving revision 1.21.2.6
diff -u -r1.21.2.5 -r1.21.2.6
--- psy.h 2001/08/07 03:47:22 1.21.2.5
+++ psy.h 2001/08/07 19:50:00 1.21.2.6
@@ -11,7 +11,7 @@
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.21.2.5 2001/08/07 03:47:22 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.21.2.6 2001/08/07 19:50:00 xiphmont Exp $
********************************************************************/
@@ -36,26 +36,23 @@
#define P_BANDS 17
#define P_LEVELS 11
-typedef struct couple_part{
- float amppost;
- float threshhold;
-} couple_part;
-
typedef struct vp_couple{
int limit; /* sample post */
- couple_part couple_lossless;
- couple_part couple_eightphase;
- couple_part couple_sixphase;
- couple_part couple_point;
+ float granulem;
+ float igranulem;
+ float granulea;
+ float igranulea;
+
+ float amppost_Nphase;
+ float amppost_8phase;
+ float amppost_6phase;
+ float amppost_point;
} vp_couple;
-typedef struct vp_couple_pass{
- float granule;
- float igranule;
-
- vp_couple couple[8];
+typedef struct vp_couple_pass{
+ vp_couple couple_pass[8];
} vp_couple_pass;
typedef struct vp_attenblock{
1.32.2.4 +22 -3 vorbis/lib/res0.c
Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.32.2.3
retrieving revision 1.32.2.4
diff -u -r1.32.2.3 -r1.32.2.4
--- res0.c 2001/08/02 22:14:21 1.32.2.3
+++ res0.c 2001/08/07 19:50:00 1.32.2.4
@@ -11,7 +11,7 @@
********************************************************************
function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.32.2.3 2001/08/02 22:14:21 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.32.2.4 2001/08/07 19:50:00 xiphmont Exp $
********************************************************************/
@@ -488,6 +488,12 @@
int n=info->end-info->begin;
int partvals=n/samples_per_partition;
+
+ long resbits[possible_partitions];
+ long resvals[possible_partitions];
+ memset(resbits,0,sizeof(resbits));
+ memset(resvals,0,sizeof(resvals));
+
#ifdef TRAIN_RES
FILE *of;
@@ -539,20 +545,33 @@
long offset=i*samples_per_partition+info->begin;
for(j=0;j<ch;j++){
- /*if(s==0)look->resvals[partword[j][i]]++;*/
+ if(s==0)resvals[partword[j][i]]+=samples_per_partition;
if(info->secondstages[partword[j][i]]&(1<<s)){
codebook *statebook=look->partbooks[partword[j][i]][s];
if(statebook){
int ret=encode(&vb->opb,in[j]+offset,samples_per_partition,
statebook,look);
- /*look->resbits[partword[j][i]][s]+=ret;*/
look->postbits+=ret;
+ resbits[partword[j][i]]+=ret;
}
}
}
}
}
+ }
+
+ {
+ long total=0;
+ long totalbits=0;
+ fprintf(stderr,"%d :: ",vb->mode);
+ for(k=0;k<possible_partitions;k++){
+ fprintf(stderr,"%d/%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);
}
No revision
No revision
1.14.4.5.2.5 +11 -7 vorbis/lib/modes/mode_A.h
Index: mode_A.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/modes/mode_A.h,v
retrieving revision 1.14.4.5.2.4
retrieving revision 1.14.4.5.2.5
diff -u -r1.14.4.5.2.4 -r1.14.4.5.2.5
--- mode_A.h 2001/08/07 05:03:20 1.14.4.5.2.4
+++ mode_A.h 2001/08/07 19:50:02 1.14.4.5.2.5
@@ -11,7 +11,7 @@
********************************************************************
function: predefined encoding modes
- last mod: $Id: mode_A.h,v 1.14.4.5.2.4 2001/08/07 05:03:20 xiphmont Exp $
+ last mod: $Id: mode_A.h,v 1.14.4.5.2.5 2001/08/07 19:50:02 xiphmont Exp $
********************************************************************/
@@ -78,15 +78,19 @@
0,
};
-static vp_couple_pass _psy_passA0[]={
- {1.f,1.f, { {24, {9e10f,0.f}, {0.f,0.f}, {0.f,0.f}, {0.f,0.f}},
- {9999, {0.f,0.f}, {0.f,0.f}, {9e10f,12.f}, {0.f,0.f}} },
- }
+static struct vp_couple_pass _psy_passA0[]={
+ {
+ {{24, 1.f,1.f, 1.f,1.f, 0, 0, 0, 0},
+ {128, 1.f,1.f, 2.f,.5f, 22.f, 0.0f, 4.5f, 0.0f},
+ {9999, 1.f,1.f, 2.f,.5f, 22.f, 0.0f, 4.5f, 2.5f}}
+ },
};
static vp_couple_pass _psy_passA[]={
- {1.f,1.f, { {192, {9e10f,0.f}, {0.f,0.f}, {0.f,0.f}, {0.f,0.f}},
- {9999, {0.f,0.f}, {0.f,0.f}, {9e10f,12.f}, {0.f,0.f}} },
+ {
+ {{288, 1.f,1.f, 1.f,1.f, 0, 0, 0, 0},
+ {512, 1.f,1.f, 2.f,.5f, 22.f, 0.0f, 4.5f, 0.0f},
+ {9999, 1.f,1.f, 2.f,.5f, 22.f, 0.0f, 4.5f, 2.5f}}
}
};
@@ -203,7 +207,7 @@
10,10,100,
/*63 125 250 500 1k 2k 4k 8k 16k*/
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, -3, 0, 0, 0, 0, 0},
+ {-10,-10,-10,-10,-10,-10,-10, 0, 0, 0, -3, -3, 0, 0, 0, 0, 0},
{.3f,.3f,.3f,.3f,.3f,.3f,.3f,.3f,.5f,.5f,.5f,.5f,.7f,.75f,.8f,.8f,.8f},
95.f, /* even decade + 5 is important; saves an rint() later in a
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list