[Scummvm-git-logs] scummvm master -> 47932474c51c40de1686a1b4e0acc488c4078240
neuromancer
noreply at scummvm.org
Sun Jun 5 19:30:09 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b852af46c2 VIDEO: Add generic support for Smacker videos with custom signatures
47932474c5 HYPNO: Reduce memory usage when loading Smacker files with HYP2 signatures
Commit: b852af46c2fda087add76b2e3fbb182a87eb8781
https://github.com/scummvm/scummvm/commit/b852af46c2fda087add76b2e3fbb182a87eb8781
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-05T21:30:06+02:00
Commit Message:
VIDEO: Add generic support for Smacker videos with custom signatures
Changed paths:
engines/toon/movie.cpp
engines/toon/movie.h
video/smk_decoder.cpp
video/smk_decoder.h
diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp
index 2fd43c483a1..97be1be1902 100644
--- a/engines/toon/movie.cpp
+++ b/engines/toon/movie.cpp
@@ -58,8 +58,8 @@ bool ToonstruckSmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
return true;
}
-Video::SmackerDecoder::SmackerVideoTrack *ToonstruckSmackerDecoder::createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const {
- return Video::SmackerDecoder::createVideoTrack(width, height, frameCount, frameRate, (height == 200) ? 4 : flags, signature);
+Video::SmackerDecoder::SmackerVideoTrack *ToonstruckSmackerDecoder::createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version) const {
+ return Video::SmackerDecoder::createVideoTrack(width, height, frameCount, frameRate, (height == 200) ? 4 : flags, version);
}
// decoder is deallocated with Movie destruction i.e. new ToonstruckSmackerDecoder is needed
diff --git a/engines/toon/movie.h b/engines/toon/movie.h
index 6644b8c39d3..3ed53f1d4fb 100644
--- a/engines/toon/movie.h
+++ b/engines/toon/movie.h
@@ -38,7 +38,7 @@ public:
protected:
void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize) override;
- SmackerVideoTrack *createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const override;
+ SmackerVideoTrack *createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version) const override;
private:
bool _lowRes;
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index 2d102d4e316..bc6c506c990 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -294,6 +294,16 @@ SmackerDecoder::~SmackerDecoder() {
close();
}
+uint32 SmackerDecoder::getSignatureVersion(uint32 signature) const {
+ if (signature == MKTAG('S', 'M', 'K', '2')) {
+ return 2;
+ } else if (signature == MKTAG('S', 'M', 'K', '4')) {
+ return 4;
+ } else {
+ return 0;
+ }
+}
+
bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
close();
@@ -302,7 +312,8 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
// Read in the Smacker header
_header.signature = _fileStream->readUint32BE();
- if (_header.signature != MKTAG('S', 'M', 'K', '2') && _header.signature != MKTAG('S', 'M', 'K', '4'))
+ uint32 version = getSignatureVersion(_header.signature);
+ if (version == 0)
return false;
uint32 width = _fileStream->readUint32LE();
@@ -329,7 +340,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
if (_header.flags & 1)
frameCount++;
- SmackerVideoTrack *videoTrack = createVideoTrack(width, height, frameCount, frameRate, _header.flags, _header.signature);
+ SmackerVideoTrack *videoTrack = createVideoTrack(width, height, frameCount, frameRate, _header.flags, version);
addTrack(videoTrack);
// TODO: should we do any extra processing for Smacker files with ring frames?
@@ -571,14 +582,14 @@ VideoDecoder::AudioTrack *SmackerDecoder::getAudioTrack(int index) {
return (AudioTrack *)track;
}
-SmackerDecoder::SmackerVideoTrack::SmackerVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) {
+SmackerDecoder::SmackerVideoTrack::SmackerVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version) {
_surface = new Graphics::Surface();
_surface->create(width, height * ((flags & 6) ? 2 : 1), Graphics::PixelFormat::createFormatCLUT8());
_dirtyBlocks.set_size(width * height / 16);
_frameCount = frameCount;
_frameRate = frameRate;
_flags = flags;
- _signature = signature;
+ _version = version;
_curFrame = -1;
_dirtyPalette = false;
_MMapTree = _MClrTree = _FullTree = _TypeTree = 0;
@@ -663,7 +674,7 @@ void SmackerDecoder::SmackerVideoTrack::decodeFrame(Common::BitStreamMemory8LSB
break;
case SMK_BLOCK_FULL:
// Smacker v2 has one mode, Smacker v4 has three
- if (_signature == MKTAG('S','M','K','2')) {
+ if (_version == 2) {
mode = 0;
} else {
// 00 - mode 0
@@ -927,8 +938,8 @@ void SmackerDecoder::SmackerAudioTrack::queuePCM(byte *buffer, uint32 bufferSize
_audioStream->queueBuffer(buffer, bufferSize, DisposeAfterUse::YES, flags);
}
-SmackerDecoder::SmackerVideoTrack *SmackerDecoder::createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const {
- return new SmackerVideoTrack(width, height, frameCount, frameRate, flags, signature);
+SmackerDecoder::SmackerVideoTrack *SmackerDecoder::createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version) const {
+ return new SmackerVideoTrack(width, height, frameCount, frameRate, flags, version);
}
Common::Rational SmackerDecoder::getFrameRate() const {
diff --git a/video/smk_decoder.h b/video/smk_decoder.h
index db9ecee20db..3b1f910b5e8 100644
--- a/video/smk_decoder.h
+++ b/video/smk_decoder.h
@@ -81,9 +81,11 @@ protected:
virtual void handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize);
+ virtual uint32 getSignatureVersion(uint32 signature) const;
+
class SmackerVideoTrack : public FixedRateVideoTrack {
public:
- SmackerVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature);
+ SmackerVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version);
~SmackerVideoTrack();
bool isRewindable() const { return true; }
@@ -112,7 +114,7 @@ protected:
private:
Common::Rational _frameRate;
- uint32 _flags, _signature;
+ uint32 _flags, _version;
byte _palette[3 * 256];
mutable bool _dirtyPalette;
@@ -132,7 +134,7 @@ protected:
static uint getBlockRun(int index) { return (index <= 58) ? index + 1 : 128 << (index - 59); }
};
- virtual SmackerVideoTrack *createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) const;
+ virtual SmackerVideoTrack *createVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 version) const;
Common::SeekableReadStream *_fileStream;
Commit: 47932474c51c40de1686a1b4e0acc488c4078240
https://github.com/scummvm/scummvm/commit/47932474c51c40de1686a1b4e0acc488c4078240
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-05T21:30:06+02:00
Commit Message:
HYPNO: Reduce memory usage when loading Smacker files with HYP2 signatures
Changed paths:
engines/hypno/grammar.h
engines/hypno/hypno.cpp
engines/hypno/hypno.h
engines/hypno/video.cpp
diff --git a/engines/hypno/grammar.h b/engines/hypno/grammar.h
index bbee1263d9b..a7c3c5a2046 100644
--- a/engines/hypno/grammar.h
+++ b/engines/hypno/grammar.h
@@ -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 {
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 90911a6c896..2fcfc7f2264 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -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;
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index 83660dc6715..e63d034bfef 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -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);
diff --git a/engines/hypno/video.cpp b/engines/hypno/video.cpp
index 696b2d27972..74fefc12b35 100644
--- a/engines/hypno/video.cpp
+++ b/engines/hypno/video.cpp
@@ -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);
+ }
+}
+
}
More information about the Scummvm-git-logs
mailing list