diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-12-23 00:38:45 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-12-23 00:38:45 +0000 |
commit | e08715d391091e24620c8d3137c59a1e3ef2c5c7 (patch) | |
tree | 86269a16b43e1321f7b402b297c318a31d1bbb9d /libavcodec/h264.c | |
parent | f496ab12e473324e9b9f8bfc881d6b10b2601a62 (diff) | |
download | ffmpeg-e08715d391091e24620c8d3137c59a1e3ef2c5c7.tar.gz |
Optimize 0 0 0-3 search, 45% faster on pentium dual.
Originally committed as revision 16284 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index a170177fa4..1e5ac60520 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1375,9 +1375,26 @@ static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_le for(i=0; i<length; i++) printf("%2X ", src[i]); #endif + +#ifdef HAVE_FAST_UNALIGNED +# ifdef HAVE_FAST_64BIT +# define RS 7 + for(i=0; i+1<length; i+=9){ + if(!((~*(uint64_t*)(src+i) & (*(uint64_t*)(src+i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) +# else +# define RS 3 + for(i=0; i+1<length; i+=5){ + if(!((~*(uint32_t*)(src+i) & (*(uint32_t*)(src+i) - 0x01000101U)) & 0x80008080U)) +# endif + continue; + if(i>0 && !src[i]) i--; + while(src[i]) i++; +#else +# define RS 0 for(i=0; i+1<length; i+=2){ if(src[i]) continue; if(i>0 && src[i-1]==0) i--; +#endif if(i+2<length && src[i+1]==0 && src[i+2]<=3){ if(src[i+2]!=3){ /* startcode, so we must be past the end */ |