aboutsummaryrefslogtreecommitdiff
path: root/graphics/video/avi_decoder.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2010-11-11 13:23:26 +0000
committerMatthew Hoops2010-11-11 13:23:26 +0000
commit7207d920bc2f4e01a653e0fada30698c870b9e8b (patch)
tree058097ece592260c3064af6acc3c63f8efc79506 /graphics/video/avi_decoder.cpp
parent97067a75db00a29640e797da3f679074343a5526 (diff)
downloadscummvm-rg350-7207d920bc2f4e01a653e0fada30698c870b9e8b.tar.gz
scummvm-rg350-7207d920bc2f4e01a653e0fada30698c870b9e8b.tar.bz2
scummvm-rg350-7207d920bc2f4e01a653e0fada30698c870b9e8b.zip
VIDEO: Cleanup AVI audio in preparation for DK3
svn-id: r54200
Diffstat (limited to 'graphics/video/avi_decoder.cpp')
-rw-r--r--graphics/video/avi_decoder.cpp50
1 files changed, 31 insertions, 19 deletions
diff --git a/graphics/video/avi_decoder.cpp b/graphics/video/avi_decoder.cpp
index 713d57eb1e..40cb424ffc 100644
--- a/graphics/video/avi_decoder.cpp
+++ b/graphics/video/avi_decoder.cpp
@@ -30,11 +30,13 @@
#include "sound/audiostream.h"
#include "sound/mixer.h"
-#include "sound/decoders/raw.h"
#include "graphics/video/avi_decoder.h"
-// Codecs
+// Audio Codecs
+#include "sound/decoders/raw.h"
+
+// Video Codecs
#include "graphics/video/codecs/cinepak.h"
#include "graphics/video/codecs/indeo3.h"
#include "graphics/video/codecs/msvideo1.h"
@@ -342,20 +344,7 @@ Surface *AviDecoder::decodeNextFrame() {
} else if (getStreamType(nextTag) == 'wb') {
// Audio Chunk
uint32 chunkSize = _fileStream->readUint32LE();
- byte *data = (byte *)malloc(chunkSize);
- _fileStream->read(data, chunkSize);
-
- byte flags = 0;
- if (_audsHeader.sampleSize == 2)
- flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
- else
- flags |= Audio::FLAG_UNSIGNED;
-
- if (_wvInfo.channels == 2)
- flags |= Audio::FLAG_STEREO;
-
- if (_audStream)
- _audStream->queueBuffer(data, chunkSize, DisposeAfterUse::YES, flags);
+ queueAudioBuffer(chunkSize);
_fileStream->skip(chunkSize & 1); // Alignment
} else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' ||
getStreamType(nextTag) == 'AM' || getStreamType(nextTag) == '32') {
@@ -433,14 +422,37 @@ PixelFormat AviDecoder::getPixelFormat() const {
}
Audio::QueuingAudioStream *AviDecoder::createAudioStream() {
- if (_wvInfo.tag == AVI_WAVE_FORMAT_PCM)
+ if (_wvInfo.tag == kWaveFormatPCM)
return Audio::makeQueuingAudioStream(AUDIO_RATE, _wvInfo.channels == 2);
- else if (_wvInfo.tag == 98)
+ else if (_wvInfo.tag == kWaveFormatDK3)
warning("Unsupported DK3 IMA ADPCM sound");
- else if (_wvInfo.tag != 0) // No sound
+ else if (_wvInfo.tag != kWaveFormatNone) // No sound
warning("Unsupported AVI audio format %d", _wvInfo.tag);
return NULL;
}
+void AviDecoder::queueAudioBuffer(uint32 chunkSize) {
+ // Return if we haven't created the queue (unsupported audio format)
+ if (!_audStream) {
+ _fileStream->skip(chunkSize);
+ return;
+ }
+
+ Common::SeekableReadStream *stream = _fileStream->readStream(chunkSize);
+
+ if (_wvInfo.tag == kWaveFormatPCM) {
+ byte flags = 0;
+ if (_audsHeader.sampleSize == 2)
+ flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
+ else
+ flags |= Audio::FLAG_UNSIGNED;
+
+ if (_wvInfo.channels == 2)
+ flags |= Audio::FLAG_STEREO;
+
+ _audStream->queueAudioStream(Audio::makeRawStream(stream, AUDIO_RATE, flags, DisposeAfterUse::YES), DisposeAfterUse::YES);
+ }
+}
+
} // End of namespace Graphics