aboutsummaryrefslogtreecommitdiff
path: root/audio/decoders/quicktime.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-04-10 14:51:24 -0400
committerMatthew Hoops2011-04-10 14:51:24 -0400
commitf9413e4dc26081f59247fa7eae62f50258e92fa4 (patch)
tree5d5a22adf1a402133480a0c7b018db1869ce48b1 /audio/decoders/quicktime.cpp
parent13a6f40dbba1ae389b967b97b9c1cf83685af5e6 (diff)
downloadscummvm-rg350-f9413e4dc26081f59247fa7eae62f50258e92fa4.tar.gz
scummvm-rg350-f9413e4dc26081f59247fa7eae62f50258e92fa4.tar.bz2
scummvm-rg350-f9413e4dc26081f59247fa7eae62f50258e92fa4.zip
AUDIO: Add support for AAC audio
Diffstat (limited to 'audio/decoders/quicktime.cpp')
-rw-r--r--audio/decoders/quicktime.cpp72
1 files changed, 52 insertions, 20 deletions
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index e18ba7c480..9b69012c7a 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -32,6 +32,7 @@
#include "audio/decoders/quicktime.h"
// Codecs
+#include "audio/decoders/aac.h"
#include "audio/decoders/adpcm.h"
#include "audio/decoders/qdm2.h"
#include "audio/decoders/raw.h"
@@ -153,9 +154,13 @@ bool QuickTimeAudioDecoder::checkAudioCodecSupport(uint32 tag, byte objectTypeMP
if (tag == MKID_BE('mp4a')) {
Common::String audioType;
switch (objectTypeMP4) {
- case 0x40:
+ case 0x40: // AAC
+#ifdef USE_FAAD
+ return true;
+#else
audioType = "AAC";
break;
+#endif
default:
audioType = "Unknown";
break;
@@ -190,6 +195,12 @@ AudioStream *QuickTimeAudioDecoder::createAudioStream(Common::SeekableReadStream
} else if (entry->codecTag == MKID_BE('ima4')) {
// Riven uses this codec (as do some Myst ME videos)
return makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), kADPCMApple, entry->sampleRate, entry->channels, 34);
+ } else if (entry->codecTag == MKID_BE('mp4a')) {
+ // The 7th Guest iOS uses an MPEG-4 codec
+#ifdef USE_FAAD
+ if (_streams[_audioStreamIndex]->objectTypeMP4 == 0x40)
+ return makeAACStream(stream, DisposeAfterUse::YES, _streams[_audioStreamIndex]->extradata);
+#endif
#ifdef AUDIO_QDM2_H
} else if (entry->codecTag == MKID_BE('QDM2')) {
// Myst ME uses this codec for many videos
@@ -225,27 +236,48 @@ void QuickTimeAudioDecoder::queueNextAudioChunk() {
uint32 sampleCount = getAudioChunkSampleCount(_curAudioChunk);
assert(sampleCount);
- // Then calculate the right sizes
- while (sampleCount > 0) {
- uint32 samples = 0, size = 0;
+ if (_streams[_audioStreamIndex]->stts_count == 1 && _streams[_audioStreamIndex]->stts_data[0].duration == 1) {
+ // Old-style audio demuxing
+
+ // Then calculate the right sizes
+ while (sampleCount > 0) {
+ uint32 samples = 0, size = 0;
+
+ if (entry->samplesPerFrame >= 160) {
+ samples = entry->samplesPerFrame;
+ size = entry->bytesPerFrame;
+ } else if (entry->samplesPerFrame > 1) {
+ samples = MIN<uint32>((1024 / entry->samplesPerFrame) * entry->samplesPerFrame, sampleCount);
+ size = (samples / entry->samplesPerFrame) * entry->bytesPerFrame;
+ } else {
+ samples = MIN<uint32>(1024, sampleCount);
+ size = samples * _streams[_audioStreamIndex]->sample_size;
+ }
- if (entry->samplesPerFrame >= 160) {
- samples = entry->samplesPerFrame;
- size = entry->bytesPerFrame;
- } else if (entry->samplesPerFrame > 1) {
- samples = MIN<uint32>((1024 / entry->samplesPerFrame) * entry->samplesPerFrame, sampleCount);
- size = (samples / entry->samplesPerFrame) * entry->bytesPerFrame;
- } else {
- samples = MIN<uint32>(1024, sampleCount);
- size = samples * _streams[_audioStreamIndex]->sample_size;
+ // Now, we read in the data for this data and output it
+ byte *data = (byte *)malloc(size);
+ _fd->read(data, size);
+ wStream->write(data, size);
+ free(data);
+ sampleCount -= samples;
+ }
+ } else {
+ // New-style audio demuxing
+
+ // Find our starting sample
+ uint32 startSample = 0;
+ for (uint32 i = 0; i < _curAudioChunk; i++)
+ startSample += getAudioChunkSampleCount(i);
+
+ for (uint32 i = 0; i < sampleCount; i++) {
+ uint32 size = (_streams[_audioStreamIndex]->sample_size != 0) ? _streams[_audioStreamIndex]->sample_size : _streams[_audioStreamIndex]->sample_sizes[i + startSample];
+
+ // Now, we read in the data for this data and output it
+ byte *data = (byte *)malloc(size);
+ _fd->read(data, size);
+ wStream->write(data, size);
+ free(data);
}
-
- // Now, we read in the data for this data and output it
- byte *data = (byte *)malloc(size);
- _fd->read(data, size);
- wStream->write(data, size);
- free(data);
- sampleCount -= samples;
}
// Now queue the buffer