forked from len0rd/rockbox
Allow WavPack to use new sampling rate converter
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6888 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1505b4ce44
commit
24d6535b7a
2 changed files with 16 additions and 6 deletions
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue