[Scummvm-cvs-logs] SF.net SVN: scummvm:[46985] tools/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Jan 4 21:52:16 CET 2010


Revision: 46985
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46985&view=rev
Author:   fingolfin
Date:     2010-01-04 20:52:16 +0000 (Mon, 04 Jan 2010)

Log Message:
-----------
TOOLS: Remove CompressionFormat enum

Modified Paths:
--------------
    tools/trunk/compress.cpp
    tools/trunk/compress.h

Modified: tools/trunk/compress.cpp
===================================================================
--- tools/trunk/compress.cpp	2010-01-04 19:50:58 UTC (rev 46984)
+++ tools/trunk/compress.cpp	2010-01-04 20:52:16 UTC (rev 46985)
@@ -295,7 +295,7 @@
 	}
 }
 
-void CompressionTool::encodeRaw(char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode) {
+void CompressionTool::encodeRaw(const char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode) {
 
 	print(" - len=%ld, ch=%d, rate=%d, %dbits\n", length, (rawAudioType.isStereo ? 2 : 1), samplerate, rawAudioType.bitsPerSample);
 
@@ -437,7 +437,7 @@
 			} else {
 				/* Adapted from oggenc 1.1.1 */
 				if (rawAudioType.bitsPerSample == 8) {
-					unsigned char *rawDataUnsigned = (unsigned char *)rawData;
+					const byte *rawDataUnsigned = (const byte *)rawData;
 					for (i = 0; i < numSamples; i++) {
 						for (j = 0; j < numChannels; j++) {
 							buffer[j][i] = ((int)(rawDataUnsigned[i * numChannels + j]) - 128) / 128.0f;
@@ -450,8 +450,7 @@
 								buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j) + 1] << 8) | (rawData[(i * 2 * numChannels) + (2 * j)] & 0xff)) / 32768.0f;
 							}
 						}
-					}
-					else {
+					} else {
 						for (i = 0; i < numSamples; i++) {
 							for (j = 0; j < numChannels; j++) {
 								buffer[j][i] = ((rawData[(i * 2 * numChannels) + (2 * j)] << 8) | (rawData[(i * 2 * numChannels) + (2 * j) + 1] & 0xff)) / 32768.0f;
@@ -1013,14 +1012,14 @@
 	}
 }
 
-CompressionFormat compression_format(AudioFormat format) {
+int compression_format(AudioFormat format) {
 	switch(format) {
 	case AUDIO_MP3:
-		return COMPRESSION_MP3;
+		return 1;
 	case AUDIO_VORBIS:
-		return COMPRESSION_OGG;
+		return 2;
 	case AUDIO_FLAC:
-		return COMPRESSION_FLAC;
+		return 3;
 	case AUDIO_NONE:
 	default:
 		throw ToolException("Unknown compression format");

Modified: tools/trunk/compress.h
===================================================================
--- tools/trunk/compress.h	2010-01-04 19:50:58 UTC (rev 46984)
+++ tools/trunk/compress.h	2010-01-04 20:52:16 UTC (rev 46985)
@@ -54,26 +54,16 @@
  * You can bitwise them to represent several formats.
  */
 enum AudioFormat {
+	AUDIO_VORBIS = 1 << 0,
+	AUDIO_FLAC   = 1 << 1,
+	AUDIO_MP3    = 1 << 2,
+
 	AUDIO_NONE = 0,
-	AUDIO_VORBIS = 1,
-	AUDIO_FLAC = 2,
-	AUDIO_MP3 = 4,
 	AUDIO_ALL = AUDIO_VORBIS | AUDIO_FLAC | AUDIO_MP3
 };
 
-/**
- * Another enum, which cannot be ORed.
- * These are the values written to the output files.
- */
-enum CompressionFormat {
-	COMPRESSION_NONE = 0,
-	COMPRESSION_MP3 = 1,
-	COMPRESSION_OGG = 2,
-	COMPRESSION_FLAC = 3
-};
-
 const char *audio_extensions(AudioFormat format);
-CompressionFormat compression_format(AudioFormat format);
+int compression_format(AudioFormat format);
 
 
 /**
@@ -126,8 +116,11 @@
 	void extractAndEncodeWAV(const char *outName, Common::File &input, AudioFormat compMode);
 
 	void encodeAudio(const char *inname, bool rawInput, int rawSamplerate, const char *outname, AudioFormat compmode);
-	void encodeRaw(char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode);
 	void setRawAudioType(bool isLittleEndian, bool isStereo, uint8 bitsPerSample);
+
+protected:
+
+	void encodeRaw(const char *rawData, int length, int samplerate, const char *outname, AudioFormat compmode);
 };
 
 /*


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