[Scummvm-cvs-logs] scummvm master -> c6599ea5eed1b44f4aa8d632384f0dfa014e9327

lordhoto lordhoto at gmail.com
Sat Dec 24 18:24:50 CET 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c6599ea5ee AUDIO: Remove obsolete loadVOCFromStream.


Commit: c6599ea5eed1b44f4aa8d632384f0dfa014e9327
    https://github.com/scummvm/scummvm/commit/c6599ea5eed1b44f4aa8d632384f0dfa014e9327
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-12-24T09:23:47-08:00

Commit Message:
AUDIO: Remove obsolete loadVOCFromStream.

Changed paths:
    audio/decoders/voc.cpp
    audio/decoders/voc.h



diff --git a/audio/decoders/voc.cpp b/audio/decoders/voc.cpp
index 06a0b84..2cd5b23 100644
--- a/audio/decoders/voc.cpp
+++ b/audio/decoders/voc.cpp
@@ -54,7 +54,7 @@ bool checkVOCHeader(Common::ReadStream &stream) {
 	if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0)
 		return false;
 	//if (fileHeader.desc[19] != 0x1A)
-	//	debug(3, "loadVOCFromStream: Partially invalid header");
+	//	debug(3, "checkVOCHeader: Partially invalid header");
 
 	int32 offset = FROM_LE_16(fileHeader.datablock_offset);
 	int16 version = FROM_LE_16(fileHeader.version);
@@ -511,128 +511,6 @@ int getSampleRateFromVOCRate(int vocSR) {
 	}
 }
 
-byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) {
-	VocFileHeader fileHeader;
-
-	debug(2, "loadVOCFromStream");
-
-	if (stream.read(&fileHeader, 8) != 8)
-		goto invalid;
-
-	if (!memcmp(&fileHeader, "VTLK", 4)) {
-		if (stream.read(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader))
-			goto invalid;
-	} else if (!memcmp(&fileHeader, "Creative", 8)) {
-		if (stream.read(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8)
-			goto invalid;
-	} else {
-	invalid:;
-		warning("loadVOCFromStream: Invalid header");
-		return NULL;
-	}
-
-	if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0)
-		error("loadVOCFromStream: Invalid header");
-	if (fileHeader.desc[19] != 0x1A)
-		debug(3, "loadVOCFromStream: Partially invalid header");
-
-	int32 offset = FROM_LE_16(fileHeader.datablock_offset);
-	int16 version = FROM_LE_16(fileHeader.version);
-	int16 code = FROM_LE_16(fileHeader.id);
-	assert(offset == sizeof(VocFileHeader));
-	// 0x100 is an invalid VOC version used by German version of DOTT (Disk) and
-	// French version of Simon the Sorcerer 2 (CD)
-	assert(version == 0x010A || version == 0x0114 || version == 0x0100);
-	assert(code == ~version + 0x1234);
-
-	int len;
-	byte *ret_sound = 0;
-	size = 0;
-
-	while ((code = stream.readByte())) {
-		len = stream.readByte();
-		len |= stream.readByte() << 8;
-		len |= stream.readByte() << 16;
-
-		debug(2, "Block code %d, len %d", code, len);
-
-		switch (code) {
-		case 1:
-		case 9: {
-			int packing;
-			if (code == 1) {
-				int time_constant = stream.readByte();
-				packing = stream.readByte();
-				len -= 2;
-				rate = getSampleRateFromVOCRate(time_constant);
-			} else {
-				rate = stream.readUint32LE();
-				int bits = stream.readByte();
-				int channels = stream.readByte();
-				if (bits != 8 || channels != 1) {
-					warning("Unsupported VOC file format (%d bits per sample, %d channels)", bits, channels);
-					break;
-				}
-				packing = stream.readUint16LE();
-				stream.readUint32LE();
-				len -= 12;
-			}
-			debug(9, "VOC Data Block: %d, %d, %d", rate, packing, len);
-			if (packing == 0) {
-				if (size) {
-					byte *tmp = (byte *)realloc(ret_sound, size + len);
-					if (!tmp)
-						error("Cannot reallocate memory for VOC Data Block");
-
-					ret_sound = tmp;
-				} else {
-					ret_sound = (byte *)malloc(len);
-				}
-				stream.read(ret_sound + size, len);
-				size += len;
-			} else {
-				warning("VOC file packing %d unsupported", packing);
-			}
-			} break;
-		case 3: // silence
-			// occur with a few Igor sounds, voc file starts with a silence block with a
-			// frequency different from the data block. Just ignore fow now (implementing
-			// it wouldn't make a big difference anyway...)
-			assert(len == 3);
-			stream.readUint16LE();
-			stream.readByte();
-			break;
-		case 6:	// begin of loop
-			assert(len == 2);
-			stream.readUint16LE();
-			break;
-		case 7:	// end of loop
-			assert(len == 0);
-			break;
-		case 8: { // "Extended"
-			// This occures in the LoL Intro demo.
-			// This block overwrites the next parameters of a block 1 "Sound data".
-			// To assure we never get any bad data here, we will assert in case
-			// this tries to define a stereo sound block or tries to use something
-			// different than 8bit unsigned sound data.
-			// TODO: Actually we would need to check the frequency divisor (the
-			// first word) here too. It is used in the following equation:
-			// sampleRate = 256000000/(channels * (65536 - frequencyDivisor))
-			assert(len == 4);
-			stream.readUint16LE();
-			uint8 codec = stream.readByte();
-			uint8 channels = stream.readByte() + 1;
-			assert(codec == 0 && channels == 1);
-			} break;
-		default:
-			warning("Unhandled code %d in VOC file (len %d)", code, len);
-			return ret_sound;
-		}
-	}
-	debug(4, "VOC Data Size : %d", size);
-	return ret_sound;
-}
-
 SeekableAudioStream *makeVOCStream(Common::SeekableReadStream *stream, byte flags, DisposeAfterUse::Flag disposeAfterUse) {
 	if (!checkVOCHeader(*stream)) {
 		if (disposeAfterUse == DisposeAfterUse::YES)
diff --git a/audio/decoders/voc.h b/audio/decoders/voc.h
index 7d96d26..e16ffce 100644
--- a/audio/decoders/voc.h
+++ b/audio/decoders/voc.h
@@ -78,14 +78,6 @@ struct VocBlockHeader {
 extern int getSampleRateFromVOCRate(int vocSR);
 
 /**
- * Try to load a VOC from the given stream. Returns a pointer to memory
- * containing the PCM sample data (allocated with malloc). It is the callers
- * responsibility to dellocate that data again later on! Currently this
- * function only supports uncompressed raw PCM data.
- */
-extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate);
-
-/**
  * Try to load a VOC from the given seekable stream and create an AudioStream
  * from that data. Currently this function only supports uncompressed raw PCM
  * data.






More information about the Scummvm-git-logs mailing list