[Scummvm-cvs-logs] SF.net SVN: scummvm: [28749] tools

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Aug 26 19:02:50 CEST 2007


Revision: 28749
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28749&view=rev
Author:   thebluegr
Date:     2007-08-26 10:02:49 -0700 (Sun, 26 Aug 2007)

Log Message:
-----------
Some updates to compress_saga. Also, synced the code in the trunk with the gsoc2007-toolsgui branch

Modified Paths:
--------------
    tools/branches/gsoc2007-toolsgui/compress_saga.cpp
    tools/trunk/compress_saga.cpp

Modified: tools/branches/gsoc2007-toolsgui/compress_saga.cpp
===================================================================
--- tools/branches/gsoc2007-toolsgui/compress_saga.cpp	2007-08-26 15:57:30 UTC (rev 28748)
+++ tools/branches/gsoc2007-toolsgui/compress_saga.cpp	2007-08-26 17:02:49 UTC (rev 28749)
@@ -177,7 +177,6 @@
 
 GameDescription *currentGameDescription = NULL;
 GameFileDescription *currentFileDescription = NULL;
-bool isSigned = true;
 
 uint16 sampleRate;
 uint32 sampleSize;
@@ -279,28 +278,31 @@
 
 	if (currentFileDescription->resourceType == kSoundVOC) {
 		inputData = Audio::loadVOCFromStream(inputFileStream, size, rate);
+
 		sampleSize = size;
 		sampleRate = rate;
 		sampleBits = 8;
 		sampleStereo = 0;
+		writeHeader(outputFile);
+
 		writeBufferToFile(inputData, sampleSize, TEMP_RAW);
 		free(inputData);
-		writeHeader(outputFile);
 
 		setRawAudioType( true, false, 8);
 		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 	}
 	if (currentFileDescription->resourceType == kSoundPCM) {
-		copyFile(inputFile, inputSize, TEMP_RAW);
 		sampleSize = inputSize;
 		sampleRate = (uint16)currentFileDescription->frequency;
 		sampleBits = 16;
 		sampleStereo = currentFileDescription->stereo;
 		writeHeader(outputFile);
 
-		setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, sampleBits);
-		encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode);
+		copyFile(inputFile, inputSize, TEMP_RAW);
+
+		setRawAudioType( !currentFileDescription->swapEndian, sampleStereo, sampleBits);
+		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 	}
 	if (currentFileDescription->resourceType == kSoundWAV) {
@@ -323,23 +325,29 @@
 		error("VOX encoded files are not supported yet");
 		// TODO
 		/*
-		  buffer.frequency = soundInfo->frequency;
-		  buffer.isSigned = soundInfo->isSigned;
-		  buffer.sampleBits = soundInfo->sampleBits;
-		  buffer.stereo = soundInfo->stereo;
-		  buffer.size = soundResourceLength * 4;
+		sampleSize = inputSize * 4;
+		sampleRate = (uint16)currentFileDescription->frequency;
+		sampleBits = 16;
+		sampleStereo = currentFileDescription->stereo;
+		writeHeader(outputFile);
 
-		  voxStream = Audio::makeADPCMStream(&readS, soundResourceLength, Audio::kADPCMOki);
-		  buffer.buffer = (byte *)malloc(buffer.size);
-		  voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
-		  if (voxSize != soundResourceLength * 2) {
-			error("SndRes::load() wrong VOX output size");
-		  }
+		Audio::AudioStream *voxStream = Audio::makeADPCMStream(&inputFileStream, inputSize, Audio::kADPCMOki);
+        //int voxSize = voxStream->readBuffer((int16*)inputData, soundResourceLength * 2);
+        //if (voxSize != soundResourceLength * 2)
+		//	error("Wrong VOX output size");
+		//writeBufferToFile(inputData, sampleSize, TEMP_RAW);
+		free(inputData);
+
+		setRawAudioType( !currentFileDescription->swapEndian, sampleStereo, false, sampleBits);
+		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
+		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 		*/
 	}
   if (currentFileDescription->resourceType == kSoundMacPCM) {
 		error("MacBinary files are not supported yet");
 		// TODO
+		// Note: MacBinary files are unsigned. With the pending changes to setRawAudioType, there will need
+		// to be some changes here
 		/*
 		copyFile(inputFile, inputSize, TEMP_RAW);
 		sampleSize = inputSize - 36;
@@ -524,21 +532,18 @@
 		if (!process_mp3_parms(argc, argv, i)) {
 			showhelp(argv[0]);
 		}
-
 		break;
 	case kVorbisMode:
 		tempEncoded = TEMP_OGG;
 		if (!process_ogg_parms(argc, argv, i)) {
 			showhelp(argv[0]);
 		}
-
 		break;
 	case kFlacMode:
 		tempEncoded = TEMP_FLAC;
 		if (!process_flac_parms(argc, argv, i)) {
 			showhelp(argv[0]);
 		}
-
 		break;
 	}
 
@@ -551,7 +556,6 @@
 
 	// ITE
 	sprintf(inputFileNameWithExt, "%s/%s.rsc", inputPath, inputFileName);
-
 	if (detectFile(inputFileNameWithExt)) {
 		sagaEncode(inputPath, inputFileName, ".rsc");
 	} else {
@@ -567,7 +571,6 @@
 				// Check for MacBinary
 				sprintf(inputFileNameWithExt, "%s/%s.bin", inputPath, inputFileName);
 				if (detectFile(inputFileNameWithExt)) {
-					isSigned = false;
 					sagaEncode(inputPath, inputFileName, ".bin");
 				}
 			}

Modified: tools/trunk/compress_saga.cpp
===================================================================
--- tools/trunk/compress_saga.cpp	2007-08-26 15:57:30 UTC (rev 28748)
+++ tools/trunk/compress_saga.cpp	2007-08-26 17:02:49 UTC (rev 28749)
@@ -177,7 +177,6 @@
 
 GameDescription *currentGameDescription = NULL;
 GameFileDescription *currentFileDescription = NULL;
-bool isSigned = true;
 
 uint16 sampleRate;
 uint32 sampleSize;
@@ -270,6 +269,7 @@
 	writeByte(outputFile, sampleBits);
 	writeByte(outputFile, sampleStereo);
 }
+
 uint32 encodeEntry(FILE* inputFile, uint32 inputSize, FILE* outputFile) {
 	uint8 *inputData;
 	Common::File inputFileStream(inputFile);
@@ -278,28 +278,31 @@
 
 	if (currentFileDescription->resourceType == kSoundVOC) {
 		inputData = Audio::loadVOCFromStream(inputFileStream, size, rate);
+
 		sampleSize = size;
 		sampleRate = rate;
 		sampleBits = 8;
 		sampleStereo = 0;
+		writeHeader(outputFile);
+
 		writeBufferToFile(inputData, sampleSize, TEMP_RAW);
 		free(inputData);
-		writeHeader(outputFile);
 
-		setRawAudioType( true, false, !isSigned, 8);
+		setRawAudioType( true, false, false, 8);
 		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 	}
 	if (currentFileDescription->resourceType == kSoundPCM) {
-		copyFile(inputFile, inputSize, TEMP_RAW);
 		sampleSize = inputSize;
 		sampleRate = (uint16)currentFileDescription->frequency;
 		sampleBits = 16;
 		sampleStereo = currentFileDescription->stereo;
 		writeHeader(outputFile);
 
-		setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned, sampleBits);
-		encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode);
+		copyFile(inputFile, inputSize, TEMP_RAW);
+
+		setRawAudioType( !currentFileDescription->swapEndian, sampleStereo, false, sampleBits);
+		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 	}
 	if (currentFileDescription->resourceType == kSoundWAV) {
@@ -314,7 +317,7 @@
 
 		copyFile(inputFile, size, TEMP_RAW);
 
-		setRawAudioType( true, sampleStereo != 0, !isSigned, sampleBits);
+		setRawAudioType( true, sampleStereo != 0, false, sampleBits);
 		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 	}
@@ -322,23 +325,29 @@
 		error("VOX encoded files are not supported yet");
 		// TODO
 		/*
-        buffer.frequency = soundInfo->frequency;
-        buffer.isSigned = soundInfo->isSigned;
-        buffer.sampleBits = soundInfo->sampleBits;
-        buffer.stereo = soundInfo->stereo;
-        buffer.size = soundResourceLength * 4;
+		sampleSize = inputSize * 4;
+		sampleRate = (uint16)currentFileDescription->frequency;
+		sampleBits = 16;
+		sampleStereo = currentFileDescription->stereo;
+		writeHeader(outputFile);
 
-        voxStream = Audio::makeADPCMStream(&readS, soundResourceLength, Audio::kADPCMOki);
-        buffer.buffer = (byte *)malloc(buffer.size);
-        voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
-        if (voxSize != soundResourceLength * 2) {
-			error("SndRes::load() wrong VOX output size");
-        }
+		Audio::AudioStream *voxStream = Audio::makeADPCMStream(&inputFileStream, inputSize, Audio::kADPCMOki);
+        //int voxSize = voxStream->readBuffer((int16*)inputData, soundResourceLength * 2);
+        //if (voxSize != soundResourceLength * 2)
+		//	error("Wrong VOX output size");
+		//writeBufferToFile(inputData, sampleSize, TEMP_RAW);
+		free(inputData);
+
+		setRawAudioType( !currentFileDescription->swapEndian, sampleStereo, false, sampleBits);
+		encodeAudio(TEMP_RAW, true, sampleRate, tempEncoded, gCompMode);
+		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 		*/
 	}
 	if (currentFileDescription->resourceType == kSoundMacPCM) {
 		error("MacBinary files are not supported yet");
 		// TODO
+		// Note: MacBinary files are unsigned. With the pending changes to setRawAudioType, there will need
+		// to be some changes here
 		/*
 		copyFile(inputFile, inputSize, TEMP_RAW);
 		sampleSize = inputSize - 36;
@@ -348,7 +357,7 @@
 		sampleStereo = currentFileDescription->stereo;
 		writeHeader(outputFile);
 
-		setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, !isSigned, sampleBits);
+		setRawAudioType( !currentFileDescription->swapEndian, currentFileDescription->stereo, false, sampleBits);
 		encodeAudio(TEMP_RAW, true, currentFileDescription->frequency, tempEncoded, gCompMode);
 		return copyFile(tempEncoded, outputFile) + HEADER_SIZE;
 		*/
@@ -452,7 +461,7 @@
 }
 
 void showhelp(char *exename) {
-	printf("\nUsage: %s <params> [<file> | mac]\n", exename);
+	printf("\nUsage: %s [params] <file>\n", exename);
 
 	printf("\nParams:\n");
 
@@ -492,12 +501,14 @@
 	char *inputFileName;
 	char inputFileNameWithExt[256];
 
-	if (argc < 2)
+	if (argc < 2) {
 		showhelp(argv[0]);
+	}
 
 	/* compression mode */
 	gCompMode = kMP3Mode;
 	i = 1;
+
 	if (strcmp(argv[1], "--mp3") == 0) {
 		gCompMode = kMP3Mode;
 		i++;
@@ -508,27 +519,34 @@
 		gCompMode = kFlacMode;
 		i++;
 	}
+
 	switch (gCompMode) {
 	case kMP3Mode:
 		tempEncoded = TEMP_MP3;
-		if (!process_mp3_parms(argc, argv, i))
+		if (!process_mp3_parms(argc, argv, i)) {
 			showhelp(argv[0]);
+		}
 		break;
 	case kVorbisMode:
 		tempEncoded = TEMP_OGG;
-		if (!process_ogg_parms(argc, argv, i))
+		if (!process_ogg_parms(argc, argv, i)) {
 			showhelp(argv[0]);
+		}
 		break;
 	case kFlacMode:
 		tempEncoded = TEMP_FLAC;
-		if (!process_flac_parms(argc, argv, i))
+		if (!process_flac_parms(argc, argv, i)) {
 			showhelp(argv[0]);
+		}
 		break;
 	}
 
-	i = argc - 1;
-	inputFileName = argv[i];
+	inputFileName = argv[argc - 1];
 
+	if (strrchr(inputFileName, '.') != NULL) {
+		error("Please specify the filename without an extension");
+	}
+
 	// ITE
 	sprintf(inputFileNameWithExt, "%s.rsc", inputFileName);
 	if (detectFile(inputFileNameWithExt)) {
@@ -546,7 +564,6 @@
 				// Check for MacBinary
 				sprintf(inputFileNameWithExt, "%s.bin", inputFileName);
 				if (detectFile(inputFileNameWithExt)) {
-					isSigned = false;
 					sagaEncode(inputFileName, ".bin");
 				}
 			}


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