summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-06-24 20:36:42 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-06-24 20:36:42 +0200
commit7ac75999b8aa8055445bf21da7ae88a5c94b19e5 (patch)
treef88548d02ea284de49b93c4a233579214b8b5114 /plugins
parent4a3e6885409edf28b82aa572eff0c6599f67464a (diff)
added bigendian support to dts wav header reader
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dca/dcaplug.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/dca/dcaplug.c b/plugins/dca/dcaplug.c
index 11a1742d..3aea033c 100644
--- a/plugins/dca/dcaplug.c
+++ b/plugins/dca/dcaplug.c
@@ -33,11 +33,15 @@
#define s16_BE(s16,channels) do {} while (0)
#define s32_LE(s32,channels) s32_swap (s32, channels)
#define s32_BE(s32,channels) do {} while (0)
+#define u32_LE(u32) ((((u32)&0xff000000)>>24)|(((u32)&0x00ff0000)>>8)|(((u32)&0x0000ff00)<<8)|(((u32)&0x000000ff)<<24))
+#define u16_LE(u16) ((((u16)&0xff00)>>8)|(((u16)&0x00ff)<<8))
#else
#define s16_LE(s16,channels) do {} while (0)
#define s16_BE(s16,channels) s16_swap (s16, channels)
#define s32_LE(s32,channels) do {} while (0)
#define s32_BE(s32,channels) s32_swap (s32, channels)
+#define u32_LE(u32) (u32)
+#define u16_LE(u16) (u16)
#endif
#define min(x,y) ((x)<(y)?(x):(y))
@@ -267,6 +271,7 @@ dts_open_wav (DB_FILE *fp, wavfmt_t *fmt, int *totalsamples) {
if (deadbeef->fread (&size, 1, sizeof (size), fp) != sizeof (size)) {
return -1;
}
+ size = u32_LE(size);
char type[4];
if (deadbeef->fread (type, 1, sizeof (type), fp) != sizeof (type)) {
@@ -292,10 +297,18 @@ dts_open_wav (DB_FILE *fp, wavfmt_t *fmt, int *totalsamples) {
if (deadbeef->fread (&fmtsize, 1, sizeof (fmtsize), fp) != sizeof (fmtsize)) {
return -1;
}
+ fmtsize = u32_LE(fmtsize);
if (deadbeef->fread (fmt, 1, sizeof (wavfmt_t), fp) != sizeof (wavfmt_t)) {
return -1;
}
+ fmt->wFormatTag = u16_LE (fmt->wFormatTag);
+ fmt->nChannels = u16_LE (fmt->nChannels);
+ fmt->nSamplesPerSec = u32_LE (fmt->nSamplesPerSec);
+ fmt->nAvgBytesPerSec = u32_LE (fmt->nAvgBytesPerSec);
+ fmt->nBlockAlign = u16_LE (fmt->nBlockAlign);
+ fmt->wBitsPerSample = u16_LE (fmt->wBitsPerSample);
+ fmt->cbSize = u16_LE (fmt->cbSize);
if (fmt->wFormatTag != 0x0001 || fmt->wBitsPerSample != 16) {
return -1;
@@ -318,6 +331,7 @@ dts_open_wav (DB_FILE *fp, wavfmt_t *fmt, int *totalsamples) {
if (deadbeef->fread (&datasize, 1, sizeof (datasize), fp) != sizeof (datasize)) {
return -1;
}
+ datasize = u32_LE (datasize);
*totalsamples = datasize / ((fmt->wBitsPerSample >> 3) * fmt->nChannels);