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

Monty xiphmont at xiph.org
Mon Aug 13 04:33:41 PDT 2001



xiphmont    01/08/13 04:33:41

  Modified:    examples encoder_example.c
               lib      codebook.c floor1.c mapping0.c res0.c vorbisenc.c
  Log:
  final round of commits

Revision  Changes    Path
1.22      +8 -10     vorbis/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/encoder_example.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- encoder_example.c	2001/02/26 03:50:38	1.21
+++ encoder_example.c	2001/08/13 11:33:39	1.22
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.21 2001/02/26 03:50:38 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.22 2001/08/13 11:33:39 xiphmont Exp $
 
  ********************************************************************/
 
@@ -36,7 +36,7 @@
 #endif
 
 #define READ 1024
-signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
+signed char readbuffer[READ*2+44]; /* out of the data segment, not the stack */
 
 int main(){
   ogg_stream_state os; /* take physical pages, weld into a logical
@@ -79,7 +79,7 @@
   /* choose an encoding mode */
   /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
   vorbis_info_init(&vi);
-  vorbis_encode_init(&vi,2,44100, -1, 128000, -1);
+  vorbis_encode_init(&vi,1,44100, -1, 999000, -1);
 
   /* add a comment */
   vorbis_comment_init(&vc);
@@ -128,7 +128,7 @@
   
   while(!eos){
     long i;
-    long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
+    long bytes=fread(readbuffer,1,READ*2,stdin); /* stereo hardwired here */
 
     if(bytes==0){
       /* end of file.  this can be done implicitly in the mainline,
@@ -144,13 +144,11 @@
       float **buffer=vorbis_analysis_buffer(&vd,READ);
       
       /* uninterleave samples */
-      for(i=0;i<bytes/4;i++){
-	buffer[0][i]=((readbuffer[i*4+1]<<8)|
-		      (0x00ff&(int)readbuffer[i*4]))/32768.f;
-	buffer[1][i]=((readbuffer[i*4+3]<<8)|
-		      (0x00ff&(int)readbuffer[i*4+2]))/32768.f;
+      for(i=0;i<bytes/2;i++){
+	buffer[0][i]=((readbuffer[i*2+1]<<8)|
+		      (0x00ff&(int)readbuffer[i*2]))/32768.f;
       }
-    
+      
       /* tell the library how much we actually submitted */
       vorbis_analysis_wrote(&vd,i);
     }

1.29      +3 -2      vorbis/lib/codebook.c

Index: codebook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codebook.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- codebook.c	2001/08/13 01:36:56	1.28
+++ codebook.c	2001/08/13 11:33:39	1.29
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.28 2001/08/13 01:36:56 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.29 2001/08/13 11:33:39 xiphmont Exp $
 
  ********************************************************************/
 
@@ -360,7 +360,7 @@
 }
 
 long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){
-  int i,j=0,entry;
+  int i,j,entry;
   float *t;
 
   if(book->dim>8){
@@ -376,6 +376,7 @@
       entry = vorbis_book_decode(book,b);
       if(entry==-1)return(-1);
       t     = book->valuelist+entry*book->dim;
+      j=0;
       switch(book->dim){
       case 8:
         a[i++]+=t[j++];

1.12      +3 -3      vorbis/lib/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- floor1.c	2001/08/13 01:36:56	1.11
+++ floor1.c	2001/08/13 11:33:39	1.12
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.11 2001/08/13 01:36:56 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.12 2001/08/13 11:33:39 xiphmont Exp $
 
  ********************************************************************/
 
@@ -940,7 +940,7 @@
           {
             FILE *of;
             char buffer[80];
-	    sprintf(buffer,"line_%dx%d_class%d.vqd",
+	    sprintf(buffer,"line_%ldx%ld_class%d.vqd",
                     vb->pcmend/2,posts-2,class);
             of=fopen(buffer,"a");
             fprintf(of,"%d\n",cval);
@@ -964,7 +964,7 @@
             {
               FILE *of;
               char buffer[80];
-	      sprintf(buffer,"line_%dx%d_%dsub%d.vqd",
+	      sprintf(buffer,"line_%ldx%ld_%dsub%d.vqd",
                       vb->pcmend/2,posts-2,class,bookas[k]);
               of=fopen(buffer,"a");
               fprintf(of,"%d\n",fit_valueB[j+k]);

1.35      +42 -18    vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- mapping0.c	2001/08/13 01:36:57	1.34
+++ mapping0.c	2001/08/13 11:33:39	1.35
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.34 2001/08/13 01:36:57 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.35 2001/08/13 11:33:39 xiphmont Exp $
 
  ********************************************************************/
 
@@ -412,11 +412,11 @@
                      res,
                      local_ampmax[i]);
 
-    for(j=0;j<n/2;j++)
+    /*for(j=0;j<n/2;j++)
       if(fabs(res[j])>1200){
         analysis_noisy=1;
-	/*fprintf(stderr,"%ld ",seq+i);*/
-      }
+	fprintf(stderr,"%ld ",seq+i);
+	}*/
 
     _analysis_output("res",seq+i,res,n/2,1,0);
     _analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
@@ -475,13 +475,25 @@
     zerobundle[0]=alloca(sizeof(int)*vi->channels);
 
     /* initial down-quantized coupling */
-    _vp_quantize_couple(look->psy_look[blocktype],
-			info,
-			pcm,
-			sofar,
-			quantized,
-			nonzero,
-			0);
+    
+    if(info->coupling_steps==0){
+      /* this assumes all or nothing coupling right now.  it should pass
+	 through any channels left uncoupled, but it doesn't do that now */
+      for(i=0;i<vi->channels;i++){
+	float *lpcm=pcm[i];
+	float *lqua=quantized[i];
+	for(j=0;j<n/2;j++)
+	  lqua[j]=lpcm[j];
+      }
+    }else{
+      _vp_quantize_couple(look->psy_look[blocktype],
+			  info,
+			  pcm,
+			  sofar,
+			  quantized,
+			  nonzero,
+			  0);
+    }
 
     for(i=0;i<vi->channels;i++)
       _analysis_output("quant",seq+i,quantized[i],n/2,1,0);
@@ -533,13 +545,25 @@
       if(!stopflag){
         /* down-couple/down-quantize from perfect-'so-far' -> 
            new quantized vector */
-	_vp_quantize_couple(look->psy_look[blocktype],
-			    info,
-			    pcm,
-			    sofar,
-			    quantized,
-			    nonzero,
-			    i);
+	if(info->coupling_steps==0){
+	  /* this assumes all or nothing coupling right now.  it should pass
+	     through any channels left uncoupled, but it doesn't do that now */
+	  for(i=0;i<vi->channels;i++){
+	    float *lpcm=pcm[i];
+	    float *lsof=sofar[i];
+	    float *lqua=quantized[i];
+	    for(j=0;j<n/2;j++)
+	      lqua[j]=lpcm[j]-lsof[j];
+	  }
+	}else{
+	  _vp_quantize_couple(look->psy_look[blocktype],
+			      info,
+			      pcm,
+			      sofar,
+			      quantized,
+			      nonzero,
+			      i);
+	}
       }
       /* steady as she goes */
     }

1.35      +9 -8      vorbis/lib/res0.c

Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- res0.c	2001/08/13 10:01:04	1.34
+++ res0.c	2001/08/13 11:33:39	1.35
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.34 2001/08/13 10:01:04 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.35 2001/08/13 11:33:39 xiphmont Exp $
 
  ********************************************************************/
 
@@ -71,10 +71,10 @@
 
     vorbis_look_residue0 *look=(vorbis_look_residue0 *)i;
 
-    fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
+    /*fprintf(stderr,"residue bit usage %f:%f (%f total)\n",
             (float)look->phrasebits/look->frames,
             (float)look->postbits/look->frames,
-	    (float)(look->postbits+look->phrasebits)/look->frames);
+	    (float)(look->postbits+look->phrasebits)/look->frames);*/
 
     /*vorbis_info_residue0 *info=look->info;
 
@@ -531,8 +531,8 @@
           /* training hack */
           if(val<look->phrasebook->entries)
             ret=vorbis_book_encode(look->phrasebook,val,&vb->opb);
-	  else
-	    fprintf(stderr,"!");
+	  /*else
+	    fprintf(stderr,"!");*/
           
           look->phrasebits+=ret;
         
@@ -559,7 +559,7 @@
     }
   }
 
-  {
+  /*{
     long total=0;
     long totalbits=0;
     fprintf(stderr,"%d :: ",vb->mode);
@@ -570,7 +570,7 @@
     }
     
     fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total);
-  }
+    }*/
   return(0);
 }
 
@@ -641,7 +641,8 @@
     if(nonzero[i])
       in[used++]=in[i];
   if(used)
-    return(_01class(vb,vl,in,used,_interleaved_testhack));
+    /*return(_01class(vb,vl,in,used,_interleaved_testhack));*/
+    return(_01class(vb,vl,in,used,_testhack));
   else
     return(0);
 }

1.12      +13 -19    vorbis/lib/vorbisenc.c

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- vorbisenc.c	2001/08/13 08:39:30	1.11
+++ vorbisenc.c	2001/08/13 11:33:40	1.12
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.11 2001/08/13 08:39:30 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.12 2001/08/13 11:33:40 xiphmont Exp $
 
  ********************************************************************/
 
@@ -158,27 +158,21 @@
 
     break;
   default:
-#if 0
-    if(bpch<60000){
-      /* mode AA */
-      mode=&info_AA;
-    }else if(bpch<75000){
-      /* mode A */
-      mode=&info_A;
+
+    if(bpch<40000){
+      mode=&info_44_Z;
+    }else if(bpch<50000){
+      mode=&info_44_Y;
+    }else if(bpch<70000){
+      mode=&info_44_X;
     }else if(bpch<90000){
-      /* mode B */
-      mode=&info_B;
-    }else if(bpch<110000){
-      /* mode C */
-      mode=&info_C;
-    }else if(bpch<160000){
-      /* mode D */
-      mode=&info_D;
+      mode=&info_44_A;
+    }else if(bpch<120000){
+      mode=&info_44_B;
     }else{
-      /* mode E */
-      mode=&info_E;
+      mode=&info_44_C;
     }
-#endif
+    break;
   }
 
   /* now we have to deepcopy */

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