mirror of https://git.ffmpeg.org/ffmpeg.git
Optimize esc removal code.
Originally committed as revision 16294 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
ffedb5c19a
commit
593af7cdda
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue