summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libwavpack/metadata.c3
-rw-r--r--apps/codecs/libwavpack/unpack.c16
-rw-r--r--apps/codecs/libwavpack/wavpack.h2
-rw-r--r--apps/codecs/wavpack.c5
4 files changed, 23 insertions, 3 deletions
diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c
index c7f2d61841..c944093b19 100644
--- a/apps/codecs/libwavpack/metadata.c
+++ b/apps/codecs/libwavpack/metadata.c
@@ -102,6 +102,9 @@ int process_metadata (WavpackContext *wpc, WavpackMetadata *wpmd)
case ID_CHANNEL_INFO:
return read_channel_info (wpc, wpmd);
+ case ID_SAMPLE_RATE:
+ return read_sample_rate (wpc, wpmd);
+
case ID_CONFIG_BLOCK:
return read_config_info (wpc, wpmd);
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c
index f2eca7619f..69252f24ad 100644
--- a/apps/codecs/libwavpack/unpack.c
+++ b/apps/codecs/libwavpack/unpack.c
@@ -270,6 +270,22 @@ int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd)
return TRUE;
}
+// Read non-standard sampling rate from metadata.
+
+int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd)
+{
+ int bytecnt = wpmd->byte_length;
+ uchar *byteptr = wpmd->data;
+
+ if (bytecnt == 3) {
+ wpc->config.sample_rate = (int32_t) *byteptr++;
+ wpc->config.sample_rate |= (int32_t) *byteptr++ << 8;
+ wpc->config.sample_rate |= (int32_t) *byteptr++ << 16;
+ }
+
+ return TRUE;
+}
+
// This monster actually unpacks the WavPack bitstream(s) into the specified
// buffer as 32-bit integers or floats (depending on orignal data). Lossy
// samples will be clipped to their original limits (i.e. 8-bit samples are
diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h
index a000438081..e2952115e1 100644
--- a/apps/codecs/libwavpack/wavpack.h
+++ b/apps/codecs/libwavpack/wavpack.h
@@ -114,6 +114,7 @@ typedef struct {
#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4)
#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5)
#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6)
+#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7)
///////////////////////// WavPack Configuration ///////////////////////////////
@@ -364,6 +365,7 @@ int read_float_info (WavpackStream *wps, WavpackMetadata *wpmd);
int read_int32_info (WavpackStream *wps, WavpackMetadata *wpmd);
int read_channel_info (WavpackContext *wpc, WavpackMetadata *wpmd);
int read_config_info (WavpackContext *wpc, WavpackMetadata *wpmd);
+int read_sample_rate (WavpackContext *wpc, WavpackMetadata *wpmd);
int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_count);
int check_crc_error (WavpackContext *wpc);
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index 680673fec7..1485eedf8b 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -57,9 +57,6 @@ enum codec_status codec_main(void)
while (!*ci->taginfo_ready && !ci->stop_codec)
ci->sleep(1);
- ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
- codec_set_replaygain(ci->id3);
-
/* Create a decoder instance */
wpc = WavpackOpenFileInput (read_callback, error);
@@ -68,6 +65,8 @@ enum codec_status codec_main(void)
goto done;
}
+ ci->configure(DSP_SWITCH_FREQUENCY, WavpackGetSampleRate (wpc));
+ codec_set_replaygain(ci->id3);
bps = WavpackGetBytesPerSample (wpc);
nchans = WavpackGetReducedChannels (wpc);
ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO);