[xiph-cvs] cvs commit: vorbis/lib/modes mode_A.h
Monty
xiphmont at xiph.org
Tue May 1 10:08:39 PDT 2001
xiphmont 01/05/01 10:08:38
Modified: lib Tag: monty-branch-20010404 Makefile.am barkmel.c
floor1.c info.c mapping0.c vorbisenc.c
lib/modes Tag: monty-branch-20010404 mode_A.h
Log:
Floor 1 is now functional. Time for full QA.
Monty
Revision Changes Path
No revision
No revision
1.11.4.1 +3 -2 vorbis/lib/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -u -r1.11 -r1.11.4.1
--- Makefile.am 2001/02/19 07:48:39 1.11
+++ Makefile.am 2001/05/01 17:08:36 1.11.4.1
@@ -8,8 +8,9 @@
lib_LTLIBRARIES = libvorbis.la libvorbisfile.la libvorbisenc.la
-libvorbis_la_SOURCES = mdct.c smallft.c block.c envelope.c window.c lsp.c lpc.c\
- analysis.c synthesis.c psy.c info.c time0.c floor0.c\
+libvorbis_la_SOURCES = mdct.c smallft.c block.c envelope.c window.c lsp.c \
+ lpc.c analysis.c synthesis.c psy.c info.c time0.c \
+ floor1.c floor0.c\
res0.c mapping0.c registry.c codebook.c sharedbook.c\
lookup.c bitbuffer.c\
envelope.h lpc.h lsp.h codebook.h misc.h psy.h\
1.5.4.2 +4 -4 vorbis/lib/barkmel.c
Index: barkmel.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/barkmel.c,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -r1.5.4.1 -r1.5.4.2
--- barkmel.c 2001/04/29 22:21:04 1.5.4.1
+++ barkmel.c 2001/05/01 17:08:36 1.5.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: bark scale utility
- last mod: $Id: barkmel.c,v 1.5.4.1 2001/04/29 22:21:04 xiphmont Exp $
+ last mod: $Id: barkmel.c,v 1.5.4.2 2001/05/01 17:08:36 xiphmont Exp $
********************************************************************/
@@ -54,9 +54,9 @@
{
float i;
int j;
- for(i=0.,j=0;i<28;i+=.816,j++){
- fprintf(stderr,"(%d) bark=%f %gHz (%d of 1024)\n",
- j,i,fromBARK(i),(int)(fromBARK(i)/22050.*1024.));
+ for(i=0.,j=0;i<28;i+=2.107,j++){
+ fprintf(stderr,"(%d) bark=%f %gHz (%d of 128)\n",
+ j,i,fromBARK(i),(int)(fromBARK(i)/22050.*128.));
}
}
return(0);
1.1.2.3 +101 -49 vorbis/lib/Attic/floor1.c
Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/Attic/floor1.c,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- floor1.c 2001/04/29 22:21:04 1.1.2.2
+++ floor1.c 2001/05/01 17:08:36 1.1.2.3
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.1.2.2 2001/04/29 22:21:04 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.1.2.3 2001/05/01 17:08:36 xiphmont Exp $
********************************************************************/
@@ -121,7 +121,7 @@
oggpack_write(opb,info->class_dim[j]-1,3); /* 1 to 8 */
oggpack_write(opb,info->class_subs[j],2); /* 0 to 3 */
if(info->class_subs[j])oggpack_write(opb,info->class_book[j],8);
- for(k=0;k<info->class_subs[j];k++)
+ for(k=0;k<(1<<info->class_subs[j]);k++)
oggpack_write(opb,info->class_subbook[j][k]+1,8);
}
@@ -140,7 +140,7 @@
static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=vi->codec_setup;
- int j,k,count,maxclass=-1,rangebits;
+ int j,k,count=0,maxclass=-1,rangebits;
vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(vorbis_info_floor1));
/* read partitions */
@@ -159,7 +159,7 @@
if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8);
if(info->class_book[j]<0 || info->class_book[j]>=ci->books)
goto err_out;
- for(k=0;k<info->class_subs[j];k++){
+ for(k=0;k<(1<<info->class_subs[j]);k++){
info->class_subbook[j][k]=oggpack_read(opb,8)-1;
if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
goto err_out;
@@ -278,7 +278,7 @@
return(y0+off);
}
-static int FLOOR_todB_LOOKUP[560]={
+static int FLOOR_quantdB_LOOKUP[560]={
1023, 1021, 1019, 1018, 1016, 1014, 1012, 1010,
1008, 1007, 1005, 1003, 1001, 999, 997, 996,
994, 992, 990, 988, 986, 985, 983, 981,
@@ -482,6 +482,22 @@
return(a->n);
}
+static int add_fit_point(float *floor,int x,lsfit_acc *a){
+ long i;
+
+ int quantized=vorbis_floor1_dBquant(floor+x);
+ if(quantized){
+ a->xa += x;
+ a->ya += quantized;
+ a->x2a += (x*x);
+ a->y2a += quantized*quantized;
+ a->xya += x*quantized;
+ a->n++;
+ return(1);
+ }
+ return(0);
+}
+
/* 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;
@@ -550,8 +566,8 @@
ady-=abs(base*adx);
if(val){
- if(y-info->maxover>val)return(1);
- if(y+info->maxunder<val)return(1);
+ if(y+info->maxover<val)return(1);
+ if(y-info->maxunder>val)return(1);
mse=(y-val);
mse*=mse;
n++;
@@ -568,8 +584,8 @@
val=vorbis_floor1_dBquant(flr+x);
if(val){
- if(y-info->maxover>val)return(1);
- if(y+info->maxunder<val)return(1);
+ if(y+info->maxover<val)return(1);
+ if(y-info->maxunder>val)return(1);
mse+=((y-val)*(y-val));
n++;
}
@@ -591,6 +607,7 @@
a dB scale floor, puts out linear */
static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in,
float *flr){
+ static int seq=0;
long i,j,k,l;
vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
vorbis_info_floor1 *info=look->vi;
@@ -605,8 +622,10 @@
int loneighbor[VIF_POSIT+2]; /* sorted index of range list position (+2) */
int hineighbor[VIF_POSIT+2];
int memo[VIF_POSIT+2];
- static_codebook *sbooks=vb->vd->vi->codec_setup->book_param;
- codebook *books=vb->vd->backend_state->fullbooks;
+ codec_setup_info *ci=vb->vd->vi->codec_setup;
+ static_codebook **sbooks=ci->book_param;
+ codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
+ fullbooks;
memset(fit_flag,0,sizeof(fit_flag));
for(i=0;i<posts;i++)loneighbor[i]=0; /* 0 for the implicit 0 post */
@@ -618,9 +637,13 @@
if(posts==0){
nonzero+=accumulate_fit(flr,0,n,fits);
}else{
- for(i=0;i<posts-1;i++)
+ for(i=0;i<posts-2;i++){
nonzero+=accumulate_fit(flr,look->sorted_index[i],
look->sorted_index[i+1],fits+i);
+ nonzero+=add_fit_point(flr,look->sorted_index[i+1],fits+i);
+ }
+ nonzero+=accumulate_fit(flr,look->sorted_index[i],
+ look->sorted_index[i+1],fits+i);
}
if(nonzero){
@@ -657,6 +680,7 @@
/* haven't performed this error search yet */
int lsortpos=look->reverse_index[ln];
int hsortpos=look->reverse_index[hn];
+ memo[ln]=hn;
/* if this is an empty segment, its endpoints don't matter.
Mark as such */
@@ -673,7 +697,6 @@
int hx=info->postlist[hn];
int ly=post_Y(fit_valueA,fit_valueB,ln);
int hy=post_Y(fit_valueA,fit_valueB,hn);
- memo[ln]=hn;
if(i<info->searchstart ||
inspect_error(lx,hx,ly,hy,flr,info)){
@@ -685,13 +708,13 @@
int lmse=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
int hmse=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- /* Handle degeneracy */
+ /* Handle degeneracy
if(lmse<0 && hmse<0){
ly0=fit_valueA[ln];
hy1=fit_valueB[hn];
lmse=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
hmse=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
- }
+ }*/
if(lmse<0 && hmse<0) continue;
@@ -734,6 +757,34 @@
}
}
}
+
+
+
+ /* 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){
@@ -763,8 +814,8 @@
/* work backward to avoid a copy; unwind the neighbor arrays */
for(i=posts-1;i>1;i--){
int sp=look->reverse_index[i];
- int ln=loneighbor[i];
- int hn=hineighbor[i];
+ int ln=loneighbor[sp];
+ int hn=hineighbor[sp];
int x0=info->postlist[ln];
int x1=info->postlist[hn];
@@ -789,12 +840,12 @@
if(val<-headroom)
val=headroom-val-1;
else
- val=1-(val<<1);
+ val=-1-(val<<1);
else
if(val>=headroom)
val= val+headroom;
else
- val>>=1;
+ val<<=1;
fit_valueB[i]=val;
@@ -840,15 +891,15 @@
for(k=0;k<csub;k++){
int booknum=info->class_subbook[class][k];
if(booknum<0){
- maxval[k]=0;
+ maxval[k]=1;
}else{
- maxval[k]=sbooks[info->class_subbook[class][k]].entries;
+ maxval[k]=sbooks[info->class_subbook[class][k]]->entries;
}
}
for(k=0;k<cdim;k++){
for(l=0;l<csub;l++){
- val=fit_valueB[j+k];
- if(val<maxval[k]){
+ int val=fit_valueB[j+k];
+ if(val<maxval[l]){
bookas[k]=l;
break;
}
@@ -863,7 +914,7 @@
{
FILE *of;
char buffer[80];
- sprintf(buffer,"floor1_class%d.vqd",class);
+ sprintf(buffer,"line%d_class%d.vqd",vb->mode,class);
of=fopen(buffer,"a");
fprintf(of,"%d\n",cval);
fclose(of);
@@ -877,11 +928,12 @@
if(book>=0){
vorbis_book_encode(books+book,
fit_valueB[j+k],&vb->opb);
+
#ifdef TRAIN_FLOOR1
{
FILE *of;
char buffer[80];
- sprintf(buffer,"floor1_class%dsub%d.vqd",class,bookas[k]);
+ sprintf(buffer,"line%d_%dsub%d.vqd",vb->mode,class,bookas[k]);
of=fopen(buffer,"a");
fprintf(of,"%d\n",fit_valueB[j+k]);
fclose(of);
@@ -902,29 +954,31 @@
int hy=fit_valueA[current]*info->mult;
hx=info->postlist[current];
- render_line(lx,hx,ly,hy,out);
+ render_line(lx,hx,ly,hy,flr);
lx=hx;
ly=hy;
}
- for(j=hx;j<n;j++)out[j]=0.f; /* be certain */
+ for(j=hx;j<n;j++)flr[j]=0.f; /* be certain */
}
}else{
oggpack_write(&vb->opb,0,1);
memset(flr,0,n*sizeof(float));
}
+ seq++;
return(nonzero);
}
-static int floor1_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
- vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
+static int floor1_inverse(vorbis_block *vb,vorbis_look_floor *in,float *out){
+ vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
vorbis_info_floor1 *info=look->vi;
codec_setup_info *ci=vb->vd->vi->codec_setup;
int n=ci->blocksizes[vb->mode]/2;
- int i,j;
- codebook *books=vb->vd->backend_state->fullbooks;
+ int i,j,k;
+ codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
+ fullbooks;
/* unpack wrapped/predicted values from stream */
if(oggpack_read(&vb->opb,1)==1){
@@ -940,32 +994,30 @@
int cdim=info->class_dim[class];
int csubbits=info->class_subs[class];
int csub=1<<csubbits;
- int bookas[8]={0,0,0,0,0,0,0,0};
+ int cval=0;
/* decode the partition's first stage cascade value */
if(csubbits){
- int cval=vorbis_book_decode(books+info->class_book[class],&vb->opb);
+ cval=vorbis_book_decode(books+info->class_book[class],&vb->opb);
+
if(cval==-1)goto eop;
+ }
- for(k=0;k<cdim;k++){
- int book=info->class_subbook[class][val&(csub-1)];
- cval>>=csubbits;
- if(book>=0){
- if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
- goto eop;
- }else{
- fit_value[j+k]=0;
- }
- }
- }else{
- for(k=0;k<cdim;k++)
+ for(k=0;k<cdim;k++){
+ int book=info->class_subbook[class][cval&(csub-1)];
+ cval>>=csubbits;
+ if(book>=0){
+ if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
+ goto eop;
+ }else{
fit_value[j+k]=0;
- }
+ }
+ }
j+=cdim;
}
/* unwrap positive values and reconsitute via linear interpolation */
- for(i=2;i<posts;i++){
+ for(i=2;i<look->posts;i++){
int predicted=render_point(info->postlist[look->loneighbor[i-2]],
info->postlist[look->hineighbor[i-2]],
fit_value[look->loneighbor[i-2]],
@@ -984,7 +1036,7 @@
}
}else{
if(val&1){
- val= -1 -(val>>1);
+ val= -((val+1)>>1);
}else{
val>>=1;
}
@@ -998,7 +1050,7 @@
int hx;
int lx=0;
int ly=fit_value[0]*info->mult;
- for(j=1;j<posts;j++){
+ for(j=1;j<look->posts;j++){
int current=look->forward_index[j];
int hy=fit_value[current]*info->mult;
hx=info->postlist[current];
1.39.4.1 +2 -2 vorbis/lib/info.c
Index: info.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/info.c,v
retrieving revision 1.39
retrieving revision 1.39.4.1
diff -u -r1.39 -r1.39.4.1
--- info.c 2001/02/26 03:50:41 1.39
+++ info.c 2001/05/01 17:08:36 1.39.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: maintain the info structure, info <-> header packets
- last mod: $Id: info.c,v 1.39 2001/02/26 03:50:41 xiphmont Exp $
+ last mod: $Id: info.c,v 1.39.4.1 2001/05/01 17:08:36 xiphmont Exp $
********************************************************************/
@@ -408,7 +408,7 @@
}
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
- char temp[]="Xiphophorus libVorbis I 20010225";
+ char temp[]="Xiphophorus libVorbis I 20010501";
/* preamble */
oggpack_write(opb,0x03,8);
1.27.4.2 +1 -2 vorbis/lib/mapping0.c
Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.27.4.1
retrieving revision 1.27.4.2
diff -u -r1.27.4.1 -r1.27.4.2
--- mapping0.c 2001/04/29 22:21:04 1.27.4.1
+++ mapping0.c 2001/05/01 17:08:36 1.27.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.27.4.1 2001/04/29 22:21:04 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.27.4.2 2001/05/01 17:08:36 xiphmont Exp $
********************************************************************/
@@ -297,7 +297,6 @@
#endif
}
- seq++;
vbi->ampmax=newmax;
/* perform residue encoding with residue mapping; this is
1.6.4.1 +3 -2 vorbis/lib/vorbisenc.c
Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -r1.6 -r1.6.4.1
--- vorbisenc.c 2001/02/26 03:50:43 1.6
+++ vorbisenc.c 2001/05/01 17:08:36 1.6.4.1
@@ -11,7 +11,7 @@
********************************************************************
function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.6 2001/02/26 03:50:43 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.6.4.1 2001/05/01 17:08:36 xiphmont Exp $
********************************************************************/
@@ -139,7 +139,8 @@
/* adjust for sample rate */
for(i=0;i<ci->floors;i++)
- ((vorbis_info_floor0 *)(ci->floor_param[i]))->rate=rate;
+ if(ci->floor_type[i]==0)
+ ((vorbis_info_floor0 *)(ci->floor_param[i]))->rate=rate;
/* adjust for channels; all our mappings use submap zero now */
/* yeah, OK, _ogg_calloc did this for us. But it's a reminder/placeholder */
No revision
No revision
1.14.4.2 +50 -14 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.1
retrieving revision 1.14.4.2
diff -u -r1.14.4.1 -r1.14.4.2
--- mode_A.h 2001/04/29 22:21:06 1.14.4.1
+++ mode_A.h 2001/05/01 17:08:38 1.14.4.2
@@ -11,7 +11,7 @@
********************************************************************
function: predefined encoding modes
- last mod: $Id: mode_A.h,v 1.14.4.1 2001/04/29 22:21:06 xiphmont Exp $
+ last mod: $Id: mode_A.h,v 1.14.4.2 2001/05/01 17:08:38 xiphmont Exp $
********************************************************************/
@@ -22,10 +22,8 @@
#include "vorbis/codec.h"
#include "backends.h"
-#include "books/lsp12_0.vqh"
-#include "books/lsp30_0.vqh"
-#include "books/lsp12_1.vqh"
-#include "books/lsp30_1.vqh"
+#include "books/line0.vqh"
+#include "books/line1.vqh"
#include "books/res0_128_128aux.vqh"
#include "books/res0_128_1024aux.vqh"
@@ -228,10 +226,48 @@
/* with GNUisms, this could be short and readable. Oh well */
static vorbis_info_time0 _time_set0A={0};
-static vorbis_info_floor0 _floor_set0A={12, 44100, 64, 10,130, 2, {0,1},
- 0.199f, .285f};
-static vorbis_info_floor0 _floor_set1A={30, 44100, 256, 12,150, 2, {2,3},
- .082f, .126f};
+/*static vorbis_info_floor0 _floor_set0A={12, 44100, 64, 10,130, 2, {0,1},
+ 0.199f, .285f};*/
+/*static vorbis_info_floor0 _floor_set1A={30, 44100, 256, 12,150, 2, {2,3},
+ .082f, .126f};*/
+
+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}},
+
+ 2,
+ {0,128,
+ 5,21,
+
+ 2,1,3,
+ 11,7,15,
+ 45,30,73},
+
+ 40,8,200,4};
+
+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}},
+
+ 2,
+ {0,1024,
+ 88,31,243,
+ 14,54,143,460,
+
+ 6,3,10, 22,18,26, 41,36,47,
+ 69,61,78, 112,99,126, 185,162,211,
+ 329,282,387, 672,553,825},
+
+ 40,8,200,9};
+
static vorbis_info_residue0 _residue_set0A={0,96,16,6,4,
{0,1,1,1,1,1},
{6,7,8,9,10},
@@ -271,14 +307,14 @@
/* times */
{0,0},{&_time_set0A},
/* floors */
- {0,0},{&_floor_set0A,&_floor_set1A},
+ {1,1},{&_floor_set0A,&_floor_set1A},
/* residue */
{0,0},{&_residue_set0A,&_residue_set1A},
/* books */
- {&_vq_book_lsp12_0, /* 0 */
- &_vq_book_lsp12_1, /* 1 */
- &_vq_book_lsp30_0, /* 2 */
- &_vq_book_lsp30_1, /* 3 */
+ {&_huff_book_line0,
+ &_huff_book_line1,
+ &_huff_book_line0,
+ &_huff_book_line1,
&_huff_book_res0_128_128aux,
&_huff_book_res0_128_1024aux,
--- >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