[Scummvm-cvs-logs] SF.net SVN: scummvm: [24776] tools/trunk/compress_queen.c
cyx at users.sourceforge.net
cyx at users.sourceforge.net
Thu Nov 23 23:12:23 CET 2006
Revision: 24776
http://svn.sourceforge.net/scummvm/?rev=24776&view=rev
Author: cyx
Date: 2006-11-23 14:12:23 -0800 (Thu, 23 Nov 2006)
Log Message:
-----------
Fix for bug #1599393 - FOTAQ: clicks at the beginning of speech. Handle .SB file version properly, recompressing/rebuilding your FOTAQ version is recommended.
Modified Paths:
--------------
tools/trunk/compress_queen.c
Modified: tools/trunk/compress_queen.c
===================================================================
--- tools/trunk/compress_queen.c 2006-11-23 22:10:25 UTC (rev 24775)
+++ tools/trunk/compress_queen.c 2006-11-23 22:12:23 UTC (rev 24776)
@@ -39,7 +39,8 @@
#define CURRENT_TBL_VERSION 1
#define EXTRA_TBL_HEADER 8
-#define SB_HEADER_SIZE 110
+#define SB_HEADER_SIZE_V104 110
+#define SB_HEADER_SIZE_V110 122
enum {
@@ -121,7 +122,7 @@
{
printf("\nUsage: %s [--mp3/--vorbis/--flac <args>] queen.1\n", exename);
printf("\nParams:\n");
- printf(" --mp3 <args> encode to MP3 format\n");
+ printf(" --mp3 <args> encode to MP3 format\n");
printf(" --vorbis <args> encode to Ogg Vorbis Format\n");
printf(" --flac <args> encode to Flac Format\n");
printf(" (Optional: <args> are passed on to the encoder)\n");
@@ -173,7 +174,7 @@
checkOpen(inData, TEMP_DAT);
outFinal = fopen(FINAL_OUT, "wb");
checkOpen(outFinal, FINAL_OUT);
-
+
dataStartOffset = fileSize(inTbl) + EXTRA_TBL_HEADER;
dataSize = fileSize(inData);
@@ -183,7 +184,7 @@
writeUint32BE(outFinal, QTBL);
fwrite(version->versionString, 6, 1, outFinal);
writeByte(outFinal, version->isFloppy);
- writeByte(outFinal, version->isDemo);
+ writeByte(outFinal, version->isDemo);
writeByte(outFinal, versionExtra.compression);
writeUint16BE(outFinal, versionExtra.entries);
@@ -191,7 +192,7 @@
fromFileToFile(inTbl, outFinal, 12);
writeByte(outFinal, readByte(inTbl));
writeUint32BE(outFinal, dataStartOffset + readUint32BE(inTbl));
- writeUint32BE(outFinal, readUint32BE(inTbl));
+ writeUint32BE(outFinal, readUint32BE(inTbl));
}
/* Append contents of temporary datafile to final datafile */
@@ -216,7 +217,7 @@
int size, i = 1;
uint32 prevOffset;
-
+
if (argc < 2)
showhelp(argv[0]);
@@ -269,24 +270,24 @@
if (memcmp(tmp, "QTBL", 4)) {
printf("Invalid TBL file!\n");
exit(-1);
- }
+ }
if (readUint32BE(inputTbl) != CURRENT_TBL_VERSION) {
printf("Error: You are using an incorrect (outdated?) version of the queen.tbl file\n");
exit(1);
}
version = detectGameVersion(size);
- fseek(inputTbl, version->tableOffset, SEEK_SET);
+ fseek(inputTbl, version->tableOffset, SEEK_SET);
versionExtra.compression = compressionType;
versionExtra.entries = readUint16BE(inputTbl);
-
+
outputTbl = fopen(TEMP_TBL, "wb");
- checkOpen(outputTbl, TEMP_TBL);
+ checkOpen(outputTbl, TEMP_TBL);
outputData = fopen(TEMP_DAT, "wb");
checkOpen(outputData, TEMP_DAT);
-
+
/* Write tablefile header */
writeUint32BE(outputTbl, QTBL);
writeByte(outputTbl, versionExtra.compression);
@@ -294,7 +295,7 @@
for (i = 0; i < versionExtra.entries; i++) {
prevOffset = ftell(outputData);
-
+
/* Read entry */
fread(entry.filename, 1, 12, inputTbl);
entry.filename[12] = '\0';
@@ -306,10 +307,31 @@
fseek(inputData, entry.offset, SEEK_SET);
if (versionExtra.compression && strstr(entry.filename, ".SB")) { /* Do we want to compress? */
+ uint16 sbVersion;
+ int headerSize;
+
/* Read in .SB */
tmpFile = fopen(TEMP_SB, "wb");
- fseek(inputData, entry.offset + SB_HEADER_SIZE, SEEK_SET);
- fromFileToFile(inputData, tmpFile, entry.size - SB_HEADER_SIZE);
+ fseek(inputData, entry.offset, SEEK_SET);
+
+ fseek(inputData, 2, SEEK_CUR);
+ sbVersion = readUint16LE(inputData);
+ switch (sbVersion) {
+ case 104:
+ headerSize = SB_HEADER_SIZE_V104;
+ break;
+ case 110:
+ headerSize = SB_HEADER_SIZE_V110;
+ break;
+ default:
+ warning("Unhandled SB file version %d, defaulting to 104\n", sbVersion);
+ headerSize = SB_HEADER_SIZE_V104;
+ break;
+ }
+ fseek(inputData, headerSize - 4, SEEK_CUR);
+ entry.size -= headerSize;
+
+ fromFileToFile(inputData, tmpFile, entry.size);
fclose(tmpFile);
/* Invoke encoder */
@@ -329,7 +351,7 @@
unlink(TEMP_SB);
unlink(tempEncoded);
} else {
- /* Non .SB file */
+ /* Non .SB file */
bool patched = false;
/* Check for external files */
uint8 j;
@@ -357,8 +379,8 @@
fwrite(entry.filename, 12, 1, outputTbl);
writeByte(outputTbl, entry.bundle);
writeUint32BE(outputTbl, prevOffset);
- writeUint32BE(outputTbl, entry.size);
- }
+ writeUint32BE(outputTbl, entry.size);
+ }
/* Close files */
fclose(outputTbl);
@@ -368,6 +390,6 @@
/* Merge the temporary table and temporary datafile to create final file */
createFinalFile();
-
+
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list