Optimize esc removal code.

Originally committed as revision 16294 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2008-12-23 18:31:44 +00:00
parent ffedb5c19a
commit 593af7cdda
1 changed files with 11 additions and 4 deletions

View File

@ -1423,21 +1423,28 @@ static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_le
} }
//printf("decoding esc\n"); //printf("decoding esc\n");
si=di=0; memcpy(dst, src, i);
while(si<length){ si=di=i;
while(si+2<length){
//remove escapes (very rare 1:2^22) //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 if(src[si+2]==3){ //escape
dst[di++]= 0; dst[di++]= 0;
dst[di++]= 0; dst[di++]= 0;
si+=3; si+=3;
continue; continue;
}else //next start code }else //next start code
break; goto nsc;
} }
dst[di++]= src[si++]; dst[di++]= src[si++];
} }
while(si<length)
dst[di++]= src[si++];
nsc:
memset(dst+di, 0, FF_INPUT_BUFFER_PADDING_SIZE); memset(dst+di, 0, FF_INPUT_BUFFER_PADDING_SIZE);