[FFmpeg-devel] [PATCH 2/3] mpegdemux: move private stream 1 handling out of mpegps_read_pes_header

Michael Niedermayer michaelni at gmx.at
Tue Jul 31 21:08:14 CEST 2012


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/mpeg.c |   28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 2dfcf6e..ba80913 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -348,18 +348,6 @@ static int mpegps_read_pes_header(AVFormatContext *s,
     if (startcode == PRIVATE_STREAM_1) {
         startcode = avio_r8(s->pb);
         len--;
-        if (startcode >= 0x80 && startcode <= 0xcf) {
-            /* audio: skip header */
-            avio_r8(s->pb);
-            avio_r8(s->pb);
-            avio_r8(s->pb);
-            len -= 3;
-            if (startcode >= 0xb0 && startcode <= 0xbf) {
-                /* MLP/TrueHD audio has a 4-byte header */
-                avio_r8(s->pb);
-                len--;
-            }
-        }
     }
     if(len<0)
         goto error_redo;
@@ -396,6 +384,22 @@ static int mpegps_read_packet(AVFormatContext *s,
     if (len < 0)
         return len;
 
+    if (startcode >= 0x80 && startcode <= 0xcf) {
+        if(len < 4)
+            goto skip;
+
+        /* audio: skip header */
+        avio_r8(s->pb);
+        avio_r8(s->pb);
+        avio_r8(s->pb);
+        len -= 3;
+        if (startcode >= 0xb0 && startcode <= 0xbf) {
+            /* MLP/TrueHD audio has a 4-byte header */
+            avio_r8(s->pb);
+            len--;
+        }
+    }
+
     /* now find stream */
     for(i=0;i<s->nb_streams;i++) {
         st = s->streams[i];
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list