changeset 8446:489c8d652fff libavcodec

Optimize esc removal code.
author michael
date Tue, 23 Dec 2008 18:31:44 +0000
parents 8621deaff8dc
children 42198817a5ba
files h264.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/h264.c	Tue Dec 23 18:27:06 2008 +0000
+++ b/h264.c	Tue Dec 23 18:31:44 2008 +0000
@@ -1423,21 +1423,28 @@
     }
 
 //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);