From 5e182e08620fd5aa7743bf83d759f6847cd76b45 Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Fri, 1 Sep 2006 12:05:04 +0000 Subject: Support for Musepack SV4-6 stream files. Patch by Andrew Cupper. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10843 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libmusepack/streaminfo.c | 7 +++++++ apps/metadata.c | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/codecs/libmusepack/streaminfo.c b/apps/codecs/libmusepack/streaminfo.c index 5475c6f0f6..d9c925dbfb 100644 --- a/apps/codecs/libmusepack/streaminfo.c +++ b/apps/codecs/libmusepack/streaminfo.c @@ -234,8 +234,15 @@ mpc_streaminfo_read(mpc_streaminfo * si, mpc_reader * r) } } else { #ifdef MPC_SUPPORT_SV456 +#ifndef MPC_LITTLE_ENDIAN + mpc_uint32_t ptr; + for (ptr = 0; ptr < 8; ptr++) { + HeaderData[ptr] = mpc_swap32(HeaderData[ptr]); + } +#endif // stream version 4-6 Error = streaminfo_read_header_sv6(si, HeaderData); + if (Error != ERROR_CODE_OK) return Error; #else return ERROR_CODE_INVALIDSV; #endif diff --git a/apps/metadata.c b/apps/metadata.c index 1563466eda..8838a83aa4 100644 --- a/apps/metadata.c +++ b/apps/metadata.c @@ -1260,9 +1260,24 @@ static bool get_musepack_metadata(int fd, struct mp3entry *id3) "%d.%d dB", album_gain/100, abs(album_gain)%100); } } else { - /* There's no certain way to detect these pre-sv7 streams, apparently */ - /* TODO: add sv6 parsing here */ - return false; + header[0] = letoh32(header[0]); + unsigned int streamversion = (header[0] >> 11) & 0x03FF; + if (streamversion != 4 && streamversion != 5 && streamversion != 6) + return false; + id3->frequency = 44100; + id3->track_gain = 0; + id3->track_peak = 0; + id3->album_gain = 0; + id3->album_peak = 0; + + if (streamversion >= 5) + samples = (uint64_t)header[1]*1152; // 32 bit + else + samples = (uint64_t)(header[1] >> 16)*1152; // 16 bit + + samples -= 576; + if (streamversion < 6) + samples -= 1152; } id3->vbr = true; -- cgit v1.2.3