diff options
author | Peter Kohaut | 2019-04-13 01:03:48 +0200 |
---|---|---|
committer | Peter Kohaut | 2019-04-17 22:51:18 +0200 |
commit | e86ee33999f33ad66bb7c018b4d4b7604b48badb (patch) | |
tree | fbc44cf5d597c7aaed1ee230bad4e5918ee92b4b /engines/bladerunner/vqa_decoder.cpp | |
parent | 955bf0c6694cca49e5031ec9866b343cc86f596d (diff) | |
download | scummvm-rg350-e86ee33999f33ad66bb7c018b4d4b7604b48badb.tar.gz scummvm-rg350-e86ee33999f33ad66bb7c018b4d4b7604b48badb.tar.bz2 scummvm-rg350-e86ee33999f33ad66bb7c018b4d4b7604b48badb.zip |
BLADERUNNER: Abstraction from 555 pixel format
Removing hardcoded 555 pixel format to support Android
Diffstat (limited to 'engines/bladerunner/vqa_decoder.cpp')
-rw-r--r-- | engines/bladerunner/vqa_decoder.cpp | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp index 05ad7a8449..e97d2383a9 100644 --- a/engines/bladerunner/vqa_decoder.cpp +++ b/engines/bladerunner/vqa_decoder.cpp @@ -830,42 +830,31 @@ bool VQADecoder::VQAVideoTrack::readVPTR(Common::SeekableReadStream *s, uint32 s } void VQADecoder::VQAVideoTrack::VPTRWriteBlock(Graphics::Surface *surface, unsigned int dstBlock, unsigned int srcBlock, int count, bool alpha) { - uint16 *frame = (uint16 *)surface->getPixels(); - uint16 frame_width = _width; - uint32 frame_stride = surface->w; - uint16 block_width = _blockW; - uint16 block_height = _blockH; + const uint8 *const block_src = &_codebook[2 * srcBlock * _blockW * _blockH]; - const uint8 *const block_src = - &_codebook[2 * srcBlock * block_width * block_height]; + int blocks_per_line = _width / _blockW; - int blocks_per_line = frame_width / block_width; + for (int i = 0; i < count; ++i) { + uint32 dst_x = (dstBlock + i) % blocks_per_line * _blockW + _offsetX; + uint32 dst_y = (dstBlock + i) / blocks_per_line * _blockH + _offsetY; - do { - uint32 frame_x = dstBlock % blocks_per_line * block_width + _offsetX; - uint32 frame_y = dstBlock / blocks_per_line * block_height + _offsetY; - - uint32 dst_offset = frame_x + frame_y * frame_stride; + const uint8 *src_p = block_src; - const uint8 *__restrict src = block_src; - uint16 *__restrict dst = frame + dst_offset; + for (int y = 0; y != _blockH; ++y) { + for (int x = 0; x != _blockW; ++x) { + uint16 vqaColor = READ_LE_UINT16(src_p); + src_p += 2; - unsigned int block_y; - for (block_y = 0; block_y != block_height; ++block_y) { - unsigned int block_x; - for (block_x = 0; block_x != block_width; ++block_x) { - uint16 rgb555 = src[0] | (src[1] << 8); - src += 2; + uint8 a, r, g, b; + gameDataPixelFormat().colorToARGB(vqaColor, a, r, g, b); + uint16 outColor = (uint16)surface->format.ARGBToColor(a, r, g, b); - if (!(alpha && (rgb555 & 0x8000))) - *dst = rgb555; - ++dst; + if (!(alpha && a)) { + *(uint16 *)(surface->getBasePtr(dst_x + x, dst_y + y)) = outColor; + } } - dst += frame_stride - block_width; } - - ++dstBlock; - } while (--count); + } } bool VQADecoder::VQAVideoTrack::decodeFrame(Graphics::Surface *surface) { |