mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
NANCY: Add support for uncompressed video
Added support for the extremely rare case where an AVF video would be uncompressed.
This commit is contained in:
parent
62d7cd5792
commit
ff642056b4
@ -100,6 +100,7 @@ AVFDecoder::AVFVideoTrack::AVFVideoTrack(Common::SeekableReadStream *stream, uin
|
||||
_frameTime = stream->readUint32LE();
|
||||
|
||||
byte comp = stream->readByte();
|
||||
_compressed = comp == 2;
|
||||
|
||||
uint formatHi = chunkFileFormat >> 16;
|
||||
|
||||
@ -107,7 +108,7 @@ AVFDecoder::AVFVideoTrack::AVFVideoTrack(Common::SeekableReadStream *stream, uin
|
||||
stream->skip(1);
|
||||
}
|
||||
|
||||
if (comp != 2)
|
||||
if (comp != 1 && comp != 2)
|
||||
error("Unknown compression type %d found in AVF", comp);
|
||||
|
||||
_surface = new Graphics::Surface();
|
||||
@ -247,27 +248,38 @@ const Graphics::Surface *AVFDecoder::AVFVideoTrack::decodeFrame(uint frameNr) {
|
||||
warning("Decompressed size %d exceeds frame size %d", info.size, _frameSize);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
decompBuf = (byte *)_surface->getPixels();
|
||||
} else {
|
||||
// For types 1 and 2, we decompress to a temp buffer for decoding
|
||||
decompBuf = new byte[info.size];
|
||||
}
|
||||
|
||||
Common::MemoryWriteStream output((info.type == 0 ? (byte *)_surface->getPixels() : decompBuf), info.size);
|
||||
|
||||
Common::SeekableSubReadStream input(_fileStream, info.offset, info.offset + info.compressedSize);
|
||||
|
||||
if (!_dec->decompress(input, output)) {
|
||||
warning("Failed to decompress frame %d", frameNr);
|
||||
delete[] decompBuf;
|
||||
return nullptr;
|
||||
}
|
||||
if (_compressed) {
|
||||
Common::MemoryWriteStream output(decompBuf, info.size);
|
||||
|
||||
if (!_dec->decompress(input, output)) {
|
||||
warning("Failed to decompress frame %d", frameNr);
|
||||
delete[] decompBuf;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
// No compression, just copy the data
|
||||
input.read(decompBuf, info.size);
|
||||
}
|
||||
|
||||
if (info.type != 0) {
|
||||
Common::MemoryReadStream decompStr(decompBuf, info.size);
|
||||
decode((byte *)_surface->getPixels(), _frameSize, decompStr);
|
||||
}
|
||||
|
||||
if (info.type != 0) {
|
||||
delete[] decompBuf;
|
||||
}
|
||||
|
||||
_refFrame = frameNr;
|
||||
delete[] decompBuf;
|
||||
return _surface;
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ private:
|
||||
Common::Array<ChunkInfo> _chunkInfo;
|
||||
Decompressor *_dec;
|
||||
bool _reversed;
|
||||
bool _compressed;
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user