[xiph-cvs] cvs commit: theora/lib dct_decode.c encoder_internal.h reconstruct.c

Monty xiphmont at xiph.org
Wed Sep 25 03:01:53 PDT 2002



xiphmont    02/09/25 06:01:53

  Modified:    examples encoder_example.c player_example.c
               lib      dct_decode.c encoder_internal.h reconstruct.c
  Log:
  busywait fix for audio or video only files
  
  minor optimizations ot decoder

Revision  Changes    Path
1.6       +7 -1      theora/examples/encoder_example.c

Index: encoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/encoder_example.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- encoder_example.c	25 Sep 2002 06:06:36 -0000	1.5
+++ encoder_example.c	25 Sep 2002 10:01:52 -0000	1.6
@@ -12,9 +12,15 @@
 
   function: example encoder application; makes an Ogg Theora/Vorbis 
             file from YUV4MPEG2 and WAV input
-  last mod: $Id: encoder_example.c,v 1.5 2002/09/25 06:06:36 xiphmont Exp $
+  last mod: $Id: encoder_example.c,v 1.6 2002/09/25 10:01:52 xiphmont Exp $
 
  ********************************************************************/
+
+#define _GNU_SOURCE
+#define _REENTRANT
+#define _LARGEFILE_SOURCE 
+#define _LARGEFILE64_SOURCE
+#define _FILE_OFFSET_BITS 64
 
 #include <stdio.h>
 #include <unistd.h>

<p><p>1.9       +11 -2     theora/examples/player_example.c

Index: player_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/player_example.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- player_example.c	25 Sep 2002 06:06:36 -0000	1.8
+++ player_example.c	25 Sep 2002 10:01:52 -0000	1.9
@@ -12,7 +12,7 @@
 
   function: example SDL player application; plays Ogg Theora files (with
             optional Vorbis audio second stream)
-  last mod: $Id: player_example.c,v 1.8 2002/09/25 06:06:36 xiphmont Exp $
+  last mod: $Id: player_example.c,v 1.9 2002/09/25 10:01:52 xiphmont Exp $
 
  ********************************************************************/
 
@@ -25,6 +25,12 @@
    A simple 'demux and write back streams' would have been easier,
    it's true. */
 
+#define _GNU_SOURCE
+#define _REENTRANT
+#define _LARGEFILE_SOURCE 
+#define _LARGEFILE64_SOURCE
+#define _FILE_OFFSET_BITS 64
+
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -549,7 +555,10 @@
       videobuf_ready=0;
     }
       
-    if(stateflag && audiobuf_ready && videobuf_ready && !got_sigint){
+    if(stateflag && 
+       (audiobuf_ready || !vorbis_p) && 
+       (videobuf_ready || !theora_p) && 
+       !got_sigint){
       /* we have an audio frame ready (which means the audio buffer is
          full), it's not time to play video, so wait until one of the
          audio buffer is ready or it's near time to play video */

<p><p>1.4       +13 -14    theora/lib/dct_decode.c

Index: dct_decode.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/dct_decode.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- dct_decode.c	23 Sep 2002 08:31:02 -0000	1.3
+++ dct_decode.c	25 Sep 2002 10:01:52 -0000	1.4
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: dct_decode.c,v 1.3 2002/09/23 08:31:02 xiphmont Exp $
+  last mod: $Id: dct_decode.c,v 1.4 2002/09/25 10:01:52 xiphmont Exp $
 
  ********************************************************************/
 
@@ -50,12 +50,12 @@
 
 static int ModeUsesMC[MAX_MODES] = { 0, 0, 1, 1, 1, 0, 1, 1 };
 
-static ogg_int32_t *SetupBoundingValueArray_Generic(PB_INSTANCE *pbi, 
-					     ogg_int32_t FLimit){
-  ogg_int32_t * BoundingValuePtr;
+static void SetupBoundingValueArray_Generic(PB_INSTANCE *pbi, 
+					    ogg_int32_t FLimit){
+
+  ogg_int32_t * BoundingValuePtr = pbi->FiltBoundingValue+256;
   ogg_int32_t i;
   
-  BoundingValuePtr = &pbi->FiltBoundingValue[256];
   /* Set up the bounding value array. */
   memset ( pbi->FiltBoundingValue, 0, (512*sizeof(*pbi->FiltBoundingValue)) );
   for ( i = 0; i < FLimit; i++ ){
@@ -64,15 +64,13 @@
     BoundingValuePtr[i] = i;
     BoundingValuePtr[i+FLimit] = FLimit-i;
   }
-  
-  return BoundingValuePtr;
 }
 
 void SetupLoopFilter(PB_INSTANCE *pbi){
   ogg_int32_t FLimit; 
   
   FLimit = LoopFilterLimitValuesV2[pbi->FrameQIndex];
-  pbi->BoundingValuePtr = SetupBoundingValueArray_Generic(pbi, FLimit);
+  SetupBoundingValueArray_Generic(pbi, FLimit);
 }
 
 void CopyBlock(unsigned char *src, 
@@ -655,12 +653,13 @@
   ogg_int32_t FiltVal;
   
   for ( j = 0; j < 8; j++ ){            
-    FiltVal =  ( PixelPtr[0] ) - 
+    FiltVal =  
+      ( PixelPtr[0] ) - 
       ( PixelPtr[1] * 3 ) +
       ( PixelPtr[2] * 3 ) - 
       ( PixelPtr[3] );
     
-    FiltVal = BoundingValuePtr[(FiltVal + 4) >> 3];
+    FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
     
     PixelPtr[1] = clamp255(PixelPtr[1] + FiltVal);
     PixelPtr[2] = clamp255(PixelPtr[2] - FiltVal);
@@ -687,7 +686,7 @@
       ( (ogg_int32_t)PixelPtr[2 * LineLength] * 3 ) - 
       ( (ogg_int32_t)PixelPtr[3 * LineLength] );
     
-    FiltVal = BoundingValuePtr[(FiltVal + 4) >> 3];
+    FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
     
     PixelPtr[LineLength] = clamp255(PixelPtr[LineLength] + FiltVal);
     PixelPtr[2 * LineLength] = clamp255(PixelPtr[2*LineLength] - FiltVal);
@@ -699,7 +698,7 @@
 void LoopFilter(PB_INSTANCE *pbi){
   ogg_int32_t i;
   
-  ogg_int32_t * BoundingValuePtr;
+  ogg_int32_t * BoundingValuePtr=pbi->FiltBoundingValue+256;
   int FragsAcross=pbi->HFragments;	
   int FromFragment,ToFragment;
   int FragsDown = pbi->VFragments;
@@ -724,7 +723,7 @@
   
   if ( FLimit == 0 ) return;
   
-  BoundingValuePtr = SetupBoundingValueArray_Generic(pbi, FLimit);
+  SetupBoundingValueArray_Generic(pbi, FLimit);
  
   
   for ( j = 0; j < 3 ; j++){
@@ -769,7 +768,7 @@
       if ( !pbi->display_fragments[ i + 1 ] ){
         FilterHoriz(pbi->LastFrameRecon+
                     pbi->recon_pixel_index_table[i]+6, 
-		    LineLength, BoundingValuePtr);
+		    LineLength,BoundingValuePtr);
       }
       
       /* Bottom done if next row set */

<p><p>1.10      +7 -6      theora/lib/encoder_internal.h

Index: encoder_internal.h
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/encoder_internal.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- encoder_internal.h	23 Sep 2002 23:18:07 -0000	1.9
+++ encoder_internal.h	25 Sep 2002 10:01:52 -0000	1.10
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: encoder_internal.h,v 1.9 2002/09/23 23:18:07 xiphmont Exp $
+  last mod: $Id: encoder_internal.h,v 1.10 2002/09/25 10:01:52 xiphmont Exp $
 
  ********************************************************************/
 
@@ -315,8 +315,6 @@
   YUV_BUFFER_ENTRY *LastFrameRecon;
   YUV_BUFFER_ENTRY *PostProcessBuffer;
   
-  ogg_int32_t   *BoundingValuePtr;
-
   /**********************************************************************/
   /* Fragment Information */
   ogg_uint32_t  *pixel_index_table;        /* start address of first
@@ -634,8 +632,11 @@
 
 } CP_INSTANCE;
 
-/*#define clamp255(x) (((ogg_int32_t)(x)&~0xff)?((ogg_int32_t)(x))>>31:(x))*/
-#define clamp255(val)  ( val<0 ? 0: ( val>255 ? 255:val ) )
+static ogg_int32_t andmask[2]={0xff,0x00};
+static ogg_int32_t ormask[4]={0x00,0xff,0xff,0xff};
+
+//#define clamp255(val)  ( val<0 ? 0: ( val>255 ? 255:val ) )
+#define clamp255(x) ((unsigned char)((((x)<0)-1) & ((x) | -((x)>255))))
 
 extern void ConfigurePP( PP_INSTANCE *ppi, int Level ) ;
 extern ogg_uint32_t YUVAnalyseFrame( PP_INSTANCE *ppi, 
@@ -661,7 +662,7 @@
                    ogg_int16_t * OutputData );
 
 extern void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-			ogg_uint16_t * ChangePtr, ogg_uint32_t LineStep );
+			ogg_int16_t * ChangePtr, ogg_uint32_t LineStep );
 
 extern void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
                         unsigned char * RefPtr, ogg_int16_t * ChangePtr, 

<p><p>1.3       +30 -60    theora/lib/reconstruct.c

Index: reconstruct.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/reconstruct.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- reconstruct.c	20 Sep 2002 22:01:43 -0000	1.2
+++ reconstruct.c	25 Sep 2002 10:01:53 -0000	1.3
@@ -11,106 +11,76 @@
  ********************************************************************
 
   function: 
-  last mod: $Id: reconstruct.c,v 1.2 2002/09/20 22:01:43 xiphmont Exp $
+  last mod: $Id: reconstruct.c,v 1.3 2002/09/25 10:01:53 xiphmont Exp $
 
  ********************************************************************/
 
 #include <ogg/ogg.h>
 #include "encoder_internal.h"
 
-
-static void SatUnsigned8( unsigned char * ResultPtr, ogg_int16_t * DataBlock, 
-		   ogg_uint32_t ResultLineStep, ogg_uint32_t DataLineStep ) {
-  int  i;
-       
-  for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){
-    ResultPtr[0] = clamp255(DataBlock[0]);
-    ResultPtr[1] = clamp255(DataBlock[1]);
-    ResultPtr[2] = clamp255(DataBlock[2]);
-    ResultPtr[3] = clamp255(DataBlock[3]);
-    ResultPtr[4] = clamp255(DataBlock[4]);
-    ResultPtr[5] = clamp255(DataBlock[5]);
-    ResultPtr[6] = clamp255(DataBlock[6]);
-    ResultPtr[7] = clamp255(DataBlock[7]);
-    
-    DataBlock += DataLineStep;
-    ResultPtr += ResultLineStep;
-  }
-}
-
 void ReconIntra( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
-		 ogg_uint16_t * ChangePtr, ogg_uint32_t LineStep ) {
+		 ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
   ogg_uint32_t i;
-  ogg_int16_t *TmpDataPtr = pbi->TmpDataBuffer;
   
   for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){	
     /* Convert the data back to 8 bit unsigned */
-    TmpDataPtr[0] = ( ChangePtr[0] + 128 );
-    TmpDataPtr[1] = ( ChangePtr[1] + 128 );
-    TmpDataPtr[2] = ( ChangePtr[2] + 128 );
-    TmpDataPtr[3] = ( ChangePtr[3] + 128 );
-    TmpDataPtr[4] = ( ChangePtr[4] + 128 );
-    TmpDataPtr[5] = ( ChangePtr[5] + 128 );
-    TmpDataPtr[6] = ( ChangePtr[6] + 128 );
-    TmpDataPtr[7] = ( ChangePtr[7] + 128 );
+    /* Saturate the output to unsigend 8 bit values */
+    ReconPtr[0] = clamp255( ChangePtr[0] + 128 );
+    ReconPtr[1] = clamp255( ChangePtr[1] + 128 );
+    ReconPtr[2] = clamp255( ChangePtr[2] + 128 );
+    ReconPtr[3] = clamp255( ChangePtr[3] + 128 );
+    ReconPtr[4] = clamp255( ChangePtr[4] + 128 );
+    ReconPtr[5] = clamp255( ChangePtr[5] + 128 );
+    ReconPtr[6] = clamp255( ChangePtr[6] + 128 );
+    ReconPtr[7] = clamp255( ChangePtr[7] + 128 );
     
-    TmpDataPtr += BLOCK_HEIGHT_WIDTH;
+    ReconPtr += LineStep;
     ChangePtr += BLOCK_HEIGHT_WIDTH;
   }
   
-  /* Saturate the output to unsigend 8 bit values */
-  SatUnsigned8( ReconPtr, pbi->TmpDataBuffer, LineStep, BLOCK_HEIGHT_WIDTH );
 }
 
 void ReconInter( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
                  unsigned char * RefPtr, ogg_int16_t * ChangePtr, 
                  ogg_uint32_t LineStep ) {
   ogg_uint32_t i;
-  ogg_int16_t *TmpDataPtr = pbi->TmpDataBuffer;
   
   for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++) {	
-    TmpDataPtr[0] = (RefPtr[0] + ChangePtr[0]);
-    TmpDataPtr[1] = (RefPtr[1] + ChangePtr[1]);
-    TmpDataPtr[2] = (RefPtr[2] + ChangePtr[2]);
-    TmpDataPtr[3] = (RefPtr[3] + ChangePtr[3]);
-    TmpDataPtr[4] = (RefPtr[4] + ChangePtr[4]);
-    TmpDataPtr[5] = (RefPtr[5] + ChangePtr[5]);
-    TmpDataPtr[6] = (RefPtr[6] + ChangePtr[6]);
-    TmpDataPtr[7] = (RefPtr[7] + ChangePtr[7]);
+    ReconPtr[0] = clamp255(RefPtr[0] + ChangePtr[0]);
+    ReconPtr[1] = clamp255(RefPtr[1] + ChangePtr[1]);
+    ReconPtr[2] = clamp255(RefPtr[2] + ChangePtr[2]);
+    ReconPtr[3] = clamp255(RefPtr[3] + ChangePtr[3]);
+    ReconPtr[4] = clamp255(RefPtr[4] + ChangePtr[4]);
+    ReconPtr[5] = clamp255(RefPtr[5] + ChangePtr[5]);
+    ReconPtr[6] = clamp255(RefPtr[6] + ChangePtr[6]);
+    ReconPtr[7] = clamp255(RefPtr[7] + ChangePtr[7]);
     
     ChangePtr += BLOCK_HEIGHT_WIDTH;
-    TmpDataPtr += BLOCK_HEIGHT_WIDTH;
+    ReconPtr += LineStep;
     RefPtr += LineStep; 
   }
   
-  /* Saturate the output to unsigend 8 bit values */
-  SatUnsigned8( ReconPtr, pbi->TmpDataBuffer, LineStep, BLOCK_HEIGHT_WIDTH );
-  
 }
 
 void ReconInterHalfPixel2( PB_INSTANCE *pbi, unsigned char * ReconPtr, 
                            unsigned char * RefPtr1, unsigned char * RefPtr2, 
                            ogg_int16_t * ChangePtr, ogg_uint32_t LineStep ) {
   ogg_uint32_t  i;
-  ogg_int16_t *TmpPtr = pbi->TmpDataBuffer;
   
   for ( i = 0; i < BLOCK_HEIGHT_WIDTH; i++ ){	
-    TmpPtr[0] = ((((int)RefPtr1[0] + (int)RefPtr2[0]) >> 1) + ChangePtr[0] );
-    TmpPtr[1] = ((((int)RefPtr1[1] + (int)RefPtr2[1]) >> 1) + ChangePtr[1] );
-    TmpPtr[2] = ((((int)RefPtr1[2] + (int)RefPtr2[2]) >> 1) + ChangePtr[2] );
-    TmpPtr[3] = ((((int)RefPtr1[3] + (int)RefPtr2[3]) >> 1) + ChangePtr[3] );
-    TmpPtr[4] = ((((int)RefPtr1[4] + (int)RefPtr2[4]) >> 1) + ChangePtr[4] );
-    TmpPtr[5] = ((((int)RefPtr1[5] + (int)RefPtr2[5]) >> 1) + ChangePtr[5] );
-    TmpPtr[6] = ((((int)RefPtr1[6] + (int)RefPtr2[6]) >> 1) + ChangePtr[6] );
-    TmpPtr[7] = ((((int)RefPtr1[7] + (int)RefPtr2[7]) >> 1) + ChangePtr[7] );
+    ReconPtr[0] = clamp255((((int)RefPtr1[0] + (int)RefPtr2[0]) >> 1) + ChangePtr[0] );
+    ReconPtr[1] = clamp255((((int)RefPtr1[1] + (int)RefPtr2[1]) >> 1) + ChangePtr[1] );
+    ReconPtr[2] = clamp255((((int)RefPtr1[2] + (int)RefPtr2[2]) >> 1) + ChangePtr[2] );
+    ReconPtr[3] = clamp255((((int)RefPtr1[3] + (int)RefPtr2[3]) >> 1) + ChangePtr[3] );
+    ReconPtr[4] = clamp255((((int)RefPtr1[4] + (int)RefPtr2[4]) >> 1) + ChangePtr[4] );
+    ReconPtr[5] = clamp255((((int)RefPtr1[5] + (int)RefPtr2[5]) >> 1) + ChangePtr[5] );
+    ReconPtr[6] = clamp255((((int)RefPtr1[6] + (int)RefPtr2[6]) >> 1) + ChangePtr[6] );
+    ReconPtr[7] = clamp255((((int)RefPtr1[7] + (int)RefPtr2[7]) >> 1) + ChangePtr[7] );
 
     ChangePtr += BLOCK_HEIGHT_WIDTH;
-    TmpPtr += BLOCK_HEIGHT_WIDTH;
+    ReconPtr += LineStep;
     RefPtr1 += LineStep; 
     RefPtr2 += LineStep; 
   }
-
-  /* Saturate the output to unsigend 8 bit values */
-  SatUnsigned8( ReconPtr, pbi->TmpDataBuffer, LineStep, BLOCK_HEIGHT_WIDTH );
 
 }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list