aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders/quicktime.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-10 15:20:33 -0400
committerMatthew Hoops2011-07-10 15:50:47 -0400
commitc46aa548d6d8a1eabb968bfd0152215490bf746c (patch)
tree2d69f3ce5415f13a1b55af1f7efc5a5b43b1c4f4 /audio/decoders/quicktime.cpp
parent0d02cc0ef5efe1ed3d16904f6622fa9cd520be1d (diff)
downloadscummvm-rg350-c46aa548d6d8a1eabb968bfd0152215490bf746c.tar.gz
scummvm-rg350-c46aa548d6d8a1eabb968bfd0152215490bf746c.tar.bz2
scummvm-rg350-c46aa548d6d8a1eabb968bfd0152215490bf746c.zip
AUDIO: Fix remaining AAC bugs by decoding with the same AAC context
This introduces a new Audio::Codec class, based on DrMcCoy's solution for WMA in eos.
Diffstat (limited to 'audio/decoders/quicktime.cpp')
-rw-r--r--audio/decoders/quicktime.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index 0ad2821cd5..4531ccee19 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -30,6 +30,7 @@
#include "common/textconsole.h"
#include "audio/audiostream.h"
+#include "audio/decoders/codec.h"
#include "audio/decoders/quicktime.h"
#include "audio/decoders/quicktime_intern.h"
@@ -86,6 +87,9 @@ void QuickTimeAudioDecoder::init() {
// Make sure the bits per sample transfers to the sample size
if (entry->getCodecTag() == MKTAG('r', 'a', 'w', ' ') || entry->getCodecTag() == MKTAG('t', 'w', 'o', 's'))
_tracks[_audioTrackIndex]->sampleSize = (entry->_bitsPerSample / 8) * entry->_channels;
+
+ // Initialize the codec (if necessary)
+ entry->initCodec();
}
}
}
@@ -217,6 +221,9 @@ void QuickTimeAudioDecoder::setAudioStreamPos(const Timestamp &where) {
Audio::QuickTimeAudioDecoder::AudioSampleDesc *entry = (Audio::QuickTimeAudioDecoder::AudioSampleDesc *)_tracks[_audioTrackIndex]->sampleDescs[0];
_audStream = Audio::makeQueuingAudioStream(entry->_sampleRate, entry->_channels == 2);
+ // Reinitialize the codec
+ entry->initCodec();
+
// First, we need to track down what audio sample we need
Audio::Timestamp curAudioTime = where.convertToFramerate(_tracks[_audioTrackIndex]->timeScale);
uint32 sample = curAudioTime.totalNumberOfFrames();
@@ -266,6 +273,11 @@ QuickTimeAudioDecoder::AudioSampleDesc::AudioSampleDesc(Common::QuickTimeParser:
_samplesPerFrame = 0;
_bytesPerFrame = 0;
_bitsPerSample = 0;
+ _codec = 0;
+}
+
+QuickTimeAudioDecoder::AudioSampleDesc::~AudioSampleDesc() {
+ delete _codec;
}
bool QuickTimeAudioDecoder::AudioSampleDesc::isAudioCodecSupported() const {
@@ -313,7 +325,12 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
if (!stream)
return 0;
- if (_codecTag == MKTAG('t', 'w', 'o', 's') || _codecTag == MKTAG('r', 'a', 'w', ' ')) {
+ if (_codec) {
+ // If we've loaded a codec, make sure we use first
+ AudioStream *audioStream = _codec->decodeFrame(*stream);
+ delete stream;
+ return audioStream;
+ } else if (_codecTag == MKTAG('t', 'w', 'o', 's') || _codecTag == MKTAG('r', 'a', 'w', ' ')) {
// Fortunately, most of the audio used in Myst videos is raw...
uint16 flags = 0;
if (_codecTag == MKTAG('r', 'a', 'w', ' '))
@@ -330,12 +347,6 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
} else if (_codecTag == MKTAG('i', 'm', 'a', '4')) {
// Riven uses this codec (as do some Myst ME videos)
return makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), kADPCMApple, _sampleRate, _channels, 34);
- } else if (_codecTag == MKTAG('m', 'p', '4', 'a')) {
- // The 7th Guest iOS uses an MPEG-4 codec
-#ifdef USE_FAAD
- if (_parentTrack->objectTypeMP4 == 0x40)
- return makeAACStream(stream, DisposeAfterUse::YES, _parentTrack->extraData);
-#endif
#ifdef AUDIO_QDM2_H
} else if (_codecTag == MKTAG('Q', 'D', 'M', '2')) {
// Myst ME uses this codec for many videos
@@ -344,10 +355,24 @@ AudioStream *QuickTimeAudioDecoder::AudioSampleDesc::createAudioStream(Common::S
}
error("Unsupported audio codec");
-
return NULL;
}
+void QuickTimeAudioDecoder::AudioSampleDesc::initCodec() {
+ delete _codec; _codec = 0;
+
+ switch (_codecTag) {
+ case MKTAG('m', 'p', '4', 'a'):
+#ifdef USE_FAAD
+ if (_parentTrack->objectTypeMP4 == 0x40)
+ _codec = makeAACDecoder(_parentTrack->extraData);
+#endif
+ break;
+ default:
+ break;
+ }
+}
+
/**
* A wrapper around QuickTimeAudioDecoder that implements the RewindableAudioStream API
*/