From e16be12e373e10906a5d2846631023142883c96e Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 9 Feb 2018 11:20:38 +0100 Subject: [PATCH] qtdemux: More 'meta' atom parsing fixes Turns out everybody is doing it their own way, so peek into the meta atom itself to figure out which spec it is following --- gst/isomp4/qtdemux.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 9774ece8f7..b0deab5165 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -7521,13 +7521,27 @@ qtdemux_parse_node (GstQTDemux * qtdemux, GNode * node, const guint8 * buffer, case FOURCC_meta: { GST_DEBUG_OBJECT (qtdemux, "parsing meta atom"); + /* You are reading this correctly. QTFF specifies that the * metadata atom is a short atom, whereas ISO BMFF specifies - * it's a full atom. joy joy joy */ - if (qtdemux->major_brand == FOURCC_qt__) + * it's a full atom. But since so many people are doing things + * differently, we actually peek into the atom to see which + * variant it is */ + if (length < 16) { + GST_LOG_OBJECT (qtdemux, "skipping small %" GST_FOURCC_FORMAT " box", + GST_FOURCC_ARGS (fourcc)); + break; + } + if (QT_FOURCC (buffer + 12) == FOURCC_hdlr) { + /* Variant 1: What QTFF specifies. 'meta' is a short header which + * starts with a 'hldr' atom */ qtdemux_parse_container (qtdemux, node, buffer + 8, end); - else + } else if (QT_UINT32 (buffer + 8) == 0x00000000) { + /* Variant 2: What ISO BMFF specifies. 'meta' is a _full_ atom + * with version/flags both set to zero */ qtdemux_parse_container (qtdemux, node, buffer + 12, end); + } else + GST_WARNING_OBJECT (qtdemux, "Unknown 'meta' atom format"); break; } case FOURCC_mp4s: