mpeg12_parser: make mpegvideo_split() more robust
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 18 Oct 2011 12:08:06 +0000 (14:08 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 18 Oct 2011 12:08:06 +0000 (14:08 +0200)
I just found this issue while debuging, i dont have a testcase.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpegvideo_parser.c

index bcbe1f1..25028a9 100644 (file)
@@ -164,10 +164,13 @@ static int mpegvideo_split(AVCodecContext *avctx,
 {
     int i;
     uint32_t state= -1;
+    int found=0;
 
     for(i=0; i<buf_size; i++){
         state= (state<<8) | buf[i];
-        if(state != 0x1B3 && state != 0x1B5 && state < 0x200 && state >= 0x100)
+        if(state == 0x1B3){
+            found=1;
+        }else if(found && state != 0x1B5 && state < 0x200 && state >= 0x100)
             return i-3;
     }
     return 0;