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

Monty xiphmont at xiph.org
Fri Jun 15 15:07:07 PDT 2001



xiphmont    01/06/15 15:07:07

  Modified:    lib      floor1.c
  Log:
  Restore the correct version; the default: bugfix commit and then
  partial rollback had removed a month's worth of changes.
  
  Monty

Revision  Changes    Path
1.8       +70 -34    vorbis/lib/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor1.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- floor1.c	2001/06/15 21:15:39	1.7
+++ floor1.c	2001/06/15 22:07:06	1.8
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: floor backend 1 implementation
- last mod: $Id: floor1.c,v 1.7 2001/06/15 21:15:39 xiphmont Exp $
+ last mod: $Id: floor1.c,v 1.8 2001/06/15 22:07:06 xiphmont Exp $
 
  ********************************************************************/
 
@@ -86,10 +86,10 @@
 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",
+    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));*/
+	    sqrt(look->mse/look->seq));
 
     memset(look,0,sizeof(vorbis_look_floor1));
     free(i);
@@ -382,6 +382,31 @@
 
   ady-=abs(base*adx);
 
+  d[x]*=FLOOR_fromdB_LOOKUP[y];
+  while(++x<x1){
+    err=err+ady;
+    if(err>=adx){
+      err-=adx;
+      y+=sy;
+    }else{
+      y+=base;
+    }
+    d[x]*=FLOOR_fromdB_LOOKUP[y];
+  }
+}
+
+static void render_line0(int x0,int x1,int y0,int y1,float *d){
+  int dy=y1-y0;
+  int adx=x1-x0;
+  int ady=abs(dy);
+  int base=dy/adx;
+  int sy=(dy<0?base-1:base+1);
+  int x=x0;
+  int y=y0;
+  int err=0;
+
+  ady-=abs(base*adx);
+
   d[x]=FLOOR_fromdB_LOOKUP[y];
   while(++x<x1){
     err=err+ady;
@@ -510,7 +535,6 @@
     double fx=x;
     double fy=y;
     double fx2=x2;
-    double fy2=y2;
     double fxy=xy;
     double denom=1./(an*fx2-fx*fx);
     double a=(fy*fx2-fxy*fx)*denom;
@@ -528,7 +552,7 @@
   }
 }
 
-static void fit_line_point(lsfit_acc *a,int fits,int *y0,int *y1){
+/*static void fit_line_point(lsfit_acc *a,int fits,int *y0,int *y1){
   long y=0;
   int i;
 
@@ -536,7 +560,7 @@
     y+=a[i].ya;
   
   *y0=*y1=y;
-}
+  }*/
 
 static int inspect_error(int x0,int x1,int y0,int y1,const float *mask,
                          const float *mdct,
@@ -959,13 +983,14 @@
       int hx;
       int lx=0;
       int ly=fit_valueA[0]*info->mult;
+
       for(j=1;j<posts;j++){
         int current=look->forward_index[j];
         if(!(fit_valueA[current]&0x8000)){
           int hy=(fit_valueA[current]&0x7fff)*info->mult;
           hx=info->postlist[current];
           
-	  render_line(lx,hx,ly,hy,codedflr);
+	  render_line0(lx,hx,ly,hy,codedflr);
           
           lx=hx;
           ly=hy;
@@ -996,19 +1021,18 @@
   return(nonzero);
 }
 
-static int floor1_inverse(vorbis_block *vb,vorbis_look_floor *in,float *out){
+static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
   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,k;
   codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
     fullbooks;   
 
   /* unpack wrapped/predicted values from stream */
   if(oggpack_read(&vb->opb,1)==1){
-    int fit_value[VIF_POSIT+2];
+    int *fit_value=_vorbis_block_alloc(vb,(look->posts)*sizeof(int));
 
     fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
     fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
@@ -1079,32 +1103,44 @@
         
     }
 
-    /* render the lines */
-    {
-      int hx;
-      int lx=0;
-      int ly=fit_value[0]*info->mult;
-      for(j=1;j<look->posts;j++){
-	int current=look->forward_index[j];
-	int hy=fit_value[current]&0x7fff;
-	if(hy==fit_value[current]){
+    return(fit_value);
+  }
+ eop:
+  return(NULL);
+}
 
-	  hy*=info->mult;
-	  hx=info->postlist[current];
-	  
-	  render_line(lx,hx,ly,hy,out);
-	  
-	  lx=hx;
-	  ly=hy;
-	}
+static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
+			  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 j;
+
+  if(memo){
+    /* render the lines */
+    int *fit_value=(int *)memo;
+    int hx;
+    int lx=0;
+    int ly=fit_value[0]*info->mult;
+    for(j=1;j<look->posts;j++){
+      int current=look->forward_index[j];
+      int hy=fit_value[current]&0x7fff;
+      if(hy==fit_value[current]){
+	
+	hy*=info->mult;
+	hx=info->postlist[current];
+	
+	render_line(lx,hx,ly,hy,out);
+	
+	lx=hx;
+	ly=hy;
       }
-      for(j=hx;j<n;j++)out[j]=out[j-1]; /* be certain */
-    }    
+    }
+    for(j=hx;j<n;j++)out[j]*=out[j-1]; /* be certain */    
     return(1);
   }
-
-  /* fall through */
- eop:
   memset(out,0,sizeof(float)*n);
   return(0);
 }
@@ -1112,6 +1148,6 @@
 /* export hooks */
 vorbis_func_floor floor1_exportbundle={
   &floor1_pack,&floor1_unpack,&floor1_look,&floor1_copy_info,&floor1_free_info,
-  &floor1_free_look,&floor1_forward,&floor1_inverse
+  &floor1_free_look,&floor1_forward,&floor1_inverse1,&floor1_inverse2
 };
 

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