From 6303b0e80d0904f271a881e02aeffd2e91689121 Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Thu, 16 Jul 2009 12:03:32 +0200 Subject: pesfilter: Permit unbounded packets for 0xfd (extended stream id). Added parsing of PES extension related data. Fixes some VC1 related issues. --- gst/mpegdemux/gstpesfilter.c | 49 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'gst/mpegdemux/gstpesfilter.c') diff --git a/gst/mpegdemux/gstpesfilter.c b/gst/mpegdemux/gstpesfilter.c index b520c766..736d4960 100644 --- a/gst/mpegdemux/gstpesfilter.c +++ b/gst/mpegdemux/gstpesfilter.c @@ -151,6 +151,7 @@ gst_pes_filter_parse (GstPESFilter * filter) * to set the allow_unbounded flag if they want */ if (filter->length == 0 && ((filter->start_code & 0xFFFFFFF0) == PACKET_VIDEO_START_CODE || + filter->start_code == ID_EXTENDED_STREAM_ID || filter->allow_unbounded)) { GST_DEBUG ("id 0x%02x, unbounded length", filter->id); filter->unbounded_packet = TRUE; @@ -389,9 +390,53 @@ gst_pes_filter_parse (GstPESFilter * filter) } /* PES_extension_flag */ if ((flags & 0x01)) { - GST_DEBUG ("%x PES_extension", filter->id); + flags = *data++; + header_data_length -= 1; + datalen -= 1; + GST_DEBUG ("%x PES_extension, flags 0x%02x", filter->id, flags); + /* PES_private_data_flag */ + if ((flags & 0x80)) { + GST_DEBUG ("%x PES_private_data_flag", filter->id); + data += 16; + header_data_length -= 16; + datalen -= 16; + } + /* pack_header_field_flag */ + if ((flags & 0x40)) { + guint8 pack_field_length = *data; + GST_DEBUG ("%x pack_header_field_flag, pack_field_length %d", + filter->id, pack_field_length); + data += pack_field_length + 1; + header_data_length -= pack_field_length + 1; + datalen -= pack_field_length + 1; + } + /* program_packet_sequence_counter_flag */ + if ((flags & 0x20)) { + GST_DEBUG ("%x program_packet_sequence_counter_flag", filter->id); + data += 2; + header_data_length -= 2; + datalen -= 2; + } + /* P-STD_buffer_flag */ + if ((flags & 0x10)) { + GST_DEBUG ("%x P-STD_buffer_flag", filter->id); + data += 2; + header_data_length -= 2; + datalen -= 2; + } + /* PES_extension_flag_2 */ + if ((flags & 0x01)) { + guint8 PES_extension_field_length = *data++; + GST_DEBUG ("%x PES_extension_flag_2, len %d", + filter->id, PES_extension_field_length & 0x7f); + if (PES_extension_field_length == 0x81) { + GST_DEBUG ("%x substream id 0x%02x", filter->id, *data); + } + data += PES_extension_field_length & 0x7f; + header_data_length -= (PES_extension_field_length & 0x7f) + 1; + datalen -= (PES_extension_field_length & 0x7f) + 1; + } } - /* calculate the amount of real data in this PES packet */ data += header_data_length; datalen -= header_data_length; -- cgit v1.2.1