X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions engines/chewy/video/cfo_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,19 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() {
void CfoDecoder::CfoVideoTrack::fadeOut() {
for (int j = 0; j < 64; j++) {
for (int i = 0; i < 256; i++) {
if (_palette[i * 3 + 0] > 0)
--_palette[i * 3 + 0];
if (_palette[i * 3 + 1] > 0)
--_palette[i * 3 + 1];
if (_palette[i * 3 + 2] > 0)
--_palette[i * 3 + 2];
byte r, g, b;
_palette.get(i, r, g, b);
if (r > 0)
--r;
if (g > 0)
--g;
if (b > 0)
--b;
_palette.set(i, r, g, b);
}

//setScummVMPalette(_palette, 0, 256);
g_system->getPaletteManager()->setPalette(_palette, 0, 256);
g_system->getPaletteManager()->setPalette(_palette, 0);
g_system->updateScreen();
g_system->delayMillis(10);
}
Expand Down
48 changes: 33 additions & 15 deletions video/coktel_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ CoktelDecoder::State::State() : flags(0), speechId(0) {

CoktelDecoder::CoktelDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) :
_mixer(mixer), _soundType(soundType), _width(0), _height(0), _x(0), _y(0),
_defaultX(0), _defaultY(0), _features(0), _frameCount(0), _paletteDirty(false),
_defaultX(0), _defaultY(0), _features(0), _frameCount(0), _palette(256), _paletteDirty(false),
_isDouble(false), _ownSurface(true), _frameRate(12), _hasSound(false),
_soundEnabled(false), _soundStage(kSoundNone), _audioStream(0), _startTime(0),
_pauseStartTime(0), _isPaused(false) {

assert(_mixer);

memset(_palette, 0, 768);
}

CoktelDecoder::~CoktelDecoder() {
Expand Down Expand Up @@ -316,7 +314,7 @@ uint32 CoktelDecoder::getFrameCount() const {

const byte *CoktelDecoder::getPalette() {
_paletteDirty = false;
return _palette;
return _palette.data();
}

bool CoktelDecoder::hasDirtyPalette() const {
Expand Down Expand Up @@ -1122,8 +1120,12 @@ bool IMDDecoder::loadStream(Common::SeekableReadStream *stream) {
_features |= kFeaturesPalette;

// Palette
for (int i = 0; i < 768; i++)
_palette[i] = _stream->readByte() << 2;
for (int i = 0; i < 256; i++) {
byte r = _stream->readByte() << 2;
byte g = _stream->readByte() << 2;
byte b = _stream->readByte() << 2;
_palette.set(i, r, g, b);
}

_paletteDirty = true;

Expand Down Expand Up @@ -1403,8 +1405,12 @@ void IMDDecoder::processFrame() {

_paletteDirty = true;

for (int i = 0; i < 768; i++)
_palette[i] = _stream->readByte() << 2;
for (int i = 0; i < 256; i++) {
byte r = _stream->readByte() << 2;
byte g = _stream->readByte() << 2;
byte b = _stream->readByte() << 2;
_palette.set(i, r, g, b);
}

cmd = _stream->readUint16LE();
}
Expand Down Expand Up @@ -1519,9 +1525,13 @@ bool IMDDecoder::renderFrame(Common::Rect &rect) {
// One byte index
int index = *dataPtr++;

int count = MIN((255 - index) * 3, 48);
for (int i = 0; i < count; i++)
_palette[index * 3 + i] = dataPtr[i] << 2;
int count = MIN((255 - index), 16);
for (int i = 0; i < count; i++) {
byte r = dataPtr[i * 3] << 2;
byte g = dataPtr[i * 3 + 1] << 2;
byte b = dataPtr[i * 3 + 2] << 2;
_palette.set(index + i, r, g, b);
}

dataPtr += 48;
dataSize -= 49;
Expand Down Expand Up @@ -1964,8 +1974,12 @@ bool VMDDecoder::loadStream(Common::SeekableReadStream *stream) {
_videoCodec = _stream->readUint32BE();

if (_features & kFeaturesPalette) {
for (int i = 0; i < 768; i++)
_palette[i] = _stream->readByte() << 2;
for (int i = 0; i < 256; i++) {
byte r = _stream->readByte() << 2;
byte g = _stream->readByte() << 2;
byte b = _stream->readByte() << 2;
_palette.set(i, r, g, b);
}

_paletteDirty = true;
}
Expand Down Expand Up @@ -2389,8 +2403,12 @@ void VMDDecoder::processFrame() {
uint8 index = _stream->readByte();
uint8 count = _stream->readByte();

for (int j = 0; j < ((count + 1) * 3); j++)
_palette[index * 3 + j] = _stream->readByte() << 2;
for (int j = 0; j < (count + 1); j++) {
byte r = _stream->readByte() << 2;
byte g = _stream->readByte() << 2;
byte b = _stream->readByte() << 2;
_palette.set(index + j, r, g, b);
}

_stream->skip((255 - count) * 3);

Expand Down
3 changes: 2 additions & 1 deletion video/coktel_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "common/rational.h"
#include "common/str.h"

#include "graphics/palette.h"
#include "graphics/surface.h"

#include "video/video_decoder.h"
Expand Down Expand Up @@ -236,7 +237,7 @@ class CoktelDecoder {

uint32 _startTime;

byte _palette[768];
Graphics::Palette _palette;
bool _paletteDirty;

bool _isDouble;
Expand Down
11 changes: 8 additions & 3 deletions video/dxa_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ void DXADecoder::readSoundData(Common::SeekableReadStream *stream) {
}
}

DXADecoder::DXAVideoTrack::DXAVideoTrack(Common::SeekableReadStream *stream) {
DXADecoder::DXAVideoTrack::DXAVideoTrack(Common::SeekableReadStream *stream) : _palette(256) {
_fileStream = stream;
_curFrame = -1;
_frameStartOffset = 0;
_decompBuffer = 0;
_inBuffer = 0;
memset(_palette, 0, 256 * 3);

uint8 flags = _fileStream->readByte();
_frameCount = _fileStream->readUint16BE();
Expand Down Expand Up @@ -465,7 +464,13 @@ void DXADecoder::DXAVideoTrack::decode13(int size) {
const Graphics::Surface *DXADecoder::DXAVideoTrack::decodeNextFrame() {
uint32 tag = _fileStream->readUint32BE();
if (tag == MKTAG('C','M','A','P')) {
_fileStream->read(_palette, 256 * 3);
for (int i = 0; i < 256; i++) {
byte r = _fileStream->readByte();
byte g = _fileStream->readByte();
byte b = _fileStream->readByte();
_palette.set(i, r, g, b);
}

_dirtyPalette = true;
}

Expand Down
5 changes: 3 additions & 2 deletions video/dxa_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define VIDEO_DXA_DECODER_H

#include "common/rational.h"
#include "graphics/palette.h"
#include "graphics/pixelformat.h"
#include "video/video_decoder.h"

Expand Down Expand Up @@ -68,7 +69,7 @@ class DXADecoder : public VideoDecoder {
int getCurFrame() const { return _curFrame; }
int getFrameCount() const { return _frameCount; }
const Graphics::Surface *decodeNextFrame();
const byte *getPalette() const { _dirtyPalette = false; return _palette; }
const byte *getPalette() const { _dirtyPalette = false; return _palette.data(); }
bool hasDirtyPalette() const { return _dirtyPalette; }

void setFrameStartPos();
Expand Down Expand Up @@ -103,7 +104,7 @@ class DXADecoder : public VideoDecoder {
uint16 _width, _height;
uint32 _frameRate;
uint32 _frameCount;
byte _palette[256 * 3];
Graphics::Palette _palette;
mutable bool _dirtyPalette;
int _curFrame;
uint32 _frameStartOffset;
Expand Down
14 changes: 9 additions & 5 deletions video/flic_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ void FlicDecoder::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
((FlicVideoTrack *)track)->copyDirtyRectsToBuffer(dst, pitch);
}

FlicDecoder::FlicVideoTrack::FlicVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader) {
FlicDecoder::FlicVideoTrack::FlicVideoTrack(Common::SeekableReadStream *stream, uint16 frameCount, uint16 width, uint16 height, bool skipHeader) : _palette(256) {
_fileStream = stream;
_frameCount = frameCount;

_surface = new Graphics::Surface();
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_palette = new byte[3 * 256]();
_dirtyPalette = false;

_curFrame = -1;
Expand All @@ -103,7 +102,6 @@ FlicDecoder::FlicVideoTrack::FlicVideoTrack(Common::SeekableReadStream *stream,

FlicDecoder::FlicVideoTrack::~FlicVideoTrack() {
delete _fileStream;
delete[] _palette;

_surface->free();
delete _surface;
Expand Down Expand Up @@ -363,7 +361,10 @@ void FlicDecoder::FlicVideoTrack::unpackPalette(uint8 *data) {
if (0 == READ_LE_UINT16(data)) { //special case
data += 2;
for (int i = 0; i < 256; ++i) {
memcpy(_palette + i * 3, data + i * 3, 3);
byte r = data[i * 3];
byte g = data[i * 3 + 1];
byte b = data[i * 3 + 2];
_palette.set(i, r, g, b);
}
} else {
uint8 palPos = 0;
Expand All @@ -373,7 +374,10 @@ void FlicDecoder::FlicVideoTrack::unpackPalette(uint8 *data) {
uint8 change = *data++;

for (int i = 0; i < change; ++i) {
memcpy(_palette + (palPos + i) * 3, data + i * 3, 3);
byte r = data[i * 3];
byte g = data[i * 3 + 1];
byte b = data[i * 3 + 2];
_palette.set(palPos + i, r, g, b);
}

palPos += change;
Expand Down
5 changes: 3 additions & 2 deletions video/flic_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "video/video_decoder.h"
#include "common/list.h"
#include "common/rect.h"
#include "graphics/palette.h"

namespace Common {
class SeekableReadStream;
Expand Down Expand Up @@ -77,7 +78,7 @@ class FlicDecoder : public VideoDecoder {
uint32 getNextFrameStartTime() const { return _nextFrameStartTime; }
virtual const Graphics::Surface *decodeNextFrame();
virtual void handleFrame();
const byte *getPalette() const { _dirtyPalette = false; return _palette; }
const byte *getPalette() const { _dirtyPalette = false; return _palette.data(); }
bool hasDirtyPalette() const { return _dirtyPalette; }

const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
Expand All @@ -93,7 +94,7 @@ class FlicDecoder : public VideoDecoder {

uint32 _offsetFrame1;
uint32 _offsetFrame2;
byte *_palette;
Graphics::Palette _palette;
mutable bool _dirtyPalette;

uint32 _frameCount;
Expand Down
11 changes: 4 additions & 7 deletions video/mve_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ MveDecoder::MveDecoder()
: _done(false),
_s(nullptr),
_dirtyPalette(false),
_palette(256),
_skipMapSize(0),
_skipMap(nullptr),
_decodingMapSize(0),
Expand All @@ -50,8 +51,6 @@ MveDecoder::MveDecoder()
_audioTrack(0),
_audioStream(nullptr)
{
for (int i = 0; i < 0x300; ++i)
_palette[i] = 0;
}

MveDecoder::~MveDecoder() {
Expand Down Expand Up @@ -97,7 +96,7 @@ void MveDecoder::setAudioTrack(int track) {
}

void MveDecoder::applyPalette(PaletteManager *paletteManager) {
paletteManager->setPalette(_palette + 3 * _palStart, _palStart, _palCount);
paletteManager->setPalette(_palette.data() + 3 * _palStart, _palStart, _palCount);
}

void MveDecoder::copyBlock_8bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block) {
Expand Down Expand Up @@ -443,9 +442,7 @@ void MveDecoder::readNextPacket() {
byte g = _s->readByte();
byte b = _s->readByte();

_palette[3*i+0] = (r << 2) | (r >> 4);
_palette[3*i+1] = (g << 2) | (g >> 4);
_palette[3*i+2] = (b << 2) | (b >> 4);
_palette.set(i, (r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4));
}
if (palCount & 1) {
_s->skip(1);
Expand Down Expand Up @@ -523,7 +520,7 @@ const Graphics::Surface *MveDecoder::MveVideoTrack::decodeNextFrame() {
}

const byte *MveDecoder::MveVideoTrack::getPalette() const {
return _decoder->_palette;
return _decoder->_palette.data();
}

bool MveDecoder::MveVideoTrack::hasDirtyPalette() const {
Expand Down
3 changes: 2 additions & 1 deletion video/mve_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "audio/audiostream.h"
#include "video/video_decoder.h"
#include "graphics/palette.h"
#include "graphics/surface.h"
#include "common/list.h"
#include "common/rect.h"
Expand Down Expand Up @@ -72,7 +73,7 @@ class MveDecoder : public VideoDecoder {
bool _dirtyPalette;
uint16 _palStart;
uint16 _palCount;
byte _palette[0x300];
Graphics::Palette _palette;

uint16 _skipMapSize;
byte *_skipMap;
Expand Down
16 changes: 9 additions & 7 deletions video/paco_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,18 @@ const byte* PacoDecoder::getPalette(){

const byte* PacoDecoder::PacoVideoTrack::getPalette() const {
_dirtyPalette = false;
return _palette;
return _palette.data();
}

PacoDecoder::PacoVideoTrack::PacoVideoTrack(
uint16 frameRate, uint16 frameCount, uint16 width, uint16 height) {
uint16 frameRate, uint16 frameCount, uint16 width, uint16 height) : _palette(256) {
_curFrame = 0;
_frameRate = frameRate;
_frameCount = frameCount;

_surface = new Graphics::Surface();
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
_palette = const_cast<byte *>(quickTimeDefaultPalette256);
_palette.set(quickTimeDefaultPalette256, 0, 256);
_dirtyPalette = true;
}

Expand Down Expand Up @@ -260,12 +260,14 @@ const Graphics::Surface *PacoDecoder::PacoVideoTrack::decodeNextFrame() {
void PacoDecoder::PacoVideoTrack::handlePalette(Common::SeekableReadStream *fileStream) {
uint32 header = fileStream->readUint32BE();
if (header == 0x30000000) { // default quicktime palette
_palette = const_cast<byte *>(quickTimeDefaultPalette256);
_palette.set(quickTimeDefaultPalette256, 0, 256);
} else {
fileStream->readUint32BE(); // 4 bytes of 00
_palette = new byte[256 * 3]();
for (int i = 0; i < 256 * 3; i++){
_palette[i] = fileStream->readByte();
for (int i = 0; i < 256; i++){
byte r = fileStream->readByte();
byte g = fileStream->readByte();
byte b = fileStream->readByte();
_palette.set(i, r, g, b);
}
}
_dirtyPalette = true;
Expand Down
4 changes: 2 additions & 2 deletions video/paco_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "audio/audiostream.h"
#include "common/list.h"
#include "common/rect.h"
#include "graphics/palette.h"
#include "video/video_decoder.h"

namespace Common {
Expand Down Expand Up @@ -88,8 +89,7 @@ class PacoDecoder : public VideoDecoder {

protected:
Graphics::Surface *_surface;

byte *_palette;
Graphics::Palette _palette;

mutable bool _dirtyPalette;

Expand Down
Loading
X Tutup