summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demux_ty.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-14 20:37:30 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-09-14 20:37:30 +0000
commit99ef8adf6f7e32a1f131f1ab7d8b0771d479c652 (patch)
tree3d2ee3627867e3ecf9051e66c0cf0144a5168004 /libmpdemux/demux_ty.c
parent9d885bbbe86d3487ad4a72b612f78921c2b5dd4d (diff)
downloadmpv-99ef8adf6f7e32a1f131f1ab7d8b0771d479c652.tar.bz2
mpv-99ef8adf6f7e32a1f131f1ab7d8b0771d479c652.tar.xz
Optimize demux_ty_FindESHeader
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24503 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demux_ty.c')
-rw-r--r--libmpdemux/demux_ty.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libmpdemux/demux_ty.c b/libmpdemux/demux_ty.c
index c7ed95b803..6e51c347b4 100644
--- a/libmpdemux/demux_ty.c
+++ b/libmpdemux/demux_ty.c
@@ -356,14 +356,15 @@ static void demux_ty_CopyToDemuxPacket( int type, TiVoInfo *tivo, demux_stream_t
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;
}