Make h264 parser 50% faster.

Originally committed as revision 16286 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 16 years ago
parent abb27cfb24
commit 5cb5023c78
  1. 9
      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;

Loading…
Cancel
Save