[xiph-cvs] cvs commit: vorbis/lib codebook.c sharedbook.c vorbisenc.c

Monty xiphmont at xiph.org
Mon Jan 21 18:16:41 PST 2002



xiphmont    02/01/21 18:16:41

  Modified:    lib      codebook.c sharedbook.c vorbisenc.c
  Log:
  Finished treeless decode optimizations for now.
  Fixed the approx_vbr assignment bug in vorbisenc

Revision  Changes    Path
1.38      +12 -13    vorbis/lib/codebook.c

Index: codebook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/codebook.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- codebook.c	2002/01/21 20:51:28	1.37
+++ codebook.c	2002/01/22 02:16:40	1.38
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.37 2002/01/21 20:51:28 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.38 2002/01/22 02:16:40 xiphmont Exp $
 
  ********************************************************************/
 
@@ -315,12 +315,11 @@
   return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa);
 }
 
-
-static long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
+STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){
   int  read=book->dec_maxlength;
   long lo,hi;
-  long lok = oggpack_look(b, book->dec_firsttablen);
-
+  long lok = oggpack_look(b,book->dec_firsttablen);
+ 
   if (lok >= 0) {
     long entry = book->dec_firsttable[lok];
     if(entry&0x80000000UL){
@@ -336,6 +335,7 @@
   }
 
   lok = oggpack_look(b, read);
+
   while(lok<0 && read>1)
     lok = oggpack_look(b, --read);
   if(lok<0)return -1;
@@ -343,18 +343,17 @@
   /* bisect search for the codeword in the ordered list */
   {
     ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok);
-    long p=(lo+hi)>>1;
 
     while(hi-lo>1){
-      long test=(book->codelist[p]<=testword)-1;
-      lo+=(p-lo)&(~test);
-      hi-=(hi-p)&test;
-      p=(lo+hi)>>1;
+      long p=(hi-lo)>>1;
+      long test=book->codelist[lo+p]>testword;    
+      lo+=p&(test-1);
+      hi-=p&(-test);
     }
 
-    if(book->dec_codelengths[p]<=read){
-      oggpack_adv(b, book->dec_codelengths[p]);
-      return(p);
+    if(book->dec_codelengths[lo]<=read){
+      oggpack_adv(b, book->dec_codelengths[lo]);
+      return(lo);
     }
   }
   

<p><p>1.26      +9 -8      vorbis/lib/sharedbook.c

Index: sharedbook.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/sharedbook.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- sharedbook.c	2002/01/21 20:51:28	1.25
+++ sharedbook.c	2002/01/22 02:16:40	1.26
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: basic shared codebook operations
- last mod: $Id: sharedbook.c,v 1.25 2002/01/21 20:51:28 xiphmont Exp $
+ last mod: $Id: sharedbook.c,v 1.26 2002/01/22 02:16:40 xiphmont Exp $
 
  ********************************************************************/
 
@@ -398,14 +398,14 @@
      hints for the non-direct-hits */
   {
     ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
+    long lo=0,hi=0;
 
     for(i=0;i<tabn;i++){
-      if(c->dec_firsttable[i]==0){
-	ogg_uint32_t testword=bitreverse(i);
-	long lo=0,hi=0;
-	while((lo+1)<n && c->codelist[lo+1]<=testword)lo++;
-	while(    hi<n && testword>=(c->codelist[hi]&mask))hi++;
-
+      ogg_uint32_t word=i<<(32-c->dec_firsttablen);
+      if(c->dec_firsttable[bitreverse(word)]==0){
+	while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
+	while(    hi<n && word>=(c->codelist[hi]&mask))hi++;
+	
         /* we only actually have 15 bits per hint to play with here.
            In order to overflow gracefully (nothing breaks, efficiency
            just drops), encode as the difference from the extremes. */
@@ -415,7 +415,8 @@
 
           if(loval>0x7fff)loval=0x7fff;
           if(hival>0x7fff)hival=0x7fff;
-	  c->dec_firsttable[i]=0x80000000UL | (loval<<15) | hival;
+	  c->dec_firsttable[bitreverse(word)]=
+	    0x80000000UL | (loval<<15) | hival;
         }
       }
     }

<p><p>1.34      +7 -4      vorbis/lib/vorbisenc.c

Index: vorbisenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisenc.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- vorbisenc.c	2001/12/23 11:53:53	1.33
+++ vorbisenc.c	2002/01/22 02:16:40	1.34
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: simple programmatic interface for encoder mode setup
- last mod: $Id: vorbisenc.c,v 1.33 2001/12/23 11:53:53 xiphmont Exp $
+ last mod: $Id: vorbisenc.c,v 1.34 2002/01/22 02:16:40 xiphmont Exp $
 
  ********************************************************************/
 
@@ -915,10 +915,8 @@
                                 long min_bitrate){
 
   double tnominal=nominal_bitrate;
-  double approx_vbr=approx_bitrate_to_vbr(channels,(channels==2), 
-					  (float)nominal_bitrate,rate);
+  double approx_vbr;
   int ret=0;
-  if(approx_vbr<0)return(OV_EIMPL);
 
   if(nominal_bitrate<=0.){
     if(max_bitrate>0.){
@@ -931,6 +929,11 @@
       }
     }
   }
+
+  approx_vbr=approx_bitrate_to_vbr(channels,(channels==2), 
+				   (float)nominal_bitrate,rate);
+  if(approx_vbr<0)return(OV_EIMPL);
+
 
   ret=vorbis_encode_setup_vbr(vi,channels,rate,approx_vbr);
   if(ret){

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