diff options
author | Dave Chapman <dave@dchapman.com> | 2005-10-06 19:27:43 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2005-10-06 19:27:43 +0000 |
commit | 9e19c95d8efc78a22a32b4a77f9c4a0b4e64125c (patch) | |
tree | 1d0bc7970de2cd2f4fa365614f84f12517ad1b5f /apps | |
parent | 1c3a83c44e6dd18990d813c2f12e83bab67f313a (diff) | |
download | rockbox-9e19c95d8efc78a22a32b4a77f9c4a0b4e64125c.tar.gz rockbox-9e19c95d8efc78a22a32b4a77f9c4a0b4e64125c.zip |
Replace SWAB16 and SWAB32 with a comprehensive set of byte-swap macros - letoh16, letoh32, htole16, htole32, betoh16, betoh32, htobe16 and htobe32
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7584 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/libmusepack/internal.h | 9 | ||||
-rw-r--r-- | apps/codecs/wav.c | 2 | ||||
-rw-r--r-- | apps/metadata.c | 4 | ||||
-rw-r--r-- | apps/plugins/midi/guspat.c | 7 |
4 files changed, 6 insertions, 16 deletions
diff --git a/apps/codecs/libmusepack/internal.h b/apps/codecs/libmusepack/internal.h index a912bfc0ab..27656d5a54 100644 --- a/apps/codecs/libmusepack/internal.h +++ b/apps/codecs/libmusepack/internal.h | |||
@@ -42,15 +42,6 @@ enum { | |||
42 | MPC_DECODER_SYNTH_DELAY = 481 | 42 | MPC_DECODER_SYNTH_DELAY = 481 |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /// Big/little endian 32 bit byte swapping routine. | ||
46 | static inline | ||
47 | mpc_uint32_t swap32(mpc_uint32_t val) { | ||
48 | const unsigned char* src = (const unsigned char*)&val; | ||
49 | return | ||
50 | (mpc_uint32_t)src[0] | | ||
51 | ((mpc_uint32_t)src[1] << 8) | ((mpc_uint32_t)src[2] << 16) | ((mpc_uint32_t)src[3] << 24); | ||
52 | } | ||
53 | |||
54 | /// Searches for a ID3v2-tag and reads the length (in bytes) of it. | 45 | /// Searches for a ID3v2-tag and reads the length (in bytes) of it. |
55 | /// \param reader supplying raw stream data | 46 | /// \param reader supplying raw stream data |
56 | /// \return size of tag, in bytes | 47 | /// \return size of tag, in bytes |
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index 36076caf25..2806409dd5 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c | |||
@@ -482,7 +482,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
482 | else if (bitspersample > 8) { | 482 | else if (bitspersample > 8) { |
483 | /* Byte-swap data. */ | 483 | /* Byte-swap data. */ |
484 | for (i=0;i<n/2;i++) { | 484 | for (i=0;i<n/2;i++) { |
485 | int16_samples[i]=(int16_t)SWAB16(wavbuf[i]); | 485 | int16_samples[i]=(int16_t)letoh16(wavbuf[i]); |
486 | } | 486 | } |
487 | wavbufsize = n; | 487 | wavbufsize = n; |
488 | } | 488 | } |
diff --git a/apps/metadata.c b/apps/metadata.c index 0cf0890886..86e0887231 100644 --- a/apps/metadata.c +++ b/apps/metadata.c | |||
@@ -152,7 +152,7 @@ static void convert_endian(void *data, const char *format) | |||
152 | { | 152 | { |
153 | long* d = (long*) data; | 153 | long* d = (long*) data; |
154 | 154 | ||
155 | *d = SWAB32(*d); | 155 | *d = letoh32(*d); |
156 | data = d + 1; | 156 | data = d + 1; |
157 | } | 157 | } |
158 | 158 | ||
@@ -162,7 +162,7 @@ static void convert_endian(void *data, const char *format) | |||
162 | { | 162 | { |
163 | short* d = (short*) data; | 163 | short* d = (short*) data; |
164 | 164 | ||
165 | *d = SWAB16(*d); | 165 | *d = letoh16(*d); |
166 | data = d + 1; | 166 | data = d + 1; |
167 | } | 167 | } |
168 | 168 | ||
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index 23b6811542..6f1866cd58 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c | |||
@@ -97,12 +97,11 @@ struct GWaveform * loadWaveform(int file) | |||
97 | */ | 97 | */ |
98 | 98 | ||
99 | 99 | ||
100 | /* Iriver needs byteswapping.. big endian, go figure. Gus files are little endian */ | 100 | #ifdef ROCKBOX_BIG_ENDIAN |
101 | 101 | /* Byte-swap if necessary. Gus files are little endian */ | |
102 | #if !defined(SIMULATOR) | ||
103 | for(a=0; a<wav->numSamples; a++) | 102 | for(a=0; a<wav->numSamples; a++) |
104 | { | 103 | { |
105 | ((unsigned short *) wav->data)[a] = SWAB16(((unsigned short *) wav->data)[a]); | 104 | ((unsigned short *) wav->data)[a] = letoh16(((unsigned short *) wav->data)[a]); |
106 | } | 105 | } |
107 | #endif | 106 | #endif |
108 | 107 | ||