[Scummvm-git-logs] scummvm master -> 45483b3a7b0624f91ecedf1c1a853667d56e464c

rvanlaar noreply at scummvm.org
Mon Feb 28 18:33:49 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:
6a3b192ead VIDEO: PACo decoder framerate and palette
45483b3a7b DIRECTOR: LINGO: Improve PACo: xPlayAnim


Commit: 6a3b192eada8ed549fa89ca1b6fd7aae524b599d
    https://github.com/scummvm/scummvm/commit/6a3b192eada8ed549fa89ca1b6fd7aae524b599d
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-02-28T19:33:37+01:00

Commit Message:
VIDEO: PACo decoder framerate and palette

Move the VideoTrack to FixedRateVideoTrack. It handles frame duration
internally and removes the need to use nextFrameStartTime accounting.

Add getPalette function.

Changed paths:
    video/paco_decoder.cpp
    video/paco_decoder.h


diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index 7fa1e14c727..feb9c015d9a 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -91,21 +91,27 @@ void PacoDecoder::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
 		((PacoVideoTrack *)track)->copyDirtyRectsToBuffer(dst, pitch);
 }
 
+const byte* PacoDecoder::getPalette(){
+	Track *track = getTrack(0);
+
+	if (track)
+		return ((PacoVideoTrack *)track)->getPalette();
+	return nullptr;
+}
+
 PacoDecoder::PacoVideoTrack::PacoVideoTrack(
 	Common::SeekableReadStream *stream, uint16 frameRate, uint16 frameCount, bool hasAudio, uint16 width, uint16 height) {
 
 	_fileStream = stream;
-	_frameDelay = 1000 / frameRate; // frameRate is in fps, ms per frame
+	_frameRate = frameRate;
 	_frameCount = frameCount;
 
 	_surface = new Graphics::Surface();
 	_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
-	_palette = new byte[3 * 256]();
-	memcpy(_palette, quickTimeDefaultPalette256, 256 * 3);
+	_palette = const_cast<byte *>(quickTimeDefaultPalette256);
 	_dirtyPalette = false;
 
 	_curFrame = 0;
-	_nextFrameStartTime = 0;
 
 	for (uint i = 0; i < _frameCount; i++) {
 		_frameSizes[i] = stream->readUint32BE();
@@ -114,8 +120,6 @@ PacoDecoder::PacoVideoTrack::PacoVideoTrack(
 
 PacoDecoder::PacoVideoTrack::~PacoVideoTrack() {
 	delete _fileStream;
-	delete[] _palette;
-
 	_surface->free();
 	delete _surface;
 }
@@ -184,7 +188,6 @@ const Graphics::Surface *PacoDecoder::PacoVideoTrack::decodeNextFrame() {
 	 }
 
 	_curFrame++;
-	_nextFrameStartTime += _frameDelay;
 
 	return _surface;
 }
diff --git a/video/paco_decoder.h b/video/paco_decoder.h
index e347168b25f..102cb2d7745 100644
--- a/video/paco_decoder.h
+++ b/video/paco_decoder.h
@@ -53,9 +53,11 @@ public:
 	const Common::List<Common::Rect> *getDirtyRects() const;
 	void clearDirtyRects();
 	void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
+	const byte *getPalette();
 
 protected:
-	class PacoVideoTrack : public VideoTrack {
+
+	class PacoVideoTrack : public FixedRateVideoTrack {
 	public:
 		PacoVideoTrack(
 			Common::SeekableReadStream *stream, uint16 frameRate, uint16 frameCount,
@@ -70,7 +72,6 @@ protected:
 		Graphics::PixelFormat getPixelFormat() const;
 		int getCurFrame() const { return _curFrame; }
 		int getFrameCount() const { return _frameCount; }
-		uint32 getNextFrameStartTime() const { return _nextFrameStartTime; }
 		virtual const Graphics::Surface *decodeNextFrame();
 		virtual void handleFrame(uint32 chunkSize);
 		const byte *getPalette() const { return _palette; }
@@ -79,6 +80,8 @@ protected:
 		const Common::List<Common::Rect> *getDirtyRects() const { return &_dirtyRects; }
 		void clearDirtyRects() { _dirtyRects.clear(); }
 		void copyDirtyRectsToBuffer(uint8 *dst, uint pitch);
+		Common::Rational getFrameRate() const { return Common::Rational(_frameRate, 1); }
+
 
 	protected:
 		Common::SeekableReadStream *_fileStream;
@@ -87,12 +90,13 @@ protected:
 		int _curFrame;
 
 		byte *_palette;
+
 		int _frameSizes[65536]; // can be done differently?
 		mutable bool _dirtyPalette;
 
 		uint32 _frameCount;
 		uint32 _frameDelay;
-		uint32 _nextFrameStartTime;
+		uint16 _frameRate;
 
 		Common::List<Common::Rect> _dirtyRects;
 	};


Commit: 45483b3a7b0624f91ecedf1c1a853667d56e464c
    https://github.com/scummvm/scummvm/commit/45483b3a7b0624f91ecedf1c1a853667d56e464c
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-02-28T19:33:38+01:00

Commit Message:
DIRECTOR: LINGO: Improve PACo: xPlayAnim

Multiple improvements:

- use needsUpdate to display with the right framerate
- use system surface to draw the frames on, makes
  g_system->updateScreen()
- switch to the palette used in the video
- break when quitting scummvm
- cleanup after the video

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 68ca9d830f1..e4179a3f27e 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -2707,15 +2707,30 @@ void LB::b_xPlayAnim(int nargs){
 	Video::PacoDecoder *video = new Video::PacoDecoder();
 	video->loadFile(Common::Path(filename, g_director->_dirSeparator));
 
+	Common::Event event;
+	video->start();
 	while (!video->endOfVideo()) {
 		warning("LB::b_xPlayAnim: loop");
-		Graphics::Surface const *frame = video->decodeNextFrame();
-		Graphics::ManagedSurface *surface = g_director->getCurrentWindow()->getSurface();
-		surface->copyRectToSurface(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
 
+		if (g_system->getEventManager()->pollEvent(event))
+			if (event.type == Common::EVENT_QUIT)
+				break;
+
+		if (!video->needsUpdate()) 
+			continue;
+
+		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;
 }
 
 void LB::b_getVolumes(int nargs) {




More information about the Scummvm-git-logs mailing list