mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 04:35:16 +00:00
HYPNO: Reduce memory usage when loading Smacker files with HYP2 signatures
This commit is contained in:
parent
b852af46c2
commit
47932474c5
@ -40,6 +40,9 @@ typedef Common::List<Filename> Filenames;
|
||||
class HypnoSmackerDecoder : public Video::SmackerDecoder {
|
||||
public:
|
||||
bool loadStream(Common::SeekableReadStream *stream) override;
|
||||
|
||||
protected:
|
||||
uint32 getSignatureVersion(uint32 signature) const override;
|
||||
};
|
||||
|
||||
class MVideo {
|
||||
|
@ -324,30 +324,6 @@ void HypnoEngine::drawImage(Graphics::Surface &surf, int x, int y, bool transpar
|
||||
_compositeSurface->blitFrom(surf, Common::Point(x, y));
|
||||
}
|
||||
|
||||
Common::File *HypnoEngine::fixSmackerHeader(Common::File *file) {
|
||||
Common::String magic;
|
||||
magic += file->readByte();
|
||||
magic += file->readByte();
|
||||
magic += file->readByte();
|
||||
magic += file->readByte();
|
||||
|
||||
if (magic == "HYP2") {
|
||||
uint32 size = file->size();
|
||||
byte *data = (byte *)malloc(size);
|
||||
file->seek(0);
|
||||
file->read(data, size);
|
||||
data[0] = 'S';
|
||||
data[1] = 'M';
|
||||
data[2] = 'K';
|
||||
file->close();
|
||||
delete file;
|
||||
file = (Common::File *)new Common::MemoryReadStream(data, size, DisposeAfterUse::YES);
|
||||
} else
|
||||
file->seek(0);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
Graphics::Surface *HypnoEngine::decodeFrame(const Common::String &name, int n, byte **palette) {
|
||||
Common::File *file = new Common::File();
|
||||
Common::String path = convertPath(name);
|
||||
@ -357,8 +333,6 @@ Graphics::Surface *HypnoEngine::decodeFrame(const Common::String &name, int n, b
|
||||
if (!file->open(path))
|
||||
error("unable to find video file %s", path.c_str());
|
||||
|
||||
file = fixSmackerHeader(file);
|
||||
|
||||
HypnoSmackerDecoder vd;
|
||||
if (!vd.loadStream(file))
|
||||
error("unable to load video %s", path.c_str());
|
||||
@ -387,8 +361,6 @@ Frames HypnoEngine::decodeFrames(const Common::String &name) {
|
||||
if (!file->open(path))
|
||||
error("unable to find video file %s", path.c_str());
|
||||
|
||||
file = fixSmackerHeader(file);
|
||||
|
||||
HypnoSmackerDecoder vd;
|
||||
if (!vd.loadStream(file))
|
||||
error("unable to load video %s", path.c_str());
|
||||
@ -526,8 +498,6 @@ void HypnoEngine::playVideo(MVideo &video) {
|
||||
if (!file->open(path))
|
||||
error("unable to find video file %s", path.c_str());
|
||||
|
||||
file = fixSmackerHeader(file);
|
||||
|
||||
if (video.decoder != nullptr) {
|
||||
debugC(1, kHypnoDebugMedia, "Restarting %s!!!!", video.path.c_str());
|
||||
delete video.decoder;
|
||||
|
@ -157,7 +157,6 @@ public:
|
||||
void playVideo(MVideo &video);
|
||||
void skipVideo(MVideo &video);
|
||||
|
||||
Common::File *fixSmackerHeader(Common::File *file);
|
||||
Graphics::Surface *decodeFrame(const Common::String &name, int frame, byte **palette = nullptr);
|
||||
Frames decodeFrames(const Common::String &name);
|
||||
void loadImage(const Common::String &file, int x, int y, bool transparent, bool palette = false, int frameNumber = 0);
|
||||
|
@ -49,4 +49,12 @@ bool HypnoSmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 HypnoSmackerDecoder::getSignatureVersion(uint32 signature) const {
|
||||
if (signature == MKTAG('H', 'Y', 'P', '2')) {
|
||||
return 2;
|
||||
} else {
|
||||
return SmackerDecoder::getSignatureVersion(signature);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user