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

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Nov 28 12:03:18 PST 2007


Author: xiphmont
Date: 2007-11-28 12:03:18 -0800 (Wed, 28 Nov 2007)
New Revision: 14246

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/frarray.c
   branches/theora-thusnelda/lib/enc/frinit.c
   branches/theora-thusnelda/lib/enc/mcomp.c
Log:
Eliminate global storage used for local encode in frarray.c
Remove more things from PB_INSTANCE



Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-28 20:03:18 UTC (rev 14246)
@@ -121,6 +121,16 @@
 
   ogg_uint32_t raw_index;
   ogg_uint32_t recon_index;
+
+#ifdef _TH_DEBUG_
+  ogg_int16_t QUAN[64];           /* Fragment Coefficients
+				     Array Pointers */
+  ogg_int16_t FREQ[64];            /* Fragment Coefficients
+				      Array Pointers */
+  ogg_int16_t TIME[64];            /* Fragment Coefficients
+				      Array Pointers */
+#endif
+
 } fragment_t;
 
 typedef struct macroblock {
@@ -145,55 +155,6 @@
 /** Decoder (Playback) instance -- installed in a theora_state */
 typedef struct PB_INSTANCE {
 
-
-  /***********************************************************************/
-  /* Frame Info */
-  unsigned char FrameType;
-
-  /**********************************************************************/
-  /* Frame Size & Index Information */
-
-  ogg_uint32_t  YPlaneSize;
-  ogg_uint32_t  UVPlaneSize;
-  ogg_uint32_t  VFragments;
-  ogg_uint32_t  HFragments;
-  ogg_uint32_t  UnitFragments;
-  ogg_uint32_t  YPlaneFragments;
-  ogg_uint32_t  UVPlaneFragments;
-
-  ogg_uint32_t  YSBRows;        /* Number of rows of SuperBlocks in a
-                                   Y frame */
-  ogg_uint32_t  YSBCols;        /* Number of cols of SuperBlocks in a
-                                   Y frame */
-  ogg_uint32_t  UVSBRows;       /* Number of rows of SuperBlocks in a
-                                   U or V frame */
-  ogg_uint32_t  UVSBCols;       /* Number of cols of SuperBlocks in a
-                                   U or V frame */
-  ogg_uint32_t SuperBlocks;
-  ogg_uint32_t YSuperBlocks;
-  ogg_uint32_t UVSuperBlocks;
-  ogg_uint32_t MacroBlocks;
-
-  
-  /**********************************************************************/
-  /* Frames  */
-  unsigned char *ThisFrameRecon;
-  unsigned char *GoldenFrame;
-  unsigned char *LastFrameRecon;
-
-  /**********************************************************************/
-  /* Fragment Information */
-  int            CodedBlockIndex;
-  fragment_t   **CodedBlockList;           
-
-  /***********************************************************************/
-  /* Coded flag arrays and counters for them */
-  unsigned char *SBCodedFlags;
-  unsigned char *SBFullyFlags;
-  unsigned char *MBCodedFlags;
-  unsigned char *MBFullyFlags;
-
-  /**********************************************************************/
   ogg_uint32_t   EOB_Run;
 
   ogg_int32_t    ReconPtr2Offset;       /* Offset for second reconstruction
@@ -218,15 +179,6 @@
 
   DspFunctions   dsp;  /* Selected functions for this platform */
 
-#ifdef _TH_DEBUG_
-  ogg_int16_t (*QFragQUAN)[64];           /* Fragment Coefficients
-                                               Array Pointers */
-  ogg_int16_t (*QFragFREQ)[64];            /* Fragment Coefficients
-                                               Array Pointers */
-  ogg_int16_t (*QFragTIME)[64];            /* Fragment Coefficients
-                                               Array Pointers */
-#endif
-
 } PB_INSTANCE;
 
 /* Encoder (Compressor) instance -- installed in a theora_state */
@@ -236,13 +188,13 @@
      is the only assumption that library makes about our internal format.*/
   oc_state_dispatch_vtbl dispatch_vtbl;
 
-  theora_info     info;
+  theora_info      info;
   unsigned char   *yuvptr;
   
   /* flag to indicate if the headers already have been written */
-  int             HeadersWritten;
+  int              HeadersWritten;
   /* how far do we shift the granulepos to seperate out P frame counts? */
-  int             keyframe_granule_shift;
+  int              keyframe_granule_shift;
 
   /* Compressor Configuration */
   int              BaseQ;
@@ -311,25 +263,26 @@
   ogg_uint32_t      recon_offset[3];
 
   /* Coded flag arrays and counters for them */
-  unsigned char    *PartiallyCodedFlags;
-  unsigned char    *PartiallyCodedMbPatterns;
-  ogg_uint32_t     *FragmentLastQ;     /* Array used to keep track of
-                                          quality at which each
-                                          fragment was last
-                                          updated. */
+
   ogg_uint32_t     *RunHuffIndices;
-  ogg_uint32_t     *ModeList;
 
   unsigned char    *BlockCodedFlags;
 
+  mv_t             *MVList;
   ogg_uint32_t      MvListCount;
+  ogg_uint32_t     *ModeList;
   ogg_uint32_t      ModeListCount;
 
-
   unsigned char    *DataOutputBuffer;
+
+  unsigned char     FrameType;
+  unsigned char    *ThisFrameRecon;
+  unsigned char    *GoldenFrame;
+  unsigned char    *LastFrameRecon;
+  int               CodedBlockIndex;
+  fragment_t      **CodedBlockList;           
+
   /*********************************************************************/
-  mv_t             *MVList;
-  ogg_uint32_t      MVListCount;
 
   ogg_uint32_t      RunLength;
 

Modified: branches/theora-thusnelda/lib/enc/dct_decode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -80,7 +80,7 @@
 #endif
 
   /* Convert fragment number to a pixel offset in a reconstruction buffer. */
-  dsp_recon8x8 (pbi->dsp, &pbi->ThisFrameRecon[fp->recon_index],
+  dsp_recon8x8 (pbi->dsp, &cpi->ThisFrameRecon[fp->recon_index],
 		reconstruct, ReconPixelsPerLine);
 
 }
@@ -289,14 +289,14 @@
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !fp[1].coded ){
-        dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			fp[0].recon_index+6,
 			LineLength,BoundingValuePtr);
       }
 
       /* Bottom done if next row set */
       if( !fp[LineFragments].coded ){
-        dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		       fp[LineFragments].recon_index,
 		       LineLength, BoundingValuePtr);
       }
@@ -308,21 +308,21 @@
     for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++) {
       if( fp->coded){
         /* Filter Left edge always */
-        dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			fp[0].recon_index-2,
 			LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			  fp[0].recon_index+6,
 			  LineLength, BoundingValuePtr);
         }
 
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 			 fp[LineFragments].recon_index,
 			 LineLength, BoundingValuePtr);
         }
@@ -334,13 +334,13 @@
     /* Last Column */
     if(fp->coded){
       /* Filter Left edge always */
-      dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+      dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 		      fp[0].recon_index - 2 ,
 		      LineLength, BoundingValuePtr);
       
       /* Bottom done if next row set */
       if( !fp[LineFragments].coded ){
-        dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		       fp[LineFragments].recon_index,
 		       LineLength, BoundingValuePtr);
       }
@@ -358,21 +358,21 @@
          all fragments are intra */
       if( fp->coded){
         /* TopRow is always done */
-        dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		       fp[0].recon_index,
 		       LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			  fp[0].recon_index + 6,
 			  LineLength, BoundingValuePtr);
         }
 	
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 			 fp[LineFragments].recon_index,
 			 LineLength, BoundingValuePtr);
         }
@@ -384,26 +384,26 @@
       for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++){
         if( fp->coded){
           /* Filter Left edge always */
-          dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			  fp[0].recon_index - 2,
 			  LineLength, BoundingValuePtr);
 
           /* TopRow is always done */
-          dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 			 fp[0].recon_index,
 			 LineLength, BoundingValuePtr);
 	  
           /* Filter right hand border only if the block to the right
              is not coded */
           if ( !fp[1].coded ){
-            dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+            dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			    fp[0].recon_index + 6,
 			    LineLength, BoundingValuePtr);
           }
 
           /* Bottom done if next row set */
           if( !fp[LineFragments].coded ){
-            dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+            dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 			   fp[LineFragments].recon_index,
 			   LineLength, BoundingValuePtr);
           }
@@ -414,18 +414,18 @@
       /* Last Column */
       if(fp->coded){
         /* Filter Left edge always*/
-        dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			fp[0].recon_index - 2,
 			LineLength, BoundingValuePtr);
 
         /* TopRow is always done */
-        dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		       fp[0].recon_index,		       
 		       LineLength, BoundingValuePtr);
 	
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 			 fp[LineFragments].recon_index,
 			 LineLength, BoundingValuePtr);
         }
@@ -442,14 +442,14 @@
     if(fp->coded){
 
       /* TopRow is always done */
-      dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+      dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		     fp[0].recon_index,
 		     LineLength, BoundingValuePtr);
 
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !fp[1].coded ){
-        dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			fp[0].recon_index + 6,
 			LineLength, BoundingValuePtr);
       }
@@ -461,19 +461,19 @@
     for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++){
       if( fp->coded){
         /* Filter Left edge always */
-        dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			fp[0].recon_index - 2,
 			LineLength, BoundingValuePtr);
 	
         /* TopRow is always done */
-        dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+        dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		       fp[0].recon_index,
 		       LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+          dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 			  fp[0].recon_index + 6,
 			  LineLength, BoundingValuePtr);
         }
@@ -484,12 +484,12 @@
     /* Last Column */
     if( fp->coded){
       /* Filter Left edge always */
-      dsp_FilterHoriz(pbi->dsp,pbi->LastFrameRecon+
+      dsp_FilterHoriz(pbi->dsp,cpi->LastFrameRecon+
 		      fp[0].recon_index - 2,
 		      LineLength, BoundingValuePtr);
 
       /* TopRow is always done */
-      dsp_FilterVert(pbi->dsp,pbi->LastFrameRecon+
+      dsp_FilterVert(pbi->dsp,cpi->LastFrameRecon+
 		     fp[0].recon_index,
 		     LineLength, BoundingValuePtr);
       
@@ -504,17 +504,17 @@
   unsigned char *SwapReconBuffersTemp;
 
   /* Inverse DCT and reconstitute buffer in thisframe */
-  for(i=0;i<pbi->UnitFragments;i++)
+  for(i=0;i<cpi->frag_total;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)){
-    SwapReconBuffersTemp = pbi->ThisFrameRecon;
-    pbi->ThisFrameRecon = pbi->LastFrameRecon;
-    pbi->LastFrameRecon = SwapReconBuffersTemp;
-    CopyNotRecon( cpi, pbi->LastFrameRecon, pbi->ThisFrameRecon );
+  if(cpi->CodedBlockIndex > (ogg_int32_t) (cpi->frag_total >> 1)){
+    SwapReconBuffersTemp = cpi->ThisFrameRecon;
+    cpi->ThisFrameRecon = cpi->LastFrameRecon;
+    cpi->LastFrameRecon = SwapReconBuffersTemp;
+    CopyNotRecon( cpi, cpi->LastFrameRecon, cpi->ThisFrameRecon );
   }else{
-    CopyRecon( cpi, pbi->LastFrameRecon, pbi->ThisFrameRecon );
+    CopyRecon( cpi, cpi->LastFrameRecon, cpi->ThisFrameRecon );
   }
 
   /* Apply a loop filter to edge pixels of updated blocks */
@@ -599,7 +599,7 @@
 	    int l = cpi->frag[0][i].recon_index + j*stride;
 	    TH_DEBUG("\n   ");
 	    for(k=0;k<8;k++,l++)
-	      TH_DEBUG("%d ", pbi->LastFrameRecon[l]);
+	      TH_DEBUG("%d ", cpi->LastFrameRecon[l]);
 	  }
 	  TH_DEBUG(" }\n\n");
 	}
@@ -609,14 +609,14 @@
 #endif
   
   /* We may need to update the UMV border */
-  UpdateUMVBorder(cpi, pbi->LastFrameRecon);
+  UpdateUMVBorder(cpi, cpi->LastFrameRecon);
   
   /* Reconstruct the golden frame if necessary.
      For VFW codec only on key frames */
-  if ( pbi->FrameType == KEY_FRAME ){
-    CopyRecon( cpi, pbi->GoldenFrame, pbi->LastFrameRecon );
+  if ( cpi->FrameType == KEY_FRAME ){
+    CopyRecon( cpi, cpi->GoldenFrame, cpi->LastFrameRecon );
     /* We may need to update the UMV border */
-    UpdateUMVBorder(cpi, pbi->GoldenFrame);
+    UpdateUMVBorder(cpi, cpi->GoldenFrame);
   }
 }
 

Modified: branches/theora-thusnelda/lib/enc/dct_encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -312,9 +312,9 @@
     }
     
     if ( mode==CODE_GOLDEN_MV ) {
-      ReconPtr1 = &cpi->pb.GoldenFrame[fp->recon_index];
+      ReconPtr1 = &cpi->GoldenFrame[fp->recon_index];
     } else {
-      ReconPtr1 = &cpi->pb.LastFrameRecon[fp->recon_index];
+      ReconPtr1 = &cpi->LastFrameRecon[fp->recon_index];
     }
     
     ReconPtr1 += MVOffset;
@@ -339,9 +339,9 @@
     if ( ( mode==CODE_INTER_NO_MV ) ||
 	 ( mode==CODE_USING_GOLDEN ) ) {
       if ( mode==CODE_INTER_NO_MV ) {
-	ReconPtr1 = &cpi->pb.LastFrameRecon[fp->recon_index];
+	ReconPtr1 = &cpi->LastFrameRecon[fp->recon_index];
       } else {
-	ReconPtr1 = &cpi->pb.GoldenFrame[fp->recon_index];
+	ReconPtr1 = &cpi->GoldenFrame[fp->recon_index];
       }
       
       dsp_sub8x8(cpi->dsp, FiltPtr, ReconPtr1, DctInputPtr,
@@ -367,7 +367,7 @@
   ogg_uint32_t ReconPixelsPerLine = cpi->recon_stride[plane];
   ogg_int32_t   MvDivisor;      /* Defines MV resolution (2 = 1/2
                                    pixel for Y or 4 = 1/4 for UV) */
-  unsigned char   *ReconPtr1 = &cpi->pb.ThisFrameRecon[fp->recon_index];
+  unsigned char   *ReconPtr1 = &cpi->ThisFrameRecon[fp->recon_index];
 
   /* Set plane specific values */
   if (plane == 0){

Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/encode.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -171,7 +171,7 @@
 	     assosciated MB as coded. */
 	  if ( fp->coded ) {
 	    /* Create linear list of coded block indices */
-	    cpi->pb.CodedBlockList[cpi->pb.CodedBlockIndex++] = fp;
+	    cpi->CodedBlockList[cpi->CodedBlockIndex++] = fp;
 	    
 	    /* MB is still coded */
 	    coded = 1;
@@ -692,20 +692,20 @@
   cpi->TokensCoded = 0;
 
   /* Blank the various fragment data structures before we start. */
-  for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
-    fragment_t *fp = cpi->pb.CodedBlockList[i];
+  for ( i = 0; i < cpi->CodedBlockIndex; i++ ) {
+    fragment_t *fp = cpi->CodedBlockList[i];
     fp->coeffs_packed = 0;
     fp->tokens_packed = 0;
   }
 
   /* The tree is not needed (implicit) for key frames */
-  if ( cpi->pb.FrameType != KEY_FRAME ){
+  if ( cpi->FrameType != KEY_FRAME ){
     /* Pack the quad tree fragment mapping. */
     PackAndWriteDFArray( cpi );
   }
 
   /* Mode and MV data not needed for key frames. */
-  if ( cpi->pb.FrameType != KEY_FRAME ){
+  if ( cpi->FrameType != KEY_FRAME ){
     /* Pack and code the mode list. */
     PackModes(cpi);
     /* Pack the motion vectors */
@@ -713,9 +713,9 @@
   }
 
   /* Optimise the DC tokens */
-  for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
+  for ( i = 0; i < cpi->CodedBlockIndex; i++ ) {
     /* Get the linear index for the current fragment. */
-    fragment_t *fp = cpi->pb.CodedBlockList[i];
+    fragment_t *fp = cpi->CodedBlockList[i];
     fp->nonzero = EncodedCoeffs;
     PackToken(cpi, fp, DC_HUFF_OFFSET );
   }
@@ -742,9 +742,9 @@
       HuffIndex = AC_HUFF_OFFSET + (AC_HUFF_CHOICES * 3);
 
     /* Repeatedly scan through the list of blocks. */
-    for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
+    for ( i = 0; i < cpi->CodedBlockIndex; i++ ) {
       /* Get the linear index for the current fragment. */
-      fragment_t *fp = cpi->pb.CodedBlockList[i];
+      fragment_t *fp = cpi->CodedBlockList[i];
 
       /* Should we code a token for this block on this pass. */
       if ( fp->tokens_packed < fp->tokens_coded &&
@@ -782,7 +782,7 @@
   /* Initialise the coded block indices variables. These allow
      subsequent linear access to the quad tree ordered list of coded
      blocks */
-  cpi->pb.CodedBlockIndex = 0;
+  cpi->CodedBlockIndex = 0;
 
   dsp_save_fpu (cpi->dsp);
 
@@ -796,7 +796,7 @@
 #ifdef _TH_DEBUG_
  {
    int j;
-   for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) {
+   for ( i = 0; i < cpi->CodedBlockIndex; i++ ) {
      fragment_t *fp = cpi->frag[0][i];
      for(j=0;j<64;j++)
        fp->QUAN[j] = fp->dct[j];
@@ -805,8 +805,8 @@
 #endif
 
   /* Pack DCT tokens */
-  for ( i = 0; i < cpi->pb.CodedBlockIndex; i++ ) 
-    DPCMTokenizeBlock ( cpi, cpi->pb.CodedBlockList[i] );
+  for ( i = 0; i < cpi->CodedBlockIndex; i++ ) 
+    DPCMTokenizeBlock ( cpi, cpi->CodedBlockList[i] );
 
   /* Bit pack the video data data */
   PackCodedVideo(cpi);
@@ -949,39 +949,32 @@
 
 
         /* Look at the intra coding error. */
-        MBIntraError = GetMBIntraError( cpi, 
-					mp,
-					PixelsPerLine );
+        MBIntraError = GetMBIntraError( cpi, mp, PixelsPerLine );
         BestError = (BestError > MBIntraError) ? MBIntraError : BestError;
 
         /* Get the golden frame error */
-        MBGFError = GetMBInterError( cpi, cpi->yuvptr,
-                                     cpi->pb.GoldenFrame, 
-				     mp,
-                                     0, 0, PixelsPerLine );
+        MBGFError = GetMBInterError( cpi, cpi->yuvptr, cpi->GoldenFrame, 
+				     mp, 0, 0, PixelsPerLine );
         BestError = (BestError > MBGFError) ? MBGFError : BestError;
 
         /* Calculate the 0,0 case. */
         MBInterError = GetMBInterError( cpi, cpi->yuvptr,
-                                        cpi->pb.LastFrameRecon,
-					mp,
-                                        0, 0, PixelsPerLine );
+                                        cpi->LastFrameRecon,
+					mp, 0, 0, PixelsPerLine );
         BestError = (BestError > MBInterError) ? MBInterError : BestError;
 
         /* Measure error for last MV */
         MBLastInterError =  GetMBInterError( cpi, cpi->yuvptr,
-                                             cpi->pb.LastFrameRecon,
-					     mp,
-                                             LastInterMVect.x,
+                                             cpi->LastFrameRecon,
+					     mp, LastInterMVect.x,
                                              LastInterMVect.y, PixelsPerLine );
         BestError = (BestError > MBLastInterError) ?
           MBLastInterError : BestError;
 
         /* Measure error for prior last MV */
         MBPriorLastInterError =  GetMBInterError( cpi, cpi->yuvptr,
-                                                  cpi->pb.LastFrameRecon,
-						  mp,
-                                                  PriorLastInterMVect.x,
+                                                  cpi->LastFrameRecon,
+						  mp, PriorLastInterMVect.x,
                                                   PriorLastInterMVect.y,
                                                   PixelsPerLine );
         BestError = (BestError > MBPriorLastInterError) ?
@@ -998,9 +991,8 @@
           /* Use a mix of heirachical and exhaustive searches for
              quick mode. */
           if ( cpi->info.quick_p ) {
-            MBInterMVError = GetMBMVInterError( cpi, cpi->pb.LastFrameRecon,
-						mp,
-						PixelsPerLine,
+            MBInterMVError = GetMBMVInterError( cpi, cpi->LastFrameRecon,
+						mp, PixelsPerLine,
                                                 cpi->MVPixelOffsetY,
                                                 &InterMVect );
 
@@ -1010,7 +1002,7 @@
                  (BestError > cpi->ExhaustiveSearchThresh) ) {
 
               MBInterMVExError =
-                GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+                GetMBMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
 					 mp,
                                          PixelsPerLine,
                                          &InterMVectEx );
@@ -1026,7 +1018,7 @@
           }else{
             /* Use an exhaustive search */
             MBInterMVError =
-              GetMBMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+              GetMBMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
 				       mp,
                                        PixelsPerLine,
                                        &InterMVect );
@@ -1048,14 +1040,14 @@
         GFMVect.y = 0;
         if ( BestError > cpi->MinImprovementForNewMV && cpi->MotionCompensation) {
           /* Do an MV search in the golden reference frame */
-          MBGF_MVError = GetMBMVInterError( cpi, cpi->pb.GoldenFrame,
+          MBGF_MVError = GetMBMVInterError( cpi, cpi->GoldenFrame,
 					    mp,
                                             PixelsPerLine,
                                             cpi->MVPixelOffsetY, &GFMVect );
 
           /* Measure error for last GFMV */
           LastMBGF_MVError =  GetMBInterError( cpi, cpi->yuvptr,
-                                               cpi->pb.GoldenFrame,
+                                               cpi->GoldenFrame,
 					       mp,
                                                LastGFMVect.x,
                                                LastGFMVect.y, PixelsPerLine );
@@ -1084,7 +1076,7 @@
         if ( BestError > cpi->FourMVThreshold && cpi->MotionCompensation) {
           /* Get the 4MV error. */
           MBInterFOURMVError =
-            GetFOURMVExhaustiveSearch( cpi, cpi->pb.LastFrameRecon,
+            GetFOURMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
 				       mp,
                                        PixelsPerLine, FourMVect );
 
@@ -1214,7 +1206,7 @@
   TH_DEBUG("\n>>>> beginning frame %ld\n\n",dframe);
 
   /* Output the frame type (base/key frame or inter frame) */
-  oggpackB_write( opb, cpi->pb.FrameType, 1 );
+  oggpackB_write( opb, cpi->FrameType, 1 );
   TH_DEBUG("frame type = video, %s\n",cpi->pb.FrameType?"predicted":"key");
   
   /* Write out details of the current value of Q... variable resolution. */
@@ -1224,7 +1216,7 @@
   oggpackB_write( opb, 0, 1 );
 
   /* If the frame was a base frame then write out the frame dimensions. */
-  if ( cpi->pb.FrameType == KEY_FRAME ) {
+  if ( cpi->FrameType == KEY_FRAME ) {
     /* all bits reserved! */
     oggpackB_write( opb, 0, 3 );
   }

Modified: branches/theora-thusnelda/lib/enc/encoder_toplevel.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -40,7 +40,7 @@
       cpi->frag[i][j].coded=1;
   
   /* Set up for a KEY FRAME */
-  cpi->pb.FrameType = KEY_FRAME;
+  cpi->FrameType = KEY_FRAME;
 }
 
 static void AdjustKeyFrameContext(CP_INSTANCE *cpi) {
@@ -69,7 +69,7 @@
   /* Encode the data.  */
   EncodeData(cpi);
 
-  if ( cpi->pb.FrameType == KEY_FRAME ) 
+  if ( cpi->FrameType == KEY_FRAME ) 
     AdjustKeyFrameContext(cpi);
 
 }
@@ -108,14 +108,14 @@
   fragment_t *fp = cpi->frag[0];
 
   /* Clear down the macro block level mode and MV arrays. */
-  for ( i = 0; i < cpi->pb.UnitFragments; i++, fp++ ) {
+  for ( i = 0; i < cpi->frag_total; i++, fp++ ) {
     fp->mode = CODE_INTER_NO_MV;  /* Default coding mode */
     fp->mv.x=0;
     fp->mv.y=0;
   }
 
   /* Default to delta frames. */
-  cpi->pb.FrameType = DELTA_FRAME;
+  cpi->FrameType = DELTA_FRAME;
 
   /* Clear down the difference arrays for the current frame. */
   for(i=0;i<3;i++)
@@ -135,7 +135,7 @@
     
     /* Select modes and motion vectors for each of the blocks : return
        an error score for inter and intra */
-    PickModes( cpi, cpi->pb.YSBRows, cpi->pb.YSBCols,
+    PickModes( cpi, cpi->super_v[0], cpi->super_h[0],
                cpi->info.width,
                &InterError, &IntraError );
 

Modified: branches/theora-thusnelda/lib/enc/frarray.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frarray.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/frarray.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -17,6 +17,7 @@
 
 #include <string.h>
 #include "codec_internal.h"
+#include <stdio.h>
 
 /* Long run bit string coding */
 static ogg_uint32_t FrArrayCodeSBRun( CP_INSTANCE *cpi, ogg_uint32_t value){
@@ -107,205 +108,140 @@
 }
 
 void PackAndWriteDFArray( CP_INSTANCE *cpi ){
-  ogg_uint32_t  i;
-  unsigned char val;
-  ogg_uint32_t  run_count;
-
   ogg_uint32_t  SB, B;
-  ogg_uint32_t  BListIndex = 0;
-  ogg_uint32_t  LastSbBIndex = 0;
+  int run_last = -1;
+  int run_count = 0;
+  int run_break = 0;
+  int partial=0;
+  int fully = 1;
 
-  /* Initialise workspaces */
-  memset( cpi->pb.SBFullyFlags, 1, cpi->pb.SuperBlocks);
-  memset( cpi->pb.SBCodedFlags, 0, cpi->pb.SuperBlocks );
-  memset( cpi->PartiallyCodedFlags, 0, cpi->pb.SuperBlocks );
-  memset( cpi->BlockCodedFlags, 0, cpi->pb.UnitFragments);
-
-#ifdef _TH_DEBUG_
-  unsigned char blockraster[cpi->pb.UnitFragments];
-  memset(blockraster,0,sizeof(blockraster));
-#endif
-
-  for( SB = 0; SB < cpi->pb.SuperBlocks; SB++ ) {
+  /* code the partially coded SB flags */
+  for( SB = 0; SB < cpi->super_total; SB++ ) {
     superblock_t *sp = &cpi->super[0][SB];
+    int coded = 0;
+    fully = 1;
 
-    /* Check for blocks and macro-blocks */
     for ( B=0; B<16; B++ ) {
       fragment_t *fp = sp->f[B];
-      
       if ( fp ) {
-	/* In Frame: If it is not coded then this SB is only
-	   partly coded.: */
 	if ( fp->coded ) {
-	  cpi->pb.SBCodedFlags[SB] = 1; /* SB at least partly coded */
-	  cpi->BlockCodedFlags[BListIndex] = 1; /* Block is coded */
-	  
-#ifdef _TH_DEBUG_
-	  blockraster[fp - cpi->frag[0]]=1;
-#endif	      
-	  
+	  coded = 1; /* SB at least partly coded */
 	}else{
-	  cpi->pb.SBFullyFlags[SB] = 0; /* SB not fully coded */
-	  cpi->BlockCodedFlags[BListIndex] = 0; /* Block is not coded */
+	  fully = 0;
 	}
-	
-	BListIndex++;
-	
       }
     }
     
-    /* Is the SB fully coded or uncoded.
-       If so then backup BListIndex and MBListIndex */
-    if ( cpi->pb.SBFullyFlags[SB] || !cpi->pb.SBCodedFlags[SB] ) {
-      BListIndex = LastSbBIndex; /* Reset to values from previous SB */
-    }else{
-      cpi->PartiallyCodedFlags[SB] = 1; /* Set up list of partially
-                                           coded SBs */
-      LastSbBIndex = BListIndex;
+    partial = (!fully && coded);
+    
+    if(run_last == -1){
+      oggpackB_write( cpi->oggbuffer, partial, 1);      
+      run_last = partial;
     }
-  }
 
-#ifdef _TH_DEBUG_
-  // assuming 4:2:0 right now
-  TH_DEBUG("predicted (partially coded frame)\n");
-  TH_DEBUG("superblock coded flags = {");
-  int x,y;
-  i=0;
-
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+31)/32;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+31)/32;x++,i++)
-      TH_DEBUG("%x", ((cpi->pb.SBFullyFlags[i]!=0)|
-		      (cpi->PartiallyCodedFlags[i]!=0)));
-  }
-  TH_DEBUG("\n   ");
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+63)/64;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+63)/64;x++,i++)
-      TH_DEBUG("%x", ((cpi->pb.SBFullyFlags[i]!=0)|
-		      (cpi->PartiallyCodedFlags[i]!=0)));
-  }
-  TH_DEBUG("\n   ");
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+63)/64;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+63)/64;x++,i++)
-      TH_DEBUG("%x", ((cpi->pb.SBFullyFlags[i]!=0)|
-		      (cpi->PartiallyCodedFlags[i]!=0)));
-  }
-  TH_DEBUG("\n}\n");
-
-  if(i!=cpi->pb.SuperBlocks)
-    TH_DEBUG("WARNING!  superblock count, raster %d != flat %d\n",
-	     i,cpi->pb.SuperBlocks);
-
-  TH_DEBUG("block coded flags = {");
-
-  i=0;
-
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+7)/8;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+7)/8;x++,i++)
-      TH_DEBUG("%x", blockraster[i]);
-  }
-  TH_DEBUG("\n   ");
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+15)/16;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+15)/16;x++,i++)
-      TH_DEBUG("%x", blockraster[i]);
-  }
-  TH_DEBUG("\n   ");
-  for(y=0;y< (cpi->ScanConfig.VideoFrameHeight+15)/16;y++){
-    TH_DEBUG("\n   ");
-    for(x=0;x< (cpi->ScanConfig.VideoFrameWidth+15)/16;x++,i++)
-      TH_DEBUG("%x", blockraster[i]);
-  }
-  TH_DEBUG("\n}\n");
-
-  if(i!=cpi->pb.UnitFragments)
-    TH_DEBUG("WARNING!  block count, raster %d != flat %d\n",
-	     i,cpi->pb.UnitFragments);
-#endif	      
-
-  /* Code list of partially coded Super-Block.  */
-  val = cpi->PartiallyCodedFlags[0];
-  oggpackB_write( cpi->oggbuffer, (ogg_uint32_t)val, 1);
-
-  i = 0; 
-  while ( i < cpi->pb.SuperBlocks ) {
-    run_count = 0;
-    while ( (i<cpi->pb.SuperBlocks) && 
-	    (cpi->PartiallyCodedFlags[i]==val) &&
-	    run_count<4129 ) {
-      i++;
+    if(run_last == partial && run_count < 4129){
       run_count++;
+    }else{
+      if(run_break)
+	oggpackB_write( cpi->oggbuffer, partial, 1);
+  
+      run_break=0;
+      FrArrayCodeSBRun( cpi, run_count );      
+      if(run_count >= 4129) run_break = 1;
+      run_count=1;
     }
-
-    /* Code the run */
-    FrArrayCodeSBRun( cpi, run_count);
-
-    if(run_count >= 4129 && i < cpi->pb.SuperBlocks ){
-      val = cpi->PartiallyCodedFlags[i];
-      oggpackB_write( cpi->oggbuffer, (ogg_uint32_t)val, 1);
-      
-    }else
-      val = ( val == 0 ) ? 1 : 0;
+    run_last=partial;
   }
+  if(run_break)
+    oggpackB_write( cpi->oggbuffer, partial, 1);
+  if(run_count)
+    FrArrayCodeSBRun(cpi, run_count);      
 
-  /* RLC Super-Block fully/not coded. */
-  i = 0; 
-
-  /* Skip partially coded blocks */
-  while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] )
-    i++;
-
-  if ( i < cpi->pb.SuperBlocks ) {
-    val = cpi->pb.SBFullyFlags[i];
-    oggpackB_write( cpi->oggbuffer, (ogg_uint32_t)val, 1);
-
-    while ( i < cpi->pb.SuperBlocks ) {
-      run_count = 0;
-      while ( (i < cpi->pb.SuperBlocks) && 
-	      (cpi->pb.SBFullyFlags[i] == val) &&
-	      run_count < 4129) {
-        i++;
-        /* Skip partially coded blocks */
-        while( (i < cpi->pb.SuperBlocks) && cpi->PartiallyCodedFlags[i] )
-          i++;
-        run_count++;
+  /* code the fully coded/uncoded SB flags */
+  run_last = -1;
+  run_count = 0;
+  run_break = 0;
+  for( SB = 0; SB < cpi->super_total; SB++ ) {
+    superblock_t *sp = &cpi->super[0][SB];
+    int coded = 0;
+    fully = 1;
+    
+    for ( B=0; B<16; B++ ) {
+      fragment_t *fp = sp->f[B];
+      if ( fp ) {
+	if ( fp->coded ) {
+	  coded = 1;
+	}else{
+	  fully = 0;
+	}
       }
-
-      /* Code the run */
-      FrArrayCodeSBRun( cpi, run_count );
-
-    if(run_count >= 4129 && i < cpi->pb.SuperBlocks ){
-      val = cpi->PartiallyCodedFlags[i];
-      oggpackB_write( cpi->oggbuffer, (ogg_uint32_t)val, 1);
-    }else
-      val = ( val == 0 ) ? 1 : 0;
     }
+    
+    if(!fully && coded) continue;
+    
+    if(run_last == -1){
+      oggpackB_write( cpi->oggbuffer, fully, 1);      
+      run_last = fully;
+    }
+    
+    if(run_last == fully && run_count < 4129){
+      run_count++;
+    }else{
+      if(run_break)
+	oggpackB_write( cpi->oggbuffer, fully, 1);
+      run_break=0;
+      FrArrayCodeSBRun( cpi, run_count );      
+      if(run_count >= 4129) run_break = 1;
+      run_count=1;
+    }
+    run_last=fully;
   }
+  if(run_break)
+    oggpackB_write( cpi->oggbuffer, fully, 1);
 
+  if(run_count)
+    FrArrayCodeSBRun(cpi, run_count);      
 
-  /*  Now code the block flags */
-  if ( BListIndex > 0 ) {
-    /* Code the block flags start value */
-    val = cpi->BlockCodedFlags[0];
-    oggpackB_write( cpi->oggbuffer, (ogg_uint32_t)val, 1);
+  /* code the block flags */
+  run_last = -1;
+  run_count = 0;
+  for( SB = 0; SB < cpi->super_total; SB++ ) {
+    superblock_t *sp = &cpi->super[0][SB];
+    int coded = 0;
+    fully = 1;
 
-    /* Now code the block flags. */
-    for ( i = 0; i < BListIndex; ) {
-      run_count = 0;
-      while ( (cpi->BlockCodedFlags[i] == val) && (i < BListIndex) ) {
-        i++;
-        run_count++;
+    for ( B=0; B<16; B++ ) {
+      fragment_t *fp = sp->f[B];      
+      if ( fp ) {
+	if ( fp->coded ) {
+	  coded = 1;
+	}else{
+	  fully = 0; /* SB not fully coded */
+	}
       }
+    }
 
-      FrArrayCodeBlockRun( cpi, run_count );
+    if(fully || !coded) continue;
 
-      val = ( val == 0 ) ? 1 : 0;
+    for ( B=0; B<16; B++ ) {
+      fragment_t *fp = sp->f[B];      
+      if(fp){
+	if(run_last == -1){
+	  oggpackB_write( cpi->oggbuffer, fp->coded, 1);      
+	  run_last = fp->coded;
+	}
+	
+	if(run_last == fp->coded){
+	  run_count++;
+	}else{
+	  FrArrayCodeBlockRun( cpi, run_count );
+	  run_count=1;
+	}
+	run_last=fp->coded;
+      }
     }
   }
-}
+  if(run_count)
+    FrArrayCodeBlockRun( cpi, run_count );
 
-
-
+}

Modified: branches/theora-thusnelda/lib/enc/frinit.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frinit.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/frinit.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -41,46 +41,21 @@
   PB_INSTANCE *pbi = &cpi->pb;
 
   /* free prior allocs if present */
-  if(pbi->CodedBlockList) _ogg_free(pbi->CodedBlockList);
-#ifdef _TH_DEBUG_
-  if(pbi->QFragTIME) _ogg_free(pbi->QFragTIME);
-  if(pbi->QFragFREQ) _ogg_free(pbi->QFragFREQ);
-  if(pbi->QFragQUAN) _ogg_free(pbi->QFragQUAN);
-  pbi->QFragTIME = 0;
-  pbi->QFragFREQ = 0;
-  pbi->QFragQUAN = 0;
-#endif
+  if(cpi->CodedBlockList) _ogg_free(cpi->CodedBlockList);
+  cpi->CodedBlockList = 0;
 
-  if(pbi->SBCodedFlags) _ogg_free(pbi->SBCodedFlags);
-  if(pbi->SBFullyFlags) _ogg_free(pbi->SBFullyFlags);
-  if(pbi->MBFullyFlags) _ogg_free(pbi->MBFullyFlags);
-  if(pbi->MBCodedFlags) _ogg_free(pbi->MBCodedFlags);
-
-  pbi->CodedBlockList = 0;
-  pbi->MBCodedFlags = 0;
-  pbi->MBFullyFlags = 0;
-
-  pbi->SBCodedFlags = 0;
-  pbi->SBFullyFlags = 0;
-
   if(cpi->RunHuffIndices)
     _ogg_free(cpi->RunHuffIndices);
   if(cpi->ModeList)
     _ogg_free(cpi->ModeList);
   if(cpi->MVList)
     _ogg_free(cpi->MVList);
-  if(cpi->PartiallyCodedFlags)
-    _ogg_free(cpi->PartiallyCodedFlags);
-  if(cpi->PartiallyCodedMbPatterns)
-    _ogg_free(cpi->PartiallyCodedMbPatterns);
   if(cpi->BlockCodedFlags)
     _ogg_free(cpi->BlockCodedFlags);
 
   cpi->RunHuffIndices = 0;
   cpi->ModeList = 0;
   cpi->MVList = 0;
-  cpi->PartiallyCodedFlags = 0;
-  cpi->PartiallyCodedMbPatterns = 0;
   cpi->BlockCodedFlags = 0;
 
 }
@@ -113,59 +88,24 @@
      a waste of code. */
 
   cpi->RunHuffIndices =
-    _ogg_malloc(cpi->pb.UnitFragments*
+    _ogg_malloc(cpi->frag_total*
                 sizeof(*cpi->RunHuffIndices));
   cpi->BlockCodedFlags =
-    _ogg_malloc(cpi->pb.UnitFragments*
+    _ogg_malloc(cpi->frag_total*
                 sizeof(*cpi->BlockCodedFlags));
   cpi->ModeList =
-    _ogg_malloc(cpi->pb.UnitFragments*
+    _ogg_malloc(cpi->frag_total*
                 sizeof(*cpi->ModeList));
   cpi->MVList =
-    _ogg_malloc(cpi->pb.UnitFragments*
+    _ogg_malloc(cpi->frag_total*
                 sizeof(*cpi->MVList));
-  cpi->PartiallyCodedFlags =
-    _ogg_malloc(cpi->pb.MacroBlocks*
-                sizeof(*cpi->PartiallyCodedFlags));
-  cpi->PartiallyCodedMbPatterns =
-    _ogg_malloc(cpi->pb.MacroBlocks*
-                sizeof(*cpi->PartiallyCodedMbPatterns));
 
-  pbi->CodedBlockList =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->CodedBlockList));
+  cpi->CodedBlockList =
+    _ogg_malloc(cpi->frag_total * sizeof(*cpi->CodedBlockList));
 
-#ifdef _TH_DEBUG_
-
-  pbi->QFragTIME =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->QFragTIME));
-
-  pbi->QFragFREQ =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->QFragFREQ));
-
-  pbi->QFragQUAN =
-    _ogg_malloc(pbi->UnitFragments * sizeof(*pbi->QFragQUAN));
-
-#endif
-
-  /* Super Block Initialization */
-  pbi->SBCodedFlags =
-    _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->SBCodedFlags));
-
-  pbi->SBFullyFlags =
-    _ogg_malloc(pbi->SuperBlocks * sizeof(*pbi->SBFullyFlags));
-
-  /* Macro Block Initialization */
-  pbi->MBCodedFlags =
-    _ogg_malloc(pbi->MacroBlocks * sizeof(*pbi->MBCodedFlags));
-
-  pbi->MBFullyFlags =
-    _ogg_malloc(pbi->MacroBlocks * sizeof(*pbi->MBFullyFlags));
-
 }
 
 void ClearFrameInfo(CP_INSTANCE *cpi){
-  PB_INSTANCE *pbi = &cpi->pb;
-
   if(cpi->yuvptr)
     _ogg_free(cpi->yuvptr);
   cpi->yuvptr = 0;
@@ -197,33 +137,31 @@
   cpi->super[1] = 0;
   cpi->super[2] = 0;
 
-  if(pbi->ThisFrameRecon )
-    _ogg_free(pbi->ThisFrameRecon );
-  if(pbi->GoldenFrame)
-    _ogg_free(pbi->GoldenFrame);
-  if(pbi->LastFrameRecon)
-    _ogg_free(pbi->LastFrameRecon);
+  if(cpi->LastFrameRecon )
+    _ogg_free(cpi->LastFrameRecon );
+  if(cpi->GoldenFrame)
+    _ogg_free(cpi->GoldenFrame);
+  if(cpi->ThisFrameRecon)
+    _ogg_free(cpi->ThisFrameRecon);
 
-  pbi->ThisFrameRecon = 0;
-  pbi->GoldenFrame = 0;
-  pbi->LastFrameRecon = 0;
+  cpi->LastFrameRecon = 0;
+  cpi->GoldenFrame = 0;
+  cpi->ThisFrameRecon = 0;
 }
 
 static void InitFrameInfo(CP_INSTANCE *cpi, unsigned int FrameSize){
-  PB_INSTANCE *pbi = &cpi->pb;
-
   /* clear any existing info */
   ClearFrameInfo(cpi);
 
   /* allocate frames */
-  pbi->ThisFrameRecon =
-    _ogg_malloc(FrameSize*sizeof(*pbi->ThisFrameRecon));
+  cpi->LastFrameRecon =
+    _ogg_malloc(FrameSize*sizeof(*cpi->LastFrameRecon));
 
-  pbi->GoldenFrame =
-    _ogg_malloc(FrameSize*sizeof(*pbi->GoldenFrame));
+  cpi->GoldenFrame =
+    _ogg_malloc(FrameSize*sizeof(*cpi->GoldenFrame));
 
-  pbi->LastFrameRecon =
-    _ogg_malloc(FrameSize*sizeof(*pbi->LastFrameRecon));
+  cpi->ThisFrameRecon =
+    _ogg_malloc(FrameSize*sizeof(*cpi->ThisFrameRecon));
 
   /* allocate frames */
   cpi->yuvptr =
@@ -356,19 +294,7 @@
 
 void InitFrameDetails(CP_INSTANCE *cpi){
   int FrameSize;
-  PB_INSTANCE *pbi = &cpi->pb;
 
-    /* Set the frame size etc. */
-
-  pbi->YPlaneSize = cpi->info.width *
-    cpi->info.height;
-  pbi->UVPlaneSize = pbi->YPlaneSize / 4;
-  pbi->HFragments = cpi->info.width / HFRAGPIXELS;
-  pbi->VFragments = cpi->info.height / VFRAGPIXELS;
-  pbi->UnitFragments = ((pbi->VFragments * pbi->HFragments)*3)/2;
-  pbi->YPlaneFragments = pbi->HFragments * pbi->VFragments;
-  pbi->UVPlaneFragments = pbi->YPlaneFragments / 4;
-
   cpi->recon_stride[0] = (cpi->info.width + STRIDE_EXTRA);
   cpi->recon_stride[1] = (cpi->info.width + STRIDE_EXTRA) / 2;
   cpi->recon_stride[2] = (cpi->info.width + STRIDE_EXTRA) / 2;
@@ -383,26 +309,8 @@
     cpi->recon_offset[2] = ry_size + ruv_size + cpi->recon_stride[2] * (UMV_BORDER/2) + (UMV_BORDER/2);
   }
 
-  /* Image dimensions in Super-Blocks */
-  pbi->YSBRows = (cpi->info.height/32)  +
-    ( cpi->info.height%32 ? 1 : 0 );
-  pbi->YSBCols = (cpi->info.width/32)  +
-    ( cpi->info.width%32 ? 1 : 0 );
-  pbi->UVSBRows = ((cpi->info.height/2)/32)  +
-    ( (cpi->info.height/2)%32 ? 1 : 0 );
-  pbi->UVSBCols = ((cpi->info.width/2)/32)  +
-    ( (cpi->info.width/2)%32 ? 1 : 0 );
-
-  /* Super-Blocks per component */
-  pbi->YSuperBlocks = pbi->YSBRows * pbi->YSBCols;
-  pbi->UVSuperBlocks = pbi->UVSBRows * pbi->UVSBCols;
-  pbi->SuperBlocks = pbi->YSuperBlocks+2*pbi->UVSuperBlocks;
-
-  /* Useful externals */
-  pbi->MacroBlocks = ((pbi->VFragments+1)/2)*((pbi->HFragments+1)/2);
-
-  InitFragmentInfo(cpi);
   InitFrameInfo(cpi, FrameSize);
+  InitFragmentInfo(cpi);
 
   /* Re-initialise the pixel index table. */
   CalcPixelIndexTable( cpi );

Modified: branches/theora-thusnelda/lib/enc/mcomp.c
===================================================================
--- branches/theora-thusnelda/lib/enc/mcomp.c	2007-11-28 18:56:55 UTC (rev 14245)
+++ branches/theora-thusnelda/lib/enc/mcomp.c	2007-11-28 20:03:18 UTC (rev 14246)
@@ -252,8 +252,8 @@
   unsigned char *SrcPtr[4] = {NULL, NULL, NULL, NULL};
   unsigned char *RefPtr[4] = {NULL, NULL, NULL, NULL};
   int            BestBlockOffset=0;
-  int           disp[4];
-  int           off = 0;
+  int            disp[4];
+  int            off = 0;
 
   /* Half pixel variables */
   ogg_int32_t   HalfPixelError;



More information about the commits mailing list