[Scummvm-git-logs] scummvm master -> a5af85d6fb20a8764f796d9c624025cf652f7560
rvanlaar
noreply at scummvm.org
Tue Mar 1 16:19:18 UTC 2022
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
d9222bed62 VIDEO: PACo decoder: fix dirty rect handler
810792195a VIDEO: PACo decoder: support custom palettes
f89084dd39 VIDEO: PACo decoder up debug level
a5af85d6fb DIRECTOR: LINGO: Implement palette changes in PACo
Commit: d9222bed62c8571aa8d9b0d5002c4df19772230f
https://github.com/scummvm/scummvm/commit/d9222bed62c8571aa8d9b0d5002c4df19772230f
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-01T17:09:01+01:00
Commit Message:
VIDEO: PACo decoder: fix dirty rect handler
Rects are left, top, right, bottom. Not left, top, width, height.
Changed paths:
video/paco_decoder.cpp
diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index feb9c015d9a..cdb3798e8d6 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -491,8 +491,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
_dirtyRects.clear();
- _dirtyRects.push_back(Common::Rect(x, y, bw, bh));
-
+ _dirtyRects.push_back(Common::Rect(x, y, x + bw, y + bh));
}
void PacoDecoder::PacoVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
Commit: 810792195ad10fe16c7304f0c34aa827cff473ce
https://github.com/scummvm/scummvm/commit/810792195ad10fe16c7304f0c34aa827cff473ce
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-01T17:09:01+01:00
Commit Message:
VIDEO: PACo decoder: support custom palettes
Custom palettes inside PACo files are now parsed and imported.
Changed paths:
video/paco_decoder.cpp
video/paco_decoder.h
diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index cdb3798e8d6..2083c7f3027 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -99,6 +99,11 @@ const byte* PacoDecoder::getPalette(){
return nullptr;
}
+const byte* PacoDecoder::PacoVideoTrack::getPalette() const {
+ _dirtyPalette = false;
+ return _palette;
+}
+
PacoDecoder::PacoVideoTrack::PacoVideoTrack(
Common::SeekableReadStream *stream, uint16 frameRate, uint16 frameCount, bool hasAudio, uint16 width, uint16 height) {
@@ -109,7 +114,7 @@ PacoDecoder::PacoVideoTrack::PacoVideoTrack(
_surface = new Graphics::Surface();
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_palette = const_cast<byte *>(quickTimeDefaultPalette256);
- _dirtyPalette = false;
+ _dirtyPalette = true;
_curFrame = 0;
@@ -176,7 +181,7 @@ const Graphics::Surface *PacoDecoder::PacoVideoTrack::decodeNextFrame() {
handleFrame(chunkSize - 4);
break;
case PALLETE:
- warning("PacoDecode::decodeFrame(): Palette not implemented");
+ handlePalette();
break;
case EOC:
break;
@@ -192,6 +197,21 @@ const Graphics::Surface *PacoDecoder::PacoVideoTrack::decodeNextFrame() {
return _surface;
}
+void PacoDecoder::PacoVideoTrack::handlePalette() {
+ uint32 header = _fileStream->readUint32BE();
+ if (header == 0x30000000) { // default quicktime palette
+ _palette = const_cast<byte *>(quickTimeDefaultPalette256);
+ } else {
+ _fileStream->readUint32BE(); // 4 bytes of 00
+ _palette = new byte[256 * 3]();
+ for (int i = 0; i < 256 * 3; i++){
+ _palette[i] = _fileStream->readByte();
+ }
+ }
+ _dirtyPalette = true;
+}
+
+
enum {
COPY = 0, // raw copy pixels
RLE, // RLE
diff --git a/video/paco_decoder.h b/video/paco_decoder.h
index 102cb2d7745..f594458e458 100644
--- a/video/paco_decoder.h
+++ b/video/paco_decoder.h
@@ -74,8 +74,9 @@ protected:
int getFrameCount() const { return _frameCount; }
virtual const Graphics::Surface *decodeNextFrame();
virtual void handleFrame(uint32 chunkSize);
- const byte *getPalette() const { return _palette; }
- bool hasDirtyPalette() const { return false; }
+ void handlePalette();
+ const byte *getPalette() const override;
+ bool hasDirtyPalette() const { return _dirtyPalette; }
const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
void clearDirtyRects() { _dirtyRects.clear(); }
Commit: f89084dd396b4322472efe9c99e7564225b6fe7d
https://github.com/scummvm/scummvm/commit/f89084dd396b4322472efe9c99e7564225b6fe7d
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-01T17:09:01+01:00
Commit Message:
VIDEO: PACo decoder up debug level
PACo decoder for frames work aside from some artifacts.
Always outputting debug info is no longer needed.
Changed paths:
video/paco_decoder.cpp
diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index 2083c7f3027..457cf2f7c5d 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -164,14 +164,14 @@ enum frameTypes {
const Graphics::Surface *PacoDecoder::PacoVideoTrack::decodeNextFrame() {
uint32 nextFrame = _fileStream->pos() + _frameSizes[_curFrame];
- debug(" frame %3d size %d @ %lX", _curFrame, _frameSizes[_curFrame], _fileStream->pos());
+ debug(2, " frame %3d size %d @ %lX", _curFrame, _frameSizes[_curFrame], _fileStream->pos());
while (_fileStream->pos() < nextFrame) {
int64 currentPos = _fileStream->pos();
int frameType = _fileStream->readByte();
int v = _fileStream->readByte();
uint32 chunkSize = (v << 16 ) | _fileStream->readUint16BE();
- debug(" slot type %d size %d @ %lX", frameType, chunkSize, _fileStream->pos() - 4);
+ debug(2, " slot type %d size %d @ %lX", frameType, chunkSize, _fileStream->pos() - 4);
switch (frameType) {
case AUDIO:
@@ -211,7 +211,6 @@ void PacoDecoder::PacoVideoTrack::handlePalette() {
_dirtyPalette = true;
}
-
enum {
COPY = 0, // raw copy pixels
RLE, // RLE
@@ -257,13 +256,13 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
uint compr = _fileStream->readByte(); // compression method and flags
_fileStream->readByte(); // padding
- debug(" +%d,%d - %dx%d compr %X", x, y, bw, bh, compr);
+ debug(5, " +%d,%d - %dx%d compr %X", x, y, bw, bh, compr);
compr = compr & 0xF;
uint8 *fdata = new uint8[1048576]; // 0x100000 copied from original pacodec
_fileStream->read(fdata, chunkSize - 10); // remove header length
- debug("pos: %ld", _fileStream->pos());
+ debug(5, "pos: %ld", _fileStream->pos());
int16 xpos = x, ypos = y, ypos2 = y;
byte *dst = (byte *)_surface->getPixels() + x + y * w;
@@ -274,13 +273,13 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
while (ypos < y + bh) {
c = *src++;
- debug("debug info: ypos %d y %d bh %d src: %d", ypos, y, bh, c);
+ debug(5, "debug info: ypos %d y %d bh %d src: %d", ypos, y, bh, c);
if (c == 0 ){ // long operation
int16 op = src[0] >> 4;
int16 len = ((src[0] & 0xF) << 8) | src[1];
src += 2;
- debug(" long operation: opcode: %d", op);
+ debug(5, " long operation: opcode: %d", op);
switch (op) {
case COPY:
while (len--)
@@ -327,15 +326,15 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
break;
default:
PUTPIX(0xFF);
- debug("PacoDecoder::PacoVideoTrack::handleFrame: Long op: 0x0 op %d", op);
+ debug(5, "PacoDecoder::PacoVideoTrack::handleFrame: Long op: 0x0 op %d", op);
}
} else if (c < 128) { // copy the same amount of pixels
- debug(" copy pixels: %d", c);
+ debug(5, " copy pixels: %d", c);
while (c--)
PUTPIX(*src++);
} else if (c < 254) { // repeat the following value 256 - op times
- debug(" copy pixels -op: %d", 256 - c);
+ debug(5, " copy pixels -op: %d", 256 - c);
c1 = *src++;
c = 256 - c;
while (c--)
@@ -348,7 +347,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
if (!c) { // compact RLE mode
unsigned mask = (src[0] << 8) | src[1];
src += 2;
- debug("debug info compact RLE: c: %d mask: %d", c, mask);
+ debug(5, "debug info compact RLE: c: %d mask: %d", c, mask);
for (i = 0; i < 16; i++, mask >>= 1) {
if (mask & 1)
@@ -361,10 +360,10 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
if (op == 0) { // low nibble....
op = len;
len = *src++;
- debug("debug info compact: op: %d", op);
+ debug(5, "debug info compact: op: %d", op);
switch (op) {
case COPY:
- debug("debug info COPY: %d", len);
+ debug(5, "debug info COPY: %d", len);
while (len--) {
c = *src++;
PUTPIX(clrs[c >> 4]);
@@ -375,13 +374,13 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
break;
case RLE:
- debug("debug info RLE: %d", len);
+ debug(5, "debug info RLE: %d", len);
c = *src++;
while (len--)
PUTPIX(clrs[c & 0xF]);
break;
case PRLE:
- debug("debug info PRLE: %d", len);
+ debug(5, "debug info PRLE: %d", len);
c = *src++;
c1 = clrs[c >> 4];
c2 = clrs[c & 0xF];
@@ -391,7 +390,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
break;
case QRLE:
- debug("debug info QRLE: %d", len);
+ debug(5, "debug info QRLE: %d", len);
c = *src++;
c1 = clrs[c >> 4];
c2 = clrs[c & 0xF];
@@ -406,19 +405,19 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
break;
case SKIP:
- debug("debug info SKIP: %d", len);
+ debug(5, "debug info SKIP: %d", len);
while (len--)
SKIP();
break;
case ENDCURRENTLINE:
- debug("debug info ENDCURRENTLINE: %d", len);
+ debug(5, "debug info ENDCURRENTLINE: %d", len);
xpos = x + bw;
break;
default:
warning("PacoDecoder::PacoVideoTrack::handleFrame: Compact RLE mode: 0x0 op %d", op);
}
} else if (op < 8) { // copy 1-7 colors
- debug("debug info copy 1-7 colors: %d", len);
+ debug(5, "debug info copy 1-7 colors: %d", len);
PUTPIX(clrs[len]);
op--;
while (op--) {
@@ -430,17 +429,17 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
PUTPIX(clrs[c & 0xF]);
}
} else if (op < 14) { // repeat color
- debug("debug info Repeat color: %d", len);
+ debug(5, "debug info Repeat color: %d", len);
op = 16 - op;
while (op--)
PUTPIX(clrs[len]);
} else if (op < 15) { // skip number of pixels in low nibbel
- debug("debug info Skip number of pixels: %d", len);
+ debug(5, "debug info Skip number of pixels: %d", len);
while (len--)
SKIP();
} else {
if (len < 8) { // Pair run
- debug("debug info pair run: %d", len);
+ debug(5, "debug info pair run: %d", len);
c = *src++;
c1 = clrs[c >> 4];
c2 = clrs[c & 0xF];
@@ -449,7 +448,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
PUTPIX(c2);
}
} else { // Quad run
- debug("debug info quad run: %d", len);
+ debug(5, "debug info quad run: %d", len);
len = 16 - len;
c = *src++;
c1 = clrs[c >> 4];
@@ -467,7 +466,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
}
} else {
- debug("debug info SKIP: %d", c);
+ debug(5, "debug info SKIP: %d", c);
while (c--)
SKIP();
}
@@ -477,7 +476,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
// (but 256 - len times)
c = *src++;
if (c < 128) { // pair run
- debug("debug info PAIR RUN: %d", c);
+ debug(5, "debug info PAIR RUN: %d", c);
c1 = *src++;
c2 = *src++;
@@ -486,7 +485,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
PUTPIX(c2);
}
} else { // quad run
- debug("debug info QUAD RUN: %d", c);
+ debug(5, "debug info QUAD RUN: %d", c);
c = 256 - c;
c1 = *src++;
c2 = *src++;
@@ -500,9 +499,9 @@ void PacoDecoder::PacoVideoTrack::handleFrame(uint32 chunkSize) {
}
}
}
- if (xpos > x + bw) debug("!!!");
+ if (xpos > x + bw) debug(5, "!!!");
if (xpos >= x + bw) {
- debug("debug info ADJUST LINE");
+ debug(5, "debug info ADJUST LINE");
xpos = x;
ypos++;
ADJUST_LINE;
Commit: a5af85d6fb20a8764f796d9c624025cf652f7560
https://github.com/scummvm/scummvm/commit/a5af85d6fb20a8764f796d9c624025cf652f7560
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-03-01T17:09:01+01:00
Commit Message:
DIRECTOR: LINGO: Implement palette changes in PACo
PACo palette changes are now handled.
After playing the PACo file, switch back to the palette used in the
movie.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index e4179a3f27e..d4a9cca2240 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2707,6 +2707,10 @@ void LB::b_xPlayAnim(int nargs){
Video::PacoDecoder *video = new Video::PacoDecoder();
video->loadFile(Common::Path(filename, g_director->_dirSeparator));
+ // save the current palette
+ byte *origPalette = const_cast<byte *>(g_director->getPalette());
+ uint16 origCount = g_director->getPaletteColorCount();
+
Common::Event event;
video->start();
while (!video->endOfVideo()) {
@@ -2716,21 +2720,23 @@ void LB::b_xPlayAnim(int nargs){
if (event.type == Common::EVENT_QUIT)
break;
- if (!video->needsUpdate())
- continue;
+ if (video->needsUpdate()) {
+ Graphics::Surface const *frame = video->decodeNextFrame();
+ g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
+ }
+ if (video->hasDirtyPalette()) {
+ byte *palette = const_cast<byte *>(video->getPalette());
+ g_director->setPalette(palette, 256);
+ }
- Graphics::Surface const *frame = video->decodeNextFrame();
- g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
g_system->updateScreen();
-
- byte * palette = const_cast<byte *>(video->getPalette());
- g_director->setPalette(palette, 256);
-
g_system->delayMillis(10);
}
video->close();
delete video;
+ // restore the palette
+ g_director->setPalette(origPalette, origCount);
}
void LB::b_getVolumes(int nargs) {
More information about the Scummvm-git-logs
mailing list