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., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "qtdemux_types.h"
23 #include "qtdemux_dump.h"
25 #include "qtatomparser.h"
29 #define GET_UINT8(data) gst_byte_reader_get_uint8_unchecked(data)
30 #define GET_UINT16(data) gst_byte_reader_get_uint16_be_unchecked(data)
31 #define GET_UINT32(data) gst_byte_reader_get_uint32_be_unchecked(data)
32 #define GET_UINT64(data) gst_byte_reader_get_uint64_be_unchecked(data)
33 #define GET_FP32(data) (gst_byte_reader_get_uint32_be_unchecked(data)/65536.0)
34 #define GET_FP16(data) (gst_byte_reader_get_uint16_be_unchecked(data)/256.0)
35 #define GET_FOURCC(data) qt_atom_parser_get_fourcc_unchecked(data)
38 qtdemux_dump_mvhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
42 if (!qt_atom_parser_has_remaining (data, 100))
45 version = GET_UINT32 (data);
46 GST_LOG ("%*s version/flags: %08x", depth, "", version);
48 version = version >> 24;
50 GST_LOG ("%*s creation time: %u", depth, "", GET_UINT32 (data));
51 GST_LOG ("%*s modify time: %u", depth, "", GET_UINT32 (data));
52 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
53 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
54 } else if (version == 1) {
55 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT,
56 depth, "", GET_UINT64 (data));
57 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT,
58 depth, "", GET_UINT64 (data));
59 GST_LOG ("%*s time scale: 1/%u sec", depth, "", GET_UINT32 (data));
60 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT,
61 depth, "", GET_UINT64 (data));
65 GST_LOG ("%*s pref. rate: %g", depth, "", GET_FP32 (data));
66 GST_LOG ("%*s pref. volume: %g", depth, "", GET_FP16 (data));
67 gst_byte_reader_skip_unchecked (data, 46);
68 GST_LOG ("%*s preview time: %u", depth, "", GET_UINT32 (data));
69 GST_LOG ("%*s preview dur.: %u", depth, "", GET_UINT32 (data));
70 GST_LOG ("%*s poster time: %u", depth, "", GET_UINT32 (data));
71 GST_LOG ("%*s select time: %u", depth, "", GET_UINT32 (data));
72 GST_LOG ("%*s select dur.: %u", depth, "", GET_UINT32 (data));
73 GST_LOG ("%*s current time: %u", depth, "", GET_UINT32 (data));
74 GST_LOG ("%*s next track ID: %d", depth, "", GET_UINT32 (data));
79 qtdemux_dump_tkhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
81 guint64 duration, ctime, mtime;
82 guint32 version = 0, track_id = 0, iwidth = 0, iheight = 0;
83 guint16 layer = 0, alt_group = 0, ivol = 0;
86 if (!gst_byte_reader_get_uint32_be (data, &version))
89 GST_LOG ("%*s version/flags: %08x", depth, "", version);
91 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
93 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
94 qt_atom_parser_get_offset (data, value_size, &mtime) &&
95 gst_byte_reader_get_uint32_be (data, &track_id) &&
96 gst_byte_reader_skip (data, 4) &&
97 qt_atom_parser_get_offset (data, value_size, &duration) &&
98 gst_byte_reader_skip (data, 4) &&
99 gst_byte_reader_get_uint16_be (data, &layer) &&
100 gst_byte_reader_get_uint16_be (data, &alt_group) &&
101 gst_byte_reader_skip (data, 4) &&
102 gst_byte_reader_get_uint16_be (data, &ivol) &&
103 gst_byte_reader_skip (data, 2 + (9 * 4)) &&
104 gst_byte_reader_get_uint32_be (data, &iwidth) &&
105 gst_byte_reader_get_uint32_be (data, &iheight)) {
106 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
107 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
108 GST_LOG ("%*s track ID: %u", depth, "", track_id);
109 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
110 GST_LOG ("%*s layer: %u", depth, "", layer);
111 GST_LOG ("%*s alt group: %u", depth, "", alt_group);
112 GST_LOG ("%*s volume: %g", depth, "", ivol / 256.0);
113 GST_LOG ("%*s track width: %g", depth, "", iwidth / 65536.0);
114 GST_LOG ("%*s track height: %g", depth, "", iheight / 65536.0);
122 qtdemux_dump_elst (GstQTDemux * qtdemux, GstByteReader * data, int depth)
124 guint32 ver_flags = 0, num_entries = 0, i;
126 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
127 !gst_byte_reader_get_uint32_be (data, &num_entries))
130 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
131 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
133 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
136 for (i = 0; i < num_entries; i++) {
137 GST_LOG ("%*s track dur: %u", depth, "", GET_UINT32 (data));
138 GST_LOG ("%*s media time: %u", depth, "", GET_UINT32 (data));
139 GST_LOG ("%*s media rate: %g", depth, "", GET_FP32 (data));
145 qtdemux_dump_mdhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
148 guint64 duration, ctime, mtime;
149 guint32 time_scale = 0;
150 guint16 language = 0, quality = 0;
153 if (!gst_byte_reader_get_uint32_be (data, &version))
156 GST_LOG ("%*s version/flags: %08x", depth, "", version);
158 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
160 if (qt_atom_parser_get_offset (data, value_size, &ctime) &&
161 qt_atom_parser_get_offset (data, value_size, &mtime) &&
162 gst_byte_reader_get_uint32_be (data, &time_scale) &&
163 qt_atom_parser_get_offset (data, value_size, &duration) &&
164 gst_byte_reader_get_uint16_be (data, &language) &&
165 gst_byte_reader_get_uint16_be (data, &quality)) {
166 GST_LOG ("%*s creation time: %" G_GUINT64_FORMAT, depth, "", ctime);
167 GST_LOG ("%*s modify time: %" G_GUINT64_FORMAT, depth, "", mtime);
168 GST_LOG ("%*s time scale: 1/%u sec", depth, "", time_scale);
169 GST_LOG ("%*s duration: %" G_GUINT64_FORMAT, depth, "", duration);
170 GST_LOG ("%*s language: %u", depth, "", language);
171 GST_LOG ("%*s quality: %u", depth, "", quality);
179 qtdemux_dump_hdlr (GstQTDemux * qtdemux, GstByteReader * data, int depth)
181 guint32 version, type, subtype, manufacturer;
184 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4 + 1))
187 version = GET_UINT32 (data);
188 type = GET_FOURCC (data);
189 subtype = GET_FOURCC (data);
190 manufacturer = GET_FOURCC (data);
192 GST_LOG ("%*s version/flags: %08x", depth, "", version);
193 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
194 GST_FOURCC_ARGS (type));
195 GST_LOG ("%*s subtype: %" GST_FOURCC_FORMAT, depth, "",
196 GST_FOURCC_ARGS (subtype));
197 GST_LOG ("%*s manufacturer: %" GST_FOURCC_FORMAT, depth, "",
198 GST_FOURCC_ARGS (manufacturer));
199 GST_LOG ("%*s flags: %08x", depth, "", GET_UINT32 (data));
200 GST_LOG ("%*s flags mask: %08x", depth, "", GET_UINT32 (data));
202 /* quicktime uses pascal string, mp4 zero-terminated string */
203 if (gst_byte_reader_peek_string (data, &name)) {
204 GST_LOG ("%*s name: %s", depth, "", name);
209 len = gst_byte_reader_get_uint8_unchecked (data);
210 if (qt_atom_parser_has_remaining (data, len)) {
211 memcpy (buf, gst_byte_reader_peek_data_unchecked (data), len);
213 GST_LOG ("%*s name: %s", depth, "", buf);
220 qtdemux_dump_vmhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
222 if (!qt_atom_parser_has_remaining (data, 4 + 4))
225 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
226 GST_LOG ("%*s mode/color: %08x", depth, "", GET_UINT32 (data));
231 qtdemux_dump_dref (GstQTDemux * qtdemux, GstByteReader * data, int depth)
233 guint32 ver_flags = 0, num_entries = 0, i;
235 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
236 !gst_byte_reader_get_uint32_be (data, &num_entries))
239 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
240 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
241 for (i = 0; i < num_entries; i++) {
242 guint32 size = 0, fourcc;
244 if (!gst_byte_reader_get_uint32_be (data, &size) ||
245 !qt_atom_parser_get_fourcc (data, &fourcc) || size < 8 ||
246 !gst_byte_reader_skip (data, size - 8))
249 GST_LOG ("%*s size: %u", depth, "", size);
250 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
251 GST_FOURCC_ARGS (fourcc));
257 qtdemux_dump_stsd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
259 guint32 ver_flags = 0, num_entries = 0, i;
261 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
262 !gst_byte_reader_get_uint32_be (data, &num_entries))
265 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
266 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
268 for (i = 0; i < num_entries; i++) {
270 guint32 size = 0, fourcc;
272 if (!gst_byte_reader_get_uint32_be (data, &size) ||
273 !qt_atom_parser_get_fourcc (data, &fourcc))
276 GST_LOG ("%*s size: %u", depth, "", size);
277 GST_LOG ("%*s type: %" GST_FOURCC_FORMAT, depth, "",
278 GST_FOURCC_ARGS (fourcc));
280 if (size < (6 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 2 + 1 + 31 + 2 + 2))
283 qt_atom_parser_peek_sub (data, 0, 78, &sub);
284 gst_byte_reader_skip_unchecked (&sub, 6);
285 GST_LOG ("%*s data reference:%d", depth, "", GET_UINT16 (&sub));
286 GST_LOG ("%*s version/rev.: %08x", depth, "", GET_UINT32 (&sub));
287 fourcc = GET_FOURCC (&sub);
288 GST_LOG ("%*s vendor: %" GST_FOURCC_FORMAT, depth, "",
289 GST_FOURCC_ARGS (fourcc));
290 GST_LOG ("%*s temporal qual: %u", depth, "", GET_UINT32 (&sub));
291 GST_LOG ("%*s spatial qual: %u", depth, "", GET_UINT32 (&sub));
292 GST_LOG ("%*s width: %u", depth, "", GET_UINT16 (&sub));
293 GST_LOG ("%*s height: %u", depth, "", GET_UINT16 (&sub));
294 GST_LOG ("%*s horiz. resol: %g", depth, "", GET_FP32 (&sub));
295 GST_LOG ("%*s vert. resol.: %g", depth, "", GET_FP32 (&sub));
296 GST_LOG ("%*s data size: %u", depth, "", GET_UINT32 (&sub));
297 GST_LOG ("%*s frame count: %u", depth, "", GET_UINT16 (&sub));
298 /* something is not right with this, it's supposed to be a string but it's
299 * not apparently, so just skip this for now */
300 gst_byte_reader_skip_unchecked (&sub, 1 + 31);
301 GST_LOG ("%*s compressor: (skipped)", depth, "");
302 GST_LOG ("%*s depth: %u", depth, "", GET_UINT16 (&sub));
303 GST_LOG ("%*s color table ID:%u", depth, "", GET_UINT16 (&sub));
304 if (!gst_byte_reader_skip (data, size - (4 + 4)))
311 qtdemux_dump_stts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
313 guint32 ver_flags = 0, num_entries = 0, i;
315 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
316 !gst_byte_reader_get_uint32_be (data, &num_entries))
319 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
320 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
322 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
325 for (i = 0; i < num_entries; i++) {
326 GST_LOG ("%*s count: %u", depth, "", GET_UINT32 (data));
327 GST_LOG ("%*s duration: %u", depth, "", GET_UINT32 (data));
333 qtdemux_dump_stps (GstQTDemux * qtdemux, GstByteReader * data, int depth)
335 guint32 ver_flags = 0, num_entries = 0, i;
337 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
338 !gst_byte_reader_get_uint32_be (data, &num_entries))
341 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
342 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
344 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
347 for (i = 0; i < num_entries; i++) {
348 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
354 qtdemux_dump_stss (GstQTDemux * qtdemux, GstByteReader * data, int depth)
356 guint32 ver_flags = 0, num_entries = 0, i;
358 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
359 !gst_byte_reader_get_uint32_be (data, &num_entries))
362 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
363 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
365 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
368 for (i = 0; i < num_entries; i++) {
369 GST_LOG ("%*s sample: %u", depth, "", GET_UINT32 (data));
375 qtdemux_dump_stsc (GstQTDemux * qtdemux, GstByteReader * data, int depth)
377 guint32 ver_flags = 0, num_entries = 0, i;
379 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
380 !gst_byte_reader_get_uint32_be (data, &num_entries))
383 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
384 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
386 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4 + 4))
389 for (i = 0; i < num_entries; i++) {
390 GST_LOG ("%*s first chunk: %u", depth, "", GET_UINT32 (data));
391 GST_LOG ("%*s sample per ch: %u", depth, "", GET_UINT32 (data));
392 GST_LOG ("%*s sample desc id:%08x", depth, "", GET_UINT32 (data));
398 qtdemux_dump_stsz (GstQTDemux * qtdemux, GstByteReader * data, int depth)
400 guint32 ver_flags = 0, sample_size = 0, num_entries = 0;
402 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
403 !gst_byte_reader_get_uint32_be (data, &sample_size))
406 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
407 GST_LOG ("%*s sample size: %d", depth, "", sample_size);
409 if (sample_size == 0) {
410 if (!gst_byte_reader_get_uint32_be (data, &num_entries))
413 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
415 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
417 for (i = 0; i < num_entries; i++) {
418 GST_LOG ("%*s sample size: %u", depth, "", GET_UINT32 (data));
426 qtdemux_dump_stco (GstQTDemux * qtdemux, GstByteReader * data, int depth)
428 guint32 ver_flags = 0, num_entries = 0, i;
430 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
431 !gst_byte_reader_get_uint32_be (data, &num_entries))
434 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
435 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
437 if (!qt_atom_parser_has_chunks (data, num_entries, 4))
440 for (i = 0; i < num_entries; i++) {
441 GST_LOG ("%*s chunk offset: %u", depth, "", GET_UINT32 (data));
447 qtdemux_dump_ctts (GstQTDemux * qtdemux, GstByteReader * data, int depth)
449 guint32 ver_flags = 0, num_entries = 0, i, count, offset;
451 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
452 !gst_byte_reader_get_uint32_be (data, &num_entries))
455 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
456 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
458 if (!qt_atom_parser_has_chunks (data, num_entries, 4 + 4))
461 for (i = 0; i < num_entries; i++) {
462 count = GET_UINT32 (data);
463 offset = GET_UINT32 (data);
464 GST_LOG ("%*s sample count :%8d offset: %8d", depth, "", count, offset);
470 qtdemux_dump_co64 (GstQTDemux * qtdemux, GstByteReader * data, int depth)
472 guint32 ver_flags = 0, num_entries = 0, i;
474 if (!gst_byte_reader_get_uint32_be (data, &ver_flags) ||
475 !gst_byte_reader_get_uint32_be (data, &num_entries))
478 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
479 GST_LOG ("%*s n entries: %d", depth, "", num_entries);
481 if (!qt_atom_parser_has_chunks (data, num_entries, 8))
484 for (i = 0; i < num_entries; i++) {
485 GST_LOG ("%*s chunk offset: %" G_GUINT64_FORMAT, depth, "",
492 qtdemux_dump_dcom (GstQTDemux * qtdemux, GstByteReader * data, int depth)
494 if (!qt_atom_parser_has_remaining (data, 4))
497 GST_LOG ("%*s compression type: %" GST_FOURCC_FORMAT, depth, "",
498 GST_FOURCC_ARGS (GET_FOURCC (data)));
503 qtdemux_dump_cmvd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
505 if (!qt_atom_parser_has_remaining (data, 4))
508 GST_LOG ("%*s length: %d", depth, "", GET_UINT32 (data));
513 qtdemux_dump_mfro (GstQTDemux * qtdemux, GstByteReader * data, int depth)
515 if (!qt_atom_parser_has_remaining (data, 4))
518 GST_LOG ("%*s size: %d", depth, "", GET_UINT32 (data));
523 qtdemux_dump_tfra (GstQTDemux * qtdemux, GstByteReader * data, int depth)
525 guint64 time = 0, moof_offset = 0;
526 guint32 len = 0, num_entries = 0, ver_flags = 0, track_id = 0, i;
527 guint value_size, traf_size, trun_size, sample_size;
529 if (!gst_byte_reader_get_uint32_be (data, &ver_flags))
532 GST_LOG ("%*s version/flags: %08x", depth, "", ver_flags);
534 if (!gst_byte_reader_get_uint32_be (data, &track_id) ||
535 gst_byte_reader_get_uint32_be (data, &len) ||
536 gst_byte_reader_get_uint32_be (data, &num_entries))
539 GST_LOG ("%*s track ID: %u", depth, "", track_id);
540 GST_LOG ("%*s length: 0x%x", depth, "", len);
541 GST_LOG ("%*s n entries: %u", depth, "", num_entries);
543 value_size = ((ver_flags >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
544 sample_size = (len & 3) + 1;
545 trun_size = ((len & 12) >> 2) + 1;
546 traf_size = ((len & 48) >> 4) + 1;
548 if (!qt_atom_parser_has_chunks (data, num_entries,
549 value_size + value_size + traf_size + trun_size + sample_size))
552 for (i = 0; i < num_entries; i++) {
553 qt_atom_parser_get_offset (data, value_size, &time);
554 qt_atom_parser_get_offset (data, value_size, &moof_offset);
555 GST_LOG ("%*s time: %" G_GUINT64_FORMAT, depth, "", time);
556 GST_LOG ("%*s moof_offset: %" G_GUINT64_FORMAT,
557 depth, "", moof_offset);
558 GST_LOG ("%*s traf_number: %u", depth, "",
559 qt_atom_parser_get_uint_with_size_unchecked (data, traf_size));
560 GST_LOG ("%*s trun_number: %u", depth, "",
561 qt_atom_parser_get_uint_with_size_unchecked (data, trun_size));
562 GST_LOG ("%*s sample_number: %u", depth, "",
563 qt_atom_parser_get_uint_with_size_unchecked (data, sample_size));
570 qtdemux_dump_tfhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
572 guint32 flags = 0, n = 0, track_id = 0;
573 guint64 base_data_offset = 0;
575 if (!gst_byte_reader_skip (data, 1) ||
576 !gst_byte_reader_get_uint24_be (data, &flags))
578 GST_LOG ("%*s flags: %08x", depth, "", flags);
580 if (!gst_byte_reader_get_uint32_be (data, &track_id))
582 GST_LOG ("%*s track_id: %u", depth, "", track_id);
584 if (flags & TF_BASE_DATA_OFFSET) {
585 if (!gst_byte_reader_get_uint64_be (data, &base_data_offset))
587 GST_LOG ("%*s base-data-offset: %" G_GUINT64_FORMAT,
588 depth, "", base_data_offset);
591 if (flags & TF_SAMPLE_DESCRIPTION_INDEX) {
592 if (!gst_byte_reader_get_uint32_be (data, &n))
594 GST_LOG ("%*s sample-description-index: %u", depth, "", n);
597 if (flags & TF_DEFAULT_SAMPLE_DURATION) {
598 if (!gst_byte_reader_get_uint32_be (data, &n))
600 GST_LOG ("%*s default-sample-duration: %u", depth, "", n);
603 if (flags & TF_DEFAULT_SAMPLE_SIZE) {
604 if (!gst_byte_reader_get_uint32_be (data, &n))
606 GST_LOG ("%*s default-sample-size: %u", depth, "", n);
609 if (flags & TF_DEFAULT_SAMPLE_FLAGS) {
610 if (!gst_byte_reader_get_uint32_be (data, &n))
612 GST_LOG ("%*s default-sample-flags: %u", depth, "", n);
615 GST_LOG ("%*s duration-is-empty: %s", depth, "",
616 flags & TF_DURATION_IS_EMPTY ? "yes" : "no");
622 qtdemux_dump_trun (GstQTDemux * qtdemux, GstByteReader * data, int depth)
624 guint32 flags = 0, samples_count = 0, data_offset = 0, first_sample_flags = 0;
625 guint32 sample_duration = 0, sample_size = 0, sample_flags =
626 0, composition_time_offsets = 0;
629 if (!gst_byte_reader_skip (data, 1) ||
630 !gst_byte_reader_get_uint24_be (data, &flags))
633 GST_LOG ("%*s flags: %08x", depth, "", flags);
635 if (!gst_byte_reader_get_uint32_be (data, &samples_count))
637 GST_LOG ("%*s samples_count: %u", depth, "", samples_count);
639 if (flags & TR_DATA_OFFSET) {
640 if (!gst_byte_reader_get_uint32_be (data, &data_offset))
642 GST_LOG ("%*s data-offset: %u", depth, "", data_offset);
645 if (flags & TR_FIRST_SAMPLE_FLAGS) {
646 if (!gst_byte_reader_get_uint32_be (data, &first_sample_flags))
648 GST_LOG ("%*s first-sample-flags: %u", depth, "", first_sample_flags);
651 for (i = 0; i < samples_count; i++) {
652 if (flags & TR_SAMPLE_DURATION) {
653 if (!gst_byte_reader_get_uint32_be (data, &sample_duration))
655 GST_LOG ("%*s sample-duration: %u", depth, "", sample_duration);
658 if (flags & TR_SAMPLE_SIZE) {
659 if (!gst_byte_reader_get_uint32_be (data, &sample_size))
661 GST_LOG ("%*s sample-size: %u", depth, "", sample_size);
664 if (flags & TR_SAMPLE_FLAGS) {
665 if (!gst_byte_reader_get_uint32_be (data, &sample_flags))
667 GST_LOG ("%*s sample-flags: %u", depth, "", sample_flags);
670 if (flags & TR_COMPOSITION_TIME_OFFSETS) {
671 if (!gst_byte_reader_get_uint32_be (data, &composition_time_offsets))
673 GST_LOG ("%*s composition_time_offsets: %u", depth, "",
674 composition_time_offsets);
682 qtdemux_dump_trex (GstQTDemux * qtdemux, GstByteReader * data, int depth)
684 if (!qt_atom_parser_has_remaining (data, 4 + 4 + 4 + 4 + 4 + 4))
687 GST_LOG ("%*s version/flags: %08x", depth, "", GET_UINT32 (data));
688 GST_LOG ("%*s track ID: %08x", depth, "", GET_UINT32 (data));
689 GST_LOG ("%*s default sample desc. index: %08x", depth, "",
691 GST_LOG ("%*s default sample duration: %08x", depth, "",
693 GST_LOG ("%*s default sample size: %08x", depth, "",
695 GST_LOG ("%*s default sample flags: %08x", depth, "",
702 qtdemux_dump_mehd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
705 guint64 fragment_duration;
708 if (!gst_byte_reader_get_uint32_be (data, &version))
711 GST_LOG ("%*s version/flags: %08x", depth, "", version);
713 value_size = ((version >> 24) == 1) ? sizeof (guint64) : sizeof (guint32);
714 if (qt_atom_parser_get_offset (data, value_size, &fragment_duration)) {
715 GST_LOG ("%*s fragment duration: %" G_GUINT64_FORMAT,
716 depth, "", fragment_duration);
724 qtdemux_dump_sdtp (GstQTDemux * qtdemux, GstByteReader * data, int depth)
730 version = GET_UINT32 (data);
731 GST_LOG ("%*s version/flags: %08x", depth, "", version);
733 /* the sample_count is specified in the stsz or stz2 box.
734 * the information for a sample is stored in a single byte,
735 * so we read until there are no remaining bytes */
736 while (qt_atom_parser_has_remaining (data, 1)) {
737 val = GET_UINT8 (data);
738 GST_LOG ("%*s sample number: %d", depth, "", i);
739 GST_LOG ("%*s sample_depends_on: %d", depth, "",
740 ((guint16) (val)) & 0x3);
741 GST_LOG ("%*s sample_is_depended_on: %d", depth, "",
742 ((guint16) (val >> 2)) & 0x3);
743 GST_LOG ("%*s sample_has_redundancy: %d", depth, "",
744 ((guint16) (val >> 4)) & 0x3);
745 GST_LOG ("%*s early display: %d", depth, "",
746 ((guint16) (val >> 6)) & 0x1);
753 qtdemux_dump_unknown (GstQTDemux * qtdemux, GstByteReader * data, int depth)
757 len = gst_byte_reader_get_remaining (data);
758 GST_LOG ("%*s length: %d", depth, "", len);
760 GST_MEMDUMP_OBJECT (qtdemux, "unknown atom data",
761 gst_byte_reader_peek_data_unchecked (data), len);
766 qtdemux_node_dump_foreach (GNode * node, gpointer qtdemux)
768 GstByteReader parser;
769 guint8 *buffer = (guint8 *) node->data; /* FIXME: move to byte reader */
772 const QtNodeType *type;
775 node_length = GST_READ_UINT32_BE (buffer);
776 fourcc = GST_READ_UINT32_LE (buffer + 4);
778 g_warn_if_fail (node_length >= 8);
780 gst_byte_reader_init (&parser, buffer + 8, node_length - 8);
782 type = qtdemux_type_get (fourcc);
784 depth = (g_node_depth (node) - 1) * 2;
785 GST_LOG ("%*s'%" GST_FOURCC_FORMAT "', [%d], %s",
786 depth, "", GST_FOURCC_ARGS (fourcc), node_length, type->name);
791 ret = type->dump (GST_QTDEMUX_CAST (qtdemux), &parser, depth);
794 GST_WARNING ("%*s not enough data parsing atom %" GST_FOURCC_FORMAT,
795 depth, "", GST_FOURCC_ARGS (fourcc));
803 qtdemux_node_dump (GstQTDemux * qtdemux, GNode * node)
805 if (_gst_debug_min < GST_LEVEL_LOG)
808 g_node_traverse (node, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
809 qtdemux_node_dump_foreach, qtdemux);