aboutsummaryrefslogtreecommitdiff
path: root/video/bink_decoder.cpp
diff options
context:
space:
mode:
authorSven Hesse2011-08-27 19:24:36 +0200
committerSven Hesse2011-08-27 23:37:07 +0200
commitf1724f1637219676a0dbb507cc0330a8e18ca323 (patch)
tree6e6e6f94963d67d2130de5a6c41066a73ceeb64f /video/bink_decoder.cpp
parent35aa235e4b4c4212b59d00adb77d2e3d00dd440e (diff)
downloadscummvm-rg350-f1724f1637219676a0dbb507cc0330a8e18ca323.tar.gz
scummvm-rg350-f1724f1637219676a0dbb507cc0330a8e18ca323.tar.bz2
scummvm-rg350-f1724f1637219676a0dbb507cc0330a8e18ca323.zip
COMMON: Rewrite BitStream as a template
This rewrites BitStream as a template, allowing for more different memory layouts of the actual bit data.
Diffstat (limited to 'video/bink_decoder.cpp')
-rw-r--r--video/bink_decoder.cpp20
1 files changed, 15 insertions, 5 deletions
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);