[FFmpeg-cvslog] r19073 - trunk/libavformat/mpegts.c

bcoudurier subversion
Tue Jun 2 09:26:59 CEST 2009


Author: bcoudurier
Date: Tue Jun  2 09:26:58 2009
New Revision: 19073

Log:
export data from private streams

Modified:
   trunk/libavformat/mpegts.c

Modified: trunk/libavformat/mpegts.c
==============================================================================
--- trunk/libavformat/mpegts.c	Mon Jun  1 18:07:48 2009	(r19072)
+++ trunk/libavformat/mpegts.c	Tue Jun  2 09:26:58 2009	(r19073)
@@ -923,6 +923,11 @@ static int mpegts_push_data(MpegTSFilter
                     pes->header[2] == 0x01) {
                     /* it must be an mpeg2 PES stream */
                     code = pes->header[3] | 0x100;
+                    dprintf(pes->stream, "pid=%x pes_code=%#x\n", pes->pid, code);
+
+                    if ((pes->st && pes->st->discard == AVDISCARD_ALL) ||
+                        code == 0x1be) /* padding_stream */
+                        goto skip;
 
                     /* stream not present in PMT */
                     if (!pes->st)
@@ -930,16 +935,27 @@ static int mpegts_push_data(MpegTSFilter
                     if (!pes->st)
                         return AVERROR(ENOMEM);
 
-                    if (pes->st->discard == AVDISCARD_ALL ||
-                        !((code >= 0x1c0 && code <= 0x1df) ||
-                          (code >= 0x1e0 && code <= 0x1ef) ||
-                          (code == 0x1bd) || (code == 0x1fd)))
-                        goto skip;
-                    pes->state = MPEGTS_PESHEADER_FILL;
                     pes->total_size = AV_RB16(pes->header + 4);
                     /* NOTE: a zero total size means the PES size is
                        unbounded */
-                    pes->pes_header_size = pes->header[8] + 9;
+                    if (!pes->total_size)
+                        pes->total_size = MAX_PES_PAYLOAD;
+
+                    /* allocate pes buffer */
+                    pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
+                    if (!pes->buffer)
+                        return AVERROR(ENOMEM);
+
+                    if (code != 0x1bc && code != 0x1bf && /* program_stream_map, private_stream_2 */
+                        code != 0x1f0 && code != 0x1f1 && /* ECM, EMM */
+                        code != 0x1ff && code != 0x1f2 && /* program_stream_directory, DSMCC_stream */
+                        code != 0x1f8) {                  /* ITU-T Rec. H.222.1 type E stream */
+                        pes->state = MPEGTS_PESHEADER_FILL;
+                        pes->pes_header_size = pes->header[8] + 9;
+                    } else {
+                        pes->state = MPEGTS_PAYLOAD;
+                        pes->data_index = 0;
+                    }
                 } else {
                     /* otherwise, it should be a table */
                     /* skip packet */
@@ -979,15 +995,6 @@ static int mpegts_push_data(MpegTSFilter
                     r += 5;
                 }
 
-                if (pes->total_size > pes->data_index - 6)
-                    pes->total_size -= pes->data_index - 6;
-                else
-                    pes->total_size = MAX_PES_PAYLOAD;
-                /* allocate pes buffer */
-                pes->buffer = av_malloc(pes->total_size+FF_INPUT_BUFFER_PADDING_SIZE);
-                if (!pes->buffer)
-                    return AVERROR(ENOMEM);
-
                 /* we got the full header. We parse it and get the payload */
                 pes->state = MPEGTS_PAYLOAD;
                 pes->data_index = 0;



More information about the ffmpeg-cvslog mailing list