From f1724f1637219676a0dbb507cc0330a8e18ca323 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 27 Aug 2011 19:24:36 +0200 Subject: COMMON: Rewrite BitStream as a template This rewrites BitStream as a template, allowing for more different memory layouts of the actual bit data. --- video/bink_decoder.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'video/bink_decoder.cpp') diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index c02042f972..41cd591282 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); -- cgit v1.2.3