[MPlayer-cvslog] r24503 - trunk/libmpdemux/demux_ty.c

reimar subversion at mplayerhq.hu
Fri Sep 14 22:37:30 CEST 2007


Author: reimar
Date: Fri Sep 14 22:37:30 2007
New Revision: 24503

Log:
Optimize demux_ty_FindESHeader


Modified:
   trunk/libmpdemux/demux_ty.c

Modified: trunk/libmpdemux/demux_ty.c
==============================================================================
--- trunk/libmpdemux/demux_ty.c	(original)
+++ trunk/libmpdemux/demux_ty.c	Fri Sep 14 22:37:30 2007
@@ -356,14 +356,15 @@ static void demux_ty_CopyToDemuxPacket( 
 static int demux_ty_FindESHeader( unsigned char *header,
    unsigned char *buffer, int bufferSize )
 {
-   int count;
-   for( count = 0 ; count + 3 < bufferSize ; count++ )
-   {
-      if ( buffer[ count + 0 ] == header[ 0 ] &&
-           buffer[ count + 1 ] == header[ 1 ] &&
-           buffer[ count + 2 ] == header[ 2 ] &&
-           buffer[ count + 3 ] == header[ 3 ] )
-         return count;
+   uint32_t search = AV_RB32(header);
+   uint32_t found = -1;
+   uint8_t *p = buffer;
+   uint8_t *end = p + bufferSize;
+   while (p < end) {
+      found <<= 8;
+      found |= *p++;
+      if (found == search)
+         return p - buffer - 4;
    }
    return -1;
 }



More information about the MPlayer-cvslog mailing list