]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpegvideo_parser.c
mpeg12_parser: make mpegvideo_split() more robust
[ffmpeg] / libavcodec / mpegvideo_parser.c
index cfc950d017d0116ef2d647a0f275857cebba3729..25028a9eb10d8e6975fcef0e330efe78ad394292 100644 (file)
@@ -151,10 +151,8 @@ static int mpegvideo_parse(AVCodecParserContext *s,
        to have the full timing information. The time take by this
        function should be negligible for uncorrupted streams */
     mpegvideo_extract_headers(s, avctx, buf, buf_size);
-#if 0
-    printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
-           s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);
-#endif
+    av_dlog(NULL, "pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
+            s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);
 
     *poutbuf = buf;
     *poutbuf_size = buf_size;
@@ -166,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;