
--------------------------------------------------------------------------------
From: Segher Boessenkool (segher@chello.nl)
Date: Fri 02 Aug 2002 - 04:23:45 PDT 

Previous message: Kenneth C. Arnold: "[vorbis-dev] More spec notes" 
Next in thread: Kenneth C. Arnold: "Re: [vorbis-dev] rehuff -- maintenance release" 
Reply: Kenneth C. Arnold: "Re: [vorbis-dev] rehuff -- maintenance release" 
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ] 

--------------------------------------------------------------------------------


Hi all, 


There were a few "non-optimalities" in the rehuff code. Please apply 
patch, and cross fingers. 


Special thanks to Alan MacDonald, who found the semicolon imperfection, 
and everyone who sent me bug reports. 


Please test again :) 


The second problem is an evil one: a codeword length of zero is actually 
quite fine if it's the only codeword in the codebook; but Vorbis takes 
a length of zero to mean "not allocated". So let's waste a bit on those 
cases... 



Have fun, 



Segher 




diff -ur rehuff/recode-headers.c rehuff-new/recode-headers.c 
--- rehuff/recode-headers.c Wed Jul 31 02:09:23 2002 
+++ rehuff-new/recode-headers.c Fri Aug 2 10:11:41 2002 
@@ -275,11 +275,11 @@ 
                 recode_residue(&ob_in, &ob_out, headers->residue + i); 
  
         oggpack_copy(&ob_in, &ob_out, 6); 
- for (i = 0; i < headers->mappings; i++); 
+ for (i = 0; i < headers->mappings; i++) 
                 recode_mapping(&ob_in, &ob_out, headers->mapping + i, headers); 
  
         oggpack_copy(&ob_in, &ob_out, 6); 
- for (i = 0; i < headers->modes; i++); 
+ for (i = 0; i < headers->modes; i++) 
                 recode_mode(&ob_in, &ob_out, headers->mode + i); 
  
         oggpack_copy(&ob_in, &ob_out, 1); 
diff -ur rehuff/recode.c rehuff-new/recode.c 
--- rehuff/recode.c Wed Jul 31 01:54:03 2002 
+++ rehuff-new/recode.c Fri Aug 2 12:55:24 2002 
@@ -118,7 +118,7 @@ 
         if (heap.n) { 
                 for (i = 0; i < 2*book->n-1; i++) 
                         length[i] = -1; 
- length[heap.x[1]] = 0; 
+ length[heap.x[1]] = (heap.x[1] < book->n ? 1 : 0); 
         } 
  
         book->new_length = malloc(book->n * sizeof(*book->new_length)); 


diff -ur rehuff/recode-headers.c rehuff-new/recode-headers.c 
--- rehuff/recode-headers.c Wed Jul 31 02:09:23 2002 
+++ rehuff-new/recode-headers.c Fri Aug 2 10:11:41 2002 
@@ -275,11 +275,11 @@ 
                 recode_residue(&ob_in, &ob_out, headers->residue + i); 
  
         oggpack_copy(&ob_in, &ob_out, 6); 
- for (i = 0; i < headers->mappings; i++); 
+ for (i = 0; i < headers->mappings; i++) 
                 recode_mapping(&ob_in, &ob_out, headers->mapping + i, headers); 
  
         oggpack_copy(&ob_in, &ob_out, 6); 
- for (i = 0; i < headers->modes; i++); 
+ for (i = 0; i < headers->modes; i++) 
                 recode_mode(&ob_in, &ob_out, headers->mode + i); 
  
         oggpack_copy(&ob_in, &ob_out, 1); 
diff -ur rehuff/recode.c rehuff-new/recode.c 
--- rehuff/recode.c Wed Jul 31 01:54:03 2002 
+++ rehuff-new/recode.c Fri Aug 2 12:55:24 2002 
@@ -118,7 +118,7 @@ 
         if (heap.n) { 
                 for (i = 0; i < 2*book->n-1; i++) 
                         length[i] = -1; 
- length[heap.x[1]] = 0; 
+ length[heap.x[1]] = (heap.x[1] < book->n ? 1 : 0); 
         } 
  
         book->new_length = malloc(book->n * sizeof(*book->new_length)); 


