diff options
author | Eugene Sandulenko | 2011-10-20 09:27:26 -0700 |
---|---|---|
committer | Eugene Sandulenko | 2011-10-20 09:27:26 -0700 |
commit | f5e4d63a77ab83cc50bb0fa1ec4761bc4454688a (patch) | |
tree | 94a06380dc7fa7870f2de3c73c70abcac8c129b8 /video/bink_decoder.cpp | |
parent | 1736345906af095c863a62ded2638ce92c2a0704 (diff) | |
parent | c9a59235b202d96aae2f295af7404d1b22e60bcf (diff) | |
download | scummvm-rg350-f5e4d63a77ab83cc50bb0fa1ec4761bc4454688a.tar.gz scummvm-rg350-f5e4d63a77ab83cc50bb0fa1ec4761bc4454688a.tar.bz2 scummvm-rg350-f5e4d63a77ab83cc50bb0fa1ec4761bc4454688a.zip |
Merge pull request #80 from DrMcCoy/newbitstream
COMMON: Rewrite Common::BitStream as a template
Diffstat (limited to 'video/bink_decoder.cpp')
-rw-r--r-- | video/bink_decoder.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index a08c93522b..46ac8ac386 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -30,6 +30,7 @@ #include "common/textconsole.h" #include "common/math.h" #include "common/stream.h" +#include "common/substream.h" #include "common/file.h" #include "common/str.h" #include "common/bitstream.h" @@ -199,28 +200,37 @@ const Graphics::Surface *BinkDecoder::decodeNextFrame() { error("Audio packet too big for the frame"); if (audioPacketLength >= 4) { + uint32 audioPacketStart = _bink->pos(); + uint32 audioPacketEnd = _bink->pos() + audioPacketLength; + if (i == _audioTrack) { // Only play one audio track // Number of samples in bytes audio.sampleCount = _bink->readUint32LE() / (2 * audio.channels); - audio.bits = new Common::BitStream32LE(*_bink, (audioPacketLength - 4) * 8); + audio.bits = + new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink, + audioPacketStart + 4, audioPacketEnd), true); audioPacket(audio); delete audio.bits; audio.bits = 0; + } - } else - // Skip the rest - _bink->skip(audioPacketLength); + _bink->seek(audioPacketEnd); frameSize -= audioPacketLength; } } - frame.bits = new Common::BitStream32LE(*_bink, frameSize * 8); + uint32 videoPacketStart = _bink->pos(); + uint32 videoPacketEnd = _bink->pos() + frameSize; + + frame.bits = + new Common::BitStream32LELSB(new Common::SeekableSubReadStream(_bink, + videoPacketStart, videoPacketEnd), true); videoPacket(frame); |