[xiph-commits] r14250 - in branches/theora-thusnelda/lib/enc: . x86_32 x86_32_vs x86_64

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Nov 29 13:17:54 PST 2007


Author: xiphmont
Date: 2007-11-29 13:17:53 -0800 (Thu, 29 Nov 2007)
New Revision: 14250

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/dsp.c
   branches/theora-thusnelda/lib/enc/dsp.h
   branches/theora-thusnelda/lib/enc/encode.c
   branches/theora-thusnelda/lib/enc/encoder_toplevel.c
   branches/theora-thusnelda/lib/enc/frinit.c
   branches/theora-thusnelda/lib/enc/mcomp.c
   branches/theora-thusnelda/lib/enc/x86_32/dsp_mmx.c
   branches/theora-thusnelda/lib/enc/x86_32/dsp_mmxext.c
   branches/theora-thusnelda/lib/enc/x86_32_vs/dsp_mmx.c
   branches/theora-thusnelda/lib/enc/x86_64/dsp_mmx.c
   branches/theora-thusnelda/lib/enc/x86_64/dsp_mmxext.c
Log:
eliminate seperate addressing scheme for input and reconstruction
frames (just add a border area to the input and use the same offsets
all around]



Modified: branches/theora-thusnelda/lib/enc/codec_internal.h
===================================================================
--- branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/codec_internal.h	2007-11-29 21:17:53 UTC (rev 14250)
@@ -119,18 +119,8 @@
   unsigned char coeffs_packed;
   unsigned char tokens_packed;
 
-  ogg_uint32_t raw_index;
-  ogg_uint32_t recon_index;
+  ogg_uint32_t buffer_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 {
@@ -160,9 +150,13 @@
   oc_state_dispatch_vtbl dispatch_vtbl;
 
   theora_info      info;
-  unsigned char   *yuvptr;
+
+  unsigned char   *frame;
+  unsigned char   *recon;
+  unsigned char   *golden;
+  unsigned char   *lastrecon;
   
-  /* flag to indicate if the headers already have been written */
+  /* flag to indicate if he headers already have been written */
   int              HeadersWritten;
   /* how far do we shift the granulepos to seperate out P frame counts? */
   int              keyframe_granule_shift;
@@ -194,168 +188,177 @@
 
   /*********************************************************************/
   /* Token Buffers */
-  ogg_uint32_t     *OptimisedTokenListEb; /* Optimised token list extra bits */
-  unsigned char    *OptimisedTokenList;   /* Optimised token list. */
-  unsigned char    *OptimisedTokenListHi; /* Optimised token list huffman
+  ogg_uint32_t    *OptimisedTokenListEb; /* Optimised token list extra bits */
+  unsigned char   *OptimisedTokenList;   /* Optimised token list. */
+  unsigned char   *OptimisedTokenListHi; /* Optimised token list huffman
                                              table index */
 
   unsigned char    *OptimisedTokenListPl; /* Plane to which the token
                                              belongs Y = 0 or UV = 1 */
-  ogg_int32_t       OptimisedTokenCount;           /* Count of Optimized tokens */
-  ogg_uint32_t      RunHuffIndex;         /* Huffman table in force at
+  ogg_int32_t      OptimisedTokenCount;           /* Count of Optimized tokens */
+  ogg_uint32_t     RunHuffIndex;         /* Huffman table in force at
                                              the start of a run */
-  ogg_uint32_t      RunPlaneIndex;        /* The plane (Y=0 UV=1) to
+  ogg_uint32_t     RunPlaneIndex;        /* The plane (Y=0 UV=1) to
                                              which the first token in
                                              an EOB run belonged. */
-  ogg_uint32_t      TotTokenCount;
-  ogg_int32_t       TokensToBeCoded;
-  ogg_int32_t       TokensCoded;
+  ogg_uint32_t     TotTokenCount;
+  ogg_int32_t      TokensToBeCoded;
+  ogg_int32_t      TokensCoded;
   /********************************************************************/
   /* SuperBlock, MacroBLock and Fragment Information */
-  fragment_t       *frag[3];
-  macroblock_t     *macro;
-  superblock_t     *super[3];
+  fragment_t      *frag[3];
+  macroblock_t    *macro;
+  superblock_t    *super[3];
 
-  ogg_uint32_t      frag_h[3];
-  ogg_uint32_t      frag_v[3];
-  ogg_uint32_t      frag_n[3];
-  ogg_uint32_t      frag_total;
+  ogg_uint32_t     frag_h[3];
+  ogg_uint32_t     frag_v[3];
+  ogg_uint32_t     frag_n[3];
+  ogg_uint32_t     frag_total;
 
-  ogg_uint32_t      macro_h;
-  ogg_uint32_t      macro_v;
-  ogg_uint32_t      macro_total;
+  ogg_uint32_t     macro_h;
+  ogg_uint32_t     macro_v;
+  ogg_uint32_t     macro_total;
   
-  ogg_uint32_t      super_h[3];
-  ogg_uint32_t      super_v[3];
-  ogg_uint32_t      super_n[3];
-  ogg_uint32_t      super_total;
+  ogg_uint32_t     super_h[3];
+  ogg_uint32_t     super_v[3];
+  ogg_uint32_t     super_n[3];
+  ogg_uint32_t     super_total;
 
-  ogg_uint32_t      recon_stride[3];
-  ogg_uint32_t      recon_offset[3];
+  ogg_uint32_t     stride[3]; // stride of image and recon planes, accounting for borders
+  ogg_uint32_t     offset[3]; // data offset of first coded pixel in plane
 
   /* Coded flag arrays and counters for them */
 
-  ogg_uint32_t     *RunHuffIndices;
+  ogg_uint32_t    *RunHuffIndices;
 
-  unsigned char    *BlockCodedFlags;
+  unsigned char   *BlockCodedFlags;
 
-  mv_t             *MVList;
-  ogg_uint32_t      MvListCount;
-  ogg_uint32_t     *ModeList;
-  ogg_uint32_t      ModeListCount;
+  mv_t            *MVList;
+  ogg_uint32_t     MvListCount;
+  ogg_uint32_t    *ModeList;
+  ogg_uint32_t     ModeListCount;
 
-  unsigned char    *DataOutputBuffer;
+  unsigned char   *DataOutputBuffer;
 
-  unsigned char     FrameType;
-  unsigned char    *ThisFrameRecon;
-  unsigned char    *GoldenFrame;
-  unsigned char    *LastFrameRecon;
-  int               CodedBlockIndex;
-  fragment_t      **CodedBlockList;           
+  unsigned char    FrameType;
+  int              CodedBlockIndex;
+  fragment_t     **CodedBlockList;           
 
   /*********************************************************************/
 
-  ogg_uint32_t      RunLength;
+  ogg_uint32_t     RunLength;
 
-  ogg_int32_t       MVPixelOffsetY[MAX_SEARCH_SITES];
-  ogg_uint32_t      InterTripOutThresh;
-  unsigned char     MVEnabled;
-  ogg_uint32_t      MotionVectorSearchCount;
-  ogg_uint32_t      FrameMVSearcOunt;
-  ogg_int32_t       MVSearchSteps;
-  ogg_int32_t       MVOffsetX[MAX_SEARCH_SITES];
-  ogg_int32_t       MVOffsetY[MAX_SEARCH_SITES];
-  ogg_int32_t       HalfPixelRef2Offset[9]; /* Offsets for half pixel
+  ogg_int32_t      MVPixelOffsetY[MAX_SEARCH_SITES];
+  ogg_uint32_t     InterTripOutThresh;
+  unsigned char    MVEnabled;
+  ogg_uint32_t     MotionVectorSearchCount;
+  ogg_uint32_t     FrameMVSearcOunt;
+  ogg_int32_t      MVSearchSteps;
+  ogg_int32_t      MVOffsetX[MAX_SEARCH_SITES];
+  ogg_int32_t      MVOffsetY[MAX_SEARCH_SITES];
+  ogg_int32_t      HalfPixelRef2Offset[9]; /* Offsets for half pixel
                                                compensation */
-  signed char       HalfPixelXOffset[9];    /* Half pixel MV offsets for X */
-  signed char       HalfPixelYOffset[9];    /* Half pixel MV offsets for Y */
+  signed char      HalfPixelXOffset[9];    /* Half pixel MV offsets for X */
+  signed char      HalfPixelYOffset[9];    /* Half pixel MV offsets for Y */
 
   /* hufftables and quant setup ****************************************/
 
-  HUFF_ENTRY    *HuffRoot_VP3x[NUM_HUFF_TABLES];
-  ogg_uint32_t  *HuffCodeArray_VP3x[NUM_HUFF_TABLES];
-  unsigned char *HuffCodeLengthArray_VP3x[NUM_HUFF_TABLES];
+  HUFF_ENTRY      *HuffRoot_VP3x[NUM_HUFF_TABLES];
+  ogg_uint32_t    *HuffCodeArray_VP3x[NUM_HUFF_TABLES];
+  unsigned char   *HuffCodeLengthArray_VP3x[NUM_HUFF_TABLES];
   const unsigned char *ExtraBitLengths_VP3x;
 
-  th_quant_info  quant_info;
-  quant_tables   quant_tables[2][3];
-  iquant_tables  iquant_tables[2][3];
+  th_quant_info    quant_info;
+  quant_tables     quant_tables[2][3];
+  iquant_tables    iquant_tables[2][3];
 
   /* ogg bitpacker for use in packet coding, other API state */
   oggpack_buffer   *oggbuffer;
 #ifdef LIBOGG2  /* Remember, this is just until we drop libogg1 */
   ogg_buffer_state *oggbufferstate;
 #endif
-  int               readyflag;
-  int               packetflag;
-  int               doneflag;
+  int              readyflag;
+  int              packetflag;
+  int              doneflag;
 
-  DspFunctions   dsp;  /* Selected functions for this platform */
+  DspFunctions     dsp;  /* Selected functions for this platform */
 
 } CP_INSTANCE;
 
 #define clamp255(x) ((unsigned char)((((x)<0)-1) & ((x) | -((x)>255))))
 
-extern void IDct1( ogg_int16_t * InputData,
+extern void IDct1( ogg_int16_t *InputData,
                    ogg_int16_t *QuantMatrix,
-                   ogg_int16_t * OutputData );
+                   ogg_int16_t *OutputData );
 
 extern void ReconRefFrames (CP_INSTANCE *cpi);
+
 extern void quantize( CP_INSTANCE *cpi,
 		      ogg_int32_t *iquant_table,
-                      ogg_int16_t * DCT_block,
-                      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,
-				       fragment_t *fp);
-extern void TransformQuantizeBlock (CP_INSTANCE *cpi, fragment_t *fp, 
-                                    ogg_uint32_t PixelsPerLine ) ;
-extern void InitFrameDetails(CP_INSTANCE *cpi);
+                      ogg_int16_t *DCT_block,
+                      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, fragment_t *fp);
+
+extern void TransformQuantizeBlock (CP_INSTANCE *cpi, fragment_t *fp) ;
+
 extern void WriteQTables(CP_INSTANCE *cpi,oggpack_buffer *opb);
+
 extern void InitQTables( CP_INSTANCE *cpi );
+
 extern void InitHuffmanSet( CP_INSTANCE *cpi );
+
 extern void ClearHuffmanSet( CP_INSTANCE *cpi );
+
 extern void WriteHuffmanTrees(HUFF_ENTRY *HuffRoot[NUM_HUFF_TABLES],
                               oggpack_buffer *opb);
+
 extern void PackAndWriteDFArray( CP_INSTANCE *cpi );
+
 extern void InitMotionCompensation ( CP_INSTANCE *cpi );
+
 extern ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, 
-				     macroblock_t *mp,
-                                     ogg_uint32_t PixelsPerLine ) ;
+				     macroblock_t *mp );
+
 extern ogg_uint32_t GetMBInterError (CP_INSTANCE *cpi,
                                      unsigned char * SrcPtr,
                                      unsigned char * RefPtr,
 				     macroblock_t *mp,
                                      ogg_int32_t LastXMV,
-                                     ogg_int32_t LastYMV,
-                                     ogg_uint32_t PixelsPerLine ) ;
+                                     ogg_int32_t LastYMV );
+
 extern void WriteFrameHeader( CP_INSTANCE *cpi) ;
+
 extern ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi,
                                        unsigned char * RefFramePtr,
 				       macroblock_t *mp,
-                                       ogg_uint32_t PixelsPerLine,
                                        ogg_int32_t *MVPixelOffset,
                                        mv_t *MV );
+
 extern ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi,
                                              unsigned char * RefFramePtr,
 					     macroblock_t *mp,
-                                             ogg_uint32_t PixelsPerLine,
                                              mv_t *MV );
+
 extern ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi,
                                                unsigned char * RefFramePtr,
 					       macroblock_t *mp,
-                                               ogg_uint32_t PixelsPerLine,
                                                mv_t *MV ) ;
+
 extern void EncodeData(CP_INSTANCE *cpi);
+
 extern ogg_uint32_t PickIntra( CP_INSTANCE *cpi );
+
 extern ogg_uint32_t PickModes(CP_INSTANCE *cpi,
                               ogg_uint32_t SBRows,
                               ogg_uint32_t SBCols,
-                              ogg_uint32_t PixelsPerLine,
                               ogg_uint32_t *InterError,
                               ogg_uint32_t *IntraError);
 
-extern void ClearFragmentInfo (CP_INSTANCE *cpi);
+extern void InitFrameInfo(CP_INSTANCE *cpi);
+
 extern void ClearFrameInfo (CP_INSTANCE *cpi);
 
 #endif /* ENCODER_INTERNAL_H */

Modified: branches/theora-thusnelda/lib/enc/dct_decode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/dct_decode.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -39,21 +39,11 @@
   int            mode = fp->mode;
   int            qi = cpi->BaseQ; // temporary 
   int            plane = (fp<cpi->frag[1] ? 0 : (fp<cpi->frag[2] ? 1 : 2));
-  ogg_uint32_t   ReconPixelsPerLine = cpi->recon_stride[plane];
   int            inter = (mode != CODE_INTRA);
   ogg_int16_t    reconstruct[64];
   ogg_int16_t  *quantizers = cpi->quant_tables[inter][plane][qi];
   ogg_int16_t   *data = fp->dct;
   
-#ifdef _TH_DEBUG_
- {
-   int i;
-   for(i=0;i<64;i++)
-     fp->FREQ[FragmentNumber][dezigzag_index[i]]= 
-       cpi->quantized_list[i] * quantizers[i];
- }
-#endif
-
   /* Invert quantisation and DCT to get pixel data. */
   switch(fp->nonzero){
   case 0:case 1:
@@ -69,17 +59,9 @@
     dsp_IDctSlow(cpi->dsp, data, quantizers, reconstruct );
   }
 
-#ifdef _TH_DEBUG_
- {
-   int i;
-   for(i=0;i<64;i++)
-     cpi->TIME[FragmentNumber][i]= reconstruct[i];
- }
-#endif
-
   /* Convert fragment number to a pixel offset in a reconstruction buffer. */
-  dsp_recon8x8 (cpi->dsp, &cpi->ThisFrameRecon[fp->recon_index],
-		reconstruct, ReconPixelsPerLine);
+  dsp_recon8x8 (cpi->dsp, &cpi->recon[fp->buffer_index],
+		reconstruct, cpi->stride[plane]);
 
 }
 
@@ -89,8 +71,8 @@
   ogg_uint32_t  i;
   ogg_uint32_t  PixelIndex;
 
-  ogg_uint32_t  PlaneStride = cpi->recon_stride[plane];
-  ogg_uint32_t  BlockVStep = cpi->recon_stride[plane] * (VFRAGPIXELS - 1);
+  ogg_uint32_t  PlaneStride = cpi->stride[plane];
+  ogg_uint32_t  BlockVStep = cpi->stride[plane] * (VFRAGPIXELS - 1);
   ogg_uint32_t  PlaneFragments = cpi->frag_n[plane];
   ogg_uint32_t  LineFragments = cpi->frag_h[plane];
   ogg_uint32_t  PlaneBorderWidth = (plane ? UMV_BORDER / 2 : UMV_BORDER );
@@ -104,11 +86,11 @@
 
   /* Setup the source and destination pointers for the top and bottom
      borders */
-  PixelIndex = fp[0].recon_index;
+  PixelIndex = fp[0].buffer_index;
   SrcPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
   DestPtr1 = SrcPtr1 - (PlaneBorderWidth * PlaneStride);
 
-  PixelIndex = fp[PlaneFragments - LineFragments].recon_index + BlockVStep;
+  PixelIndex = fp[PlaneFragments - LineFragments].buffer_index + BlockVStep;
   SrcPtr2 = &DestReconPtr[ PixelIndex - PlaneBorderWidth];
   DestPtr2 = SrcPtr2 + PlaneStride;
 
@@ -128,7 +110,7 @@
   ogg_uint32_t   i;
   ogg_uint32_t   PixelIndex;
 
-  ogg_uint32_t   PlaneStride = cpi->recon_stride[plane];
+  ogg_uint32_t   PlaneStride = cpi->stride[plane];
   ogg_uint32_t   LineFragments = cpi->frag_h[plane];
   ogg_uint32_t   PlaneBorderWidth = (plane ? UMV_BORDER / 2 : UMV_BORDER );
   ogg_uint32_t   PlaneHeight = (plane ? cpi->info.height/2 : cpi->info.height );
@@ -142,11 +124,11 @@
 
   /* Setup the source data values and destination pointers for the
      left and right edge borders */
-  PixelIndex = fp[0].recon_index;
+  PixelIndex = fp[0].buffer_index;
   SrcPtr1 = &DestReconPtr[ PixelIndex ];
   DestPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
 
-  PixelIndex = fp[LineFragments - 1].recon_index + (HFRAGPIXELS - 1);
+  PixelIndex = fp[LineFragments - 1].buffer_index + (HFRAGPIXELS - 1);
   SrcPtr2 = &DestReconPtr[ PixelIndex ];
   DestPtr2 = &DestReconPtr[ PixelIndex + 1 ];
 
@@ -183,10 +165,10 @@
   
   /* Copy over only updated blocks.*/
   for(plane=0;plane<3;plane++){  
-    int PlaneLineStep = cpi->recon_stride[plane];
+    int PlaneLineStep = cpi->stride[plane];
     for ( i = 0; i < cpi->frag_n[plane]; i++,fp++ ) {
       if ( fp->coded ) {
-	int pi= fp->recon_index;
+	int pi= fp->buffer_index;
 	unsigned char *src = &SrcReconPtr[ pi ];
 	unsigned char *dst = &DestReconPtr[ pi ];
 	dsp_copy8x8 (cpi->dsp, src, dst, PlaneLineStep);
@@ -202,10 +184,10 @@
   
   /* Copy over only updated blocks.*/
   for(plane=0;plane<3;plane++){  
-    int PlaneLineStep = cpi->recon_stride[plane];
+    int PlaneLineStep = cpi->stride[plane];
     for ( i = 0; i < cpi->frag_n[plane]; i++,fp++ ) {
       if ( !fp->coded ) {
-	int pi= fp->recon_index;
+	int pi= fp->buffer_index;
 	unsigned char *src = &SrcReconPtr[ pi ];
 	unsigned char *dst = &DestReconPtr[ pi ];
 	dsp_copy8x8 (cpi->dsp, src, dst, PlaneLineStep);
@@ -274,7 +256,7 @@
 
   for ( j = 0; j < 3 ; j++){
     ogg_int32_t LineFragments = cpi->frag_h[j];
-    ogg_int32_t LineLength = cpi->recon_stride[j];
+    ogg_int32_t LineLength = cpi->stride[j];
     fp = cpi->frag[j];
 
     /**************************************************************
@@ -287,15 +269,15 @@
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !fp[1].coded ){
-        dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			fp[0].recon_index+6,
+        dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			fp[0].buffer_index+6,
 			LineLength,BoundingValuePtr);
       }
 
       /* Bottom done if next row set */
       if( !fp[LineFragments].coded ){
-        dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		       fp[LineFragments].recon_index,
+        dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		       fp[LineFragments].buffer_index,
 		       LineLength, BoundingValuePtr);
       }
     }
@@ -306,22 +288,22 @@
     for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++) {
       if( fp->coded){
         /* Filter Left edge always */
-        dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			fp[0].recon_index-2,
+        dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			fp[0].buffer_index-2,
 			LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			  fp[0].recon_index+6,
+          dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			  fp[0].buffer_index+6,
 			  LineLength, BoundingValuePtr);
         }
 
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-			 fp[LineFragments].recon_index,
+          dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+			 fp[LineFragments].buffer_index,
 			 LineLength, BoundingValuePtr);
         }
 	
@@ -332,14 +314,14 @@
     /* Last Column */
     if(fp->coded){
       /* Filter Left edge always */
-      dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-		      fp[0].recon_index - 2 ,
+      dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+		      fp[0].buffer_index - 2 ,
 		      LineLength, BoundingValuePtr);
       
       /* Bottom done if next row set */
       if( !fp[LineFragments].coded ){
-        dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		       fp[LineFragments].recon_index,
+        dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		       fp[LineFragments].buffer_index,
 		       LineLength, BoundingValuePtr);
       }
     }
@@ -356,22 +338,22 @@
          all fragments are intra */
       if( fp->coded){
         /* TopRow is always done */
-        dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		       fp[0].recon_index,
+        dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		       fp[0].buffer_index,
 		       LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			  fp[0].recon_index + 6,
+          dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			  fp[0].buffer_index + 6,
 			  LineLength, BoundingValuePtr);
         }
 	
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-			 fp[LineFragments].recon_index,
+          dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+			 fp[LineFragments].buffer_index,
 			 LineLength, BoundingValuePtr);
         }
       }
@@ -382,27 +364,27 @@
       for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++){
         if( fp->coded){
           /* Filter Left edge always */
-          dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			  fp[0].recon_index - 2,
+          dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			  fp[0].buffer_index - 2,
 			  LineLength, BoundingValuePtr);
 
           /* TopRow is always done */
-          dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-			 fp[0].recon_index,
+          dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+			 fp[0].buffer_index,
 			 LineLength, BoundingValuePtr);
 	  
           /* Filter right hand border only if the block to the right
              is not coded */
           if ( !fp[1].coded ){
-            dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			    fp[0].recon_index + 6,
+            dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			    fp[0].buffer_index + 6,
 			    LineLength, BoundingValuePtr);
           }
 
           /* Bottom done if next row set */
           if( !fp[LineFragments].coded ){
-            dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-			   fp[LineFragments].recon_index,
+            dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+			   fp[LineFragments].buffer_index,
 			   LineLength, BoundingValuePtr);
           }
         }
@@ -412,19 +394,19 @@
       /* Last Column */
       if(fp->coded){
         /* Filter Left edge always*/
-        dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			fp[0].recon_index - 2,
+        dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			fp[0].buffer_index - 2,
 			LineLength, BoundingValuePtr);
 
         /* TopRow is always done */
-        dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		       fp[0].recon_index,		       
+        dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		       fp[0].buffer_index,		       
 		       LineLength, BoundingValuePtr);
 	
         /* Bottom done if next row set */
         if( !fp[LineFragments].coded ){
-          dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-			 fp[LineFragments].recon_index,
+          dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+			 fp[LineFragments].buffer_index,
 			 LineLength, BoundingValuePtr);
         }
       }
@@ -440,15 +422,15 @@
     if(fp->coded){
 
       /* TopRow is always done */
-      dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		     fp[0].recon_index,
+      dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		     fp[0].buffer_index,
 		     LineLength, BoundingValuePtr);
 
       /* Filter right hand border only if the block to the right is
          not coded */
       if ( !fp[1].coded ){
-        dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			fp[0].recon_index + 6,
+        dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			fp[0].buffer_index + 6,
 			LineLength, BoundingValuePtr);
       }
     }
@@ -459,20 +441,20 @@
     for ( n = 1 ; n < cpi->frag_h[j] - 1 ; n++, fp++){
       if( fp->coded){
         /* Filter Left edge always */
-        dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			fp[0].recon_index - 2,
+        dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			fp[0].buffer_index - 2,
 			LineLength, BoundingValuePtr);
 	
         /* TopRow is always done */
-        dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		       fp[0].recon_index,
+        dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		       fp[0].buffer_index,
 		       LineLength, BoundingValuePtr);
 
         /* Filter right hand border only if the block to the right is
            not coded */
         if ( !fp[1].coded ){
-          dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-			  fp[0].recon_index + 6,
+          dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+			  fp[0].buffer_index + 6,
 			  LineLength, BoundingValuePtr);
         }
       }
@@ -482,13 +464,13 @@
     /* Last Column */
     if( fp->coded){
       /* Filter Left edge always */
-      dsp_FilterHoriz(cpi->dsp,cpi->LastFrameRecon+
-		      fp[0].recon_index - 2,
+      dsp_FilterHoriz(cpi->dsp,cpi->lastrecon+
+		      fp[0].buffer_index - 2,
 		      LineLength, BoundingValuePtr);
 
       /* TopRow is always done */
-      dsp_FilterVert(cpi->dsp,cpi->LastFrameRecon+
-		     fp[0].recon_index,
+      dsp_FilterVert(cpi->dsp,cpi->lastrecon+
+		     fp[0].buffer_index,
 		     LineLength, BoundingValuePtr);
       
     }
@@ -506,114 +488,26 @@
 
   /* Copy the current reconstruction back to the last frame recon buffer. */
   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 );
+    SwapReconBuffersTemp = cpi->recon;
+    cpi->recon = cpi->lastrecon;
+    cpi->lastrecon = SwapReconBuffersTemp;
+    CopyNotRecon( cpi, cpi->lastrecon, cpi->recon );
   }else{
-    CopyRecon( cpi, cpi->LastFrameRecon, cpi->ThisFrameRecon );
+    CopyRecon( cpi, cpi->lastrecon, cpi->recon );
   }
 
   /* Apply a loop filter to edge pixels of updated blocks */
   LoopFilter(cpi);
 
-#ifdef _TH_DEBUG_
-  {
-    int x,y,i,j,k,xn,yn,stride;
-    int plane;
-    int buf;
-    
-    /* dump fragment DCT components */
-    for(plane=0;plane<3;plane++){
-      char *plstr;
-      int offset;
-      switch(plane){
-      case 0:
-	plstr="Y";
-	xn = pbi->HFragments;
-	yn = pbi->VFragments;
-	offset = 0; 
-	stride = pbi->YStride;
-	break;
-      case 1:
-	plstr="U";
-	xn = pbi->HFragments>>1;
-	yn = pbi->VFragments>>1;
-	offset = pbi->VFragments * pbi->HFragments;	
-	stride = pbi->UVStride;
-	break;
-      case 2:
-	plstr="V";
-	xn = pbi->HFragments>>1;
-	yn = pbi->VFragments>>1;
-	offset = pbi->VFragments * pbi->HFragments + 
-	  ((pbi->VFragments * pbi->HFragments) >> 2);
-	stride = pbi->UVStride;
-	break;
-      }
-      for(y=0;y<yn;y++){
-	for(x=0;x<xn;x++,i++){
-	  
-	  for(buf=0;buf<3;buf++){
-	    Q_LIST_ENTRY (*ptr)[64];
-	    char *bufn;
-	    
-	    switch(buf){
-	    case 0:
-	      bufn = "coded";
-	      ptr = pbi->QFragQUAN;
-	      break;
-	    case 1:
-	      bufn = "coeff";
-	      ptr = pbi->QFragFREQ;
-	      break;
-	    case 2:
-	      bufn = "idct";
-	      ptr = pbi->QFragTIME;
-	      break;
-	    }
-	    
-	    i = offset + y*xn + x;
-	    
-	    TH_DEBUG("%s %s [%d][%d] = {",bufn,plstr,x,y);
-	    if ( !pbi->display_fragments[i] ) 
-	      TH_DEBUG(" not coded }\n");
-	    else{
-	      int l=0;
-	      for(j=0;j<8;j++){
-		TH_DEBUG("\n   ");
-		for(k=0;k<8;k++,l++){
-		  TH_DEBUG("%d ",ptr[i][l]);
-		}
-	      }
-	      TH_DEBUG(" }\n");
-	    }
-	  }
-	  
-	  /* and the loop filter output, which is a flat struct */
-	  TH_DEBUG("recon %s [%d][%d] = {",plstr,x,y);
-	  for(j=0;j<8;j++){
-	    int l = cpi->frag[0][i].recon_index + j*stride;
-	    TH_DEBUG("\n   ");
-	    for(k=0;k<8;k++,l++)
-	      TH_DEBUG("%d ", cpi->LastFrameRecon[l]);
-	  }
-	  TH_DEBUG(" }\n\n");
-	}
-      }
-    }
-  }
-#endif
-  
   /* We may need to update the UMV border */
-  UpdateUMVBorder(cpi, cpi->LastFrameRecon);
+  UpdateUMVBorder(cpi, cpi->lastrecon);
   
   /* Reconstruct the golden frame if necessary.
      For VFW codec only on key frames */
   if ( cpi->FrameType == KEY_FRAME ){
-    CopyRecon( cpi, cpi->GoldenFrame, cpi->LastFrameRecon );
+    CopyRecon( cpi, cpi->golden, cpi->lastrecon );
     /* We may need to update the UMV border */
-    UpdateUMVBorder(cpi, cpi->GoldenFrame);
+    UpdateUMVBorder(cpi, cpi->golden);
   }
 }
 

Modified: branches/theora-thusnelda/lib/enc/dct_encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/dct_encode.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -255,7 +255,6 @@
 				   ogg_int32_t MvDevisor,
 				   fragment_t *fp,
 				   ogg_uint32_t PixelsPerLine,
-				   ogg_uint32_t ReconPixelsPerLine,
 				   int mode) {
 
   ogg_int32_t MvShift;
@@ -287,7 +286,7 @@
     mv = fp->mv;
     
     /* Set up the baseline offset for the motion vector. */
-    MVOffset = ((mv.y / MvDevisor) * ReconPixelsPerLine) + (mv.x / MvDevisor);
+    MVOffset = ((mv.y / MvDevisor) * PixelsPerLine) + (mv.x / MvDevisor);
     
     /* Work out the offset of the second reference position for 1/2
        pixel interpolation.  For the U and V planes the MV specifies 1/4
@@ -306,15 +305,15 @@
     
     if ( AbsYOffset ) {
       if ( mv.y > 0 )
-	ReconPtr2Offset += ReconPixelsPerLine;
+	ReconPtr2Offset += PixelsPerLine;
       else
-	ReconPtr2Offset -= ReconPixelsPerLine;
+	ReconPtr2Offset -= PixelsPerLine;
     }
     
     if ( mode==CODE_GOLDEN_MV ) {
-      ReconPtr1 = &cpi->GoldenFrame[fp->recon_index];
+      ReconPtr1 = &cpi->golden[fp->buffer_index];
     } else {
-      ReconPtr1 = &cpi->LastFrameRecon[fp->recon_index];
+      ReconPtr1 = &cpi->lastrecon[fp->buffer_index];
     }
     
     ReconPtr1 += MVOffset;
@@ -324,50 +323,46 @@
     
     /* Is the MV offset exactly pixel alligned */
     if ( AbsRefOffset == 0 ){
-      dsp_sub8x8(cpi->dsp, FiltPtr, ReconPtr1, DctInputPtr,
-		 PixelsPerLine, ReconPixelsPerLine);
-      dsp_copy8x8 (cpi->dsp, ReconPtr1, thisrecon, ReconPixelsPerLine);
+      dsp_sub8x8(cpi->dsp, FiltPtr, ReconPtr1, DctInputPtr, PixelsPerLine);
+      dsp_copy8x8 (cpi->dsp, ReconPtr1, thisrecon, PixelsPerLine);
     } else {
       /* Fractional pixel MVs. */
       /* Note that we only use two pixel values even for the diagonal */
-      dsp_sub8x8avg2(cpi->dsp, FiltPtr, ReconPtr1,ReconPtr2,DctInputPtr,
-		     PixelsPerLine, ReconPixelsPerLine);
-      dsp_copy8x8_half (cpi->dsp, ReconPtr1, ReconPtr2, thisrecon, ReconPixelsPerLine);
+      dsp_sub8x8avg2(cpi->dsp, FiltPtr, ReconPtr1, ReconPtr2, DctInputPtr, PixelsPerLine);
+      dsp_copy8x8_half (cpi->dsp, ReconPtr1, ReconPtr2, thisrecon, PixelsPerLine);
     }
 
   } else { 
     if ( ( mode==CODE_INTER_NO_MV ) ||
 	 ( mode==CODE_USING_GOLDEN ) ) {
       if ( mode==CODE_INTER_NO_MV ) {
-	ReconPtr1 = &cpi->LastFrameRecon[fp->recon_index];
+	ReconPtr1 = &cpi->lastrecon[fp->buffer_index];
       } else {
-	ReconPtr1 = &cpi->GoldenFrame[fp->recon_index];
+	ReconPtr1 = &cpi->golden[fp->buffer_index];
       }
       
-      dsp_sub8x8(cpi->dsp, FiltPtr, ReconPtr1, DctInputPtr,
-		 PixelsPerLine, ReconPixelsPerLine);
-      dsp_copy8x8 (cpi->dsp, ReconPtr1, thisrecon, ReconPixelsPerLine);
+      dsp_sub8x8(cpi->dsp, FiltPtr, ReconPtr1, DctInputPtr,PixelsPerLine);
+      dsp_copy8x8 (cpi->dsp, ReconPtr1, thisrecon, PixelsPerLine);
     } else if ( mode==CODE_INTRA ) {
       dsp_sub8x8_128(cpi->dsp, FiltPtr, DctInputPtr, PixelsPerLine);
-      dsp_set8x8(cpi->dsp, 128, thisrecon, ReconPixelsPerLine);
+      dsp_set8x8(cpi->dsp, 128, thisrecon, PixelsPerLine);
     }
   }
 }
 
 void TransformQuantizeBlock (CP_INSTANCE *cpi, 
-			     fragment_t *fp,
-                             ogg_uint32_t PixelsPerLine) {
-  unsigned char *FiltPtr = &cpi->yuvptr[fp->raw_index];
+			     fragment_t *fp){
+
+  unsigned char *FiltPtr = &cpi->frame[fp->buffer_index];
   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->iquant_tables[inter][plane][qi];
   ogg_int16_t DCTInput[64];
   ogg_int16_t DCTOutput[64];
-  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->ThisFrameRecon[fp->recon_index];
+  unsigned char   *ReconPtr1 = &cpi->recon[fp->buffer_index];
 
   /* Set plane specific values */
   if (plane == 0){
@@ -380,8 +375,7 @@
      the reconstruction buffer, and proces a difference block for
      forward DCT */
   BlockUpdateDifference(cpi, FiltPtr, DCTInput, ReconPtr1,
-			MvDivisor, fp, PixelsPerLine,
-			ReconPixelsPerLine, fp->mode);
+			MvDivisor, fp, cpi->stride[plane], fp->mode);
   
   /* Proceed to encode the data into the encode buffer if the encoder
      is enabled. */

Modified: branches/theora-thusnelda/lib/enc/dsp.c
===================================================================
--- branches/theora-thusnelda/lib/enc/dsp.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/dsp.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -44,8 +44,7 @@
 }
 
 static void sub8x8__c (unsigned char *FiltPtr, unsigned char *ReconPtr,
-                  ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine,
-                  ogg_uint32_t ReconPixelsPerLine) {
+		       ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine){
   int i;
 
   /* For each block row */
@@ -61,13 +60,13 @@
 
     /* Start next row */
     FiltPtr += PixelsPerLine;
-    ReconPtr += ReconPixelsPerLine;
+    ReconPtr += PixelsPerLine;
     DctInputPtr += 8;
   }
 }
 
 static void sub8x8_128__c (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
-                      ogg_uint32_t PixelsPerLine) {
+			   ogg_uint32_t PixelsPerLine) {
   int i;
   /* For each block row */
   for (i=8; i; i--) {
@@ -91,10 +90,9 @@
 }
 
 static void sub8x8avg2__c (unsigned char *FiltPtr, unsigned char *ReconPtr1,
-                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
-                     ogg_uint32_t PixelsPerLine,
-                     ogg_uint32_t ReconPixelsPerLine) 
-{
+			   unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+			   ogg_uint32_t PixelsPerLine) {
+
   int i;
 
   /* For each block row */
@@ -110,8 +108,8 @@
 
     /* Start next row */
     FiltPtr += PixelsPerLine;
-    ReconPtr1 += ReconPixelsPerLine;
-    ReconPtr2 += ReconPixelsPerLine;
+    ReconPtr1 += PixelsPerLine;
+    ReconPtr2 += PixelsPerLine;
     DctInputPtr += 8;
   }
 }
@@ -137,7 +135,7 @@
 }
 
 static ogg_uint32_t col_sad8x8__c (unsigned char *Src1, unsigned char *Src2,
-                        ogg_uint32_t stride)
+				   ogg_uint32_t stride)
 {
   ogg_uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
   ogg_uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
@@ -182,8 +180,9 @@
   return MaxSad;
 }
 
-static ogg_uint32_t sad8x8__c (unsigned char *ptr1, ogg_uint32_t stride1,
-                 unsigned char *ptr2, ogg_uint32_t stride2)
+static ogg_uint32_t sad8x8__c (unsigned char *ptr1, 
+			       unsigned char *ptr2, 
+			       ogg_uint32_t stride)
 {
   ogg_uint32_t  i;
   ogg_uint32_t  sad = 0;
@@ -199,16 +198,17 @@
     sad += DSP_OP_ABS_DIFF(ptr1[7], ptr2[7]);
 
     /* Step to next row of block. */
-    ptr1 += stride1;
-    ptr2 += stride2;
+    ptr1 += stride;
+    ptr2 += stride;
   }
 
   return sad;
 }
 
-static ogg_uint32_t sad8x8_thres__c (unsigned char *ptr1, ogg_uint32_t stride1,
-                 unsigned char *ptr2, ogg_uint32_t stride2, 
-             ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_thres__c (unsigned char *ptr1, 
+				     unsigned char *ptr2, 
+				     ogg_uint32_t stride, 
+				     ogg_uint32_t thres)
 {
   ogg_uint32_t  i;
   ogg_uint32_t  sad = 0;
@@ -227,17 +227,18 @@
       break;
 
     /* Step to next row of block. */
-    ptr1 += stride1;
-    ptr2 += stride2;
+    ptr1 += stride;
+    ptr2 += stride;
   }
 
   return sad;
 }
 
-static ogg_uint32_t sad8x8_xy2_thres__c (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                          unsigned char *RefDataPtr1,
-                    unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
-                    ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_xy2_thres__c (unsigned char *SrcData, 
+					 unsigned char *RefDataPtr1,
+					 unsigned char *RefDataPtr2, 
+					 ogg_uint32_t Stride,
+					 ogg_uint32_t thres)
 {
   ogg_uint32_t  i;
   ogg_uint32_t  sad = 0;
@@ -256,9 +257,9 @@
       break;
 
     /* Step to next row of block. */
-    SrcData += SrcStride;
-    RefDataPtr1 += RefStride;
-    RefDataPtr2 += RefStride;
+    SrcData += Stride;
+    RefDataPtr1 += Stride;
+    RefDataPtr2 += Stride;
   }
 
   return sad;
@@ -297,8 +298,9 @@
    return (( (XXSum<<6) - XSum*XSum ) );
 }
 
-static ogg_uint32_t inter8x8_err__c (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                     unsigned char *RefDataPtr, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err__c (unsigned char *SrcData, 
+				     unsigned char *RefDataPtr, 
+				     ogg_uint32_t Stride)
 {
   ogg_uint32_t  i;
   ogg_uint32_t  XSum=0;
@@ -339,17 +341,18 @@
     XXSum += DiffVal*DiffVal;
         
     /* Step to next row of block. */
-    SrcData += SrcStride;
-    RefDataPtr += RefStride;
+    SrcData += Stride;
+    RefDataPtr += Stride;
   }
 
   /* Compute and return population variance as mis-match metric. */
   return (( (XXSum<<6) - XSum*XSum ));
 }
 
-static ogg_uint32_t inter8x8_err_xy2__c (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                         unsigned char *RefDataPtr1,
-             unsigned char *RefDataPtr2, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err_xy2__c (unsigned char *SrcData, 
+					 unsigned char *RefDataPtr1,
+					 unsigned char *RefDataPtr2, 
+					 ogg_uint32_t Stride)
 {
   ogg_uint32_t  i;
   ogg_uint32_t  XSum=0;
@@ -390,9 +393,9 @@
     XXSum += DiffVal*DiffVal;
 
     /* Step to next row of block. */
-    SrcData += SrcStride;
-    RefDataPtr1 += RefStride;
-    RefDataPtr2 += RefStride;
+    SrcData += Stride;
+    RefDataPtr1 += Stride;
+    RefDataPtr2 += Stride;
   }
 
   /* Compute and return population variance as mis-match metric. */

Modified: branches/theora-thusnelda/lib/enc/dsp.h
===================================================================
--- branches/theora-thusnelda/lib/enc/dsp.h	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/dsp.h	2007-11-29 21:17:53 UTC (rev 14250)
@@ -23,75 +23,70 @@
 
 typedef struct
 {
-  void   (*save_fpu)            (void);
-  void   (*restore_fpu)         (void);
+  void   (*save_fpu)              (void);
+  void   (*restore_fpu)           (void);
 
-  void   (*set8x8)      (unsigned char val, unsigned char *ptr,
-			 ogg_uint32_t PixelsPerLine);
+  void   (*set8x8)                (unsigned char val, unsigned char *ptr,
+				   ogg_uint32_t stride);
 
-  void   (*sub8x8)      (unsigned char *FiltPtr, unsigned char *ReconPtr,
-                        ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine,
-         ogg_uint32_t ReconPixelsPerLine);
+  void   (*sub8x8)                (unsigned char *FiltPtr, unsigned char *ReconPtr,
+				   ogg_int16_t *DctInputPtr, ogg_uint32_t stride);
 
-  void   (*sub8x8_128)     (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
-               ogg_uint32_t PixelsPerLine);
+  void   (*sub8x8_128)            (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
+				   ogg_uint32_t stride);
 
-  void   (*sub8x8avg2)     (unsigned char *FiltPtr, unsigned char *ReconPtr1,
-                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
-               ogg_uint32_t PixelsPerLine,
-               ogg_uint32_t ReconPixelsPerLine); 
+  void   (*sub8x8avg2)            (unsigned char *FiltPtr, unsigned char *ReconPtr1,
+				   unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+				   ogg_uint32_t stride);
 
-  void   (*copy8x8)      (unsigned char *src, unsigned char *dest, 
-                     ogg_uint32_t stride);
+  void   (*copy8x8)               (unsigned char *src, unsigned char *dest, 
+				   ogg_uint32_t stride);
+  
+  void   (*copy8x8_half)          (unsigned char *src1, unsigned char *src2, 
+				   unsigned char *dest, ogg_uint32_t stride);
 
-  void   (*copy8x8_half)      (unsigned char *src1, unsigned char *src2, 
-			       unsigned char *dest, ogg_uint32_t stride);
+  void   (*recon8x8)              (unsigned char *ReconPtr, ogg_int16_t *ChangePtr, 
+				   ogg_uint32_t stride);
 
-  void   (*recon8x8)    (unsigned char *ReconPtr, ogg_int16_t *ChangePtr, 
-			 ogg_uint32_t LineStep);
+  void   (*fdct_short)            (ogg_int16_t *InputData, ogg_int16_t *OutputData);
 
-  void   (*fdct_short)          (ogg_int16_t *InputData, ogg_int16_t *OutputData);
+  ogg_uint32_t (*row_sad8)        (unsigned char *Src1, unsigned char *Src2);
 
-  ogg_uint32_t (*row_sad8)  (unsigned char *Src1, unsigned char *Src2);
+  ogg_uint32_t (*col_sad8x8)      (unsigned char *Src1, unsigned char *Src2,
+				   ogg_uint32_t stride);
+  
+  ogg_uint32_t (*sad8x8)          (unsigned char *ptr1, unsigned char *ptr2, 
+				   ogg_uint32_t stride);
 
-  ogg_uint32_t (*col_sad8x8)  (unsigned char *Src1, unsigned char *Src2,
-           ogg_uint32_t stride);
+  ogg_uint32_t (*sad8x8_thres)    (unsigned char *ptr1, unsigned char *ptr2, 
+				   ogg_uint32_t stride, ogg_uint32_t thres);
 
-  ogg_uint32_t (*sad8x8)  (unsigned char *ptr1, ogg_uint32_t stride1,
-               unsigned char *ptr2, ogg_uint32_t stride2);
+  ogg_uint32_t (*sad8x8_xy2_thres)(unsigned char *SrcData, unsigned char *RefDataPtr1,
+				   unsigned char *RefDataPtr2, ogg_uint32_t stride,
+				   ogg_uint32_t thres);
+  
+  ogg_uint32_t (*intra8x8_err)    (unsigned char *DataPtr, ogg_uint32_t stride);
+  
+  ogg_uint32_t (*inter8x8_err)    (unsigned char *SrcData, unsigned char *RefData, 
+				   ogg_uint32_t stride);
 
-  ogg_uint32_t (*sad8x8_thres)  (unsigned char *ptr1, ogg_uint32_t stride1,
-                unsigned char *ptr2, ogg_uint32_t stride2, 
-         ogg_uint32_t thres);
-
-  ogg_uint32_t (*sad8x8_xy2_thres)(unsigned char *SrcData, ogg_uint32_t SrcStride,
-                     unsigned char *RefDataPtr1,
-               unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
-         ogg_uint32_t thres);
-
-  ogg_uint32_t (*intra8x8_err)  (unsigned char *DataPtr, ogg_uint32_t Stride);
-
-  ogg_uint32_t (*inter8x8_err)  (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                     unsigned char *RefDataPtr, ogg_uint32_t RefStride);
-
-  ogg_uint32_t (*inter8x8_err_xy2)(unsigned char *SrcData, ogg_uint32_t SrcStride,
-                     unsigned char *RefDataPtr1,
-               unsigned char *RefDataPtr2, ogg_uint32_t RefStride);
+  ogg_uint32_t (*inter8x8_err_xy2)(unsigned char *SrcData, unsigned char *RefDataPtr1,
+				   unsigned char *RefDataPtr2, ogg_uint32_t stride);
                
-  void (*FilterHoriz) (unsigned char * PixelPtr,
-                ogg_int32_t LineLength, ogg_int16_t *BoundingValuePtr);
+  void (*FilterHoriz)             (unsigned char * PixelPtr,
+				   ogg_int32_t LineLength, ogg_int16_t *BoundingValuePtr);
 
-  void (*FilterVert) (unsigned char * PixelPtr,
-                 ogg_int32_t LineLength, ogg_int16_t *BoundingValuePtr);
+  void (*FilterVert)              (unsigned char * PixelPtr,
+				   ogg_int32_t LineLength, ogg_int16_t *BoundingValuePtr);
+  
+  void (*IDctSlow)                (ogg_int16_t *InputData, 
+				   ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
 
-   void (*IDctSlow) (ogg_int16_t *InputData, 
-                  ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
-
-    void (*IDct3) (ogg_int16_t *InputData, 
-                   ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
-                   
-    void (*IDct10) (ogg_int16_t *InputData, 
-                  ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
+  void (*IDct3)                   (ogg_int16_t *InputData, 
+				   ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
+  
+  void (*IDct10)                  (ogg_int16_t *InputData, 
+				   ogg_int16_t *QuantMatrix, ogg_int16_t *OutputData);
 } DspFunctions;
 
 extern void dsp_dct_init(DspFunctions *funcs, ogg_uint32_t cpu_flags);
@@ -116,11 +111,11 @@
 
 #define dsp_set8x8(funcs,a1,a2,a3) (funcs.set8x8 (a1,a2,a3))
 
-#define dsp_sub8x8(funcs,a1,a2,a3,a4,a5) (funcs.sub8x8 (a1,a2,a3,a4,a5))
+#define dsp_sub8x8(funcs,a1,a2,a3,a4) (funcs.sub8x8 (a1,a2,a3,a4))
 
 #define dsp_sub8x8_128(funcs,a1,a2,a3) (funcs.sub8x8_128 (a1,a2,a3))
 
-#define dsp_sub8x8avg2(funcs,a1,a2,a3,a4,a5,a6) (funcs.sub8x8avg2 (a1,a2,a3,a4,a5,a6))
+#define dsp_sub8x8avg2(funcs,a1,a2,a3,a4,a5) (funcs.sub8x8avg2 (a1,a2,a3,a4,a5))
 
 #define dsp_copy8x8(funcs,ptr1,ptr2,str1) (funcs.copy8x8 (ptr1,ptr2,str1))
 
@@ -134,20 +129,20 @@
 
 #define dsp_col_sad8x8(funcs,ptr1,ptr2,str1) (funcs.col_sad8x8 (ptr1,ptr2,str1))
 
-#define dsp_sad8x8(funcs,ptr1,str1,ptr2,str2) (funcs.sad8x8 (ptr1,str1,ptr2,str2))
+#define dsp_sad8x8(funcs,ptr1,ptr2,str) (funcs.sad8x8 (ptr1,ptr2,str))
 
-#define dsp_sad8x8_thres(funcs,ptr1,str1,ptr2,str2,t) (funcs.sad8x8_thres (ptr1,str1,ptr2,str2,t))
+#define dsp_sad8x8_thres(funcs,ptr1,ptr2,str,t) (funcs.sad8x8_thres (ptr1,ptr2,str,t))
 
-#define dsp_sad8x8_xy2_thres(funcs,ptr1,str1,ptr2,ptr3,str2,t) \
-  (funcs.sad8x8_xy2_thres (ptr1,str1,ptr2,ptr3,str2,t))
+#define dsp_sad8x8_xy2_thres(funcs,ptr1,ptr2,ptr3,str,t) \
+  (funcs.sad8x8_xy2_thres (ptr1,ptr2,ptr3,str,t))
 
 #define dsp_intra8x8_err(funcs,ptr1,str1) (funcs.intra8x8_err (ptr1,str1))
 
-#define dsp_inter8x8_err(funcs,ptr1,str1,ptr2,str2) \
-  (funcs.inter8x8_err (ptr1,str1,ptr2,str2))
+#define dsp_inter8x8_err(funcs,ptr1,ptr2,str) \
+  (funcs.inter8x8_err (ptr1,ptr2,str))
 
-#define dsp_inter8x8_err_xy2(funcs,ptr1,str1,ptr2,ptr3,str2) \
-  (funcs.inter8x8_err_xy2 (ptr1,str1,ptr2,ptr3,str2))
+#define dsp_inter8x8_err_xy2(funcs,ptr1,ptr2,ptr3,str) \
+  (funcs.inter8x8_err_xy2 (ptr1,ptr2,ptr3,str))
 
 #define dsp_FilterHoriz(funcs, ptr1, ptr2, ptr3) \
   (funcs.FilterHoriz(ptr1, ptr2, ptr3))

Modified: branches/theora-thusnelda/lib/enc/encode.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encode.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/encode.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -136,8 +136,7 @@
 
 
 static ogg_uint32_t CodePlane ( CP_INSTANCE *cpi,
-				int plane,
-				ogg_uint32_t PixelsPerLine){
+				int plane ){
 
   ogg_uint32_t SBs = cpi->super_n[plane];
   ogg_uint32_t SB, MB, B;
@@ -164,7 +163,7 @@
 	if ( fp && fp->coded ) {
 	  
 	  /* transform and quantize block */
-	  TransformQuantizeBlock( cpi, fp, PixelsPerLine );
+	  TransformQuantizeBlock( cpi, fp );
 	  
 	  /* Has the block got struck off (no MV and no data
 	     generated after DCT) If not then mark it and the
@@ -784,9 +783,9 @@
   dsp_save_fpu (cpi->dsp);
 
   /* Encode and tokenise the Y, U and V components */
-  CodePlane(cpi, 0, cpi->info.width );
-  CodePlane(cpi, 1, cpi->info.width>>1 );
-  CodePlane(cpi, 2, cpi->info.width>>1 );
+  CodePlane(cpi, 0);
+  CodePlane(cpi, 1);
+  CodePlane(cpi, 2);
   
   PredictDC(cpi);
 
@@ -848,7 +847,6 @@
 
 ogg_uint32_t PickModes(CP_INSTANCE *cpi,
                        ogg_uint32_t SBRows, ogg_uint32_t SBCols,
-                       ogg_uint32_t PixelsPerLine,
                        ogg_uint32_t *InterError, ogg_uint32_t *IntraError) {
   ogg_uint32_t  MB, B;      /* Macro-Block, Block indices */
   ogg_uint32_t  SBrow;      /* Super-Block row number */
@@ -946,34 +944,33 @@
 
 
         /* Look at the intra coding error. */
-        MBIntraError = GetMBIntraError( cpi, mp, PixelsPerLine );
+        MBIntraError = GetMBIntraError( cpi, mp );
         BestError = (BestError > MBIntraError) ? MBIntraError : BestError;
 
         /* Get the golden frame error */
-        MBGFError = GetMBInterError( cpi, cpi->yuvptr, cpi->GoldenFrame, 
-				     mp, 0, 0, PixelsPerLine );
+        MBGFError = GetMBInterError( cpi, cpi->frame, cpi->golden, 
+				     mp, 0, 0 );
         BestError = (BestError > MBGFError) ? MBGFError : BestError;
 
         /* Calculate the 0,0 case. */
-        MBInterError = GetMBInterError( cpi, cpi->yuvptr,
-                                        cpi->LastFrameRecon,
-					mp, 0, 0, PixelsPerLine );
+        MBInterError = GetMBInterError( cpi, cpi->frame,
+                                        cpi->lastrecon,
+					mp, 0, 0 );
         BestError = (BestError > MBInterError) ? MBInterError : BestError;
 
         /* Measure error for last MV */
-        MBLastInterError =  GetMBInterError( cpi, cpi->yuvptr,
-                                             cpi->LastFrameRecon,
+        MBLastInterError =  GetMBInterError( cpi, cpi->frame,
+                                             cpi->lastrecon,
 					     mp, LastInterMVect.x,
-                                             LastInterMVect.y, PixelsPerLine );
+                                             LastInterMVect.y );
         BestError = (BestError > MBLastInterError) ?
           MBLastInterError : BestError;
 
         /* Measure error for prior last MV */
-        MBPriorLastInterError =  GetMBInterError( cpi, cpi->yuvptr,
-                                                  cpi->LastFrameRecon,
+        MBPriorLastInterError =  GetMBInterError( cpi, cpi->frame,
+                                                  cpi->lastrecon,
 						  mp, PriorLastInterMVect.x,
-                                                  PriorLastInterMVect.y,
-                                                  PixelsPerLine );
+                                                  PriorLastInterMVect.y );
         BestError = (BestError > MBPriorLastInterError) ?
           MBPriorLastInterError : BestError;
 
@@ -988,8 +985,8 @@
           /* Use a mix of heirachical and exhaustive searches for
              quick mode. */
           if ( cpi->info.quick_p ) {
-            MBInterMVError = GetMBMVInterError( cpi, cpi->LastFrameRecon,
-						mp, PixelsPerLine,
+            MBInterMVError = GetMBMVInterError( cpi, cpi->lastrecon,
+						mp,
                                                 cpi->MVPixelOffsetY,
                                                 &InterMVect );
 
@@ -999,9 +996,8 @@
                  (BestError > cpi->ExhaustiveSearchThresh) ) {
 
               MBInterMVExError =
-                GetMBMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
+                GetMBMVExhaustiveSearch( cpi, cpi->lastrecon,
 					 mp,
-                                         PixelsPerLine,
                                          &InterMVectEx );
 
               /* Is the Variance measure for the EX search
@@ -1015,9 +1011,8 @@
           }else{
             /* Use an exhaustive search */
             MBInterMVError =
-              GetMBMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
+              GetMBMVExhaustiveSearch( cpi, cpi->lastrecon,
 				       mp,
-                                       PixelsPerLine,
                                        &InterMVect );
           }
 
@@ -1037,17 +1032,16 @@
         GFMVect.y = 0;
         if ( BestError > cpi->MinImprovementForNewMV && cpi->MotionCompensation) {
           /* Do an MV search in the golden reference frame */
-          MBGF_MVError = GetMBMVInterError( cpi, cpi->GoldenFrame,
+          MBGF_MVError = GetMBMVInterError( cpi, cpi->golden,
 					    mp,
-                                            PixelsPerLine,
                                             cpi->MVPixelOffsetY, &GFMVect );
 
           /* Measure error for last GFMV */
-          LastMBGF_MVError =  GetMBInterError( cpi, cpi->yuvptr,
-                                               cpi->GoldenFrame,
+          LastMBGF_MVError =  GetMBInterError( cpi, cpi->frame,
+                                               cpi->golden,
 					       mp,
                                                LastGFMVect.x,
-                                               LastGFMVect.y, PixelsPerLine );
+                                               LastGFMVect.y );
 
           /* Check against last GF motion vector and reset if the
              search has thrown a worse result. */
@@ -1073,9 +1067,9 @@
         if ( BestError > cpi->FourMVThreshold && cpi->MotionCompensation) {
           /* Get the 4MV error. */
           MBInterFOURMVError =
-            GetFOURMVExhaustiveSearch( cpi, cpi->LastFrameRecon,
+            GetFOURMVExhaustiveSearch( cpi, cpi->lastrecon,
 				       mp,
-                                       PixelsPerLine, FourMVect );
+                                       FourMVect );
 
           /* If the improvement is great enough then use the four MV mode */
           if ( ((MBInterFOURMVError + cpi->MinImprovementForFourMV) <

Modified: branches/theora-thusnelda/lib/enc/encoder_toplevel.c
===================================================================
--- branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/encoder_toplevel.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -136,7 +136,6 @@
     /* Select modes and motion vectors for each of the blocks : return
        an error score for inter and intra */
     PickModes( cpi, cpi->super_v[0], cpi->super_h[0],
-               cpi->info.width,
                &InterError, &IntraError );
 
     /* decide whether we really should have made this frame a key frame */
@@ -251,7 +250,7 @@
   oggpackB_writeinit(cpi->oggbuffer, cpi->oggbufferstate);
 #endif 
 
-  InitFrameDetails(cpi);
+  InitFrameInfo(cpi);
 
   /* Initialise Motion compensation */
   InitMotionCompensation(cpi);
@@ -295,32 +294,29 @@
   /* Copy over input YUV to internal YUV buffers. */
   /* we invert the image for backward compatibility with VP3 */
   /* First copy over the Y data */
-  LocalDataPtr = cpi->yuvptr + yuv->y_width*(yuv->y_height - 1);
+  LocalDataPtr = cpi->frame + cpi->offset[0] + cpi->stride[0]*(yuv->y_height - 1);
   InputDataPtr = yuv->y;
   for ( i = 0; i < yuv->y_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->y_width );
-    LocalDataPtr -= yuv->y_width;
+    LocalDataPtr -= cpi->stride[0];
     InputDataPtr += yuv->y_stride;
   }
 
   /* Now copy over the U data */
-  LocalDataPtr = &cpi->yuvptr[(yuv->y_height * yuv->y_width)];
-  LocalDataPtr += yuv->uv_width*(yuv->uv_height - 1);
+  LocalDataPtr = cpi->frame + cpi->offset[1] + cpi->stride[1]*(yuv->uv_height - 1);
   InputDataPtr = yuv->u;
   for ( i = 0; i < yuv->uv_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
-    LocalDataPtr -= yuv->uv_width;
+    LocalDataPtr -= cpi->stride[1];
     InputDataPtr += yuv->uv_stride;
   }
 
   /* Now copy over the V data */
-  LocalDataPtr =
-    &cpi->yuvptr[((yuv->y_height*yuv->y_width)*5)/4];
-  LocalDataPtr += yuv->uv_width*(yuv->uv_height - 1);
+  LocalDataPtr = cpi->frame + cpi->offset[2] + cpi->stride[2]*(yuv->uv_height - 1);
   InputDataPtr = yuv->v;
   for ( i = 0; i < yuv->uv_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
-    LocalDataPtr -= yuv->uv_width;
+    LocalDataPtr -= cpi->stride[2];
     InputDataPtr += yuv->uv_stride;
   }
 
@@ -564,7 +560,6 @@
   if(cpi){
 
     ClearHuffmanSet(cpi);
-    ClearFragmentInfo(cpi);
     ClearFrameInfo(cpi);
 
     oggpackB_writeclear(cpi->oggbuffer);

Modified: branches/theora-thusnelda/lib/enc/frinit.c
===================================================================
--- branches/theora-thusnelda/lib/enc/frinit.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/frinit.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -22,163 +22,112 @@
 static void CalcPixelIndexTable(CP_INSTANCE *cpi){
   ogg_uint32_t plane,row,col;
   fragment_t *fp = cpi->frag[0];
-  ogg_uint32_t raw=0;
 
   for(plane=0;plane<3;plane++){
-    ogg_uint32_t recon = cpi->recon_offset[plane];
+    ogg_uint32_t offset = cpi->offset[plane];
     for(row=0;row<cpi->frag_v[plane];row++){
       for(col=0;col<cpi->frag_h[plane];col++,fp++){
-	fp->raw_index = raw+col*8;
-	fp->recon_index = recon+col*8;
+	fp->buffer_index = offset+col*8;
       }
-      raw += col*8*8;
-      recon += cpi->recon_stride[plane]*8;
+      offset += cpi->stride[plane]*8;
     }
   }
 }
 
-void ClearFragmentInfo(CP_INSTANCE *cpi){
+void ClearFrameInfo(CP_INSTANCE *cpi){
 
-  /* free prior allocs if present */
-  if(cpi->CodedBlockList) _ogg_free(cpi->CodedBlockList);
-  cpi->CodedBlockList = 0;
+  if(cpi->frame) _ogg_free(cpi->frame);
+  cpi->frame = 0;
 
-  if(cpi->RunHuffIndices)
-    _ogg_free(cpi->RunHuffIndices);
-  if(cpi->ModeList)
-    _ogg_free(cpi->ModeList);
-  if(cpi->MVList)
-    _ogg_free(cpi->MVList);
-  if(cpi->BlockCodedFlags)
-    _ogg_free(cpi->BlockCodedFlags);
+  if(cpi->lastrecon ) _ogg_free(cpi->lastrecon );
+  cpi->lastrecon = 0;
 
-  cpi->RunHuffIndices = 0;
-  cpi->ModeList = 0;
-  cpi->MVList = 0;
-  cpi->BlockCodedFlags = 0;
+  if(cpi->golden) _ogg_free(cpi->golden);
+  cpi->golden = 0;
 
-}
+  if(cpi->recon) _ogg_free(cpi->recon);
+  cpi->recon = 0;
 
-static void InitFragmentInfo(CP_INSTANCE * cpi){
+  if(cpi->CodedBlockList) _ogg_free(cpi->CodedBlockList);
+  cpi->CodedBlockList = 0;
 
-  /* clear any existing info */
-  ClearFragmentInfo(cpi);
+  if(cpi->RunHuffIndices) _ogg_free(cpi->RunHuffIndices);
+  cpi->RunHuffIndices = 0;
 
-  /* A note to people reading and wondering why malloc returns aren't
-     checked:
+  if(cpi->ModeList) _ogg_free(cpi->ModeList);
+  cpi->ModeList = 0;
 
-     lines like the following that implement a general strategy of
-     'check the return of malloc; a zero pointer means we're out of
-     memory!'...:
+  if(cpi->MVList) _ogg_free(cpi->MVList);
+  cpi->MVList = 0;
 
-     if(!cpi->extra_fragments) { EDeleteFragmentInfo(cpi); return FALSE; }
-     
-     ...are not useful.  It's true that many platforms follow this
-     malloc behavior, but many do not.  The more modern malloc
-     strategy is only to allocate virtual pages, which are not mapped
-     until the memory on that page is touched.  At *that* point, if
-     the machine is out of heap, the page fails to be mapped and a
-     SEGV is generated.
+  if(cpi->BlockCodedFlags) _ogg_free(cpi->BlockCodedFlags);
+  cpi->BlockCodedFlags = 0;
 
-     That means that if we want to deal with out of memory conditions,
-     we *must* be prepared to process a SEGV.  If we implement the
-     SEGV handler, there's no reason to to check malloc return; it is
-     a waste of code. */
-
-  cpi->RunHuffIndices =
-    _ogg_malloc(cpi->frag_total*
-                sizeof(*cpi->RunHuffIndices));
-  cpi->BlockCodedFlags =
-    _ogg_malloc(cpi->frag_total*
-                sizeof(*cpi->BlockCodedFlags));
-  cpi->ModeList =
-    _ogg_malloc(cpi->frag_total*
-                sizeof(*cpi->ModeList));
-  cpi->MVList =
-    _ogg_malloc(cpi->frag_total*
-                sizeof(*cpi->MVList));
-
-  cpi->CodedBlockList =
-    _ogg_malloc(cpi->frag_total * sizeof(*cpi->CodedBlockList));
-
-}
-
-void ClearFrameInfo(CP_INSTANCE *cpi){
-  if(cpi->yuvptr)
-    _ogg_free(cpi->yuvptr);
-  cpi->yuvptr = 0;
-
-  if(cpi->OptimisedTokenListEb )
-    _ogg_free(cpi->OptimisedTokenListEb);
+  if(cpi->OptimisedTokenListEb ) _ogg_free(cpi->OptimisedTokenListEb);
   cpi->OptimisedTokenListEb = 0;
 
-  if(cpi->OptimisedTokenList )
-    _ogg_free(cpi->OptimisedTokenList);
+  if(cpi->OptimisedTokenList ) _ogg_free(cpi->OptimisedTokenList);
   cpi->OptimisedTokenList = 0;
 
-  if(cpi->OptimisedTokenListHi )
-    _ogg_free(cpi->OptimisedTokenListHi);
+  if(cpi->OptimisedTokenListHi ) _ogg_free(cpi->OptimisedTokenListHi);
   cpi->OptimisedTokenListHi = 0;
 
-  if(cpi->OptimisedTokenListPl )
-    _ogg_free(cpi->OptimisedTokenListPl);
+  if(cpi->OptimisedTokenListPl ) _ogg_free(cpi->OptimisedTokenListPl);
   cpi->OptimisedTokenListPl = 0;
 
-  if(cpi->frag[0])_ogg_free(cpi->frag[0]);
-  if(cpi->macro)_ogg_free(cpi->macro);
-  if(cpi->super[0])_ogg_free(cpi->super[0]);
+  if(cpi->frag[0]) _ogg_free(cpi->frag[0]);
   cpi->frag[0] = 0;
   cpi->frag[1] = 0;
   cpi->frag[2] = 0;
+
+  if(cpi->macro) _ogg_free(cpi->macro);
   cpi->macro = 0;
+
+  if(cpi->super[0]) _ogg_free(cpi->super[0]);
   cpi->super[0] = 0;
   cpi->super[1] = 0;
   cpi->super[2] = 0;
 
-  if(cpi->LastFrameRecon )
-    _ogg_free(cpi->LastFrameRecon );
-  if(cpi->GoldenFrame)
-    _ogg_free(cpi->GoldenFrame);
-  if(cpi->ThisFrameRecon)
-    _ogg_free(cpi->ThisFrameRecon);
-
-  cpi->LastFrameRecon = 0;
-  cpi->GoldenFrame = 0;
-  cpi->ThisFrameRecon = 0;
 }
 
-static void InitFrameInfo(CP_INSTANCE *cpi, unsigned int FrameSize){
-  /* clear any existing info */
-  ClearFrameInfo(cpi);
+/* A note to people reading and wondering why malloc returns aren't
+   checked:
+   
+   lines like the following that implement a general strategy of
+   'check the return of malloc; a zero pointer means we're out of
+   memory!'...:
+   
+   if(!cpi->extra_fragments) { EDeleteFragmentInfo(cpi); return FALSE; }
+   
+   ...are not useful.  It's true that many platforms follow this
+   malloc behavior, but many do not.  The more modern malloc
+   strategy is only to allocate virtual pages, which are not mapped
+   until the memory on that page is touched.  At *that* point, if
+   the machine is out of heap, the page fails to be mapped and a
+   SEGV is generated.
+   
+   That means that if we want to deal with out of memory conditions,
+   we *must* be prepared to process a SEGV.  If we implement the
+   SEGV handler, there's no reason to to check malloc return; it is
+   a waste of code. */
 
-  /* allocate frames */
-  cpi->LastFrameRecon =
-    _ogg_malloc(FrameSize*sizeof(*cpi->LastFrameRecon));
+void InitFrameInfo(CP_INSTANCE *cpi){
+  int FrameSize;
 
-  cpi->GoldenFrame =
-    _ogg_malloc(FrameSize*sizeof(*cpi->GoldenFrame));
+  cpi->stride[0] = (cpi->info.width + STRIDE_EXTRA);
+  cpi->stride[1] = (cpi->info.width + STRIDE_EXTRA) / 2;
+  cpi->stride[2] = (cpi->info.width + STRIDE_EXTRA) / 2;
 
-  cpi->ThisFrameRecon =
-    _ogg_malloc(FrameSize*sizeof(*cpi->ThisFrameRecon));
+  {
+    ogg_uint32_t ry_size = cpi->stride[0] * (cpi->info.height + STRIDE_EXTRA);
+    ogg_uint32_t ruv_size = ry_size / 4;
+    FrameSize = ry_size + 2 * ruv_size;
 
-  /* allocate frames */
-  cpi->yuvptr =
-    _ogg_malloc(FrameSize*
-                sizeof(*cpi->yuvptr));
-  cpi->OptimisedTokenListEb =
-    _ogg_malloc(FrameSize*
-                sizeof(*cpi->OptimisedTokenListEb));
-  cpi->OptimisedTokenList =
-    _ogg_malloc(FrameSize*
-                sizeof(*cpi->OptimisedTokenList));
-  cpi->OptimisedTokenListHi =
-    _ogg_malloc(FrameSize*
-                sizeof(*cpi->OptimisedTokenListHi));
-  cpi->OptimisedTokenListPl =
-    _ogg_malloc(FrameSize*
-                sizeof(*cpi->OptimisedTokenListPl));
+    cpi->offset[0] = (cpi->stride[0] * UMV_BORDER) + UMV_BORDER;
+    cpi->offset[1] = ry_size + cpi->stride[1] * (UMV_BORDER/2) + (UMV_BORDER/2);
+    cpi->offset[2] = ry_size + ruv_size + cpi->stride[2] * (UMV_BORDER/2) + (UMV_BORDER/2);
+  }
 
-  /* new block abstraction setup... babysteps... */
   cpi->frag_h[0] = (cpi->info.width >> 3);
   cpi->frag_v[0] = (cpi->info.height >> 3);
   cpi->frag_n[0] = cpi->frag_h[0] * cpi->frag_v[0];
@@ -288,28 +237,42 @@
     }
   }
 
-}
+  /* allocate frames */
+  cpi->frame = _ogg_malloc(FrameSize*sizeof(*cpi->frame));
+  cpi->lastrecon = _ogg_malloc(FrameSize*sizeof(*cpi->lastrecon));
+  cpi->golden = _ogg_malloc(FrameSize*sizeof(*cpi->golden));
+  cpi->recon = _ogg_malloc(FrameSize*sizeof(*cpi->recon));
 
-void InitFrameDetails(CP_INSTANCE *cpi){
-  int FrameSize;
+  cpi->OptimisedTokenListEb =
+    _ogg_malloc(FrameSize*
+                sizeof(*cpi->OptimisedTokenListEb));
+  cpi->OptimisedTokenList =
+    _ogg_malloc(FrameSize*
+                sizeof(*cpi->OptimisedTokenList));
+  cpi->OptimisedTokenListHi =
+    _ogg_malloc(FrameSize*
+                sizeof(*cpi->OptimisedTokenListHi));
+  cpi->OptimisedTokenListPl =
+    _ogg_malloc(FrameSize*
+                sizeof(*cpi->OptimisedTokenListPl));
 
-  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;
+  /* misc */
+  cpi->RunHuffIndices =
+    _ogg_malloc(cpi->frag_total*
+                sizeof(*cpi->RunHuffIndices));
+  cpi->BlockCodedFlags =
+    _ogg_malloc(cpi->frag_total*
+                sizeof(*cpi->BlockCodedFlags));
+  cpi->ModeList =
+    _ogg_malloc(cpi->frag_total*
+                sizeof(*cpi->ModeList));
+  cpi->MVList =
+    _ogg_malloc(cpi->frag_total*
+                sizeof(*cpi->MVList));
 
-  {
-    ogg_uint32_t ry_size = cpi->recon_stride[0] * (cpi->info.height + STRIDE_EXTRA);
-    ogg_uint32_t ruv_size = ry_size / 4;
-    FrameSize = ry_size + 2 * ruv_size;
+  cpi->CodedBlockList =
+    _ogg_malloc(cpi->frag_total * sizeof(*cpi->CodedBlockList));
 
-    cpi->recon_offset[0] = (cpi->recon_stride[0] * UMV_BORDER) + UMV_BORDER;
-    cpi->recon_offset[1] = ry_size + cpi->recon_stride[1] * (UMV_BORDER/2) + (UMV_BORDER/2);
-    cpi->recon_offset[2] = ry_size + ruv_size + cpi->recon_stride[2] * (UMV_BORDER/2) + (UMV_BORDER/2);
-  }
-
-  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-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/mcomp.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -24,7 +24,7 @@
   int i;
   int SearchSite=0;
   int Len;
-  int LineStepY = cpi->recon_stride[0];
+  int LineStepY = cpi->stride[0];
 
   Len=((MAX_MV_EXTENT/2)+1)/2;
 
@@ -98,21 +98,19 @@
 static ogg_uint32_t GetInterErr (CP_INSTANCE *cpi, 
 				 unsigned char * NewDataPtr,
 				 unsigned char * RefDataPtr1,
-				 unsigned char * RefDataPtr2,
-				 ogg_uint32_t PixelsPerLine ) {
+				 unsigned char * RefDataPtr2 ) {
   ogg_int32_t   DiffVal;
   ogg_int32_t   RefOffset = (int)(RefDataPtr1 - RefDataPtr2);
-  ogg_uint32_t  RefPixelsPerLine = PixelsPerLine + STRIDE_EXTRA;
 
   /* Mode of interpolation chosen based upon on the offset of the
      second reference pointer */
   if ( RefOffset == 0 ) {
-    DiffVal = dsp_inter8x8_err (cpi->dsp, NewDataPtr, PixelsPerLine,
-              RefDataPtr1, RefPixelsPerLine);
+    DiffVal = dsp_inter8x8_err (cpi->dsp, NewDataPtr,
+				RefDataPtr1, cpi->stride[0]);
   }else{
-    DiffVal = dsp_inter8x8_err_xy2 (cpi->dsp, NewDataPtr, PixelsPerLine,
-              RefDataPtr1, 
-              RefDataPtr2, RefPixelsPerLine);
+    DiffVal = dsp_inter8x8_err_xy2 (cpi->dsp, NewDataPtr, 
+				    RefDataPtr1, RefDataPtr2, 
+				    cpi->stride[0]);
   }
 
   /* Compute and return population variance as mis-match metric. */
@@ -123,30 +121,29 @@
 					     unsigned char * SrcData,
 					     unsigned char * RefDataPtr1,
 					     unsigned char * RefDataPtr2,
-					     ogg_uint32_t PixelsPerLine,
 					     ogg_uint32_t ErrorSoFar,
 					     ogg_uint32_t BestSoFar ) {
   
   ogg_uint32_t  DiffVal = ErrorSoFar;
   ogg_int32_t   RefOffset = (int)(RefDataPtr1 - RefDataPtr2);
-  ogg_uint32_t  RefPixelsPerLine = PixelsPerLine + STRIDE_EXTRA;
-
+  
   if ( RefOffset == 0 ) {
     /* Simple case as for non 0.5 pixel */
-    DiffVal += dsp_sad8x8 (cpi->dsp, SrcData, PixelsPerLine, 
-                   RefDataPtr1, RefPixelsPerLine);
+    DiffVal += dsp_sad8x8 (cpi->dsp, SrcData,
+			   RefDataPtr1, cpi->stride[0]);
   } else  {
-    DiffVal += dsp_sad8x8_xy2_thres (cpi->dsp, SrcData, PixelsPerLine, 
-                   RefDataPtr1, 
-                   RefDataPtr2, RefPixelsPerLine, BestSoFar);
+    DiffVal += dsp_sad8x8_xy2_thres (cpi->dsp, SrcData,
+				     RefDataPtr1, 
+				     RefDataPtr2, 
+				     cpi->stride[0],
+				     BestSoFar);
   }
 
   return DiffVal;
 }
 
 ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, 
-			      macroblock_t *mp,
-                              ogg_uint32_t PixelsPerLine ) {
+			      macroblock_t *mp){
 
   ogg_uint32_t  IntraError = 0;
   dsp_save_fpu (cpi->dsp);
@@ -154,13 +151,13 @@
   /* Add together the intra errors for those blocks in the macro block
      that are coded (Y only) */
   if ( mp->y[0] && mp->y[0]->coded )
-    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->yuvptr[mp->y[0]->raw_index],PixelsPerLine);
+    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[0]->buffer_index],cpi->stride[0]);
   if ( mp->y[1] && mp->y[1]->coded )
-    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->yuvptr[mp->y[1]->raw_index],PixelsPerLine);
+    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[1]->buffer_index],cpi->stride[0]);
   if ( mp->y[2] && mp->y[2]->coded )
-    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->yuvptr[mp->y[2]->raw_index],PixelsPerLine);
+    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[2]->buffer_index],cpi->stride[0]);
   if ( mp->y[3] && mp->y[3]->coded )
-    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->yuvptr[mp->y[3]->raw_index],PixelsPerLine);
+    IntraError += dsp_intra8x8_err (cpi->dsp, &cpi->frame[mp->y[3]->buffer_index],cpi->stride[0]);
 
   dsp_restore_fpu (cpi->dsp);
   return IntraError;
@@ -171,10 +168,9 @@
                               unsigned char * RefPtr,
 			      macroblock_t *mp,
                               ogg_int32_t LastXMV,
-                              ogg_int32_t LastYMV,
-                              ogg_uint32_t PixelsPerLine ) {
-  ogg_uint32_t  RefPixelsPerLine = cpi->recon_stride[0];
-  ogg_int32_t   RefPixelOffset = ((LastYMV/2) * RefPixelsPerLine) + (LastXMV/2);
+                              ogg_int32_t LastYMV){
+  ogg_uint32_t  PixelsPerLine = cpi->stride[0];
+  ogg_int32_t   RefPixelOffset = ((LastYMV/2) * PixelsPerLine) + (LastXMV/2);
   ogg_int32_t   RefPtr2Offset = 0;
   
   ogg_uint32_t  InterError = 0;
@@ -193,40 +189,36 @@
   }
   if ( LastYMV % 2 ) {
     if ( LastYMV > 0 )
-      RefPtr2Offset += RefPixelsPerLine;
+      RefPtr2Offset += PixelsPerLine;
     else
-      RefPtr2Offset -= RefPixelsPerLine;
+      RefPtr2Offset -= PixelsPerLine;
   }
 
   /* Add together the errors for those blocks in the macro block that
      are coded (Y only) */
   if ( mp->y[0] && mp->y[0]->coded ) {
-    SrcPtr1 = &SrcPtr[mp->y[0]->raw_index];
-    RefPtr1 = &RefPtr[mp->y[0]->recon_index + RefPixelOffset];
-    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1,
-                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    SrcPtr1 = &SrcPtr[mp->y[0]->buffer_index];
+    RefPtr1 = &RefPtr[mp->y[0]->buffer_index + RefPixelOffset];
+    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
   }
 
   if ( mp->y[1] && mp->y[1]->coded ) {
-    SrcPtr1 = &SrcPtr[mp->y[1]->raw_index];
-    RefPtr1 = &RefPtr[mp->y[1]->recon_index + RefPixelOffset];
-    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1,
-			      &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    SrcPtr1 = &SrcPtr[mp->y[1]->buffer_index];
+    RefPtr1 = &RefPtr[mp->y[1]->buffer_index + RefPixelOffset];
+    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
     
   }
   
   if ( mp->y[2] && mp->y[2]->coded ) {
-    SrcPtr1 = &SrcPtr[mp->y[2]->raw_index];
-    RefPtr1 = &RefPtr[mp->y[2]->recon_index + RefPixelOffset];
-    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1,
-                                 &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    SrcPtr1 = &SrcPtr[mp->y[2]->buffer_index];
+    RefPtr1 = &RefPtr[mp->y[2]->buffer_index + RefPixelOffset];
+    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
   }
 
   if ( mp->y[3] && mp->y[3]->coded ) {
-    SrcPtr1 = &SrcPtr[mp->y[3]->raw_index];
-    RefPtr1 = &RefPtr[mp->y[3]->recon_index + RefPixelOffset];
-    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1,
-			      &RefPtr1[RefPtr2Offset], PixelsPerLine );
+    SrcPtr1 = &SrcPtr[mp->y[3]->buffer_index];
+    RefPtr1 = &RefPtr[mp->y[3]->buffer_index + RefPixelOffset];
+    InterError += GetInterErr(cpi, SrcPtr1, RefPtr1, &RefPtr1[RefPtr2Offset] );
   }
   
   dsp_restore_fpu (cpi->dsp);
@@ -235,9 +227,8 @@
 }
 
 ogg_uint32_t GetMBMVInterError (CP_INSTANCE *cpi,
-                                unsigned char * RefFramePtr,
+                                unsigned char *RefFramePtr,
 				macroblock_t *mp,
-                                ogg_uint32_t PixelsPerLine,
                                 ogg_int32_t *MVPixelOffset,
                                 mv_t *MV ) {
   ogg_uint32_t  Error = 0;
@@ -272,28 +263,28 @@
   disp[3] = (mp->y[3] && mp->y[3]->coded);
 
   if(disp[0]){
-    SrcPtr[0] = &cpi->yuvptr[mp->y[0]->raw_index];
-    RefPtr[0] = &RefFramePtr[mp->y[0]->recon_index];
-    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], PixelsPerLine, RefPtr[0],
-                         PixelsPerLine + STRIDE_EXTRA);
+    SrcPtr[0] = &cpi->frame[mp->y[0]->buffer_index];
+    RefPtr[0] = &RefFramePtr[mp->y[0]->buffer_index];
+    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], RefPtr[0],
+                         cpi->stride[0]);
   }
   if(disp[1]){
-    SrcPtr[1] = &cpi->yuvptr[mp->y[1]->raw_index];
-    RefPtr[1] = &RefFramePtr[mp->y[1]->recon_index];
-    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[1], PixelsPerLine, RefPtr[1],
-                         PixelsPerLine + STRIDE_EXTRA);
+    SrcPtr[1] = &cpi->frame[mp->y[1]->buffer_index];
+    RefPtr[1] = &RefFramePtr[mp->y[1]->buffer_index];
+    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[1], RefPtr[1],
+                         cpi->stride[0]);
   }
   if(disp[2]){
-    SrcPtr[2] = &cpi->yuvptr[mp->y[2]->raw_index];
-    RefPtr[2] = &RefFramePtr[mp->y[2]->recon_index];
-    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[2], PixelsPerLine, RefPtr[2],
-                         PixelsPerLine + STRIDE_EXTRA);
+    SrcPtr[2] = &cpi->frame[mp->y[2]->buffer_index];
+    RefPtr[2] = &RefFramePtr[mp->y[2]->buffer_index];
+    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[2], RefPtr[2],
+                         cpi->stride[0]);
   }
   if(disp[3]){
-    SrcPtr[3] = &cpi->yuvptr[mp->y[3]->raw_index];
-    RefPtr[3] = &RefFramePtr[mp->y[3]->recon_index];
-    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[3], PixelsPerLine, RefPtr[3],
-                         PixelsPerLine + STRIDE_EXTRA);
+    SrcPtr[3] = &cpi->frame[mp->y[3]->buffer_index];
+    RefPtr[3] = &RefFramePtr[mp->y[3]->buffer_index];
+    Error += dsp_sad8x8 (cpi->dsp, SrcPtr[3], RefPtr[3],
+                         cpi->stride[0]);
   }
 
   /* Set starting values to results of 0, 0 vector. */
@@ -314,20 +305,20 @@
       
       /* Get the score for the current offset */
       if ( disp[0] ) 
-        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], PixelsPerLine, RefPtr[0] + loff,
-                             PixelsPerLine + STRIDE_EXTRA);
+        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], RefPtr[0] + loff,
+                             cpi->stride[0]);
       
       if ( disp[1] && (Error < MinError) ) 
-        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[1], PixelsPerLine, RefPtr[1] + loff,
-				   PixelsPerLine + STRIDE_EXTRA, MinError);
+        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[1], RefPtr[1] + loff,
+				   cpi->stride[0], MinError);
       
       if ( disp[2] && (Error < MinError) ) 
-        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[2], PixelsPerLine, RefPtr[2] + loff,
-				   PixelsPerLine + STRIDE_EXTRA, MinError);
+        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[2], RefPtr[2] + loff,
+				   cpi->stride[0],  MinError);
       
       if ( disp[3] && (Error < MinError) ) 
-        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[3], PixelsPerLine, RefPtr[3] + loff,
-				   PixelsPerLine + STRIDE_EXTRA, MinError);
+        Error += dsp_sad8x8_thres (cpi->dsp, SrcPtr[3], RefPtr[3] + loff,
+				   cpi->stride[0],  MinError);
 
       if ( Error < MinError ) {
         /* Remember best match. */
@@ -366,7 +357,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[0], RefDataPtr1, RefDataPtr2,
-                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
+                         HalfPixelError, BestHalfPixelError );
     }
 
     if ( disp[1]  && (HalfPixelError < BestHalfPixelError) ) {
@@ -374,7 +365,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[1], RefDataPtr1, RefDataPtr2,
-                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
+                         HalfPixelError, BestHalfPixelError );
     }
 
     if ( disp[2] && (HalfPixelError < BestHalfPixelError) ) {
@@ -382,7 +373,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[2], RefDataPtr1, RefDataPtr2,
-                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
+                         HalfPixelError, BestHalfPixelError );
     }
 
     if ( disp[3] && (HalfPixelError < BestHalfPixelError) ) { 
@@ -390,7 +381,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[3], RefDataPtr1, RefDataPtr2,
-                         PixelsPerLine, HalfPixelError, BestHalfPixelError );
+                         HalfPixelError, BestHalfPixelError );
     }
 
     if ( HalfPixelError < BestHalfPixelError ) {
@@ -404,8 +395,8 @@
   MV->y += cpi->HalfPixelYOffset[BestHalfOffset];
 
   /* Get the error score for the chosen 1/2 pixel offset as a variance. */
-  InterMVError = GetMBInterError( cpi, cpi->yuvptr, RefFramePtr, mp,
-                                  MV->x, MV->y, PixelsPerLine );
+  InterMVError = GetMBInterError( cpi, cpi->frame, RefFramePtr, mp,
+                                  MV->x, MV->y);
   
   dsp_restore_fpu (cpi->dsp);
   
@@ -416,7 +407,6 @@
 ogg_uint32_t GetMBMVExhaustiveSearch (CP_INSTANCE *cpi,
                                       unsigned char *RefFramePtr,
 				      macroblock_t *mp,
-                                      ogg_uint32_t PixelsPerLine,
                                       mv_t *MV ) {
   ogg_uint32_t  Error = 0;
   ogg_uint32_t  MinError = HUGE_ERROR;
@@ -449,23 +439,23 @@
   disp[3] = (mp->y[3] && mp->y[3]->coded);
 
   if(disp[0]){
-    SrcPtr[0] = &cpi->yuvptr[mp->y[0]->raw_index];
-    RefPtr[0] = &RefFramePtr[mp->y[0]->recon_index];
+    SrcPtr[0] = &cpi->frame[mp->y[0]->buffer_index];
+    RefPtr[0] = &RefFramePtr[mp->y[0]->buffer_index];
   }
   if(disp[1]){
-    SrcPtr[1] = &cpi->yuvptr[mp->y[1]->raw_index];
-    RefPtr[1] = &RefFramePtr[mp->y[1]->recon_index];
+    SrcPtr[1] = &cpi->frame[mp->y[1]->buffer_index];
+    RefPtr[1] = &RefFramePtr[mp->y[1]->buffer_index];
   }
   if(disp[2]){
-    SrcPtr[2] = &cpi->yuvptr[mp->y[2]->raw_index];
-    RefPtr[2] = &RefFramePtr[mp->y[2]->recon_index];
+    SrcPtr[2] = &cpi->frame[mp->y[2]->buffer_index];
+    RefPtr[2] = &RefFramePtr[mp->y[2]->buffer_index];
   }
   if(disp[3]){
-    SrcPtr[3] = &cpi->yuvptr[mp->y[3]->raw_index];
-    RefPtr[3] = &RefFramePtr[mp->y[3]->recon_index];
+    SrcPtr[3] = &cpi->frame[mp->y[3]->buffer_index];
+    RefPtr[3] = &RefFramePtr[mp->y[3]->buffer_index];
   }
 
-  off = - ((MAX_MV_EXTENT/2) * cpi->recon_stride[0]) - (MAX_MV_EXTENT/2);
+  off = - ((MAX_MV_EXTENT/2) * cpi->stride[0]) - (MAX_MV_EXTENT/2);
 
   /* Search each pixel alligned site */
   for ( i = 0; i < (ogg_int32_t)MAX_MV_EXTENT; i ++ ) {
@@ -476,22 +466,14 @@
       Error = 0;
 
       /* Summ errors for each block. */
-      if ( disp[0] ) {
-        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], PixelsPerLine, RefPtr[0]+loff,
-                             PixelsPerLine + STRIDE_EXTRA);
-      }
-      if ( disp[1] ){
-        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[1], PixelsPerLine, RefPtr[1]+loff,
-                             PixelsPerLine + STRIDE_EXTRA);
-      }
-      if ( disp[2] ){
-        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[2], PixelsPerLine, RefPtr[2]+loff,
-                             PixelsPerLine + STRIDE_EXTRA);
-      }
-      if ( disp[3] ){
-        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[3], PixelsPerLine, RefPtr[3]+loff,
-                             PixelsPerLine + STRIDE_EXTRA);
-      }
+      if ( disp[0] ) 
+        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[0], RefPtr[0]+loff, cpi->stride[0]);
+      if ( disp[1] )
+        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[1], RefPtr[1]+loff, cpi->stride[0]);
+      if ( disp[2] )
+        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[2], RefPtr[2]+loff, cpi->stride[0]);
+      if ( disp[3] )
+        Error += dsp_sad8x8 (cpi->dsp, SrcPtr[3], RefPtr[3]+loff, cpi->stride[0]);
       
       /* Was this the best so far */
       if ( Error < MinError ) {
@@ -506,7 +488,7 @@
     }
 
     /* Move on to the next row. */
-    off += cpi->recon_stride[0];
+    off += cpi->stride[0];
 
   }
 
@@ -527,7 +509,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[0], RefDataPtr1, RefDataPtr2,
-				PixelsPerLine, HalfPixelError, BestHalfPixelError );
+				HalfPixelError, BestHalfPixelError );
     }
 
     if ( disp[1]  && (HalfPixelError < BestHalfPixelError) ) {
@@ -535,7 +517,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[1], RefDataPtr1, RefDataPtr2,
-				PixelsPerLine, HalfPixelError, BestHalfPixelError );
+				HalfPixelError, BestHalfPixelError );
     }
     
     if ( disp[2] && (HalfPixelError < BestHalfPixelError) ) {
@@ -543,7 +525,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[2], RefDataPtr1, RefDataPtr2,
-				PixelsPerLine, HalfPixelError, BestHalfPixelError );
+				HalfPixelError, BestHalfPixelError );
     }
     
     if ( disp[3] && (HalfPixelError < BestHalfPixelError) ) {
@@ -551,7 +533,7 @@
       RefDataPtr2 = RefDataPtr1 + cpi->HalfPixelRef2Offset[i];
       HalfPixelError =
         GetHalfPixelSumAbsDiffs(cpi, SrcPtr[3], RefDataPtr1, RefDataPtr2,
-				PixelsPerLine, HalfPixelError, BestHalfPixelError );
+				HalfPixelError, BestHalfPixelError );
     }
 
     if ( HalfPixelError < BestHalfPixelError ){
@@ -565,8 +547,8 @@
   MV->y += cpi->HalfPixelYOffset[BestHalfOffset];
 
   /* Get the error score for the chosen 1/2 pixel offset as a variance. */
-  InterMVError = GetMBInterError( cpi, cpi->yuvptr, RefFramePtr, mp,
-                                  MV->x, MV->y, PixelsPerLine );
+  InterMVError = GetMBInterError( cpi, cpi->frame, RefFramePtr, mp,
+                                  MV->x, MV->y );
 
   dsp_restore_fpu (cpi->dsp);
 
@@ -577,7 +559,6 @@
 static ogg_uint32_t GetBMVExhaustiveSearch (CP_INSTANCE *cpi,
                                             unsigned char *RefFramePtr,
 					    fragment_t *fp,
-                                            ogg_uint32_t PixelsPerLine,
                                             mv_t *MV ) {
   ogg_uint32_t  Error = 0;
   ogg_uint32_t  MinError = HUGE_ERROR;
@@ -598,9 +579,9 @@
   unsigned char * RefDataPtr2;
 
   /* Set up the source pointer for the block. */
-  SrcPtr = &cpi->yuvptr[fp->raw_index];
-  RefPtr = &RefFramePtr[fp->recon_index];
-  RefPtr = RefPtr - ((MAX_MV_EXTENT/2) * cpi->recon_stride[0]) - (MAX_MV_EXTENT/2);
+  SrcPtr = &cpi->frame[fp->buffer_index];
+  RefPtr = &RefFramePtr[fp->buffer_index];
+  RefPtr = RefPtr - ((MAX_MV_EXTENT/2) * cpi->stride[0]) - (MAX_MV_EXTENT/2);
   
   /* Search each pixel alligned site */
   for ( i = 0; i < (ogg_int32_t)MAX_MV_EXTENT; i ++ ) {
@@ -609,8 +590,7 @@
     
     for ( j = 0; j < (ogg_int32_t)MAX_MV_EXTENT; j++ ){
       /* Get the block error score. */
-      Error = dsp_sad8x8 (cpi->dsp, SrcPtr, PixelsPerLine, CandidateBlockPtr,
-                             PixelsPerLine + STRIDE_EXTRA);
+      Error = dsp_sad8x8 (cpi->dsp, SrcPtr, CandidateBlockPtr, cpi->stride[0] );
 
       /* Was this the best so far */
       if ( Error < MinError ) {
@@ -625,7 +605,7 @@
     }
 
     /* Move on to the next row. */
-    RefPtr += cpi->recon_stride[0];
+    RefPtr += cpi->stride[0];
   }
 
   /* Factor vectors to 1/2 pixel resoultion. */
@@ -641,7 +621,7 @@
     RefDataPtr2 = BestBlockPtr + cpi->HalfPixelRef2Offset[i];
     HalfPixelError =
       GetHalfPixelSumAbsDiffs(cpi, SrcPtr, BestBlockPtr, RefDataPtr2,
-			      PixelsPerLine, 0, BestHalfPixelError );
+			      0, BestHalfPixelError );
     
     if ( HalfPixelError < BestHalfPixelError ){
       BestHalfOffset = (unsigned char)i;
@@ -657,7 +637,7 @@
   RefDataPtr2 = BestBlockPtr + cpi->HalfPixelRef2Offset[BestHalfOffset];
 
   InterMVError =
-    GetInterErr(cpi, SrcPtr, BestBlockPtr, RefDataPtr2, PixelsPerLine );
+    GetInterErr(cpi, SrcPtr, BestBlockPtr, RefDataPtr2 );
 
   /* Return score of best matching block. */
   return InterMVError;
@@ -666,7 +646,6 @@
 ogg_uint32_t GetFOURMVExhaustiveSearch (CP_INSTANCE *cpi,
                                         unsigned char * RefFramePtr,
 					macroblock_t *mp,
-                                        ogg_uint32_t PixelsPerLine,
                                         mv_t *MV ) {
   ogg_uint32_t  InterMVError;
   dsp_save_fpu (cpi->dsp);
@@ -684,17 +663,13 @@
     
     /* Get the error component from each coded block */
     InterMVError +=
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[0],
-                             PixelsPerLine, &(MV[0]) );
+      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[0], &(MV[0]) );
     InterMVError +=
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[1],
-                             PixelsPerLine, &(MV[1]) );
+      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[1], &(MV[1]) );
     InterMVError +=
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[2],
-                             PixelsPerLine, &(MV[2]) );
+      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[2], &(MV[2]) );
     InterMVError +=
-      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[3],
-                             PixelsPerLine, &(MV[3]) );
+      GetBMVExhaustiveSearch(cpi, RefFramePtr, mp->y[3], &(MV[3]) );
   }else{
     InterMVError = HUGE_ERROR;
   }

Modified: branches/theora-thusnelda/lib/enc/x86_32/dsp_mmx.c
===================================================================
--- branches/theora-thusnelda/lib/enc/x86_32/dsp_mmx.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/x86_32/dsp_mmx.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -46,11 +46,10 @@
   /* Increment pointers */                                                    \
   "  add         $16, %2           \n\t"                                      \
   "  add         %3, %0           \n\t"                                       \
-  "  add         %4, %1           \n\t"
+  "  add         %3, %1           \n\t"
 
 static void sub8x8__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr,
-                  ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine,
-                  ogg_uint32_t ReconPixelsPerLine) 
+			 ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine)
 {
   __asm__ __volatile__ (
     "  .p2align 4                   \n\t"
@@ -67,8 +66,7 @@
      : "+r" (FiltPtr),
        "+r" (ReconPtr),
        "+r" (DctInputPtr)
-     : "m" (PixelsPerLine),
-       "m" (ReconPixelsPerLine) 
+     : "m" (PixelsPerLine)
      : "memory"
   );
 }
@@ -90,7 +88,7 @@
 
 
 static void sub8x8_128__mmx (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
-                      ogg_uint32_t PixelsPerLine) 
+			     ogg_uint32_t PixelsPerLine) 
 {
   __asm__ __volatile__ (
     "  .p2align 4                   \n\t"
@@ -139,14 +137,13 @@
   /* Increment pointers */                                                    \
   "  add         $16, %3           \n\t"                                      \
   "  add         %4, %0           \n\t"                                       \
-  "  add         %5, %1           \n\t"                                       \
-  "  add         %5, %2           \n\t"  
+  "  add         %4, %1           \n\t"                                       \
+  "  add         %4, %2           \n\t"  
 
 
 static void sub8x8avg2__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr1,
-                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
-                     ogg_uint32_t PixelsPerLine,
-                     ogg_uint32_t ReconPixelsPerLine) 
+			     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+			     ogg_uint32_t PixelsPerLine)
 {
   __asm__ __volatile__ (
     "  .p2align 4                   \n\t"
@@ -165,7 +162,6 @@
        "+r" (ReconPtr2),
        "+r" (DctInputPtr)
      : "m" (PixelsPerLine),
-       "m" (ReconPixelsPerLine) 
      : "memory"
   );
 }
@@ -314,10 +310,10 @@
   "  punpckhbw   %%mm6, %%mm1     \n\t"	/* unpack high four bytes to higher precision */ \
   "  add         %3, %1           \n\t"	/* Inc pointer into the new data */   \
   "  paddw       %%mm1, %%mm7     \n\t"	/* accumulate difference... */        \
-  "  add         %4, %2           \n\t"	/* Inc pointer into ref data */  
+  "  add         %3, %2           \n\t"	/* Inc pointer into ref data */  
 
-static ogg_uint32_t sad8x8__mmx (unsigned char *ptr1, ogg_uint32_t stride1,
-		       	    unsigned char *ptr2, ogg_uint32_t stride2)
+static ogg_uint32_t sad8x8__mmx (unsigned char *ptr1, unsigned char *ptr2, 
+				 ogg_uint32_t stride)
 {
   ogg_uint32_t  DiffVal;
 
@@ -345,25 +341,22 @@
      : "=m" (DiffVal),
        "+r" (ptr1), 
        "+r" (ptr2) 
-     : "r" (stride1),
-       "r" (stride2)
+     : "r" (stride1)
      : "memory"
   );
 
   return DiffVal;
 }
 
-static ogg_uint32_t sad8x8_thres__mmx (unsigned char *ptr1, ogg_uint32_t stride1,
-		       		  unsigned char *ptr2, ogg_uint32_t stride2, 
-			   	  ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_thres__mmx (unsigned char *ptr1, unsigned char *ptr2, ogg_uint32_t stride, 
+				       ogg_uint32_t thres)
 {
-  return sad8x8__mmx (ptr1, stride1, ptr2, stride2);
+  return sad8x8__mmx (ptr1, ptr2, stride);
 }
 
-static ogg_uint32_t sad8x8_xy2_thres__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                      unsigned char *RefDataPtr1,
-			              unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
-			              ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_xy2_thres__mmx (unsigned char *SrcData, unsigned char *RefDataPtr1,
+					   unsigned char *RefDataPtr2, ogg_uint32_t Stride,
+					   ogg_uint32_t thres)
 {
   ogg_uint32_t  DiffVal;
 
@@ -400,8 +393,8 @@
     "  punpckhbw   %%mm6, %%mm1     \n\t"	/* unpack high four bytes to higher precision */
     "  add         %4, %1           \n\t"	/* Inc pointer into the new data */
     "  paddw       %%mm1, %%mm7     \n\t"	/* accumulate difference... */
-    "  add         %5, %2           \n\t"	/* Inc pointer into ref data */
-    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %4, %2           \n\t"	/* Inc pointer into ref data */
+    "  add         %4, %3           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%edi            \n\t"
     "  jnz 1b                       \n\t"
@@ -419,8 +412,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1), 
        "+r" (RefDataPtr2) 
-     : "m" (SrcStride),
-       "m" (RefStride)
+     : "m" (SrcStride)
      : "edi", "memory"
   );
 
@@ -486,8 +478,8 @@
   return (( (XXSum<<6) - XSum*XSum ) );
 }
 
-static ogg_uint32_t inter8x8_err__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                 unsigned char *RefDataPtr, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err__mmx (unsigned char *SrcData, unsigned char *RefDataPtr, 
+				       ogg_uint32_t Stride)
 {
   ogg_uint32_t  XSum;
   ogg_uint32_t  XXSum;
@@ -523,7 +515,7 @@
     "  paddd       %%mm2, %%mm7     \n\t"
 
     "  add         %4, %2           \n\t"	/* Inc pointer into src data */
-    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %4, %3           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%edi            \n\t"
     "  jnz 1b                       \n\t"
@@ -547,8 +539,7 @@
        "=m" (XXSum),
        "+r" (SrcData), 
        "+r" (RefDataPtr) 
-     : "m" (SrcStride),
-       "m" (RefStride)
+     : "m" (Stride)
      : "edi", "memory"
   );
 
@@ -556,9 +547,8 @@
   return (( (XXSum<<6) - XSum*XSum ));
 }
 
-static ogg_uint32_t inter8x8_err_xy2__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                     unsigned char *RefDataPtr1,
-				     unsigned char *RefDataPtr2, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err_xy2__mmx (unsigned char *SrcData, unsigned char *RefDataPtr1,
+					   unsigned char *RefDataPtr2, ogg_uint32_t Stride)
 {
   ogg_uint32_t XSum;
   ogg_uint32_t XXSum;
@@ -605,8 +595,8 @@
     "  paddd       %%mm2, %%mm7     \n\t"
 
     "  add         %5, %2           \n\t"	/* Inc pointer into src data */
-    "  add         %6, %3           \n\t"	/* Inc pointer into ref data */
-    "  add         %6, %4           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %4           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%edi            \n\t"
     "  jnz 1b                       \n\t"
@@ -631,8 +621,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1),
        "+r" (RefDataPtr2) 
-     : "m" (SrcStride),
-       "m" (RefStride)
+     : "m" (Stride)
      : "edi", "memory"
   );
 

Modified: branches/theora-thusnelda/lib/enc/x86_32/dsp_mmxext.c
===================================================================
--- branches/theora-thusnelda/lib/enc/x86_32/dsp_mmxext.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/x86_32/dsp_mmxext.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -28,11 +28,11 @@
  "  psadbw %%mm1, %%mm0          \n\t" \
  "  add %3, %1                   \n\t"	/* Inc pointer into the new data */ \
  "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */ \
- "  add %4, %2                   \n\t"	/* Inc pointer into ref data */ 
+ "  add %3, %2                   \n\t"	/* Inc pointer into ref data */ 
 
 
-static ogg_uint32_t sad8x8__mmxext (unsigned char *ptr1, ogg_uint32_t stride1,
-		       	    unsigned char *ptr2, ogg_uint32_t stride2)
+static ogg_uint32_t sad8x8__mmxext (unsigned char *ptr1, unsigned char *ptr2, 
+				    ogg_uint32_t stride)
 {
   ogg_uint32_t  DiffVal;
 
@@ -57,8 +57,7 @@
      : "=r" (DiffVal),
        "+r" (ptr1), 
        "+r" (ptr2) 
-     : "r" (stride1),
-       "r" (stride2)
+     : "r" (stride)
      : "memory"
   );
 
@@ -71,12 +70,11 @@
   "  psadbw %%mm1, %%mm0          \n\t" \
   "  add %3, %1                   \n\t"	/* Inc pointer into the new data */ \
   "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */ \
-  "  add %4, %2                   \n\t"	/* Inc pointer into ref data */
+  "  add %3, %2                   \n\t"	/* Inc pointer into ref data */
 
 
-static ogg_uint32_t sad8x8_thres__mmxext (unsigned char *ptr1, ogg_uint32_t stride1,
-		       		  unsigned char *ptr2, ogg_uint32_t stride2, 
-			   	  ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_thres__mmxext (unsigned char *ptr1, unsigned char *ptr2, 
+					  ogg_uint32_t stride, ogg_uint32_t thres)
 {
   ogg_uint32_t  DiffVal;
 
@@ -98,8 +96,7 @@
      : "=r" (DiffVal),
        "+r" (ptr1), 
        "+r" (ptr2) 
-     : "r" (stride1),
-       "r" (stride2)
+    : "r" (stride)
      : "memory"
   );
 
@@ -115,14 +112,13 @@
  \
   "  add %4, %1                   \n\t"	/* Inc pointer into the new data */ \
   "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */ \
-  "  add %5, %2                   \n\t"	/* Inc pointer into ref data */ \
-  "  add %5, %3                   \n\t"	/* Inc pointer into ref data */
+  "  add %4, %2                   \n\t"	/* Inc pointer into ref data */ \
+  "  add %4, %3                   \n\t"	/* Inc pointer into ref data */
 
 
-static ogg_uint32_t sad8x8_xy2_thres__mmxext (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                      unsigned char *RefDataPtr1,
-			              unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
-			              ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_xy2_thres__mmxext (unsigned char *SrcData, unsigned char *RefDataPtr1,
+					      unsigned char *RefDataPtr2, ogg_uint32_t Stride,
+					      ogg_uint32_t thres)
 {
   ogg_uint32_t  DiffVal;
 
@@ -143,8 +139,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1), 
        "+r" (RefDataPtr2) 
-     : "m" (SrcStride),
-       "m" (RefStride)
+     : "m" (Stride)
      : "memory"
   );
 
@@ -180,7 +175,7 @@
 }
 
 static ogg_uint32_t col_sad8x8__mmxext (unsigned char *Src1, unsigned char *Src2,
-		                    ogg_uint32_t stride)
+					ogg_uint32_t stride)
 {
   ogg_uint32_t MaxSad;
 
@@ -256,9 +251,8 @@
   return MaxSad;
 }
 
-static ogg_uint32_t inter8x8_err_xy2__mmxext (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                     unsigned char *RefDataPtr1,
-				     unsigned char *RefDataPtr2, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err_xy2__mmxext (unsigned char *SrcData, unsigned char *RefDataPtr1,
+					      unsigned char *RefDataPtr2, ogg_uint32_t Stride)
 {
   ogg_uint32_t XSum;
   ogg_uint32_t XXSum;
@@ -299,8 +293,8 @@
     "  paddd       %%mm2, %%mm7     \n\t"
 
     "  add         %5, %2           \n\t"	/* Inc pointer into src data */
-    "  add         %6, %3           \n\t"	/* Inc pointer into ref data */
-    "  add         %6, %4           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %4           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%edi            \n\t"
     "  jnz 1b                       \n\t"
@@ -325,8 +319,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1),
        "+r" (RefDataPtr2) 
-     : "m" (SrcStride),
-       "m" (RefStride)
+     : "m" (Stride)
      : "edi", "memory"
   );
 

Modified: branches/theora-thusnelda/lib/enc/x86_32_vs/dsp_mmx.c
===================================================================
--- branches/theora-thusnelda/lib/enc/x86_32_vs/dsp_mmx.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/x86_32_vs/dsp_mmx.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -31,8 +31,7 @@
 static const ogg_int64_t V128 = 0x0080008000800080;
 
 static void sub8x8__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr,
-                  ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine,
-                  ogg_uint32_t ReconPixelsPerLine) 
+			 ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine)
 {
 
     //Make non-zero to use the C-version
@@ -52,7 +51,7 @@
 
     /* Start next row */
     FiltPtr += PixelsPerLine;
-    ReconPtr += ReconPixelsPerLine;
+    ReconPtr += PixelsPerLine;
     DctInputPtr += 8;
   }
 #else
@@ -85,7 +84,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 2 */
@@ -106,7 +105,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 3 */
@@ -127,7 +126,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 4 */
@@ -148,7 +147,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 5 */
@@ -169,7 +168,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 6 */
@@ -190,7 +189,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 7 */
@@ -211,7 +210,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
      /* ITERATION 8 */
@@ -232,7 +231,7 @@
         /* Increment pointers */
         add		edx, 16		
         add		eax, PixelsPerLine		
-        add		ebx, ReconPixelsPerLine
+        add		ebx, PixelsPerLine
 
 
 
@@ -244,7 +243,7 @@
 }
 
 static void sub8x8_128__mmx (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
-                      ogg_uint32_t PixelsPerLine) 
+			     ogg_uint32_t PixelsPerLine) 
 {
 
 #if 0
@@ -416,9 +415,8 @@
 
 
 static void sub8x8avg2__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr1,
-                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
-                     ogg_uint32_t PixelsPerLine,
-                     ogg_uint32_t ReconPixelsPerLine) 
+			     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+			     ogg_uint32_t PixelsPerLine)
 {
 
 #if 0
@@ -437,8 +435,8 @@
 
     /* Start next row */
     FiltPtr += PixelsPerLine;
-    ReconPtr1 += ReconPixelsPerLine;
-    ReconPtr2 += ReconPixelsPerLine;
+    ReconPtr1 += PixelsPerLine;
+    ReconPtr2 += PixelsPerLine;
     DctInputPtr += 8;
   }
 #else
@@ -479,8 +477,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 	
 
         /*  ITERATION 2 */	
@@ -509,8 +507,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 3 */	
@@ -539,8 +537,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 4 */	
@@ -569,8 +567,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 5 */	
@@ -599,8 +597,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 6 */	
@@ -629,8 +627,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 7 */	
@@ -659,8 +657,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
 
         /*  ITERATION 8 */	
@@ -689,8 +687,8 @@
 	        ;	/* Increment pointers */
         add		edx, 16		;	
         add		eax, PixelsPerLine		;	
-        add		ebx, ReconPixelsPerLine		;	
-        add		ecx, ReconPixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
 
     };
 

Modified: branches/theora-thusnelda/lib/enc/x86_64/dsp_mmx.c
===================================================================
--- branches/theora-thusnelda/lib/enc/x86_64/dsp_mmx.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/x86_64/dsp_mmx.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -31,8 +31,7 @@
 #define DSP_OP_ABS_DIFF(a,b) abs((((int)(a)) - ((int)(b))))
 
 static void sub8x8__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr,
-                  ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine,
-                  ogg_uint32_t ReconPixelsPerLine) 
+			 ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine) 
 {
   __asm__ __volatile__ (
     "  .balign 16                   \n\t"
@@ -57,20 +56,19 @@
     /* Increment pointers */
     "  add         $16, %2          \n\t"
     "  add         %3, %0           \n\t"
-    "  add         %4, %1           \n\t"
+    "  add         %3, %1           \n\t"
     ".endr                          \n\t"
 
      : "+r" (FiltPtr),
        "+r" (ReconPtr),
        "+r" (DctInputPtr)
-     : "r" ((ogg_uint64_t)PixelsPerLine),
-       "r" ((ogg_uint64_t)ReconPixelsPerLine) 
+     : "r" ((ogg_uint64_t)PixelsPerLine)
      : "memory"
   );
 }
 
 static void sub8x8_128__mmx (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
-                      ogg_uint32_t PixelsPerLine) 
+			     ogg_uint32_t PixelsPerLine) 
 {
   ogg_uint64_t ppl = PixelsPerLine;
 
@@ -105,9 +103,8 @@
 }
 
 static void sub8x8avg2__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr1,
-                     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
-                     ogg_uint32_t PixelsPerLine,
-                     ogg_uint32_t ReconPixelsPerLine) 
+			     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+			     ogg_uint32_t PixelsPerLine)
 {
   __asm__ __volatile__ (
     "  .balign 16                   \n\t"
@@ -140,16 +137,15 @@
     /* Increment pointers */
     "  add         $16, %3           \n\t"
     "  add         %4, %0           \n\t"
-    "  add         %5, %1           \n\t"
-    "  add         %5, %2           \n\t"
+    "  add         %4, %1           \n\t"
+    "  add         %4, %2           \n\t"
     ".endr                          \n\t"
 
      : "+r" (FiltPtr),
        "+r" (ReconPtr1),
        "+r" (ReconPtr2),
        "+r" (DctInputPtr)
-     : "r" ((ogg_uint64_t)PixelsPerLine),
-       "r" ((ogg_uint64_t)ReconPixelsPerLine) 
+     : "r" ((ogg_uint64_t)PixelsPerLine)
      : "memory"
   );
 }
@@ -213,8 +209,8 @@
   return (( (XXSum<<6) - XSum*XSum ) );
 }
 
-static ogg_uint32_t inter8x8_err__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
-		                 unsigned char *RefDataPtr, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err__mmx (unsigned char *SrcData, unsigned char *RefDataPtr, 
+				       ogg_uint32_t Stride)
 {
   ogg_uint64_t  XSum;
   ogg_uint64_t  XXSum;
@@ -250,7 +246,7 @@
     "  paddd       %%mm2, %%mm7     \n\t"
 
     "  add         %4, %2           \n\t"	/* Inc pointer into src data */
-    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %4, %3           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%rdi            \n\t"
     "  jnz 1b                       \n\t"
@@ -274,8 +270,7 @@
        "=m" (XXSum),
        "+r" (SrcData), 
        "+r" (RefDataPtr) 
-     : "r" ((ogg_uint64_t)SrcStride),
-       "r" ((ogg_uint64_t)RefStride)
+     : "r" ((ogg_uint64_t)Stride)
      : "rdi", "memory"
   );
 

Modified: branches/theora-thusnelda/lib/enc/x86_64/dsp_mmxext.c
===================================================================
--- branches/theora-thusnelda/lib/enc/x86_64/dsp_mmxext.c	2007-11-29 16:31:03 UTC (rev 14249)
+++ branches/theora-thusnelda/lib/enc/x86_64/dsp_mmxext.c	2007-11-29 21:17:53 UTC (rev 14250)
@@ -24,8 +24,8 @@
 
 typedef unsigned long long ogg_uint64_t;
 
-static ogg_uint32_t sad8x8__mmxext (unsigned char *ptr1, ogg_uint32_t stride1,
-                                    unsigned char *ptr2, ogg_uint32_t stride2)
+static ogg_uint32_t sad8x8__mmxext (unsigned char *ptr1, unsigned char *ptr2, 
+				    ogg_uint32_t stride)
 {
   ogg_uint32_t  DiffVal;
 
@@ -39,7 +39,7 @@
     "  psadbw %%mm1, %%mm0          \n\t"
     "  add %3, %1                   \n\t"	/* Inc pointer into the new data */
     "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */
-    "  add %4, %2                   \n\t"	/* Inc pointer into ref data */
+    "  add %3, %2                   \n\t"	/* Inc pointer into ref data */
     ".endr                          \n\t"
 
     "  movq (%1), %%mm0             \n\t"	/* take 8 bytes */
@@ -51,17 +51,15 @@
      : "=r" (DiffVal),
        "+r" (ptr1), 
        "+r" (ptr2) 
-     : "r" ((ogg_uint64_t)stride1),
-       "r" ((ogg_uint64_t)stride2)
+     : "r" ((ogg_uint64_t)stride)
      : "memory"
   );
 
   return DiffVal;
 }
 
-static ogg_uint32_t sad8x8_thres__mmxext (unsigned char *ptr1, ogg_uint32_t stride1,
-                                          unsigned char *ptr2, ogg_uint32_t stride2, 
-			   	  ogg_uint32_t thres)
+static ogg_uint32_t sad8x8_thres__mmxext (unsigned char *ptr1, unsigned char *ptr2, 
+					  ogg_uint32_t stride, ogg_uint32_t thres)
 {
   ogg_uint32_t  DiffVal;
 
@@ -75,7 +73,7 @@
     "  psadbw %%mm1, %%mm0          \n\t"
     "  add %3, %1                   \n\t"	/* Inc pointer into the new data */
     "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */
-    "  add %4, %2                   \n\t"	/* Inc pointer into ref data */
+    "  add %3, %2                   \n\t"	/* Inc pointer into ref data */
     ".endr                          \n\t"
 
     "  movd %%mm7, %0               \n\t"
@@ -83,17 +81,15 @@
      : "=r" (DiffVal),
        "+r" (ptr1), 
        "+r" (ptr2) 
-     : "r" ((ogg_uint64_t)stride1),
-       "r" ((ogg_uint64_t)stride2)
+     : "r" ((ogg_uint64_t)stride)
      : "memory"
   );
 
   return DiffVal;
 }
 
-static ogg_uint32_t sad8x8_xy2_thres__mmxext (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                                              unsigned char *RefDataPtr1,
-                                              unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
+static ogg_uint32_t sad8x8_xy2_thres__mmxext (unsigned char *SrcData, unsigned char *RefDataPtr1,
+                                              unsigned char *RefDataPtr2, ogg_uint32_t Stride,
                                               ogg_uint32_t thres)
 {
   ogg_uint32_t  DiffVal;
@@ -110,8 +106,8 @@
 
     "  add %4, %1                   \n\t"	/* Inc pointer into the new data */
     "  paddw %%mm0, %%mm7           \n\t"	/* accumulate difference... */
-    "  add %5, %2                   \n\t"	/* Inc pointer into ref data */
-    "  add %5, %3                   \n\t"	/* Inc pointer into ref data */
+    "  add %4, %2                   \n\t"	/* Inc pointer into ref data */
+    "  add %4, %3                   \n\t"	/* Inc pointer into ref data */
     ".endr                          \n\t"
 
     "  movd %%mm7, %0               \n\t"
@@ -119,8 +115,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1), 
        "+r" (RefDataPtr2) 
-     : "r" ((ogg_uint64_t)SrcStride),
-       "r" ((ogg_uint64_t)RefStride)
+     : "r" ((ogg_uint64_t)Stride)
      : "memory"
   );
 
@@ -156,7 +151,7 @@
 }
 
 static ogg_uint32_t col_sad8x8__mmxext (unsigned char *Src1, unsigned char *Src2,
-		                    ogg_uint32_t stride)
+					ogg_uint32_t stride)
 {
   ogg_uint32_t MaxSad;
 
@@ -232,9 +227,8 @@
   return MaxSad;
 }
 
-static ogg_uint32_t inter8x8_err_xy2__mmxext (unsigned char *SrcData, ogg_uint32_t SrcStride,
-                                              unsigned char *RefDataPtr1,
-                                              unsigned char *RefDataPtr2, ogg_uint32_t RefStride)
+static ogg_uint32_t inter8x8_err_xy2__mmxext (unsigned char *SrcData, unsigned char *RefDataPtr1,
+                                              unsigned char *RefDataPtr2, ogg_uint32_t Stride)
 {
   ogg_uint64_t XSum;
   ogg_uint64_t XXSum;
@@ -275,8 +269,8 @@
     "  paddd       %%mm2, %%mm7     \n\t"
 
     "  add         %5, %2           \n\t"	/* Inc pointer into src data */
-    "  add         %6, %3           \n\t"	/* Inc pointer into ref data */
-    "  add         %6, %4           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %3           \n\t"	/* Inc pointer into ref data */
+    "  add         %5, %4           \n\t"	/* Inc pointer into ref data */
 
     "  dec         %%rdi            \n\t"
     "  jnz 1b                       \n\t"
@@ -301,8 +295,7 @@
        "+r" (SrcData), 
        "+r" (RefDataPtr1),
        "+r" (RefDataPtr2) 
-     : "r" ((ogg_uint64_t)SrcStride),
-       "r" ((ogg_uint64_t)RefStride)
+     : "r" ((ogg_uint64_t)Stride)
      : "rdi", "memory"
   );
 



More information about the commits mailing list