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
This commit is contained in:
Dominik Riebeling 2012-06-03 16:40:30 +02:00
parent e9b7202b2f
commit d83ef9935c

View file

@ -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 */