summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <xiphmont@xiph.org>2001-06-15 21:15:43 +0000
committerMonty <xiphmont@xiph.org>2001-06-15 21:15:43 +0000
commit8d96e574de435ef69c82a34be48f257606f0a2e6 (patch)
tree5d9bfb20ae673debc2f2d0f88e9b071ee60ad4a4
parent7e777f7e07e05662e4ba9765a932d50d94dd7fc7 (diff)
downloadlibvorbis-git-8d96e574de435ef69c82a34be48f257606f0a2e6.tar.gz
Additional optimizations, rearrangement.
Residue backend # 2 (interleaved channels) Channel coupling added to mapping 0 Modes do not currently make use of either. Monty svn path=/trunk/vorbis/; revision=1479
-rw-r--r--lib/backends.h11
-rw-r--r--lib/barkmel.c4
-rw-r--r--lib/codebook.c103
-rw-r--r--lib/codebook.h15
-rw-r--r--lib/floor0.c40
-rw-r--r--lib/floor1.c6
-rw-r--r--lib/info.c4
-rw-r--r--lib/lsp.c12
-rw-r--r--lib/mapping0.c198
-rw-r--r--lib/masking.h179
-rw-r--r--lib/modes/modes.h3
-rw-r--r--lib/psy.c125
-rw-r--r--lib/psy.h4
-rw-r--r--lib/registry.c4
-rw-r--r--lib/registry.h4
-rw-r--r--lib/res0.c168
-rw-r--r--vq/distribution.c21
-rw-r--r--vq/latticetune.c25
-rwxr-xr-xvq/make_residue_books.pl15
-rw-r--r--vq/res_128k.vqs4
20 files changed, 654 insertions, 291 deletions
diff --git a/lib/backends.h b/lib/backends.h
index 3929f99f..79947109 100644
--- a/lib/backends.h
+++ b/lib/backends.h
@@ -12,7 +12,7 @@
function: libvorbis backend and mapping structures; needed for
static mode headers
- last mod: $Id: backends.h,v 1.7 2001/05/27 06:43:59 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.8 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -64,8 +64,9 @@ typedef struct{
const float *, const float *, /* in */
const float *, const float *, /* in */
float *, float *); /* out */
- int (*inverse) (struct vorbis_block *,vorbis_look_floor *,
- float *);
+ void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *);
+ int (*inverse2) (struct vorbis_block *,vorbis_look_floor *,
+ void *buffer,float *);
} vorbis_func_floor;
typedef struct{
@@ -172,6 +173,10 @@ typedef struct vorbis_info_mapping0{
int floorsubmap[16]; /* [mux] submap to floors */
int residuesubmap[16]; /* [mux] submap to residue */
int psysubmap[16]; /* [mux]; encode only */
+
+ int coupling_steps;
+ int coupling_mag[256];
+ int coupling_ang[256];
} vorbis_info_mapping0;
#endif
diff --git a/lib/barkmel.c b/lib/barkmel.c
index 13ae993d..d458614d 100644
--- a/lib/barkmel.c
+++ b/lib/barkmel.c
@@ -11,7 +11,7 @@
********************************************************************
function: bark scale utility
- last mod: $Id: barkmel.c,v 1.6 2001/05/27 06:43:59 xiphmont Exp $
+ last mod: $Id: barkmel.c,v 1.7 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -54,7 +54,7 @@ int main(){
{
float i;
int j;
- for(i=0.,j=0;i<28;i+=2.107,j++){
+ for(i=0.,j=0;i<28;i+=1.,j++){
fprintf(stderr,"(%d) bark=%f %gHz (%d of 128)\n",
j,i,fromBARK(i),(int)(fromBARK(i)/22050.*128.));
}
diff --git a/lib/codebook.c b/lib/codebook.c
index 9f01186a..d58723b2 100644
--- a/lib/codebook.c
+++ b/lib/codebook.c
@@ -11,7 +11,7 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.25 2001/06/04 05:50:10 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.26 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -342,8 +342,7 @@ long vorbis_book_decode(codebook *book, oggpack_buffer *b){
}
/* returns 0 on OK or -1 on eof *************************************/
-long vorbis_book_decodevs(codebook *book,float *a,oggpack_buffer *b,
- int n,int addmul){
+long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){
int step=n/book->dim;
long *entry = alloca(sizeof(long)*step);
float **t = alloca(sizeof(float *)*step);
@@ -354,65 +353,91 @@ long vorbis_book_decodevs(codebook *book,float *a,oggpack_buffer *b,
if(entry[i]==-1)return(-1);
t[i] = book->valuelist+entry[i]*book->dim;
}
- switch(addmul){
- case -1:
- for(i=0,o=0;i<book->dim;i++,o+=step)
- for (j=0;j<step;j++)
- a[o+j]=t[j][i];
- break;
- case 0:
- for(i=0,o=0;i<book->dim;i++,o+=step)
- for (j=0;j<step;j++)
- a[o+j]+=t[j][i];
- break;
- case 1:
- for(i=0,o=0;i<book->dim;i++,o+=step)
- for (j=0;j<step;j++)
- a[o+j]*=t[j][i];
- break;
- }
+ for(i=0,o=0;i<book->dim;i++,o+=step)
+ for (j=0;j<step;j++)
+ a[o+j]+=t[j][i];
return(0);
}
-long vorbis_book_decodev(codebook *book,float *a,oggpack_buffer *b,
- int n,int addmul){
+long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
int i,j,entry;
float *t;
- switch(addmul){
- case -1:
+ if(book->dim>8){
for(i=0;i<n;){
entry = vorbis_book_decode(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
for (j=0;j<book->dim;)
- a[i++]=t[j++];
+ a[i++]+=t[j++];
}
- break;
- case 0:
+ }else{
for(i=0;i<n;){
entry = vorbis_book_decode(book,b);
if(entry==-1)return(-1);
t = book->valuelist+entry*book->dim;
- for (j=0;j<book->dim;)
+ switch(book->dim){
+ case 8:
+ a[i++]+=t[j++];
+ case 7:
a[i++]+=t[j++];
+ case 6:
+ a[i++]+=t[j++];
+ case 5:
+ a[i++]+=t[j++];
+ case 4:
+ a[i++]+=t[j++];
+ case 3:
+ a[i++]+=t[j++];
+ case 2:
+ a[i++]+=t[j++];
+ case 1:
+ a[i++]+=t[j++];
+ case 0:
+ break;
+ }
}
- break;
- case 1:
- for(i=0;i<n;){
- entry = vorbis_book_decode(book,b);
- if(entry==-1)return(-1);
- t = book->valuelist+entry*book->dim;
- for (j=0;j<book->dim;)
- a[i++]*=t[j++];
+ }
+ return(0);
+}
+
+long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){
+ int i,j,entry;
+ float *t;
+
+ for(i=0;i<n;){
+ entry = vorbis_book_decode(book,b);
+ if(entry==-1)return(-1);
+ t = book->valuelist+entry*book->dim;
+ for (j=0;j<book->dim;)
+ a[i++]=t[j++];
+ }
+ return(0);
+}
+
+long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch,
+ oggpack_buffer *b,int n){
+ long i,j,k,entry;
+ int chptr=0;
+
+ for(i=offset/ch;i<(offset+n)/ch;){
+ entry = vorbis_book_decode(book,b);
+ if(entry==-1)return(-1);
+ {
+ const float *t = book->valuelist+entry*book->dim;
+ for (j=0;j<book->dim;j++){
+ a[chptr++][i]+=t[j];
+ if(chptr==ch){
+ chptr=0;
+ i++;
+ }
+ }
}
- break;
}
return(0);
}
#ifdef _V_SELFTEST
-
/* Simple enough; pack a few candidate codebooks, unpack them. Code a
number of vectors through (keeping track of the quantized values),
and decode using the unpacked book. quantized version of in should
@@ -531,7 +556,7 @@ int main(){
}
for(i=0;i<TESTSIZE;i+=c.dim)
- if(vorbis_book_decodevs(&c,iv+i,&read,1,-1)==-1){
+ if(vorbis_book_decodev_set(&c,iv+i,&read,c.dim)==-1){
fprintf(stderr,"Error reading codebook test data (EOP).\n");
exit(1);
}
diff --git a/lib/codebook.h b/lib/codebook.h
index f7c00f94..7402c708 100644
--- a/lib/codebook.h
+++ b/lib/codebook.h
@@ -11,7 +11,7 @@
********************************************************************
function: basic shared codebook operations
- last mod: $Id: codebook.h,v 1.7 2001/06/04 05:50:10 xiphmont Exp $
+ last mod: $Id: codebook.h,v 1.8 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -149,10 +149,15 @@ extern int vorbis_book_encodevs(codebook *book, float *a, oggpack_buffer *b,
int step,int stagetype);
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b);
-extern long vorbis_book_decodevs(codebook *book, float *a, oggpack_buffer *b,
- int n,int stagetype);
-extern long vorbis_book_decodev(codebook *book, float *a, oggpack_buffer *b,
- int n,int stagetype);
+extern long vorbis_book_decodevs_add(codebook *book, float *a,
+ oggpack_buffer *b,int n);
+extern long vorbis_book_decodev_set(codebook *book, float *a,
+ oggpack_buffer *b,int n);
+extern long vorbis_book_decodev_add(codebook *book, float *a,
+ oggpack_buffer *b,int n);
+extern long vorbis_book_decodevv_add(codebook *book, float **a,
+ long off,int ch,
+ oggpack_buffer *b,int n);
diff --git a/lib/floor0.c b/lib/floor0.c
index 90dc2b62..41c8e372 100644
--- a/lib/floor0.c
+++ b/lib/floor0.c
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.41 2001/06/04 05:50:10 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.42 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -402,7 +402,7 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *in,
return(val);
}
-static int floor0_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
+static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
vorbis_info_floor0 *info=look->vi;
int j,k;
@@ -412,30 +412,42 @@ static int floor0_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
long maxval=(1<<info->ampbits)-1;
float amp=(float)ampraw/maxval*info->ampdB;
int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
- float *lsp=alloca(sizeof(float)*look->m);
-
+
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */
backend_lookup_state *be=vb->vd->backend_state;
codebook *b=be->fullbooks+info->books[booknum];
float last=0.f;
-
- memset(out,0,sizeof(float)*look->m);
-
+ float *lsp=_vorbis_block_alloc(vb,sizeof(float)*(look->m+1));
+
for(j=0;j<look->m;j+=b->dim)
- if(vorbis_book_decodev(b,lsp+j,&vb->opb,b->dim,-1)==-1)goto eop;
+ if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop;
for(j=0;j<look->m;){
for(k=0;k<b->dim;k++,j++)lsp[j]+=last;
last=lsp[j-1];
}
- /* take the coefficients back to a spectral envelope curve */
- vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
- lsp,look->m,amp,info->ampdB);
- return(1);
+ lsp[look->m]=amp;
+ return(lsp);
}
}
-
eop:
+ return(NULL);
+}
+
+static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i,
+ void *memo,float *out){
+ vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+ vorbis_info_floor0 *info=look->vi;
+
+ if(memo){
+ float *lsp=(float *)memo;
+ float amp=lsp[look->m];
+
+ /* take the coefficients back to a spectral envelope curve */
+ vorbis_lsp_to_curve(out,look->linearmap,look->n,look->ln,
+ lsp,look->m,amp,info->ampdB);
+ return(1);
+ }
memset(out,0,sizeof(float)*look->n);
return(0);
}
@@ -443,7 +455,7 @@ static int floor0_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
/* export hooks */
vorbis_func_floor floor0_exportbundle={
&floor0_pack,&floor0_unpack,&floor0_look,&floor0_copy_info,&floor0_free_info,
- &floor0_free_look,&floor0_forward,&floor0_inverse
+ &floor0_free_look,&floor0_forward,&floor0_inverse1,&floor0_inverse2
};
diff --git a/lib/floor1.c b/lib/floor1.c
index 4a533408..fa274af0 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.6 2001/06/12 02:44:27 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.7 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -86,10 +86,10 @@ static void floor1_free_info(vorbis_info_floor *i){
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",
+ /*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));
+ sqrt(look->mse/look->seq));*/
memset(look,0,sizeof(vorbis_look_floor1));
free(i);
diff --git a/lib/info.c b/lib/info.c
index 461d3e76..50a484cc 100644
--- a/lib/info.c
+++ b/lib/info.c
@@ -11,7 +11,7 @@
********************************************************************
function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.40 2001/05/27 06:44:00 xiphmont Exp $
+ last mod: $Id: info.c,v 1.41 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -408,7 +408,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
}
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
- char temp[]="Xiphophorus libVorbis I 20010501";
+ char temp[]="Xiphophorus libVorbis I 20010615";
/* preamble */
oggpack_write(opb,0x03,8);
diff --git a/lib/lsp.c b/lib/lsp.c
index 9281dd46..1854a370 100644
--- a/lib/lsp.c
+++ b/lib/lsp.c
@@ -11,7 +11,7 @@
********************************************************************
function: LSP (also called LSF) conversion routines
- last mod: $Id: lsp.c,v 1.17 2001/02/26 03:50:42 xiphmont Exp $
+ last mod: $Id: lsp.c,v 1.18 2001/06/15 21:15:39 xiphmont Exp $
The LSP generation code is taken (with minimal modification and a
few bugfixes) from "On the Computation of the LSP Frequencies" by
@@ -104,7 +104,7 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
ampoffset);
do{
- curve[i++]=q;
+ curve[i++]*=q;
}while(map[i]==k);
}
vorbis_fpu_restore(fpu);
@@ -231,8 +231,8 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
/* m.8, m+n<=8 */
ampoffseti); /* 8.12[0] */
- curve[i]=amp;
- while(map[++i]==k)curve[i]=amp;
+ curve[i]*=amp;
+ while(map[++i]==k)curve[i]*=amp;
}
}
@@ -273,8 +273,8 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m,
q=fromdB(amp/sqrt(p+q)-ampoffset);
- curve[i]=q;
- while(map[++i]==k)curve[i]=q;
+ curve[i]*=q;
+ while(map[++i]==k)curve[i]*=q;
}
}
diff --git a/lib/mapping0.c b/lib/mapping0.c
index 04c5a0f6..1b708858 100644
--- a/lib/mapping0.c
+++ b/lib/mapping0.c
@@ -7,11 +7,11 @@
* *
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
* by the XIPHOPHORUS Company http://www.xiph.org/ *
-
+ * *
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.29 2001/06/04 05:50:10 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.30 2001/06/15 21:15:39 xiphmont Exp $
********************************************************************/
@@ -143,12 +143,45 @@ static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode
return(look);
}
+static int ilog2(unsigned int v){
+ int ret=0;
+ while(v>1){
+ ret++;
+ v>>=1;
+ }
+ return(ret);
+}
+
static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer *opb){
int i;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
- /* leave submaps as a hook to be filled in later */
- oggpack_write(opb,info->submaps-1,4);
+ /* another 'we meant to do it this way' hack... up to beta 4, we
+ packed 4 binary zeros here to signify one submapping in use. We
+ now redefine that to mean four bitflags that indicate use of
+ deeper features; bit0:submappings, bit1:coupling,
+ bit2,3:reserved. This is backward compatable with all actual uses
+ of the beta code. */
+
+ if(info->submaps>1){
+ oggpack_write(opb,1,1);
+ oggpack_write(opb,info->submaps-1,4);
+ }else
+ oggpack_write(opb,0,1);
+
+ if(info->coupling_steps>0){
+ oggpack_write(opb,1,1);
+ oggpack_write(opb,info->coupling_steps-1,8);
+
+ for(i=0;i<info->coupling_steps;i++){
+ oggpack_write(opb,info->coupling_mag[i],ilog2(vi->channels));
+ oggpack_write(opb,info->coupling_ang[i],ilog2(vi->channels));
+ }
+ }else
+ oggpack_write(opb,0,1);
+
+ oggpack_write(opb,0,2); /* 2,3:reserved */
+
/* we don't write the channel submappings if we only have one... */
if(info->submaps>1){
for(i=0;i<vi->channels;i++)
@@ -168,8 +201,29 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
codec_setup_info *ci=vi->codec_setup;
memset(info,0,sizeof(vorbis_info_mapping0));
- info->submaps=oggpack_read(opb,4)+1;
+ if(oggpack_read(opb,1))
+ info->submaps=oggpack_read(opb,4)+1;
+ else
+ info->submaps=1;
+
+ if(oggpack_read(opb,1)){
+ info->coupling_steps=oggpack_read(opb,8)+1;
+ for(i=0;i<info->coupling_steps;i++){
+ int testM=info->coupling_mag[i]=oggpack_read(opb,ilog2(vi->channels));
+ int testA=info->coupling_ang[i]=oggpack_read(opb,ilog2(vi->channels));
+
+ if(testM<0 ||
+ testA<0 ||
+ testM==testA ||
+ testM>=vi->channels ||
+ testA>=vi->channels) goto err_out;
+ }
+
+ }
+
+ if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
+
if(info->submaps>1){
for(i=0;i<vi->channels;i++){
info->chmuxlist[i]=oggpack_read(opb,4);
@@ -280,30 +334,69 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
res,
codedflr);
- _analysis_output("codedflr",seq,codedflr,n/2,0,1);
- _analysis_output("res",seq++,res,n/2,0,0);
+ for(j=0;j<n/2;j++)
+ if(fabs(vb->pcm[i][j]>1000))
+ fprintf(stderr,"%ld ",seq);
+
+ _analysis_output("res",seq-vi->channels+j,vb->pcm[i],n,0,0);
+ _analysis_output("codedflr",seq++,codedflr,n/2,0,1);
-#ifdef TRAIN_RES
- if(nonzero[i]){
- FILE *of;
- char buffer[80];
+ }
+
+ vbi->ampmax=newmax;
+
+ /* channel coupling */
+ for(i=0;i<info->coupling_steps;i++){
+ float *pcmM=vb->pcm[info->coupling_mag[i]];
+ float *pcmA=vb->pcm[info->coupling_ang[i]];
+
+ /* +-
+ B
+ | A-B
+ -4 -3 -2 -1 0
+ |
+ 3 | 1
+ |
+ -+ 2-----+-----2----A ++
+ |
+ 1 | 3
+ |
+ 0 -1 -2 -3 -4
+ B-A |
+ --
+
+ */
+ for(j=n/2-1;j>=0;j--){
+ float A=rint(pcmM[j]);
+ float B=rint(pcmA[j]);
- sprintf(buffer,"residue_%d.vqd",vb->mode);
- of=fopen(buffer,"a");
- for(j=0;j<n/2;j++){
- fprintf(of,"%.2f, ",res[j]);
- if(fabs(res[j])>1000){
- fprintf(stderr," %d ",seq-1);
- }
+ if(fabs(A)>fabs(B)){
+ pcmM[j]=A;
+ if(A>0)
+ pcmA[j]=A-B;
+ else
+ pcmA[j]=B-A;
+ }else{
+ pcmM[j]=B;
+ if(B>0)
+ pcmA[j]=A-B;
+ else
+ pcmA[j]=B-A;
}
- fprintf(of,"\n");
- fclose(of);
+
+ /*if(fabs(mag)<3.5f)
+ ang=rint(ang/(mag*2.f))*mag*2.f;*/
+
+ /*if(fabs(mag)<1.5)
+ ang=0;*/
+
+ /*if(i>(n*3/16))
+ ang=0;*/
+
+ /*if(ang>=fabs(mag*2))ang=-fabs(mag*2);*/
}
-#endif
}
- vbi->ampmax=newmax;
-
/* perform residue encoding with residue mapping; this is
multiplexed. All the channels belonging to one submap are
encoded (values interleaved), then the next submap, etc */
@@ -311,18 +404,14 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
for(j=0;j<vi->channels;j++){
- if(info->chmuxlist[j]==i && nonzero[j]>0){
+ if(info->chmuxlist[j]==i && nonzero[j])
pcmbundle[ch_in_bundle++]=vb->pcm[j];
- }
+
}
look->residue_func[i]->forward(vb,look->residue_look[i],
pcmbundle,ch_in_bundle);
}
-
- for(j=0;j<vi->channels;j++){
- _analysis_output("resres",seq-vi->channels+j,vb->pcm[j],n/2,0,0);
- }
look->lastframe=vb->sequence;
return(0);
@@ -341,7 +430,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
float *window=b->window[vb->W][vb->lW][vb->nW][mode->windowtype];
float **pcmbundle=alloca(sizeof(float *)*vi->channels);
- int *nonzero=alloca(sizeof(int)*vi->channels);
+ void **nonzero=alloca(sizeof(void *)*vi->channels);
/* time domain information decode (note that applying the
information would have to happen later; we'll probably add a
@@ -350,14 +439,13 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
/* recover the spectral envelope; store it in the PCM vector for now */
for(i=0;i<vi->channels;i++){
- float *pcm=vb->pcm[i];
int submap=info->chmuxlist[i];
nonzero[i]=look->floor_func[submap]->
- inverse(vb,look->floor_look[submap],pcm);
- _analysis_output("ifloor",seq+i,pcm,n/2,0,1);
+ inverse1(vb,look->floor_look[submap]);
+ memset(vb->pcm[i],0,sizeof(float)*n/2);
}
- /* recover the residue, apply directly to the spectral envelope */
+ /* recover the residue into our working vectors */
for(i=0;i<info->submaps;i++){
int ch_in_bundle=0;
@@ -369,6 +457,42 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
look->residue_func[i]->inverse(vb,look->residue_look[i],pcmbundle,ch_in_bundle);
}
+ /* channel coupling */
+ for(i=info->coupling_steps-1;i>=0;i--){
+ float *pcmM=vb->pcm[info->coupling_mag[i]];
+ float *pcmA=vb->pcm[info->coupling_ang[i]];
+
+ for(j=0;j<n/2;j++){
+ float mag=pcmM[j];
+ float ang=pcmA[j];
+
+ if(mag>0)
+ if(ang>0){
+ pcmM[j]=mag;
+ pcmA[j]=mag-ang;
+ }else{
+ pcmA[j]=mag;
+ pcmM[j]=mag+ang;
+ }
+ else
+ if(ang>0){
+ pcmM[j]=mag;
+ pcmA[j]=mag+ang;
+ }else{
+ pcmA[j]=mag;
+ pcmM[j]=mag-ang;
+ }
+ }
+ }
+
+ /* compute and apply spectral envelope */
+ for(i=0;i<vi->channels;i++){
+ float *pcm=vb->pcm[i];
+ int submap=info->chmuxlist[i];
+ look->floor_func[submap]->
+ inverse2(vb,look->floor_look[submap],nonzero[i],pcm);
+ }
+
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
/* only MDCT right now.... */
for(i=0;i<vi->channels;i++){
@@ -377,9 +501,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
mdct_backward(b->transform[vb->W][0],pcm,pcm);
}
- /* now apply the decoded pre-window time information */
- /* NOT IMPLEMENTED */
-
/* window the data */
for(i=0;i<vi->channels;i++){
float *pcm=vb->pcm[i];
@@ -404,6 +525,3 @@ vorbis_func_mapping mapping0_exportbundle={
&mapping0_pack,&mapping0_unpack,&mapping0_look,&mapping0_copy_info,
&mapping0_free_info,&mapping0_free_look,&mapping0_forward,&mapping0_inverse
};
-
-
-
diff --git a/lib/masking.h b/lib/masking.h
index f5b53650..86ae0723 100644
--- a/lib/masking.h
+++ b/lib/masking.h
@@ -11,19 +11,28 @@
********************************************************************
function: masking curve data for psychoacoustics
- last mod: $Id: masking.h,v 1.15 2001/05/28 21:05:31 xiphmont Exp $
+ last mod: $Id: masking.h,v 1.16 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
#ifndef _V_MASKING_H_
#define _V_MASKING_H_
-/* Not really an ATH, more a bottom curve to limit LSP dynamic range */
-float ATH_Bark_dB[]={
+static float ATH_Bark_dB_lspconservative[]={
15, 15, 15, 15, 11, 10, 8, 7, 7, 7,
6, 2, 0, 0, -3, -5, -6, -6, -4.5f, 2.5f,
10, 15, 15, 15, 15, 15, 15};
+static float ATH_Bark_dB_lineconservative[]={
+ 0, 15, 15, 15, 11, 10, 8, 7, 7, 7,
+ 6, 2, 0, 0, -2, -5, -6, -6, -4, 0,
+ 2, 6, 5, 5, 15, 25, 35};
+
+static float ATH_Bark_dB_lineaggressive[]={
+ 0, 15, 15, 15, 11, 10, 8, 7, 7, 7,
+ 6, 2, 0, 0, -2, -5, -6, -6, -4, 4,
+ 14, 20, 19, 17, 30, 60, 60};
+
/* The below masking curves are straight from the R. Ehmer
(J. Acoustical Society of America) papers ca 1958-59. I modified
them slightly as Ehmer does not correct for the Absolute Threshold
@@ -36,202 +45,202 @@ float ATH_Bark_dB[]={
#define EHMER_OFFSET 16
#define EHMER_MAX 56
-float tone_125_40dB_SL[EHMER_MAX]={
+static float tone_125_40dB_SL[EHMER_MAX]={
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 18, 16, 14, 12, 11, 9, 7, 5, 3, 2, 0, -2, -4, -6, -8,
- -10, -12, -14, -16, -18, -20, -23, -25, -28,-30,-34,-37,-40,-44,-48,-52,
+ -10, -12, -14, -16, -18, -20, -900, -900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_125_60dB_SL[EHMER_MAX]={
+static float tone_125_60dB_SL[EHMER_MAX]={
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 38, 36, 34, 32, 31, 29, 27, 25, 23, 22, 20, 18, 16, 14, 12,
- 10, 8, 6, 4, 2, 0, -3, -5, -8,-10,-14,-17,-20,-24,-28,-32,
+ 10, 8, 6, 4, 2, 0, -3, -5, -8,-10,-14,-17,-20,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_125_80dB_SL[EHMER_MAX]={
+static float tone_125_80dB_SL[EHMER_MAX]={
60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
60, 58, 56, 54, 52, 51, 49, 47, 45, 43, 42, 40, 38, 36, 34, 32,
30, 28, 26, 24, 22, 20, 17, 15, 12, 10, 6, 3, 0, -4, -8,-12,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_125_100dB_SL[EHMER_MAX]={
+static float tone_125_100dB_SL[EHMER_MAX]={
78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
78, 77, 75, 74, 73, 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, 60,
58, 57, 55, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 31, 29,
27, 24, 22, 20, 18, 15, 13, 11};
-float tone_250_40dB_SL[EHMER_MAX]={
+static float tone_250_40dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -19, -13, -7, -1, 4, 9, 15, 20,
22, 23, 22, 19, 18, 18, 16, 13, 9, 7, 3, 1, -1, -3, -6, -8,
- -10, -13, -16, -19, -21, -24, -28, -32, -900,-900,-900,-900,-900,-900,-900,-900,
+ -10, -13, -16, -19,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_250_60dB_SL[EHMER_MAX]={
+static float tone_250_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900, -10, -5, 1, 7, 13, 19, 25, 30, 33,
36, 39, 38, 37, 38, 39, 39, 40, 38, 36, 35, 34, 33, 31, 29, 28,
- 28, 28, 25, 20, 14, 10, 5, 0, -5,-10,-15,-20,-25,-30,-35,-40,
+ 28, 28, 25, 20, 14, 10, 5, 0, -5,-10,-15,-20,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_250_80dB_SL[EHMER_MAX]={
+static float tone_250_80dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900, -10, 10, 17, 24, 30, 37, 41, 48, 49,
50, 53, 54, 53, 53, 54, 55, 57, 57, 57, 58, 59, 60, 58, 57, 58,
59, 58, 57, 54, 52, 50, 49, 47, 46, 47, 46, 44, 43, 42, 41, 40,
38, 32, 27, 22, 17, 11, 6, 0};
/* no data, just interpolated from 80 */
-float tone_250_100dB_SL[EHMER_MAX]={
+static float tone_250_100dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900, -10, 15, 25, 34, 40, 50, 56, 60, 70,
70, 73, 74, 73, 73, 74, 75, 77, 77, 77, 78, 79, 80, 78, 77, 78,
79, 78, 77, 74, 72, 70, 69, 67, 66, 67, 66, 64, 63, 62, 61, 60,
58, 52, 47, 42, 37, 31, 26, 20};
-float tone_500_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900, -40, -26, -20, -14, -8, -2, 4, 10, 17,
- 23, 16, 12, 9, 6, 3, 0, -3, -7, -10, -13, -16, -20, -23, -26, -30,
+static float tone_500_40dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900, -20, -14, -8, -2, 4, 10, 17,
+ 23, 16, 12, 9, 6, 3, 0, -3, -7, -10, -13, -16, -20,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_500_60dB_SL[EHMER_MAX]={
+static float tone_500_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900,-900, -18, -12, -6, 0, 6, 13, 20, 30,
39, 34, 31, 29, 29, 27, 24, 21, 18, 16, 13, 8, 6, 3, 1, -1,
- -5, -2, -5, -8, -12, -15, -18, -22, -900,-900,-900,-900,-900,-900,-900,-900,
+ -5, -2, -5, -8, -12, -15, -18,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_500_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -22,-16,-10, 0, 10, 20, 32, 43,
+static float tone_500_80dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-16,-10, 0, 10, 20, 32, 43,
53, 52, 52, 50, 49, 50, 52, 55, 55, 54, 51, 49, 46, 44, 44, 42,
38, 34, 32, 29, 29, 28, 25, 23, 20, 16, 10, 7, 4, 2, -1, -4,
- -7, -10, -15, -20, -25, -30, -35, -40};
-float tone_500_100dB_SL[EHMER_MAX]={
+ -7, -10, -15, -20,-900,-900,-900,-900};
+static float tone_500_100dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900, -10, -7, 2, 10, 19, 27, 35, 55, 56,
62, 61, 60, 58, 57, 57, 59, 63, 65, 66, 62, 60, 57, 57, 58, 58,
57, 56, 56, 56, 57, 57, 56, 57, 57, 54, 47, 41, 37, 28, 21, 16,
- 10, 3, -3, -8, -13, -18, -23, -28};
+ 10, 3, -3, -8, -13, -18,-900,-900};
-float tone_1000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -55, -40, -30, -20, -10, 0, 9, 20,
- 27, 20, 13, 14, 13, 5, -1, -6, -11, -20, -30,-900,-900,-900,-900,-900,
+static float tone_1000_40dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900, -20, -10, 0, 9, 20,
+ 27, 20, 13, 14, 13, 5, -1, -6, -11, -20,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_1000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900, -43, -33,-23,-13, -3, 7, 17, 25, 37,
+static float tone_1000_60dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-13,-3, 7, 17, 25, 37,
42, 33, 25, 25, 23, 18, 13, 9, 4, -1, -7,-13,-18, -23, -28, -33,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_1000_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900, -35, -25,-14, -4, 6, 16, 27, 33, 50,
+static float tone_1000_80dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-14, -4, 6, 16, 27, 33, 50,
59, 57, 47, 41, 40, 43, 47, 48, 47, 42, 39, 37, 37, 36, 35, 32,
30, 27, 21, 15, 5, -2, -10, -18, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_1000_100dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900, -40, -30, -20,-10, 0, 10, 23, 33, 45, 60,
+static float tone_1000_100dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-10, 0, 10, 23, 33, 45, 60,
70, 72, 55, 49, 43, 40, 44, 54, 59, 58, 49, 43, 52, 57, 57, 58,
- 58, 54, 49, 47, 42, 39, 33, 28, 20, 15, 5, 0, -5,-15,-20,-25,
+ 58, 54, 49, 47, 42, 39, 33, 28, 20, 15, 5, 0, -5,-15,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_2000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -3, 5, 12, 20,
- 24, 21, 14, 5, -5, -15, -25, -35, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_2000_40dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900, 5, 12, 20,
+ 24, 14, 8, 0, -5,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_2000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 8, 19, 31,
- 38, 34, 24, 17, 14, 13, 11, 7, 3, -2, -6, -10, -14, -20, -26, -32,
+static float tone_2000_60dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -2, 8, 19, 31,
+ 38, 30, 15, 15, 15, 13, 8, 5, -2,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_2000_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 13, 28, 40,
- 51, 51, 43, 35, 28, 29, 35, 37, 37, 35, 31, 28, 25, 22, 19, 15,
- 11, 8, 6, 2, -6, -14, -22, -30, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_2000_80dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 2, 10, 22, 38,
+ 52, 51, 40, 30, 28, 30, 33, 37, 37, 35, 31, 26, 20, 15, 10, 5,
+ 0,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_2000_100dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -10, 6, 25, 42, 60,
- 66, 60, 53, 43, 35, 31, 34, 47, 58, 51, 43, 45, 54, 59, 59, 56,
- 54, 51, 40, 29, 20, 11, 2, -8, -17, -26, -35,-900,-900,-900,-900,-900,
+static float tone_2000_100dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 6, 20, 40, 55,
+ 66, 60, 53, 40, 35, 31, 34, 42, 58, 48, 43, 45, 52, 57, 50, 42,
+ 45, 45, 35, 25, 20, 11, 2,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_4000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, 0, 3, 10, 18,
- 24, 21, 14, 5, -5, -15, -25, -35, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_4000_40dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900, 2, 4, 18,
+ 24, 10, 5, 0, -5,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_4000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, -2, 8, 19, 31,
- 38, 33, 28, 23, 19, 14, 11, 8, 3, -2, -7, -12, -17, -22, -27, -37,
+static float tone_4000_60dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -2, 2, 4, 20,
+ 38, 30, 22, 15, 10, 5, 0, -10, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_4000_80dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -60, -50, -40, -29, -12, 5, 19, 37,
- 51, 49, 40, 35, 36, 36, 36, 33, 32, 24, 18, 8, -3, -12, -20, -29,
+static float tone_4000_80dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, 0, 4, 10, 35,
+ 51, 49, 35, 35, 36, 36, 36, 31, 25, 20, 10, 0,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_4000_100dB_SL[EHMER_MAX]={
- -20, -12, -8, -4, 0, 4, 8, 11, 15, 22, 26, 28, 32, 36, 43, 52,
- 62, 59, 50, 48, 50, 50, 45, 36, 45, 30, 20, 10, 0, -10, -19, -28,
- -37,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_4000_100dB_SL[EHMER_MAX]={
+-900, -5, 1, 3, 5, 8, 10, 12, 14, 20, 26, 28, 32, 36, 41, 51,
+ 61, 59, 45, 45, 48, 48, 40, 25, 40, 30, 18, 5, 0, -900,-900,-900,
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_8000_40dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900,-900, -40, -30, -21, -12, 0, 3, 10, 18,
- 24, 21, 14, 5, 0, 0, 5, 10, 15, 25, 30, 45, 50, 55, 60, 65,
- 70, 75, 80, 85, 90, 95, 100, 100, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_8000_40dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -10, 3, 10, 18,
+ 26, 21, 14, 5, 0, 0, 5, 10, 20, 35, 55, 45, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_8000_60dB_SL[EHMER_MAX]={
--900,-900,-900,-900,-900,-900,-900, -10, -21, -18, -14, -10, 0, 3, 15, 30,
- 43, 40, 36, 35, 36, 38, 41, 43, 45, 47, 50, 55, 60, 65, 70, 75,
- 80, 85, 90, 95, 100, 100, 100, 100, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_8000_60dB_SL[EHMER_MAX]={
+-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900, -10, 5, 12, 30,
+ 43, 40, 36, 35, 36, 38, 41, 43, 45, 60, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_8000_80dB_SL[EHMER_MAX]={
+static float tone_8000_80dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900,-900,-900, -10, -1, 2, 6, 10, 13, 19, 25, 35,
- 63, 55, 50, 48, 46, 45, 45, 50, 55, 65, 75, 80, 85, 90, 95, 100,
- 100, 100, 100, 100,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
+ 63, 59, 57, 56, 57, 59, 61, 62, 63, 65, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float tone_8000_100dB_SL[EHMER_MAX]={
- -18, -12, -7, -3, 0, 2, 6, 9, 12, 19, 22, 21, 19, 21, 40, 40,
- 80, 60, 35, 25, 15, 5, 5, 5, 25, 30, 35, 43, 50, 55, 60, 65,
- 70, 75, 80, 85, 90, 95, 100, 100, -900,-900,-900,-900,-900,-900,-900,-900,
+static float tone_8000_100dB_SL[EHMER_MAX]={
+ -18, -12, -7, -3, 0, 2, 5, 8, 10, 14, 18, 20, 20, 22, 40, 40,
+ 70, 50, 30, 30, 30, 30, 30, 30, 30, 40, 70, 70, 70, 70, 70, 70,
+ 70, 70, 70, 70, 70, 70, 70, 70, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
#if 0 /* not used for the time being */
-float noise_500_60dB_SL[EHMER_MAX]={
+static float noise_500_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900,-900, -20, -11, -2, 7, 16, 25, 34, 43, 52, 61, 66,
69, 68, 58, 50, 44, 38, 32, 28, 25, 24, 20, 18, 17, 12, 10, 8,
5, 0, -5, -8, -12, -15, -18, -22, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_500_80dB_SL[EHMER_MAX]={
+static float noise_500_80dB_SL[EHMER_MAX]={
-900,-900,-900, -20, -10, -1, 8, 17, 26, 35, 44, 53, 62, 70, 79, 83,
85, 85, 81, 77, 74, 71, 68, 63, 61, 59, 56, 55, 54, 52, 48, 47,
45, 46, 45, 43, 40, 37, 33, 32, 35, 32, 30, 29, 20, 10, 0, -10,
-20, -30,-900,-900,-900,-900,-900,-900};
-float noise_1000_60dB_SL[EHMER_MAX]={
+static float noise_1000_60dB_SL[EHMER_MAX]={
-900,-900,-900,-900, -24, -15, -6, 3, 12, 21, 28, 34, 40, 48, 57, 60,
61, 56, 54, 45, 36, 27, 21, 19, 17, 13, 10, 0, -10, -20, -20,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_1000_80dB_SL[EHMER_MAX]={
+static float noise_1000_80dB_SL[EHMER_MAX]={
-900, -26, -17, -8, 1, 10, 19, 28, 37, 41, 46, 51, 58, 68, 74, 81,
80, 81, 70, 66, 58, 61, 59, 55, 54, 53, 52, 49, 48, 42, 38, 38,
39, 34, 30, 27, 20, 10, 0, -10, -20, -30,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_2000_60dB_SL[EHMER_MAX]={
+static float noise_2000_60dB_SL[EHMER_MAX]={
-900,-900,-900, -34, -25, -16, -7, 2, 11, 18, 23, 30, 35, 42, 51, 58,
58, 57, 50, 40,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_2000_80dB_SL[EHMER_MAX]={
+static float noise_2000_80dB_SL[EHMER_MAX]={
-900, -26, -17, -8, 1, 10, 19, 28, 33, 38, 43, 48, 53, 62, 70, 77,
77, 75, 70, 67, 68, 66, 62, 61, 60, 59, 52, 47, 39, 35, 34, 35,
35, 33, 30, 27, 20, 10, 0, -10, -20, -30,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_4000_60dB_SL[EHMER_MAX]={
+static float noise_4000_60dB_SL[EHMER_MAX]={
-900,-900,-900, -34, -25, -16, -7, 2, 11, 20, 25, 31, 37, 45, 56, 62,
64, 61,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900, -900,-900,-900,-900,-900,-900,-900,-900,
-900,-900,-900,-900,-900,-900,-900,-900};
-float noise_4000_80dB_SL[EHMER_MAX]={
+static float noise_4000_80dB_SL[EHMER_MAX]={
-900, -26, -17, -8, 1, 10, 19, 26, 33, 39, 45, 50, 55, 65, 75, 82,
84, 81, 78, 72, 70, 69, 66, 61, 50, 48, 46, 40, 35, 30, 25, 20,
15, 10, 5, 0, -10, -20, -30,-900, -900,-900,-900,-900,-900,-900,-900,-900,
diff --git a/lib/modes/modes.h b/lib/modes/modes.h
index 0ed4d160..b218e76e 100644
--- a/lib/modes/modes.h
+++ b/lib/modes/modes.h
@@ -11,13 +11,14 @@
********************************************************************
function: predefined encoding modes
- last mod: $Id: modes.h,v 1.7 2001/02/26 03:51:10 xiphmont Exp $
+ last mod: $Id: modes.h,v 1.8 2001/06/15 21:15:43 xiphmont Exp $
********************************************************************/
#ifndef _V_MODES_H_
#define _V_MODES_H_
+#include "masking.h"
#include "modes/mode_AA.h"
#include "modes/mode_A.h"
#include "modes/mode_B.h"
diff --git a/lib/psy.c b/lib/psy.c
index e81408de..7f32aa80 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.45 2001/05/27 06:44:00 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.46 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
@@ -97,6 +97,7 @@ static void setup_curve(float **c,
int i,j;
float ath[EHMER_MAX];
float tempc[P_LEVELS][EHMER_MAX];
+ float *ATH=ATH_Bark_dB_lineconservative; /* just for limiting here */
memcpy(c[0]+2,c[4]+2,sizeof(float)*EHMER_MAX);
memcpy(c[2]+2,c[4]+2,sizeof(float)*EHMER_MAX);
@@ -116,18 +117,18 @@ static void setup_curve(float **c,
float ath_min,ath_max;
if(ibark<26)
- ath_min=ATH_Bark_dB[ibark]*(1.f-del)+ATH_Bark_dB[ibark+1]*del;
+ ath_min=ATH[ibark]*(1.f-del)+ATH[ibark+1]*del;
else
- ath_min=ATH_Bark_dB[25];
+ ath_min=ATH[25];
bark=toBARK(fromOC(oc_max));
ibark=floor(bark);
del=bark-ibark;
if(ibark<26)
- ath_max=ATH_Bark_dB[ibark]*(1.f-del)+ATH_Bark_dB[ibark+1]*del;
+ ath_max=ATH[ibark]*(1.f-del)+ATH[ibark+1]*del;
else
- ath_max=ATH_Bark_dB[25];
+ ath_max=ATH[25];
ath[i]=min(ath_min,ath_max);
}
@@ -190,7 +191,8 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate){
maxoc=toOC((n*.5f-.25f)*rate/n)*(1<<(p->shiftoc+1))+.5f;
p->total_octave_lines=maxoc-p->firstoc+1;
- p->ath=_ogg_malloc(n*sizeof(float));
+ if(vi->ath)
+ p->ath=_ogg_malloc(n*sizeof(float));
p->octave=_ogg_malloc(n*sizeof(long));
p->bark=_ogg_malloc(n*sizeof(unsigned long));
p->vi=vi;
@@ -198,17 +200,18 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi,int n,long rate){
/* set up the lookups for a given blocksize and sample rate */
/* Vorbis max sample rate is currently limited by 26 Bark (54kHz) */
- set_curve(ATH_Bark_dB, p->ath,n,rate);
+ if(vi->ath)
+ set_curve(vi->ath, p->ath,n,rate);
for(i=0;i<n;i++){
float bark=toBARK(rate/(2*n)*i);
for(;lo+vi->noisewindowlomin<i &&
- toBARK(rate/(2*n)*lo)<=(bark-vi->noisewindowlo);lo++);
+ toBARK(rate/(2*n)*lo)<(bark-vi->noisewindowlo);lo++);
for(;hi<n && (hi<i+vi->noisewindowhimin ||
- toBARK(rate/(2*n)*hi)<=(bark+vi->noisewindowhi));hi++);
+ toBARK(rate/(2*n)*hi)<(bark+vi->noisewindowhi));hi++);
- p->bark[i]=((hi+1)<<16)+(lo+1);
+ p->bark[i]=(hi<<16)+lo;
}
@@ -572,15 +575,18 @@ static void bark_noise_median(int n,const long *b,const float *f,
int fixedcountbelow=0;
memset(barkradix,0,sizeof(barkradix));
- memset(fixedradix,0,sizeof(fixedradix));
-
- /* bootstrap the fixed window case seperately */
- for(i=0;i<(fixed>>1);i++){
- int bin=psy_dBquant(f+i);
- fixedradix[bin]++;
- fixedc++;
- if(bin<=median)
- fixedcountbelow++;
+
+ if(fixed>0){
+ memset(fixedradix,0,sizeof(fixedradix));
+
+ /* bootstrap the fixed window case seperately */
+ for(i=0;i<(fixed>>1);i++){
+ int bin=psy_dBquant(f+i);
+ fixedradix[bin]++;
+ fixedc++;
+ if(bin<=median)
+ fixedcountbelow++;
+ }
}
for(i=0;i<n;i++){
@@ -600,43 +606,58 @@ static void bark_noise_median(int n,const long *b,const float *f,
barkcountbelow--;
}
- bi=i+(fixed>>1);
- if(bi<n){
- int bin=psy_dBquant(f+bi);
- fixedradix[bin]++;
- fixedc++;
- if(bin<=median)
- fixedcountbelow++;
- }
-
- bi-=fixed;
- if(bi>=0){
- int bin=psy_dBquant(f+bi);
- fixedradix[bin]--;
- fixedc--;
- if(bin<=median)
- fixedcountbelow--;
+ if(fixed>0){
+ bi=i+(fixed>>1);
+ if(bi<n){
+ int bin=psy_dBquant(f+bi);
+ fixedradix[bin]++;
+ fixedc++;
+ if(bin<=median)
+ fixedcountbelow++;
+ }
+
+ bi-=fixed;
+ if(bi>=0){
+ int bin=psy_dBquant(f+bi);
+ fixedradix[bin]--;
+ fixedc--;
+ if(bin<=median)
+ fixedcountbelow--;
+ }
}
/* move the median if needed */
{
int bark_th = (thresh[i]*(hi-lo)+512)/1024;
- int fixed_th = (thresh[i]*(fixedc)+512)/1024;
-
- while(bark_th>=barkcountbelow &&
- fixed_th>=fixedcountbelow /* && median<LASTBIN by rep invariant */
- ){
- median++;
- barkcountbelow+=barkradix[median];
- fixedcountbelow+=fixedradix[median];
- }
-
- while(bark_th<barkcountbelow ||
- fixed_th<fixedcountbelow /* && median>=0 by rep invariant */
- ){
- barkcountbelow-=barkradix[median];
- fixedcountbelow-=fixedradix[median];
- median--;
+
+ if(fixed>0){
+ int fixed_th = (thresh[i]*(fixedc)+512)/1024;
+
+ while(bark_th>=barkcountbelow &&
+ fixed_th>=fixedcountbelow /* && median<LASTBIN by rep invariant */
+ ){
+ median++;
+ barkcountbelow+=barkradix[median];
+ fixedcountbelow+=fixedradix[median];
+ }
+
+ while(bark_th<barkcountbelow ||
+ fixed_th<fixedcountbelow /* && median>=0 by rep invariant */
+ ){
+ barkcountbelow-=barkradix[median];
+ fixedcountbelow-=fixedradix[median];
+ median--;
+ }
+ }else{
+ while(bark_th>=barkcountbelow){
+ median++;
+ barkcountbelow+=barkradix[median];
+ }
+
+ while(bark_th<barkcountbelow){
+ barkcountbelow-=barkradix[median];
+ median--;
+ }
}
}
@@ -684,7 +705,7 @@ float _vp_compute_mask(vorbis_look_psy *p,
/* set the ATH (floating below localmax, not global max by a
specified att) */
- if(p->vi->athp){
+ if(p->vi->ath){
float att=localmax+p->vi->ath_adjatt;
if(att<p->vi->ath_maxatt)att=p->vi->ath_maxatt;
diff --git a/lib/psy.h b/lib/psy.h
index cc724da2..4047f59b 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.20 2001/05/27 06:44:00 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.21 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
@@ -28,7 +28,7 @@
#define P_BANDS 17
#define P_LEVELS 11
typedef struct vorbis_info_psy{
- int athp;
+ float *ath;
int decayp;
float ath_adjatt;
diff --git a/lib/registry.c b/lib/registry.c
index 1fcac859..c35b6bb9 100644
--- a/lib/registry.c
+++ b/lib/registry.c
@@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.c,v 1.7 2001/05/27 06:44:00 xiphmont Exp $
+ last mod: $Id: registry.c,v 1.8 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
@@ -27,6 +27,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_residue residue2_exportbundle;
extern vorbis_func_mapping mapping0_exportbundle;
vorbis_func_time *_time_P[]={
@@ -41,6 +42,7 @@ vorbis_func_floor *_floor_P[]={
vorbis_func_residue *_residue_P[]={
&residue0_exportbundle,
&residue1_exportbundle,
+ &residue2_exportbundle,
};
vorbis_func_mapping *_mapping_P[]={
diff --git a/lib/registry.h b/lib/registry.h
index d29a6aa3..53d7c4a7 100644
--- a/lib/registry.h
+++ b/lib/registry.h
@@ -11,7 +11,7 @@
********************************************************************
function: registry for time, floor, res backends and channel mappings
- last mod: $Id: registry.h,v 1.6 2001/05/27 06:44:00 xiphmont Exp $
+ last mod: $Id: registry.h,v 1.7 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
@@ -24,7 +24,7 @@
#define VI_WINDOWB 1
#define VI_TIMEB 1
#define VI_FLOORB 2
-#define VI_RESB 2
+#define VI_RESB 3
#define VI_MAPB 1
extern vorbis_func_time *_time_P[];
diff --git a/lib/res0.c b/lib/res0.c
index d8e94d40..0bab0712 100644
--- a/lib/res0.c
+++ b/lib/res0.c
@@ -10,8 +10,8 @@
* *
********************************************************************
- function: residue backend 0 and 1 implementation
- last mod: $Id: res0.c,v 1.30 2001/06/05 01:14:44 xiphmont Exp $
+ function: residue backend 0, 1 and 2 implementation
+ last mod: $Id: res0.c,v 1.31 2001/06/15 21:15:40 xiphmont Exp $
********************************************************************/
@@ -45,6 +45,12 @@ typedef struct {
int partvals;
int **decodemap;
+ /*long resbits[32][32];
+ long resbitsflat;
+ long resvals[32];
+ long phrasebits;
+ long frames;*/
+
} vorbis_look_residue0;
vorbis_info_residue *res0_copy_info(vorbis_info_residue *vr){
@@ -62,9 +68,31 @@ void res0_free_info(vorbis_info_residue *i){
}
void res0_free_look(vorbis_look_residue *i){
- int j;
+ int j,k;
if(i){
+
vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
+ vorbis_info_residue0 *info=look->info;
+
+ /*fprintf(stderr,
+ "%ld frames encoded in %ld phrasebits and %ld residue bits "
+ "(%g/frame) \n",look->frames,look->phrasebits,
+ look->resbitsflat,
+ (look->phrasebits+look->resbitsflat)/(float)look->frames);
+
+ for(j=0;j<look->parts;j++){
+ long acc=0;
+ fprintf(stderr,"\t[%d] == ",j);
+ for(k=0;k<look->stages;k++)
+ if((info->secondstages[j]>>k)&1){
+ fprintf(stderr,"%ld,",look->resbits[j][k]);
+ acc+=look->resbits[j][k];
+ }
+
+ fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j],
+ acc?(float)acc/(look->resvals[j]*info->grouping):0);
+ }
+ fprintf(stderr,"\n");*/
for(j=0;j<look->parts;j++)
if(look->partbooks[j])_ogg_free(look->partbooks[j]);
@@ -366,6 +394,22 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
long **partword=_vorbis_block_alloc(vb,ch*sizeof(long *));
+#ifdef TRAIN_RES
+ FILE *of;
+ char buffer[80];
+ int m;
+
+ for(i=0;i<ch;i++){
+ sprintf(buffer,"residue_%d.vqd",vb->mode);
+ of=fopen(buffer,"a");
+ for(m=0;m<info->end;m++)
+ fprintf(of,"%.2f, ",in[i][m]);
+ fprintf(of,"\n");
+ fclose(of);
+ }
+
+#endif
+
partvals=partwords*partitions_per_word;
/* we find the patition type for each partition of each
@@ -391,6 +435,7 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
residual words for that partition word. Then write the next
partition channel words... */
+ /*look->frames++;*/
for(s=0;s<look->stages;s++){
for(i=info->begin,l=0;i<info->end;){
@@ -398,9 +443,11 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
if(s==0){
for(j=0;j<ch;j++){
long val=partword[j][l];
+ long ret;
for(k=1;k<partitions_per_word;k++)
val= val*possible_partitions+partword[j][l+k];
- vorbis_book_encode(look->phrasebook,val,&vb->opb);
+ ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
+ /*look->phrasebits+=ret;*/
}
}
@@ -408,11 +455,15 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
for(k=0;k<partitions_per_word;k++,l++,i+=samples_per_partition){
for(j=0;j<ch;j++){
+ /*if(s==0)look->resvals[partword[j][l]]++;*/
if(info->secondstages[partword[j][l]]&(1<<s)){
codebook *statebook=look->partbooks[partword[j][l]][s];
if(statebook){
int ret=encode(&vb->opb,in[j]+i,samples_per_partition,
statebook,look);
+ /*look->resbits[partword[j][l]][s]+=ret;
+ look->resbitsflat+=ret;*/
+
}
}
}
@@ -427,9 +478,9 @@ static int _01forward(vorbis_block *vb,vorbis_look_residue *vl,
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
float **in,int ch,
long (*decodepart)(codebook *, float *,
- oggpack_buffer *,int,int)){
+ oggpack_buffer *,int)){
- long i,j,k,l,s,transend=vb->pcmend/2;
+ long i,j,k,l,s;
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
vorbis_info_residue0 *info=look->info;
@@ -441,15 +492,10 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
int partvals=n/samples_per_partition;
int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
int ***partword=alloca(ch*sizeof(int **));
- float **work=alloca(ch*sizeof(float *));
partvals=partwords*partitions_per_word;
- /* make sure we're zeroed up to the start */
- for(j=0;j<ch;j++){
- work[j]=_vorbis_block_alloc(vb,n*sizeof(float));
+ for(j=0;j<ch;j++)
partword[j]=_vorbis_block_alloc(vb,partwords*sizeof(int *));
- memset(work[j],0,sizeof(float)*n);
- }
for(s=0;s<look->stages;s++){
for(i=info->begin,l=0;i<info->end;l++){
@@ -470,28 +516,16 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
if(info->secondstages[partword[j][l][k]]&(1<<s)){
codebook *stagebook=look->partbooks[partword[j][l][k]][s];
if(stagebook){
- if(decodepart(stagebook,work[j]+i,&vb->opb,
- samples_per_partition,0)==-1)goto eopbreak;
+ if(decodepart(stagebook,in[j]+i,&vb->opb,
+ samples_per_partition)==-1)goto eopbreak;
}
}
}
}
}
-
- eopbreak:
- for(j=0;j<ch;j++){
- for(i=0;i<n;i++)
- in[j][i]*=work[j][i];
- for(;i<transend;i++)
- in[j][i]=0;
- }
-
- return(0);
-
errout:
- for(j=0;j<ch;j++)
- memset(in[j],0,sizeof(float)*transend);
+ eopbreak:
return(0);
}
@@ -503,7 +537,7 @@ int res0_forward(vorbis_block *vb,vorbis_look_residue *vl,
}
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
- return(_01inverse(vb,vl,in,ch,vorbis_book_decodevs));
+ return(_01inverse(vb,vl,in,ch,vorbis_book_decodevs_add));
}
int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
@@ -512,9 +546,74 @@ int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
}
int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
- return(_01inverse(vb,vl,in,ch,vorbis_book_decodev));
+ return(_01inverse(vb,vl,in,ch,vorbis_book_decodev_add));
+}
+
+/* res2 is slightly more different; all the channels are interleaved
+ into a single vector and encoded. */
+int res2_forward(vorbis_block *vb,vorbis_look_residue *vl,
+ float **in,int ch){
+ long i,j,k,n=vb->pcmend/2;
+
+ /* don't duplicate the code; use a working vector hack for now and
+ reshape ourselves into a single channel res1 */
+ float *work=_vorbis_block_alloc(vb,ch*n*sizeof(float));
+ for(i=0;i<ch;i++){
+ float *pcm=vb->pcm[i];
+ for(j=0,k=i;j<n;j++,k+=ch)
+ work[k]=pcm[j];
+ }
+
+ return(_01forward(vb,vl,&work,1,_testhack,_encodepart));
+}
+
+/* duplicate code here as speed is somewhat more important */
+int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
+ long i,k,l,s;
+ vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
+ vorbis_info_residue0 *info=look->info;
+
+ /* move all this setup out later */
+ int samples_per_partition=info->grouping;
+ int partitions_per_word=look->phrasebook->dim;
+ int n=info->end-info->begin;
+
+ int partvals=n/samples_per_partition;
+ int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
+ int **partword=_vorbis_block_alloc(vb,partwords*sizeof(int *));
+ partvals=partwords*partitions_per_word;
+
+ for(s=0;s<look->stages;s++){
+ for(i=info->begin,l=0;i<info->end;l++){
+
+ if(s==0){
+ /* fetch the partition word */
+ int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
+ if(temp==-1)goto eopbreak;
+ partword[l]=look->decodemap[temp];
+ if(partword[l]==NULL)goto errout;
+ }
+
+ /* now we decode residual values for the partitions */
+ for(k=0;k<partitions_per_word;k++,i+=samples_per_partition)
+ if(info->secondstages[partword[l][k]]&(1<<s)){
+ codebook *stagebook=look->partbooks[partword[l][k]][s];
+
+ if(stagebook){
+ if(vorbis_book_decodevv_add(stagebook,in,i,ch,
+ &vb->opb,samples_per_partition)==-1)
+ goto eopbreak;
+ }
+ }
+ }
+ }
+
+ errout:
+ eopbreak:
+ return(0);
}
+
vorbis_func_residue residue0_exportbundle={
&res0_pack,
&res0_unpack,
@@ -536,3 +635,14 @@ vorbis_func_residue residue1_exportbundle={
&res1_forward,
&res1_inverse
};
+
+vorbis_func_residue residue2_exportbundle={
+ &res0_pack,
+ &res0_unpack,
+ &res0_look,
+ &res0_copy_info,
+ &res0_free_info,
+ &res0_free_look,
+ &res2_forward,
+ &res2_inverse
+};
diff --git a/vq/distribution.c b/vq/distribution.c
index 93c40fd9..adabcb68 100644
--- a/vq/distribution.c
+++ b/vq/distribution.c
@@ -11,7 +11,7 @@
********************************************************************
function: utility for finding the distribution in a data set
- last mod: $Id: distribution.c,v 1.5 2001/05/27 06:44:07 xiphmont Exp $
+ last mod: $Id: distribution.c,v 1.6 2001/06/15 21:15:43 xiphmont Exp $
********************************************************************/
@@ -102,7 +102,24 @@ int main(int argc,char *argv[]){
for(i=0;i<b->entries;i++)
if(c->lengthlist[i]>base)base=c->lengthlist[i];
-
+
+ /* dump a full, correlated count */
+ for(j=0;j<b->entries;j++){
+ if(c->lengthlist[j]){
+ int indexdiv=1;
+ printf("%4ld: ",j);
+ for(k=0;k<b->dim;k++){
+ int index= (j/indexdiv)%bins;
+ printf("%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+
+ _float32_unpack(c->q_min));
+ indexdiv*=bins;
+ }
+ printf("\t|",(1<<(base-c->lengthlist[j])));
+ for(k=0;k<base-c->lengthlist[j];k++)printf("*");
+ printf("\n");
+ }
+ }
+
/* do a rough count */
for(j=0;j<b->entries;j++){
int indexdiv=1;
diff --git a/vq/latticetune.c b/vq/latticetune.c
index 6ae38843..c56f6cb0 100644
--- a/vq/latticetune.c
+++ b/vq/latticetune.c
@@ -12,7 +12,7 @@
function: utility main for setting entropy encoding parameters
for lattice codebooks
- last mod: $Id: latticetune.c,v 1.8 2001/06/04 05:50:12 xiphmont Exp $
+ last mod: $Id: latticetune.c,v 1.9 2001/06/15 21:15:43 xiphmont Exp $
********************************************************************/
@@ -162,6 +162,29 @@ int main(int argc,char *argv[]){
c->lengthlist=lengths;
write_codebook(stdout,name,c);
+
+ {
+ long bins=_book_maptype1_quantvals(c);
+ long i,k,base=c->lengthlist[0];
+ for(i=0;i<entries;i++)
+ if(c->lengthlist[i]>base)base=c->lengthlist[i];
+
+ for(j=0;j<entries;j++){
+ if(c->lengthlist[j]){
+ int indexdiv=1;
+ fprintf(stderr,"%4ld: ",j);
+ for(k=0;k<c->dim;k++){
+ int index= (j/indexdiv)%bins;
+ fprintf(stderr,"%+3.1f,", c->quantlist[index]*_float32_unpack(c->q_delta)+
+ _float32_unpack(c->q_min));
+ indexdiv*=bins;
+ }
+ fprintf(stderr,"\t|",(1<<(base-c->lengthlist[j])));
+ for(k=0;k<base-c->lengthlist[j];k++)fprintf(stderr,"*");
+ fprintf(stderr,"\n");
+ }
+ }
+ }
fprintf(stderr,"\r "
"\nDone.\n");
diff --git a/vq/make_residue_books.pl b/vq/make_residue_books.pl
index f0fc78cc..60b5ed29 100755
--- a/vq/make_residue_books.pl
+++ b/vq/make_residue_books.pl
@@ -19,9 +19,24 @@
die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]);
+$goflag=0;
while($line=<F>){
print "\n#### $line\n\n";
+ if($line=~m/^GO/){
+ $goflag=1;
+ next;
+ }
+
+ if($goflag==0){
+ if($line=~m/\S+/ && !($line=~m/^\#/) ){
+ my $command=$line;
+ print ">>> $command\n";
+ die "Couldn't shell command.\n\tcommand:$command\n"
+ if syst($command);
+ }
+ next;
+ }
# >res0_128_128
if($line=~m/^>(\S+)\s+(\S*)/){
diff --git a/vq/res_128k.vqs b/vq/res_128k.vqs
index e8c3aa78..597165ab 100644
--- a/vq/res_128k.vqs
+++ b/vq/res_128k.vqs
@@ -1,4 +1,4 @@
->res0_128_128
+>res0_128_128 noninterleave
haux res0_128_128aux.vqd 0,6,3
:_1 res0_128_128_1.vqd, 4, nonseq, 0 +- 1
:_2 res0_128_128_2.vqd, 2, nonseq, 0 +- 1 2 3
@@ -6,7 +6,7 @@ haux res0_128_128aux.vqd 0,6,3
:_4 res0_128_128_4.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
:_5 res0_128_128_5.vqd, 1, nonseq, 0 +- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
->res0_128_1024
+>res0_128_1024 noninterleave
haux res0_128_1024aux.vqd 0,30,2
:_1 res0_128_1024_1.vqd, 4, nonseq, 0 +- 1
:_2 res0_128_1024_2.vqd, 4, nonseq, 0 +- 1