qtdemux: use GstByteReader when parsing tkhd atom

This commit is contained in:
Tim-Philipp Müller 2009-08-20 01:21:04 +01:00
parent 6b7f4f5e23
commit a16feec38e

View file

@ -4065,8 +4065,8 @@ done:
static gboolean static gboolean
qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
{ {
QtAtomParser tkhd;
int offset; int offset;
GNode *tkhd;
GNode *mdia; GNode *mdia;
GNode *mdhd; GNode *mdhd;
GNode *hdlr; GNode *hdlr;
@ -4083,6 +4083,8 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
gchar *codec = NULL; gchar *codec = NULL;
const guint8 *stsd_data; const guint8 *stsd_data;
guint32 version; guint32 version;
guint32 tkhd_flags;
guint8 tkhd_version;
stream = g_new0 (QtDemuxStream, 1); stream = g_new0 (QtDemuxStream, 1);
/* new streams always need a discont */ /* new streams always need a discont */
@ -4094,11 +4096,13 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
stream->sample_index = -1; stream->sample_index = -1;
stream->last_ret = GST_FLOW_OK; stream->last_ret = GST_FLOW_OK;
if (!(tkhd = qtdemux_tree_get_child_by_type (trak, FOURCC_tkhd))) if (!qtdemux_tree_get_child_by_type_full (trak, FOURCC_tkhd, &tkhd) ||
!qt_atom_parser_get_uint8 (&tkhd, &tkhd_version) ||
!qt_atom_parser_get_uint24 (&tkhd, &tkhd_flags))
goto corrupt_file; goto corrupt_file;
GST_LOG_OBJECT (qtdemux, "track[tkhd] version/flags: 0x%08x", GST_LOG_OBJECT (qtdemux, "track[tkhd] version/flags: 0x%02x/%06x",
QT_UINT32 ((guint8 *) tkhd->data + 8)); tkhd_version, tkhd_flags);
if (!(mdia = qtdemux_tree_get_child_by_type (trak, FOURCC_mdia))) if (!(mdia = qtdemux_tree_get_child_by_type (trak, FOURCC_mdia)))
goto corrupt_file; goto corrupt_file;
@ -4173,15 +4177,18 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
stsd_data = (const guint8 *) stsd->data; stsd_data = (const guint8 *) stsd->data;
if (stream->subtype == FOURCC_vide) { if (stream->subtype == FOURCC_vide) {
guint32 fourcc; guint32 w, h, fourcc;
const guint8 *tkhd_data = (const guint8 *) tkhd->data;
stream->sampled = TRUE; stream->sampled = TRUE;
/* version 1 uses some 64-bit ints */ /* version 1 uses some 64-bit ints */
offset = (QT_UINT8 (tkhd_data + 8) == 1) ? 96 : 84; if (!qt_atom_parser_skip (&tkhd, (tkhd_version == 1) ? 84 : 72) ||
stream->display_width = (guint) QT_FP32 (tkhd_data + offset); !qt_atom_parser_get_uint32 (&tkhd, &w) ||
stream->display_height = (guint) QT_FP32 (tkhd_data + offset + 4); !qt_atom_parser_get_uint32 (&tkhd, &h))
goto corrupt_file;
stream->display_width = w >> 16;
stream->display_height = h >> 16;
offset = 16; offset = 16;
stream->fourcc = fourcc = QT_FOURCC (stsd_data + offset + 4); stream->fourcc = fourcc = QT_FOURCC (stsd_data + offset + 4);