summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-03 16:40:30 +0200
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-06-03 22:10:38 +0200
commitd83ef9935cc55fbf5508efa40c35e1dded621157 (patch)
treee474ecfc712c74c12ae47090a02546b835e934d4
parente9b7202b2fdc74b337d6194d18eb553e797e079e (diff)
downloadrockbox-d83ef9935cc55fbf5508efa40c35e1dded621157.tar.gz
rockbox-d83ef9935cc55fbf5508efa40c35e1dded621157.zip
voicefont: rename SWAP macros.
Those macros actually swap to big endian. Since the macro names didn't tell what way to swap (and on big endian they don't swap anything at all) they are somewhat confusing. Change names for clarity. Change-Id: Ie4b0026458a69d7533abb66109a6f83bc5ee2c0e
-rw-r--r--tools/voicefont.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/voicefont.c b/tools/voicefont.c
index df2577b455..546d0052f4 100644
--- a/tools/voicefont.c
+++ b/tools/voicefont.c
@@ -33,11 +33,9 @@
33 33
34/* endian conversion macros */ 34/* endian conversion macros */
35#if defined(__BIG_ENDIAN__) 35#if defined(__BIG_ENDIAN__)
36#define SWAP2(x) (x) 36#define UINT_TO_BE(x) (x)
37#define SWAP4(x) (x)
38#else 37#else
39#define SWAP2(x) ((((unsigned)(x)>>8) & 0x00ff) | (((unsigned)(x)<<8) & 0xff00)) 38#define UINT_TO_BE(x) ((((unsigned)(x)>>24) & 0x000000ff) |\
40#define SWAP4(x) ((((unsigned)(x)>>24) & 0x000000ff) |\
41 (((unsigned)(x)>>8) & 0x0000ff00) |\ 39 (((unsigned)(x)>>8) & 0x0000ff00) |\
42 (((unsigned)(x)<<8) & 0x00ff0000) |\ 40 (((unsigned)(x)<<8) & 0x00ff0000) |\
43 (((unsigned)(x)<<24) & 0xff000000)) 41 (((unsigned)(x)<<24) & 0xff000000))
@@ -163,24 +161,24 @@ int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output)
163 /* Create the file format: */ 161 /* Create the file format: */
164 162
165 /* 1st 32 bit value in the file is the version number */ 163 /* 1st 32 bit value in the file is the version number */
166 value = SWAP4(400); /* 4.00 */ 164 value = UINT_TO_BE(400); /* 4.00 */
167 fwrite(&value, sizeof(value), 1, output); 165 fwrite(&value, sizeof(value), 1, output);
168 166
169 /* 2nd 32 bit value in the file is the id number for the target 167 /* 2nd 32 bit value in the file is the id number for the target
170 we made the voce file for */ 168 we made the voce file for */
171 value = SWAP4(targetnum); 169 value = UINT_TO_BE(targetnum);
172 fwrite(&value, sizeof(value), 1, output); 170 fwrite(&value, sizeof(value), 1, output);
173 171
174 /* 3rd 32 bit value in the file is the header size (= 1st table position) */ 172 /* 3rd 32 bit value in the file is the header size (= 1st table position) */
175 value = SWAP4(HEADER_SIZE); /* version, target id, header size, number1, number2 */ 173 value = UINT_TO_BE(HEADER_SIZE); /* version, target id, header size, number1, number2 */
176 fwrite(&value, sizeof(value), 1, output); 174 fwrite(&value, sizeof(value), 1, output);
177 175
178 /* 4th 32 bit value in the file is the number of clips in 1st table */ 176 /* 4th 32 bit value in the file is the number of clips in 1st table */
179 value = SWAP4(count-count_voiceonly); 177 value = UINT_TO_BE(count-count_voiceonly);
180 fwrite(&value, sizeof(value), 1, output); 178 fwrite(&value, sizeof(value), 1, output);
181 179
182 /* 5th bit value in the file is the number of clips in 2nd table */ 180 /* 5th bit value in the file is the number of clips in 2nd table */
183 value = SWAP4(count_voiceonly); 181 value = UINT_TO_BE(count_voiceonly);
184 fwrite(&value, sizeof(value), 1, output); 182 fwrite(&value, sizeof(value), 1, output);
185 183
186 /* then followed by offset/size pairs for each clip */ 184 /* then followed by offset/size pairs for each clip */
@@ -199,9 +197,9 @@ int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output)
199 continue; 197 continue;
200 } 198 }
201 199
202 value = SWAP4(pos[i]); /* position */ 200 value = UINT_TO_BE(pos[i]); /* position */
203 fwrite(&value, sizeof(value), 1,output); 201 fwrite(&value, sizeof(value), 1,output);
204 value = SWAP4(size[i]); /* size */ 202 value = UINT_TO_BE(size[i]); /* size */
205 fwrite(&value, sizeof(value), 1, output); 203 fwrite(&value, sizeof(value), 1, output);
206 } /* for i */ 204 } /* for i */
207 } /* for j */ 205 } /* for j */