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

Monty xiphmont at xiph.org
Fri Jun 15 16:59:48 PDT 2001



xiphmont    01/06/15 16:59:48

  Modified:    lib      floor1.c mapping0.c
  Log:
  Finished patch to deal with channel coupling and some-zero, some-nonzero channels
  
  Monty

Revision  Changes    Path
1.10      +3 -17     vorbis/lib/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- floor1.c	2001/06/15 23:31:00	1.9
+++ floor1.c	2001/06/15 23:59:47	1.10
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.9 2001/06/15 23:31:00 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.10 2001/06/15 23:59:47 xiphmont Exp $
 
  ********************************************************************/
 
@@ -43,12 +43,6 @@
   int quant_q;
   vorbis_info_floor1 *vi;
 
-
-  long seq;
-  long postbits;
-  long classbits;
-  long subbits;
-  float mse;
 } vorbis_look_floor1;
 
 typedef struct lsfit_acc{
@@ -86,11 +80,6 @@
 static void floor1_free_look(vorbis_look_floor *i){
   vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
   if(i){
-    fprintf(stderr,"floor 1 bit usage: %ld:%ld:%ld (%ld/frame), mse:%gdB\n",
-	    look->postbits/look->seq,look->classbits/look->seq,look->subbits/look->seq,
-	    (look->postbits+look->subbits+look->classbits)/look->seq,
-	    sqrt(look->mse/look->seq));
-
     memset(look,0,sizeof(vorbis_look_floor1));
     free(i);
   }
@@ -680,8 +669,6 @@
       fit_line(fits,posts-1,&y0,&y1);
     }
 
-    look->seq++;
-
     fit_flag[0]=1;
     fit_flag[1]=1;
     fit_valueA[0]=y0;
@@ -892,7 +879,6 @@
     oggpack_write(&vb->opb,1,1);
 
     /* beginning/end post */
-    look->postbits+=ilog(look->quant_q-1)*2;
     oggpack_write(&vb->opb,fit_valueA[0],ilog(look->quant_q-1));
     oggpack_write(&vb->opb,fit_valueA[1],ilog(look->quant_q-1));
 
@@ -942,7 +928,7 @@
           cshift+=csubbits;
         }
         /* write it */
-	look->classbits+=vorbis_book_encode(books+info->class_book[class],cval,&vb->opb);
+	vorbis_book_encode(books+info->class_book[class],cval,&vb->opb);
 
 #ifdef TRAIN_FLOOR1
         {
@@ -960,7 +946,7 @@
       for(k=0;k<cdim;k++){
         int book=info->class_subbook[class][bookas[k]];
         if(book>=0){
-	  look->subbits+=vorbis_book_encode(books+book,
+	  vorbis_book_encode(books+book,
                              fit_valueB[j+k],&vb->opb);
 
 #ifdef TRAIN_FLOOR1

1.32      +57 -35    vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- mapping0.c	2001/06/15 23:31:00	1.31
+++ mapping0.c	2001/06/15 23:59:47	1.32
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.31 2001/06/15 23:31:00 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.32 2001/06/15 23:59:47 xiphmont Exp $
 
  ********************************************************************/
 
@@ -348,9 +348,12 @@
 
   /* 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]];
-
+    if(nonzero[info->coupling_mag[i]] ||
+       nonzero[info->coupling_ang[i]]){
+      
+      float *pcmM=vb->pcm[info->coupling_mag[i]];
+      float *pcmA=vb->pcm[info->coupling_ang[i]];
+      
     /*     +- 
             B
             |       A-B
@@ -367,42 +370,47 @@
            --
 
     */
-    for(j=n/2-1;j>=0;j--){
-      float A=rint(pcmM[j]);
-      float B=rint(pcmA[j]);
-      float mag;
-      float ang;
-      
-      if(fabs(A)>fabs(B)){
-	mag=A;
-	if(A>0)
-	  ang=A-B;
-	else
-	  ang=B-A;
-      }else{
-	mag=B;
+
+      nonzero[info->coupling_mag[i]]=1; 
+      nonzero[info->coupling_ang[i]]=1; 
+
+      for(j=n/2-1;j>=0;j--){
+	float A=rint(pcmM[j]);
+	float B=rint(pcmA[j]);
+	float mag;
+	float ang;
+	
+	if(fabs(A)>fabs(B)){
+	  mag=A;
+	  if(A>0)
+	    ang=A-B;
+	  else
+	    ang=B-A;
+	}else{
+	  mag=B;
         if(B>0)
           ang=A-B;
         else
           ang=B-A;
-      }
-
-      /*if(fabs(mag)<3.5f)
-	ang=rint(ang/(mag*2.f))*mag*2.f;*/
-      
-      if(fabs(mag)<1.5)
-	ang=0;
-      
-      if(j>(n*3/16))
+	}
+	
+	/*if(fabs(mag)<3.5f)
+	  ang=rint(ang/(mag*2.f))*mag*2.f;*/
+	
+	if(fabs(mag)<1.5)
         ang=0;
       
-      if(ang>=fabs(mag*2))ang=-fabs(mag*2);
-
-      pcmM[j]=mag;
-      pcmA[j]=ang;
+	if(j>(n*3/16))
+	  ang=0;
+	
+	if(ang>=fabs(mag*2))ang=-fabs(mag*2);
+	
+	pcmM[j]=mag;
+	pcmA[j]=ang;
+      }
     }
   }
-
+  
   /* 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 */
@@ -441,7 +449,9 @@
   float *window=b->window[vb->W][vb->lW][vb->nW][mode->windowtype];
   float **pcmbundle=alloca(sizeof(float *)*vi->channels);
   int    *zerobundle=alloca(sizeof(int)*vi->channels);
-  void **nonzero=alloca(sizeof(void *)*vi->channels);
+
+  int   *nonzero  =alloca(sizeof(int)*vi->channels);
+  void **floormemo=alloca(sizeof(void *)*vi->channels);
   
   /* time domain information decode (note that applying the
      information would have to happen later; we'll probably add a
@@ -451,13 +461,25 @@
   /* recover the spectral envelope; store it in the PCM vector for now */
   for(i=0;i<vi->channels;i++){
     int submap=info->chmuxlist[i];
-    nonzero[i]=look->floor_func[submap]->
+    floormemo[i]=look->floor_func[submap]->
       inverse1(vb,look->floor_look[submap]);
+    if(floormemo[i])
+      nonzero[i]=1;
+    else
+      nonzero[i]=0;      
     memset(vb->pcm[i],0,sizeof(float)*n/2);
   }
 
-  /* recover the residue into our working vectors */
+  /* channel coupling can 'dirty' the nonzero listing */
+  for(i=0;i<info->coupling_steps;i++){
+    if(nonzero[info->coupling_mag[i]] ||
+       nonzero[info->coupling_ang[i]]){
+      nonzero[info->coupling_mag[i]]=1; 
+      nonzero[info->coupling_ang[i]]=1; 
+    }
+  }
 
+  /* recover the residue into our working vectors */
   for(i=0;i<info->submaps;i++){
     int ch_in_bundle=0;
     for(j=0;j<vi->channels;j++){
@@ -507,7 +529,7 @@
     float *pcm=vb->pcm[i];
     int submap=info->chmuxlist[i];
     look->floor_func[submap]->
-      inverse2(vb,look->floor_look[submap],nonzero[i],pcm);
+      inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
   }
 
   /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */

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