diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-12-23 18:31:44 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-12-23 18:31:44 +0000 |
commit | 593af7cddab232fb9c14f3df7a01b514ae66d575 (patch) | |
tree | 1f9f6f27331152c31935858caf9f813d815f7d22 | |
parent | ffedb5c19a2a0f57d686c40b01395befe9f38e67 (diff) | |
download | ffmpeg-593af7cddab232fb9c14f3df7a01b514ae66d575.tar.gz |
Optimize esc removal code.
Originally committed as revision 16294 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/h264.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index ab206a2b6f..b3d3575a9d 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1423,21 +1423,28 @@ static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_le } //printf("decoding esc\n"); - si=di=0; - while(si<length){ + memcpy(dst, src, i); + si=di=i; + while(si+2<length){ //remove escapes (very rare 1:2^22) - if(si+2<length && src[si]==0 && src[si+1]==0 && src[si+2]<=3){ + if(src[si+2]>3){ + dst[di++]= src[si++]; + dst[di++]= src[si++]; + }else if(src[si]==0 && src[si+1]==0){ if(src[si+2]==3){ //escape dst[di++]= 0; dst[di++]= 0; si+=3; continue; }else //next start code - break; + goto nsc; } dst[di++]= src[si++]; } + while(si<length) + dst[di++]= src[si++]; +nsc: memset(dst+di, 0, FF_INPUT_BUFFER_PADDING_SIZE); |