[FFmpeg-devel] [PATCH] mpegps: skip pes payload during probing to avoid start code emulation

Janne Grunau janne-ffmpeg
Thu May 13 01:18:37 CEST 2010


Hi,

the mpeg ps probe function needs for some evob files a large probe
buffer (1M). This is caused by start code emulation in PRIVATE_STREAM_1.
Attached patch skips the pes payload for audio and private_stream_1
streams. It also validates private_stream_1 streams with check_pes.

probetest doesn't find new false positives with the patch.

Janne
-------------- next part --------------
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 4224a04..4d1db25 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -60,16 +60,20 @@ static int mpegps_probe(AVProbeData *p)
     for(i=0; i<p->buf_size; i++){
         code = (code<<8) + p->buf[i];
         if ((code & 0xffffff00) == 0x100) {
+            int len= p->buf[i+1] << 8 | p->buf[i+2];
             int pes= check_pes(p->buf+i, p->buf+p->buf_size);
 
             if(code == SYSTEM_HEADER_START_CODE) sys++;
-            else if(code == PRIVATE_STREAM_1)    priv1++;
             else if(code == PACK_START_CODE)     pspack++;
             else if((code & 0xf0) == VIDEO_ID &&  pes) vid++;
-            else if((code & 0xe0) == AUDIO_ID &&  pes) audio++;
+            // skip pes payload to avoid start code emulation for private
+            // and audio streams
+            else if((code & 0xe0) == AUDIO_ID &&  pes) {audio++; i+=len;}
+            else if(code == PRIVATE_STREAM_1  &&  pes) {priv1++; i+=len;}
 
             else if((code & 0xf0) == VIDEO_ID && !pes) invalid++;
             else if((code & 0xe0) == AUDIO_ID && !pes) invalid++;
+            else if(code == PRIVATE_STREAM_1  && !pes) invalid++;
         }
     }
 



More information about the ffmpeg-devel mailing list