[FFmpeg-cvslog] avformat/mpeg: do not count PES packets inside PES packets during probing

Michael Niedermayer git at videolan.org
Sun Jan 18 00:23:35 CET 2015


ffmpeg | branch: release/2.4 | Michael Niedermayer <michaelni at gmx.at> | Sat Dec  6 22:33:09 2014 +0100| [705e0e05131fc64df76631947136571eafea8bfb] | committer: Michael Niedermayer

avformat/mpeg: do not count PES packets inside PES packets during probing

Fixes: misdetection of test2.mp3

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit e15b29bb18bee8b65fab5a3c873540e01fd20afe)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=705e0e05131fc64df76631947136571eafea8bfb
---

 libavformat/mpeg.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index b153727..c2ec1e2 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -70,20 +70,23 @@ static int mpegps_probe(AVProbeData *p)
     int i;
     int sys = 0, pspack = 0, priv1 = 0, vid = 0;
     int audio = 0, invalid = 0, score = 0;
+    int endpes = 0;
 
     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);
+            int pes  = endpes <= i && check_pes(p->buf + i, p->buf + p->buf_size);
             int pack = check_pack_header(p->buf + i);
 
             if (code == SYSTEM_HEADER_START_CODE)
                 sys++;
             else if (code == PACK_START_CODE && pack)
                 pspack++;
-            else if ((code & 0xf0) == VIDEO_ID && pes)
+            else if ((code & 0xf0) == VIDEO_ID && pes) {
+                endpes = i + len;
                 vid++;
+            }
             // skip pes payload to avoid start code emulation for private
             // and audio streams
             else if ((code & 0xe0) == AUDIO_ID &&  pes) {audio++; i+=len;}



More information about the ffmpeg-cvslog mailing list