[xiph-cvs] cvs commit: Tremor floor1.c framing.c

Monty xiphmont at xiph.org
Mon Nov 25 12:20:21 PST 2002



xiphmont    02/11/25 15:20:21

  Modified:    .        floor1.c framing.c
  Log:
  Memory behavior tuning.  Average heap usage from 250kB -> 155kB.  Much more
  requires the newer zero-copy libogg2 backport and on-the-fly codebook decode.

Revision  Changes    Path
1.6       +0 -6      Tremor/floor1.c

Index: floor1.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/floor1.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- floor1.c	16 Oct 2002 09:12:08 -0000	1.5
+++ floor1.c	25 Nov 2002 20:20:21 -0000	1.6
@@ -28,9 +28,7 @@
 #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
 
 typedef struct {
-  int sorted_index[VIF_POSIT+2];
   int forward_index[VIF_POSIT+2];
-  int reverse_index[VIF_POSIT+2];
   
   int hineighbor[VIF_POSIT];
   int loneighbor[VIF_POSIT];
@@ -151,10 +149,6 @@
 
   /* points from sort order back to range number */
   for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
-  /* points from range order to sorted position */
-  for(i=0;i<n;i++)look->reverse_index[look->forward_index[i]]=i;
-  /* we actually need the post values too */
-  for(i=0;i<n;i++)look->sorted_index[i]=info->postlist[look->forward_index[i]];
   
   /* quantize values to multiplier spec */
   switch(info->mult){

<p><p>1.4       +31 -30    Tremor/framing.c

Index: framing.c
===================================================================
RCS file: /usr/local/cvsroot/Tremor/framing.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- framing.c	16 Oct 2002 08:10:08 -0000	1.3
+++ framing.c	25 Nov 2002 20:20:21 -0000	1.4
@@ -166,10 +166,10 @@
 int ogg_stream_init(ogg_stream_state *os,int serialno){
   if(os){
     memset(os,0,sizeof(*os));
-    os->body_storage=16*1024;
+    os->body_storage=6*1024;
     os->body_data=(unsigned char *)_ogg_malloc(os->body_storage*sizeof(*os->body_data));
 
-    os->lacing_storage=1024;
+    os->lacing_storage=128;
     os->lacing_vals=(int *)_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
     os->granule_vals=(ogg_int64_t *)_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
 
@@ -204,6 +204,17 @@
    what's happening fairly clear */
 
 static void _os_body_expand(ogg_stream_state *os,int needed){
+  /* can we shift first? */
+  if(os->body_storage<=os->body_fill+needed){
+    long br=os->body_returned;
+    
+    os->body_fill-=br;
+    if(os->body_fill)
+      memmove(os->body_data,os->body_data+br,os->body_fill);
+    os->body_returned=0;
+  }
+
+  /* still need more? */
   if(os->body_storage<=os->body_fill+needed){
     os->body_storage+=(needed+1024);
     os->body_data=(unsigned char *)_ogg_realloc(os->body_data,os->body_storage*sizeof(*os->body_data));
@@ -211,6 +222,24 @@
 }
 
 static void _os_lacing_expand(ogg_stream_state *os,int needed){
+
+  /* first check for a shift */
+  if(os->lacing_storage<=os->lacing_fill+needed){
+    long lr=os->lacing_returned;
+
+    /* segment table */
+    if(os->lacing_fill-lr){
+      memmove(os->lacing_vals,os->lacing_vals+lr,
+	      (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
+      memmove(os->granule_vals,os->granule_vals+lr,
+	      (os->lacing_fill-lr)*sizeof(*os->granule_vals));
+    }
+    os->lacing_fill-=lr;
+    os->lacing_packet-=lr;
+    os->lacing_returned=0;
+  }
+  
+  /* not enough?  *now* realloc */
   if(os->lacing_storage<=os->lacing_fill+needed){
     os->lacing_storage+=(needed+32);
     os->lacing_vals=(int *)_ogg_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals));
@@ -453,7 +482,6 @@
 
 /* add the incoming page to the stream state; we decompose the page
    into packet segments here as well. */
-
 int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){
   unsigned char *header=og->header;
   unsigned char *body=og->body;
@@ -469,33 +497,6 @@
   long pageno=ogg_page_pageno(og);
   int segments=header[26];
   
-  /* clean up 'returned data' */
-  {
-    long lr=os->lacing_returned;
-    long br=os->body_returned;
-
-    /* body data */
-    if(br>8192){
-      os->body_fill-=br;
-      if(os->body_fill)
-	memmove(os->body_data,os->body_data+br,os->body_fill);
-      os->body_returned=0;
-    }
-
-    if(lr>8192){
-      /* segment table */
-      if(os->lacing_fill-lr){
-	memmove(os->lacing_vals,os->lacing_vals+lr,
-		(os->lacing_fill-lr)*sizeof(*os->lacing_vals));
-	memmove(os->granule_vals,os->granule_vals+lr,
-		(os->lacing_fill-lr)*sizeof(*os->granule_vals));
-      }
-      os->lacing_fill-=lr;
-      os->lacing_packet-=lr;
-      os->lacing_returned=0;
-    }
-  }
-
   /* check the serial number */
   if(serialno!=os->serialno)return(-1);
   if(version>0)return(-1);

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