2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) 2009 Tim-Philipp Müller <tim centricular net>
4 * Copyright (C) <2009> STEricsson <benjamin.gaignard@stericsson.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "qtdemux_types.h"
23 #include "qtdemux_dump.h"
26 #include "qtatomparser.h"
30 #define GET_UINT8(data) gst_byte_reader_get_uint8_unchecked(data)
31 #define GET_UINT16(data) gst_byte_reader_get_uint16_be_unchecked(data)
32 #define GET_UINT32(data) gst_byte_reader_get_uint32_be_unchecked(data)
33 #define GET_UINT64(data) gst_byte_reader_get_uint64_be_unchecked(data)
34 #define GET_FP32(data) (gst_byte_reader_get_uint32_be_unchecked(data)/65536.0)
35 #define GET_FP16(data) (gst_byte_reader_get_uint16_be_unchecked(data)/256.0)
36 #define GET_FOURCC(data) qt_atom_parser_get_fourcc_unchecked(data)
39 qtdemux_dump_mvhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
43 if (!qt_atom_parser_has_remaining (data, 100))
46 version = GET_UINT32 (data);
47 GST_LOG ("%*s version/flags: %08x", depth, "", version);
49 version = version >> 24;
51 GST_LOG ("%*s creation time: %u", depth, "", GET_UINT32 (data));
52 GST_LOG ("%*s modify time: %u", depth, "", GET_UINT32 (data));
53 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
54 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
55 } else if (version == 1) {
56 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT,
57 depth, "", GET_UINT64 (data));
58 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT,
59 depth, "", GET_UINT64 (data));
60 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
61 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT,
62 depth, "", GET_UINT64 (data));
66 GST_LOG ("%*s pref. rate: %g", depth, "", GET_FP32 (data));
67 GST_LOG ("%*s pref. volume: %g", depth, "", GET_FP16 (data));
68 gst_byte_reader_skip_unchecked (data, 46);
69 GST_LOG ("%*s preview time: %u", depth, "", GET_UINT32 (data));
70 GST_LOG ("%*s preview dur.: %u", depth, "", GET_UINT32 (data));
71 GST_LOG ("%*s poster time: %u", depth, "", GET_UINT32 (data));
72 GST_LOG ("%*s select time: %u", depth, "", GET_UINT32 (data));
73 GST_LOG ("%*s select dur.: %u", depth, "", GET_UINT32 (data));
74 GST_LOG ("%*s current time: %u", depth, "", GET_UINT32 (data));
75 GST_LOG ("%*s next track ID: %d", depth, "", GET_UINT32 (data));
80 qtdemux_dump_tkhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
82 guint64 duration, ctime, mtime;
83 guint32 version = 0, track_id = 0, iwidth = 0, iheight = 0;
84 guint16 layer = 0, alt_group = 0, ivol = 0;
87 if (!gst_byte_reader_get_uint32_be (data, &version))
90 GST_LOG ("%*s version/flags: %08x", depth, "", version);
92 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
94 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
95 qt_atom_parser_get_offset (data, value_size, &mtime) &&
96 gst_byte_reader_get_uint32_be (data, &track_id) &&
97 gst_byte_reader_skip (data, 4) &&
98 qt_atom_parser_get_offset (data, value_size, &duration) &&
99 gst_byte_reader_skip (data, 4) &&
100 gst_byte_reader_get_uint16_be (data, &layer) &&
101 gst_byte_reader_get_uint16_be (data, &alt_group) &&
102 gst_byte_reader_skip (data, 4) &&
103 gst_byte_reader_get_uint16_be (data, &ivol) &&
104 gst_byte_reader_skip (data, 2 + (9 * 4)) &&
105 gst_byte_reader_get_uint32_be (data, &iwidth) &&
106 gst_byte_reader_get_uint32_be (data, &iheight)) {
107 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
108 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
109 GST_LOG ("%*s track ID: %u", depth, "", track_id);
110 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
111 GST_LOG ("%*s layer: %u", depth, "", layer);
112 GST_LOG ("%*s alt group: %u", depth, "", alt_group);
113 GST_LOG ("%*s volume: %g", depth, "", ivol / 256.0);
114 GST_LOG ("%*s track width: %g", depth, "", iwidth / 65536.0);
115 GST_LOG ("%*s track height: %g", depth, "", iheight / 65536.0);
123 qtdemux_dump_elst (GstQTDemux * qtdemux, GstByteReader * data, int depth)
125 guint32 ver_flags = 0, num_entries = 0, i;
127 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
128 !gst_byte_reader_get_uint32_be (data, &num_entries))
131 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
132 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
134 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
137 for (i = 0; i < num_entries; i++) {
138 GST_LOG ("%*s track dur: %u", depth, "", GET_UINT32 (data));
139 GST_LOG ("%*s media time: %u", depth, "", GET_UINT32 (data));
140 GST_LOG ("%*s media rate: %g", depth, "", GET_FP32 (data));
146 qtdemux_dump_mdhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
149 guint64 duration, ctime, mtime;
150 guint32 time_scale = 0;
151 guint16 language = 0, quality = 0;
154 if (!gst_byte_reader_get_uint32_be (data, &version))
157 GST_LOG ("%*s version/flags: %08x", depth, "", version);
159 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
161 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
162 qt_atom_parser_get_offset (data, value_size, &mtime) &&
163 gst_byte_reader_get_uint32_be (data, &time_scale) &&
164 qt_atom_parser_get_offset (data, value_size, &duration) &&
165 gst_byte_reader_get_uint16_be (data, &language) &&
166 gst_byte_reader_get_uint16_be (data, &quality)) {
167 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
168 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
169 GST_LOG ("%*s time scale: 1/%u sec", depth, "", time_scale);
170 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
171 GST_LOG ("%*s language: %u", depth, "", language);
172 GST_LOG ("%*s quality: %u", depth, "", quality);
180 qtdemux_dump_hdlr (GstQTDemux * qtdemux, GstByteReader * data, int depth)
182 guint32 version, type, subtype, manufacturer;
185 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4 + 1))
188 version = GET_UINT32 (data);
189 type = GET_FOURCC (data);
190 subtype = GET_FOURCC (data);
191 manufacturer = GET_FOURCC (data);
193 GST_LOG ("%*s version/flags: %08x", depth, "", version);
194 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
195 GST_FOURCC_ARGS (type));
196 GST_LOG ("%*s subtype: %" GST_FOURCC_FORMAT, depth, "",
197 GST_FOURCC_ARGS (subtype));
198 GST_LOG ("%*s manufacturer: %" GST_FOURCC_FORMAT, depth, "",
199 GST_FOURCC_ARGS (manufacturer));
200 GST_LOG ("%*s flags: %08x", depth, "", GET_UINT32 (data));
201 GST_LOG ("%*s flags mask: %08x", depth, "", GET_UINT32 (data));
203 /* quicktime uses pascal string, mp4 zero-terminated string */
204 if (gst_byte_reader_peek_string (data, &name)) {
205 GST_LOG ("%*s name: %s", depth, "", name);
210 len = gst_byte_reader_get_uint8_unchecked (data);
211 if (qt_atom_parser_has_remaining (data, len)) {
212 memcpy (buf, gst_byte_reader_peek_data_unchecked (data), len);
214 GST_LOG ("%*s name: %s", depth, "", buf);
221 qtdemux_dump_vmhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
223 if (!qt_atom_parser_has_remaining (data, 4 + 4))
226 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
227 GST_LOG ("%*s mode/color: %08x", depth, "", GET_UINT32 (data));
232 qtdemux_dump_dref (GstQTDemux * qtdemux, GstByteReader * data, int depth)
234 guint32 ver_flags = 0, num_entries = 0, i;
236 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
237 !gst_byte_reader_get_uint32_be (data, &num_entries))
240 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
241 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
242 for (i = 0; i < num_entries; i++) {
243 guint32 size = 0, fourcc;
245 if (!gst_byte_reader_get_uint32_be (data, &size) ||
246 !qt_atom_parser_get_fourcc (data, &fourcc) || size < 8 ||
247 !gst_byte_reader_skip (data, size - 8))
250 GST_LOG ("%*s size: %u", depth, "", size);
251 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
252 GST_FOURCC_ARGS (fourcc));
258 qtdemux_dump_stsd_avc1 (GstQTDemux * qtdemux, GstByteReader * data, guint size,
263 /* Size of avc1 = 78 bytes */
264 if (size < (6 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 2 + 1 + 31 + 2 + 2))
267 gst_byte_reader_skip_unchecked (data, 6);
268 GST_LOG_OBJECT (qtdemux, "%*s data reference:%d", depth, "",
270 GST_LOG_OBJECT (qtdemux, "%*s version/rev.: %08x", depth, "",
272 fourcc = GET_FOURCC (data);
273 GST_LOG_OBJECT (qtdemux, "%*s vendor: %" GST_FOURCC_FORMAT, depth,
274 "", GST_FOURCC_ARGS (fourcc));
275 GST_LOG_OBJECT (qtdemux, "%*s temporal qual: %u", depth, "",
277 GST_LOG_OBJECT (qtdemux, "%*s spatial qual: %u", depth, "",
279 GST_LOG_OBJECT (qtdemux, "%*s width: %u", depth, "",
281 GST_LOG_OBJECT (qtdemux, "%*s height: %u", depth, "",
283 GST_LOG_OBJECT (qtdemux, "%*s horiz. resol: %g", depth, "",
285 GST_LOG_OBJECT (qtdemux, "%*s vert. resol.: %g", depth, "",
287 GST_LOG_OBJECT (qtdemux, "%*s data size: %u", depth, "",
289 GST_LOG_OBJECT (qtdemux, "%*s frame count: %u", depth, "",
291 /* something is not right with this, it's supposed to be a string but it's
292 * not apparently, so just skip this for now */
293 gst_byte_reader_skip_unchecked (data, 1 + 31);
294 GST_LOG_OBJECT (qtdemux, "%*s compressor: (skipped)", depth, "");
295 GST_LOG_OBJECT (qtdemux, "%*s depth: %u", depth, "",
297 GST_LOG_OBJECT (qtdemux, "%*s color table ID:%u", depth, "",
304 qtdemux_dump_stsd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
306 guint32 ver_flags = 0, num_entries = 0, i;
308 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
309 !gst_byte_reader_get_uint32_be (data, &num_entries))
312 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
313 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
315 for (i = 0; i < num_entries; i++) {
317 guint32 size, remain;
320 if (!gst_byte_reader_get_uint32_be (data, &size) ||
321 !qt_atom_parser_get_fourcc (data, &fourcc))
324 GST_LOG_OBJECT (qtdemux, "%*s size: %u", depth, "", size);
325 GST_LOG_OBJECT (qtdemux, "%*s type: %" GST_FOURCC_FORMAT, depth,
326 "", GST_FOURCC_ARGS (fourcc));
328 remain = gst_byte_reader_get_remaining (data);
329 /* Size includes the 8 bytes we just read: len & fourcc, then 8 bytes
330 * version, flags, entries_count */
331 if (size > remain + 8) {
332 GST_LOG_OBJECT (qtdemux,
333 "Not enough data left for this atom (have %u need %u)", remain, size);
337 qt_atom_parser_peek_sub (data, 0, size, &sub);
340 if (!qtdemux_dump_stsd_avc1 (qtdemux, &sub, size, depth + 1))
344 if (!gst_byte_reader_get_uint32_be (&sub, &ver_flags) ||
345 !gst_byte_reader_get_uint32_be (&sub, &num_entries))
347 if (!qtdemux_dump_unknown (qtdemux, &sub, depth + 1))
351 /* Unknown stsd data, dump the bytes */
352 if (!qtdemux_dump_unknown (qtdemux, &sub, depth + 1))
357 if (!gst_byte_reader_skip (data, size - (4 + 4)))
364 qtdemux_dump_stts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
366 guint32 ver_flags = 0, num_entries = 0, i;
368 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
369 !gst_byte_reader_get_uint32_be (data, &num_entries))
372 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
373 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
375 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
378 for (i = 0; i < num_entries; i++) {
379 GST_LOG ("%*s count: %u", depth, "", GET_UINT32 (data));
380 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
386 qtdemux_dump_stps (GstQTDemux * qtdemux, GstByteReader * data, int depth)
388 guint32 ver_flags = 0, num_entries = 0, i;
390 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
391 !gst_byte_reader_get_uint32_be (data, &num_entries))
394 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
395 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
397 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
400 for (i = 0; i < num_entries; i++) {
401 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
407 qtdemux_dump_stss (GstQTDemux * qtdemux, GstByteReader * data, int depth)
409 guint32 ver_flags = 0, num_entries = 0, i;
411 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
412 !gst_byte_reader_get_uint32_be (data, &num_entries))
415 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
416 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
418 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
421 for (i = 0; i < num_entries; i++) {
422 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
428 qtdemux_dump_stsc (GstQTDemux * qtdemux, GstByteReader * data, int depth)
430 guint32 ver_flags = 0, num_entries = 0, i;
432 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
433 !gst_byte_reader_get_uint32_be (data, &num_entries))
436 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
437 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
439 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
442 for (i = 0; i < num_entries; i++) {
443 GST_LOG ("%*s first chunk: %u", depth, "", GET_UINT32 (data));
444 GST_LOG ("%*s sample per ch: %u", depth, "", GET_UINT32 (data));
445 GST_LOG ("%*s sample desc id:%08x", depth, "", GET_UINT32 (data));
451 qtdemux_dump_stsz (GstQTDemux * qtdemux, GstByteReader * data, int depth)
453 guint32 ver_flags = 0, sample_size = 0, num_entries = 0;
455 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
456 !gst_byte_reader_get_uint32_be (data, &sample_size))
459 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
460 GST_LOG ("%*s sample size: %d", depth, "", sample_size);
462 if (sample_size == 0) {
463 if (!gst_byte_reader_get_uint32_be (data, &num_entries))
466 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
468 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
470 for (i = 0; i < num_entries; i++) {
471 GST_LOG ("%*s sample size: %u", depth, "", GET_UINT32 (data));
479 qtdemux_dump_stco (GstQTDemux * qtdemux, GstByteReader * data, int depth)
481 guint32 ver_flags = 0, num_entries = 0, i;
483 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
484 !gst_byte_reader_get_uint32_be (data, &num_entries))
487 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
488 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
490 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
493 for (i = 0; i < num_entries; i++) {
494 GST_LOG ("%*s chunk offset: %u", depth, "", GET_UINT32 (data));
500 qtdemux_dump_ctts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
502 guint32 ver_flags = 0, num_entries = 0, i, count;
506 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
507 !gst_byte_reader_get_uint32_be (data, &num_entries))
510 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
511 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
513 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
516 for (i = 0; i < num_entries; i++) {
517 count = GET_UINT32 (data);
518 offset = GET_UINT32 (data);
519 GST_LOG ("%*s sample count :%8d offset: %8d", depth, "", count, offset);
525 qtdemux_dump_co64 (GstQTDemux * qtdemux, GstByteReader * data, int depth)
527 guint32 ver_flags = 0, num_entries = 0, i;
529 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
530 !gst_byte_reader_get_uint32_be (data, &num_entries))
533 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
534 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
536 if (!qt_atom_parser_has_chunks (data, num_entries, 8))
539 for (i = 0; i < num_entries; i++) {
540 GST_LOG ("%*s chunk offset: %" G_GUINT64_FORMAT, depth, "",
547 qtdemux_dump_dcom (GstQTDemux * qtdemux, GstByteReader * data, int depth)
549 if (!qt_atom_parser_has_remaining (data, 4))
552 GST_LOG ("%*s compression type: %" GST_FOURCC_FORMAT, depth, "",
553 GST_FOURCC_ARGS (GET_FOURCC (data)));
558 qtdemux_dump_cmvd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
560 if (!qt_atom_parser_has_remaining (data, 4))
563 GST_LOG ("%*s length: %d", depth, "", GET_UINT32 (data));
568 qtdemux_dump_mfro (GstQTDemux * qtdemux, GstByteReader * data, int depth)
570 if (!qt_atom_parser_has_remaining (data, 4))
573 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
574 GST_LOG ("%*s size: %d", depth, "", GET_UINT32 (data));
579 qtdemux_dump_mfhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
581 if (!qt_atom_parser_has_remaining (data, 4))
584 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
585 GST_LOG ("%*s sequence_number: %d", depth, "", GET_UINT32 (data));
590 qtdemux_dump_tfra (GstQTDemux * qtdemux, GstByteReader * data, int depth)
592 guint64 time = 0, moof_offset = 0;
593 guint32 len = 0, num_entries = 0, ver_flags = 0, track_id = 0, i;
594 guint value_size, traf_size, trun_size, sample_size;
596 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
599 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
601 if (!gst_byte_reader_get_uint32_be (data, &track_id) ||
602 !gst_byte_reader_get_uint32_be (data, &len) ||
603 !gst_byte_reader_get_uint32_be (data, &num_entries))
606 GST_LOG ("%*s track ID: %u", depth, "", track_id);
607 GST_LOG ("%*s length: 0x%x", depth, "", len);
608 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
610 value_size = ((ver_flags >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
611 sample_size = (len & 3) + 1;
612 trun_size = ((len & 12) >> 2) + 1;
613 traf_size = ((len & 48) >> 4) + 1;
615 if (!qt_atom_parser_has_chunks (data, num_entries,
616 value_size + value_size + traf_size + trun_size + sample_size))
619 for (i = 0; i < num_entries; i++) {
620 qt_atom_parser_get_offset (data, value_size, &time);
621 qt_atom_parser_get_offset (data, value_size, &moof_offset);
622 GST_LOG ("%*s time: %" G_GUINT64_FORMAT, depth, "", time);
623 GST_LOG ("%*s moof_offset: %" G_GUINT64_FORMAT,
624 depth, "", moof_offset);
625 GST_LOG ("%*s traf_number: %u", depth, "",
626 qt_atom_parser_get_uint_with_size_unchecked (data, traf_size));
627 GST_LOG ("%*s trun_number: %u", depth, "",
628 qt_atom_parser_get_uint_with_size_unchecked (data, trun_size));
629 GST_LOG ("%*s sample_number: %u", depth, "",
630 qt_atom_parser_get_uint_with_size_unchecked (data, sample_size));
637 qtdemux_dump_tfhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
639 guint32 flags = 0, n = 0, track_id = 0;
640 guint64 base_data_offset = 0;
642 if (!gst_byte_reader_skip (data, 1) ||
643 !gst_byte_reader_get_uint24_be (data, &flags))
645 GST_LOG ("%*s flags: %08x", depth, "", flags);
647 if (!gst_byte_reader_get_uint32_be (data, &track_id))
649 GST_LOG ("%*s track_id: %u", depth, "", track_id);
651 if (flags & TF_BASE_DATA_OFFSET) {
652 if (!gst_byte_reader_get_uint64_be (data, &base_data_offset))
654 GST_LOG ("%*s base-data-offset: %" G_GUINT64_FORMAT,
655 depth, "", base_data_offset);
658 if (flags & TF_SAMPLE_DESCRIPTION_INDEX) {
659 if (!gst_byte_reader_get_uint32_be (data, &n))
661 GST_LOG ("%*s sample-description-index: %u", depth, "", n);
664 if (flags & TF_DEFAULT_SAMPLE_DURATION) {
665 if (!gst_byte_reader_get_uint32_be (data, &n))
667 GST_LOG ("%*s default-sample-duration: %u", depth, "", n);
670 if (flags & TF_DEFAULT_SAMPLE_SIZE) {
671 if (!gst_byte_reader_get_uint32_be (data, &n))
673 GST_LOG ("%*s default-sample-size: %u", depth, "", n);
676 if (flags & TF_DEFAULT_SAMPLE_FLAGS) {
677 if (!gst_byte_reader_get_uint32_be (data, &n))
679 GST_LOG ("%*s default-sample-flags: %u", depth, "", n);
682 GST_LOG ("%*s duration-is-empty: %s", depth, "",
683 flags & TF_DURATION_IS_EMPTY ? "yes" : "no");
689 qtdemux_dump_trun (GstQTDemux * qtdemux, GstByteReader * data, int depth)
691 guint32 flags = 0, samples_count = 0, data_offset = 0, first_sample_flags = 0;
692 guint32 sample_duration = 0, sample_size = 0, sample_flags =
693 0, composition_time_offsets = 0;
696 if (!gst_byte_reader_skip (data, 1) ||
697 !gst_byte_reader_get_uint24_be (data, &flags))
700 GST_LOG ("%*s flags: %08x", depth, "", flags);
702 if (!gst_byte_reader_get_uint32_be (data, &samples_count))
704 GST_LOG ("%*s samples_count: %u", depth, "", samples_count);
706 if (flags & TR_DATA_OFFSET) {
707 if (!gst_byte_reader_get_uint32_be (data, &data_offset))
709 GST_LOG ("%*s data-offset: %u", depth, "", data_offset);
712 if (flags & TR_FIRST_SAMPLE_FLAGS) {
713 if (!gst_byte_reader_get_uint32_be (data, &first_sample_flags))
715 GST_LOG ("%*s first-sample-flags: %u", depth, "", first_sample_flags);
718 for (i = 0; i < samples_count; i++) {
719 if (flags & TR_SAMPLE_DURATION) {
720 if (!gst_byte_reader_get_uint32_be (data, &sample_duration))
722 GST_LOG ("%*s sample-duration: %u", depth, "", sample_duration);
725 if (flags & TR_SAMPLE_SIZE) {
726 if (!gst_byte_reader_get_uint32_be (data, &sample_size))
728 GST_LOG ("%*s sample-size: %u", depth, "", sample_size);
731 if (flags & TR_SAMPLE_FLAGS) {
732 if (!gst_byte_reader_get_uint32_be (data, &sample_flags))
734 GST_LOG ("%*s sample-flags: %u", depth, "", sample_flags);
737 if (flags & TR_COMPOSITION_TIME_OFFSETS) {
738 if (!gst_byte_reader_get_uint32_be (data, &composition_time_offsets))
740 GST_LOG ("%*s composition_time_offsets: %u", depth, "",
741 composition_time_offsets);
749 qtdemux_dump_trex (GstQTDemux * qtdemux, GstByteReader * data, int depth)
751 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4))
754 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
755 GST_LOG ("%*s track ID: %08x", depth, "", GET_UINT32 (data));
756 GST_LOG ("%*s default sample desc. index: %08x", depth, "",
758 GST_LOG ("%*s default sample duration: %08x", depth, "",
760 GST_LOG ("%*s default sample size: %08x", depth, "",
762 GST_LOG ("%*s default sample flags: %08x", depth, "",
769 qtdemux_dump_mehd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
772 guint64 fragment_duration;
775 if (!gst_byte_reader_get_uint32_be (data, &version))
778 GST_LOG ("%*s version/flags: %08x", depth, "", version);
780 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
781 if (qt_atom_parser_get_offset (data, value_size, &fragment_duration)) {
782 GST_LOG ("%*s fragment duration: %" G_GUINT64_FORMAT,
783 depth, "", fragment_duration);
791 qtdemux_dump_tfdt (GstQTDemux * qtdemux, GstByteReader * data, int depth)
797 if (!gst_byte_reader_get_uint32_be (data, &version))
800 GST_LOG ("%*s version/flags: %08x", depth, "", version);
802 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
803 if (qt_atom_parser_get_offset (data, value_size, &decode_time)) {
804 GST_LOG ("%*s Track fragment decode time: %" G_GUINT64_FORMAT,
805 depth, "", decode_time);
813 qtdemux_dump_sdtp (GstQTDemux * qtdemux, GstByteReader * data, int depth)
819 version = GET_UINT32 (data);
820 GST_LOG ("%*s version/flags: %08x", depth, "", version);
822 /* the sample_count is specified in the stsz or stz2 box.
823 * the information for a sample is stored in a single byte,
824 * so we read until there are no remaining bytes */
825 while (qt_atom_parser_has_remaining (data, 1)) {
826 val = GET_UINT8 (data);
827 GST_LOG ("%*s sample number: %d", depth, "", i);
828 GST_LOG ("%*s sample_depends_on: %d", depth, "",
829 ((guint16) (val)) & 0x3);
830 GST_LOG ("%*s sample_is_depended_on: %d", depth, "",
831 ((guint16) (val >> 2)) & 0x3);
832 GST_LOG ("%*s sample_has_redundancy: %d", depth, "",
833 ((guint16) (val >> 4)) & 0x3);
834 GST_LOG ("%*s early display: %d", depth, "",
835 ((guint16) (val >> 6)) & 0x1);
842 qtdemux_dump_svmi (GstQTDemux * qtdemux, GstByteReader * data, int depth)
845 guint stereo_mono_change_count;
848 version = GET_UINT32 (data);
849 GST_LOG ("%*s version/flags: %08x", depth, "", version);
852 /* stereoscopic visual type information */
853 GST_LOG ("%*s stereo_composition_type: %d", depth, "",
855 GST_LOG ("%*s is_left_first: %d", depth, "",
856 ((guint8) GET_UINT8 (data)) & 0x01);
858 /* stereo_mono_change information */
859 stereo_mono_change_count = GET_UINT32 (data);
860 GST_LOG ("%*s stereo_mono_change_count: %d", depth, "",
861 stereo_mono_change_count);
862 for (i = 1; i <= stereo_mono_change_count; i++) {
863 GST_LOG ("%*s sample_count: %d", depth, "", GET_UINT32 (data));
864 GST_LOG ("%*s stereo_flag: %d", depth, "",
865 ((guint8) GET_UINT8 (data)) & 0x01);
872 qtdemux_dump_unknown (GstQTDemux * qtdemux, GstByteReader * data, int depth)
876 len = gst_byte_reader_get_remaining (data);
877 GST_LOG ("%*s length: %d", depth, "", len);
879 GST_MEMDUMP_OBJECT (qtdemux, "unknown atom data",
880 gst_byte_reader_peek_data_unchecked (data), len);
885 qtdemux_node_dump_foreach (GNode * node, gpointer qtdemux)
887 GstByteReader parser;
888 guint8 *buffer = (guint8 *) node->data; /* FIXME: move to byte reader */
891 const QtNodeType *type;
894 node_length = GST_READ_UINT32_BE (buffer);
895 fourcc = GST_READ_UINT32_LE (buffer + 4);
897 g_warn_if_fail (node_length >= 8);
899 gst_byte_reader_init (&parser, buffer + 8, node_length - 8);
901 type = qtdemux_type_get (fourcc);
903 depth = (g_node_depth (node) - 1) * 2;
904 GST_LOG ("%*s'%" GST_FOURCC_FORMAT "', [%d], %s",
905 depth, "", GST_FOURCC_ARGS (fourcc), node_length, type->name);
910 ret = type->dump (GST_QTDEMUX_CAST (qtdemux), &parser, depth);
913 GST_WARNING ("%*s not enough data parsing atom %" GST_FOURCC_FORMAT,
914 depth, "", GST_FOURCC_ARGS (fourcc));
922 qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node)
924 #ifndef GST_DISABLE_GST_DEBUG
925 /* Only traverse/dump if we know it will be outputted in the end */
926 if (qtdemux_debug->threshold < GST_LEVEL_LOG)
929 g_node_traverse (node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
930 qtdemux_node_dump_foreach, qtdemux);