[Scummvm-git-logs] scummvm master -> 417cc51bcb668a1a1aaa8efa406094c0a7ff37f0

dreammaster dreammaster at scummvm.org
Sat Sep 3 03:34:22 CEST 2016


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:
417cc51bcb AUDIO: Add support for MP3 encoded data in WAVE files


Commit: 417cc51bcb668a1a1aaa8efa406094c0a7ff37f0
    https://github.com/scummvm/scummvm/commit/417cc51bcb668a1a1aaa8efa406094c0a7ff37f0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-02T21:32:32-04:00

Commit Message:
AUDIO: Add support for MP3 encoded data in WAVE files

This is needed for playback of Starship Titanic speech data

Changed paths:
    audio/decoders/wave.cpp



diff --git a/audio/decoders/wave.cpp b/audio/decoders/wave.cpp
index cdd6412..6da0f2a 100644
--- a/audio/decoders/wave.cpp
+++ b/audio/decoders/wave.cpp
@@ -27,10 +27,19 @@
 #include "audio/audiostream.h"
 #include "audio/decoders/wave.h"
 #include "audio/decoders/adpcm.h"
+#include "audio/decoders/mp3.h"
 #include "audio/decoders/raw.h"
 
 namespace Audio {
 
+// Audio Codecs
+enum {
+	kWaveFormatPCM = 1,
+	kWaveFormatMSADPCM = 2,
+	kWaveFormatMSIMAADPCM = 17,
+	kWaveFormatMP3 = 85
+};
+
 bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags, uint16 *wavType, int *blockAlign_) {
 	const int32 initialPos = stream.pos();
 	byte buf[4+1];
@@ -97,17 +106,21 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate,
 	debug("  bitsPerSample: %d", bitsPerSample);
 #endif
 
-	if (type != 1 && type != 2 && type != 17) {
-		warning("getWavInfo: only PCM, MS ADPCM or IMA ADPCM data is supported (type %d)", type);
-		return false;
-	}
+	if (type == kWaveFormatMP3) {
+		bitsPerSample = 8;
+	} else {
+		if (type != kWaveFormatPCM && type != kWaveFormatMSADPCM && type != kWaveFormatMSIMAADPCM) {
+			warning("getWavInfo: only PCM, MS ADPCM, MP3, or IMA ADPCM data is supported (type %d)", type);
+			return false;
+		}
 
-	if (blockAlign != numChannels * bitsPerSample / 8 && type != 2) {
-		debug(0, "getWavInfo: blockAlign is invalid");
-	}
+		if (blockAlign != numChannels * bitsPerSample / 8 && type != kWaveFormatMSADPCM) {
+			debug(0, "getWavInfo: blockAlign is invalid");
+		}
 
-	if (avgBytesPerSec != samplesPerSec * blockAlign && type != 2) {
-		debug(0, "getWavInfo: avgBytesPerSec is invalid");
+		if (avgBytesPerSec != samplesPerSec * blockAlign && type != kWaveFormatMSADPCM) {
+			debug(0, "getWavInfo: avgBytesPerSec is invalid");
+		}
 	}
 
 	// Prepare the return values.
@@ -118,7 +131,7 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate,
 		flags |= Audio::FLAG_UNSIGNED;
 	else if (bitsPerSample == 16)	// 16 bit data is signed little endian
 		flags |= (Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN);
-	else if (bitsPerSample == 4 && (type == 2 || type == 17))
+	else if (bitsPerSample == 4 && (type == kWaveFormatMSADPCM || type == kWaveFormatMSIMAADPCM))
 		flags |= Audio::FLAG_16BITS;
 	else {
 		warning("getWavInfo: unsupported bitsPerSample %d", bitsPerSample);
@@ -170,10 +183,12 @@ SeekableAudioStream *makeWAVStream(Common::SeekableReadStream *stream, DisposeAf
 		return 0;
 	}
 
-	if (type == 17) // MS IMA ADPCM
+	if (type == kWaveFormatMSIMAADPCM) // MS IMA ADPCM
 		return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMSIma, rate, (flags & Audio::FLAG_STEREO) ? 2 : 1, blockAlign);
-	else if (type == 2) // MS ADPCM
+	else if (type == kWaveFormatMSADPCM) // MS ADPCM
 		return makeADPCMStream(stream, disposeAfterUse, size, Audio::kADPCMMS, rate, (flags & Audio::FLAG_STEREO) ? 2 : 1, blockAlign);
+	else if (type == kWaveFormatMP3)
+		return makeMP3Stream(stream, disposeAfterUse);
 
 	// Raw PCM, make sure the last packet is complete
 	uint sampleSize = (flags & Audio::FLAG_16BITS ? 2 : 1) * (flags & Audio::FLAG_STEREO ? 2 : 1);





More information about the Scummvm-git-logs mailing list