Mercurial > mplayer.hg
changeset 24483:e24dd407fb58
Optimize demux_ty_FindESHeader
author | reimar |
---|---|
date | Fri, 14 Sep 2007 20:37:30 +0000 |
parents | e5eb9ccd6679 |
children | cf224658fbe2 |
files | libmpdemux/demux_ty.c |
diffstat | 1 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_ty.c Fri Sep 14 20:18:00 2007 +0000 +++ b/libmpdemux/demux_ty.c Fri Sep 14 20:37:30 2007 +0000 @@ -356,14 +356,15 @@ 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; }