diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-02-02 15:12:55 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-02-02 15:12:55 +0000 |
commit | 35bcdef1441519bb66a77b675013309ef39e9eec (patch) | |
tree | 62a3ebcfecb0a4a582d5bd1998e29be066e090e0 /apps/metadata | |
parent | 0f4dfc4e9d4c2cbae69442e415639476c73478b2 (diff) | |
download | rockbox-35bcdef1441519bb66a77b675013309ef39e9eec.tar.gz rockbox-35bcdef1441519bb66a77b675013309ef39e9eec.zip |
Find a more consistent and resilient way to handle SBR upsampled files. The detection is only done in one place (the metadata parser) and takes into account that the m4a header might already report corrected frame/sample sizes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29188 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/metadata')
-rw-r--r-- | apps/metadata/mp4.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index c9c691f0c4..a3721f0e9a 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c | |||
@@ -639,7 +639,10 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
639 | { | 639 | { |
640 | uint32_t entries; | 640 | uint32_t entries; |
641 | unsigned int i; | 641 | unsigned int i; |
642 | 642 | ||
643 | /* Reset to false. */ | ||
644 | id3->needs_upsampling_correction = true; | ||
645 | |||
643 | lseek(fd, 4, SEEK_CUR); | 646 | lseek(fd, 4, SEEK_CUR); |
644 | read_uint32be(fd, &entries); | 647 | read_uint32be(fd, &entries); |
645 | id3->samples = 0; | 648 | id3->samples = 0; |
@@ -651,7 +654,21 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, | |||
651 | 654 | ||
652 | read_uint32be(fd, &n); | 655 | read_uint32be(fd, &n); |
653 | read_uint32be(fd, &l); | 656 | read_uint32be(fd, &l); |
654 | id3->samples += n * l; | 657 | |
658 | /* Some SBR files use upsampling. In this case the number | ||
659 | * of output samples is doubled to a maximum of 2048 | ||
660 | * samples per frame. This means that files which already | ||
661 | * report a frame size of 2048 in their header will not | ||
662 | * need any further special handling. */ | ||
663 | if (SBR_upsampling_used && l<=1024) | ||
664 | { | ||
665 | id3->samples += n * l * 2; | ||
666 | id3->needs_upsampling_correction = true; | ||
667 | } | ||
668 | else | ||
669 | { | ||
670 | id3->samples += n * l; | ||
671 | } | ||
655 | } | 672 | } |
656 | 673 | ||
657 | size = 0; | 674 | size = 0; |
@@ -760,12 +777,6 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3) | |||
760 | logf("Not an ALAC or AAC file"); | 777 | logf("Not an ALAC or AAC file"); |
761 | return false; | 778 | return false; |
762 | } | 779 | } |
763 | |||
764 | /* SBR upsampling will output double amount of samples per frame. */ | ||
765 | if (SBR_upsampling_used) | ||
766 | { | ||
767 | id3->samples *= 2; | ||
768 | } | ||
769 | 780 | ||
770 | id3->length = ((int64_t) id3->samples * 1000) / id3->frequency; | 781 | id3->length = ((int64_t) id3->samples * 1000) / id3->frequency; |
771 | 782 | ||