VIDEO: Make VideoDecoder::decodeNextFrame() return a const Surface pointer

svn-id: r54927
This commit is contained in:
Matthew Hoops 2010-12-16 01:35:13 +00:00
parent a2bb676c19
commit 375f32fbe9
28 changed files with 47 additions and 47 deletions

View File

@ -267,7 +267,7 @@ void MoviePlayerDXA::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
uint h = getHeight();
uint w = getWidth();
Graphics::Surface *surface = decodeNextFrame();
const Graphics::Surface *surface = decodeNextFrame();
byte *src = (byte *)surface->pixels;
dst += y * pitch + x;
@ -428,7 +428,7 @@ void MoviePlayerSMK::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
uint h = getHeight();
uint w = getWidth();
Graphics::Surface *surface = decodeNextFrame();
const Graphics::Surface *surface = decodeNextFrame();
byte *src = (byte *)surface->pixels;
dst += y * pitch + x;

View File

@ -325,7 +325,7 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
_vm->_draw->forceBlit();
}
Graphics::Surface *surface = video->decoder->decodeNextFrame();
const Graphics::Surface *surface = video->decoder->decodeNextFrame();
WRITE_VAR(11, video->decoder->getCurFrame());

View File

@ -178,18 +178,19 @@ bool VideoManager::updateBackgroundMovies() {
// Check if we need to draw a frame
if (_videoStreams[i]->needsUpdate()) {
Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
bool deleteFrame = false;
const Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
Graphics::Surface *convertedFrame = 0;
if (frame && _videoStreams[i].enabled) {
// Convert from 8bpp to the current screen format if necessary
Graphics::PixelFormat pixelFormat = _vm->_system->getScreenFormat();
if (frame->bytesPerPixel == 1 && pixelFormat.bytesPerPixel != 1) {
Graphics::Surface *newFrame = new Graphics::Surface();
convertedFrame = new Graphics::Surface();
byte *palette = _videoStreams[i]->getPalette();
assert(palette);
newFrame->create(frame->w, frame->h, pixelFormat.bytesPerPixel);
convertedFrame->create(frame->w, frame->h, pixelFormat.bytesPerPixel);
for (uint16 j = 0; j < frame->h; j++) {
for (uint16 k = 0; k < frame->w; k++) {
@ -198,14 +199,13 @@ bool VideoManager::updateBackgroundMovies() {
byte g = palette[palIndex * 3 + 1];
byte b = palette[palIndex * 3 + 2];
if (pixelFormat.bytesPerPixel == 2)
*((uint16 *)newFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b);
*((uint16 *)convertedFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b);
else
*((uint32 *)newFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b);
*((uint32 *)convertedFrame->getBasePtr(k, j)) = pixelFormat.RGBToColor(r, g, b);
}
}
frame = newFrame;
deleteFrame = true;
frame = convertedFrame;
}
// Clip the width/height to make sure we stay on the screen (Myst does this a few times)
@ -216,10 +216,10 @@ bool VideoManager::updateBackgroundMovies() {
// We've drawn something to the screen, make sure we update it
updateScreen = true;
// Delete the frame if we're using the buffer from the 8bpp conversion
if (deleteFrame) {
frame->free();
delete frame;
// Delete 8bpp conversion surface
if (convertedFrame) {
convertedFrame->free();
delete convertedFrame;
}
}
}

View File

@ -103,7 +103,7 @@ void Scene::playMovie(const char *filename) {
while (!_vm->shouldQuit() && !smkDecoder->endOfVideo() && !skipVideo) {
if (smkDecoder->needsUpdate()) {
Graphics::Surface *frame = smkDecoder->decodeNextFrame();
const Graphics::Surface *frame = smkDecoder->decodeNextFrame();
if (frame) {
_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);

View File

@ -67,7 +67,7 @@ void playVideo(Graphics::VideoDecoder *videoDecoder) {
while (!g_engine->shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
if (videoDecoder->needsUpdate()) {
Graphics::Surface *frame = videoDecoder->decodeNextFrame();
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
if (frame) {
if (scaleBuffer) {
// TODO: Probably should do aspect ratio correction in e.g. GK1 Windows

View File

@ -108,7 +108,7 @@ void SeqDecoder::close() {
reset();
}
Graphics::Surface *SeqDecoder::decodeNextFrame() {
const Graphics::Surface *SeqDecoder::decodeNextFrame() {
int16 frameWidth = _fileStream->readUint16LE();
int16 frameHeight = _fileStream->readUint16LE();
int16 frameLeft = _fileStream->readUint16LE();

View File

@ -47,7 +47,7 @@ public:
uint16 getWidth() const { return SEQ_SCREEN_WIDTH; }
uint16 getHeight() const { return SEQ_SCREEN_HEIGHT; }
uint32 getFrameCount() const { return _frameCount; }
Graphics::Surface *decodeNextFrame();
const Graphics::Surface *decodeNextFrame();
Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); }
byte *getPalette() { _dirtyPalette = false; return _palette; }
bool hasDirtyPalette() const { return _dirtyPalette; }

View File

@ -68,7 +68,7 @@ void MoviePlayer::copyFrameToBuffer(byte *dst, int dstType, uint x, uint y, uint
uint h = getHeight();
uint w = getWidth();
Graphics::Surface *surface = decodeNextFrame();
const Graphics::Surface *surface = decodeNextFrame();
byte *src = (byte *)surface->pixels;
if (hasDirtyPalette())

View File

@ -252,7 +252,7 @@ bool MoviePlayer::playVideo() {
while (!_vm->shouldQuit() && !_decoder->endOfVideo()) {
if (_decoder->needsUpdate()) {
Graphics::Surface *frame = _decoder->decodeNextFrame();
const Graphics::Surface *frame = _decoder->decodeNextFrame();
if (frame)
_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);

View File

@ -279,7 +279,7 @@ bool MoviePlayer::playVideo() {
while (!_vm->shouldQuit() && !_decoder->endOfVideo()) {
if (_decoder->needsUpdate()) {
Graphics::Surface *frame = _decoder->decodeNextFrame();
const Graphics::Surface *frame = _decoder->decodeNextFrame();
if (frame)
_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);

View File

@ -124,7 +124,7 @@ bool MoviePlayer::pause() {
void MoviePlayer::update() {
if (_decoder.isVideoLoaded()) {
Graphics::Surface *s = _decoder.decodeNextFrame();
const Graphics::Surface *s = _decoder.decodeNextFrame();
if (s) {
// Transfer the next frame
assert(s->bytesPerPixel == 4);

View File

@ -329,7 +329,7 @@ void TheoraDecoder::close() {
reset();
}
Graphics::Surface *TheoraDecoder::decodeNextFrame() {
const Graphics::Surface *TheoraDecoder::decodeNextFrame() {
int i, j;
// _stateFlag = false; // playback has not begun

View File

@ -67,7 +67,7 @@ public:
* @note the return surface should *not* be freed
* @note this may return 0, in which case the last frame should be kept on screen
*/
Graphics::Surface *decodeNextFrame();
const Graphics::Surface *decodeNextFrame();
bool isVideoLoaded() const {
return _fileStream != 0;

View File

@ -97,7 +97,7 @@ bool Movie::playVideo() {
int32 y = 0;
while (!_vm->shouldQuit() && !_decoder->endOfVideo()) {
if (_decoder->needsUpdate()) {
Graphics::Surface *frame = _decoder->decodeNextFrame();
const Graphics::Surface *frame = _decoder->decodeNextFrame();
if (frame)
_vm->getSystem()->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
_decoder->setSystemPalette();

View File

@ -765,7 +765,7 @@ void AnimationSequencePlayer::openAnimation(int index, const char *fileName) {
}
bool AnimationSequencePlayer::decodeNextAnimationFrame(int index, bool copyDirtyRects) {
::Graphics::Surface *surface = _flicPlayer[index].decodeNextFrame();
const ::Graphics::Surface *surface = _flicPlayer[index].decodeNextFrame();
if (!copyDirtyRects) {
for (uint16 y = 0; (y < surface->h) && (y < kScreenHeight); y++)
@ -804,7 +804,7 @@ void AnimationSequencePlayer::playIntroSeq19_20() {
// The intro credits animation. This uses 2 animations: the foreground one, which
// is the actual intro credits, and the background one, which is an animation of
// cogs, and is being replayed when an intro credit appears
::Graphics::Surface *surface = 0;
const ::Graphics::Surface *surface = 0;
if (_flicPlayer[0].getCurFrame() >= 115) {
surface = _flicPlayer[1].decodeNextFrame();

View File

@ -316,7 +316,7 @@ uint32 AviDecoder::getElapsedTime() const {
return VideoDecoder::getElapsedTime();
}
Surface *AviDecoder::decodeNextFrame() {
const Surface *AviDecoder::decodeNextFrame() {
uint32 nextTag = _fileStream->readUint32BE();
if (_fileStream->eos())
@ -334,9 +334,9 @@ Surface *AviDecoder::decodeNextFrame() {
error ("Expected 'rec ' LIST");
// Decode chunks in the list and see if we get a frame
Surface *frame = NULL;
const Surface *frame = NULL;
while (_fileStream->pos() < startPos + (int32)listSize) {
Surface *temp = decodeNextFrame();
const Surface *temp = decodeNextFrame();
if (temp)
frame = temp;
}

View File

@ -176,7 +176,7 @@ public:
uint16 getHeight() const { return _header.height; }
uint32 getFrameCount() const { return _header.totalFrames; }
uint32 getElapsedTime() const;
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const;
byte *getPalette() { _dirtyPalette = false; return _palette; }
bool hasDirtyPalette() const { return _dirtyPalette; }

View File

@ -669,7 +669,7 @@ bool PreIMDDecoder::isVideoLoaded() const {
return _stream != 0;
}
Surface *PreIMDDecoder::decodeNextFrame() {
const Surface *PreIMDDecoder::decodeNextFrame() {
if (!isVideoLoaded() || endOfVideo())
return 0;
@ -1128,7 +1128,7 @@ bool IMDDecoder::isVideoLoaded() const {
return _stream != 0;
}
Surface *IMDDecoder::decodeNextFrame() {
const Surface *IMDDecoder::decodeNextFrame() {
if (!isVideoLoaded() || endOfVideo())
return 0;
@ -1925,7 +1925,7 @@ bool VMDDecoder::isVideoLoaded() const {
return _stream != 0;
}
Surface *VMDDecoder::decodeNextFrame() {
const Surface *VMDDecoder::decodeNextFrame() {
if (!isVideoLoaded() || endOfVideo())
return 0;

View File

@ -227,7 +227,7 @@ public:
bool isVideoLoaded() const;
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const;
@ -260,7 +260,7 @@ public:
bool isVideoLoaded() const;
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const;
@ -364,7 +364,7 @@ public:
bool isVideoLoaded() const;
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const;

View File

@ -477,7 +477,7 @@ void DXADecoder::decode13(int size) {
#endif
}
Surface *DXADecoder::decodeNextFrame() {
const Surface *DXADecoder::decodeNextFrame() {
uint32 tag = _fileStream->readUint32BE();
if (tag == MKID_BE('CMAP')) {
_fileStream->read(_palette, 256 * 3);

View File

@ -50,7 +50,7 @@ public:
uint16 getWidth() const { return _width; }
uint16 getHeight() const { return _height; }
uint32 getFrameCount() const { return _frameCount; }
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const { return PixelFormat::createFormatCLUT8(); }
byte *getPalette() { _dirtyPalette = false; return _palette; }
bool hasDirtyPalette() const { return _dirtyPalette; }

View File

@ -194,7 +194,7 @@ void FlicDecoder::decodeDeltaFLC(uint8 *data) {
#define PSTAMP 18
#define FRAME_TYPE 0xF1FA
Surface *FlicDecoder::decodeNextFrame() {
const Surface *FlicDecoder::decodeNextFrame() {
// Read chunk
uint32 frameSize = _fileStream->readUint32LE();
uint16 frameType = _fileStream->readUint16LE();

View File

@ -59,7 +59,7 @@ public:
* @note the return surface should *not* be freed
* @note this may return 0, in which case the last frame should be kept on screen
*/
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
bool isVideoLoaded() const { return _fileStream != 0; }
uint16 getWidth() const { return _surface->w; }

View File

@ -216,7 +216,7 @@ Codec *QuickTimeDecoder::findDefaultVideoCodec() const {
return _streams[_videoStreamIndex]->stsdEntries[0].videoCodec;
}
Surface *QuickTimeDecoder::decodeNextFrame() {
const Surface *QuickTimeDecoder::decodeNextFrame() {
if (_videoStreamIndex < 0 || _curFrame >= (int32)getFrameCount() - 1)
return 0;

View File

@ -107,7 +107,7 @@ public:
void setChunkBeginOffset(uint32 offset) { _beginOffset = offset; }
bool isVideoLoaded() const { return _fd != 0; }
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
bool endOfVideo() const;
uint32 getElapsedTime() const;
uint32 getTimeToNextFrame() const;

View File

@ -519,7 +519,7 @@ void SmackerDecoder::close() {
reset();
}
Surface *SmackerDecoder::decodeNextFrame() {
const Surface *SmackerDecoder::decodeNextFrame() {
uint i;
uint32 chunkSize = 0;
uint32 dataSizeUnpacked = 0;

View File

@ -65,7 +65,7 @@ public:
uint16 getHeight() const { return _surface->h; }
uint32 getFrameCount() const { return _frameCount; }
uint32 getElapsedTime() const;
Surface *decodeNextFrame();
const Surface *decodeNextFrame();
PixelFormat getPixelFormat() const { return PixelFormat::createFormatCLUT8(); }
byte *getPalette() { _dirtyPalette = false; return _palette; }
bool hasDirtyPalette() const { return _dirtyPalette; }

View File

@ -109,7 +109,7 @@ public:
* @note the return surface should *not* be freed
* @note this may return 0, in which case the last frame should be kept on screen
*/
virtual Surface *decodeNextFrame() = 0;
virtual const Surface *decodeNextFrame() = 0;
/**
* Get the pixel format of the video