From 5cb5023c78ceb43d02db609db948fce62221b554 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <michaelni@gmx.at> Date: Tue, 23 Dec 2008 02:34:58 +0000 Subject: [PATCH] Make h264 parser 50% faster. Originally committed as revision 16286 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/h264_parser.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index e0973bf6e0f..62cd9485959 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -44,6 +44,15 @@ int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size) for(i=0; i<buf_size; i++){ if(state==7){ +#ifdef HAVE_FAST_UNALIGNED +# ifdef HAVE_FAST_64BIT + while(i<buf_size && !((~*(uint64_t*)(buf+i) & (*(uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL)) + i+=8; +# else + while(i<buf_size && !((~*(uint32_t*)(buf+i) & (*(uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U)) + i+=4; +# endif +#endif for(; i<buf_size; i++){ if(!buf[i]){ state=2; -- GitLab