[xiph-cvs] cvs commit: theora/lib huffman.c hufftables.h quant.c toplevel.c

Ralph Giles giles at xiph.org
Wed Feb 26 13:04:33 PST 2003



giles       03/02/26 16:04:33

  Modified:    lib      huffman.c hufftables.h quant.c toplevel.c
  Log:
  Write the quant tables and frequency counts into the file header so
  they're not needed in the decoder, a la vorbis. Also rename some of the
  VP31 tables to just VP3. Patch from Dan Miller.
  
  THIS BREAKS BITSTREAM COMPATIBILITY WITH ALPHA 1. There will be more
  changes as we hammer out the details; backward compatibility will only
  be maintained after the first beta release.

Revision  Changes    Path
1.5       +19 -2     theora/lib/huffman.c

Index: huffman.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/huffman.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- huffman.c	23 Sep 2002 02:01:28 -0000	1.4
+++ huffman.c	26 Feb 2003 21:04:33 -0000	1.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: huffman.c,v 1.4 2002/09/23 02:01:28 xiphmont Exp $
+  last mod: $Id: huffman.c,v 1.5 2003/02/26 21:04:33 giles Exp $
 
  ********************************************************************/
 
@@ -237,7 +237,24 @@
     BuildHuffmanTree( pbi->HuffRoot_VP3x, 
                       pbi->HuffCodeArray_VP3x[i],
                       pbi->HuffCodeLengthArray_VP3x[i],
-		      i, FrequencyCounts_VP31[i]);
+		      i, FrequencyCounts_VP3[i]);
   }
 }
 
+void write_FrequencyCounts(oggpack_buffer* opb) {
+  int x, y;
+  for(x=0; x<NUM_HUFF_TABLES; x++) {
+    for(y=0; y<MAX_ENTROPY_TOKENS; y++) {
+	  oggpackB_write(opb, FrequencyCounts_VP3[x][y], 16);
+	}
+  }
+}
+
+void read_FrequencyCounts(oggpack_buffer* opb) {
+  int x, y;
+  for(x=0; x<NUM_HUFF_TABLES; x++) {
+    for(y=0; y<MAX_ENTROPY_TOKENS; y++) {
+	  FrequencyCounts_VP3[x][y]=oggpackB_read(opb, 16);
+	}
+  }
+}

<p><p>1.2       +2 -2      theora/lib/hufftables.h

Index: hufftables.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/hufftables.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- hufftables.h	18 Sep 2002 08:56:57 -0000	1.1
+++ hufftables.h	26 Feb 2003 21:04:33 -0000	1.2
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: hufftables.h,v 1.1 2002/09/18 08:56:57 xiphmont Exp $
+  last mod: $Id: hufftables.h,v 1.2 2003/02/26 21:04:33 giles Exp $
 
  ********************************************************************/
 
@@ -26,7 +26,7 @@
 };
 
 /* Frequency tables for encoder version < 2 */
-ogg_uint32_t FrequencyCounts_VP31[NUM_HUFF_TABLES][MAX_ENTROPY_TOKENS] = {
+ogg_uint32_t FrequencyCounts_VP3[NUM_HUFF_TABLES][MAX_ENTROPY_TOKENS] = {
   /* DC Intra bias */
   {  198,    62,    22,    31,    14,     6,     6,   205,     3,
      843,   843,   415,   516,

<p><p>1.5       +45 -1     theora/lib/quant.c

Index: quant.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/quant.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- quant.c	23 Sep 2002 09:15:04 -0000	1.4
+++ quant.c	26 Feb 2003 21:04:33 -0000	1.5
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: quant.c,v 1.4 2002/09/23 09:15:04 xiphmont Exp $
+  last mod: $Id: quant.c,v 1.5 2003/02/26 21:04:33 giles Exp $
 
  ********************************************************************/
 
@@ -74,6 +74,50 @@
   32,  40,  48,  64,  64,  64,  96,  128,
   40,  48,  64,  64,  64,  96,  128, 128
 };
+
+
+///	dbm 12/5/02 -- write qtables into header.  called from theora_encode_header (toplevel.c)
+///	someday we can change the quant tables to be adaptive, or just plain better.
+
+void write_Qtables(oggpack_buffer* opb) {
+  int x;
+  for(x=0; x<64; x++) {
+	oggpackB_write(opb, QThreshTableV1[x],16);
+  }
+  for(x=0; x<64; x++) {
+	oggpackB_write(opb, DcScaleFactorTableV1[x],16);
+  }
+  for(x=0; x<64; x++) {
+	oggpackB_write(opb, Y_coeffsV1[x],8);
+  }
+  for(x=0; x<64; x++) {
+	oggpackB_write(opb, UV_coeffsV1[x],8);
+  }
+  for(x=0; x<64; x++) {
+	oggpackB_write(opb, Inter_coeffsV1[x],8);
+  }
+}
+
+///	dbm 12/5/02 -- read qtables from header.  called from theora_decode_header (toplevel.c)
+
+void read_Qtables(oggpack_buffer* opb) {
+  int x;
+  for(x=0; x<64; x++) {
+	QThreshTableV1[x]=oggpackB_read(opb, 16);
+  }
+  for(x=0; x<64; x++) {
+	DcScaleFactorTableV1[x]=oggpackB_read(opb, 16);
+  }
+  for(x=0; x<64; x++) {
+	Y_coeffsV1[x]=oggpackB_read(opb, 8);
+  }
+  for(x=0; x<64; x++) {
+	UV_coeffsV1[x]=oggpackB_read(opb, 8);
+  }
+  for(x=0; x<64; x++) {
+	Inter_coeffsV1[x]=oggpackB_read(opb, 8);
+  }
+}
 
 void InitQTables( PB_INSTANCE *pbi ){
   memcpy ( pbi->QThreshTable, QThreshTableV1, sizeof( pbi->QThreshTable ) );

<p><p>1.13      +9 -1      theora/lib/toplevel.c

Index: toplevel.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- toplevel.c	25 Sep 2002 02:38:10 -0000	1.12
+++ toplevel.c	26 Feb 2003 21:04:33 -0000	1.13
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: toplevel.c,v 1.12 2002/09/25 02:38:10 xiphmont Exp $
+  last mod: $Id: toplevel.c,v 1.13 2003/02/26 21:04:33 giles Exp $
 
  ********************************************************************/
 
@@ -1035,6 +1035,10 @@
   oggpackB_write(&cpi->oggbuffer,cpi->pb.info.target_bitrate,24);
   oggpackB_write(&cpi->oggbuffer,cpi->pb.info.quality,6);
 
+///	dbm -- added functions to write important data (qtables + huff stuff) into header
+  write_Qtables(&cpi->oggbuffer);
+  write_FrequencyCounts(&cpi->oggbuffer);
+
   op->packet=oggpackB_get_buffer(&cpi->oggbuffer);
   op->bytes=oggpackB_bytes(&cpi->oggbuffer);
 
@@ -1118,6 +1122,10 @@
 
   c->target_bitrate=oggpackB_read(&opb,24);
   c->quality=ret=oggpackB_read(&opb,6);
+
+///	dbm -- read important stuff from the stream header:
+  read_Qtables(&opb);
+  read_FrequencyCounts(&opb);
 
   if(ret==-1)return(OC_BADHEADER);
 

<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