[xiph-commits] r9495 - trunk/theora/lib

giles at svn.xiph.org giles at svn.xiph.org
Mon Jun 20 09:42:30 PDT 2005


Author: giles
Date: 2005-06-20 09:42:25 -0700 (Mon, 20 Jun 2005)
New Revision: 9495

Modified:
   trunk/theora/lib/encoder_internal.h
   trunk/theora/lib/quant.c
   trunk/theora/lib/toplevel.c
Log:
Remeber the range table for the quant matricies from the setup header.


Modified: trunk/theora/lib/encoder_internal.h
===================================================================
--- trunk/theora/lib/encoder_internal.h	2005-06-20 10:29:53 UTC (rev 9494)
+++ trunk/theora/lib/encoder_internal.h	2005-06-20 16:42:25 UTC (rev 9495)
@@ -5,7 +5,7 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2005                *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
@@ -45,6 +45,7 @@
 /* Border is for unrestricted mv's */
 #define UMV_BORDER              16
 #define STRIDE_EXTRA            (UMV_BORDER * 2)
+
 #define Q_TABLE_SIZE            64
 
 #define BASE_FRAME              0
@@ -250,11 +251,19 @@
 
 } HUFF_ENTRY;
 
+typedef struct qmat_range_table {
+  int startq, startqi; /* index where this range starts */
+  Q_LIST_ENTRY *qmat;  /* qmat at each this range boundary */
+} qmat_range_table;
+
 typedef struct codec_setup_info {
   ogg_uint32_t QThreshTable[Q_TABLE_SIZE];
   Q_LIST_ENTRY DcScaleFactorTable[Q_TABLE_SIZE];
+
   int MaxQMatrixIndex;
   Q_LIST_ENTRY *qmats;
+  qmat_range_table *range_table[6];
+
   Q_LIST_ENTRY Y_coeffs[64];
   Q_LIST_ENTRY UV_coeffs[64];
   Q_LIST_ENTRY Inter_coeffs[64];

Modified: trunk/theora/lib/quant.c
===================================================================
--- trunk/theora/lib/quant.c	2005-06-20 10:29:53 UTC (rev 9494)
+++ trunk/theora/lib/quant.c	2005-06-20 16:42:25 UTC (rev 9495)
@@ -5,7 +5,7 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2005                *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
@@ -168,12 +168,17 @@
   oggpackB_write(opb, 0, 2);  /* inter V the same */
 }
 
-static int _read_qtable_range(codec_setup_info *ci, oggpack_buffer* opb, int N) 
+static int _read_qtable_range(codec_setup_info *ci, oggpack_buffer* opb,
+	 int N, int type) 
 {
   int index, range;
   int qi = 0;
+  int count = 0;
+  qmat_range_table table[65];
 
   theora_read(opb,_ilog(N-1),&index); /* qi=0 index */
+  table[count].startqi = 0;
+  table[count++].qmat = ci->qmats + index * Q_TABLE_SIZE;
   //fprintf(stderr, " [%d]",index);
   while(qi<63) {
     theora_read(opb,_ilog(62-qi),&range); /* range to next code q matrix */
@@ -182,10 +187,18 @@
     if(range<=0) return OC_BADHEADER;
     qi+=range;
     theora_read(opb,_ilog(N-1),&index); /* next index */
+    table[count].startqi = qi;
+    table[count++].qmat = ci->qmats + index * Q_TABLE_SIZE;
     //fprintf(stderr, " [%d]",index);
   }
 
-  return 0;
+  ci->range_table[type] = _ogg_malloc(count * sizeof(qmat_range_table));
+  if (ci->range_table[type] != NULL) {
+    memcpy(&ci->range_table[type], table, count * sizeof(qmat_range_table)); 
+    return 0;
+  }
+  
+  return OC_FAULT; /* allocation failed */
 }
 
 int ReadQTables(codec_setup_info *ci, oggpack_buffer* opb) {
@@ -224,18 +237,21 @@
     //fprintf(stderr,"\n");
   }
   /* table mapping */
+  for(x=0; x<6; x++) {
+    ci->range_table[x] = NULL;
+  }
   {
     int flag, ret;
     /* intra Y */
     //fprintf(stderr,"\n Intra Y:");
-    if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+    if((ret=_read_qtable_range(ci,opb,N,0))<0) return ret;
     /* intra U */
     //fprintf(stderr, "\n Intra U:");
     theora_read(opb,1,&flag);
     if(flag<0) return OC_BADHEADER;
     if(flag) {
       /* explicitly coded */
-      if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+      if((ret=_read_qtable_range(ci,opb,N,1))<0) return ret;
     } else {
       /* same as previous */
       //fprintf(stderr," same as above");
@@ -246,7 +262,7 @@
     if(flag<0) return OC_BADHEADER;
     if(flag) {
       /* explicitly coded */
-      if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+      if((ret=_read_qtable_range(ci,opb,N,2))<0) return ret;
     } else {
        /* same as previous */
       //fprintf(stderr," same as above");
@@ -257,7 +273,7 @@
     if(flag<0) return OC_BADHEADER;
     if(flag) {
       /* explicitly coded */
-      if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+      if((ret=_read_qtable_range(ci,opb,N,3))<0) return ret;
     } else {
       theora_read(opb,1,&flag);
       if(flag<0) return OC_BADHEADER;
@@ -275,7 +291,7 @@
     if(flag<0) return OC_BADHEADER;
     if(flag) {
       /* explicitly coded */
-      if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+      if((ret=_read_qtable_range(ci,opb,N,4))<0) return ret;
     } else {
       theora_read(opb,1,&flag);
       if(flag<0) return OC_BADHEADER;
@@ -293,7 +309,7 @@
     if(flag<0) return OC_BADHEADER;
     if(flag) {
       /* explicitly coded */
-      if((ret=_read_qtable_range(ci,opb,N))<0) return ret;
+      if((ret=_read_qtable_range(ci,opb,N,5))<0) return ret;
     } else {
       theora_read(opb,1,&flag);
       if(flag<0) return OC_BADHEADER;

Modified: trunk/theora/lib/toplevel.c
===================================================================
--- trunk/theora/lib/toplevel.c	2005-06-20 10:29:53 UTC (rev 9494)
+++ trunk/theora/lib/toplevel.c	2005-06-20 16:42:25 UTC (rev 9495)
@@ -5,7 +5,7 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2005                *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
@@ -71,8 +71,11 @@
 
 void theora_info_clear(theora_info *c) {
   codec_setup_info *ci=c->codec_setup;
+  int i;
   if(ci){
     if(ci->qmats) _ogg_free(ci->qmats);
+    for(i=0;i<6;i++)
+      if(ci->range_table[i]) _ogg_free(ci->range_table[i]);
     ClearHuffmanTrees(ci->HuffRoot);
     _ogg_free(ci);
   }



More information about the commits mailing list