From 76aedf56412f709896f5c60d83e4f2a66e7e9a3d Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 12 Jul 2012 10:13:50 +0200 Subject: tsdemux: more correctly determine expected PES packet payload size ... particularly considering that packet_length == 0 is possible. --- gst/mpegtsdemux/tsdemux.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'gst/mpegtsdemux') diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index bc516a7dd..2deb37296 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -1300,8 +1300,16 @@ gst_ts_demux_parse_pes_header (GstTSDemux * demux, TSDemuxStream * stream, /* Remove PES headers */ GST_DEBUG ("Moving data forward by %d bytes (packet_size:%d, have:%d)", header.header_size, header.packet_length, length); - g_assert (header.packet_length >= header.header_size); - stream->expected_size = header.packet_length - header.header_size; + stream->expected_size = header.packet_length; + if (stream->expected_size) { + if (G_LIKELY (stream->expected_size > header.header_size)) { + stream->expected_size -= header.header_size; + } else { + /* next packet will have to complete this one */ + GST_ERROR ("invalid header and packet size combination"); + stream->expected_size = 0; + } + } data += header.header_size; length -= header.header_size; -- cgit v1.2.1