mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 19:30:41 +00:00
VIDEO: Switch to all packetized streams for AVI
ZVision does not currently, but that's OK
This commit is contained in:
parent
72239a25f9
commit
561d1a1d62
@ -41,6 +41,15 @@ Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDec
|
||||
return new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);
|
||||
}
|
||||
|
||||
ZorkAVIDecoder::ZorkAVIAudioTrack::ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :
|
||||
Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), _queueStream(0), _decoder(waveFormat.channels == 2) {
|
||||
}
|
||||
|
||||
void ZorkAVIDecoder::ZorkAVIAudioTrack::createAudioStream() {
|
||||
_queueStream = Audio::makeQueuingAudioStream(_wvInfo.samplesPerSec, _wvInfo.channels == 2);
|
||||
_audioStream = _queueStream;
|
||||
}
|
||||
|
||||
void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {
|
||||
RawChunkStream::RawChunk chunk = _decoder.readNextChunk(stream);
|
||||
delete stream;
|
||||
|
@ -39,15 +39,14 @@ public:
|
||||
private:
|
||||
class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {
|
||||
public:
|
||||
ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :
|
||||
Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType),
|
||||
_decoder(waveFormat.channels == 2) {
|
||||
}
|
||||
ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType);
|
||||
|
||||
void createAudioStream();
|
||||
void queueSound(Common::SeekableReadStream *stream);
|
||||
void resetStream();
|
||||
|
||||
private:
|
||||
Audio::QueuingAudioStream *_queueStream;
|
||||
RawChunkStream _decoder;
|
||||
};
|
||||
|
||||
|
@ -278,7 +278,9 @@ void AVIDecoder::handleStreamHeader(uint32 size) {
|
||||
if (wvInfo.channels == 2)
|
||||
sHeader.sampleSize /= 2;
|
||||
|
||||
addTrack(createAudioTrack(sHeader, wvInfo));
|
||||
AVIAudioTrack *track = createAudioTrack(sHeader, wvInfo);
|
||||
track->createAudioStream();
|
||||
addTrack(track);
|
||||
}
|
||||
|
||||
// Ensure that we're at the end of the chunk
|
||||
@ -841,40 +843,18 @@ void AVIDecoder::AVIVideoTrack::setDither(const byte *palette) {
|
||||
}
|
||||
|
||||
AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType)
|
||||
: _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType), _curChunk(0) {
|
||||
createAudioStream();
|
||||
: _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType), _audioStream(0), _packetStream(0), _curChunk(0) {
|
||||
}
|
||||
|
||||
AVIDecoder::AVIAudioTrack::~AVIAudioTrack() {
|
||||
delete _queueStream;
|
||||
delete _packetStream;
|
||||
delete _audioStream;
|
||||
}
|
||||
|
||||
void AVIDecoder::AVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {
|
||||
if (_packetStream) {
|
||||
if (_packetStream)
|
||||
_packetStream->queuePacket(stream);
|
||||
} else if (_queueStream) {
|
||||
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;
|
||||
|
||||
_queueStream->queueAudioStream(Audio::makeRawStream(stream, _wvInfo.samplesPerSec, flags, DisposeAfterUse::YES), DisposeAfterUse::YES);
|
||||
} else if (_wvInfo.tag == kWaveFormatMSADPCM) {
|
||||
_queueStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMMS, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES);
|
||||
} else if (_wvInfo.tag == kWaveFormatMSIMAADPCM) {
|
||||
_queueStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMMSIma, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES);
|
||||
} else if (_wvInfo.tag == kWaveFormatDK3) {
|
||||
_queueStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMDK3, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES);
|
||||
}
|
||||
} else {
|
||||
else
|
||||
delete stream;
|
||||
}
|
||||
|
||||
_curChunk++;
|
||||
}
|
||||
@ -899,8 +879,7 @@ void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Au
|
||||
}
|
||||
|
||||
void AVIDecoder::AVIAudioTrack::resetStream() {
|
||||
delete _queueStream;
|
||||
delete _packetStream;
|
||||
delete _audioStream;
|
||||
createAudioStream();
|
||||
_curChunk = 0;
|
||||
}
|
||||
@ -910,33 +889,50 @@ bool AVIDecoder::AVIAudioTrack::rewind() {
|
||||
return true;
|
||||
}
|
||||
|
||||
Audio::AudioStream *AVIDecoder::AVIAudioTrack::getAudioStream() const {
|
||||
if (_packetStream)
|
||||
return _packetStream;
|
||||
|
||||
return _queueStream;
|
||||
}
|
||||
|
||||
void AVIDecoder::AVIAudioTrack::createAudioStream() {
|
||||
_queueStream = 0;
|
||||
_packetStream = 0;
|
||||
|
||||
if (_wvInfo.tag == kWaveFormatPCM || _wvInfo.tag == kWaveFormatMSADPCM || _wvInfo.tag == kWaveFormatMSIMAADPCM || _wvInfo.tag == kWaveFormatDK3) {
|
||||
// For now, a QueuingAudioStream will be created
|
||||
} else if (_wvInfo.tag == kWaveFormatMP3) {
|
||||
// MPEG audio
|
||||
switch (_wvInfo.tag) {
|
||||
case 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;
|
||||
|
||||
_packetStream = Audio::makePacketizedRawStream(_wvInfo.samplesPerSec, flags);
|
||||
break;
|
||||
}
|
||||
case kWaveFormatMSADPCM:
|
||||
_packetStream = Audio::makePacketizedADPCMStream(Audio::kADPCMMS, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign);
|
||||
break;
|
||||
case kWaveFormatMSIMAADPCM:
|
||||
_packetStream = Audio::makePacketizedADPCMStream(Audio::kADPCMMSIma, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign);
|
||||
break;
|
||||
case kWaveFormatDK3:
|
||||
_packetStream = Audio::makePacketizedADPCMStream(Audio::kADPCMDK3, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign);
|
||||
break;
|
||||
case kWaveFormatMP3:
|
||||
#ifdef USE_MAD
|
||||
_packetStream = Audio::makePacketizedMP3Stream(_wvInfo.channels, _wvInfo.samplesPerSec);
|
||||
#else
|
||||
warning("AVI MP3 stream found, but no libmad support compiled in");
|
||||
#endif
|
||||
} else if (_wvInfo.tag != kWaveFormatNone) {
|
||||
// No supported format
|
||||
break;
|
||||
case kWaveFormatNone:
|
||||
break;
|
||||
default:
|
||||
warning("Unsupported AVI audio format %d", _wvInfo.tag);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_packetStream)
|
||||
_queueStream = Audio::makeQueuingAudioStream(_wvInfo.samplesPerSec, _wvInfo.channels == 2);
|
||||
if (_packetStream)
|
||||
_audioStream = _packetStream;
|
||||
else
|
||||
_audioStream = Audio::makeNullAudioStream();
|
||||
}
|
||||
|
||||
AVIDecoder::TrackStatus::TrackStatus() : track(0), chunkSearchOffset(0) {
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include "audio/mixer.h"
|
||||
|
||||
namespace Audio {
|
||||
class AudioStream;
|
||||
class PacketizedAudioStream;
|
||||
class QueuingAudioStream;
|
||||
}
|
||||
|
||||
namespace Common {
|
||||
@ -216,6 +216,7 @@ protected:
|
||||
AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType);
|
||||
~AVIAudioTrack();
|
||||
|
||||
virtual void createAudioStream();
|
||||
virtual void queueSound(Common::SeekableReadStream *stream);
|
||||
Audio::Mixer::SoundType getSoundType() const { return _soundType; }
|
||||
void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime);
|
||||
@ -227,7 +228,7 @@ protected:
|
||||
bool rewind();
|
||||
|
||||
protected:
|
||||
Audio::AudioStream *getAudioStream() const;
|
||||
Audio::AudioStream *getAudioStream() const { return _audioStream; }
|
||||
|
||||
// Audio Codecs
|
||||
enum {
|
||||
@ -242,9 +243,8 @@ protected:
|
||||
AVIStreamHeader _audsHeader;
|
||||
PCMWaveFormat _wvInfo;
|
||||
Audio::Mixer::SoundType _soundType;
|
||||
Audio::QueuingAudioStream *_queueStream;
|
||||
Audio::AudioStream *_audioStream;
|
||||
Audio::PacketizedAudioStream *_packetStream;
|
||||
void createAudioStream();
|
||||
uint32 _curChunk;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user