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

Monty xiphmont at xiph.org
Fri Jun 15 16:31:02 PDT 2001



xiphmont    01/06/15 16:31:01

  Modified:    lib      backends.h floor0.c floor1.c mapping0.c res0.c
  Log:
  zeroed channel logic fix to residue backend 2
  
  Monty

Revision  Changes    Path
1.9       +3 -3      vorbis/lib/backends.h

Index: backends.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/backends.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- backends.h	2001/06/15 21:15:39	1.8
+++ backends.h	2001/06/15 23:31:00	1.9
@@ -12,7 +12,7 @@
 
  function: libvorbis backend and mapping structures; needed for 
            static mode headers
- last mod: $Id: backends.h,v 1.8 2001/06/15 21:15:39 xiphmont Exp $
+ last mod: $Id: backends.h,v 1.9 2001/06/15 23:31:00 xiphmont Exp $
 
  ********************************************************************/
 
@@ -126,9 +126,9 @@
   void (*free_info)    (vorbis_info_residue *);
   void (*free_look)    (vorbis_look_residue *);
   int  (*forward)      (struct vorbis_block *,vorbis_look_residue *,
-			float **,int);
+			float **,int *,int);
   int  (*inverse)      (struct vorbis_block *,vorbis_look_residue *,
-			float **,int);
+			float **,int *,int);
 } vorbis_func_residue;
 
 typedef struct vorbis_info_residue0{

1.43      +2 -1      vorbis/lib/floor0.c

Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor0.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- floor0.c	2001/06/15 21:15:39	1.42
+++ floor0.c	2001/06/15 23:31:00	1.43
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.42 2001/06/15 21:15:39 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.43 2001/06/15 23:31:00 xiphmont Exp $
 
  ********************************************************************/
 
@@ -399,6 +399,7 @@
 #endif
 
   memset(codedflr,0,sizeof(float)*look->n);
+  memset(residue,0,sizeof(float)*look->n);
   return(val);
 }
 

1.9       +2 -1      vorbis/lib/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- floor1.c	2001/06/15 22:07:06	1.8
+++ floor1.c	2001/06/15 23:31:00	1.9
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.8 2001/06/15 22:07:06 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.9 2001/06/15 23:31:00 xiphmont Exp $
 
  ********************************************************************/
 
@@ -1016,6 +1016,7 @@
   }else{
     oggpack_write(&vb->opb,0,1);
     memset(codedflr,0,n*sizeof(float));
+    memset(residue,0,n*sizeof(float));
   }
   seq++;
   return(nonzero);

1.31      +36 -19    vorbis/lib/mapping0.c

Index: mapping0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/mapping0.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- mapping0.c	2001/06/15 21:15:39	1.30
+++ mapping0.c	2001/06/15 23:31:00	1.31
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.30 2001/06/15 21:15:39 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.31 2001/06/15 23:31:00 xiphmont Exp $
 
  ********************************************************************/
 
@@ -270,6 +270,7 @@
   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);
 
   int    *nonzero=alloca(sizeof(int)*vi->channels);
 
@@ -369,31 +370,36 @@
     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)){
-	pcmM[j]=A;
+	mag=A;
         if(A>0)
-	  pcmA[j]=A-B;
+	  ang=A-B;
         else
-	  pcmA[j]=B-A;
+	  ang=B-A;
       }else{
-	pcmM[j]=B;
+	mag=B;
         if(B>0)
-	  pcmA[j]=A-B;
+	  ang=A-B;
         else
-	  pcmA[j]=B-A;
+	  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(fabs(mag)<1.5)
+	ang=0;
+      
+      if(j>(n*3/16))
+	ang=0;
+      
+      if(ang>=fabs(mag*2))ang=-fabs(mag*2);
 
-      /*if(i>(n*3/16))
-	ang=0;*/
-            
-      /*if(ang>=fabs(mag*2))ang=-fabs(mag*2);*/
+      pcmM[j]=mag;
+      pcmA[j]=ang;
     }
   }
 
@@ -404,13 +410,17 @@
   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])
+      if(info->chmuxlist[j]==i){
+	if(nonzero[j])
+	  zerobundle[ch_in_bundle]=1;
+	else
+	  zerobundle[ch_in_bundle]=0;
         pcmbundle[ch_in_bundle++]=vb->pcm[j];
-   
+      }
     }
     
     look->residue_func[i]->forward(vb,look->residue_look[i],
-				   pcmbundle,ch_in_bundle);
+				   pcmbundle,zerobundle,ch_in_bundle);
   }
   
   look->lastframe=vb->sequence;
@@ -430,6 +440,7 @@
 
   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);
   
   /* time domain information decode (note that applying the
@@ -450,11 +461,17 @@
   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])
+      if(info->chmuxlist[j]==i){
+	if(nonzero[j])
+	  zerobundle[ch_in_bundle]=1;
+	else
+	  zerobundle[ch_in_bundle]=0;
         pcmbundle[ch_in_bundle++]=vb->pcm[j];
+      }
     }
-
-    look->residue_func[i]->inverse(vb,look->residue_look[i],pcmbundle,ch_in_bundle);
+    
+    look->residue_func[i]->inverse(vb,look->residue_look[i],
+				   pcmbundle,zerobundle,ch_in_bundle);
   }
 
   /* channel coupling */

1.32      +58 -18    vorbis/lib/res0.c

Index: res0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/res0.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- res0.c	2001/06/15 21:15:40	1.31
+++ res0.c	2001/06/15 23:31:00	1.32
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: residue backend 0, 1 and 2 implementation
- last mod: $Id: res0.c,v 1.31 2001/06/15 21:15:40 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.32 2001/06/15 23:31:00 xiphmont Exp $
 
  ********************************************************************/
 
@@ -532,43 +532,79 @@
 /* residue 0 and 1 are just slight variants of one another. 0 is
    interleaved, 1 is not */
 int res0_forward(vorbis_block *vb,vorbis_look_residue *vl,
-	    float **in,int ch){
-  return(_01forward(vb,vl,in,ch,_interleaved_testhack,_interleaved_encodepart));
+	    float **in,int *nonzero,int ch){
+  /* we encode only the nonzero parts of a bundle */
+  int i,used=0;
+  for(i=0;i<ch;i++)
+    if(nonzero[i])
+      in[used++]=in[i];
+  if(used)
+    return(_01forward(vb,vl,in,used,_interleaved_testhack,_interleaved_encodepart));
+  else
+    return(0);
+}
+
+int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,
+		 float **in,int *nonzero,int ch){
+  int i,used=0;
+  for(i=0;i<ch;i++)
+    if(nonzero[i])
+      in[used++]=in[i];
+  if(used)
+    return(_01inverse(vb,vl,in,used,vorbis_book_decodevs_add));
+  else
+    return(0);
 }
 
-int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
-  return(_01inverse(vb,vl,in,ch,vorbis_book_decodevs_add));
-}
-
 int res1_forward(vorbis_block *vb,vorbis_look_residue *vl,
-		 float **in,int ch){
-  return(_01forward(vb,vl,in,ch,_testhack,_encodepart));
-}
-
-int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
-  return(_01inverse(vb,vl,in,ch,vorbis_book_decodev_add));
+		 float **in,int *nonzero,int ch){
+  int i,used=0;
+  for(i=0;i<ch;i++)
+    if(nonzero[i])
+      in[used++]=in[i];
+  if(used)
+    return(_01forward(vb,vl,in,used,_testhack,_encodepart));
+  else
+    return(0);
+}
+
+int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
+		 float **in,int *nonzero,int ch){
+  int i,used=0;
+  for(i=0;i<ch;i++)
+    if(nonzero[i])
+      in[used++]=in[i];
+  if(used)
+    return(_01inverse(vb,vl,in,used,vorbis_book_decodev_add));
+  else
+    return(0);
 }
 
 /* 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;
+	    float **in,int *nonzero,int ch){
+  long i,j,k,n=vb->pcmend/2,used=0;
 
   /* 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];
+    if(nonzero[i])used++;
     for(j=0,k=i;j<n;j++,k+=ch)
       work[k]=pcm[j];
   }
-
-  return(_01forward(vb,vl,&work,1,_testhack,_encodepart));
+  
+  if(used)
+    return(_01forward(vb,vl,&work,1,_testhack,_encodepart));
+  else
+    return(0);
 }
 
 /* duplicate code here as speed is somewhat more important */
-int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,float **in,int ch){
+int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
+		 float **in,int *nonzero,int ch){
   long i,k,l,s;
   vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
   vorbis_info_residue0 *info=look->info;
@@ -581,7 +617,11 @@
   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 *));
+  int used;
   partvals=partwords*partitions_per_word;
+
+  for(i=0;i<ch;i++)if(nonzero[i])break;
+  if(i==ch)return(0); /* no nonzero vectors */
 
   for(s=0;s<look->stages;s++){
     for(i=info->begin,l=0;i<info->end;l++){

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