[xiph-commits] r14208 - branches/theora-thusnelda/lib/enc

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Nov 20 23:36:22 PST 2007


Author: xiphmont
Date: 2007-11-20 23:36:21 -0800 (Tue, 20 Nov 2007)
New Revision: 14208

Modified:
   branches/theora-thusnelda/lib/enc/codec_internal.h
   branches/theora-thusnelda/lib/enc/dct_decode.c
   branches/theora-thusnelda/lib/enc/encode.c
   branches/theora-thusnelda/lib/enc/encoder_huffman.c
   branches/theora-thusnelda/lib/enc/encoder_lookup.h
   branches/theora-thusnelda/lib/enc/encoder_toplevel.c
   branches/theora-thusnelda/lib/enc/toplevel_lookup.h
Log:
Continue removal of dead code



Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-21 07:36:21 UTC (rev 14208)
@@ -125,25 +125,6 @@
 
 } HUFF_ENTRY;
 
-typedef struct qmat_range_table {
-  int startq, startqi; /* index where this range starts */
-  ogg_int16_t *qmat;  /* qmat at this range boundary */
-} qmat_range_table;
-
-/** codec setup data, maps to the third bitstream header */
-typedef struct codec_setup_info {
-  ogg_uint32_t QThreshTable[Q_TABLE_SIZE];
-  ogg_int16_t DcScaleFactorTable[Q_TABLE_SIZE];
-
-  int MaxQMatrixIndex;
-  ogg_int16_t *qmats;
-  qmat_range_table *range_table[6];
-
-  HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES];
-
-  unsigned char LoopFilterLimitValues[Q_TABLE_SIZE];
-} codec_setup_info;
-
 /** Decoder (Playback) instance -- installed in a theora_state */
 typedef struct PB_INSTANCE {
   theora_info     info;
@@ -506,12 +487,8 @@
 extern void quant_tables_init( PB_INSTANCE *pbi, const th_quant_info *qinfo);
 extern void InitHuffmanSet( PB_INSTANCE *pbi );
 extern void ClearHuffmanSet( PB_INSTANCE *pbi );
-extern int  ReadHuffmanTrees(codec_setup_info *ci, oggpack_buffer *opb);
 extern void WriteHuffmanTrees(HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES],
                               oggpack_buffer *opb);
-extern void InitHuffmanTrees(PB_INSTANCE *pbi, const codec_setup_info *ci);
-extern void ClearHuffmanTrees(HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES]);
-extern int  ReadFilterTables(codec_setup_info *ci, oggpack_buffer *opb);
 extern void QuadDecodeDisplayFragments ( PB_INSTANCE *pbi );
 extern void PackAndWriteDFArray( CP_INSTANCE *cpi );
 extern void UpdateFragQIndex(PB_INSTANCE *pbi);

Modified: branches/theora-thusnelda/lib/enc/dct_decode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-21 07:36:21 UTC (rev 14208)
@@ -20,17 +20,6 @@
 #include "codec_internal.h"
 #include "quant_lookup.h"
 
-
-#define GOLDEN_FRAME_THRESH_Q   50
-#define PUR 8
-#define PU 4
-#define PUL 2
-#define PL 1
-#define HIGHBITDUPPED(X) (((signed short) X)  >> 15)
-
-
-static const int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
-
 static void SetupBoundingValueArray_Generic(PB_INSTANCE *pbi,
                                             ogg_int32_t FLimit){
 
@@ -47,22 +36,6 @@
   }
 }
 
-/* handle the in-loop filter limit value table */
-
-int ReadFilterTables(codec_setup_info *ci, oggpack_buffer *opb){
-  int i;
-  int bits, value;
-
-  theora_read(opb, 3, &bits);
-  for(i=0;i<Q_TABLE_SIZE;i++){
-    theora_read(opb,bits,&value);
-    ci->LoopFilterLimitValues[i]=value;
-  }
-  if(bits<0)return OC_BADHEADER;
-
-  return 0;
-}
-
 void SetupLoopFilter(PB_INSTANCE *pbi){
   ogg_int32_t FLimit;
 
@@ -673,7 +646,7 @@
 }
 
 void ReconRefFrames (PB_INSTANCE *pbi){
-  ogg_int32_t i,j;
+  ogg_int32_t i;
   unsigned char *SwapReconBuffersTemp;
 
   SetupLoopFilter(pbi);

Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/encode.c	2007-11-21 07:36:21 UTC (rev 14208)
@@ -21,12 +21,144 @@
 #include "encoder_lookup.h"
 #include "block_inline.h"
 
-#define PUR 8
-#define PU 4
-#define PUL 2
-#define PL 1
-#define HIGHBITDUPPED(X) (((ogg_int16_t) X)  >> 15)
+static void PredictDC(CP_INSTANCE *cpi, ogg_int16_t *predicted){
+  ogg_int32_t   i,j;
+  int k,m,n;
 
+  /* value left value up-left, value up, value up-right, missing
+      values skipped. */
+  int v[4];
+
+  /* fragment number left, up-left, up, up-right */
+  int fn[4];
+
+  /* predictor count. */
+  int pcount;
+
+  /*which predictor constants to use */
+  ogg_int16_t wpc;
+
+  /* last used inter predictor (Raster Order) */
+  ogg_int16_t Last[3];  /* last value used for given frame */
+
+  int FragsAcross;
+  int FragsDown;
+  int FromFragment,ToFragment;
+  int WhichFrame;
+  int WhichCase;
+
+  /* for y,u,v */
+  for ( j = 0; j < 3 ; j++) {
+    /* pick which fragments based on Y, U, V */
+    switch(j){
+    case 0: /* y */
+      FromFragment = 0;
+      ToFragment = cpi->pb.YPlaneFragments;
+      FragsAcross = cpi->pb.HFragments;
+      FragsDown = cpi->pb.VFragments;
+      break;
+    case 1: /* u */
+      FromFragment = cpi->pb.YPlaneFragments;
+      ToFragment = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments ;
+      FragsAcross = cpi->pb.HFragments >> 1;
+      FragsDown = cpi->pb.VFragments >> 1;
+      break;
+    /*case 2:  v */
+    default:
+      FromFragment = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments;
+      ToFragment = cpi->pb.YPlaneFragments + (2 * cpi->pb.UVPlaneFragments) ;
+      FragsAcross = cpi->pb.HFragments >> 1;
+      FragsDown = cpi->pb.VFragments >> 1;
+      break;
+    }
+
+    /* initialize our array of last used DC Components */
+    for(k=0;k<3;k++)Last[k]=0;
+    i=FromFragment;
+
+    /* do prediction on all of Y, U or V */
+    for ( m = 0 ; m < FragsDown ; m++) {
+      for ( n = 0 ; n < FragsAcross ; n++, i++) {
+        predicted[i] = cpi->pb.QFragData[i][0];
+
+        /* only do 2 prediction if fragment coded and on non intra or
+           if all fragments are intra */
+        if( cpi->pb.display_fragments[i] ||
+            (cpi->pb.FrameType == KEY_FRAME) ) {
+          /* Type of Fragment */
+
+          WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
+
+          /* Check Borderline Cases */
+          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
+
+          fn[0]=i-1;
+          fn[1]=i-FragsAcross-1;
+          fn[2]=i-FragsAcross;
+          fn[3]=i-FragsAcross+1;
+
+          /* fragment valid for prediction use if coded and it comes
+             from same frame as the one we are predicting */
+          for(k=pcount=wpc=0; k<4; k++) {
+            int pflag;
+            pflag=1<<k;
+            if((bc_mask[WhichCase]&pflag) &&
+               cpi->pb.display_fragments[fn[k]] &&
+               (Mode2Frame[cpi->pb.FragCodingMethod[fn[k]]] == WhichFrame)){
+              v[pcount]=cpi->pb.QFragData[fn[k]][0];
+              wpc|=pflag;
+              pcount++;
+            }
+          }
+
+          if(wpc==0) {
+
+            /* fall back to the last coded fragment */
+            predicted[i] -= Last[WhichFrame];
+
+          } else {
+
+            /* don't do divide if divisor is 1 or 0 */
+            ogg_int16_t DC = pc[wpc][0]*v[0];
+            for(k=1; k<pcount; k++)
+              DC += pc[wpc][k]*v[k];
+	    
+            /* if we need to do a shift */
+            if(pc[wpc][4] != 0 ) {
+	      
+              /* If negative add in the negative correction factor */
+              DC += (HIGHBITDUPPED(DC) & pc[wpc][5]);
+              /* Shift in lieu of a divide */
+              DC >>= pc[wpc][4];
+
+            }
+
+            /* check for outranging on the two predictors that can outrange */
+            if((wpc&(PU|PUL|PL)) == (PU|PUL|PL)){
+              if( abs(DC - v[2]) > 128) {
+                DC = v[2];
+              } else if( abs(DC - v[0]) > 128) {
+                DC = v[0];
+              } else if( abs(DC - v[1]) > 128) {
+                DC = v[1];
+              }
+            }
+
+            predicted[i] -= DC;
+          }
+
+          /* Save the last fragment coded for whatever frame we are
+             predicting from */
+
+          Last[WhichFrame] = cpi->pb.QFragData[i][0];
+
+        }
+      }
+    }
+  }
+}
+
+
 static ogg_uint32_t QuadCodeComponent ( CP_INSTANCE *cpi,
 					ogg_uint32_t FirstSB,
 					ogg_uint32_t SBRows,
@@ -271,7 +403,7 @@
 static void PackModes (CP_INSTANCE *cpi) {
   ogg_uint32_t    i,j;
   unsigned char   ModeIndex;
-  unsigned char  *SchemeList;
+  const unsigned char  *SchemeList;
 
   unsigned char   BestModeSchemes[MAX_MODES];
   ogg_int32_t     ModeCount[MAX_MODES];
@@ -389,8 +521,8 @@
 static void PackMotionVectors (CP_INSTANCE *cpi) {
   ogg_int32_t  i;
   ogg_uint32_t MethodBits[2] = {0,0};
-  ogg_uint32_t * MvBitsPtr;
-  ogg_uint32_t * MvPatternPtr;
+  const ogg_uint32_t * MvBitsPtr;
+  const ogg_uint32_t * MvPatternPtr;
 
   oggpack_buffer *opb=cpi->oggbuffer;
 
@@ -691,104 +823,26 @@
 
 }
 
-static ogg_uint32_t QuadCodeDisplayFragments (CP_INSTANCE *cpi) {
-  ogg_int32_t   i,j;
+ogg_uint32_t EncodeData(CP_INSTANCE *cpi){
+  ogg_int32_t   i;
   ogg_uint32_t  coded_pixels=0;
-  int           QIndex;
-  int k,m,n;
 
-  /* predictor multiplier up-left, up, up-right,left, shift
-     Entries are packed in the order L, UL, U, UR, with missing entries
-      moved to the end (before the shift parameters). */
-  static const ogg_int16_t pc[16][6]={
-    {0,0,0,0,0,0},
-    {1,0,0,0,0,0},      /* PL */
-    {1,0,0,0,0,0},      /* PUL */
-    {1,0,0,0,0,0},      /* PUL|PL */
-    {1,0,0,0,0,0},      /* PU */
-    {1,1,0,0,1,1},      /* PU|PL */
-    {0,1,0,0,0,0},      /* PU|PUL */
-    {29,-26,29,0,5,31}, /* PU|PUL|PL */
-    {1,0,0,0,0,0},      /* PUR */
-    {75,53,0,0,7,127},  /* PUR|PL */
-    {1,1,0,0,1,1},      /* PUR|PUL */
-    {75,0,53,0,7,127},  /* PUR|PUL|PL */
-    {1,0,0,0,0,0},      /* PUR|PU */
-    {75,0,53,0,7,127},  /* PUR|PU|PL */
-    {3,10,3,0,4,15},    /* PUR|PU|PUL */
-    {29,-26,29,0,5,31}  /* PUR|PU|PUL|PL */
-  };
-
-  /* boundary case bit masks. */
-  static const int bc_mask[8]={
-    /* normal case no boundary condition */
-    PUR|PU|PUL|PL,
-    /* left column */
-    PUR|PU,
-    /* top row */
-    PL,
-    /* top row, left column */
-    0,
-    /* right column */
-    PU|PUL|PL,
-    /* right and left column */
-    PU,
-    /* top row, right column */
-    PL,
-    /* top row, right and left column */
-    0
-  };
-
-  /* value left value up-left, value up, value up-right, missing
-      values skipped. */
-  int v[4];
-
-  /* fragment number left, up-left, up, up-right */
-  int fn[4];
-
-  /* predictor count. */
-  int pcount;
-
-  /*which predictor constants to use */
-  ogg_int16_t wpc;
-
-  /* last used inter predictor (Raster Order) */
-  ogg_int16_t Last[3];  /* last value used for given frame */
-
-  int FragsAcross=cpi->pb.HFragments;
-  int FragsDown = cpi->pb.VFragments;
-  int FromFragment,ToFragment;
-  int WhichFrame;
-  int WhichCase;
-
-  static const ogg_int16_t Mode2Frame[] = {
-    1,  /* CODE_INTER_NO_MV     0 => Encoded diff from same MB last frame  */
-    0,  /* CODE_INTRA           1 => DCT Encoded Block */
-    1,  /* CODE_INTER_PLUS_MV   2 => Encoded diff from included MV MB last frame */
-    1,  /* CODE_INTER_LAST_MV   3 => Encoded diff from MRU MV MB last frame */
-    1,  /* CODE_INTER_PRIOR_MV  4 => Encoded diff from included 4 separate MV blocks */
-    2,  /* CODE_USING_GOLDEN    5 => Encoded diff from same MB golden frame */
-    2,  /* CODE_GOLDEN_MV       6 => Encoded diff from included MV MB golden frame */
-    1   /* CODE_INTER_FOUR_MV   7 => Encoded diff from included 4 separate MV blocks */
-  };
-
-  ogg_int16_t PredictedDC;
-
+  /* Zero the count of tokens so far this frame. */
+  cpi->TotTokenCount = 0;
+  
+  /* Zero the mode and MV list indices. */
+  cpi->ModeListCount = 0;
+  
+  /* Zero Decoder EOB run count */
+  cpi->pb.EOB_Run = 0;
+  
   /* Initialise the coded block indices variables. These allow
      subsequent linear access to the quad tree ordered list of coded
      blocks */
   cpi->pb.CodedBlockIndex = 0;
 
-  /* Set the inter/intra descision control variables. */
-  QIndex = Q_TABLE_SIZE - 1;
-  while ( QIndex >= 0 ) {
-    if ( (QIndex == 0) ||
-         ( cpi->pb.QThreshTable[QIndex] >= cpi->pb.ThisFrameQualityValue) )
-      break;
-    QIndex --;
-  }
+  dsp_save_fpu (cpi->dsp);
 
-
   /* Encode and tokenise the Y, U and V components */
   coded_pixels = QuadCodeComponent(cpi, 0, cpi->pb.YSBRows, cpi->pb.YSBCols,
                                    cpi->pb.info.width );
@@ -801,117 +855,8 @@
                                     cpi->pb.UVSBRows, cpi->pb.UVSBCols,
                                     cpi->pb.info.width>>1 );
 
-  /* for y,u,v */
-  for ( j = 0; j < 3 ; j++) {
-    /* pick which fragments based on Y, U, V */
-    switch(j){
-    case 0: /* y */
-      FromFragment = 0;
-      ToFragment = cpi->pb.YPlaneFragments;
-      FragsAcross = cpi->pb.HFragments;
-      FragsDown = cpi->pb.VFragments;
-      break;
-    case 1: /* u */
-      FromFragment = cpi->pb.YPlaneFragments;
-      ToFragment = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments ;
-      FragsAcross = cpi->pb.HFragments >> 1;
-      FragsDown = cpi->pb.VFragments >> 1;
-      break;
-    /*case 2:  v */
-    default:
-      FromFragment = cpi->pb.YPlaneFragments + cpi->pb.UVPlaneFragments;
-      ToFragment = cpi->pb.YPlaneFragments + (2 * cpi->pb.UVPlaneFragments) ;
-      FragsAcross = cpi->pb.HFragments >> 1;
-      FragsDown = cpi->pb.VFragments >> 1;
-      break;
-    }
+  PredictDC(cpi, cpi->PredictedDC);
 
-    /* initialize our array of last used DC Components */
-    for(k=0;k<3;k++)Last[k]=0;
-    i=FromFragment;
-
-    /* do prediction on all of Y, U or V */
-    for ( m = 0 ; m < FragsDown ; m++) {
-      for ( n = 0 ; n < FragsAcross ; n++, i++) {
-        cpi->PredictedDC[i] = cpi->pb.QFragData[i][0];
-
-        /* only do 2 prediction if fragment coded and on non intra or
-           if all fragments are intra */
-        if( cpi->pb.display_fragments[i] ||
-            (cpi->pb.FrameType == KEY_FRAME) ) {
-          /* Type of Fragment */
-
-          WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
-
-          /* Check Borderline Cases */
-          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
-
-          fn[0]=i-1;
-          fn[1]=i-FragsAcross-1;
-          fn[2]=i-FragsAcross;
-          fn[3]=i-FragsAcross+1;
-
-          /* fragment valid for prediction use if coded and it comes
-             from same frame as the one we are predicting */
-          for(k=pcount=wpc=0; k<4; k++) {
-            int pflag;
-            pflag=1<<k;
-            if((bc_mask[WhichCase]&pflag) &&
-               cpi->pb.display_fragments[fn[k]] &&
-               (Mode2Frame[cpi->pb.FragCodingMethod[fn[k]]] == WhichFrame)){
-              v[pcount]=cpi->pb.QFragData[fn[k]][0];
-              wpc|=pflag;
-              pcount++;
-            }
-          }
-
-          if(wpc==0) {
-
-            /* fall back to the last coded fragment */
-            cpi->PredictedDC[i] -= Last[WhichFrame];
-
-          } else {
-
-            /* don't do divide if divisor is 1 or 0 */
-            PredictedDC = pc[wpc][0]*v[0];
-            for(k=1; k<pcount; k++){
-              PredictedDC += pc[wpc][k]*v[k];
-            }
-
-            /* if we need to do a shift */
-            if(pc[wpc][4] != 0 ) {
-
-              /* If negative add in the negative correction factor */
-              PredictedDC += (HIGHBITDUPPED(PredictedDC) & pc[wpc][5]);
-              /* Shift in lieu of a divide */
-              PredictedDC >>= pc[wpc][4];
-
-            }
-
-            /* check for outranging on the two predictors that can outrange */
-            if((wpc&(PU|PUL|PL)) == (PU|PUL|PL)){
-              if( abs(PredictedDC - v[2]) > 128) {
-                PredictedDC = v[2];
-              } else if( abs(PredictedDC - v[0]) > 128) {
-                PredictedDC = v[0];
-              } else if( abs(PredictedDC - v[1]) > 128) {
-                PredictedDC = v[1];
-              }
-            }
-
-            cpi->PredictedDC[i] -= PredictedDC;
-          }
-
-          /* Save the last fragment coded for whatever frame we are
-             predicting from */
-
-          Last[WhichFrame] = cpi->pb.QFragData[i][0];
-
-        }
-      }
-    }
-  }
-
 #ifdef _TH_DEBUG_
  {
    int j;
@@ -933,33 +878,12 @@
   /* Reconstruct the reference frames */
   ReconRefFrames(&cpi->pb);
 
+  dsp_restore_fpu (cpi->dsp);
+
   /* Return total number of coded pixels */
   return coded_pixels;
 }
 
-ogg_uint32_t EncodeData(CP_INSTANCE *cpi){
-    ogg_uint32_t coded_pixels = 0;
-
-    /* Zero the count of tokens so far this frame. */
-    cpi->TotTokenCount = 0;
-
-    /* Zero the mode and MV list indices. */
-    cpi->ModeListCount = 0;
-
-    /* Zero Decoder EOB run count */
-    cpi->pb.EOB_Run = 0;
-
-    dsp_save_fpu (cpi->dsp);
-
-    /* Encode any fragments coded using DCT. */
-    coded_pixels += QuadCodeDisplayFragments (cpi);
-
-    dsp_restore_fpu (cpi->dsp);
-
-    return coded_pixels;
-
-}
-
 ogg_uint32_t PickIntra( CP_INSTANCE *cpi,
                         ogg_uint32_t SBRows,
                         ogg_uint32_t SBCols){

Modified: branches/theora-thusnelda/lib/enc/encoder_huffman.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_huffman.c	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/encoder_huffman.c	2007-11-21 07:36:21 UTC (rev 14208)
@@ -188,6 +188,14 @@
   }
 }
 
+static void  ClearHuffmanTrees(HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES]){
+  int i;
+  for(i=0; i<NUM_HUFF_TABLES; i++) {
+    DestroyHuffTree(HuffRoot[i]);
+    HuffRoot[i] = NULL;
+  }
+}
+
 void ClearHuffmanSet( PB_INSTANCE *pbi ){
   int i;
 
@@ -242,32 +250,3 @@
   }
 }
 
-static HUFF_ENTRY *CopyHuffTree(const HUFF_ENTRY *HuffSrc) {
-  if(HuffSrc){
-    HUFF_ENTRY *HuffDst;
-    HuffDst = (HUFF_ENTRY *)_ogg_calloc(1, sizeof(HUFF_ENTRY));
-    HuffDst->Value = HuffSrc->Value;
-    if (HuffSrc->Value < 0) {
-      HuffDst->ZeroChild = CopyHuffTree(HuffSrc->ZeroChild);
-      HuffDst->OneChild = CopyHuffTree(HuffSrc->OneChild);
-    }
-    return HuffDst;
-  }
-  return NULL;
-}
-
-void InitHuffmanTrees(PB_INSTANCE *pbi, const codec_setup_info *ci) {
-  int i;
-  pbi->ExtraBitLengths_VP3x = ExtraBitLengths_VP31;
-  for(i=0; i<NUM_HUFF_TABLES; i++){
-    pbi->HuffRoot_VP3x[i] = CopyHuffTree(ci->HuffRoot[i]);
-  }
-}
-
-void  ClearHuffmanTrees(HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES]){
-  int i;
-  for(i=0; i<NUM_HUFF_TABLES; i++) {
-    DestroyHuffTree(HuffRoot[i]);
-    HuffRoot[i] = NULL;
-  }
-}

Modified: branches/theora-thusnelda/lib/enc/encoder_lookup.h
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_lookup.h	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/encoder_lookup.h	2007-11-21 07:36:21 UTC (rev 14208)
@@ -17,7 +17,7 @@
 
 #include "codec_internal.h"
 
-ogg_uint32_t MvPattern[(MAX_MV_EXTENT * 2) + 1] = {
+static const ogg_uint32_t MvPattern[(MAX_MV_EXTENT * 2) + 1] = {
   0x000000ff, 0x000000fd, 0x000000fb, 0x000000f9,
   0x000000f7, 0x000000f5, 0x000000f3, 0x000000f1,
   0x000000ef, 0x000000ed, 0x000000eb, 0x000000e9,
@@ -36,7 +36,7 @@
   0x000000fa, 0x000000fc, 0x000000fe,
 };
 
-ogg_uint32_t MvBits[(MAX_MV_EXTENT * 2) + 1] = {
+static const ogg_uint32_t MvBits[(MAX_MV_EXTENT * 2) + 1] = {
   8, 8, 8, 8, 8, 8, 8, 8,
   8, 8, 8, 8, 8, 8, 8, 8,
   7, 7, 7, 7, 7, 7, 7, 7,
@@ -47,7 +47,7 @@
   8, 8, 8, 8, 8, 8, 8,
 };
 
-ogg_uint32_t MvPattern2[(MAX_MV_EXTENT * 2) + 1] = {
+static const ogg_uint32_t MvPattern2[(MAX_MV_EXTENT * 2) + 1] = {
   0x0000003f, 0x0000003d, 0x0000003b, 0x00000039,
   0x00000037, 0x00000035, 0x00000033, 0x00000031,
   0x0000002f, 0x0000002d, 0x0000002b, 0x00000029,
@@ -66,7 +66,7 @@
   0x0000003a, 0x0000003c, 0x0000003e,
 };
 
-ogg_uint32_t MvBits2[(MAX_MV_EXTENT * 2) + 1] = {
+static const ogg_uint32_t MvBits2[(MAX_MV_EXTENT * 2) + 1] = {
   6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6,
   6, 6, 6, 6, 6, 6, 6, 6,
@@ -77,13 +77,13 @@
   6, 6, 6, 6, 6, 6, 6,
 };
 
-ogg_uint32_t ModeBitPatterns[MAX_MODES] = {
+static const ogg_uint32_t ModeBitPatterns[MAX_MODES] = {
   0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0x7E, 0x7F };
 
-ogg_int32_t ModeBitLengths[MAX_MODES] =  {
+static const ogg_int32_t ModeBitLengths[MAX_MODES] =  {
   1,    2,    3,    4,    5,    6,    7,    7 };
 
-unsigned char ModeSchemes[MODE_METHODS-2][MAX_MODES] =  {
+static const unsigned char ModeSchemes[MODE_METHODS-2][MAX_MODES] =  {
   /* Last Mv dominates */
   { 3,    4,    2,    0,    1,    5,    6,    7 },    /* L P  M N I G GM 4 */
   { 2,    4,    3,    0,    1,    5,    6,    7 },    /* L P  N M I G GM 4 */
@@ -96,8 +96,7 @@
 
 };
 
-
-ogg_uint32_t MvThreshTable[Q_TABLE_SIZE] = {
+static const ogg_uint32_t MvThreshTable[Q_TABLE_SIZE] = {
   65, 65, 65, 65, 50, 50, 50, 50,
   40, 40, 40, 40, 40, 40, 40, 40,
   30, 30, 30, 30, 30, 30, 30, 30,
@@ -108,7 +107,7 @@
   0,  0,  0,  0,  0,  0,  0,  0
 };
 
-ogg_uint32_t MVChangeFactorTable[Q_TABLE_SIZE] = {
+static const ogg_uint32_t MVChangeFactorTable[Q_TABLE_SIZE] = {
   11, 11, 11, 11, 12, 12, 12, 12,
   13, 13, 13, 13, 13, 13, 13, 13,
   14, 14, 14, 14, 14, 14, 14, 14,
@@ -118,3 +117,62 @@
   15, 15, 15, 15, 15, 15, 15, 15,
   15, 15, 15, 15, 15, 15, 15, 15
 };
+
+#define PUR 8
+#define PU 4
+#define PUL 2
+#define PL 1
+#define HIGHBITDUPPED(X) (((ogg_int16_t) X)  >> 15)
+
+/* predictor multiplier up-left, up, up-right,left, shift
+   Entries are packed in the order L, UL, U, UR, with missing entries
+   moved to the end (before the shift parameters). */
+static const ogg_int16_t pc[16][6]={
+  {0,0,0,0,0,0},
+  {1,0,0,0,0,0},      /* PL */
+  {1,0,0,0,0,0},      /* PUL */
+  {1,0,0,0,0,0},      /* PUL|PL */
+  {1,0,0,0,0,0},      /* PU */
+  {1,1,0,0,1,1},      /* PU|PL */
+  {0,1,0,0,0,0},      /* PU|PUL */
+  {29,-26,29,0,5,31}, /* PU|PUL|PL */
+  {1,0,0,0,0,0},      /* PUR */
+  {75,53,0,0,7,127},  /* PUR|PL */
+  {1,1,0,0,1,1},      /* PUR|PUL */
+  {75,0,53,0,7,127},  /* PUR|PUL|PL */
+  {1,0,0,0,0,0},      /* PUR|PU */
+  {75,0,53,0,7,127},  /* PUR|PU|PL */
+  {3,10,3,0,4,15},    /* PUR|PU|PUL */
+  {29,-26,29,0,5,31}  /* PUR|PU|PUL|PL */
+};
+
+/* boundary case bit masks. */
+static const int bc_mask[8]={
+  /* normal case no boundary condition */
+  PUR|PU|PUL|PL,
+  /* left column */
+  PUR|PU,
+  /* top row */
+  PL,
+  /* top row, left column */
+  0,
+  /* right column */
+  PU|PUL|PL,
+  /* right and left column */
+  PU,
+  /* top row, right column */
+  PL,
+  /* top row, right and left column */
+  0
+};
+
+static const ogg_int16_t Mode2Frame[] = {
+  1,  /* CODE_INTER_NO_MV     0 => Encoded diff from same MB last frame  */
+  0,  /* CODE_INTRA           1 => DCT Encoded Block */
+  1,  /* CODE_INTER_PLUS_MV   2 => Encoded diff from included MV MB last frame */
+  1,  /* CODE_INTER_LAST_MV   3 => Encoded diff from MRU MV MB last frame */
+  1,  /* CODE_INTER_PRIOR_MV  4 => Encoded diff from included 4 separate MV blocks */
+  2,  /* CODE_USING_GOLDEN    5 => Encoded diff from same MB golden frame */
+  2,  /* CODE_GOLDEN_MV       6 => Encoded diff from included MV MB golden frame */
+  1   /* CODE_INTER_FOUR_MV   7 => Encoded diff from included 4 separate MV blocks */
+};

Modified: branches/theora-thusnelda/lib/enc/encoder_toplevel.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-21 07:36:21 UTC (rev 14208)
@@ -31,121 +31,6 @@
 long dframe=0;
 #endif
 
-/*The default quantization parameters used by VP3.1.*/
-static const int OC_VP31_RANGE_SIZES[1]={63};
-static const th_quant_base OC_VP31_BASES_INTRA_Y[2]={
-  {
-     16, 11, 10, 16, 24,  40, 51, 61,
-     12, 12, 14, 19, 26,  58, 60, 55,
-     14, 13, 16, 24, 40,  57, 69, 56,
-     14, 17, 22, 29, 51,  87, 80, 62,
-     18, 22, 37, 58, 68, 109,103, 77,
-     24, 35, 55, 64, 81, 104,113, 92,
-     49, 64, 78, 87,103, 121,120,101,
-     72, 92, 95, 98,112, 100,103, 99
-  },
-  {
-     16, 11, 10, 16, 24,  40, 51, 61,
-     12, 12, 14, 19, 26,  58, 60, 55,
-     14, 13, 16, 24, 40,  57, 69, 56,
-     14, 17, 22, 29, 51,  87, 80, 62,
-     18, 22, 37, 58, 68, 109,103, 77,
-     24, 35, 55, 64, 81, 104,113, 92,
-     49, 64, 78, 87,103, 121,120,101,
-     72, 92, 95, 98,112, 100,103, 99
-  }
-};
-static const th_quant_base OC_VP31_BASES_INTRA_C[2]={
-  {
-     17, 18, 24, 47, 99, 99, 99, 99,
-     18, 21, 26, 66, 99, 99, 99, 99,
-     24, 26, 56, 99, 99, 99, 99, 99,
-     47, 66, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99
-  },
-  {
-     17, 18, 24, 47, 99, 99, 99, 99,
-     18, 21, 26, 66, 99, 99, 99, 99,
-     24, 26, 56, 99, 99, 99, 99, 99,
-     47, 66, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99,
-     99, 99, 99, 99, 99, 99, 99, 99
-  }
-};
-static const th_quant_base OC_VP31_BASES_INTER[2]={
-  {
-     16, 16, 16, 20, 24, 28, 32, 40,
-     16, 16, 20, 24, 28, 32, 40, 48,
-     16, 20, 24, 28, 32, 40, 48, 64,
-     20, 24, 28, 32, 40, 48, 64, 64,
-     24, 28, 32, 40, 48, 64, 64, 64,
-     28, 32, 40, 48, 64, 64, 64, 96,
-     32, 40, 48, 64, 64, 64, 96,128,
-     40, 48, 64, 64, 64, 96,128,128
-  },
-  {
-     16, 16, 16, 20, 24, 28, 32, 40,
-     16, 16, 20, 24, 28, 32, 40, 48,
-     16, 20, 24, 28, 32, 40, 48, 64,
-     20, 24, 28, 32, 40, 48, 64, 64,
-     24, 28, 32, 40, 48, 64, 64, 64,
-     28, 32, 40, 48, 64, 64, 64, 96,
-     32, 40, 48, 64, 64, 64, 96,128,
-     40, 48, 64, 64, 64, 96,128,128
-  }
-};
-
-const th_quant_info TH_VP31_QUANT_INFO={
-  {
-    220,200,190,180,170,170,160,160,
-    150,150,140,140,130,130,120,120,
-    110,110,100,100, 90, 90, 90, 80,
-     80, 80, 70, 70, 70, 60, 60, 60,
-     60, 50, 50, 50, 50, 40, 40, 40,
-     40, 40, 30, 30, 30, 30, 30, 30,
-     30, 20, 20, 20, 20, 20, 20, 20,
-     20, 10, 10, 10, 10, 10, 10, 10
-  },
-  {
-    500,450,400,370,340,310,285,265,
-    245,225,210,195,185,180,170,160,
-    150,145,135,130,125,115,110,107,
-    100, 96, 93, 89, 85, 82, 75, 74,
-     70, 68, 64, 60, 57, 56, 52, 50,
-     49, 45, 44, 43, 40, 38, 37, 35,
-     33, 32, 30, 29, 28, 25, 24, 22,
-     21, 19, 18, 17, 15, 13, 12, 10
-  },
-  {
-    30,25,20,20,15,15,14,14,
-    13,13,12,12,11,11,10,10,
-     9, 9, 8, 8, 7, 7, 7, 7,
-     6, 6, 6, 6, 5, 5, 5, 5,
-     4, 4, 4, 4, 3, 3, 3, 3,
-     2, 2, 2, 2, 2, 2, 2, 2,
-     0, 0, 0, 0, 0, 0, 0, 0,
-     0, 0, 0, 0, 0, 0, 0, 0
-  },
-  {
-    {
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_Y},
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C},
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C}
-    },
-    {
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
-      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER}
-    }
-  }
-};
-
-
 static void EClearFragmentInfo(CP_INSTANCE * cpi){
   if(cpi->FragTokens)
     _ogg_free(cpi->FragTokens);
@@ -322,6 +207,7 @@
 #else
   oggpackB_writeinit(cpi->oggbuffer, cpi->oggbufferstate);
 #endif
+
   /* mark as video frame */
   oggpackB_write(cpi->oggbuffer,0,1);
 

Modified: branches/theora-thusnelda/lib/enc/toplevel_lookup.h
===================================================================
--- branches/theora-thusnelda/lib/enc/toplevel_lookup.h	2007-11-21 05:03:05 UTC (rev 14207)
+++ branches/theora-thusnelda/lib/enc/toplevel_lookup.h	2007-11-21 07:36:21 UTC (rev 14208)
@@ -29,6 +29,7 @@
   240, 235, 230, 225, 220, 215, 210, 205,
   200, 195, 190, 185, 180, 175, 170, 165,
   160, 155, 150, 145, 140, 135, 130, 130 };
+
 const ogg_uint32_t ResidueBlockFactor[Q_TABLE_SIZE] =  {
   3,   3,   3,   3,   3,   3,   3,   3,
   3,   3,   3,   3,   3,   3,   3,   3,
@@ -38,3 +39,119 @@
   2,   2,   2,   2,   2,   2,   2,   2,
   2,   2,   2,   2,   2,   2,   2,   2,
   2,   2,   2,   2,   2,   2,   2,   2 };
+
+/*The default quantization parameters used by VP3.1.*/
+static const int OC_VP31_RANGE_SIZES[1]={63};
+static const th_quant_base OC_VP31_BASES_INTRA_Y[2]={
+  {
+     16, 11, 10, 16, 24,  40, 51, 61,
+     12, 12, 14, 19, 26,  58, 60, 55,
+     14, 13, 16, 24, 40,  57, 69, 56,
+     14, 17, 22, 29, 51,  87, 80, 62,
+     18, 22, 37, 58, 68, 109,103, 77,
+     24, 35, 55, 64, 81, 104,113, 92,
+     49, 64, 78, 87,103, 121,120,101,
+     72, 92, 95, 98,112, 100,103, 99
+  },
+  {
+     16, 11, 10, 16, 24,  40, 51, 61,
+     12, 12, 14, 19, 26,  58, 60, 55,
+     14, 13, 16, 24, 40,  57, 69, 56,
+     14, 17, 22, 29, 51,  87, 80, 62,
+     18, 22, 37, 58, 68, 109,103, 77,
+     24, 35, 55, 64, 81, 104,113, 92,
+     49, 64, 78, 87,103, 121,120,101,
+     72, 92, 95, 98,112, 100,103, 99
+  }
+};
+static const th_quant_base OC_VP31_BASES_INTRA_C[2]={
+  {
+     17, 18, 24, 47, 99, 99, 99, 99,
+     18, 21, 26, 66, 99, 99, 99, 99,
+     24, 26, 56, 99, 99, 99, 99, 99,
+     47, 66, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99
+  },
+  {
+     17, 18, 24, 47, 99, 99, 99, 99,
+     18, 21, 26, 66, 99, 99, 99, 99,
+     24, 26, 56, 99, 99, 99, 99, 99,
+     47, 66, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99
+  }
+};
+static const th_quant_base OC_VP31_BASES_INTER[2]={
+  {
+     16, 16, 16, 20, 24, 28, 32, 40,
+     16, 16, 20, 24, 28, 32, 40, 48,
+     16, 20, 24, 28, 32, 40, 48, 64,
+     20, 24, 28, 32, 40, 48, 64, 64,
+     24, 28, 32, 40, 48, 64, 64, 64,
+     28, 32, 40, 48, 64, 64, 64, 96,
+     32, 40, 48, 64, 64, 64, 96,128,
+     40, 48, 64, 64, 64, 96,128,128
+  },
+  {
+     16, 16, 16, 20, 24, 28, 32, 40,
+     16, 16, 20, 24, 28, 32, 40, 48,
+     16, 20, 24, 28, 32, 40, 48, 64,
+     20, 24, 28, 32, 40, 48, 64, 64,
+     24, 28, 32, 40, 48, 64, 64, 64,
+     28, 32, 40, 48, 64, 64, 64, 96,
+     32, 40, 48, 64, 64, 64, 96,128,
+     40, 48, 64, 64, 64, 96,128,128
+  }
+};
+
+const th_quant_info TH_VP31_QUANT_INFO={
+  {
+    220,200,190,180,170,170,160,160,
+    150,150,140,140,130,130,120,120,
+    110,110,100,100, 90, 90, 90, 80,
+     80, 80, 70, 70, 70, 60, 60, 60,
+     60, 50, 50, 50, 50, 40, 40, 40,
+     40, 40, 30, 30, 30, 30, 30, 30,
+     30, 20, 20, 20, 20, 20, 20, 20,
+     20, 10, 10, 10, 10, 10, 10, 10
+  },
+  {
+    500,450,400,370,340,310,285,265,
+    245,225,210,195,185,180,170,160,
+    150,145,135,130,125,115,110,107,
+    100, 96, 93, 89, 85, 82, 75, 74,
+     70, 68, 64, 60, 57, 56, 52, 50,
+     49, 45, 44, 43, 40, 38, 37, 35,
+     33, 32, 30, 29, 28, 25, 24, 22,
+     21, 19, 18, 17, 15, 13, 12, 10
+  },
+  {
+    30,25,20,20,15,15,14,14,
+    13,13,12,12,11,11,10,10,
+     9, 9, 8, 8, 7, 7, 7, 7,
+     6, 6, 6, 6, 5, 5, 5, 5,
+     4, 4, 4, 4, 3, 3, 3, 3,
+     2, 2, 2, 2, 2, 2, 2, 2,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0
+  },
+  {
+    {
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_Y},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C}
+    },
+    {
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER}
+    }
+  }
+};
+
+



More information about the commits mailing list