[xiph-cvs] cvs commit: theora/lib dct_decode.c quant.c toplevel.c

Ralph Giles giles at xiph.org
Wed Mar 17 18:00:31 PST 2004



giles       04/03/17 21:00:31

  Modified:    lib      dct_decode.c quant.c toplevel.c
  Log:
  Instead of using fixed-size tables in the setup header, record a number
  of bits per entry before each array. This breaks byte but since the
  table values are often smaller than their reasonable maximums it allows
  saving considerable space.
  
  THIS IS AN INCOMPATIBLE BITSTREAM CHANGE.
  
  However, lossless transcoding is possible, as with all the recent header
  changes.
  
  For the in-loop filter limits table, 7 bits is the maximum reasonable
  value so we store the entry size as a 3 bit explicit value, so the range
  is 0-7 bits. (0 is an error)
  
  For the quantizer tables, 16 bits is a general upper bound although our
  current table entries are much smaller. For all of these tables we store
  the entry size minus one in 4 bits, so the range is 1-16 bits.

Revision  Changes    Path
1.11      +9 -5      theora/lib/dct_decode.c

Index: dct_decode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/dct_decode.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- a/dct_decode.c	9 Mar 2004 02:02:56 -0000	1.10
+++ b/dct_decode.c	18 Mar 2004 02:00:30 -0000	1.11
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: dct_decode.c,v 1.10 2004/03/09 02:02:56 giles Exp $
+  last mod: $Id: dct_decode.c,v 1.11 2004/03/18 02:00:30 giles Exp $
 
  ********************************************************************/
 
@@ -73,16 +73,20 @@
 
 void WriteFilterTables(PB_INSTANCE *pbi, oggpack_buffer *opb){
   int i;
+  int bits=4;
+  oggpackB_write(opb, bits, 3);
   for(i=0;i<Q_TABLE_SIZE;i++)
-    oggpackB_write(opb, pbi->LoopFilterLimits[i],7);
+    oggpackB_write(opb, pbi->LoopFilterLimits[i],bits);
 }
 
 int ReadFilterTables(codec_setup_info *ci, oggpack_buffer *opb){
-  int i, bits;
+  int i;
+  int bits, value;
 
+  theora_read(opb, 3, &bits);
   for(i=0;i<Q_TABLE_SIZE;i++){
-    theora_read(opb,7,&bits);
-    ci->LoopFilterLimitValues[i]=bits;
+    theora_read(opb,bits,&value);
+    ci->LoopFilterLimitValues[i]=value;
   }
   if(bits<0)return OC_BADHEADER;
 

<p><p>1.19      +27 -18    theora/lib/quant.c

Index: quant.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/quant.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- a/quant.c	8 Mar 2004 02:11:46 -0000	1.18
+++ b/quant.c	18 Mar 2004 02:00:30 -0000	1.19
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: quant.c,v 1.18 2004/03/08 02:11:46 giles Exp $
+  last mod: $Id: quant.c,v 1.19 2004/03/18 02:00:30 giles Exp $
 
  ********************************************************************/
 
@@ -129,24 +129,31 @@
   }
   return(ret);
 }
-                
+
 void WriteQTables(PB_INSTANCE *pbi,oggpack_buffer* opb) {
-  int x;
+  int x, bits;
+  bits=10;
+  oggpackB_write(opb, bits-1, 4);
   for(x=0; x<64; x++) {
-    oggpackB_write(opb, pbi->QThreshTable[x],16);
+    oggpackB_write(opb, pbi->QThreshTable[x],bits);
   }
+  oggpackB_write(opb, bits-1, 4);
   for(x=0; x<64; x++) {
-    oggpackB_write(opb, pbi->DcScaleFactorTable[x],16);
+    oggpackB_write(opb, pbi->DcScaleFactorTable[x],bits);
   }
   oggpackB_write(opb, 3 - 1, 9); /* number of base matricies */
+  bits=8;
+  oggpackB_write(opb, bits-1, 4);
   for(x=0; x<64; x++) {
-    oggpackB_write(opb, pbi->Y_coeffs[x],8);
+    oggpackB_write(opb, pbi->Y_coeffs[x],bits);
   }
+  oggpackB_write(opb, bits-1, 4);
   for(x=0; x<64; x++) {
-    oggpackB_write(opb, pbi->UV_coeffs[x],8);
+    oggpackB_write(opb, pbi->UV_coeffs[x],bits);
   }
+  oggpackB_write(opb, bits-1, 4);
   for(x=0; x<64; x++) {
-    oggpackB_write(opb, pbi->Inter_coeffs[x],8);
+    oggpackB_write(opb, pbi->Inter_coeffs[x],bits);
   }
   /* table mapping */
   oggpackB_write(opb, 0, 2);  /* matrix 0 for intra Y */
@@ -186,35 +193,37 @@
 }
 
 int ReadQTables(codec_setup_info *ci, oggpack_buffer* opb) {
-  long bits;
+  long bits,value;
   int x,y, N;
   //fprintf(stderr, "Reading Q tables...\n");
   /* AC scale table */
+  theora_read(opb,4,&bits); bits++;
   for(x=0; x<Q_TABLE_SIZE; x++) {
-    theora_read(opb,16,&bits);
+    theora_read(opb,bits,&value);
     if(bits<0)return OC_BADHEADER;
-    ci->QThreshTable[x]=bits;
+    ci->QThreshTable[x]=value;
   }
   /* DC scale table */
+  theora_read(opb,4,&bits); bits++;
   for(x=0; x<Q_TABLE_SIZE; x++) {
-    theora_read(opb,16,&bits);
+    theora_read(opb,bits,&value);
     if(bits<0)return OC_BADHEADER;
-    ci->DcScaleFactorTable[x]=(Q_LIST_ENTRY)bits;
+    ci->DcScaleFactorTable[x]=(Q_LIST_ENTRY)value;
   }
   /* base matricies */
-  theora_read(opb,9,&N);
-  N++;
+  theora_read(opb,9,&N); N++;
   //fprintf(stderr, "  max q matrix index %d\n", N);
   if(N!=3)return OC_BADHEADER; /* we only support the VP3 config */
   ci->qmats=_ogg_malloc(N*64*sizeof(Q_LIST_ENTRY));
   ci->MaxQMatrixIndex = N;
   for(y=0; y<N; y++) {
     //fprintf(stderr," q matrix %d:\n  ", y);
+    theora_read(opb,4,&bits); bits++;
     for(x=0; x<64; x++) {
-      theora_read(opb,8,&bits);
+      theora_read(opb,bits,&value);
       if(bits<0)return OC_BADHEADER;
-      ci->qmats[(y<<6)+x]=(Q_LIST_ENTRY)bits;
-      //fprintf(stderr," %03d", (Q_LIST_ENTRY)bits);
+      ci->qmats[(y<<6)+x]=(Q_LIST_ENTRY)value;
+      //fprintf(stderr," %03d", (Q_LIST_ENTRY)value);
       //if((x+1)%8==0)fprintf(stderr,"\n  ");
     }
     //fprintf(stderr,"\n");

<p><p>1.39      +2 -2      theora/lib/toplevel.c

Index: toplevel.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- a/toplevel.c	13 Mar 2004 23:46:27 -0000	1.38
+++ b/toplevel.c	18 Mar 2004 02:00:30 -0000	1.39
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: toplevel.c,v 1.38 2004/03/13 23:46:27 giles Exp $
+  last mod: $Id: toplevel.c,v 1.39 2004/03/18 02:00:30 giles Exp $
 
  ********************************************************************/
 
@@ -24,7 +24,7 @@
 #define VERSION_MINOR 2
 #define VERSION_SUB 0
 
-#define VENDOR_STRING "Xiph.Org libTheora I 20040313 3 2 0"
+#define VENDOR_STRING "Xiph.Org libTheora I 20040317 3 2 0"
 
 #define A_TABLE_SIZE        29
 #define DF_CANDIDATE_WINDOW 5

<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