summaryrefslogtreecommitdiff
path: root/apps/codecs/libm4a/demux.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libm4a/demux.c')
-rw-r--r--apps/codecs/libm4a/demux.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/apps/codecs/libm4a/demux.c b/apps/codecs/libm4a/demux.c
index f2e5149ef7..d560256cd9 100644
--- a/apps/codecs/libm4a/demux.c
+++ b/apps/codecs/libm4a/demux.c
@@ -525,8 +525,8 @@ static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
525 } 525 }
526 break; 526 break;
527 default: 527 default:
528 DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n", 528 /*DEBUGF("(stbl) unknown chunk id: %c%c%c%c\n",
529 SPLITFOURCC(sub_chunk_id)); 529 SPLITFOURCC(sub_chunk_id));*/
530 stream_skip(qtmovie->stream, sub_chunk_len - 8); 530 stream_skip(qtmovie->stream, sub_chunk_len - 8);
531 } 531 }
532 532
@@ -537,57 +537,58 @@ static bool read_chunk_stbl(qtmovie_t *qtmovie, size_t chunk_len)
537 537
538static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len) 538static bool read_chunk_minf(qtmovie_t *qtmovie, size_t chunk_len)
539{ 539{
540 size_t dinf_size, stbl_size;
541 size_t size_remaining = chunk_len - 8; 540 size_t size_remaining = chunk_len - 8;
542 uint32_t i; 541 uint32_t i;
543 542
544 /**** SOUND HEADER CHUNK ****/ 543 /* Check for smhd, only kind of minf we care about */
545 if ((i=stream_read_uint32(qtmovie->stream)) != 16) 544
545 if ((i = stream_read_uint32(qtmovie->stream)) != 16)
546 { 546 {
547 DEBUGF("unexpected size in media info: %d\n",i); 547 DEBUGF("unexpected size in media info: %d\n",i);
548 stream_skip(qtmovie->stream, size_remaining-4); 548 stream_skip(qtmovie->stream, size_remaining-4);
549 return true; 549 return true;
550 } 550 }
551
551 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d')) 552 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','m','h','d'))
552 { 553 {
553 DEBUGF("not a sound header! can't handle this.\n"); 554 DEBUGF("not a sound header! can't handle this.\n");
554 return false; 555 return false;
555 } 556 }
556 /* now skip the rest */ 557
558 /* now skip the rest of the atom */
557 stream_skip(qtmovie->stream, 16 - 8); 559 stream_skip(qtmovie->stream, 16 - 8);
558 size_remaining -= 16; 560 size_remaining -= 16;
559 /****/
560 561
561 /**** DINF CHUNK ****/ 562 while (size_remaining)
562 dinf_size = stream_read_uint32(qtmovie->stream);
563 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('d','i','n','f'))
564 { 563 {
565 DEBUGF("expected dinf, didn't get it.\n"); 564 size_t sub_chunk_len;
566 return false; 565 fourcc_t sub_chunk_id;
567 }
568 /* skip it */
569 stream_skip(qtmovie->stream, dinf_size - 8);
570 size_remaining -= dinf_size;
571 /****/
572 566
567 sub_chunk_len = stream_read_uint32(qtmovie->stream);
573 568
574 /**** SAMPLE TABLE ****/ 569 if (sub_chunk_len <= 1 || sub_chunk_len > size_remaining)
575 stbl_size = stream_read_uint32(qtmovie->stream); 570 {
576 if (stream_read_uint32(qtmovie->stream) != MAKEFOURCC('s','t','b','l')) 571 DEBUGF("strange size (%u) for chunk inside minf\n", sub_chunk_len);
577 { 572 return false;
578 DEBUGF("expected stbl, didn't get it.\n"); 573 }
579 return false;
580 }
581 if (!read_chunk_stbl(qtmovie, stbl_size)) {
582 return false;
583 }
584 574
585 size_remaining -= stbl_size; 575 sub_chunk_id = stream_read_uint32(qtmovie->stream);
576
577 switch (sub_chunk_id)
578 {
579 case MAKEFOURCC('s','t','b','l'):
580 if (!read_chunk_stbl(qtmovie, sub_chunk_len)) {
581 return false;
582 }
583 break;
584 default:
585 /*DEBUGF("(minf) unknown chunk id: %c%c%c%c\n",
586 SPLITFOURCC(sub_chunk_id));*/
587 stream_skip(qtmovie->stream, sub_chunk_len - 8);
588 break;
589 }
586 590
587 if (size_remaining) 591 size_remaining -= sub_chunk_len;
588 {
589 DEBUGF("oops\n");
590 stream_skip(qtmovie->stream, size_remaining);
591 } 592 }
592 return true; 593 return true;
593} 594}