FS#8961 - Anti-Aliased Fonts.
[kugel-rb/myfork.git] / apps / codecs / libm4a / demux.c
blob2cb236ae23262058c4df11e30ab87b82ac1bf922
1 /*
2 * ALAC (Apple Lossless Audio Codec) decoder
3 * Copyright (c) 2005 David Hammerton
4 * All rights reserved.
6 * This is the quicktime container demuxer.
8 * http://crazney.net/programs/itunes/alac.html
9 *
10 * Permission is hereby granted, free of charge, to any person
11 * obtaining a copy of this software and associated documentation
12 * files (the "Software"), to deal in the Software without
13 * restriction, including without limitation the rights to use,
14 * copy, modify, merge, publish, distribute, sublicense, and/or
15 * sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
32 #include <string.h>
33 #include <inttypes.h>
34 #include <stdlib.h>
36 #include "codeclib.h"
38 #include "m4a.h"
40 #if defined(DEBUG) || defined(SIMULATOR)
41 #ifdef DEBUGF
42 #undef DEBUGF
43 #endif
44 #define DEBUGF qtmovie->stream->ci->debugf
45 #else
46 #define DEBUGF(...)
47 #endif
49 typedef struct
51 stream_t *stream;
52 demux_res_t *res;
53 } qtmovie_t;
56 /* chunk handlers */
57 static void read_chunk_ftyp(qtmovie_t *qtmovie, size_t chunk_len)
59 fourcc_t type;
60 uint32_t minor_ver;
61 size_t size_remaining = chunk_len - 8;
63 type = stream_read_uint32(qtmovie->stream);
64 size_remaining-=4;
65 if ((type != MAKEFOURCC('M','4','A',' ')) &&
66 (type != MAKEFOURCC('M','4','B',' ')) &&
67 (type != MAKEFOURCC('m','p','4','2')) &&
68 (type != MAKEFOURCC('3','g','p','6')) &&
69 (type != MAKEFOURCC('q','t',' ',' ')))
71 DEBUGF("not M4A file\n");
72 return;
74 minor_ver = stream_read_uint32(qtmovie->stream);
75 size_remaining-=4;
77 /* compatible brands */
78 while (size_remaining)
80 /* unused */
81 /*fourcc_t cbrand =*/ stream_read_uint32(qtmovie->stream);
82 size_remaining-=4;
86 static uint32_t mp4ff_read_mp4_descr_length(stream_t* stream)
88 uint8_t b;
89 uint8_t numBytes = 0;
90 uint32_t length = 0;
94 b = stream_read_uint8(stream);
95 numBytes++;
96 length = (length << 7) | (b & 0x7F);
97 } while ((b & 0x80) && numBytes < 4);
99 return length;
102 /* The following function is based on mp4ff */
103 static bool read_chunk_esds(qtmovie_t *qtmovie, size_t chunk_len)
105 uint8_t tag;
106 uint32_t temp;
107 int audioType;
108 int32_t maxBitrate;
109 int32_t avgBitrate;
111 (void)chunk_len;
112 /* version and flags */
113 temp=stream_read_uint32(qtmovie->stream);
115 /* get and verify ES_DescrTag */
116 tag = stream_read_uint8(qtmovie->stream);
117 if (tag == 0x03)
119 /* read length */
120 if (mp4ff_read_mp4_descr_length(qtmovie->stream) < 5 + 15)
122 return false;
124 /* skip 3 bytes */
125 stream_skip(qtmovie->stream,3);
126 } else {
127 /* skip 2 bytes */
128 stream_skip(qtmovie->stream,2);
131 /* get and verify DecoderConfigDescrTab */
132 if (stream_read_uint8(qtmovie->stream) != 0x04)
134 return false;
137 /* read length */
138 temp = mp4ff_read_mp4_descr_length(qtmovie->stream);
139 if (temp < 13) return false;
141 audioType = stream_read_uint8(qtmovie->stream);
142 temp=stream_read_int32(qtmovie->stream);//0x15000414 ????
143 maxBitrate = stream_read_int32(qtmovie->stream);
144 avgBitrate = stream_read_int32(qtmovie->stream);
145 DEBUGF("audioType=%d, maxBitrate=%ld, avgBitrate=%ld\n",audioType,
146 (long)maxBitrate,(long)avgBitrate);
148 /* get and verify DecSpecificInfoTag */
149 if (stream_read_uint8(qtmovie->stream) != 0x05)
151 return false;
154 /* read length */
155 qtmovie->res->codecdata_len = mp4ff_read_mp4_descr_length(qtmovie->stream);
156 if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE)
158 DEBUGF("codecdata too large (%d) in esds\n",
159 (int)qtmovie->res->codecdata_len);
160 return false;
163 stream_read(qtmovie->stream, qtmovie->res->codecdata_len, qtmovie->res->codecdata);
165 /* will skip the remainder of the atom */
166 return true;
169 static bool read_chunk_stsd(qtmovie_t *qtmovie, size_t chunk_len)
171 unsigned int i;
172 int j;
173 uint32_t numentries;
174 size_t size_remaining = chunk_len - 8;
176 /* version */
177 stream_read_uint8(qtmovie->stream);
178 size_remaining -= 1;
179 /* flags */
180 stream_read_uint8(qtmovie->stream);
181 stream_read_uint8(qtmovie->stream);
182 stream_read_uint8(qtmovie->stream);
183 size_remaining -= 3;
185 numentries = stream_read_uint32(qtmovie->stream);
186 size_remaining -= 4;
188 if (numentries != 1)
190 DEBUGF("only expecting one entry in sample description atom!\n");
191 return false;
194 for (i = 0; i < numentries; i++)
196 uint32_t entry_size;
198 uint32_t entry_remaining;
200 entry_size = stream_read_uint32(qtmovie->stream);
201 qtmovie->res->format = stream_read_uint32(qtmovie->stream);
202 DEBUGF("format: %c%c%c%c\n",SPLITFOURCC(qtmovie->res->format));
203 entry_remaining = entry_size;
204 entry_remaining -= 8;
206 /* sound info: */
208 /* reserved + data reference index + sound version + reserved */
209 stream_skip(qtmovie->stream, 6 + 2 + 2 + 6);
210 entry_remaining -= 6 + 2 + 2 + 6;
212 qtmovie->res->num_channels = stream_read_uint16(qtmovie->stream);
213 qtmovie->res->sound_sample_size = stream_read_uint16(qtmovie->stream);
214 entry_remaining -= 4;
216 /* packet size */
217 stream_skip(qtmovie->stream, 2);
218 qtmovie->res->sound_sample_rate = stream_read_uint32(qtmovie->stream);
219 /* reserved size */
220 stream_skip(qtmovie->stream, 2);
221 entry_remaining -= 8;
223 /* remaining is codec data */
225 if ((qtmovie->res->format==MAKEFOURCC('a','l','a','c'))) {
226 if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_ALAC) {
227 return false;
230 /* 12 = audio format atom, 8 = padding */
231 qtmovie->res->codecdata_len = entry_remaining + 12 + 8;
232 if (qtmovie->res->codecdata_len > MAX_CODECDATA_SIZE)
234 DEBUGF("codecdata too large (%d) in stsd\n",
235 (int)qtmovie->res->codecdata_len);
238 memset(qtmovie->res->codecdata, 0, qtmovie->res->codecdata_len);
239 /* audio format atom */
240 #if 0
241 /* The ALAC decoder skips these bytes, so there is no need to store them,
242 and this code isn't endian/alignment safe */
243 ((unsigned int*)qtmovie->res->codecdata)[0] = 0x0c000000;
244 ((unsigned int*)qtmovie->res->codecdata)[1] = MAKEFOURCC('a','m','r','f');
245 ((unsigned int*)qtmovie->res->codecdata)[2] = MAKEFOURCC('c','a','l','a');
246 #endif
248 stream_read(qtmovie->stream,
249 entry_remaining,
250 ((char*)qtmovie->res->codecdata) + 12);
251 entry_remaining -= entry_remaining;
253 if (entry_remaining)
254 stream_skip(qtmovie->stream, entry_remaining);
256 } else if (qtmovie->res->format==MAKEFOURCC('m','p','4','a')) {
257 if (qtmovie->stream->ci->id3->codectype!=AFMT_MP4_AAC) {
258 return false;
261 size_t sub_chunk_len;
262 fourcc_t sub_chunk_id;
264 sub_chunk_len = stream_read_uint32(qtmovie->stream);
265 if (sub_chunk_len <= 1 || sub_chunk_len > entry_remaining)
267 DEBUGF("strange size (%lu) for chunk inside mp4a\n",
268 (unsigned long)sub_chunk_len);
269 return false;
272 sub_chunk_id = stream_read_uint32(qtmovie->stream);
274 if (sub_chunk_id != MAKEFOURCC('e','s','d','s'))
276 DEBUGF("Expected esds chunk inside mp4a, found %c%c%c%c\n",SPLITFOURCC(sub_chunk_id));
277 return false;
280 j=qtmovie->stream->ci->curpos+sub_chunk_len-8;
281 if (read_chunk_esds(qtmovie,sub_chunk_len)) {
282 if (j!=qtmovie->stream->ci->curpos) {
283 DEBUGF("curpos=%ld, j=%d - Skipping %ld bytes\n",qtmovie->stream->ci->curpos,j,j-qtmovie->stream->ci->curpos);
284 stream_skip(qtmovie->stream,j-qtmovie->stream->ci->curpos);
286 entry_remaining-=sub_chunk_len;
287 } else {
288 DEBUGF("Error reading esds\n");
289 return false;
292 DEBUGF("entry_remaining=%ld\n",(long)entry_remaining);
293 stream_skip(qtmovie->stream,entry_remaining);
295 } else {
296 DEBUGF("expecting 'alac' or 'mp4a' data format, got %c%c%c%c\n",
297 SPLITFOURCC(qtmovie->res->format));
298 return false;
301 return true;
304 static bool read_chunk_stts(qtmovie_t *qtmovie, size_t chunk_len)
306 unsigned int i;
307 uint32_t numentries;
308 size_t size_remaining = chunk_len - 8;
310 /* version */
311 stream_read_uint8(qtmovie->stream);
312 size_remaining -= 1;
313 /* flags */
314 stream_read_uint8(qtmovie->stream);
315 stream_read_uint8(qtmovie->stream);
316 stream_read_uint8(qtmovie->stream);
317 size_remaining -= 3;
319 numentries = stream_read_uint32(qtmovie->stream);
320 size_remaining -= 4;
322 qtmovie->res->num_time_to_samples = numentries;
323 qtmovie->res->time_to_sample = malloc(numentries * sizeof(*qtmovie->res->time_to_sample));
325 if (!qtmovie->res->time_to_sample)
327 DEBUGF("stts too large\n");
328 return false;
331 for (i = 0; i < numentries; i++)
333 qtmovie->res->time_to_sample[i].sample_count = stream_read_uint32(qtmovie->stream);
334 qtmovie->res->time_to_sample[i].sample_duration = stream_read_uint32(qtmovie->stream);
335 size_remaining -= 8;
338 if (size_remaining)
340 DEBUGF("ehm, size remianing?\n");
341 stream_skip(qtmovie->stream, size_remaining);
344 return true;
347 static bool read_chunk_stsz(qtmovie_t *qtmovie, size_t chunk_len)
349 unsigned int i;
350 uint32_t numentries;
351 size_t size_remaining = chunk_len - 8;
353 /* version */
354 stream_read_uint8(qtmovie->stream);
355 size_remaining -= 1;
356 /* flags */
357 stream_read_uint8(qtmovie->stream);
358 stream_read_uint8(qtmovie->stream);
359 stream_read_uint8(qtmovie->stream);
360 size_remaining -= 3;
362 /* default sample size */
363 if (stream_read_uint32(qtmovie->stream) != 0)
365 DEBUGF("i was expecting variable samples sizes\n");
366 stream_read_uint32(qtmovie->stream);
367 size_remaining -= 4;
368 return true;
370 size_remaining -= 4;
372 numentries = stream_read_uint32(qtmovie->stream);
373 size_remaining -= 4;
375 qtmovie->res->num_sample_byte_sizes = numentries;
376 qtmovie->res->sample_byte_size = malloc(numentries * sizeof(*qtmovie->res->sample_byte_size));
378 if (!qtmovie->res->sample_byte_size)
380 DEBUGF("stsz too large\n");
381 return false;
384 for (i = 0; i < numentries; i++)
386 uint32_t v = stream_read_uint32(qtmovie->stream);
388 if (v > 0x0000ffff)
390 DEBUGF("stsz[%d] > 65 kB (%ld)\n", i, (long)v);
391 return false;
394 qtmovie->res->sample_byte_size[i] = v;
395 size_remaining -= 4;
398 if (size_remaining)
400 DEBUGF("ehm, size remianing?\n");
401 stream_skip(qtmovie->stream, size_remaining);
404 return true;
407 static bool read_chunk_stsc(qtmovie_t *qtmovie, size_t chunk_len)
409 unsigned int i;
410 uint32_t numentries;
411 size_t size_remaining = chunk_len - 8;
413 /* version + flags */
414 stream_read_uint32(qtmovie->stream);
415 size_remaining -= 4;
417 numentries = stream_read_uint32(qtmovie->stream);
418 size_remaining -= 4;
420 qtmovie->res->num_sample_to_chunks = numentries;
421 qtmovie->res->sample_to_chunk = malloc(numentries *
422 sizeof(*qtmovie->res->sample_to_chunk));
424 if (!qtmovie->res->sample_to_chunk)
426 DEBUGF("stsc too large\n");
427 return false;
430 for (i = 0; i < numentries; i++)
432 qtmovie->res->sample_to_chunk[i].first_chunk =
433 stream_read_uint32(qtmovie->stream);
434 qtmovie->res->sample_to_chunk[i].num_samples =
435 stream_read_uint32(qtmovie->stream);
436 stream_read_uint32(qtmovie->stream);
437 size_remaining -= 12;
440 if (size_remaining)
442 DEBUGF("ehm, size remianing?\n");
443 stream_skip(qtmovie->stream, size_remaining);
446 return true;
449 static bool read_chunk_stco(qtmovie_t *qtmovie, size_t chunk_len)
451 unsigned int i;
452 uint32_t numentries;
453 size_t size_remaining = chunk_len - 8;
455 /* version + flags */
456 stream_read_uint32(qtmovie->stream);
457 size_remaining -= 4;
459 numentries = stream_read_uint32(qtmovie->stream);
460 size_remaining -= 4;
462 qtmovie->res->num_chunk_offsets = numentries;
463 qtmovie->res->chunk_offset = malloc(numentries *
464 sizeof(*qtmovie->res->chunk_offset));
466 if (!qtmovie->res->chunk_offset)
468 DEBUGF("stco too large\n");
469 return false;
472 for (i = 0; i < numentries; i++)
474 qtmovie->res->chunk_offset[i] = stream_read_uint32(qtmovie->stream);
475 size_remaining -= 4;
478 if (size_remaining)
480 DEBUGF("ehm, size remianing?\n");
481 stream_skip(qtmovie->stream, size_remaining);
484 return true;
487 static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
489 size_t size_remaining = chunk_len - 8;
491 while (size_remaining)
493 size_t sub_chunk_len;
494 fourcc_t sub_chunk_id;
496 sub_chunk_len = stream_read_uint32(qtmovie->stream);
497 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
499 DEBUGF("strange size (%lu) for chunk inside stbl\n",
500 (unsigned long)sub_chunk_len);
501 return false;
504 sub_chunk_id = stream_read_uint32(qtmovie->stream);
506 switch (sub_chunk_id)
508 case MAKEFOURCC('s','t','s','d'):
509 if (!read_chunk_stsd(qtmovie, sub_chunk_len)) {
510 return false;
512 break;
513 case MAKEFOURCC('s','t','t','s'):
514 if (!read_chunk_stts(qtmovie, sub_chunk_len))
516 return false;
518 break;
519 case MAKEFOURCC('s','t','s','z'):
520 if (!read_chunk_stsz(qtmovie, sub_chunk_len))
522 return false;
524 break;
525 case MAKEFOURCC('s','t','s','c'):
526 if (!read_chunk_stsc(qtmovie, sub_chunk_len))
528 return false;
530 break;
531 case MAKEFOURCC('s','t','c','o'):
532 if (!read_chunk_stco(qtmovie, sub_chunk_len))
534 return false;
536 break;
537 default:
538 /*DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n",
539 SPLITFOURCC(sub_chunk_id));*/
540 stream_skip(qtmovie->stream, sub_chunk_len - 8);
543 size_remaining -= sub_chunk_len;
545 return true;
548 static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
550 size_t size_remaining = chunk_len - 8;
551 uint32_t i;
553 /* Check for smhd, only kind of minf we care about */
555 if ((i = stream_read_uint32(qtmovie->stream)) != 16)
557 DEBUGF("unexpected size in media info: %ld\n", (long)i);
558 stream_skip(qtmovie->stream, size_remaining-4);
559 return true;
562 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d'))
564 DEBUGF("not a sound header! can't handle this.\n");
565 return false;
568 /* now skip the rest of the atom */
569 stream_skip(qtmovie->stream, 16 - 8);
570 size_remaining -= 16;
572 while (size_remaining)
574 size_t sub_chunk_len;
575 fourcc_t sub_chunk_id;
577 sub_chunk_len = stream_read_uint32(qtmovie->stream);
579 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
581 DEBUGF("strange size (%lu) for chunk inside minf\n",
582 (unsigned long)sub_chunk_len);
583 return false;
586 sub_chunk_id = stream_read_uint32(qtmovie->stream);
588 switch (sub_chunk_id)
590 case MAKEFOURCC('s','t','b','l'):
591 if (!read_chunk_stbl(qtmovie, sub_chunk_len)) {
592 return false;
594 break;
595 default:
596 /*DEBUGF("(minf) unknown chunk id: %c%c%c%c\n",
597 SPLITFOURCC(sub_chunk_id));*/
598 stream_skip(qtmovie->stream, sub_chunk_len - 8);
599 break;
602 size_remaining -= sub_chunk_len;
604 return true;
607 static bool read_chunk_mdia(qtmovie_t *qtmovie, size_t chunk_len)
609 size_t size_remaining = chunk_len - 8;
611 while (size_remaining)
613 size_t sub_chunk_len;
614 fourcc_t sub_chunk_id;
616 sub_chunk_len = stream_read_uint32(qtmovie->stream);
617 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
619 DEBUGF("strange size (%lu) for chunk inside mdia\n",
620 (unsigned long)sub_chunk_len);
621 return false;
624 sub_chunk_id = stream_read_uint32(qtmovie->stream);
626 switch (sub_chunk_id)
628 case MAKEFOURCC('m','i','n','f'):
629 if (!read_chunk_minf(qtmovie, sub_chunk_len)) {
630 return false;
632 break;
633 default:
634 /*DEBUGF("(mdia) unknown chunk id: %c%c%c%c\n",
635 SPLITFOURCC(sub_chunk_id));*/
636 stream_skip(qtmovie->stream, sub_chunk_len - 8);
637 break;
640 size_remaining -= sub_chunk_len;
642 return true;
645 /* 'trak' - a movie track - contains other atoms */
646 static bool read_chunk_trak(qtmovie_t *qtmovie, size_t chunk_len)
648 size_t size_remaining = chunk_len - 8;
650 while (size_remaining)
652 size_t sub_chunk_len;
653 fourcc_t sub_chunk_id;
655 sub_chunk_len = stream_read_uint32(qtmovie->stream);
656 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
658 DEBUGF("strange size (%lu) for chunk inside trak\n",
659 (unsigned long)sub_chunk_len);
660 return false;
663 sub_chunk_id = stream_read_uint32(qtmovie->stream);
665 switch (sub_chunk_id)
667 case MAKEFOURCC('m','d','i','a'):
668 if (!read_chunk_mdia(qtmovie, sub_chunk_len)) {
669 return false;
671 break;
672 default:
673 /*DEBUGF("(trak) unknown chunk id: %c%c%c%c\n",
674 SPLITFOURCC(sub_chunk_id));*/
675 stream_skip(qtmovie->stream, sub_chunk_len - 8);
676 break;
679 size_remaining -= sub_chunk_len;
681 return true;
684 /* 'moov' movie atom - contains other atoms */
685 static bool read_chunk_moov(qtmovie_t *qtmovie, size_t chunk_len)
687 size_t size_remaining = chunk_len - 8;
689 while (size_remaining)
691 size_t sub_chunk_len;
692 fourcc_t sub_chunk_id;
694 sub_chunk_len = stream_read_uint32(qtmovie->stream);
695 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
697 DEBUGF("strange size (%lu) for chunk inside moov\n",
698 (unsigned long)sub_chunk_len);
699 return false;
702 sub_chunk_id = stream_read_uint32(qtmovie->stream);
704 switch (sub_chunk_id)
706 case MAKEFOURCC('t','r','a','k'):
707 if (!read_chunk_trak(qtmovie, sub_chunk_len)) {
708 return false;
710 break;
711 default:
712 /*DEBUGF("(moov) unknown chunk id: %c%c%c%c\n",
713 SPLITFOURCC(sub_chunk_id));*/
714 stream_skip(qtmovie->stream, sub_chunk_len - 8);
715 break;
718 size_remaining -= sub_chunk_len;
720 return true;
723 static void read_chunk_mdat(qtmovie_t *qtmovie, size_t chunk_len)
725 size_t size_remaining = chunk_len - 8;
727 qtmovie->res->mdat_len = size_remaining;
730 int qtmovie_read(stream_t *file, demux_res_t *demux_res)
732 qtmovie_t qtmovie;
734 /* construct the stream */
735 qtmovie.stream = file;
736 qtmovie.res = demux_res;
738 /* read the chunks */
739 while (1)
741 size_t chunk_len;
742 fourcc_t chunk_id;
744 chunk_len = stream_read_uint32(qtmovie.stream);
745 if (stream_eof(qtmovie.stream))
747 return 0;
750 if (chunk_len == 1)
752 //DEBUGF("need 64bit support\n");
753 return 0;
755 chunk_id = stream_read_uint32(qtmovie.stream);
757 //DEBUGF("Found a chunk %c%c%c%c, length=%d\n",SPLITFOURCC(chunk_id),chunk_len);
758 switch (chunk_id)
760 case MAKEFOURCC('f','t','y','p'):
761 read_chunk_ftyp(&qtmovie, chunk_len);
762 break;
763 case MAKEFOURCC('m','o','o','v'):
764 if (!read_chunk_moov(&qtmovie, chunk_len)) {
765 return 0;
767 break;
768 /* once we hit mdat we stop reading and return.
769 * this is on the assumption that there is no furhter interesting
770 * stuff in the stream. if there is stuff will fail (:()).
771 * But we need the read pointer to be at the mdat stuff
772 * for the decoder. And we don't want to rely on fseek/ftell,
773 * as they may not always be avilable */
774 case MAKEFOURCC('m','d','a','t'):
775 read_chunk_mdat(&qtmovie, chunk_len);
776 /* Keep track of start of stream in file - used for seeking */
777 qtmovie.res->mdat_offset=stream_tell(qtmovie.stream);
778 /* There can be empty mdats before the real one. If so, skip them */
779 if (qtmovie.res->mdat_len > 0) {
780 return 1;
782 break;
784 /* these following atoms can be skipped !!!! */
785 case MAKEFOURCC('f','r','e','e'):
786 stream_skip(qtmovie.stream, chunk_len - 8);
787 break;
788 default:
789 //DEBUGF("(top) unknown chunk id: %c%c%c%c\n",SPLITFOURCC(chunk_id));
790 return 0;
794 return 0;