diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2006-01-08 08:58:58 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2006-01-08 08:58:58 +0000 |
commit | e8b1787296dae2a69893bd0fe97b2361fb6180ba (patch) | |
tree | 5fb1ab112c52a240c577c9d0570c88efbc36e6fb | |
parent | c78b019944a1e79116855355a10f120be52668ff (diff) | |
download | rockbox-e8b1787296dae2a69893bd0fe97b2361fb6180ba.tar.gz rockbox-e8b1787296dae2a69893bd0fe97b2361fb6180ba.zip |
Discard some LAME header fields if the file length has changed since the header was written. Fixes some NPR podcasts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8307 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/id3.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/firmware/id3.c b/firmware/id3.c index 89864a659b..a2b6521b67 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -882,6 +882,32 @@ static int getsonglength(int fd, struct mp3entry *entry) | |||
882 | 882 | ||
883 | bytecount += entry->id3v2len; | 883 | bytecount += entry->id3v2len; |
884 | 884 | ||
885 | /* Validate byte count, in case the file has been edited without | ||
886 | * updating the header. | ||
887 | */ | ||
888 | if (info.byte_count) | ||
889 | { | ||
890 | const unsigned long expected = entry->filesize - entry->id3v1len | ||
891 | - entry->id3v2len; | ||
892 | const unsigned long diff = MAX(10240, info.byte_count / 20); | ||
893 | |||
894 | if ((info.byte_count > expected + diff) | ||
895 | || (info.byte_count < expected - diff)) | ||
896 | { | ||
897 | DEBUGF("Note: info.byte_count differs from expected value by " | ||
898 | "%d bytes\n", labs((long) (expected - info.byte_count))); | ||
899 | info.byte_count = 0; | ||
900 | info.frame_count = 0; | ||
901 | info.file_time = 0; | ||
902 | info.enc_padding = 0; | ||
903 | |||
904 | /* Even if the bitrate was based on "known bad" values, it | ||
905 | * should still be better for VBR files than using the bitrate | ||
906 | * of the first audio frame. | ||
907 | */ | ||
908 | } | ||
909 | } | ||
910 | |||
885 | entry->bitrate = info.bitrate; | 911 | entry->bitrate = info.bitrate; |
886 | entry->frequency = info.frequency; | 912 | entry->frequency = info.frequency; |
887 | entry->version = info.version; | 913 | entry->version = info.version; |