diff options
author | Edward Hervey <bilboed@bilboed.com> | 2018-02-19 11:20:17 +0100 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2018-03-09 12:11:23 +0100 |
commit | 9700dcb1e464a815b21fac1060de9619ae76f391 (patch) | |
tree | be5c5ec37f0ba33319265544acd676ff0804d119 | |
parent | 16afbd4f12c06e4567ef2e6514277aec3ab22686 (diff) |
fixup qtdemux CC
-rw-r--r-- | gst/isomp4/fourcc.h | 2 | ||||
-rw-r--r-- | gst/isomp4/qtdemux.c | 39 |
2 files changed, 38 insertions, 3 deletions
diff --git a/gst/isomp4/fourcc.h b/gst/isomp4/fourcc.h index e3503cb59..6f467ffbb 100644 --- a/gst/isomp4/fourcc.h +++ b/gst/isomp4/fourcc.h @@ -97,7 +97,9 @@ G_BEGIN_DECLS #define FOURCC_avcC GST_MAKE_FOURCC('a','v','c','C') #define FOURCC_c608 GST_MAKE_FOURCC('c','6','0','8') #define FOURCC_c708 GST_MAKE_FOURCC('c','7','0','8') +#define FOURCC_ccdp GST_MAKE_FOURCC('c','c','d','p') #define FOURCC_cdat GST_MAKE_FOURCC('c','d','a','t') +#define FOURCC_cdt2 GST_MAKE_FOURCC('c','d','t','2') #define FOURCC_clcp GST_MAKE_FOURCC('c','l','c','p') #define FOURCC_clip GST_MAKE_FOURCC('c','l','i','p') #define FOURCC_cmov GST_MAKE_FOURCC('c','m','o','v') diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index b4f6303c8..94e908701 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -5353,16 +5353,49 @@ gst_qtdemux_align_buffer (GstQTDemux * demux, } static guint8 * -extract_cc_from_cdat (const guint8 * data, gsize size, gsize * cclen) +extract_cc_from_data (QtDemuxStream * stream, const guint8 * data, gsize size, + gsize * cclen) { guint8 *res = NULL; guint32 atom_length, fourcc; + QtDemuxStreamStsdEntry *stsd_entry; + + GST_MEMDUMP ("caption atom", data, size); *cclen = 0; if (size < 8) goto invalid_cdat; atom_length = QT_UINT32 (data); fourcc = QT_FOURCC (data + 4); + if (G_UNLIKELY (atom_length > size || atom_length == 8)) + goto invalid_cdat; + + /* Check if we have somethig compatible */ + stsd_entry = CUR_STREAM (stream); + switch (stsd_entry->fourcc) { + case FOURCC_c608: + /* Should be cdat or cdt2 */ + if (fourcc != FOURCC_cdat || fourcc != FOURCC_cdt2) { + GST_WARNING_OBJECT (stream->pad, + "Unknown data atom (%" GST_FOURCC_FORMAT ") for CEA608", + GST_FOURCC_ARGS (fourcc)); + goto invalid_cdat; + } + break; + case FOURCC_c708: + if (fourcc != FOURCC_ccdp) { + GST_WARNING_OBJECT (stream->pad, + "Unknown data atom (%" GST_FOURCC_FORMAT ") for CEA708", + GST_FOURCC_ARGS (fourcc)); + goto invalid_cdat; + } + break; + default: + /* Keep this here in case other closed caption formats are added */ + g_assert_not_reached (); + break; + } + if (G_UNLIKELY (atom_length > size || atom_length == 8 || fourcc != FOURCC_cdat)) @@ -5421,8 +5454,8 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream, guint8 *cc; gsize cclen = 0; /* For closed caption, we need to extract the information from the - * [cdat] atom */ - cc = extract_cc_from_cdat (map.data, map.size, &cclen); + * [cdat],[cdt2] or [ccdp] atom */ + cc = extract_cc_from_data (stream, map.data, map.size, &cclen); gst_buffer_unmap (buf, &map); gst_buffer_unref (buf); if (cc) { |