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)
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 @@
/* endian conversion macros */
#if defined(__BIG_ENDIAN__)
-#define SWAP2(x) (x)
-#define SWAP4(x) (x)
+#define UINT_TO_BE(x) (x)
#else
-#define SWAP2(x) ((((unsigned)(x)>>8) & 0x00ff) | (((unsigned)(x)<<8) & 0xff00))
-#define SWAP4(x) ((((unsigned)(x)>>24) & 0x000000ff) |\
+#define UINT_TO_BE(x) ((((unsigned)(x)>>24) & 0x000000ff) |\
(((unsigned)(x)>>8) & 0x0000ff00) |\
(((unsigned)(x)<<8) & 0x00ff0000) |\
(((unsigned)(x)<<24) & 0xff000000))
@@ -163,24 +161,24 @@ int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output)
/* Create the file format: */
/* 1st 32 bit value in the file is the version number */
- value = SWAP4(400); /* 4.00 */
+ value = UINT_TO_BE(400); /* 4.00 */
fwrite(&value, sizeof(value), 1, output);
/* 2nd 32 bit value in the file is the id number for the target
we made the voce file for */
- value = SWAP4(targetnum);
+ value = UINT_TO_BE(targetnum);
fwrite(&value, sizeof(value), 1, output);
/* 3rd 32 bit value in the file is the header size (= 1st table position) */
- value = SWAP4(HEADER_SIZE); /* version, target id, header size, number1, number2 */
+ value = UINT_TO_BE(HEADER_SIZE); /* version, target id, header size, number1, number2 */
fwrite(&value, sizeof(value), 1, output);
/* 4th 32 bit value in the file is the number of clips in 1st table */
- value = SWAP4(count-count_voiceonly);
+ value = UINT_TO_BE(count-count_voiceonly);
fwrite(&value, sizeof(value), 1, output);
/* 5th bit value in the file is the number of clips in 2nd table */
- value = SWAP4(count_voiceonly);
+ value = UINT_TO_BE(count_voiceonly);
fwrite(&value, sizeof(value), 1, output);
/* then followed by offset/size pairs for each clip */
@@ -199,9 +197,9 @@ int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output)
continue;
}
- value = SWAP4(pos[i]); /* position */
+ value = UINT_TO_BE(pos[i]); /* position */
fwrite(&value, sizeof(value), 1,output);
- value = SWAP4(size[i]); /* size */
+ value = UINT_TO_BE(size[i]); /* size */
fwrite(&value, sizeof(value), 1, output);
} /* for i */
} /* for j */