[xiph-cvs] cvs commit: vorbis/lib floor1.c mapping0.c psy.c res0.c vorbisenc.c backends.h psy.h

Monty xiphmont at xiph.org
Thu Aug 2 15:14:24 PDT 2001



xiphmont    01/08/02 15:14:23

  Modified:    lib      Tag: branch_monty_20010708 floor1.c mapping0.c
                        psy.c res0.c vorbisenc.c backends.h psy.h
  Log:
  In progress build/run fixes to upcoming rc encoder

Revision  Changes    Path
No                   revision

No                   revision

1.10.2.3  +8 -4      vorbis/lib/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -r1.10.2.2 -r1.10.2.3
--- floor1.c	2001/08/02 06:14:43	1.10.2.2
+++ floor1.c	2001/08/02 22:14:21	1.10.2.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.10.2.2 2001/08/02 06:14:43 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.10.2.3 2001/08/02 22:14:21 xiphmont Exp $
 
  ********************************************************************/
 
@@ -964,9 +964,13 @@
         for(k=0;k<cdim;k++){
           int book=info->class_subbook[class][bookas[k]];
           if(book>=0){
-	    look->postbits+=vorbis_book_encode(books+book,
-					       fit_valueB[j+k],&vb->opb);
-	    
+	    /* hack to allow training with 'bad' books */
+	    if(fit_valueB[j+k]<(books+book)->entries)
+	      look->postbits+=vorbis_book_encode(books+book,
+						 fit_valueB[j+k],&vb->opb);
+	    else
+	      fprintf(stderr,"+!");
+
 #ifdef TRAIN_FLOOR1
             {
               FILE *of;

1.33.2.4  +30 -17    vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.33.2.3
retrieving revision 1.33.2.4
diff -u -r1.33.2.3 -r1.33.2.4
--- mapping0.c	2001/08/02 06:14:43	1.33.2.3
+++ mapping0.c	2001/08/02 22:14:21	1.33.2.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.33.2.3 2001/08/02 06:14:43 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.33.2.4 2001/08/02 22:14:21 xiphmont Exp $
 
  ********************************************************************/
 
@@ -282,11 +282,11 @@
 
     /* the following makes things clearer to *me* anyway */
     float *pcm     =vb->pcm[i]; 
-    float *mdct    =pcm;
     float *fft     =work;
     float *logfft  =pcm+n/2;
 
     /*float *res     =pcm;
+    float *mdct    =pcm;
     float *codedflr=pcm+n/2;
     float *logmax  =work;
     float *logmask =work+n/2;*/
@@ -329,7 +329,7 @@
 
     for(j=0;j<n/2;j++)
       logmdct[j]=todB(mdct+j);
-    _analysis_output("mdct",seq,logmdct,n/2,1,0);
+    _analysis_output("mdct",seq+i,logmdct,n/2,1,0);
 
 
     /* perform psychoacoustics; do masking */
@@ -343,7 +343,7 @@
                      local_ampmax[i],
                      ci->blocksizes[vb->lW]/2);
 
-    _analysis_output("mask",seq,logmask,n/2,1,0);
+    _analysis_output("mask",seq+i,logmask,n/2,1,0);
     
     /* perform floor encoding */
     nonzero[i]=look->floor_func[submap]->
@@ -356,6 +356,7 @@
               codedflr);
 
 
+    _analysis_output("mdct2",seq+i,mdct,n/2,1,1);
     _vp_remove_floor(look->psy_look,
                      b->psy_g_look,
                      logmdct,
@@ -365,11 +366,11 @@
                      local_ampmax[i]);
 
     for(j=0;j<n/2;j++)
-      if(fabs(vb->pcm[i][j])>1500)
-	fprintf(stderr,"%ld ",seq);
+      if(fabs(res[j])>1500)
+	fprintf(stderr,"%ld ",seq+i);
     
-    _analysis_output("res",seq,res,n,1,0);
-    _analysis_output("codedflr",seq++,codedflr,n/2,1,1);
+    _analysis_output("res",seq+i,res,n/2,1,0);
+    _analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
       
   }
 
@@ -405,6 +406,7 @@
 
     long  ***classifications=alloca(sizeof(long**)*info->submaps);
     float ***pcmbundle=alloca(sizeof(float **)*info->submaps);
+    float ***sobundle=alloca(sizeof(float **)*info->submaps);
     int    **zerobundle=alloca(sizeof(int *)*info->submaps);
     int     *chbundle=alloca(sizeof(int)*info->submaps);
     int      chcounter=0;
@@ -414,14 +416,14 @@
     int   stopflag=0;
 
     for(i=0;i<vi->channels;i++){
-      quantized[i]=perfect[i]+n/2;
+      quantized[i]=pcm[i]+n/2;
       sofar[i]=_vorbis_block_alloc(vb,n/2*sizeof(float));
       memset(sofar[i],0,sizeof(float)*n/2);
     }
 
-    pcmbundle=alloca(sizeof(float *)*vi->channels);
-    sobundle=alloca(sizeof(float *)*vi->channels);
-    zerobundle=alloca(sizeof(int)*vi->channels);
+    pcmbundle[0]=alloca(sizeof(float *)*vi->channels);
+    sobundle[0]=alloca(sizeof(float *)*vi->channels);
+    zerobundle[0]=alloca(sizeof(int)*vi->channels);
 
     /* initial down-quantized coupling */
     _vp_quantize_couple(look->psy_look,
@@ -431,14 +433,18 @@
                         quantized,
                         nonzero,
                         0);
+
+    for(i=0;i<vi->channels;i++)
+      _analysis_output("quant",seq+i,quantized[i],n/2,1,0);
+
   
     /* classify, by submap */
 
     for(i=0;i<info->submaps;i++){
       int ch_in_bundle=0;
-      pcmbundle[i]=pcmbundle+chcounter;
-      sobundle[i]=sobundle+chcounter;
-      zerobundle[i]=zerobundle+chcounter;
+      pcmbundle[i]=pcmbundle[0]+chcounter;
+      sobundle[i]=sobundle[0]+chcounter;
+      zerobundle[i]=zerobundle[0]+chcounter;
 
       for(j=0;j<vi->channels;j++){
         if(info->chmuxlist[j]==i){
@@ -488,6 +494,7 @@
       }
       /* steady as she goes */
     }
+    seq+=vi->channels;
   }
   
   look->lastframe=vb->sequence;
@@ -620,6 +627,12 @@
 
 /* export hooks */
 vorbis_func_mapping mapping0_exportbundle={
-  &mapping0_pack,&mapping0_unpack,&mapping0_look,&mapping0_copy_info,
-  &mapping0_free_info,&mapping0_free_look,&mapping0_forward,&mapping0_inverse
+  &mapping0_pack,
+  &mapping0_unpack,
+  &mapping0_look,
+  &mapping0_copy_info,
+  &mapping0_free_info,
+  &mapping0_free_look,
+  &mapping0_forward,
+  &mapping0_inverse
 };

1.48.2.4  +17 -14    vorbis/lib/psy.c

Index: psy.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.c,v
retrieving revision 1.48.2.3
retrieving revision 1.48.2.4
diff -u -r1.48.2.3 -r1.48.2.4
--- psy.c	2001/08/02 06:14:44	1.48.2.3
+++ psy.c	2001/08/02 22:14:21	1.48.2.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.48.2.3 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.48.2.4 2001/08/02 22:14:21 xiphmont Exp $
 
  ********************************************************************/
 
@@ -318,17 +318,20 @@
   for(i=0;i<P_BANDS;i+=2)
     for(j=4;j<P_LEVELS;j+=2){
       float neutraldB=-vi->toneatt[i][j];
-      for(k=2;k<EHMER_MAX+2;k++)
+      for(k=2;k<EHMER_MAX+2;k++){
+	p->tonecurves[i][j][k]+=vi->tone_masteratt;
         if(p->tonecurves[i][j][k]-neutraldB>vi->peakatt[i][j])
           p->tonecurves[i][j][k]=neutraldB+vi->peakatt[i][j];
+      }
     }
 
   if(vi->peakattp) /* we limit depth only optionally */
-    for(j=4;j<P_LEVELS;j+=2){
-      float neutraldB=-vi->toneatt[i][j];
-      if(p->tonecurves[i][j][EHMER_OFFSET]-neutraldB<vi->peakatt[i][j])
-	p->tonecurves[i][j][EHMER_OFFSET]=neutraldB+vi->peakatt[i][j];
-    }
+    for(i=0;i<P_BANDS;i+=2)
+      for(j=4;j<P_LEVELS;j+=2){
+	float neutraldB=-vi->toneatt[i][j];
+	if(p->tonecurves[i][j][EHMER_OFFSET]-neutraldB<vi->peakatt[i][j])
+	  p->tonecurves[i][j][EHMER_OFFSET]=neutraldB+vi->peakatt[i][j];
+      }
 
 
   /* interpolate curves between */
@@ -470,7 +473,7 @@
         if(vi->tonemaskp)
           seed_curve(seed,
                      curves[oc],
-		     max+vi->tone_masteratt,
+		     max,
                      p->octave[i]-p->firstoc,
                      p->total_octave_lines,
                      p->eighth_octave_lines,
@@ -931,13 +934,13 @@
                          float **pcm,
                          float **sofar,
                          float **quantized,
-			 int   *nonzero
+			 int   *nonzero,
                          int   passno){
 
-  int i,j,k,l,n=p->n;
+  int i,j,k,n=p->n;
   vorbis_info_psy *info=p->vi;
-  float granule=info->couple_pass[passno]->granule;
-  float igranule=info->couple_pass[passno]->igranule;
+  float granule=info->couple_pass[passno].granule;
+  float igranule=info->couple_pass[passno].igranule;
 
   /* perform any requested channel coupling */
   for(i=0;i<vi->coupling_steps;i++){
@@ -958,9 +961,9 @@
       nonzero[vi->coupling_ang[i]]=1; 
 
       for(j=0,k=0;j<n;k++){
-	vp_couple *part=info->couple_pass[passno]->couple+k;
+	vp_couple *part=info->couple_pass[passno].couple+k;
 
-	for(;j<info->partition*part->partition_limit && j<p->n;j++){
+	for(;j<part->limit && j<p->n;j++){
           /* partition by partition; k is our by-location partition
              class counter */
           float ang,mag=max(fabs(pcmM[j]),fabs(pcmA[j]));

1.32.2.3  +21 -19    vorbis/lib/res0.c

Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.32.2.2
retrieving revision 1.32.2.3
diff -u -r1.32.2.2 -r1.32.2.3
--- res0.c	2001/08/02 06:14:44	1.32.2.2
+++ res0.c	2001/08/02 22:14:21	1.32.2.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.32.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.32.2.3 2001/08/02 22:14:21 xiphmont Exp $
 
  ********************************************************************/
 
@@ -285,7 +285,7 @@
 static int _testhack(float *vec,int n,vorbis_look_residue0 *look,
                      int auxparts,int auxpartnum){
   vorbis_info_residue0 *info=look->info;
-  int i,j=0;
+  int i;
   float max=0.f;
   float temp[128];
   float entropy=0.f;
@@ -370,18 +370,16 @@
                        float **in,int ch,
                        int (*classify)(float *,int,vorbis_look_residue0 *,
                                        int,int)){
-  long i,j,s;
+  long i,j;
   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 possible_partitions=info->partitions;
-  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;
   long **partword=_vorbis_block_alloc(vb,ch*sizeof(long *));
 
   /* we find the partition type for each partition of each
@@ -412,7 +410,7 @@
       sprintf(buffer,"resaux_%d.vqd",vb->mode);
       of=fopen(buffer,"a");
       for(j=0;j<partvals;j++)
-	fprintf(of,"%d, ",partword[i][j]);
+	fprintf(of,"%ld, ",partword[i][j]);
       fprintf(of,"\n");
       fclose(of);
     }
@@ -427,18 +425,16 @@
                        float **in,int ch,
                        int (*classify)(float *,int,vorbis_look_residue0 *,
                                        int,int)){
-  long i,j,k,l,s;
+  long i,j,k,l;
   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 possible_partitions=info->partitions;
-  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;
   long **partword=_vorbis_block_alloc(vb,sizeof(long *));
   float *work=alloca(sizeof(float)*samples_per_partition);
   
@@ -466,7 +462,7 @@
     sprintf(buffer,"resaux_%d.vqd",vb->mode);
     of=fopen(buffer,"a");
     for(i=0;i<partvals;i++)
-      fprintf(of,"%d, ",partword[0][i]);
+      fprintf(of,"%ld, ",partword[0][i]);
     fprintf(of,"\n");
     fclose(of);
   }
@@ -492,8 +488,7 @@
   int n=info->end-info->begin;
 
   int partvals=n/samples_per_partition;
-  int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
-
+  
 #ifdef TRAIN_RES
   FILE *of;
   char buffer[80];
@@ -526,17 +521,24 @@
             val*=possible_partitions;
             if(i+k<partvals)
               val+=partword[j][i+k];
+	  }	
+
+	  /* training hack */
+	  if(val<look->phrasebook->entries)
+	    ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
+	  else
+	    fprintf(stderr,"!");
           
-	  ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
           look->phrasebits+=ret;
+	
         }
       }
       
       /* now we encode interleaved residual values for the partitions */
       for(k=0;k<partitions_per_word && i<partvals;k++,i++){
+	long offset=i*samples_per_partition+info->begin;
         
         for(j=0;j<ch;j++){
-	  long offset=i*partvals+info->begin;
           /*if(s==0)look->resvals[partword[j][i]]++;*/
           if(info->secondstages[partword[j][i]]&(1<<s)){
             codebook *statebook=look->partbooks[partword[j][i]][s];
@@ -631,7 +633,7 @@
                  float **in,float **out,int *nonzero,int ch,
                  int pass, long **partword){
   /* we encode only the nonzero parts of a bundle */
-  int i,used=0,n=vb->pcmend/2;
+  int i,j,used=0,n=vb->pcmend/2;
   for(i=0;i<ch;i++)
     if(nonzero[i]){
       for(j=0;j<n;j++)
@@ -668,7 +670,7 @@
 int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
                  float **in,float **out,int *nonzero,int ch,
                  int pass, long **partword){
-  int i,used=0,n=vb->pcmend/2;
+  int i,j,used=0,n=vb->pcmend/2;
   for(i=0;i<ch;i++)
     if(nonzero[i]){
       for(j=0;j<n;j++)
@@ -677,7 +679,7 @@
     }
 
   if(used){
-    int ret=_01forward(vb,vl,work,used,pass,partword,_encodepart);
+    int ret=_01forward(vb,vl,in,used,pass,partword,_encodepart);
     used=0;
     for(i=0;i<ch;i++)
       if(nonzero[i]){
@@ -691,7 +693,7 @@
 }
 
 long **res1_class(vorbis_block *vb,vorbis_look_residue *vl,
-		  float **in,int *nonzero,int ch{
+		  float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])
@@ -715,7 +717,7 @@
 }
 
 long **res2_class(vorbis_block *vb,vorbis_look_residue *vl,
-		  float **in,int *nonzero,int ch{
+		  float **in,int *nonzero,int ch){
   int i,used=0;
   for(i=0;i<ch;i++)
     if(nonzero[i])

1.7.2.2   +21 -6     vorbis/lib/vorbisenc.c

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -r1.7.2.1 -r1.7.2.2
--- vorbisenc.c	2001/07/08 08:48:02	1.7.2.1
+++ vorbisenc.c	2001/08/02 22:14:21	1.7.2.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.7.2.1 2001/07/08 08:48:02 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.7.2.2 2001/08/02 22:14:21 xiphmont Exp $
 
  ********************************************************************/
 
@@ -83,12 +83,22 @@
 
 }
 
-/* right now, this just encapsultes the old modes behind the interface
-   we'll be using from here on out.  After beta 3, the new bitrate
-   tracking/modding/tuning engine will lurk inside */
 /* encoders will need to use vorbis_info_init beforehand and call
    vorbis_info clear when all done */
 
+int vorbis_encode_init_vbr(vorbis_info *vi,
+			   long channels,
+			   long rate,
+			   
+			   float base_quality /* 0. to 1. */
+			   ){
+
+
+
+
+}
+
+
 int vorbis_encode_init(vorbis_info *vi,
                        long channels,
                        long rate,
@@ -114,9 +124,13 @@
 
   /* copy a mode into our allocated storage */
   bpch=nominal_bitrate/channels;
+
+  mode=&info_A;
+
+#if 0
   if(bpch<60000){
-    /* mode A */
-    //mode=&info_AA;
+    /* mode AA */
+    mode=&info_AA;
   }else if(bpch<75000){
     /* mode A */
     mode=&info_A;
@@ -133,6 +147,7 @@
     /* mode E */
     mode=&info_E;
   }
+#endif
 
   /* now we have to deepcopy */
   codec_setup_partialcopy(ci,mode);

1.9.2.3   +3 -3      vorbis/lib/backends.h

Index: backends.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/backends.h,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -r1.9.2.2 -r1.9.2.3
--- backends.h	2001/08/02 06:14:44	1.9.2.2
+++ backends.h	2001/08/02 22:14:22	1.9.2.3
@@ -12,7 +12,7 @@
 
  function: libvorbis backend and mapping structures; needed for 
            static mode headers
- last mod: $Id: backends.h,v 1.9.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.9.2.3 2001/08/02 22:14:22 xiphmont Exp $
 
  ********************************************************************/
 
@@ -127,7 +127,7 @@
   vorbis_info_residue *(*copy_info)(vorbis_info_residue *);
   void (*free_info)    (vorbis_info_residue *);
   void (*free_look)    (vorbis_look_residue *);
-  long (**class)       (struct vorbis_block *,vorbis_look_residue *,
+  long **(*class)      (struct vorbis_block *,vorbis_look_residue *,
                         float **,int *,int);
   int  (*forward)      (struct vorbis_block *,vorbis_look_residue *,
                         float **,float **,int *,int,int,long **);
@@ -152,7 +152,7 @@
   float  ampmax[64];       /* book amp threshholds*/
   int    subgrp[64];       /* book heuristic subgroup size */
   int    blimit[64];       /* subgroup position limits */
-  int    passlimit[8];     /* iteration limit per couple/quant pass */
+  int    passlimit[32];     /* iteration limit per couple/quant pass */
 } vorbis_info_residue0;
 
 /* Mapping backend generic *****************************************/

1.21.2.3  +15 -11    vorbis/lib/psy.h

Index: psy.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/psy.h,v
retrieving revision 1.21.2.2
retrieving revision 1.21.2.3
diff -u -r1.21.2.2 -r1.21.2.3
--- psy.h	2001/08/02 06:14:44	1.21.2.2
+++ psy.h	2001/08/02 22:14:22	1.21.2.3
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: random psychoacoustics (not including preecho)
- last mod: $Id: psy.h,v 1.21.2.2 2001/08/02 06:14:44 xiphmont Exp $
+ last mod: $Id: psy.h,v 1.21.2.3 2001/08/02 22:14:22 xiphmont Exp $
 
  ********************************************************************/
 
@@ -30,8 +30,13 @@
 #define P_BANDS 17
 #define P_LEVELS 11
 
+typedef struct couple_part{
+  float amppost;
+  float threshhold;
+} couple_part;
+
 typedef struct vp_couple{
-  int partition_limit;        /* partition post */
+  int limit;        /* sample post */
 
   couple_part couple_lossless;
   couple_part couple_eightphase;
@@ -40,7 +45,7 @@
   
 } vp_couple;
 
-typedef struct vp_couple_pass={
+typedef struct vp_couple_pass{
   float granule;
   float igranule;
   
@@ -154,14 +159,13 @@
                                float local_specmax,
                                int lastsize);
 
-extern void _vp_partition_prequant(vorbis_look_psy *p,
-				   vorbis_info *vi,
-				   float **vbpcm,
-				   int *nonzero);
-extern void _vp_couple(vorbis_look_psy *p,
-		       vorbis_info_mapping0 *vi,
-		       float **vbpcm,
-		       int *nonzero);
+extern void _vp_quantize_couple(vorbis_look_psy *p,
+			 vorbis_info_mapping0 *vi,
+			 float **pcm,
+			 float **sofar,
+			 float **quantized,
+			 int   *nonzero,
+			 int   passno);
 
 extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd);
 

--- >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