mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 16:33:50 +00:00
IMAGE: Make JYV1 decoder a little more robust to bad data
This commit is contained in:
parent
99642ec18e
commit
732d05f036
@ -75,8 +75,6 @@ const Graphics::Surface *JYV1Decoder::decodeFrame(Common::SeekableReadStream &st
|
|||||||
offsets[i] = stream.readUint32LE() + startOffset;
|
offsets[i] = stream.readUint32LE() + startOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = 0;
|
|
||||||
int x = 0;
|
|
||||||
bool upscale = false;
|
bool upscale = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -106,7 +104,10 @@ const Graphics::Surface *JYV1Decoder::decodeFrame(Common::SeekableReadStream &st
|
|||||||
upscale = true;
|
upscale = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numOffsets; i++) {
|
int y = 0;
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < numOffsets && y < _height; i++) {
|
||||||
stream.seek(offsets[i], SEEK_SET);
|
stream.seek(offsets[i], SEEK_SET);
|
||||||
const int cmdLen = stream.readUint32LE();
|
const int cmdLen = stream.readUint32LE();
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ const Graphics::Surface *JYV1Decoder::decodeFrame(Common::SeekableReadStream &st
|
|||||||
Common::BitStreamMemoryStream cmdMemStream(cmdData, cmdLen);
|
Common::BitStreamMemoryStream cmdMemStream(cmdData, cmdLen);
|
||||||
Common::BitStreamMemory8MSB cmdBitStream(cmdMemStream);
|
Common::BitStreamMemory8MSB cmdBitStream(cmdMemStream);
|
||||||
bool skipping = true;
|
bool skipping = true;
|
||||||
while (!cmdBitStream.eos()) {
|
while (cmdBitStream.size() - cmdBitStream.pos() >= 4 && y < _height) {
|
||||||
uint32 idx = cmdBitStream.getBits(4);
|
uint32 idx = cmdBitStream.getBits(4);
|
||||||
uint32 blocksize = BASE_LEN[idx];
|
uint32 blocksize = BASE_LEN[idx];
|
||||||
if (idx != 0 && idx != 8) {
|
if (idx != 0 && idx != 8) {
|
||||||
@ -137,7 +138,7 @@ const Graphics::Surface *JYV1Decoder::decodeFrame(Common::SeekableReadStream &st
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// draw blocksize pixels from data block
|
// draw blocksize pixels from data block
|
||||||
while (blocksize) {
|
while (blocksize && y < _height) {
|
||||||
// TODO: would be nicer to read these in whole scanlines.
|
// TODO: would be nicer to read these in whole scanlines.
|
||||||
// Also this upscale code is kinda ugly.
|
// Also this upscale code is kinda ugly.
|
||||||
const uint8 p = stream.readByte();
|
const uint8 p = stream.readByte();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user