[xiph-cvs] cvs commit: vorbis/vq bookutil.c distribution.c huffbuild.c
Monty
xiphmont at xiph.org
Fri May 11 15:07:56 PDT 2001
xiphmont 01/05/11 15:07:55
Modified: lib Tag: monty-branch-20010404 analysis.c backends.h
codebook.c envelope.c floor0.c floor1.c mapping0.c
psy.c psy.h psytune.c registry.c registry.h res0.c
scales.h
lib/modes Tag: monty-branch-20010404 mode_A.h
vq Tag: monty-branch-20010404 bookutil.c
distribution.c huffbuild.c
Log:
Another ongoing update. floor1 code being cleaned up, res1 begun,
first cascading work also begun.
Monty
Revision Changes Path
No revision
No revision
1.43.4.2 +23 -20 vorbis/lib/analysis.c
Index: analysis.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/analysis.c,v
retrieving revision 1.43.4.1
retrieving revision 1.43.4.2
diff -u -r1.43.4.1 -r1.43.4.2
--- analysis.c 2001/04/05 00:22:48 1.43.4.1
+++ analysis.c 2001/05/11 22:07:49 1.43.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.43.4.1 2001/04/05 00:22:48 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.43.4.2 2001/05/11 22:07:49 xiphmont Exp $
********************************************************************/
@@ -79,28 +79,31 @@
int j;
FILE *of;
char buffer[80];
- sprintf(buffer,"%s_%d.m",base,i);
- of=fopen(buffer,"w");
- if(!of)perror("failed to open data dump file");
-
- for(j=0;j<n;j++){
- if(dB && v[j]==0)
- fprintf(of,"\n\n");
- else{
- if(bark)
- fprintf(of,"%g ",toBARK(22050.f*j/n));
- else
- fprintf(of,"%g ",(double)j);
-
- if(dB){
- fprintf(of,"%g\n",todB(fabs(v[j])));
- }else{
- fprintf(of,"%g\n",v[j]);
+ // if(i==5870){
+ sprintf(buffer,"%s_%d.m",base,i);
+ of=fopen(buffer,"w");
+
+ if(!of)perror("failed to open data dump file");
+
+ for(j=0;j<n;j++){
+ if(dB && v[j]==0)
+ fprintf(of,"\n\n");
+ else{
+ if(bark)
+ fprintf(of,"%g ",toBARK(22050.f*j/n));
+ else
+ fprintf(of,"%g ",(double)j);
+
+ if(dB){
+ fprintf(of,"%g\n",todB(v+j));
+ }else{
+ fprintf(of,"%g\n",v[j]);
+ }
}
}
- }
- fclose(of);
+ fclose(of);
+ // }
}
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB){
1.6.4.3 +16 -6 vorbis/lib/backends.h
Index: backends.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/backends.h,v
retrieving revision 1.6.4.2
retrieving revision 1.6.4.3
diff -u -r1.6.4.2 -r1.6.4.3
--- backends.h 2001/04/29 22:21:04 1.6.4.2
+++ backends.h 2001/05/11 22:07:49 1.6.4.3
@@ -12,7 +12,7 @@
function: libvorbis backend and mapping structures; needed for
static mode headers
- last mod: $Id: backends.h,v 1.6.4.2 2001/04/29 22:21:04 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.6.4.3 2001/05/11 22:07:49 xiphmont Exp $
********************************************************************/
@@ -61,7 +61,9 @@
void (*free_info) (vorbis_info_floor *);
void (*free_look) (vorbis_look_floor *);
int (*forward) (struct vorbis_block *,vorbis_look_floor *,
- float *);
+ const float *, const float *, /* in */
+ const float *, const float *, /* in */
+ float *, float *); /* out */
int (*inverse) (struct vorbis_block *,vorbis_look_floor *,
float *);
} vorbis_func_floor;
@@ -98,11 +100,19 @@
int mult; /* 1 2 3 or 4 */
int postlist[VIF_POSIT+2]; /* first two implicit */
+
+ /* encode side analysis parameters */
+ float maxover;
+ float maxunder;
+ float maxerr;
+
+ int twofitminsize;
+ int twofitminused;
+ int twofitweight;
+ float twofitatten;
+ int unusedminsize;
+ int unusedmin_n;
- float maxover; /* encode side analysis parameter */
- float maxunder; /* encode side analysis parameter */
- float maxerr; /* encode side analysis parameter */
- int searchstart; /* encode side analysis parameter */
} vorbis_info_floor1;
/* Residue backend generic *****************************************/
1.23.4.1 +2 -2 vorbis/lib/codebook.c
Index: codebook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codebook.c,v
retrieving revision 1.23
retrieving revision 1.23.4.1
diff -u -r1.23 -r1.23.4.1
--- codebook.c 2001/02/26 03:50:41 1.23
+++ codebook.c 2001/05/11 22:07:49 1.23.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.23 2001/02/26 03:50:41 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.23.4.1 2001/05/11 22:07:49 xiphmont Exp $
********************************************************************/
@@ -40,7 +40,7 @@
length random. Decide between the two now. */
for(i=1;i<c->entries;i++)
- if(c->lengthlist[i]<c->lengthlist[i-1])break;
+ if(c->lengthlist[i-1]==0 || c->lengthlist[i]<c->lengthlist[i-1])break;
if(i==c->entries)ordered=1;
if(ordered){
1.35.4.1 +3 -3 vorbis/lib/envelope.c
Index: envelope.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.c,v
retrieving revision 1.35
retrieving revision 1.35.4.1
diff -u -r1.35 -r1.35.4.1
--- envelope.c 2001/02/26 03:50:41 1.35
+++ envelope.c 2001/05/11 22:07:49 1.35.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.35 2001/02/26 03:50:41 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.35.4.1 2001/05/11 22:07:49 xiphmont Exp $
Preecho calculation.
@@ -141,8 +141,8 @@
B+=post[i]*post[i];
}
- A=todB(A);
- B=todB(B);
+ A=todB(&A);
+ B=todB(&B);
return(B-A);
}
1.39.4.3 +25 -21 vorbis/lib/floor0.c
Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor0.c,v
retrieving revision 1.39.4.2
retrieving revision 1.39.4.3
diff -u -r1.39.4.2 -r1.39.4.3
--- floor0.c 2001/04/29 22:21:04 1.39.4.2
+++ floor0.c 2001/05/11 22:07:49 1.39.4.3
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.39.4.2 2001/04/29 22:21:04 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.39.4.3 2001/05/11 22:07:49 xiphmont Exp $
********************************************************************/
@@ -251,13 +251,12 @@
return vorbis_lpc_from_curve(work,lpc,&(l->lpclook));
}
-/* generate the whole freq response curve of an LSP IIR filter */
-/* didn't need in->out seperation, modifies the flr[] vector; takes in
- a dB scale floor, puts out linear */
-static int floor0_forward(vorbis_block *vb,vorbis_look_floor *i,
- float *flr){
+static int floor0_forward(vorbis_block *vb,vorbis_look_floor *in,
+ const float *mdct, const float *logmdct, /* in */
+ const float *logmask, const float *logmax, /* in */
+ float *residue, float *codedflr){ /* out */
long j;
- vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)in;
vorbis_info_floor0 *info=look->vi;
float amp;
long bits=0;
@@ -282,11 +281,11 @@
positive, so we offset it. */
for(j=0;j<look->n;j++)
- flr[j]+=info->ampdB;
+ codedflr[j]=logmask[j]+info->ampdB;
/* use 'out' as temp storage */
/* Convert our floor to a set of lpc coefficients */
- amp=sqrt(_curve_to_lpc(flr,flr,look));
+ amp=sqrt(_curve_to_lpc(codedflr,codedflr,look));
/* amp is in the range (0. to ampdB]. Encode that range using
ampbits bits */
@@ -307,8 +306,8 @@
if(val){
/* LSP <-> LPC is orthogonal and LSP quantizes more stably */
- _analysis_output("lpc",seq-1,flr,look->m,0,0);
- if(vorbis_lpc_to_lsp(flr,flr,look->m))
+ _analysis_output("lpc",seq-1,codedflr,look->m,0,0);
+ if(vorbis_lpc_to_lsp(codedflr,codedflr,look->m))
val=0;
}
@@ -324,15 +323,15 @@
codebook *b;
int booknum;
- _analysis_output("lsp",seq-1,flr,look->m,0,0);
+ _analysis_output("lsp",seq-1,codedflr,look->m,0,0);
/* which codebook to use? We do it only by range right now. */
if(info->numbooks>1){
float last=0.;
for(j=0;j<look->m;j++){
- float val=flr[j]-last;
+ float val=codedflr[j]-last;
if(val<info->lessthan || val>info->greaterthan)break;
- last=flr[j];
+ last=codedflr[j];
}
if(j<look->m)
booknum=0;
@@ -349,8 +348,8 @@
{
float last=0.f;
for(j=0;j<look->m;j++){
- fprintf(of,"%.12g, ",flr[j]-last);
- last=flr[j];
+ fprintf(of,"%.12g, ",codedflr[j]-last);
+ last=codedflr[j];
}
}
fprintf(of,"\n");
@@ -366,7 +365,7 @@
nailed to the last quantized value of the previous block. */
for(j=0;j<look->m;j+=b->dim){
- int entry=_f0_fit(b,flr,lspwork,j);
+ int entry=_f0_fit(b,codedflr,lspwork,j);
bits+=vorbis_book_encode(b,entry,&vb->opb);
#ifdef TRAIN_LSP
@@ -382,11 +381,16 @@
_analysis_output("lsp2",seq-1,lspwork,look->m,0,0);
/* take the coefficients back to a spectral envelope curve */
- vorbis_lsp_to_curve(flr,look->linearmap,look->n,look->ln,
+ vorbis_lsp_to_curve(codedflr,look->linearmap,look->n,look->ln,
lspwork,look->m,amp,info->ampdB);
+
+ _analysis_output("barklsp",seq-1,codedflr,look->n,1,1);
+ _analysis_output("lsp3",seq-1,codedflr,look->n,0,1);
- _analysis_output("barklsp",seq-1,flr,look->n,1,1);
- _analysis_output("lsp3",seq-1,flr,look->n,0,1);
+ /* generate residue output */
+ for(j=0;j<look->n;j++)
+ residue[j]=mdct[j]/codedflr[j];
+
return(val);
}
@@ -394,7 +398,7 @@
fclose(of);
#endif
- memset(flr,0,sizeof(float)*look->n);
+ memset(codedflr,0,sizeof(float)*look->n);
return(val);
}
1.1.2.5 +209 -159 vorbis/lib/Attic/floor1.c
Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Attic/floor1.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- floor1.c 2001/05/02 22:14:06 1.1.2.4
+++ floor1.c 2001/05/11 22:07:49 1.1.2.5
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.1.2.4 2001/05/02 22:14:06 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.1.2.5 2001/05/11 22:07:49 xiphmont Exp $
********************************************************************/
@@ -30,7 +30,7 @@
#define VORBIS_IEEE_FLOAT32
-#define floor1_rangedB 140 /* floor 0 fixed at -140dB to 0dB range */
+#define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
typedef struct {
@@ -45,6 +45,13 @@
int n;
int quant_q;
vorbis_info_floor1 *vi;
+
+
+ long seq;
+ long postbits;
+ long classbits;
+ long subbits;
+ float mse;
} vorbis_look_floor1;
typedef struct lsfit_acc{
@@ -55,12 +62,37 @@
long ya;
long x2a;
long y2a;
- long xya;
+ long xya;
long n;
+ long an;
+ long un;
long edgey0;
long edgey1;
} lsfit_acc;
+static void vorbis_msecheck(vorbis_look_floor1 *look,
+ const float *flr,const float *mdct,
+ const float *out,int n){
+ float fn=22050./n;
+ float lastbark=toBARK(0);
+ float att=look->vi->twofitatten;
+ int i;
+ float count=0;
+ float mse=0;
+ for(i=0;i<n;i++){
+ float bark=toBARK((i+1)*fn);
+ if(mdct[i]+att>=flr[i]){
+ float imse=(todB(out+i)-flr[i]);
+ imse*=imse;
+ mse+=imse*(bark-lastbark);
+ count+=(bark-lastbark);
+ }
+ lastbark=bark;
+ }
+
+ if(count)look->mse+=mse/count;
+}
+
/***********************************************/
static vorbis_info_floor *floor1_copy_info (vorbis_info_floor *i){
@@ -80,6 +112,11 @@
static void floor1_free_look(vorbis_look_floor *i){
vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
if(i){
+ fprintf(stderr,"floor 1 bit usage: %ld:%ld:%ld (%ld/frame), mse:%gdB\n",
+ look->postbits/look->seq,look->classbits/look->seq,look->subbits/look->seq,
+ (look->postbits+look->subbits+look->classbits)/look->seq,
+ sqrt(look->mse/look->seq));
+
memset(look,0,sizeof(vorbis_look_floor1));
free(i);
}
@@ -421,7 +458,7 @@
};
#ifdef VORBIS_IEEE_FLOAT32
-static int vorbis_floor1_dBquant(float *x){
+static int vorbis_floor1_dBquant(const float *x){
float temp=*x-256.f;
ogg_uint32_t *i=(ogg_uint32_t *)(&temp);
if(*i<(ogg_uint32_t)0xc3800000)return(1023);
@@ -429,7 +466,7 @@
return FLOOR_quantdB_LOOKUP[(*i-0xc3800000)>>13];
}
#else
-static int vorbis_floor1_dBquant(float *x){
+static int vorbis_floor1_dBquant(const float *x){
int i= ((*x)+140.)/140.*1024.+.5;
if(i>1023)return(1023);
if(i<0)return(0);
@@ -463,49 +500,89 @@
}
/* the floor has already been filtered to only include relevant sections */
-static int accumulate_fit(float *floor,int x0, int x1,lsfit_acc *a,int n){
+static int accumulate_fit(const float *flr,const float *mdct,
+ int x0, int x1,lsfit_acc *a,
+ int n,vorbis_info_floor1 *info){
long i;
+ int quantized=vorbis_floor1_dBquant(flr);
+ long xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
+
memset(a,0,sizeof(lsfit_acc));
a->x0=x0;
a->x1=x1;
- a->edgey0=-999;
+ a->edgey0=quantized;
+ if(x1>n)x1=n;
for(i=x0;i<x1;i++){
- int quantized=vorbis_floor1_dBquant(floor+i);
- if(quantized){
- a->xa += i;
- a->ya += quantized;
- a->x2a += (i*i);
- a->y2a += quantized*quantized;
- a->xya += i*quantized;
- a->n++;
- if(i==x0)
- a->edgey0=quantized;
+ int quantized=vorbis_floor1_dBquant(flr+i);
+ if(mdct[i]+info->twofitatten>=flr[i]){
+ xa += i;
+ ya += quantized;
+ x2a += i*i;
+ y2a += quantized*quantized;
+ xya += i*quantized;
+ na++;
+ }else{
+ xb += i;
+ yb += quantized;
+ x2b += i*i;
+ y2b += quantized*quantized;
+ xyb += i*quantized;
+ nb++;
+ }
+ }
+
+ xb+=xa;
+ yb+=ya;
+ x2b+=x2a;
+ y2b+=y2a;
+ xyb+=xya;
+ nb+=na;
+
+ /* weight toward the actually used frequencies if we meet the threshhold */
+ {
+ int weight;
+ if(nb<info->twofitminsize || na<info->twofitminused){
+ weight=0;
+ }else{
+ weight=nb*info->twofitweight/na;
}
+ a->xa=xa*weight+xb;
+ a->ya=ya*weight+yb;
+ a->x2a=x2a*weight+x2b;
+ a->y2a=y2a*weight+y2b;
+ a->xya=xya*weight+xyb;
+ a->an=na*weight+nb;
+ a->n=nb;
+ a->un=na;
+ if(nb>=info->unusedminsize)a->un++;
}
- a->edgey1=-999;
+
+ a->edgey1=-200;
if(x1<n){
- int quantized=vorbis_floor1_dBquant(floor+i);
- if(quantized)
- a->edgey1=quantized;
+ int quantized=vorbis_floor1_dBquant(flr+i);
+ a->edgey1=quantized;
}
return(a->n);
}
/* returns < 0 on too few points to fit, >=0 (meansq error) on success */
static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1){
- long x=0,y=0,x2=0,y2=0,xy=0,n=0,i;
+ long x=0,y=0,x2=0,y2=0,xy=0,n=0,an=0,i;
long x0=a[0].x0;
long x1=a[fits-1].x1;
for(i=0;i<fits;i++){
- x+=a[i].xa;
- y+=a[i].ya;
- x2+=a[i].x2a;
- y2+=a[i].y2a;
- xy+=a[i].xya;
- n+=a[i].n;
+ if(a[i].un){
+ x+=a[i].xa;
+ y+=a[i].ya;
+ x2+=a[i].x2a;
+ y2+=a[i].y2a;
+ xy+=a[i].xya;
+ n+=a[i].n;
+ an+=a[i].an;
+ }
}
if(*y0>=0){ /* hint used to break degenerate cases */
@@ -515,6 +592,7 @@
y2+= *y0 * *y0;
xy+= *y0 * x0;
n++;
+ an++;
}
if(*y1>=0){ /* hint used to break degenerate cases */
@@ -524,16 +602,10 @@
y2+= *y1 * *y1;
xy+= *y1 * x1;
n++;
+ an++;
}
-
- switch(n){
- case 0:
- return(-3);
- case 1:
- if(a[0].edgey0>=0)return(-1);
- return(-2);
- }
+ if(n<2)return(n-2);
{
/* need 64 bit multiplies, which C doesn't give portably as int */
@@ -542,13 +614,19 @@
double fx2=x2;
double fy2=y2;
double fxy=xy;
- double a=(fy*fx2-fxy*fx)/(n*fx2-fx*fx);
- double b=(n*fxy-fx*fy)/(n*fx2-fx*fx);
- int s=rint((a*a*n + a*b*(2*fx) - a*(2*fy) + b*b*fx2 - b*(2*fxy) + fy2)/(n*n));
- if(s<0)s=0;
+ double denom=1./(an*fx2-fx*fx);
+ double a=(fy*fx2-fxy*fx)*denom;
+ double b=(an*fxy-fx*fy)*denom;
*y0=rint(a+b*x0);
*y1=rint(a+b*x1);
- return(s);
+
+ /* limit to our range! */
+ if(*y0>1023)*y0=1023;
+ if(*y1>1023)*y1=1023;
+ if(*y0<0)*y0=0;
+ if(*y1<0)*y1=0;
+
+ return(0);
}
}
@@ -562,7 +640,8 @@
*y0=*y1=y;
}
-static int inspect_error(int x0,int x1,int y0,int y1,float *flr,
+static int inspect_error(int x0,int x1,int y0,int y1,const float *flr,
+ const float *mdct,
vorbis_info_floor1 *info){
int dy=y1-y0;
int adx=x1-x0;
@@ -572,13 +651,13 @@
int x=x0;
int y=y0;
int err=0;
- int mse=0;
int val=vorbis_floor1_dBquant(flr+x);
+ int mse=0;
int n=0;
ady-=abs(base*adx);
- if(val){
+ if(mdct[x]+info->twofitatten>=flr[x]){
if(y+info->maxover<val)return(1);
if(y-info->maxunder>val)return(1);
mse=(y-val);
@@ -595,15 +674,19 @@
y+=base;
}
- val=vorbis_floor1_dBquant(flr+x);
- if(val){
- if(y+info->maxover<val)return(1);
- if(y-info->maxunder>val)return(1);
- mse+=((y-val)*(y-val));
- n++;
+ if(mdct[x]+info->twofitatten>=flr[x]){
+ val=vorbis_floor1_dBquant(flr+x);
+ if(val){
+ if(y+info->maxover<val)return(1);
+ if(y-info->maxunder>val)return(1);
+ mse+=((y-val)*(y-val));
+ n++;
+ }
}
}
+ if(info->maxover*info->maxover/n>info->maxerr)return(0);
+ if(info->maxunder*info->maxunder/n>info->maxerr)return(0);
if(mse/n>info->maxerr)return(1);
return(0);
}
@@ -616,10 +699,10 @@
return (A[pos]+B[pos])>>1;
}
-/* didn't need in->out seperation, modifies the flr[] vector; takes in
- a dB scale floor, puts out linear */
static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in,
- float *flr){
+ const float *mdct, const float *logmdct, /* in */
+ const float *logmask, const float *logmax, /* in */
+ float *residue, float *codedflr){ /* out */
static int seq=0;
long i,j,k,l;
vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
@@ -645,28 +728,36 @@
for(i=0;i<posts;i++)hineighbor[i]=1; /* 1 for the implicit post at n */
for(i=0;i<posts;i++)memo[i]=-1; /* no neighbor yet */
+ /* Scan back from high edge to first 'used' frequency */
+ for(;n>info->unusedmin_n;n--)
+ if(logmdct[n-1]>-floor1_rangedB &&
+ logmdct[n-1]+info->twofitatten>logmask[n-1])break;
+
/* quantize the relevant floor points and collect them into line fit
structures (one per minimal division) at the same time */
if(posts==0){
- nonzero+=accumulate_fit(flr,0,n,fits,n);
+ nonzero+=accumulate_fit(logmask,logmdct,0,n,fits,n,info);
}else{
for(i=0;i<posts-1;i++)
- nonzero+=accumulate_fit(flr,look->sorted_index[i],
- look->sorted_index[i+1],fits+i,n);
+ nonzero+=accumulate_fit(logmask,logmdct,look->sorted_index[i],
+ look->sorted_index[i+1],fits+i,
+ n,info);
}
if(nonzero){
/* start by fitting the implicit base case.... */
- int y0=-999;
- int y1=-999;
+ int y0=-200;
+ int y1=-200;
int mse=fit_line(fits,posts-1,&y0,&y1);
if(mse<0){
/* Only a single nonzero point */
- y0=-999;
+ y0=-200;
y1=0;
fit_line(fits,posts-1,&y0,&y1);
}
+ look->seq++;
+
fit_flag[0]=1;
fit_flag[1]=1;
fit_valueA[0]=y0;
@@ -694,14 +785,14 @@
/* if this is an empty segment, its endpoints don't matter.
Mark as such */
for(j=lsortpos;j<hsortpos;j++)
- if(fits[j].n)break;
+ if(fits[j].un)break;
if(j==hsortpos){
/* empty segment; important to note that this does not
break 0/n post case */
- fit_valueB[ln]=-999;
+ fit_valueB[ln]=-200;
if(fit_valueA[ln]<0)
fit_flag[ln]=0;
- fit_valueA[hn]=-999;
+ fit_valueA[hn]=-200;
if(fit_valueB[hn]<0)
fit_flag[hn]=0;
@@ -712,18 +803,19 @@
int ly=post_Y(fit_valueA,fit_valueB,ln);
int hy=post_Y(fit_valueA,fit_valueB,hn);
- if(i<info->searchstart ||
- inspect_error(lx,hx,ly,hy,flr,info)){
+ if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){
/* outside error bounds/begin search area. Split it. */
- int ly0=-999;
- int ly1=-999;
- int hy0=-999;
- int hy1=-999;
+ int ly0=-200;
+ int ly1=-200;
+ int hy0=-200;
+ int hy1=-200;
int lmse=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
int hmse=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- /* the boundary/sparsity cases are the hard part. Pay
- them detailed attention */
+ /* the boundary/sparsity cases are the hard part. They
+ don't happen often given that we use the full mask
+ curve (weighted) now, but when they do happen they
+ can go boom. Pay them detailed attention */
/* cases for a segment:
>=0) normal fit (>=2 unique points)
-1) one point on x0;
@@ -732,71 +824,22 @@
-3) no points */
switch(lmse){
- case -3:
+ case -2:
/* no points in the low segment */
break;
case -1:
ly0=fits[lsortpos].edgey0;
break;
- case -2:
- if(fit_valueA[ln]>=0){
- ly0=fit_valueA[ln];
- fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
- }else{
- /* nothing preexisting to base lo on. look to hi */
- switch(hmse){
- case -3:
- /* nothing in hi either */
- fit_line_point(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
- break;
- case -2:case -1:
- /* one point in hi not on x1 */
- if(fit_valueB[hn]>=0){
- /* ah, something to base hi on */
- hy1=fit_valueB[hn];
- fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- ly1=hy0;
- fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
- }else{
- /* lo and hi are both in the midst of of
- emptiness. We don't need to split, just
- refit */
- fit_line(fits+sortpos,hsortpos-lsortpos,&ly0,&hy1);
- }
- break;
- default:
- ly1=hy0;
- fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
- break;
- }
- }
- break;
default:
}
switch(hmse){
- case -3:
+ case -2:
/* no points in the hi segment */
break;
case -1:
hy0=fits[sortpos].edgey0;
break;
- case -2: /* one point in middle */
- if(fit_valueB[hn]>=0){
- hy1=fit_valueB[hn];
- fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- }else{
- /* nothing preexisting to base hi on. look to lo */
- if(ly1>=0){
- hy0=ly1;
- fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- }else{
- /* nothing relevant in lo */
- fit_line_point(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- }
- }
- break;
- default:
}
/* store new edge values */
@@ -834,50 +877,27 @@
}
}
- /* generate quantized floor equivalent to what we'd unpack in decode */
- {
- int hx;
- int lx=0;
- int ly=(post_Y(fit_valueA,fit_valueB,0)+4)>>3;
-
- for(j=1;j<posts;j++){
- int current=look->forward_index[j];
- if(fit_flag[current]){
- int hy=(post_Y(fit_valueA,fit_valueB,current)+4)>>3;
- hx=info->postlist[current];
-
- render_line(lx,hx,ly*2,hy*2,flr);
-
- lx=hx;
- ly=hy;
- }
- }
- for(j=hx;j<n;j++)flr[j]=0.f; /* be certain */
- _analysis_output("infloor",seq,flr,n,0,1);
-
- }
-
/* quantize values to multiplier spec */
switch(info->mult){
case 1: /* 1024 -> 256 */
for(i=0;i<posts;i++)
if(fit_flag[i])
- fit_valueA[i]=(post_Y(fit_valueA,fit_valueB,i)+2)>>2;
+ fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>2;
break;
case 2: /* 1024 -> 128 */
for(i=0;i<posts;i++)
if(fit_flag[i])
- fit_valueA[i]=(post_Y(fit_valueA,fit_valueB,i)+4)>>3;
+ fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>3;
break;
case 3: /* 1024 -> 86 */
for(i=0;i<posts;i++)
if(fit_flag[i])
- fit_valueA[i]=(post_Y(fit_valueA,fit_valueB,i)+6)/12;
+ fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)/12;
break;
case 4: /* 1024 -> 64 */
for(i=0;i<posts;i++)
if(fit_flag[i])
- fit_valueA[i]=(post_Y(fit_valueA,fit_valueB,i)+8)>>4;
+ fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>4;
break;
}
@@ -900,10 +920,10 @@
int val=fit_valueA[i]-predicted;
/* at this point the 'deviation' value is in the range +/- max
- range, but the real, unique range can be mapped to only
- [0-maxrange). So we want to wrap the deviation into this
- limited range, but do it in the way that least screws an
- essentially gaussian probability distribution. */
+ range, but the real, unique range can always be mapped to
+ only [0-maxrange). So we want to wrap the deviation into
+ this limited range, but do it in the way that least screws
+ an essentially gaussian probability distribution. */
if(val<0)
if(val<-headroom)
@@ -941,8 +961,22 @@
oggpack_write(&vb->opb,1,1);
/* beginning/end post */
+ look->postbits+=ilog(look->quant_q-1)*2;
oggpack_write(&vb->opb,fit_valueA[0],ilog(look->quant_q-1));
oggpack_write(&vb->opb,fit_valueA[1],ilog(look->quant_q-1));
+
+#ifdef TRAIN_FLOOR1
+ {
+ FILE *of;
+ char buffer[80];
+ sprintf(buffer,"line%d_full.vqd",vb->mode);
+ of=fopen(buffer,"a");
+ for(j=2;j<posts;j++)
+ fprintf(of,"%d\n",fit_valueB[j]);
+ fclose(of);
+ }
+#endif
+
/* partition by partition */
for(i=0,j=2;i<info->partitions;i++){
@@ -977,7 +1011,7 @@
cshift+=csubbits;
}
/* write it */
- vorbis_book_encode(books+info->class_book[class],cval,&vb->opb);
+ look->classbits+=vorbis_book_encode(books+info->class_book[class],cval,&vb->opb);
#ifdef TRAIN_FLOOR1
{
@@ -995,7 +1029,7 @@
for(k=0;k<cdim;k++){
int book=info->class_subbook[class][bookas[k]];
if(book>=0){
- vorbis_book_encode(books+book,
+ look->subbits+=vorbis_book_encode(books+book,
fit_valueB[j+k],&vb->opb);
#ifdef TRAIN_FLOOR1
@@ -1013,8 +1047,8 @@
j+=cdim;
}
- /* generate quantized floor equivalent to what we'd unpack in decode */
{
+ /* generate quantized floor equivalent to what we'd unpack in decode */
int hx;
int lx=0;
int ly=fit_valueA[0]*info->mult;
@@ -1023,17 +1057,33 @@
int hy=fit_valueA[current]*info->mult;
hx=info->postlist[current];
- render_line(lx,hx,ly,hy,flr);
+ render_line(lx,hx,ly,hy,codedflr);
lx=hx;
ly=hy;
}
- for(j=hx;j<n;j++)flr[j]=0.f; /* be certain */
+ for(j=hx;j<look->n;j++)codedflr[j]=codedflr[j-1]; /* be certain */
+
+ /* use it to create residue vector. Eliminate residue elements
+ that were below the error training attenuation relative to
+ the original mask. This avoids portions of the floor fit
+ that were considered 'unused' in fitting from being used in
+ coding residue if the unfit values are significantly below
+ the original input mask */
+ for(j=0;j<n;j++)
+ if(logmdct[j]+info->twofitatten<logmask[j])
+ residue[j]=0.f;
+ else
+ residue[j]=mdct[j]/codedflr[j];
+ for(j=n;j<look->n;j++)residue[j]=0.f;
+
}
+ vorbis_msecheck(look,logmask,logmdct,codedflr,n);
+
}else{
oggpack_write(&vb->opb,0,1);
- memset(flr,0,n*sizeof(float));
+ memset(codedflr,0,n*sizeof(float));
}
seq++;
return(nonzero);
@@ -1129,7 +1179,7 @@
lx=hx;
ly=hy;
}
- for(j=hx;j<n;j++)out[j]=0.f; /* be certain */
+ for(j=hx;j<n;j++)out[j]=out[j-1]; /* be certain */
}
return(1);
}
1.27.4.4 +44 -40 vorbis/lib/mapping0.c
Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.27.4.3
retrieving revision 1.27.4.4
diff -u -r1.27.4.3 -r1.27.4.4
--- mapping0.c 2001/05/02 22:14:06 1.27.4.3
+++ mapping0.c 2001/05/11 22:07:50 1.27.4.4
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.27.4.3 2001/05/02 22:14:06 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.27.4.4 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -197,6 +197,7 @@
#include "envelope.h"
#include "mdct.h"
#include "psy.h"
+#define VORBIS_IEEE_FLOAT32
#include "scales.h"
/* no time mapping implementation for now */
@@ -217,77 +218,80 @@
int *nonzero=alloca(sizeof(int)*vi->channels);
- float **floor=_vorbis_block_alloc(vb,vi->channels*sizeof(float *));
- float *additional=_vorbis_block_alloc(vb,n*sizeof(float));
+ float *work=_vorbis_block_alloc(vb,n*sizeof(float));
float newmax=vbi->ampmax;
for(i=0;i<vi->channels;i++){
- float *pcm=vb->pcm[i];
float scale=4.f/n;
int submap=info->chmuxlist[i];
float ret;
- /*_analysis_output("pcm",seq,pcm,n,0,0);*/
+ /* the following makes things clearer to *me* anyway */
+ float *pcm =vb->pcm[i];
+ float *mdct =pcm;
+ float *logmdct =pcm+n/2;
+ float *res =pcm;
+ float *codedflr=pcm+n/2;
+ float *fft =work;
+ float *logfft =work;
+ float *logmax =work;
+ float *logmask =work+n/2;
/* window the PCM data */
for(j=0;j<n;j++)
- additional[j]=pcm[j]*=window[j];
+ fft[j]=pcm[j]*=window[j];
- /*_analysis_output("windowed",seq,pcm,n,0,0);*/
-
/* transform the PCM data */
/* only MDCT right now.... */
mdct_forward(b->transform[vb->W][0],pcm,pcm);
+ for(j=0;j<n/2;j++)
+ logmdct[j]=todB(mdct+j);
/* FFT yields more accurate tonal estimation (not phase sensitive) */
- drft_forward(&look->fft_look,additional);
-
- additional[0]=fabs(additional[0]*scale);
- for(j=1;j<n-1;j+=2)
- additional[(j+1)>>1]=scale*FAST_HYPOT(additional[j],additional[j+1]);
-
- /* set up our masking data working vector, and stash unquantized
- data for later */
- /*memcpy(pcm+n/2,pcm,n*sizeof(float)/2);*/
- memcpy(additional+n/2,pcm,n*sizeof(float)/2);
-
- /* begin masking work */
- floor[i]=_vorbis_block_alloc(vb,n*sizeof(float)/2);
-
- _analysis_output("fft",seq,additional,n/2,0,1);
- _analysis_output("mdct",seq,additional+n/2,n/2,0,1);
- /*_analysis_output("lfft",seq,additional,n/2,0,0);
- _analysis_output("lmdct",seq,additional+n/2,n/2,0,0);*/
+ drft_forward(&look->fft_look,fft);
+ fft[0]*=scale;
+ fft[0]=todB(fft);
+ for(j=1;j<n-1;j+=2){
+ float temp=scale*FAST_HYPOT(fft[j],fft[j+1]);
+ logfft[(j+1)>>1]=todB(&temp);
+ }
+ _analysis_output("fft",seq,logfft,n/2,0,0);
+ _analysis_output("mdct",seq,logmdct,n/2,0,0);
+
/* perform psychoacoustics; do masking */
- ret=_vp_compute_mask(look->psy_look+submap,additional,additional+n/2,
- floor[i],NULL,vbi->ampmax);
+ ret=_vp_compute_mask(look->psy_look+submap,
+ logfft, /* -> logmax */
+ logmdct,
+ logmask,
+ vbi->ampmax);
if(ret>newmax)newmax=ret;
- _analysis_output("mask",seq,floor[i],n/2,0,0);
+ _analysis_output("mask",seq,logmask,n/2,0,0);
/* perform floor encoding */
nonzero[i]=look->floor_func[submap]->
- forward(vb,look->floor_look[submap],floor[i]);
-
- _analysis_output("floor",seq,floor[i],n/2,0,1);
-
- /* apply the floor, do optional noise levelling */
- _vp_apply_floor(look->psy_look+submap,pcm,floor[i]);
+ forward(vb,look->floor_look[submap],
+ mdct,
+ logmdct,
+ logmask,
+ logmax,
+ res,
+ codedflr);
- _analysis_output("res",seq++,pcm,n/2,0,0);
+ _analysis_output("codedflr",seq,codedflr,n/2,0,0);
+ _analysis_output("res",seq++,res,n/2,0,0);
#ifdef TRAIN_RES
if(nonzero[i]){
FILE *of;
char buffer[80];
- int i;
sprintf(buffer,"residue_%d.vqd",vb->mode);
of=fopen(buffer,"a");
- for(i=0;i<n/2;i++){
- fprintf(of,"%.2f, ",pcm[i]);
- if(fabs(pcm[i])>1000){
+ for(j=0;j<n/2;j++){
+ fprintf(of,"%.2f, ",res[j]);
+ if(fabs(res[j])>1000){
fprintf(stderr," %d ",seq-1);
}
}
1.44.4.3 +17 -55 vorbis/lib/psy.c
Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.44.4.2
retrieving revision 1.44.4.3
diff -u -r1.44.4.2 -r1.44.4.3
--- psy.c 2001/05/02 22:14:06 1.44.4.2
+++ psy.c 2001/05/11 22:07:50 1.44.4.3
@@ -11,7 +11,7 @@
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.44.4.2 2001/05/02 22:14:06 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.44.4.3 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -607,8 +607,7 @@
float _vp_compute_mask(vorbis_look_psy *p,
float *fft,
float *mdct,
- float *flr,
- float *decay,
+ float *mask,
float specmax){
int i,n=p->n;
float localmax=NEGINF;
@@ -618,24 +617,14 @@
float *maxseed=alloca(sizeof(float)*p->total_octave_lines);
for(i=0;i<p->total_octave_lines;i++)minseed[i]=maxseed[i]=NEGINF;
- /* go to dB scale. Also find the highest peak so we know the limits */
- for(i=0;i<n;i++){
- fft[i]=todB_nn(fft[i]);
+ /* Find the highest peak so we know the limits */
+ for(i=0;i<n;i++)
if(fft[i]>localmax)localmax=fft[i];
- }
if(specmax<localmax)specmax=localmax;
-
- for(i=0;i<n;i++){
- mdct[i]=todB(mdct[i]);
- }
-
- /*_analysis_output("mdct",seq,mdct,n,0,0);
- _analysis_output("fft",seq,fft,n,0,0);*/
-
/* noise masking */
if(p->vi->noisemaskp){
- bark_noise_median(n,p->bark,mdct,flr,
+ bark_noise_median(n,p->bark,mdct,mask,
p->vi->noisewindowlo,
p->vi->noisewindowhi,
p->vi->noisewindowlomin,
@@ -644,11 +633,11 @@
p->noiseoffset);
/* suppress any noise curve > specmax+p->vi->noisemaxsupp */
for(i=0;i<n;i++)
- if(flr[i]>specmax+p->vi->noisemaxsupp)
- flr[i]=specmax+p->vi->noisemaxsupp;
+ if(mask[i]>specmax+p->vi->noisemaxsupp)
+ mask[i]=specmax+p->vi->noisemaxsupp;
/*_analysis_output("noise",seq,flr,n,0,0);*/
}else{
- for(i=0;i<n;i++)flr[i]=NEGINF;
+ for(i=0;i<n;i++)mask[i]=NEGINF;
}
/* set the ATH (floating below localmax, not global max by a
@@ -659,57 +648,30 @@
for(i=0;i<n;i++){
float av=p->ath[i]+att;
- if(av>flr[i])flr[i]=av;
+ if(av>mask[i])mask[i]=av;
}
}
- /*_analysis_output("ath",seq,flr,n,0,0);*/
/* tone/peak masking */
/* XXX apply decay to the fft here */
- seed_loop(p,p->tonecurves,p->peakatt,fft,flr,minseed,maxseed,specmax);
- bound_loop(p,mdct,maxseed,flr,p->vi->bound_att_dB);
- /*_analysis_output("minseed",seq,minseed,p->total_octave_lines,0,0);
- _analysis_output("maxseed",seq,maxseed,p->total_octave_lines,0,0);*/
- max_seeds(p,minseed,maxseed,flr);
- /*_analysis_output("final",seq,flr,n,0,0);*/
+ seed_loop(p,p->tonecurves,p->peakatt,fft,mask,minseed,maxseed,specmax);
+ bound_loop(p,mdct,maxseed,mask,p->vi->bound_att_dB);
+ max_seeds(p,minseed,maxseed,mask);
/* doing this here is clean, but we need to find a faster way to do
it than to just tack it on */
-
- if(p->vi->floor_cullp){
- for(i=0;i<n;i++)
- if(mdct[i]+6.<flr[i])
- flr[i]=NEGINF;
- }else{
- for(i=0;i<n;i++)if(mdct[i]>=flr[i])break;
- if(i==n)for(i=0;i<n;i++)flr[i]=NEGINF;
- }
+ for(i=0;i<n;i++)if(mdct[i]>=mask[i])break;
+ if(i==n)
+ for(i=0;i<n;i++)mask[i]=NEGINF;
+ else
+ for(i=0;i<n;i++)fft[i]=max(mdct[i],fft[i]);
seq++;
return(specmax);
-}
-
-
-/* this applies the floor and (optionally) tries to preserve noise
- energy in low resolution portions of the spectrum */
-/* f and flr are *linear* scale, not dB */
-void _vp_apply_floor(vorbis_look_psy *p,float *f, float *flr){
- float *work=alloca(p->n*sizeof(float));
- int j;
-
- /* subtract the floor */
- for(j=0;j<p->n;j++){
- if(flr[j]<=0)
- work[j]=0.f;
- else
- work[j]=f[j]/flr[j];
- }
-
- memcpy(f,work,p->n*sizeof(float));
}
float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd){
1.19.4.2 +2 -5 vorbis/lib/psy.h
Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.19.4.1
retrieving revision 1.19.4.2
diff -u -r1.19.4.1 -r1.19.4.2
--- psy.h 2001/04/29 22:21:05 1.19.4.1
+++ psy.h 2001/05/11 22:07:50 1.19.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.19.4.1 2001/04/29 22:21:05 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.19.4.2 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -57,7 +57,6 @@
float max_curve_dB;
float bound_att_dB;
- int floor_cullp;
} vorbis_info_psy;
typedef struct {
@@ -90,10 +89,8 @@
extern float _vp_compute_mask(vorbis_look_psy *p,
float *fft,
float *mdct,
- float *floor,
- float *decay,
+ float *mask,
float prev_maxamp);
-extern void _vp_apply_floor(vorbis_look_psy *p,float *f,float *flr);
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
#endif
1.14.4.2 +36 -138 vorbis/lib/psytune.c
Index: psytune.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psytune.c,v
retrieving revision 1.14.4.1
retrieving revision 1.14.4.2
diff -u -r1.14.4.1 -r1.14.4.2
--- psytune.c 2001/04/05 00:22:48 1.14.4.1
+++ psytune.c 2001/05/11 22:07:50 1.14.4.2
@@ -12,7 +12,7 @@
function: simple utility that runs audio through the psychoacoustics
without encoding
- last mod: $Id: psytune.c,v 1.14.4.1 2001/04/05 00:22:48 xiphmont Exp $
+ last mod: $Id: psytune.c,v 1.14.4.2 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -46,12 +46,9 @@
1,/* tonemaskp */
/* 0 10 20 30 40 50 60 70 80 90 100 */
{
- {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f
-}, /*63*/
- {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f
-}, /*88*/
- {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f
-}, /*125*/
+ {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*63*/
+ {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*88*/
+ {-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f,-999.f}, /*125*/
{-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*175*/
{-35.f,-35.f,-35.f,-40.f,-40.f,-50.f,-60.f,-70.f,-80.f,-90.f,-100.f}, /*250*/
@@ -121,11 +118,9 @@
tight loop) */
-28.,
- -0.f, -.004f, /* attack/decay control */
-
};
-static int noisy=0;
+static int noisy=1;
void analysis(char *base,int i,float *v,int n,int bark,int dB){
if(noisy){
int j;
@@ -144,7 +139,7 @@
fprintf(of,"%g ",(float)j);
if(dB){
- fprintf(of,"%g\n",todB(fabs(v[j])));
+ fprintf(of,"%g\n",todB(fabs(v+j)));
}else{
fprintf(of,"%g\n",v[j]);
}
@@ -154,109 +149,8 @@
}
}
-typedef struct {
- long n;
- int ln;
- int m;
- int *linearmap;
-
- void *vi;
- lpc_lookup lpclook;
- float *lsp_look;
-
-} vorbis_look_floor0;
-
-extern float _curve_to_lpc(float *curve,float *lpc,
- vorbis_look_floor0 *l);
-
long frameno=0;
-/* hacked from floor0.c */
-static void floorinit(vorbis_look_floor0 *look,int n,int m,int ln){
- int j;
- float scale;
- look->m=m;
- look->n=n;
- look->ln=ln;
- lpc_init(&look->lpclook,look->ln,look->m);
-
- scale=look->ln/toBARK(22050.f);
-
- look->linearmap=_ogg_malloc(look->n*sizeof(int));
- for(j=0;j<look->n;j++){
- int val=floor( toBARK(22050.f/n*j) *scale);
- if(val>look->ln)val=look->ln;
- look->linearmap[j]=val;
- }
-}
-
-/*****************************************************************/
-/* fine floor partitioner */
-
-static char amplitude_split[8000];
-static char frequency_split[8000];
-
-/* brute force it for now */
-void partition_split(float *floor,int f0,int f1,int a0,int a1,char *list,int d){
- int i;
- for(i=f0;i<f1;i++)
- if(floor[i]>=a0 && floor[i]<a1)break;
-
- if(i<f1)
- strcat(list,"1");
- else{
- strcat(list,"0");
- return;
- }
-
- if(f1-f0 >= a1-a0){
- if(f1-f0==2)return;
-
- partition_split(floor,f0,(f1+f0)/2,a0,a1,frequency_split,d+1);
- partition_split(floor,(f1+f0)/2,f1,a0,a1,frequency_split,d+1);
-
- }else{
-
- partition_split(floor,f0,f1,a0,(a1+a0)/2,amplitude_split,d+1);
- partition_split(floor,f0,f1,(a1+a0)/2,a1,amplitude_split,d+1);
-
- }
-}
-
-
-void partition_setup(float *floor,float *data,int n){
- int i;
- float foo[n];
- amplitude_split[0]='\0';
- frequency_split[0]='\0';
-
- for(i=0;i<n;i++){
- if(data[i]>0){
- if(data[i]/fromdB(floor[i])>.5){
- foo[i]=todB(data[i]);
- data[i]=fromdB(rint(todB(data[i])));
- }else{
- foo[i]=-999;
- data[i]=0.;
- }
- }else{
- if(data[i]/fromdB(floor[i])<-.5){
- foo[i]=todB(data[i]);
- data[i]=-fromdB(rint(todB(data[i])));
- }else{
- foo[i]=-999;
- data[i]=0.;
- }
- }
- }
-
- partition_split(foo,0,n,-128,0,frequency_split,0);
-
- fprintf(stderr,"%d:%d, ",strlen(frequency_split),strlen(amplitude_split));
-}
-
-
-
/****************************************************************/
int main(int argc,char *argv[]){
@@ -275,11 +169,10 @@
signed char *buffer,*buffer2;
mdct_lookup m_look;
drft_lookup f_look;
+ drft_lookup f_look2;
vorbis_look_psy p_look;
long i,j,k;
- vorbis_look_floor0 floorlook;
-
int ath=0;
int decayp=0;
@@ -325,8 +218,8 @@
window=_vorbis_window(0,framesize,framesize/2,framesize/2);
mdct_init(&m_look,framesize);
drft_init(&f_look,framesize);
+ drft_init(&f_look2,framesize/2);
_vp_psy_init(&p_look,&_psy_set0,framesize/2,44100);
- floorinit(&floorlook,framesize/2,order,map);
for(i=0;i<P_BANDS;i++)
for(j=0;j<P_LEVELS;j++)
@@ -394,37 +287,42 @@
}
analysis("mask",frameno,flr,framesize/2,0,0);
-
- partition_setup(flr,pcm[i],framesize/2);
- /*
- for(j=0;j<framesize/2;j++)
- mask[j]=flr[j]+140.;
-
- amp=sqrt(_curve_to_lpc(mask,mask,&floorlook));
- vorbis_lpc_to_lsp(mask,mask,floorlook.m);
- vorbis_lsp_to_curve(flr,floorlook.linearmap,floorlook.n,floorlook.ln,
- mask,floorlook.m,amp,140.);
+ mask[framesize-1]=0.;
+ mask[0]=0.;
+ for(j=1;j<framesize-1;j+=2){
+ mask[j]=todB(pcm[i]+((j+1)>>1));
+ mask[j+1]=0;
+ }
- analysis("floor",frameno,flr,framesize/2,0,1);
+ analysis("lfft",frameno,mask,framesize,0,0);
+ drft_backward(&f_look,mask);
- _vp_apply_floor(&p_look,pcm[i],flr);
+ analysis("cep",frameno,mask,framesize,0,0);
+ analysis("logcep",frameno,mask,framesize,0,1);
+
- analysis("quant",frameno,pcm[i],framesize/2,0,0);
+ /*for(j=0;j<framesize/2;j++){
+ float val=fromdB(flr[j]);
+ int p=rint(pcm[i][j]/val);
+ pcm[i][j]=p*val;
+ }*/
+
+ /*for(j=0;j<framesize/2;j++){
+ float val=todB(pcm[i]+j);
+ if(val+6.<flr[j])
+ pcm[i][j]=0.;
+ }*/
for(j=0;j<framesize/2;j++){
- float val=rint(pcm[i][j]);
- tot++;
- if(val){
- nonz++;
- acc+=log(fabs(val)*2.f+1.f)/log(2);
- pcm[i][j]=val*flr[j];
- }else{
- pcm[i][j]=0.f;
- }
+ float val=rint(todB(pcm[i]+j)/6);
+ if(pcm[i][j]>0)
+ pcm[i][j]=fromdB(val*6);
+ else
+ pcm[i][j]=-fromdB(val*6);
}
- */
+
analysis("final",frameno,pcm[i],framesize/2,0,1);
1.6.4.2 +3 -1 vorbis/lib/registry.c
Index: registry.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/registry.c,v
retrieving revision 1.6.4.1
retrieving revision 1.6.4.2
diff -u -r1.6.4.1 -r1.6.4.2
--- registry.c 2001/04/05 00:22:48 1.6.4.1
+++ registry.c 2001/05/11 22:07:50 1.6.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.c,v 1.6.4.1 2001/04/05 00:22:48 xiphmont Exp $
+ last mod: $Id: registry.c,v 1.6.4.2 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -26,6 +26,7 @@
extern vorbis_func_floor floor0_exportbundle;
extern vorbis_func_floor floor1_exportbundle;
extern vorbis_func_residue residue0_exportbundle;
+extern vorbis_func_residue residue1_exportbundle;
extern vorbis_func_mapping mapping0_exportbundle;
vorbis_func_time *_time_P[]={
@@ -39,6 +40,7 @@
vorbis_func_residue *_residue_P[]={
&residue0_exportbundle,
+ &residue1_exportbundle,
};
vorbis_func_mapping *_mapping_P[]={
1.5.4.2 +2 -2 vorbis/lib/registry.h
Index: registry.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/registry.h,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -r1.5.4.1 -r1.5.4.2
--- registry.h 2001/04/05 00:22:48 1.5.4.1
+++ registry.h 2001/05/11 22:07:50 1.5.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.h,v 1.5.4.1 2001/04/05 00:22:48 xiphmont Exp $
+ last mod: $Id: registry.h,v 1.5.4.2 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -24,7 +24,7 @@
#define VI_WINDOWB 1
#define VI_TIMEB 1
#define VI_FLOORB 2
-#define VI_RESB 1
+#define VI_RESB 2
#define VI_MAPB 1
extern vorbis_func_time *_time_P[];
1.26.4.1 +19 -2 vorbis/lib/res0.c
Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.26
retrieving revision 1.26.4.1
diff -u -r1.26 -r1.26.4.1
--- res0.c 2001/02/26 03:50:43 1.26
+++ res0.c 2001/05/11 22:07:50 1.26.4.1
@@ -10,8 +10,8 @@
********************************************************************
- function: residue backend 0 implementation
- last mod: $Id: res0.c,v 1.26 2001/02/26 03:50:43 xiphmont Exp $
+ function: residue backend 0 and 1 implementation
+ last mod: $Id: res0.c,v 1.26.4.1 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -385,6 +385,12 @@
return(0);
}
+int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
+ float **in,int ch){
+}
+int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
+}
+
vorbis_func_residue residue0_exportbundle={
&res0_pack,
&res0_unpack,
@@ -394,4 +400,15 @@
&res0_free_look,
&res0_forward,
&res0_inverse
+};
+
+vorbis_func_residue residue1_exportbundle={
+ &res0_pack,
+ &res0_unpack,
+ &res0_look,
+ &res0_copy_info,
+ &res0_free_info,
+ &res0_free_look,
+ &res1_forward,
+ &res1_inverse
};
1.15.4.1 +71 -5 vorbis/lib/scales.h
Index: scales.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/scales.h,v
retrieving revision 1.15
retrieving revision 1.15.4.1
diff -u -r1.15 -r1.15.4.1
--- scales.h 2001/02/26 03:50:43 1.15
+++ scales.h 2001/05/11 22:07:50 1.15.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: linear scale -> dB, Bark and Mel scales
- last mod: $Id: scales.h,v 1.15 2001/02/26 03:50:43 xiphmont Exp $
+ last mod: $Id: scales.h,v 1.15.4.1 2001/05/11 22:07:50 xiphmont Exp $
********************************************************************/
@@ -22,10 +22,76 @@
#include "os.h"
/* 20log10(x) */
-#define DYNAMIC_RANGE_dB 200.f
-#define todB(x) ((x)==0?-400.f:log((x)*(x))*4.34294480f)
-#define todB_nn(x) ((x)==0.f?-400.f:log(x)*8.6858896f)
-#define fromdB(x) (exp((x)*.11512925f))
+#ifdef VORBIS_IEEE_FLOAT32
+static float todB_LOOKUP[196]={
+ -140.277330f, -139.633636f, -139.034372f, -138.473797f,
+ -137.450747f, -136.535597f, -135.707743f, -134.951972f,
+ -134.256730f, -133.613036f, -133.013772f, -132.453198f,
+ -131.430147f, -130.514997f, -129.687144f, -128.931372f,
+ -128.236130f, -127.592437f, -126.993172f, -126.432598f,
+ -125.409547f, -124.494397f, -123.666544f, -122.910772f,
+ -122.215530f, -121.571837f, -120.972572f, -120.411998f,
+ -119.388947f, -118.473797f, -117.645944f, -116.890173f,
+ -116.194930f, -115.551237f, -114.951972f, -114.391398f,
+ -113.368347f, -112.453198f, -111.625344f, -110.869573f,
+ -110.174331f, -109.530637f, -108.931372f, -108.370798f,
+ -107.347748f, -106.432598f, -105.604744f, -104.848973f,
+ -104.153731f, -103.510037f, -102.910773f, -102.350198f,
+ -101.327148f, -100.411998f, -99.584144f, -98.828373f,
+ -98.133131f, -97.489437f, -96.890173f, -96.329598f,
+ -95.306548f, -94.391398f, -93.563544f, -92.807773f,
+ -92.112531f, -91.468837f, -90.869573f, -90.308998f,
+ -89.285948f, -88.370798f, -87.542944f, -86.787173f,
+ -86.091931f, -85.448237f, -84.848973f, -84.288398f,
+ -83.265348f, -82.350198f, -81.522344f, -80.766573f,
+ -80.071331f, -79.427637f, -78.828373f, -78.267799f,
+ -77.244748f, -76.329598f, -75.501745f, -74.745973f,
+ -74.050731f, -73.407038f, -72.807773f, -72.247199f,
+ -71.224148f, -70.308998f, -69.481145f, -68.725373f,
+ -68.030131f, -67.386438f, -66.787173f, -66.226599f,
+ -65.203548f, -64.288399f, -63.460545f, -62.704774f,
+ -62.009531f, -61.365838f, -60.766573f, -60.205999f,
+ -59.182948f, -58.267799f, -57.439945f, -56.684174f,
+ -55.988932f, -55.345238f, -54.745973f, -54.185399f,
+ -53.162349f, -52.247199f, -51.419345f, -50.663574f,
+ -49.968332f, -49.324638f, -48.725374f, -48.164799f,
+ -47.141749f, -46.226599f, -45.398745f, -44.642974f,
+ -43.947732f, -43.304038f, -42.704774f, -42.144199f,
+ -41.121149f, -40.205999f, -39.378145f, -38.622374f,
+ -37.927132f, -37.283438f, -36.684174f, -36.123599f,
+ -35.100549f, -34.185399f, -33.357545f, -32.601774f,
+ -31.906532f, -31.262838f, -30.663574f, -30.102999f,
+ -29.079949f, -28.164799f, -27.336945f, -26.581174f,
+ -25.885932f, -25.242238f, -24.642974f, -24.082400f,
+ -23.059349f, -22.144199f, -21.316346f, -20.560574f,
+ -19.865332f, -19.221639f, -18.622374f, -18.061800f,
+ -17.038749f, -16.123599f, -15.295746f, -14.539974f,
+ -13.844732f, -13.201039f, -12.601774f, -12.041200f,
+ -11.018149f, -10.103000f, -9.275146f, -8.519375f,
+ -7.824132f, -7.180439f, -6.581174f, -6.020600f,
+ -4.997549f, -4.082400f, -3.254546f, -2.498775f,
+ -1.803533f, -1.159839f, -0.560574f, 0.000000f,
+ 1.023050f, 1.938200f, 2.766054f, 3.521825f,
+ 4.217067f, 4.860761f, 5.460025f, 6.020600f
+};
+
+static float todB(float *x) {
+ ogg_int32_t *i=(ogg_int32_t *)x;
+ ogg_int32_t temp=(*i&0x7fffffff)-0x33cfffff;
+ if(temp<0)return -400.f;
+ return(todB_LOOKUP[temp]);
+}
+
+#define todB_nn(x) todB(x)
+
+#else
+
+#define todB(x) ((*x)==0?-400.f:log((*x)*(*x))*4.34294480f)
+#define todB_nn(x) ((*x)==0.f?-400.f:log(*x)*8.6858896f)
+
+#endif
+
+#define fromdB(x) (exp((x)*.11512925f))
/* The bark scale equations are approximations, since the original
table was somewhat hand rolled. The below are chosen to have the
No revision
No revision
1.14.4.3 +83 -33 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.2
retrieving revision 1.14.4.3
diff -u -r1.14.4.2 -r1.14.4.3
--- mode_A.h 2001/05/01 17:08:38 1.14.4.2
+++ mode_A.h 2001/05/11 22:07:53 1.14.4.3
@@ -11,7 +11,7 @@
********************************************************************
function: predefined encoding modes
- last mod: $Id: mode_A.h,v 1.14.4.2 2001/05/01 17:08:38 xiphmont Exp $
+ last mod: $Id: mode_A.h,v 1.14.4.3 2001/05/11 22:07:53 xiphmont Exp $
********************************************************************/
@@ -22,8 +22,33 @@
#include "vorbis/codec.h"
#include "backends.h"
-#include "books/line0.vqh"
-#include "books/line1.vqh"
+#include "books/line0_class0.vqh"
+#include "books/line0_class1.vqh"
+#include "books/line0_class2.vqh"
+#include "books/line1_class0.vqh"
+#include "books/line1_class1.vqh"
+#include "books/line1_class2.vqh"
+#include "books/line1_class3.vqh"
+
+#include "books/line0_0sub0.vqh"
+#include "books/line0_0sub1.vqh"
+#include "books/line0_1sub1.vqh"
+#include "books/line0_1sub2.vqh"
+#include "books/line0_1sub3.vqh"
+#include "books/line0_2sub1.vqh"
+#include "books/line0_2sub2.vqh"
+#include "books/line0_2sub3.vqh"
+
+#include "books/line1_0sub0.vqh"
+#include "books/line1_0sub1.vqh"
+#include "books/line1_1sub0.vqh"
+#include "books/line1_1sub1.vqh"
+#include "books/line1_2sub1.vqh"
+#include "books/line1_2sub2.vqh"
+#include "books/line1_2sub3.vqh"
+#include "books/line1_3sub1.vqh"
+#include "books/line1_3sub2.vqh"
+#include "books/line1_3sub3.vqh"
#include "books/res0_128_128aux.vqh"
#include "books/res0_128_1024aux.vqh"
@@ -130,7 +155,6 @@
tight loop) */
-22.,
- 1,
};
static vorbis_info_psy _psy_set_A={
@@ -220,8 +244,6 @@
tight loop) */
-28.,
- 1,
-
};
/* with GNUisms, this could be short and readable. Oh well */
@@ -234,12 +256,12 @@
static vorbis_info_floor1 _floor_set0A={4,
{0,1,2,2},
- {2,3,3},
- {1,1,1},
- {0,0,0},
- {{-1,1},{-1,1},{-1,1}},
+ {3,3,3},
+ {1,2,2},
+ {0,1,2},
+ {{7,8},{-1,9,10,11},{-1,12,13,14}},
- 2,
+ 4,
{0,128,
5,21,
@@ -247,17 +269,20 @@
11,7,15,
45,30,73},
- 40,8,200,4};
+ 60,30,600,
+ 999,999,0,0.,
+ 8,96};
static vorbis_info_floor1 _floor_set1A={10,
{0,1,2,2,2,2,3,3,3,3},
{3,4,3,3},
- {1,1,1,1},
- {2,2,2,2},
- {{-1,3},{-1,3},{-1,3},{-1,3}},
+ {1,1,2,2},
+ {3,4,5,6},
+ {{15,16},{17,18},
+ {-1,19,20,21},{-1,22,23,24}},
- 2,
+ 4,
{0,1024,
88,31,243,
14,54,143,460,
@@ -266,20 +291,22 @@
69,61,78, 112,99,126, 185,162,211,
329,282,387, 672,553,825},
- 40,8,200,9};
+ 60,30,600,
+ 20,8,1,18.,
+ 40,768};
-static vorbis_info_residue0 _residue_set0A={0,96,16,6,4,
+static vorbis_info_residue0 _residue_set0A={0,96,16,6,25,
{0,1,1,1,1,1},
- {6,7,8,9,10},
+ {27,28,29,30,31},
{0,99999,9999,9999,9999},
{999.f,1.5f,3.5f,15.5f,26.5f},
{4,4,4,4,4},
{99,99,99,99,99}};
-static vorbis_info_residue0 _residue_set1A={0, 960, 32,10,5,
+static vorbis_info_residue0 _residue_set1A={0, 960, 32,10,26,
{0,1,1,1,1,1,1,1,1,1},
- {11,12,13,14,15,16,17,18,19},
+ {32,33,34,35,36,37,38,39,40},
{0,8,9999,16,9999,
24,9999,9999,9999},
@@ -299,7 +326,7 @@
/* smallblock, largeblock */
{256, 2048},
/* modes,maps,times,floors,residues,books,psys */
- 2, 2, 1, 2, 2, 20, 2,
+ 2, 2, 1, 2, 2, 41, 2,
/* modes */
{&_mode_set0A,&_mode_set1A},
/* maps */
@@ -311,28 +338,51 @@
/* residue */
{0,0},{&_residue_set0A,&_residue_set1A},
/* books */
- {&_huff_book_line0,
- &_huff_book_line1,
- &_huff_book_line0,
- &_huff_book_line1,
+ {&_huff_book_line0_class0, /* 0 */
+ &_huff_book_line0_class1,
+ &_huff_book_line0_class2, /* 2 */
+ &_huff_book_line1_class0,
+ &_huff_book_line1_class1, /* 4 */
+ &_huff_book_line1_class2,
+ &_huff_book_line1_class3, /* 6 */
+
+ &_huff_book_line0_0sub0,
+ &_huff_book_line0_0sub1,
+ &_huff_book_line0_1sub1,
+ &_huff_book_line0_1sub2,
+ &_huff_book_line0_1sub3,
+ &_huff_book_line0_2sub1,
+ &_huff_book_line0_2sub2,
+ &_huff_book_line0_2sub3, /* 14 */
+
+ &_huff_book_line1_0sub0,
+ &_huff_book_line1_0sub1,
+ &_huff_book_line1_1sub0,
+ &_huff_book_line1_1sub1,
+ &_huff_book_line1_2sub1,
+ &_huff_book_line1_2sub2,
+ &_huff_book_line1_2sub3,
+ &_huff_book_line1_3sub1,
+ &_huff_book_line1_3sub2,
+ &_huff_book_line1_3sub3, /* 24 */
- &_huff_book_res0_128_128aux,
+ &_huff_book_res0_128_128aux,
&_huff_book_res0_128_1024aux,
- &_vq_book_res0_128_128_1,
+ &_vq_book_res0_128_128_1,
&_vq_book_res0_128_128_2,
&_vq_book_res0_128_128_3,
&_vq_book_res0_128_128_4,
- &_vq_book_res0_128_128_5,
+ &_vq_book_res0_128_128_5,
&_vq_book_res0_128_1024_1,
- &_vq_book_res0_128_1024_2,
+ &_vq_book_res0_128_1024_2,
&_vq_book_res0_128_1024_3,
- &_vq_book_res0_128_1024_4,
+ &_vq_book_res0_128_1024_4,
&_vq_book_res0_128_1024_5,
- &_vq_book_res0_128_1024_6,
+ &_vq_book_res0_128_1024_6,
&_vq_book_res0_128_1024_7,
- &_vq_book_res0_128_1024_8,
+ &_vq_book_res0_128_1024_8,
&_vq_book_res0_128_1024_9,
},
No revision
No revision
1.23.4.1 +3 -3 vorbis/vq/bookutil.c
Index: bookutil.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vq/bookutil.c,v
retrieving revision 1.23
retrieving revision 1.23.4.1
diff -u -r1.23 -r1.23.4.1
--- bookutil.c 2001/02/26 03:51:12 1.23
+++ bookutil.c 2001/05/11 22:07:54 1.23.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: utility functions for loading .vqh and .vqd files
- last mod: $Id: bookutil.c,v 1.23 2001/02/26 03:51:12 xiphmont Exp $
+ last mod: $Id: bookutil.c,v 1.23.4.1 2001/05/11 22:07:54 xiphmont Exp $
********************************************************************/
@@ -191,7 +191,7 @@
}
/* find the codebook struct */
- find_seek_to(in,"static static_codebook _vq_book_");
+ find_seek_to(in,"static static_codebook _");
/* get the major important values */
line=get_line(in);
@@ -379,7 +379,7 @@
}
/* load the lengthlist */
- find_seek_to(in,"static long _vq_lengthlist");
+ find_seek_to(in,"_lengthlist");
reset_next_value();
c->lengthlist=_ogg_malloc(sizeof(long)*c->entries);
for(i=0;i<c->entries;i++)
1.4.4.1 +3 -3 vorbis/vq/distribution.c
Index: distribution.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vq/distribution.c,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- distribution.c 2001/02/26 03:51:12 1.4
+++ distribution.c 2001/05/11 22:07:54 1.4.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: utility for finding the distribution in a data set
- last mod: $Id: distribution.c,v 1.4 2001/02/26 03:51:12 xiphmont Exp $
+ last mod: $Id: distribution.c,v 1.4.4.1 2001/05/11 22:07:54 xiphmont Exp $
********************************************************************/
@@ -155,7 +155,7 @@
flag=1;
}
- while(sscanf(line,"%f",&code)==1){
+ while(line && sscanf(line,"%f",&code)==1){
line=strchr(line,',');
if(line)line++;
if(code<min)min=code;
@@ -187,7 +187,7 @@
lines--;
if(!(lines&0xff))spinnit("counting distribution. lines so far...",lines);
- while(sscanf(line,"%f",&code)==1){
+ while(line && sscanf(line,"%f",&code)==1){
line=strchr(line,',');
if(line)line++;
1.8.4.1 +39 -26 vorbis/vq/huffbuild.c
Index: huffbuild.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vq/huffbuild.c,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -u -r1.8 -r1.8.4.1
--- huffbuild.c 2001/02/26 03:51:12 1.8
+++ huffbuild.c 2001/05/11 22:07:54 1.8.4.1
@@ -7,11 +7,11 @@
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
-
+ * *
********************************************************************
function: hufftree builder
- last mod: $Id: huffbuild.c,v 1.8 2001/02/26 03:51:12 xiphmont Exp $
+ last mod: $Id: huffbuild.c,v 1.8.4.1 2001/05/11 22:07:54 xiphmont Exp $
********************************************************************/
@@ -50,7 +50,7 @@
static void usage(){
fprintf(stderr,
"usage:\n"
- "huffbuild <input>.vqd <begin,n,group> [noguard]\n"
+ "huffbuild <input>.vqd <begin,n,group>|<lorange-hirange> [noguard]\n"
" where begin,n,group is first scalar, \n"
" number of scalars of each in line,\n"
" number of scalars in a group\n"
@@ -65,6 +65,7 @@
int i,j,k,begin,n,subn,guard=1;
FILE *file;
int maxval=0;
+ int loval=0;
if(argc<3)usage();
if(argc==4)guard=0;
@@ -76,19 +77,28 @@
{
char *pos=strchr(argv[2],',');
- begin=atoi(argv[2]);
- if(!pos)
- usage();
- else
- n=atoi(pos+1);
- pos=strchr(pos+1,',');
- if(!pos)
- usage();
- else
- subn=atoi(pos+1);
- if(n/subn*subn != n){
- fprintf(stderr,"n must be divisible by group\n");
- exit(1);
+ char *dpos=strchr(argv[2],'-');
+ if(dpos){
+ loval=atoi(argv[2]);
+ maxval=atoi(dpos+1);
+ subn=1;
+ subn=1;
+ begin=0;
+ }else{
+ begin=atoi(argv[2]);
+ if(!pos)
+ usage();
+ else
+ n=atoi(pos+1);
+ pos=strchr(pos+1,',');
+ if(!pos)
+ usage();
+ else
+ subn=atoi(pos+1);
+ if(n/subn*subn != n){
+ fprintf(stderr,"n must be divisible by group\n");
+ exit(1);
+ }
}
}
@@ -98,29 +108,32 @@
fprintf(stderr,"Could not open file %s\n",infile);
exit(1);
}
- i=0;
- while(1){
- long v;
- if(get_next_ivalue(file,&v))break;
- if(v>maxval)maxval=v;
- if(!(i++&0xff))spinnit("loading... ",i);
+ if(!maxval){
+ i=0;
+ while(1){
+ long v;
+ if(get_next_ivalue(file,&v))break;
+ if(v>maxval)maxval=v;
+
+ if(!(i++&0xff))spinnit("loading... ",i);
+ }
+ rewind(file);
+ maxval++;
}
- rewind(file);
- maxval++;
{
long vals=pow(maxval,subn);
long *hist=_ogg_malloc(vals*sizeof(long));
long *lengths=_ogg_malloc(vals*sizeof(long));
- for(j=0;j<vals;j++)hist[j]=guard;
+ for(j=loval;j<vals;j++)hist[j]=guard;
reset_next_value();
i/=subn;
while(!feof(file)){
long val=getval(file,begin,n,subn,maxval);
- if(val==-1)break;
+ if(val==-1 || val>=maxval)break;
hist[val]++;
if(!(i--&0xff))spinnit("loading... ",i*subn);
}
--- >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