summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2010-07-02 18:39:11 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2010-07-02 18:39:11 +0000
commit33df565584d23f8f8d1d2f1e56ff855948440329 (patch)
tree9b5e0a77f8a0b8f42bf1e580f10d130027385c78
parent2cdf332f01bf3a9904f8322596bb81740ea3fe6b (diff)
downloadrockbox-33df565584d23f8f8d1d2f1e56ff855948440329.tar.gz
rockbox-33df565584d23f8f8d1d2f1e56ff855948440329.zip
Commit FS#7831. Corrects our flac decoder to not reject files that have samplecount set to 0.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27244 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata/flac.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/metadata/flac.c b/apps/metadata/flac.c
index b8f440c3ed..29937173fd 100644
--- a/apps/metadata/flac.c
+++ b/apps/metadata/flac.c
@@ -86,17 +86,24 @@ bool get_flac_metadata(int fd, struct mp3entry* id3)
86 86
87 /* totalsamples is a 36-bit field, but we assume <= 32 bits are used */ 87 /* totalsamples is a 36-bit field, but we assume <= 32 bits are used */
88 totalsamples = get_long_be(&buf[14]); 88 totalsamples = get_long_be(&buf[14]);
89 89
90 /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */ 90 if(totalsamples > 0)
91 id3->length = ((int64_t) totalsamples * 1000) / id3->frequency; 91 {
92 92 /* Calculate track length (in ms) and estimate the bitrate (in kbit/s) */
93 if (id3->length <= 0) 93 id3->length = ((int64_t) totalsamples * 1000) / id3->frequency;
94 id3->bitrate = (id3->filesize * 8) / id3->length;
95 }
96 else if (totalsamples == 0)
97 {
98 id3->length = 0;
99 id3->bitrate = 0;
100 }
101 else
94 { 102 {
95 logf("flac length invalid!"); 103 logf("flac length invalid!");
96 return false; 104 return false;
97 } 105 }
98 106
99 id3->bitrate = ((int64_t) id3->filesize * 8) / id3->length;
100 } 107 }
101 else if (type == 4) /* 4 is the VORBIS_COMMENT block */ 108 else if (type == 4) /* 4 is the VORBIS_COMMENT block */
102 { 109 {