diff options
Diffstat (limited to 'engines/zvision/video')
-rw-r--r-- | engines/zvision/video/rlf_decoder.cpp | 6 | ||||
-rw-r--r-- | engines/zvision/video/video.cpp | 10 | ||||
-rw-r--r-- | engines/zvision/video/zork_avi_decoder.cpp | 46 | ||||
-rw-r--r-- | engines/zvision/video/zork_avi_decoder.h | 17 |
4 files changed, 39 insertions, 40 deletions
diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index db598a25b6..3bbf22edff 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -159,7 +159,7 @@ RLFDecoder::RLFVideoTrack::Frame RLFDecoder::RLFVideoTrack::readNextFrame() { bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { uint frame = getFrameAtTime(time); - assert(frame < (int)_frameCount); + assert(frame < _frameCount); if ((uint)_displayedFrame == frame) return true; @@ -169,7 +169,7 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { if (distance < 0) { for (uint i = 0; i < _completeFrames.size(); ++i) { - if ((int)_completeFrames[i] > frame) + if (_completeFrames[i] > frame) break; closestFrame = _completeFrames[i]; } @@ -197,7 +197,7 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() { if (_displayedFrame >= (int)_frameCount) return NULL; - + _displayedFrame++; applyFrameToCurrent(_displayedFrame); diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 66a567abb2..1cfd0f4197 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -23,9 +23,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "video/video_decoder.h" -// TODO: Enable once VOB + AC3 support is implemented -#if 0 -//#ifdef USE_MPEG2 +#ifdef USE_MPEG2 #include "video/mpegps_decoder.h" #endif #include "engines/util.h" @@ -50,9 +48,7 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { animation = new RLFDecoder(); else if (tmpFileName.hasSuffix(".avi")) animation = new ZorkAVIDecoder(); -// TODO: Enable once VOB + AC3 support is implemented -#if 0 -//#ifdef USE_MPEG2 +#ifdef USE_MPEG2 else if (tmpFileName.hasSuffix(".vob")) animation = new Video::MPEGPSDecoder(); #endif @@ -66,7 +62,7 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { bool loaded = animation->loadStream(_file); if (!loaded) error("Error loading animation %s", tmpFileName.c_str()); - + return animation; } diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 5618250d79..1d23546551 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -34,33 +34,43 @@ namespace ZVision { Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) { - ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType); - return (Video::AVIDecoder::AVIAudioTrack *)audioTrack; + if (wvInfo.tag != kWaveFormatZorkPCM) + return new AVIAudioTrack(sHeader, wvInfo, _soundType); + + assert(wvInfo.size == 8); + 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::queueSound(Common::SeekableReadStream *stream) { - if (_audStream) { - if (_wvInfo.tag == kWaveFormatZorkPCM) { - assert(_wvInfo.size == 8); - RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream); - delete stream; +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; - if (chunk.data) { - byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; + if (chunk.data) { + byte flags = Audio::FLAG_16BITS; + if (_wvInfo.channels == 2) + flags |= Audio::FLAG_STEREO; #ifdef SCUMM_LITTLE_ENDIAN - // RawChunkStream produces native endianness int16 - flags |= Audio::FLAG_LITTLE_ENDIAN; + // RawChunkStream produces native endianness int16 + flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); - } - } else { - AVIAudioTrack::queueSound(stream); - } + _queueStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); } + + _curChunk++; } void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() { - decoder->init(); + AVIAudioTrack::resetStream(); + _decoder.init(); } } // End of namespace ZVision diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index 89c0d1e4b9..afcdb05676 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -39,22 +39,15 @@ 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(NULL) { - if (_audStream) { - decoder = new RawChunkStream(_audStream->isStereo()); - } - } - virtual ~ZorkAVIAudioTrack() { - if (decoder) - delete decoder; - } + ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType); + void createAudioStream(); void queueSound(Common::SeekableReadStream *stream); void resetStream(); + private: - RawChunkStream *decoder; + Audio::QueuingAudioStream *_queueStream; + RawChunkStream _decoder; }; Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo); |