summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Bryant <bryant@rockbox.org>2010-12-05 22:01:28 +0000
committerDave Bryant <bryant@rockbox.org>2010-12-05 22:01:28 +0000
commit809e61b373cdc69b61595a2a0bbd78bc414c9cd1 (patch)
tree8903aee6d8e5d47d01e99b7580568af70b2cbf3f
parent32a0ce375f018e0948d22d863199e85ece4bfff8 (diff)
downloadrockbox-809e61b373cdc69b61595a2a0bbd78bc414c9cd1.tar.gz
rockbox-809e61b373cdc69b61595a2a0bbd78bc414c9cd1.zip
remove a little redundant code from the WavPack metadata module to partially make up for the code just added
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28738 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/metadata/wavpack.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/apps/metadata/wavpack.c b/apps/metadata/wavpack.c
index 7d19435543..f2811df8f3 100644
--- a/apps/metadata/wavpack.c
+++ b/apps/metadata/wavpack.c
@@ -84,19 +84,19 @@ bool get_wavpack_metadata(int fd, struct mp3entry* id3)
84 /* check up to 16 headers before we give up finding one with audio */ 84 /* check up to 16 headers before we give up finding one with audio */
85 85
86 for (i = 0; i < 16; ++i) { 86 for (i = 0; i < 16; ++i) {
87 uint32_t meta_bytes = get_long_le(&buf [4]) - 24;
87 uint32_t trial_totalsamples = get_long_le(&buf[12]); 88 uint32_t trial_totalsamples = get_long_le(&buf[12]);
88 uint32_t blockindex = get_long_le(&buf[16]); 89 uint32_t blockindex = get_long_le(&buf[16]);
89 uint32_t blocksamples = get_long_le(&buf[20]); 90 uint32_t blocksamples = get_long_le(&buf[20]);
90 uint32_t flags = get_long_le(&buf[24]); 91 uint32_t flags = get_long_le(&buf[24]);
91 92
92 if (totalsamples == (uint32_t) -1 && trial_totalsamples != (uint32_t) -1 && blockindex == 0) 93 if (totalsamples == (uint32_t) -1 && blockindex == 0)
93 totalsamples = trial_totalsamples; 94 totalsamples = trial_totalsamples;
94 95
95 if (blocksamples) { 96 if (blocksamples) {
96 int srindx = ((buf [26] >> 7) & 1) + ((buf [27] << 1) & 14); 97 int srindx = ((buf [26] >> 7) & 1) + ((buf [27] << 1) & 14);
97 98
98 if (srindx == 15) { 99 if (srindx == 15) {
99 uint32_t meta_bytes = buf [4] + (buf [5] << 8) + (buf [6] << 16) - 24;
100 uint32_t meta_size; 100 uint32_t meta_size;
101 101
102 id3->frequency = 44100; 102 id3->frequency = 44100;
@@ -134,7 +134,7 @@ bool get_wavpack_metadata(int fd, struct mp3entry* id3)
134 /* if the total number of samples is still unknown, make a guess on the high side (for now) */ 134 /* if the total number of samples is still unknown, make a guess on the high side (for now) */
135 135
136 if (totalsamples == (uint32_t) -1) { 136 if (totalsamples == (uint32_t) -1) {
137 totalsamples = filesize (fd) * 3; 137 totalsamples = id3->filesize * 3;
138 138
139 if (!(flags & HYBRID_FLAG)) 139 if (!(flags & HYBRID_FLAG))
140 totalsamples /= 2; 140 totalsamples /= 2;
@@ -144,20 +144,14 @@ bool get_wavpack_metadata(int fd, struct mp3entry* id3)
144 } 144 }
145 145
146 id3->length = ((int64_t) totalsamples * 1000) / id3->frequency; 146 id3->length = ((int64_t) totalsamples * 1000) / id3->frequency;
147 id3->bitrate = filesize (fd) / (id3->length / 8); 147 id3->bitrate = id3->filesize / (id3->length / 8);
148 148
149 read_ape_tags(fd, id3); 149 read_ape_tags(fd, id3);
150 return true; 150 return true;
151 } 151 }
152 else { /* block did not contain audio, so seek to the end and see if there's another */ 152 else { /* block did not contain audio, so seek to the end and see if there's another */
153 uint32_t meta_bytes = buf [4] + (buf [5] << 8) + (buf [6] << 16) - 24;
154
155 if ((meta_bytes > 0 && lseek(fd, meta_bytes, SEEK_CUR) < 0) || 153 if ((meta_bytes > 0 && lseek(fd, meta_bytes, SEEK_CUR) < 0) ||
156 read(fd, buf, 32) < 32) 154 read(fd, buf, 32) < 32 || memcmp (buf, "wvpk", 4) != 0)
157 break;
158
159 if (memcmp (buf, "wvpk", 4) != 0 || buf [9] != 4 ||
160 buf [8] < 2 || buf [8] > 0x10)
161 break; 155 break;
162 } 156 }
163 } 157 }