From eaf4ce01d3be395ef88230f81382caaa0e678712 Mon Sep 17 00:00:00 2001 From: Pankaj Darak Date: Thu, 1 Oct 2015 12:32:33 +0100 Subject: [PATCH] typefinding: mpeg-ts detection improvement Allow AFC to be 0 for null pid packets. https://bugzilla.gnome.org/show_bug.cgi?id=726117 --- gst/typefind/gsttypefindfunctions.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 2bedf18c43..838e76e513 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -2338,10 +2338,15 @@ static GstStaticCaps mpegts_caps = GST_STATIC_CAPS ("video/mpegts, " (GST_MPEGTS_TYPEFIND_MAX_SYNC * 4) #define MPEGTS_HDR_SIZE 4 -/* Check for sync byte, error_indicator == 0 and packet has payload */ +/* Check for sync byte, error_indicator == 0 and packet has payload. + * Adaptation control field (data[3] & 0x30) may be zero for TS packets with + * null PIDs. Still, these streams are valid TS streams (for null packets, + * AFC is supposed to be 0x1, but the spec also says decoders should just + * discard any packets with AFC = 0x00) */ #define IS_MPEGTS_HEADER(data) (((data)[0] == 0x47) && \ (((data)[1] & 0x80) == 0x00) && \ - (((data)[3] & 0x30) != 0x00)) + ((((data)[3] & 0x30) != 0x00) || \ + ((((data)[3] & 0x30) == 0x00) && (((data)[1] & 0x1f) == 0x1f) && (((data)[2] & 0xff) == 0xff)))) /* Helper function to search ahead at intervals of packet_size for mpegts * headers */