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

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Nov 27 05:40:06 PST 2007


Author: xiphmont
Date: 2007-11-27 05:40:03 -0800 (Tue, 27 Nov 2007)
New Revision: 14237

Modified:
   branches/theora-thusnelda/lib/enc/codec_internal.h
   branches/theora-thusnelda/lib/enc/dct_decode.c
   branches/theora-thusnelda/lib/enc/dct_encode.c
   branches/theora-thusnelda/lib/enc/encode.c
   branches/theora-thusnelda/lib/enc/encoder_toplevel.c
   branches/theora-thusnelda/lib/enc/frinit.c
Log:
Continue refactoring code to allow slotting in derf's MV changes 



Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-27 13:40:03 UTC (rev 14237)
@@ -94,7 +94,7 @@
     CODE_USING_GOLDEN     = 0x5, /* 'Golden frame' prediction (no MV). */
     CODE_GOLDEN_MV        = 0x6, /* 'Golden frame' prediction plus MV. */
     CODE_INTER_FOURMV     = 0x7  /* Inter prediction 4MV per macro block. */
-} CODING_MODE;
+} coding_mode_t;
 
 /** Huffman table entry */
 typedef struct HUFF_ENTRY {
@@ -113,22 +113,32 @@
 
 typedef struct fragment {
   int coded;
+  coding_mode_t mode;
   mv_t mv;
   ogg_int16_t pred_dc;
   ogg_int16_t dct[64];
 
+  unsigned char nonzero;
+  ogg_uint32_t  token_list[128];
+  unsigned char tokens_coded;
+  unsigned char coeffs_packed;
+  unsigned char tokens_packed;
+
   ogg_uint32_t raw_index;
   ogg_uint32_t recon_index;
 } fragment_t;
 
 typedef struct macroblock {
   int mode;
-  fragment_t *f[4]; // hilbert order
+  fragment_t *y[4]; // MV (raster) order
+  fragment_t *u;
+  fragment_t *v;
 } macroblock_t;
 
 #define SB_MB_BLFRAG(sb,mbnum) ((sb).f[ ((mbnum)<2? ((mbnum)==0?0:4) : ((mbnum)==2?8:14)) ])
 typedef struct superblock {
   fragment_t *f[16]; // hilbert order
+  macroblock_t *m[4]; // hilbert order
 } superblock_t;
 
 typedef ogg_int16_t    quant_table[64];
@@ -197,22 +207,10 @@
                                               pixel in recon buffer */
 
   int            CodedBlockIndex;
-  ogg_int32_t   *CodedBlockList;           /* A list of fragment indices for
-                                              coded blocks. */
+  fragment_t   **CodedBlockList;           
+
   MOTION_VECTOR *FragMVect;                /* Frag motion vectors */
 
-  ogg_uint32_t  *FragTokenCounts;          /* Number of tokens per fragment */
-  ogg_uint32_t  (*TokenList)[128];         /* Fragment Token Pointers */
-
-  unsigned char *FragCoeffs;                /* # of coeffs decoded so far for
-                                               fragment */
-  unsigned char *FragCoefEOB;               /* Position of last non 0 coef
-                                                within QFragData */
-  ogg_int16_t  (*QFragData)[64];            /* Fragment Coefficients
-                                               Array Pointers */
-  CODING_MODE   *FragCodingMethod;          /* coding method for the
-                                               fragment */
-
   /***********************************************************************/
   /* Macro Block and SuperBlock Information */
   ogg_int32_t  (*BlockMap)[4][4];               /* super block + sub macro
@@ -347,17 +345,10 @@
   /* Coded flag arrays and counters for them */
   unsigned char    *PartiallyCodedFlags;
   unsigned char    *PartiallyCodedMbPatterns;
-  unsigned char    *UncodedMbFlags;
-
-  ogg_int16_t      *PredictedDC;
-
   ogg_uint32_t     *FragmentLastQ;     /* Array used to keep track of
                                           quality at which each
                                           fragment was last
                                           updated. */
-  unsigned char    *FragTokens;
-  ogg_uint32_t     *FragTokenCounts;   /* Number of tokens per fragment */
-
   ogg_uint32_t     *RunHuffIndices;
   ogg_uint32_t     *ModeList;
   MOTION_VECTOR    *MVList;
@@ -372,7 +363,6 @@
   /*********************************************************************/
 
   ogg_uint32_t      RunLength;
-  unsigned char     MBCodingMode; 
 
   ogg_int32_t       MVPixelOffsetY[MAX_SEARCH_SITES];
   ogg_uint32_t      InterTripOutThresh;
@@ -388,10 +378,6 @@
   signed char       HalfPixelYOffset[9];    /* Half pixel MV offsets for Y */
 
   MOTION_VECTOR     MVector;
-  ogg_int16_t      *DCT_codes; /* Buffer that stores the result of
-                                  Forward DCT */
-  ogg_int16_t      *DCTDataBuffer; /* Input data buffer for Forward DCT */
-
   /* instances (used for reconstructing buffers and to hold tokens etc.) */
   PB_INSTANCE       pb;   /* playback */
 
@@ -438,7 +424,7 @@
                       ogg_int16_t * quantized_list);
 extern void fdct_short ( ogg_int16_t * InputData, ogg_int16_t * OutputData );
 extern ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi,
-                                       ogg_int32_t FragIndex);
+				       fragment_t *fp);
 extern void TransformQuantizeBlock (CP_INSTANCE *cpi, fragment_t *fp, ogg_int32_t FragIndex,
                                     ogg_uint32_t PixelsPerLine ) ;
 extern void InitFrameDetails(CP_INSTANCE *cpi);
@@ -483,9 +469,7 @@
                                                ogg_uint32_t PixelsPerLine,
                                                MOTION_VECTOR *MV ) ;
 extern void EncodeData(CP_INSTANCE *cpi);
-extern ogg_uint32_t PickIntra( CP_INSTANCE *cpi,
-                               ogg_uint32_t SBRows,
-                               ogg_uint32_t SBCols);
+extern ogg_uint32_t PickIntra( CP_INSTANCE *cpi );
 extern ogg_uint32_t PickModes(CP_INSTANCE *cpi,
                               ogg_uint32_t SBRows,
                               ogg_uint32_t SBCols,

Modified: branches/theora-thusnelda/lib/enc/dct_decode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-27 13:40:03 UTC (rev 14237)
@@ -36,16 +36,16 @@
   }
 }
 
-static void ExpandBlock ( CP_INSTANCE *cpi, ogg_int32_t FragmentNumber){
+static void ExpandBlock ( CP_INSTANCE *cpi, fragment_t *fp, ogg_int32_t FragmentNumber){
   PB_INSTANCE   *pbi = &cpi->pb;
   ogg_uint32_t   ReconPixelsPerLine; /* Pixels per line */
   ogg_int32_t    ReconPixelIndex;    /* Offset for block into a
                                         reconstruction buffer */
   ogg_int16_t    reconstruct[64];
   ogg_int16_t  *quantizers;
-  ogg_int16_t   *data = &pbi->QFragData[FragmentNumber][0];
+  ogg_int16_t   *data = fp->dct;
 
-  int            mode = pbi->FragCodingMethod[FragmentNumber];
+  int            mode = fp->mode;
   int            qi = cpi->BaseQ; // temporary 
 
   /* Select the appropriate inverse Q matrix and line stride */
@@ -80,7 +80,7 @@
 #endif
 
   /* Invert quantisation and DCT to get pixel data. */
-  switch(pbi->FragCoefEOB[FragmentNumber]){
+  switch(fp->nonzero){
   case 0:case 1:
     IDct1( data, quantizers, reconstruct );
     break;
@@ -680,7 +680,7 @@
 
   /* Inverse DCT and reconstitute buffer in thisframe */
   for(i=0;i<pbi->UnitFragments;i++)
-    ExpandBlock( cpi, i );
+    ExpandBlock( cpi, cpi->frag[0]+i, i );
 
   /* Copy the current reconstruction back to the last frame recon buffer. */
   if(pbi->CodedBlockIndex > (ogg_int32_t) (pbi->UnitFragments >> 1)){

Modified: branches/theora-thusnelda/lib/enc/dct_encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-27 13:40:03 UTC (rev 14237)
@@ -24,7 +24,7 @@
 static int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
 
 static unsigned char TokenizeDctValue (ogg_int16_t DataValue,
-                                       ogg_uint32_t * TokenListPtr ){
+                                       ogg_uint32_t *TokenListPtr ){
   int AbsDataVal = abs(DataValue);
   int neg = (DataValue<0);
   /* Values are tokenised as category value and a number of additional
@@ -95,7 +95,7 @@
 
 static unsigned char TokenizeDctRunValue (unsigned char RunLength,
                                           ogg_int16_t DataValue,
-                                          ogg_uint32_t * TokenListPtr ){
+                                          ogg_uint32_t *TokenListPtr ){
   unsigned char tokens_added = 0;
   ogg_uint32_t AbsDataVal = abs( (ogg_int32_t)DataValue );
 
@@ -157,15 +157,15 @@
   return tokens_added;
 }
 
-static unsigned char TokenizeDctBlock (ogg_int16_t DC,
-				       ogg_int16_t * RawData,
-                                       ogg_uint32_t * TokenListPtr ) {
+static unsigned char TokenizeDctBlock (fragment_t *fp){
+  ogg_int16_t DC = fp->pred_dc;
+  ogg_int16_t *RawData = fp->dct;
+  ogg_uint32_t *TokenListPtr = fp->token_list;
   ogg_uint32_t i;
   unsigned char  run_count;
   unsigned char  token_count = 0;     /* Number of tokens crated. */
   ogg_uint32_t AbsData;
-
-
+  
   /* Tokenize the block */
   for( i = 0; i < BLOCK_SIZE; i++ ){
     ogg_int16_t val = (i ? RawData[i] : DC);
@@ -227,15 +227,11 @@
 }
 
 ogg_uint32_t DPCMTokenizeBlock (CP_INSTANCE *cpi,
-                                ogg_int32_t FragIndex){
-  int token_count;
-
+				fragment_t *fp){
   /* Tokenise the dct data. */
-  token_count = TokenizeDctBlock( cpi->PredictedDC[FragIndex],
-				  cpi->pb.QFragData[FragIndex],
-                                  cpi->pb.TokenList[FragIndex] );
 
-  cpi->FragTokenCounts[FragIndex] = token_count;
+  int token_count = TokenizeDctBlock(fp);  
+  fp->tokens_coded = token_count;
   cpi->TotTokenCount += token_count;
 
   /* Return number of pixels coded (i.e. 8x8). */
@@ -364,27 +360,24 @@
 }
 
 void TransformQuantizeBlock (CP_INSTANCE *cpi, 
-			     fragment_t *frag,
+			     fragment_t *fp,
 			     ogg_int32_t FragIndex,
                              ogg_uint32_t PixelsPerLine) {
-  unsigned char *FiltPtr;     /* Pointers to srf filtered pixels */
-  ogg_int16_t   *DctInputPtr; /* Pointer into buffer containing input to DCT */
-  int LeftEdge;               /* Flag if block at left edge of component */
+  unsigned char *FiltPtr = &cpi->yuvptr[cpi->pb.pixel_index_table[FragIndex]];
+  int qi = cpi->BaseQ; // temporary
+  int inter = (fp->mode != CODE_INTRA);
+  int plane = (fp < cpi->frag[1] ? 0 : (fp < cpi->frag[2] ? 1 : 2)); 
+  ogg_int32_t *q = cpi->pb.iquant_tables[inter][plane][qi];
+  ogg_int16_t DCTInput[64];
+  ogg_int16_t DCTOutput[64];
   ogg_uint32_t  ReconPixelsPerLine; /* Line length for recon buffers. */
 
-  unsigned char   *ReconPtr1;   /* DCT reconstructed image pointers */
   ogg_int32_t   MvDivisor;      /* Defines MV resolution (2 = 1/2
                                    pixel for Y or 4 = 1/4 for UV) */
-  int qi = cpi->BaseQ;
-  ogg_int32_t     *q;
-  int mode;
+  unsigned char   *ReconPtr1 = &cpi->pb.ThisFrameRecon[cpi->pb.recon_pixel_index_table[FragIndex]];
 
-  DctInputPtr   = cpi->DCTDataBuffer;
-
-  ReconPtr1 = &cpi->pb.ThisFrameRecon[cpi->pb.recon_pixel_index_table[FragIndex]];
-
   /* Set plane specific values */
-  if (FragIndex < (ogg_int32_t)cpi->pb.YPlaneFragments){
+  if (plane == 0){
     ReconPixelsPerLine = cpi->pb.YStride;
     MvDivisor = 2;                  /* 1/2 pixel accuracy in Y */
   }else{
@@ -392,62 +385,24 @@
     MvDivisor = 4;                  /* UV planes at 1/2 resolution of Y */
   }
 
-  /* adjusted / filtered pointers */
-  FiltPtr = &cpi->yuvptr[cpi->pb.pixel_index_table[FragIndex]];
-
-  if ( cpi->pb.FrameType == KEY_FRAME ) {
-    /* Key frame so code block in INTRA mode. */
-    mode = CODE_INTRA;
-  }else{
-    /* Get Motion vector and mode for this block. */
-    mode = cpi->pb.FragCodingMethod[FragIndex];
-  }
-
-  /* Selection of Quantiser matrix and set other plane related values. */
-  if ( FragIndex < (ogg_int32_t)cpi->pb.YPlaneFragments ){
-    LeftEdge = !(FragIndex%cpi->pb.HFragments);
-
-    /* Select the appropriate Y quantiser matrix */
-    if ( mode == CODE_INTRA )
-      q=cpi->pb.iquant_tables[0][0][qi];
-    else
-      q=cpi->pb.iquant_tables[1][0][qi];
-  } else {
-    LeftEdge = !((FragIndex-cpi->pb.YPlaneFragments)%(cpi->pb.HFragments>>1));
-	
-    if(FragIndex < (ogg_int32_t)cpi->pb.YPlaneFragments + (ogg_int32_t)cpi->pb.UVPlaneFragments) {
-      /* U plane */
-      if ( mode == CODE_INTRA )
-	q=cpi->pb.iquant_tables[0][1][qi];
-      else
-	q=cpi->pb.iquant_tables[1][1][qi];
-    } else {
-      /* V plane */
-      if ( mode == CODE_INTRA )
-	q=cpi->pb.iquant_tables[0][2][qi];
-      else
-	q=cpi->pb.iquant_tables[1][2][qi];
-    }
-  }
-
   /* produces the appropriate motion compensation block, applies it to
      the reconstruction buffer, and proces a difference block for
      forward DCT */
-  BlockUpdateDifference(cpi, FiltPtr, DctInputPtr, ReconPtr1,
+  BlockUpdateDifference(cpi, FiltPtr, DCTInput, ReconPtr1,
 			MvDivisor, FragIndex, PixelsPerLine,
-			ReconPixelsPerLine, mode);
+			ReconPixelsPerLine, fp->mode);
   
   /* Proceed to encode the data into the encode buffer if the encoder
      is enabled. */
   /* Perform a 2D DCT transform on the data. */
-  dsp_fdct_short(cpi->dsp, cpi->DCTDataBuffer, cpi->DCT_codes );
+  dsp_fdct_short(cpi->dsp, DCTInput, DCTOutput);
 
   /* Quantize that transform data. */
-  quantize ( &cpi->pb, q, cpi->DCT_codes, cpi->pb.QFragData[FragIndex] );
+  quantize ( &cpi->pb, q, DCTOutput, fp->dct );
 
-  if ( (mode == CODE_INTER_NO_MV) &&
-       ( AllZeroDctData(cpi->pb.QFragData[FragIndex]) ) ) {
-    frag->coded = 0;
+  if ( (fp->mode == CODE_INTER_NO_MV) &&
+       ( AllZeroDctData(fp->dct) ) ) {
+    fp->coded = 0;
   }
 
 }

Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/encode.c	2007-11-27 13:40:03 UTC (rev 14237)
@@ -21,8 +21,8 @@
 #include "encoder_lookup.h"
 #include "block_inline.h"
 
-static void PredictDC(CP_INSTANCE *cpi, ogg_int16_t *predicted){
-  ogg_int32_t   i,j;
+static void PredictDC(CP_INSTANCE *cpi){
+  ogg_int32_t plane;
   int k,m,n;
 
   /* value left value up-left, value up, value up-right, missing
@@ -41,78 +41,47 @@
   /* 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++) {
-    fragment_t *fp;
+  for ( plane = 0; plane < 3 ; plane++) {
 
-    /* pick which fragments based on Y, U, V */
-    switch(j){
-    case 0: /* y */
-      fp = cpi->frag[0];
-      FromFragment = 0;
-      ToFragment = cpi->pb.YPlaneFragments;
-      FragsAcross = cpi->pb.HFragments;
-      FragsDown = cpi->pb.VFragments;
-      break;
-    case 1: /* u */
-      fp = cpi->frag[1];
-      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:
-      fp = cpi->frag[2];
-      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;
-    }
+    fragment_t *fp = cpi->frag[plane];
 
     /* initialize our array of last used DC Components */
     for(k=0;k<3;k++)Last[k]=0;
 
-    i=FromFragment;
     fn[0]=1;
-    fn[1]=FragsAcross+1;
-    fn[2]=FragsAcross;
-    fn[3]=FragsAcross-1;
+    fn[1]=cpi->frag_h[plane]+1;
+    fn[2]=cpi->frag_h[plane];
+    fn[3]=cpi->frag_h[plane]-1;
     
 
     /* do prediction on all of Y, U or V */
-    for ( m = 0 ; m < FragsDown ; m++) {
-      for ( n = 0 ; n < FragsAcross ; n++, i++, fp++) {
-        predicted[i] = cpi->pb.QFragData[i][0];
+    for ( m = 0 ; m < cpi->frag_v[plane] ; m++) {
+      for ( n = 0 ; n < cpi->frag_h[plane] ; n++, fp++) {
+        fp->pred_dc = fp->dct[0];
 
         /* only do 2 prediction if fragment coded and on non intra or
            if all fragments are intra */
-        if( fp->coded || cpi->pb.FrameType == KEY_FRAME ) {
+        if( fp->coded ) {
           /* Type of Fragment */
 
-          WhichFrame = Mode2Frame[cpi->pb.FragCodingMethod[i]];
+          WhichFrame = Mode2Frame[fp->mode];
 
           /* Check Borderline Cases */
-          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == FragsAcross) << 2);
+          WhichCase = (n==0) + ((m==0) << 1) + ((n+1 == cpi->frag_h[plane]) << 2);
 
           /* 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;
+            int pflag = 1<<k;
             if((bc_mask[WhichCase]&pflag)){
-	      fragment_t *fnp=fp - fn[k];
-	      
+	      fragment_t *fnp=fp - fn[k];	      
 	      if(fnp->coded &&
-		 (Mode2Frame[cpi->pb.FragCodingMethod[i-fn[k]]] == WhichFrame)){
-		v[pcount]=cpi->pb.QFragData[i-fn[k]][0];
+		 (Mode2Frame[fnp->mode] == WhichFrame)){
+		v[pcount]=fnp->dct[0];
 		wpc|=pflag;
 		pcount++;
 	      }
@@ -122,7 +91,7 @@
           if(wpc==0) {
 
             /* fall back to the last coded fragment */
-            predicted[i] -= Last[WhichFrame];
+            fp->pred_dc -= Last[WhichFrame];
 
           } else {
 
@@ -152,13 +121,13 @@
               }
             }
 
-            predicted[i] -= DC;
+            fp->pred_dc -= DC;
           }
 
           /* Save the last fragment coded for whatever frame we are
              predicting from */
 
-          Last[WhichFrame] = cpi->pb.QFragData[i][0];
+          Last[WhichFrame] = fp->dct[0];
 
         }
       }
@@ -186,7 +155,8 @@
     if(plane>1)SBi+=cpi->super_n[1];
 
     for ( MB=0; MB<4; MB++ ) {
-      int MBCodedFlag = 0;
+      int coded = 0;
+      int mode = 0;
 
       for ( B=0; B<4; B++, frag++ ) {
 	fragment_t *fp = sp->f[frag];
@@ -203,12 +173,11 @@
 	     assosciated MB as coded. */
 	  if ( fp->coded ) {
 	    /* Create linear list of coded block indices */
-	    cpi->pb.CodedBlockList[cpi->pb.CodedBlockIndex] = FragIndex;
-	    cpi->pb.CodedBlockIndex++;
+	    cpi->pb.CodedBlockList[cpi->pb.CodedBlockIndex++] = fp;
 	    
 	    /* MB is still coded */
-	    MBCodedFlag = 1;
-	    cpi->MBCodingMode = cpi->pb.FragCodingMethod[FragIndex];
+	    coded = 1;
+	    mode = fp->mode;
 	    
 	  }
 	}
@@ -216,10 +185,9 @@
      
       /* If the MB is marked as coded and we are in the Y plane then */
       /* the mode list needs to be updated. */
-      if ( MBCodedFlag && (plane == 0) ){
+      if ( coded && plane == 0 ){
 	/* Make a note of the selected mode in the mode list */
-	cpi->ModeList[cpi->ModeListCount] = cpi->MBCodingMode;
-	cpi->ModeListCount++;
+	cpi->ModeList[cpi->ModeListCount++] = mode;
       }
     }  
   }
@@ -656,31 +624,31 @@
   return 1;
 }
 
-static void PackToken ( CP_INSTANCE *cpi, ogg_int32_t FragmentNumber,
-                 ogg_uint32_t HuffIndex ) {
-  ogg_uint32_t Token =
-    cpi->pb.TokenList[FragmentNumber][cpi->FragTokens[FragmentNumber]];
-  ogg_uint32_t ExtraBitsToken =
-    cpi->pb.TokenList[FragmentNumber][cpi->FragTokens[FragmentNumber] + 1];
+static void PackToken ( CP_INSTANCE *cpi, 
+			fragment_t *fp,
+			ogg_uint32_t HuffIndex ) {
+  ogg_uint32_t Token = fp->token_list[fp->tokens_packed];
+  ogg_uint32_t ExtraBitsToken = fp->token_list[fp->tokens_packed+1];
   ogg_uint32_t OneOrTwo;
   ogg_uint32_t OneOrZero;
 
   /* Update the record of what coefficient we have got up to for this
      block and unpack the encoded token back into the quantised data
      array. */
-  cpi->pb.FragCoeffs[FragmentNumber] += TokenCoeffs ( Token, ExtraBitsToken );
+  fp->coeffs_packed += TokenCoeffs ( Token, ExtraBitsToken );
 
   /* Update record of tokens coded and where we are in this fragment. */
   /* Is there an extra bits token */
-  OneOrTwo= 1 + ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 );
+  OneOrTwo = 1 + ( cpi->pb.ExtraBitLengths_VP3x[Token] > 0 );
+
   /* Advance to the next real token. */
-  cpi->FragTokens[FragmentNumber] += (unsigned char)OneOrTwo;
+  fp->tokens_packed += (unsigned char)OneOrTwo;
 
   /* Update the counts of tokens coded */
   cpi->TokensCoded += OneOrTwo;
   cpi->TokensToBeCoded -= OneOrTwo;
 
-  OneOrZero = ( FragmentNumber < (ogg_int32_t)cpi->pb.YPlaneFragments );
+  OneOrZero = ( fp < cpi->frag[1] );
 
   if ( Token == DCT_EOB_TOKEN ) {
     if ( cpi->RunLength == 0 ) {
@@ -717,7 +685,6 @@
 static void PackCodedVideo (CP_INSTANCE *cpi) {
   ogg_int32_t i;
   ogg_int32_t EncodedCoeffs = 1;
-  ogg_int32_t FragIndex;
   ogg_uint32_t HuffIndex; /* Index to group of tables used to code a token */
 
   /* Reset the count of second order optimised tokens */
@@ -727,12 +694,12 @@
   cpi->TokensCoded = 0;
 
   /* Blank the various fragment data structures before we start. */
-  memset(cpi->pb.FragCoeffs, 0, cpi->pb.UnitFragments);
-  memset(cpi->FragTokens, 0, cpi->pb.UnitFragments);
+  for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
+    fragment_t *fp = cpi->pb.CodedBlockList[i];
+    fp->coeffs_packed = 0;
+    fp->tokens_packed = 0;
+  }
 
-  /* Clear down the QFragData structure for all coded blocks. */
-  //ClearDownQFragData(&cpi->pb);
-
   /* The tree is not needed (implicit) for key frames */
   if ( cpi->pb.FrameType != KEY_FRAME ){
     /* Pack the quad tree fragment mapping. */
@@ -750,13 +717,11 @@
   /* Optimise the DC tokens */
   for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
     /* Get the linear index for the current fragment. */
-    FragIndex = cpi->pb.CodedBlockList[i];
-
-    cpi->pb.FragCoefEOB[FragIndex]=(unsigned char)EncodedCoeffs;
-    PackToken(cpi, FragIndex, DC_HUFF_OFFSET );
-
+    fragment_t *fp = cpi->pb.CodedBlockList[i];
+    fp->nonzero = EncodedCoeffs;
+    PackToken(cpi, fp, DC_HUFF_OFFSET );
   }
-
+  
   /* Pack any outstanding EOB tokens */
   PackEOBRun(cpi);
 
@@ -781,14 +746,14 @@
     /* Repeatedly scan through the list of blocks. */
     for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
       /* Get the linear index for the current fragment. */
-      FragIndex = cpi->pb.CodedBlockList[i];
+      fragment_t *fp = cpi->pb.CodedBlockList[i];
 
       /* Should we code a token for this block on this pass. */
-      if ( cpi->FragTokens[FragIndex] < cpi->FragTokenCounts[FragIndex]
-           && cpi->pb.FragCoeffs[FragIndex] <= EncodedCoeffs ) {
+      if ( fp->tokens_packed < fp->tokens_coded &&
+           fp->coeffs_packed <= EncodedCoeffs ) {
         /* Bit pack and a token for this block */
-        cpi->pb.FragCoefEOB[FragIndex]=(unsigned char)EncodedCoeffs;
-        PackToken( cpi, FragIndex, HuffIndex );
+        fp->nonzero = EncodedCoeffs;
+        PackToken( cpi, fp, HuffIndex );
       }
     }
 
@@ -828,7 +793,7 @@
   CodePlane(cpi, 1, cpi->info.width>>1 );
   CodePlane(cpi, 2, cpi->info.width>>1 );
   
-  PredictDC(cpi, cpi->PredictedDC);
+  PredictDC(cpi);
 
 #ifdef _TH_DEBUG_
  {
@@ -854,54 +819,12 @@
   dsp_restore_fpu (cpi->dsp);
 }
 
-ogg_uint32_t PickIntra( CP_INSTANCE *cpi,
-                        ogg_uint32_t SBRows,
-                        ogg_uint32_t SBCols){
+ogg_uint32_t PickIntra( CP_INSTANCE *cpi ){
 
-  ogg_int32_t   FragIndex;  /* Fragment number */
-  ogg_uint32_t  MB, B;      /* Macro-Block, Block indices */
-  ogg_uint32_t  SBrow;      /* Super-Block row number */
-  ogg_uint32_t  SBcol;      /* Super-Block row number */
-  ogg_uint32_t  SB=0;       /* Super-Block index, initialised to first of
-                               this component */
-  ogg_uint32_t UVRow;
-  ogg_uint32_t UVColumn;
-  ogg_uint32_t UVFragOffset;
-
-  /* decide what block type and motion vectors to use on all of the frames */
-  for ( SBrow=0; SBrow<SBRows; SBrow++ ) {
-    for ( SBcol=0; SBcol<SBCols; SBcol++ ) {
-      /* Check its four Macro-Blocks */
-      for ( MB=0; MB<4; MB++ ) {
-        /* There may be MB's lying out of frame which must be
-           ignored. For these MB's Top left block will have a negative
-           Fragment Index. */
-        if ( QuadMapToMBTopLeft(cpi->pb.BlockMap,SB,MB) >= 0 ) {
-
-          cpi->MBCodingMode = CODE_INTRA;
-
-          /* Now actually code the blocks. */
-          for ( B=0; B<4; B++ ) {
-            FragIndex = QuadMapToIndex1( cpi->pb.BlockMap, SB, MB, B );
-            cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode;
-          }
-
-          /* Matching fragments in the U and V planes */
-          UVRow = (FragIndex / (cpi->pb.HFragments * 2));
-          UVColumn = (FragIndex % cpi->pb.HFragments) / 2;
-          UVFragOffset = (UVRow * (cpi->pb.HFragments / 2)) + UVColumn;
-
-          cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments + UVFragOffset] =
-            cpi->MBCodingMode;
-          cpi->pb.FragCodingMethod[cpi->pb.YPlaneFragments +
-                                  cpi->pb.UVPlaneFragments + UVFragOffset] =
-            cpi->MBCodingMode;
-	}
-      }
-
-      /* Next Super-Block */
-      SB++;
-    }
+  int i;
+  for(i=0;i<cpi->frag_total;i++){
+    cpi->frag[0][i].mode = CODE_INTRA;
+    cpi->frag[0][i].coded = 1;
   }
   return 0;
 }
@@ -914,27 +837,27 @@
 }
 
 static void SetFragMotionVectorAndMode(CP_INSTANCE *cpi,
-                                ogg_int32_t FragIndex,
-                                MOTION_VECTOR *ThisMotionVector){
+				       fragment_t *fp,
+				       MOTION_VECTOR *ThisMotionVector,
+				       int mode){
+  int FragIndex = fp - cpi->frag[0];
+
   /* Note the coding mode and vector for each block */
   cpi->pb.FragMVect[FragIndex].x = ThisMotionVector->x;
   cpi->pb.FragMVect[FragIndex].y = ThisMotionVector->y;
-  cpi->pb.FragCodingMethod[FragIndex] = cpi->MBCodingMode;
+  fp->mode = mode;
 }
 
 static void SetMBMotionVectorsAndMode(CP_INSTANCE *cpi,
-                               ogg_int32_t YFragIndex,
-                               ogg_int32_t UFragIndex,
-                               ogg_int32_t VFragIndex,
-                               MOTION_VECTOR *ThisMotionVector){
-  SetFragMotionVectorAndMode(cpi, YFragIndex, ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, YFragIndex + 1, ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments,
-                             ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1,
-                             ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, UFragIndex, ThisMotionVector);
-  SetFragMotionVectorAndMode(cpi, VFragIndex, ThisMotionVector);
+				      macroblock_t *mp,
+				      MOTION_VECTOR *ThisMotionVector,
+				      int mode){
+  SetFragMotionVectorAndMode(cpi, mp->y[0], ThisMotionVector,mode);
+  SetFragMotionVectorAndMode(cpi, mp->y[1], ThisMotionVector,mode);
+  SetFragMotionVectorAndMode(cpi, mp->y[2], ThisMotionVector,mode);
+  SetFragMotionVectorAndMode(cpi, mp->y[3], ThisMotionVector,mode);
+  SetFragMotionVectorAndMode(cpi, mp->u, ThisMotionVector,mode);
+  SetFragMotionVectorAndMode(cpi, mp->v, ThisMotionVector,mode);
 }
 
 ogg_uint32_t PickModes(CP_INSTANCE *cpi,
@@ -1045,14 +968,16 @@
   for ( SBrow=0; SBrow<SBRows; SBrow++ ) {
     for ( SBcol=0; SBcol<SBCols; SBcol++ ) {
       superblock_t *sp = &cpi->super[0][SBrow*SBCols+SBcol];
-      int fragi = 0;
       /* Check its four Macro-Blocks */
-      for ( MB=0; MB<4; MB++, fragi+=4 ) {
-	
+      for ( MB=0; MB<4; MB++ ) {
+	macroblock_t *mp = sp->m[MB];
+
+	if(!mp) continue;
+
         /* Is the current macro block coded (in part or in whole) */
         MBCodedFlag = 0;
         for ( B=0; B<4; B++ ) {
-	  fragment_t *fp = sp->f[fragi+B];
+	  fragment_t *fp = mp->y[B];
           if ( fp && fp->coded ){
 	    MBCodedFlag = 1;
 	    break;
@@ -1245,25 +1170,15 @@
 
         if ( (BestError > cpi->InterTripOutThresh) &&
              (10 * BestError > MBIntraError * 7 ) ) {
-          cpi->MBCodingMode = CODE_INTRA;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-                                    VFragIndex,&ZeroVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_INTRA);
         } else if ( BestError == MBInterError ) {
-          cpi->MBCodingMode = CODE_INTER_NO_MV;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-                                    VFragIndex,&ZeroVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_INTER_NO_MV);
         } else if ( BestError == MBGFError ) {
-          cpi->MBCodingMode = CODE_USING_GOLDEN;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-                                    VFragIndex,&ZeroVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_USING_GOLDEN);
         } else if ( BestError == MBLastInterError ) {
-          cpi->MBCodingMode = CODE_INTER_LAST_MV;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-                                    VFragIndex,&LastInterMVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&LastInterMVect,CODE_INTER_LAST_MV);
         } else if ( BestError == MBPriorLastInterError ) {
-          cpi->MBCodingMode = CODE_INTER_PRIOR_LAST;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-                                    VFragIndex,&PriorLastInterMVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&PriorLastInterMVect,CODE_INTER_PRIOR_LAST);
 
           /* Swap the prior and last MV cases over */
           TmpMVect.x = PriorLastInterMVect.x;
@@ -1275,9 +1190,7 @@
 
         } else if ( BestError == MBInterMVError ) {
 
-          cpi->MBCodingMode = CODE_INTER_PLUS_MV;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&InterMVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&InterMVect,CODE_INTER_PLUS_MV);
 
           /* Update Prior last mv with last mv */
           PriorLastInterMVect.x = LastInterMVect.x;
@@ -1291,9 +1204,7 @@
 
         } else if ( BestError == MBGF_MVError ) {
 
-          cpi->MBCodingMode = CODE_GOLDEN_MV;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&GFMVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&GFMVect,CODE_GOLDEN_MV);
 
           /* Note last inter GF MV for future use */
           LastGFMVect.x = GFMVect.x;
@@ -1301,7 +1212,6 @@
 
           AddMotionVector( cpi, &GFMVect);
         } else if ( BestError == MBInterFOURMVError ) {
-          cpi->MBCodingMode = CODE_INTER_FOURMV;
 
           /* Calculate the UV vectors as the average of the Y plane ones. */
           /* First .x component */
@@ -1322,14 +1232,12 @@
             FourMVect[4].y = (FourMVect[4].y - 2) / 4;
           FourMVect[5].y = FourMVect[4].y;
 
-          SetFragMotionVectorAndMode(cpi, YFragIndex, &FourMVect[0]);
-          SetFragMotionVectorAndMode(cpi, YFragIndex + 1, &FourMVect[1]);
-          SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments,
-                                     &FourMVect[2]);
-          SetFragMotionVectorAndMode(cpi, YFragIndex + cpi->pb.HFragments + 1,
-                                     &FourMVect[3]);
-          SetFragMotionVectorAndMode(cpi, UFragIndex, &FourMVect[4]);
-          SetFragMotionVectorAndMode(cpi, VFragIndex, &FourMVect[5]);
+          SetFragMotionVectorAndMode(cpi, mp->y[0], &FourMVect[0],CODE_INTER_FOURMV);
+          SetFragMotionVectorAndMode(cpi, mp->y[1], &FourMVect[1],CODE_INTER_FOURMV);
+          SetFragMotionVectorAndMode(cpi, mp->y[2], &FourMVect[2],CODE_INTER_FOURMV);
+          SetFragMotionVectorAndMode(cpi, mp->y[3], &FourMVect[3],CODE_INTER_FOURMV);
+          SetFragMotionVectorAndMode(cpi, mp->u, &FourMVect[4],CODE_INTER_FOURMV);
+          SetFragMotionVectorAndMode(cpi, mp->v, &FourMVect[5],CODE_INTER_FOURMV);
 
           /* Note the four MVs values for current macro-block. */
           AddMotionVector( cpi, &FourMVect[0]);
@@ -1347,9 +1255,7 @@
 
         } else {
 
-          cpi->MBCodingMode = CODE_INTRA;
-          SetMBMotionVectorsAndMode(cpi,YFragIndex,UFragIndex,
-				    VFragIndex,&ZeroVect);
+          SetMBMotionVectorsAndMode(cpi,mp,&ZeroVect,CODE_INTRA);
         }
 
 

Modified: branches/theora-thusnelda/lib/enc/encoder_toplevel.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-27 13:40:03 UTC (rev 14237)
@@ -32,40 +32,24 @@
 #endif
 
 static void EClearFragmentInfo(CP_INSTANCE * cpi){
-  if(cpi->FragTokens)
-    _ogg_free(cpi->FragTokens);
-  if(cpi->FragTokenCounts)
-    _ogg_free(cpi->FragTokenCounts);
   if(cpi->RunHuffIndices)
     _ogg_free(cpi->RunHuffIndices);
   if(cpi->ModeList)
     _ogg_free(cpi->ModeList);
   if(cpi->MVList)
     _ogg_free(cpi->MVList);
-  if(cpi->DCT_codes )
-    _ogg_free( cpi->DCT_codes );
-  if(cpi->DCTDataBuffer )
-    _ogg_free( cpi->DCTDataBuffer);
-  if(cpi->PredictedDC)
-    _ogg_free( cpi->PredictedDC);
   if(cpi->PartiallyCodedFlags)
     _ogg_free(cpi->PartiallyCodedFlags);
   if(cpi->PartiallyCodedMbPatterns)
     _ogg_free(cpi->PartiallyCodedMbPatterns);
-  if(cpi->UncodedMbFlags)
-    _ogg_free(cpi->UncodedMbFlags);
-
   if(cpi->BlockCodedFlags)
     _ogg_free(cpi->BlockCodedFlags);
 
-  cpi->FragTokens = 0;
-  cpi->FragTokenCounts = 0;
   cpi->RunHuffIndices = 0;
   cpi->ModeList = 0;
   cpi->MVList = 0;
-  cpi->DCT_codes = 0;
-  cpi->DCTDataBuffer = 0;
-  cpi->PredictedDC = 0;
+  cpi->PartiallyCodedFlags = 0;
+  cpi->PartiallyCodedMbPatterns = 0;
   cpi->BlockCodedFlags = 0;
 }
 
@@ -95,15 +79,6 @@
      SEGV handler, there's no reason to to check malloc return; it is
      a waste of code. */
 
-  cpi->FragTokens =
-    _ogg_malloc(cpi->pb.UnitFragments*
-                sizeof(*cpi->FragTokens));
-  cpi->PredictedDC =
-    _ogg_malloc(cpi->pb.UnitFragments*
-                sizeof(*cpi->PredictedDC));
-  cpi->FragTokenCounts =
-    _ogg_malloc(cpi->pb.UnitFragments*
-                sizeof(*cpi->FragTokenCounts));
   cpi->RunHuffIndices =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->RunHuffIndices));
@@ -116,21 +91,12 @@
   cpi->MVList =
     _ogg_malloc(cpi->pb.UnitFragments*
                 sizeof(*cpi->MVList));
-  cpi->DCT_codes =
-    _ogg_malloc(64*
-                sizeof(*cpi->DCT_codes));
-  cpi->DCTDataBuffer =
-    _ogg_malloc(64*
-                sizeof(*cpi->DCTDataBuffer));
   cpi->PartiallyCodedFlags =
     _ogg_malloc(cpi->pb.MacroBlocks*
                 sizeof(*cpi->PartiallyCodedFlags));
   cpi->PartiallyCodedMbPatterns =
     _ogg_malloc(cpi->pb.MacroBlocks*
                 sizeof(*cpi->PartiallyCodedMbPatterns));
-  cpi->UncodedMbFlags =
-    _ogg_malloc(cpi->pb.MacroBlocks*
-                sizeof(*cpi->UncodedMbFlags));
 
 }
 
@@ -229,30 +195,24 @@
   cpi->super[1] = cpi->super[0] + cpi->super_n[0];
   cpi->super[2] = cpi->super[1] + cpi->super_n[1];
 
-  /* fill in superblock fragment pointers */
-
-  /* complicated for one bad reason; superblock (and fragment) zero is
-     the bottom-left-most, but any uncoded 'extra' space needed to pad
-     out to multiples of 32 pixels hangs off the bottom of the image,
-     not the top. What exactly was VP3 thinking? */
-
+  /* fill in superblock fragment pointers; hilbert order */
   {
-    int row,col,frag;
-    int hilbertx[16] = {0,1,1,0,0,0,1,1,2,2,3,3,3,2,2,3};
-    int hilberty[16] = {0,0,1,1,2,3,3,2,2,3,3,2,1,1,0,0};
+    int row,col,frag,mb;
+    int fhilbertx[16] = {0,1,1,0,0,0,1,1,2,2,3,3,3,2,2,3};
+    int fhilberty[16] = {0,0,1,1,2,3,3,2,2,3,3,2,1,1,0,0};
+    int mhilbertx[4] = {0,0,1,1};
+    int mhilberty[4] = {0,1,1,0};
     int plane;
 
     for(plane=0;plane<3;plane++){
 
       for(row=0;row<cpi->super_v[plane];row++){
-	int baserow = row*4;
 	for(col=0;col<cpi->super_h[plane];col++){
-	  int basecol = col*4;
 	  int superindex = row*cpi->super_h[plane] + col;
 	  for(frag=0;frag<16;frag++){
 	    /* translate to fragment index */
-	    int frow = baserow + hilberty[frag];
-	    int fcol = basecol + hilbertx[frag];
+	    int frow = row*4 + fhilberty[frag];
+	    int fcol = col*4 + fhilbertx[frag];
 	    if(frow<cpi->frag_v[plane] && fcol<cpi->frag_h[plane]){
 	      int fragindex = frow*cpi->frag_h[plane] + fcol;
 	      cpi->super[plane][superindex].f[frag] = &cpi->frag[plane][fragindex];
@@ -261,7 +221,52 @@
 	}
       }
     }
+
+    for(row=0;row<cpi->super_v[0];row++){
+      for(col=0;col<cpi->super_h[0];col++){
+	int superindex = row*cpi->super_h[0] + col;
+	for(mb=0;mb<4;mb++){
+	  /* translate to macroblock index */
+	  int mrow = row*2 + mhilberty[mb];
+	  int mcol = col*2 + mhilbertx[mb];
+	  if(mrow<cpi->macro_v && mcol<cpi->macro_h){
+	    int macroindex = mrow*cpi->macro_h + mcol;
+	    cpi->super[0][superindex].m[mb] = &cpi->macro[macroindex];
+	  }
+	}
+      }
+    }
   }
+
+  /* fill in macroblock fragment pointers; raster (MV coding) order */
+  {
+    int row,col,frag;
+    int scanx[4] = {0,1,0,1};
+    int scany[4] = {0,1,1,0};
+
+    for(row=0;row<cpi->macro_v;row++){
+      int baserow = row*2;
+      for(col=0;col<cpi->macro_h;col++){
+	int basecol = col*2;
+	int macroindex = row*cpi->macro_h + col;
+	for(frag=0;frag<4;frag++){
+	  /* translate to fragment index */
+	  int frow = baserow + scany[frag];
+	  int fcol = basecol + scanx[frag];
+	  if(frow<cpi->frag_v[0] && fcol<cpi->frag_h[0]){
+	    int fragindex = frow*cpi->frag_h[0] + fcol;
+	    cpi->macro[macroindex].y[frag] = &cpi->frag[0][fragindex];
+	  }
+	}
+
+	if(row<cpi->frag_v[1] && col<cpi->frag_h[1])
+	  cpi->macro[macroindex].u = &cpi->frag[1][macroindex];
+	if(row<cpi->frag_v[2] && col<cpi->frag_h[2])
+	  cpi->macro[macroindex].v = &cpi->frag[2][macroindex];
+
+      }
+    }
+  }
 }
 
 static void SetupKeyFrame(CP_INSTANCE *cpi) {
@@ -317,7 +322,7 @@
   SetupKeyFrame(cpi);
 
   /* Compress and output the frist frame. */
-  PickIntra( cpi, cpi->pb.YSBRows, cpi->pb.YSBCols);
+  PickIntra(cpi);
   UpdateFrame(cpi);
 
 }
@@ -330,7 +335,7 @@
   SetupKeyFrame(cpi);
 
   /* Compress and output the frist frame. */
-  PickIntra( cpi, cpi->pb.YSBRows, cpi->pb.YSBCols);
+  PickIntra(cpi);
   UpdateFrame(cpi);
 
 }
@@ -341,7 +346,7 @@
 
   /* Clear down the macro block level mode and MV arrays. */
   for ( i = 0; i < cpi->pb.UnitFragments; i++ ) {
-    cpi->pb.FragCodingMethod[i] = CODE_INTER_NO_MV;  /* Default coding mode */
+    cpi->frag[0][i].mode = CODE_INTER_NO_MV;  /* Default coding mode */
     cpi->pb.FragMVect[i].x = 0;
     cpi->pb.FragMVect[i].y = 0;
   }

Modified: branches/theora-thusnelda/lib/enc/frinit.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frinit.c	2007-11-27 03:26:05 UTC (rev 14236)
+++ branches/theora-thusnelda/lib/enc/frinit.c	2007-11-27 13:40:03 UTC (rev 14237)
@@ -89,12 +89,8 @@
   /* free prior allocs if present */
   if(pbi->pixel_index_table) _ogg_free(pbi->pixel_index_table);
   if(pbi->recon_pixel_index_table) _ogg_free(pbi->recon_pixel_index_table);
-  if(pbi->FragTokenCounts) _ogg_free(pbi->FragTokenCounts);
   if(pbi->CodedBlockList) _ogg_free(pbi->CodedBlockList);
   if(pbi->FragMVect) _ogg_free(pbi->FragMVect);
-  if(pbi->FragCoeffs) _ogg_free(pbi->FragCoeffs);
-  if(pbi->FragCoefEOB) _ogg_free(pbi->FragCoefEOB);
-  if(pbi->QFragData) _ogg_free(pbi->QFragData);
 #ifdef _TH_DEBUG_
   if(pbi->QFragTIME) _ogg_free(pbi->QFragTIME);
   if(pbi->QFragFREQ) _ogg_free(pbi->QFragFREQ);
@@ -103,9 +99,6 @@
   pbi->QFragFREQ = 0;
   pbi->QFragQUAN = 0;
 #endif
-  if(pbi->TokenList) _ogg_free(pbi->TokenList);
-  if(pbi->FragCodingMethod) _ogg_free(pbi->FragCodingMethod);
-
   if(pbi->BlockMap) _ogg_free(pbi->BlockMap);
 
   if(pbi->SBCodedFlags) _ogg_free(pbi->SBCodedFlags);
@@ -113,15 +106,9 @@
   if(pbi->MBFullyFlags) _ogg_free(pbi->MBFullyFlags);
   if(pbi->MBCodedFlags) _ogg_free(pbi->MBCodedFlags);
 
-  pbi->QFragData = 0;
-  pbi->TokenList = 0;
-  pbi->FragCoeffs = 0;
-  pbi->FragCoefEOB = 0;
   pbi->pixel_index_table = 0;
   pbi->recon_pixel_index_table = 0;
-  pbi->FragTokenCounts = 0;
   pbi->CodedBlockList = 0;
-  pbi->FragCodingMethod = 0;
   pbi->FragMVect = 0;
   pbi->MBCodedFlags = 0;
   pbi->MBFullyFlags = 0;
@@ -143,24 +130,12 @@
   pbi->recon_pixel_index_table =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->recon_pixel_index_table));
 
-  pbi->FragTokenCounts =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragTokenCounts));
-
   pbi->CodedBlockList =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->CodedBlockList));
 
   pbi->FragMVect =
     _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragMVect));
 
-  pbi->FragCoeffs =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCoeffs));
-
-  pbi->FragCoefEOB =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCoefEOB));
-
-  pbi->QFragData =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->QFragData));
-
 #ifdef _TH_DEBUG_
 
   pbi->QFragTIME =
@@ -174,12 +149,6 @@
 
 #endif
 
-  pbi->TokenList =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->TokenList));
-
-  pbi->FragCodingMethod =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->FragCodingMethod));
-
   /* Super Block Initialization */
   pbi->SBCodedFlags =
     _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->SBCodedFlags));



More information about the commits mailing list