aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-06-02 07:53:44 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2009-06-02 07:53:44 +0000
commitb2984add8077ecc9d3cdf0d9294fb323f2001511 (patch)
treedb722fad689ebf36b738f445034d29f023bde5d0
parent617c461625daa5d569345df55e6cedc4b6100ec1 (diff)
downloadffmpeg-b2984add8077ecc9d3cdf0d9294fb323f2001511.tar.gz
do not parse full header for private streams
Originally committed as revision 19075 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/mpegts.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index df281571b1..031c460dd6 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -128,13 +128,15 @@ struct MpegTSContext {
enum MpegTSState {
MPEGTS_HEADER = 0,
+ MPEGTS_PESHEADER,
MPEGTS_PESHEADER_FILL,
MPEGTS_PAYLOAD,
MPEGTS_SKIP,
};
/* enough for PES header + length */
-#define PES_START_SIZE 9
+#define PES_START_SIZE 6
+#define PES_HEADER_SIZE 9
#define MAX_PES_HEADER_SIZE (9 + 255)
struct PESContext {
@@ -951,8 +953,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
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;
+ pes->state = MPEGTS_PESHEADER;
} else {
pes->state = MPEGTS_PAYLOAD;
pes->data_index = 0;
@@ -968,6 +969,21 @@ static int mpegts_push_data(MpegTSFilter *filter,
break;
/**********************************************/
/* PES packing parsing */
+ case MPEGTS_PESHEADER:
+ len = PES_HEADER_SIZE - pes->data_index;
+ if (len < 0)
+ return -1;
+ if (len > buf_size)
+ len = buf_size;
+ memcpy(pes->header + pes->data_index, p, len);
+ pes->data_index += len;
+ p += len;
+ buf_size -= len;
+ if (pes->data_index == PES_HEADER_SIZE) {
+ pes->pes_header_size = pes->header[8] + 9;
+ pes->state = MPEGTS_PESHEADER_FILL;
+ }
+ break;
case MPEGTS_PESHEADER_FILL:
len = pes->pes_header_size - pes->data_index;
if (len < 0)