summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-06-02 07:26:58 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-06-02 07:26:58 +0000
commit1c4df2ab2436c68ccb00d0374fc4aab866b67308 (patch)
tree7a9b23cddbb536a26c39e5b47015102583a9bdfa
parent0802356cfca638775a67680aaa602259db745689 (diff)
export data from private streams
Originally committed as revision 19073 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/mpegts.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 6df828c363..d60a25ba4f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -923,6 +923,11 @@ static int mpegts_push_data(MpegTSFilter *filter,
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 *filter,
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 *filter,
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;