diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/wavpack.c | 9 | ||||
-rw-r--r-- | apps/metadata.c | 13 |
2 files changed, 16 insertions, 6 deletions
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c index 275f5f11e4..0da8a89027 100644 --- a/apps/codecs/wavpack.c +++ b/apps/codecs/wavpack.c | |||
@@ -47,7 +47,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
47 | { | 47 | { |
48 | WavpackContext *wpc; | 48 | WavpackContext *wpc; |
49 | char error [80]; | 49 | char error [80]; |
50 | int bps, nchans; | 50 | int bps, nchans, sr_100; |
51 | 51 | ||
52 | /* Generic codec initialisation */ | 52 | /* Generic codec initialisation */ |
53 | TEST_CODEC_API(api); | 53 | TEST_CODEC_API(api); |
@@ -90,6 +90,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
90 | 90 | ||
91 | bps = WavpackGetBytesPerSample (wpc); | 91 | bps = WavpackGetBytesPerSample (wpc); |
92 | nchans = WavpackGetReducedChannels (wpc); | 92 | nchans = WavpackGetReducedChannels (wpc); |
93 | sr_100 = ci->id3->frequency / 100; | ||
93 | 94 | ||
94 | ci->set_elapsed (0); | 95 | ci->set_elapsed (0); |
95 | 96 | ||
@@ -99,7 +100,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
99 | long nsamples; | 100 | long nsamples; |
100 | 101 | ||
101 | if (ci->seek_time && ci->taginfo_ready && ci->id3->length) { | 102 | if (ci->seek_time && ci->taginfo_ready && ci->id3->length) { |
102 | int curpos_ms = (WavpackGetSampleIndex (wpc) + 220) / 441 * 10; | 103 | int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10; |
103 | int n, d, skip; | 104 | int n, d, skip; |
104 | 105 | ||
105 | if (ci->seek_time > curpos_ms) { | 106 | if (ci->seek_time > curpos_ms) { |
@@ -121,7 +122,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
121 | if (!wpc) | 122 | if (!wpc) |
122 | break; | 123 | break; |
123 | 124 | ||
124 | ci->set_elapsed ((int)((long long) WavpackGetSampleIndex (wpc) * 1000 / 44100)); | 125 | ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); |
125 | rb->yield (); | 126 | rb->yield (); |
126 | } | 127 | } |
127 | 128 | ||
@@ -189,7 +190,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
189 | while (!ci->audiobuffer_insert ((char *) temp_buffer, nsamples * 4)) | 190 | while (!ci->audiobuffer_insert ((char *) temp_buffer, nsamples * 4)) |
190 | rb->yield (); | 191 | rb->yield (); |
191 | 192 | ||
192 | ci->set_elapsed ((WavpackGetSampleIndex (wpc) + 220) / 441 * 10); | 193 | ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); |
193 | } | 194 | } |
194 | 195 | ||
195 | if (ci->request_next_track()) | 196 | if (ci->request_next_track()) |
diff --git a/apps/metadata.c b/apps/metadata.c index 540e62c4aa..f59917ceb8 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -83,6 +83,9 @@ unsigned short a52_441framesizes[]= | |||
83 | 557*2,558*2,696*2,697*2,835*2,836*2,975*2,976*2, | 83 | 557*2,558*2,696*2,697*2,835*2,836*2,975*2,976*2, |
84 | 1114*2,1115*2,1253*2,1254*2,1393*2,1394*2}; | 84 | 1114*2,1115*2,1253*2,1254*2,1393*2,1394*2}; |
85 | 85 | ||
86 | const long wavpack_sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000, | ||
87 | 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 }; | ||
88 | |||
86 | /* Get metadata for track - return false if parsing showed problems with the | 89 | /* Get metadata for track - return false if parsing showed problems with the |
87 | file that would prevent playback. */ | 90 | file that would prevent playback. */ |
88 | 91 | ||
@@ -334,12 +337,18 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname, | |||
334 | 337 | ||
335 | track->id3.vbr = true; /* All WavPack files are VBR */ | 338 | track->id3.vbr = true; /* All WavPack files are VBR */ |
336 | track->id3.filesize = filesize (fd); | 339 | track->id3.filesize = filesize (fd); |
337 | track->id3.frequency = 44100; | ||
338 | 340 | ||
339 | if ((buf [20] | buf [21] | buf [22] | buf [23]) && | 341 | if ((buf [20] | buf [21] | buf [22] | buf [23]) && |
340 | (buf [12] & buf [13] & buf [14] & buf [15]) != 0xff) { | 342 | (buf [12] & buf [13] & buf [14] & buf [15]) != 0xff) { |
343 | int srindx = ((buf [26] >> 7) & 1) + ((buf [27] << 1) & 14); | ||
344 | |||
345 | if (srindx == 15) | ||
346 | track->id3.frequency = 44100; | ||
347 | else | ||
348 | track->id3.frequency = wavpack_sample_rates [srindx]; | ||
349 | |||
341 | totalsamples = (buf[15] << 24) | (buf[14] << 16) | (buf[13] << 8) | buf[12]; | 350 | totalsamples = (buf[15] << 24) | (buf[14] << 16) | (buf[13] << 8) | buf[12]; |
342 | track->id3.length = (totalsamples + 220) / 441 * 10; | 351 | track->id3.length = totalsamples / (track->id3.frequency / 100) * 10; |
343 | track->id3.bitrate = filesize (fd) / | 352 | track->id3.bitrate = filesize (fd) / |
344 | (track->id3.length / 8); | 353 | (track->id3.length / 8); |
345 | } | 354 | } |