summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Bryant <bryant@rockbox.org>2005-06-27 00:12:40 +0000
committerDave Bryant <bryant@rockbox.org>2005-06-27 00:12:40 +0000
commit24d6535b7ae5cad7b5b460a5fe3ee9da70ad54dc (patch)
tree9dd4469d5ece097161c60ab8a6a3383255ee099c
parent1505b4ce44f3ea066a2bcd191305fb4858b2bec6 (diff)
downloadrockbox-24d6535b7ae5cad7b5b460a5fe3ee9da70ad54dc.zip
rockbox-24d6535b7ae5cad7b5b460a5fe3ee9da70ad54dc.tar.gz
rockbox-24d6535b7ae5cad7b5b460a5fe3ee9da70ad54dc.tar.bz2
rockbox-24d6535b7ae5cad7b5b460a5fe3ee9da70ad54dc.tar.xz
Allow WavPack to use new sampling rate converter
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6888 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/wavpack.c9
-rw-r--r--apps/metadata.c13
2 files changed, 16 insertions, 6 deletions
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index 275f5f1..0da8a89 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -47,7 +47,7 @@ enum codec_status codec_start(struct codec_api* api)
{
WavpackContext *wpc;
char error [80];
- int bps, nchans;
+ int bps, nchans, sr_100;
/* Generic codec initialisation */
TEST_CODEC_API(api);
@@ -90,6 +90,7 @@ enum codec_status codec_start(struct codec_api* api)
bps = WavpackGetBytesPerSample (wpc);
nchans = WavpackGetReducedChannels (wpc);
+ sr_100 = ci->id3->frequency / 100;
ci->set_elapsed (0);
@@ -99,7 +100,7 @@ enum codec_status codec_start(struct codec_api* api)
long nsamples;
if (ci->seek_time && ci->taginfo_ready && ci->id3->length) {
- int curpos_ms = (WavpackGetSampleIndex (wpc) + 220) / 441 * 10;
+ int curpos_ms = WavpackGetSampleIndex (wpc) / sr_100 * 10;
int n, d, skip;
if (ci->seek_time > curpos_ms) {
@@ -121,7 +122,7 @@ enum codec_status codec_start(struct codec_api* api)
if (!wpc)
break;
- ci->set_elapsed ((int)((long long) WavpackGetSampleIndex (wpc) * 1000 / 44100));
+ ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10);
rb->yield ();
}
@@ -189,7 +190,7 @@ enum codec_status codec_start(struct codec_api* api)
while (!ci->audiobuffer_insert ((char *) temp_buffer, nsamples * 4))
rb->yield ();
- ci->set_elapsed ((WavpackGetSampleIndex (wpc) + 220) / 441 * 10);
+ ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10);
}
if (ci->request_next_track())
diff --git a/apps/metadata.c b/apps/metadata.c
index 540e62c..f59917c 100644
--- a/apps/metadata.c
+++ b/apps/metadata.c
@@ -83,6 +83,9 @@ unsigned short a52_441framesizes[]=
557*2,558*2,696*2,697*2,835*2,836*2,975*2,976*2,
1114*2,1115*2,1253*2,1254*2,1393*2,1394*2};
+const long wavpack_sample_rates [] = { 6000, 8000, 9600, 11025, 12000, 16000,
+ 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 };
+
/* Get metadata for track - return false if parsing showed problems with the
file that would prevent playback. */
@@ -334,12 +337,18 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
track->id3.vbr = true; /* All WavPack files are VBR */
track->id3.filesize = filesize (fd);
- track->id3.frequency = 44100;
if ((buf [20] | buf [21] | buf [22] | buf [23]) &&
(buf [12] & buf [13] & buf [14] & buf [15]) != 0xff) {
+ int srindx = ((buf [26] >> 7) & 1) + ((buf [27] << 1) & 14);
+
+ if (srindx == 15)
+ track->id3.frequency = 44100;
+ else
+ track->id3.frequency = wavpack_sample_rates [srindx];
+
totalsamples = (buf[15] << 24) | (buf[14] << 16) | (buf[13] << 8) | buf[12];
- track->id3.length = (totalsamples + 220) / 441 * 10;
+ track->id3.length = totalsamples / (track->id3.frequency / 100) * 10;
track->id3.bitrate = filesize (fd) /
(track->id3.length / 8);
}