aboutsummaryrefslogtreecommitdiff
path: root/video/bink_decoder.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2011-10-20 09:27:26 -0700
committerEugene Sandulenko2011-10-20 09:27:26 -0700
commitf5e4d63a77ab83cc50bb0fa1ec4761bc4454688a (patch)
tree94a06380dc7fa7870f2de3c73c70abcac8c129b8 /video/bink_decoder.cpp
parent1736345906af095c863a62ded2638ce92c2a0704 (diff)
parentc9a59235b202d96aae2f295af7404d1b22e60bcf (diff)
downloadscummvm-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.cpp20
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);