[xiph-commits] r9774 - in branches/theora-oil: . examples lib tests

giles at svn.xiph.org giles at svn.xiph.org
Fri Aug 19 11:11:56 PDT 2005


Author: giles
Date: 2005-08-19 11:11:52 -0700 (Fri, 19 Aug 2005)
New Revision: 9774

Modified:
   branches/theora-oil/configure.ac
   branches/theora-oil/examples/Makefile.am
   branches/theora-oil/examples/player_example.c
   branches/theora-oil/lib/Makefile.am
   branches/theora-oil/lib/blockmap.c
   branches/theora-oil/lib/dct_decode.c
   branches/theora-oil/lib/dct_encode.c
   branches/theora-oil/lib/encode.c
   branches/theora-oil/lib/encoder_disabled.c
   branches/theora-oil/lib/encoder_toplevel.c
   branches/theora-oil/lib/mcomp.c
   branches/theora-oil/lib/pp.c
   branches/theora-oil/lib/scan.c
   branches/theora-oil/lib/toplevel.c
   branches/theora-oil/lib/toplevel.h
   branches/theora-oil/tests/Makefile.am
   branches/theora-oil/theora-uninstalled.pc.in
   branches/theora-oil/theora.pc.in
Log:
Apply http://people.xiph.org/~j/theora.oil-j-2005-08-19.patch the latest 
version of the liboil patch.


Modified: branches/theora-oil/configure.ac
===================================================================
--- branches/theora-oil/configure.ac	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/configure.ac	2005-08-19 18:11:52 UTC (rev 9774)
@@ -169,6 +169,26 @@
   XIPH_PATH_VORBIS(HAVE_VORBIS=yes, HAVE_VORBIS=no)
 fi
 
+dnl check for liboil
+ac_enable_liboil=yes
+AC_ARG_ENABLE(liboil,
+     [  --disable-liboil        disable liboil optimisazion ],
+     [ ac_enable_liboil=$enableval ], [ ac_enable_liboil=yes] )
+
+if test "x${ac_enable_liboil}" = xyes ; then
+  PKG_CHECK_MODULES(LIBOIL, liboil-0.3 >= 0.3.2.1, HAVE_LIBOIL=yes, HAVE_LIBOIL=no)
+  AC_SUBST(LIBOIL_LIBS)
+  AC_SUBST(LIBOIL_CFLAGS)
+  if test "$HAVE_LIBOIL" = "no"; then
+    AC_MSG_WARN([cannot find liboil-0.3, no optimization will be enabled])
+    ac_enable_liboil=no
+  else
+    AC_DEFINE_UNQUOTED(USE_LIBOIL, 1, [Defined if liboil should be used])
+    LIBOILPC=", liboil-0.3"
+  fi
+fi
+AC_SUBST(LIBOILPC)
+
 dnl check for SDL
 HAVE_SDL=no
 
@@ -284,6 +304,7 @@
 
     Encoding support: ............ ${ac_enable_encode}
     Floating point support: ...... ${ac_enable_float}
+    Liboil optimization: ......... ${ac_enable_liboil}
 
   Installation paths:
 

Modified: branches/theora-oil/examples/Makefile.am
===================================================================
--- branches/theora-oil/examples/Makefile.am	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/examples/Makefile.am	2005-08-19 18:11:52 UTC (rev 9774)
@@ -7,8 +7,8 @@
 # possible contents of BUILDABLE_EXAMPLES:
 EXTRA_PROGRAMS = player_example encoder_example
 
-AM_CFLAGS = $(SDL_CFLAGS) $(OGG_CFLAGS)
-LDADD = ../lib/libtheora.la $(OGG_LIBS)
+AM_CFLAGS = $(SDL_CFLAGS) $(OGG_CFLAGS) $(LIBOIL_CFLAGS)
+LDADD = ../lib/libtheora.la $(OGG_LIBS) $(LIBOIL_LIBS)
 
 dump_video_SOURCES = dump_video.c
 dump_video_LDADD = $(LDADD)

Modified: branches/theora-oil/examples/player_example.c
===================================================================
--- branches/theora-oil/examples/player_example.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/examples/player_example.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -513,8 +513,8 @@
         fprintf(stderr,"Error parsing Theora stream headers; corrupt stream?\n");
         exit(1);
       }
-      if(theora_decode_header(&ti,&tc,&op)){
-        printf("Error parsing Theora stream headers; corrupt stream?\n");
+      if(ret = theora_decode_header(&ti,&tc,&op)){
+        printf("Error parsing Theora stream headers; corrupt stream?(theora_decode_header) fuck: %d\n",ret);
         exit(1);
       }
       theora_p++;

Modified: branches/theora-oil/lib/Makefile.am
===================================================================
--- branches/theora-oil/lib/Makefile.am	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/Makefile.am	2005-08-19 18:11:52 UTC (rev 9774)
@@ -41,9 +41,9 @@
 	toplevel.h \
 	toplevel_lookup.h
 
-libtheora_la_CFLAGS = $(OGG_CFLAGS)
+libtheora_la_CFLAGS = $(OGG_CFLAGS) $(LIBOIL_CFLAGS)
 libtheora_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@ @SHLIB_VERSION_ARG@
-libtheora_la_LIBADD = $(OGG_LIBS)
+libtheora_la_LIBADD = $(OGG_LIBS) $(LIBOIL_LIBS)
 
 debug:
 	$(MAKE) all CFLAGS="@DEBUG@" LDFLAGS="-lefence"	

Modified: branches/theora-oil/lib/blockmap.c
===================================================================
--- branches/theora-oil/lib/blockmap.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/blockmap.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -32,8 +32,8 @@
   ogg_uint32_t FragIndex=FirstFrag;
 
   /* Set Super-Block dimensions */
-  SBRows = VFrags/4 + ( VFrags%4 ? 1 : 0 );
-  SBCols = HFrags/4 + ( HFrags%4 ? 1 : 0 );
+  SBRows = (VFrags>>2) + ( VFrags&0x03 ? 1 : 0 );
+  SBCols = (HFrags>>2) + ( HFrags&0x03 ? 1 : 0 );
 
   /* Map each Super-Block */
   for ( SBrow=0; SBrow<SBRows; SBrow++ ){
@@ -47,18 +47,9 @@
         xpos = SBcol<<2;
 
         for ( j=0; (j<4) && (xpos<HFrags); j++, xpos++ ){
-          if ( i<2 ){
-            MB = ( j<2 ? 0 : 1 );
-          }else{
-            MB = ( j<2 ? 2 : 3 );
-          }
+          MB = (i & 2) + ((j & 2) >> 1);
+          B = ((i & 1) << 1) + (j & 1);
 
-          if ( i%2 ){
-            B = ( j%2 ? 3 : 2 );
-          }else{
-            B = ( j%2 ? 1 : 0 );
-          }
-
           /* Set mapping and move to next fragment */
           BlockMap[SB][MB][B] = FragIndex++;
         }

Modified: branches/theora-oil/lib/dct_decode.c
===================================================================
--- branches/theora-oil/lib/dct_decode.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/dct_decode.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -19,7 +19,25 @@
 #include <string.h>
 #include "codec_internal.h"
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+/* redirect some functions to liboil */
+#define ReconIntra(pbi, ReconPtr, ChangePtr, LineStep) \
+        oil_recon8x8_intra(ReconPtr, LineStep, ChangePtr)
 
+#define ReconInter(pbi, ReconPtr, RefPtr, ChangePtr, LineStep) \
+        oil_recon8x8_inter(ReconPtr, LineStep, RefPtr, LineStep, ChangePtr)
+
+#define ReconInterHalfPixel2(pbi, ReconPtr, RefPtr1, RefPtr2, \
+                             ChangePtr, LineStep) \
+        oil_recon8x8_inter2(ReconPtr, LineStep, RefPtr1, LineStep, \
+                            RefPtr2, LineStep, ChangePtr)
+
+#define CopyBlock(src, dest, srcstride) \
+        oil_copy8x8_u8(dest, srcstride, src, srcstride)
+
+#endif
+
 #define GOLDEN_FRAME_THRESH_Q   50
 #define PUR 8
 #define PU 4
@@ -112,6 +130,7 @@
   SetupBoundingValueArray_Generic(pbi, FLimit);
 }
 
+#ifndef USE_LIBOIL
 void CopyBlock(unsigned char *src,
                unsigned char *dest,
                unsigned int srcstride){
@@ -127,6 +146,7 @@
     d+=stride;
   }
 }
+#endif
 
 static void ExpandKFBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber ){
   ogg_uint32_t ReconPixelsPerLine;
@@ -165,7 +185,6 @@
   /* Get the pixel index for the first pixel in the fragment. */
   ReconIntra( pbi, (unsigned char *)(&pbi->ThisFrameRecon[ReconPixelIndex]),
               (ogg_int16_t *)pbi->ReconDataBuffer, ReconPixelsPerLine );
-
 }
 
 static void ExpandBlock ( PB_INSTANCE *pbi, ogg_int32_t FragmentNumber ){
@@ -251,7 +270,6 @@
     ReconInter( pbi, &pbi->ThisFrameRecon[ReconPixelIndex],
                 &pbi->LastFrameRecon[ReconPixelIndex],
                 pbi->ReconDataBuffer, ReconPixelsPerLine );
-
   }else if ( ModeUsesMC[pbi->CodingMode] ) {
     /* The mode uses a motion vector. */
     /* Get vector from list */
@@ -678,7 +696,7 @@
 }
 
 void ClearDownQFragData(PB_INSTANCE *pbi){
-  ogg_int32_t       i,j;
+  ogg_int32_t       i;
   Q_LIST_ENTRY *    QFragPtr;
 
   for ( i = 0; i < pbi->CodedBlockIndex; i++ ) {

Modified: branches/theora-oil/lib/dct_encode.c
===================================================================
--- branches/theora-oil/lib/dct_encode.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/dct_encode.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -18,8 +18,33 @@
 #include <stdlib.h>
 #include "codec_internal.h"
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+/* redirect some functions to liboil */
+#define Sub8(FiltPtr, ReconPtr, DctInputPtr, \
+             old_ptr1, new_ptr1, PixelsPerLine, ReconPixelsPerLine)  \
+        oil_diff8x8_s16_u8(DctInputPtr, FiltPtr, PixelsPerLine, \
+                                        ReconPtr, ReconPixelsPerLine); \
+        oil_copy8x8_u8(old_ptr1, PixelsPerLine, new_ptr1, PixelsPerLine)
+
+#define Sub8_128(FiltPtr, DctInputPtr, old_ptr1, new_ptr1, PixelsPerLine) \
+        oil_diff8x8_const128_s16_u8(DctInputPtr, FiltPtr, PixelsPerLine); \
+        oil_copy8x8_u8(old_ptr1, PixelsPerLine, new_ptr1, PixelsPerLine)
+
+#define Sub8Av2(FiltPtr, ReconPtr1, ReconPtr2, DctInputPtr, \
+                     old_ptr1, new_ptr1, PixelsPerLine, ReconPixelsPerLine) \
+        oil_diff8x8_average_s16_u8(DctInputPtr, FiltPtr, PixelsPerLine, \
+               ReconPtr1, ReconPixelsPerLine, ReconPtr2, ReconPixelsPerLine); \
+        oil_copy8x8_u8(old_ptr1, PixelsPerLine, new_ptr1, PixelsPerLine)
+
+#define fdct_short(InputData, OutputData)  \
+        oil_fdct8x8theora(InputData, OutputData)
+
+#endif
+
 static int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
 
+#ifndef USE_LIBOIL
 static void Sub8 (unsigned char *FiltPtr, unsigned char *ReconPtr,
                   ogg_int16_t *DctInputPtr, unsigned char *old_ptr1,
                   unsigned char *new_ptr1, ogg_uint32_t PixelsPerLine,
@@ -120,6 +145,7 @@
     DctInputPtr += BLOCK_HEIGHT_WIDTH;
   }
 }
+#endif
 
 static unsigned char TokenizeDctValue (ogg_int16_t DataValue,
                                        ogg_uint32_t * TokenListPtr ){

Modified: branches/theora-oil/lib/encode.c
===================================================================
--- branches/theora-oil/lib/encode.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/encode.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -27,6 +27,13 @@
 #define PL 1
 #define HIGHBITDUPPED(X) (((ogg_int16_t) X)  >> 15)
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+/* redirect some functions to liboil */
+#define fdct_short(InputData, OutputData) \
+        oil_fdct8x8theora(InputData, OutputData)
+#endif
+
 static ogg_uint32_t QuadCodeComponent ( CP_INSTANCE *cpi,
                                  ogg_uint32_t FirstSB,
                                  ogg_uint32_t SBRows,
@@ -531,7 +538,9 @@
 
 static ogg_uint32_t GetBlockReconErrorSlow( CP_INSTANCE *cpi,
                                      ogg_int32_t BlockIndex ) {
+#ifndef USE_LIBOIL
   ogg_uint32_t  i;
+#endif
   ogg_uint32_t  ErrorVal = 0;
 
   unsigned char * SrcDataPtr =
@@ -550,7 +559,9 @@
     RecStride = cpi->pb.UVStride;
   }
 
-
+#ifdef USE_LIBOIL
+  oil_sad8x8_u8 (&ErrorVal, SrcDataPtr, SrcStride, RecDataPtr, RecStride);
+#else
   /* Decide on standard or MMX implementation */
   for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
     ErrorVal += abs( ((int)SrcDataPtr[0]) - ((int)RecDataPtr[0]) );
@@ -565,6 +576,7 @@
     SrcDataPtr += SrcStride;
     RecDataPtr += RecStride;
   }
+#endif
   return ErrorVal;
 }
 

Modified: branches/theora-oil/lib/encoder_disabled.c
===================================================================
--- branches/theora-oil/lib/encoder_disabled.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/encoder_disabled.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -15,10 +15,6 @@
 
  ********************************************************************/
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
 #include "toplevel_lookup.h"
 #include "toplevel.h"
 

Modified: branches/theora-oil/lib/encoder_toplevel.c
===================================================================
--- branches/theora-oil/lib/encoder_toplevel.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/encoder_toplevel.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -15,14 +15,13 @@
 
  ********************************************************************/
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
 #include <stdlib.h>
 #include <string.h>
 #include "toplevel_lookup.h"
 #include "toplevel.h"
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+#endif
 
 #define A_TABLE_SIZE        29
 #define DF_CANDIDATE_WINDOW 5
@@ -776,6 +775,10 @@
 
   CP_INSTANCE *cpi;
 
+#ifdef USE_LIBOIL
+  oil_init();
+#endif
+
   memset(th, 0, sizeof(*th));
   th->internal_encode=cpi=_ogg_calloc(1,sizeof(*cpi));
 

Modified: branches/theora-oil/lib/mcomp.c
===================================================================
--- branches/theora-oil/lib/mcomp.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/mcomp.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -19,6 +19,27 @@
 #include <stdio.h>
 #include "codec_internal.h"
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+/* redirect some functions to liboil */
+#define SadTemp uint32_t _sad_tmp;
+
+#define GetSumAbsDiffs(NewDataPtr, RefDataPtr, PixelsPerLine, ErrorSoFar) \
+        (oil_sad8x8_u8 (&_sad_tmp, NewDataPtr, PixelsPerLine, RefDataPtr, \
+                        PixelsPerLine+STRIDE_EXTRA), ErrorSoFar+_sad_tmp)
+
+#define GetNextSumAbsDiffs(NewDataPtr, RefDataPtr, PixelsPerLine, \
+                           ErrorSoFar, BestSoFar) \
+        (oil_sad8x8_u8(&_sad_tmp, NewDataPtr, PixelsPerLine, \
+                  RefDataPtr, PixelsPerLine+STRIDE_EXTRA), ErrorSoFar+_sad_tmp)
+
+#define GetIntraError(DataPtr,PixelsPerLine) \
+        (oil_err_intra8x8_u8 (&_sad_tmp,DataPtr, PixelsPerLine),_sad_tmp)
+
+#else
+#define SadTemp
+#endif
+
 /* Initialises motion compentsation. */
 void InitMotionCompensation ( CP_INSTANCE *cpi ){
   int i;
@@ -100,15 +121,21 @@
                           unsigned char * RefDataPtr1,
                           unsigned char * RefDataPtr2,
                           ogg_uint32_t PixelsPerLine ) {
-  ogg_uint32_t  i;
-  ogg_int32_t   XSum=0;
-  ogg_int32_t   XXSum=0;
-  ogg_int32_t   DiffVal;
   ogg_int32_t   AbsRefOffset = abs((int)(RefDataPtr1 - RefDataPtr2));
+  ogg_uint32_t  Result;
 
   /* Mode of interpolation chosen based upon on the offset of the
      second reference pointer */
   if ( AbsRefOffset == 0 ) {
+#ifdef USE_LIBOIL
+    oil_err_inter8x8_u8 (&Result, NewDataPtr, PixelsPerLine,
+		    RefDataPtr1, STRIDE_EXTRA+PixelsPerLine);
+#else
+    ogg_uint32_t  i;
+    ogg_int32_t   XSum=0;
+    ogg_int32_t   XXSum=0;
+    ogg_int32_t   DiffVal;
+
     for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ) {
       DiffVal = ((int)NewDataPtr[0]) - (int)RefDataPtr1[0];
       XSum += DiffVal;
@@ -148,8 +175,19 @@
       NewDataPtr += PixelsPerLine;
       RefDataPtr1 += STRIDE_EXTRA + PixelsPerLine;
     }
+    /* Compute and return population variance as mis-match metric. */
+    Result = (( (XXSum<<6) - XSum*XSum ));
+#endif
 
   }else{
+#ifdef USE_LIBOIL
+    oil_err_inter8x8_u8_avg (&Result, NewDataPtr, PixelsPerLine,
+		    RefDataPtr1, RefDataPtr2, STRIDE_EXTRA+PixelsPerLine);
+#else
+    ogg_uint32_t  i;
+    ogg_int32_t   XSum=0;
+    ogg_int32_t   XXSum=0;
+    ogg_int32_t   DiffVal;
 
     /* Simple two reference interpolation */
     for ( i=0; i<BLOCK_HEIGHT_WIDTH; i++ ) {
@@ -198,12 +236,15 @@
       RefDataPtr1 += STRIDE_EXTRA+PixelsPerLine;
       RefDataPtr2 += STRIDE_EXTRA+PixelsPerLine;
     }
+    /* Compute and return population variance as mis-match metric. */
+    Result = (( (XXSum<<6) - XSum*XSum ));
+#endif
   }
 
-  /* Compute and return population variance as mis-match metric. */
-  return (( (XXSum<<6) - XSum*XSum ));
+  return Result;
 }
 
+#ifndef USE_LIBOIL
 static ogg_uint32_t GetSumAbsDiffs  (unsigned char * NewDataPtr,
                               unsigned char  * RefDataPtr,
                               ogg_uint32_t PixelsPerLine,
@@ -257,6 +298,7 @@
 
   return DiffVal;
 }
+#endif
 
 static ogg_uint32_t GetHalfPixelSumAbsDiffs (unsigned char * SrcData,
                                       unsigned char * RefDataPtr1,
@@ -265,16 +307,24 @@
                                       ogg_uint32_t ErrorSoFar,
                                       ogg_uint32_t BestSoFar ) {
 
-  ogg_uint32_t  i;
   ogg_uint32_t  DiffVal = ErrorSoFar;
   ogg_int32_t   RefOffset = (int)(RefDataPtr1 - RefDataPtr2);
   ogg_uint32_t  RefPixelsPerLine = PixelsPerLine + STRIDE_EXTRA;
+  SadTemp;
 
   if ( RefOffset == 0 ) {
     /* Simple case as for non 0.5 pixel */
     DiffVal += GetSumAbsDiffs( SrcData, RefDataPtr1, PixelsPerLine,
                                0);
   } else  {
+#ifdef USE_LIBOIL
+    ogg_uint32_t temp;
+    oil_sad8x8_u8_avg (&temp, SrcData, PixelsPerLine, RefDataPtr1, 
+		    RefDataPtr2, RefPixelsPerLine);
+    DiffVal += temp;
+#else
+    ogg_uint32_t  i;
+
     for ( i=0; i < BLOCK_HEIGHT_WIDTH; i++ ) {
       DiffVal += abs( ((int)SrcData[0]) - (((int)RefDataPtr1[0] +
                                             (int)RefDataPtr2[0]) / 2) );
@@ -300,11 +350,13 @@
       RefDataPtr1 += RefPixelsPerLine;
       RefDataPtr2 += RefPixelsPerLine;
     }
+#endif
   }
 
   return DiffVal;
 }
 
+#ifndef USE_LIBOIL
 static ogg_uint32_t GetIntraError (unsigned char * DataPtr,
                             ogg_uint32_t PixelsPerLine ) {
   ogg_uint32_t  i;
@@ -342,11 +394,13 @@
   /* Compute population variance as mis-match metric. */
   return (( (XXSum<<6) - XSum*XSum ) );
 }
+#endif
 
 ogg_uint32_t GetMBIntraError (CP_INSTANCE *cpi, ogg_uint32_t FragIndex,
                               ogg_uint32_t PixelsPerLine ) {
   ogg_uint32_t  LocalFragIndex = FragIndex;
   ogg_uint32_t  IntraError = 0;
+  SadTemp;
 
   /* Add together the intra errors for those blocks in the macro block
      that are coded (Y only) */
@@ -479,6 +533,7 @@
   ogg_int32_t   x=0, y=0;
   ogg_int32_t   step;
   ogg_int32_t   SearchSite=0;
+  SadTemp;
 
   unsigned char *SrcPtr[4] = {NULL,NULL,NULL,NULL};
   unsigned char *RefPtr=NULL;
@@ -683,6 +738,7 @@
   unsigned char   BestHalfOffset;
   unsigned char * RefDataPtr1;
   unsigned char * RefDataPtr2;
+  SadTemp;
 
   /* Note which of the four blocks in the macro block are to be
      included in the search. */
@@ -834,6 +890,7 @@
   ogg_int32_t   BestHalfPixelError;
   unsigned char   BestHalfOffset;
   unsigned char * RefDataPtr2;
+  SadTemp;
 
   /* Set up the source pointer for the block. */
   SrcPtr = &cpi->

Modified: branches/theora-oil/lib/pp.c
===================================================================
--- branches/theora-oil/lib/pp.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/pp.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -20,6 +20,12 @@
 #include "codec_internal.h"
 #include "pp.h"
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+#define CopyBlock(src, dest, srcstride) \
+        oil_copy8x8_u8(src, srcstride, dest, srcstride)
+#endif
+
 #define MAX(a, b) ((a>b)?a:b)
 #define MIN(a, b) ((a<b)?a:b)
 #define PP_QUALITY_THRESH   49

Modified: branches/theora-oil/lib/scan.c
===================================================================
--- branches/theora-oil/lib/scan.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/scan.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -20,8 +20,33 @@
 #include <string.h>
 #include "codec_internal.h"
 
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+/* redirect some functions to liboil */
+#define SadTemp uint32_t _sad_tmp;
+
+#define ScalarRowSAD(Src1, Src2)       \
+        (oil_rowsad8x8_u8 (&_sad_tmp, Src1, Src2), _sad_tmp)
+
+#define ScalarColSAD(ppi, Src1, Src2) \
+        (oil_colsad8x8_u8 (&_sad_tmp, Src1, ppi->PlaneStride, \
+                                      Src2, ppi->PlaneStride), _sad_tmp)
+#else
+#define SadTemp 
+#endif
+
 #define MAX_SEARCH_LINE_LEN                   7
 
+#define SET8_0(ptr) \
+  ((ogg_uint32_t *)ptr)[0] = 0x00000000; \
+  ((ogg_uint32_t *)ptr)[1] = 0x00000000;
+#define SET8_1(ptr) \
+  ((ogg_uint32_t *)ptr)[0] = 0x01010101; \
+  ((ogg_uint32_t *)ptr)[1] = 0x01010101;
+#define SET8_8(ptr) \
+  ((ogg_uint32_t *)ptr)[0] = 0x08080808; \
+  ((ogg_uint32_t *)ptr)[1] = 0x08080808;
+
 static ogg_uint32_t LineLengthScores[ MAX_SEARCH_LINE_LEN + 1 ] = {
   0, 0, 0, 0, 2, 4, 12, 24
 };
@@ -384,6 +409,7 @@
   ppi->KFIndicator = ((ppi->KFIndicator*100)/((ppi->ScanYPlaneFragments*3)/4));
 }
 
+#ifndef USE_LIBOIL
 static ogg_uint32_t ScalarRowSAD( unsigned char * Src1,
                                   unsigned char * Src2 ){
   ogg_uint32_t SadValue;
@@ -445,6 +471,7 @@
 
   return MaxSad;
 }
+#endif
 
 
 static int RowSadScan( PP_INSTANCE *ppi,
@@ -460,6 +487,7 @@
   unsigned char *LocalYuvPtr2;
 
   int           InterestingBlocksInRow = 0;
+  SadTemp;
 
   /* For each row of pixels in the row of blocks */
   for ( j = 0; j < VFRAGPIXELS; j++ ){
@@ -519,6 +547,7 @@
   unsigned char * LocalYuvPtr2;
 
   int     InterestingBlocksInRow = 0;
+  SadTemp;
 
   /* Set the local pixel data pointers for this row. */
   LocalYuvPtr1 = YuvPtr1;
@@ -758,7 +787,7 @@
       if (*DispFragPtr == CANDIDATE_BLOCK){
 
         /* Clear down entries in changed locals array */
-        memset(ChLocalsPtr,0,8);
+        SET8_0(ChLocalsPtr);
 
         for ( j = 0; j < HFRAGPIXELS; j++ ){
           /* Take a local copy of the measured difference. */
@@ -777,10 +806,10 @@
       }else{
         /* If we are breaking out here mark all pixels as changed. */
         if ( *DispFragPtr > BLOCK_NOT_CODED ){
-          memset(bits_map_ptr,1,8);
-          memset(ChLocalsPtr,8,8);
+          SET8_1(bits_map_ptr);
+          SET8_8(ChLocalsPtr);
         }else{
-          memset(ChLocalsPtr,0,8);
+          SET8_0(ChLocalsPtr);
         }
       }
 
@@ -816,7 +845,7 @@
     /* Test for break out conditions to save time. */
     if (*DispFragPtr == CANDIDATE_BLOCK){
       /* Clear down entries in changed locals array */
-      memset(ChLocalsPtr,0,8);
+      SET8_0(ChLocalsPtr);
 
       for ( j = 0; j < HFRAGPIXELS; j++ ){
         /* Take a local copy of the measured difference. */
@@ -839,10 +868,10 @@
     }else{
       /* If we are breaking out here mark all pixels as changed. */
       if ( *DispFragPtr > BLOCK_NOT_CODED ){
-        memset(bits_map_ptr,1,8);
-        memset(ChLocalsPtr,8,8);
+        SET8_1(bits_map_ptr);
+        SET8_8(ChLocalsPtr);
       }else{
-        memset(ChLocalsPtr,0,8);
+        SET8_0(ChLocalsPtr);
       }
     }
 
@@ -876,7 +905,7 @@
       /* Test for break out conditions to save time. */
       if (*DispFragPtr == CANDIDATE_BLOCK){
         /* Clear down entries in changed locals array */
-        memset(ChLocalsPtr,0,8);
+        SET8_0(ChLocalsPtr);
         for ( j = 0; j < HFRAGPIXELS; j++ ){
           /* Take a local copy of the measured difference. */
           Diff = (int)YuvPtr1[j] - (int)YuvPtr2[j];
@@ -899,10 +928,10 @@
       }else{
         /* If we are breaking out here mark all pixels as changed. */
         if ( *DispFragPtr > BLOCK_NOT_CODED ){
-          memset(bits_map_ptr,1,8);
-          memset(ChLocalsPtr,8,8);
+          SET8_1(bits_map_ptr);
+          SET8_8(ChLocalsPtr);
         }else{
-          memset(ChLocalsPtr,0,8);
+          SET8_0(ChLocalsPtr);
         }
       }
 
@@ -935,7 +964,7 @@
     /* Test for break out conditions to save time. */
     if (*DispFragPtr == CANDIDATE_BLOCK){
       /* Clear down entries in changed locals array */
-      memset(ChLocalsPtr,0,8);
+      SET8_0(ChLocalsPtr);
 
       for ( j = 0; j < HFRAGPIXELS; j++ ){
         /* Take a local copy of the measured difference. */
@@ -959,10 +988,10 @@
     }else{
       /* If we are breaking out here mark all pixels as changed.*/
       if ( *DispFragPtr > BLOCK_NOT_CODED ) {
-          memset(bits_map_ptr,1,8);
-          memset(ChLocalsPtr,8,8);
+          SET8_1(bits_map_ptr);
+          SET8_8(ChLocalsPtr);
         }else{
-          memset(ChLocalsPtr,0,8);
+          SET8_0(ChLocalsPtr);
         }
     }
     /* If we have a lot of changed pixels for this fragment on this
@@ -1071,7 +1100,7 @@
         }
       }else{
         if ( *DispFragPtr > BLOCK_NOT_CODED )
-          memset(ChLocalsPtr,0,8);
+          SET8_0(ChLocalsPtr);
 
         /* Step pointers */
         ChLocalsPtr += HFRAGPIXELS;
@@ -1133,7 +1162,7 @@
         }
       }else{
         if ( *DispFragPtr > BLOCK_NOT_CODED )
-          memset(ChLocalsPtr,0,8);
+          SET8_0(ChLocalsPtr);
 
         /* Step pointers */
         ChLocalsPtr += HFRAGPIXELS;

Modified: branches/theora-oil/lib/toplevel.c
===================================================================
--- branches/theora-oil/lib/toplevel.c	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/toplevel.c	2005-08-19 18:11:52 UTC (rev 9774)
@@ -15,14 +15,13 @@
 
  ********************************************************************/
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
 #include <stdlib.h>
 #include <string.h>
 #include <theora/theora.h>
 #include "toplevel.h"
+#ifdef USE_LIBOIL
+#include <liboil/liboil.h>
+#endif
 
 static int _ilog(unsigned int v){
   int ret=0;
@@ -296,6 +295,10 @@
   PB_INSTANCE *pbi;
   codec_setup_info *ci;
 
+#ifdef USE_LIBOIL
+  oil_init();
+#endif
+
   ci=(codec_setup_info *)c->codec_setup;
   memset(th, 0, sizeof(*th));
   th->internal_decode=pbi=_ogg_calloc(1,sizeof(*pbi));

Modified: branches/theora-oil/lib/toplevel.h
===================================================================
--- branches/theora-oil/lib/toplevel.h	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/lib/toplevel.h	2005-08-19 18:11:52 UTC (rev 9774)
@@ -15,10 +15,6 @@
 
  ********************************************************************/
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
 #include "codec_internal.h"
 
 #define VERSION_MAJOR 3

Modified: branches/theora-oil/tests/Makefile.am
===================================================================
--- branches/theora-oil/tests/Makefile.am	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/tests/Makefile.am	2005-08-19 18:11:52 UTC (rev 9774)
@@ -1,7 +1,9 @@
 INCLUDES = -I$(top_srcdir)/include
 
+noinst_HEADERS = tests.h
+
 THEORADIR = ../lib
-THEORA_LIBS = $(THEORADIR)/libtheora.la $(OGG_LIBS)
+THEORA_LIBS = $(THEORADIR)/libtheora.la $(OGG_LIBS) $(LIBOIL_LIBS)
 
 test: check
 

Modified: branches/theora-oil/theora-uninstalled.pc.in
===================================================================
--- branches/theora-oil/theora-uninstalled.pc.in	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/theora-uninstalled.pc.in	2005-08-19 18:11:52 UTC (rev 9774)
@@ -8,7 +8,7 @@
 Name: theora uninstalled
 Description: Theora video codec (not installed)
 Version: @VERSION@
-Requires: ogg >= 1.1
+Requires: ogg >= 1.1 @LIBOILPC@
 Conflicts:
 Libs: ${libdir}/libtheora.la
 Cflags: -I${includedir}

Modified: branches/theora-oil/theora.pc.in
===================================================================
--- branches/theora-oil/theora.pc.in	2005-08-19 18:10:01 UTC (rev 9773)
+++ branches/theora-oil/theora.pc.in	2005-08-19 18:11:52 UTC (rev 9774)
@@ -8,7 +8,7 @@
 Name: theora
 Description: Theora video codec
 Version: @VERSION@
-Requires: ogg >= 1.1
+Requires: ogg >= 1.1 @LIBOILPC@
 Conflicts:
 Libs: -L${libdir} -ltheora
 Cflags: -I${includedir}



More information about the commits mailing list