[Scummvm-git-logs] scummvm master -> e4ba3fccc3b3c231849e1304dd8ab2c9a37d8ee6

dreammaster dreammaster at scummvm.org
Sat Jul 1 03:33:21 CEST 2017


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a897ad9e72 VIDEO: Add method to VideoDecoder to erase a track
2838776c4b VIDEO: Refactor AVIDecoder for better handling of transparency track
e4ba3fccc3 TITANIC: Update AVISurface to use refactored AVIDecoder


Commit: a897ad9e7222a3f8af1d75bc9c787da3bd464c33
    https://github.com/scummvm/scummvm/commit/a897ad9e7222a3f8af1d75bc9c787da3bd464c33
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-06-30T20:34:28-04:00

Commit Message:
VIDEO: Add method to VideoDecoder to erase a track

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


diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 05b6e7c..e4016d8 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -910,4 +910,21 @@ bool VideoDecoder::hasAudio() const {
 	return false;
 }
 
+void VideoDecoder::eraseTrack(Track *track) {
+	for (uint idx = 0; idx < _externalTracks.size(); ++idx) {
+		if (_externalTracks[idx] == track)
+			_externalTracks.remove_at(idx);
+	}
+
+	for (uint idx = 0; idx < _internalTracks.size(); ++idx) {
+		if (_internalTracks[idx] == track)
+			_internalTracks.remove_at(idx);
+	}
+
+	for (uint idx = 0; idx < _tracks.size(); ++idx) {
+		if (_tracks[idx] == track)
+			_tracks.remove_at(idx);
+	}
+}
+
 } // End of namespace Video
diff --git a/video/video_decoder.h b/video/video_decoder.h
index a415a70..598a67d 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -886,6 +886,11 @@ protected:
 	TrackListIterator getTrackListEnd() { return _internalTracks.end(); }
 
 	/**
+	 * Removes a specified track
+	 */
+	void eraseTrack(Track *track);
+
+	/**
 	 * The internal seek function that does the actual seeking.
 	 *
 	 * @see seek()


Commit: 2838776c4bf60556b73e74c7d481d9e4af718fbb
    https://github.com/scummvm/scummvm/commit/2838776c4bf60556b73e74c7d481d9e4af718fbb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-06-30T21:31:17-04:00

Commit Message:
VIDEO: Refactor AVIDecoder for better handling of transparency track

A lot of the standard VideoDecoder methods were still treating the
transparency track as part of the video, so methods like getFrameCount
would return double the amount it should be. This refactoring properly
separates the transparency track into a separate field entirely.

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


diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 9f97ffd..910a409 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -120,6 +120,7 @@ void AVIDecoder::initCommon() {
 	_videoTrackCounter = _audioTrackCounter = 0;
 	_lastAddedTrack = nullptr;
 	memset(&_header, 0, sizeof(_header));
+	_transparencyTrack.track = nullptr;
 }
 
 bool AVIDecoder::isSeekable() const {
@@ -129,10 +130,10 @@ bool AVIDecoder::isSeekable() const {
 }
 
 const Graphics::Surface *AVIDecoder::decodeNextTransparency() {
-	if (_videoTracks.size() != 2)
+	if (!_transparencyTrack.track)
 		return nullptr;
 
-	AVIVideoTrack *track = static_cast<AVIVideoTrack *>(_videoTracks[1].track);
+	AVIVideoTrack *track = static_cast<AVIVideoTrack *>(_transparencyTrack.track);
 	return track->decodeNextFrame();
 }
 
@@ -392,16 +393,22 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) {
 		} else if (_videoTracks.empty()) {
 			_videoTracks.push_back(status);
 		} else {
-			// Secondary video track
-			assert(_videoTracks.size() == 1);
+			// Secondary video track. For now we assume it will always be a
+			// transparency information track
 			status.chunkSearchOffset = getVideoTrackOffset(index);
+			assert(!_transparencyTrack.track);
 			assert(status.chunkSearchOffset != 0);
 
-			// Add the video track to the list
-			_videoTracks.push_back(status);
+			// Copy the track status information into the transparency track field
+			_transparencyTrack = status;
 		}
 	}
 
+	// If there is a transparency track, remove it from the video decoder's track list.
+	// This is to stop it being included in calls like getFrameCount
+	if (_transparencyTrack.track)
+		eraseTrack(_transparencyTrack.track);
+
 	// Check if this is a special Duck Truemotion video
 	checkTruemotion1();
 
@@ -423,6 +430,9 @@ void AVIDecoder::close() {
 
 	_videoTracks.clear();
 	_audioTracks.clear();
+
+	delete _transparencyTrack.track;
+	_transparencyTrack.track = nullptr;
 }
 
 void AVIDecoder::readNextPacket() {
@@ -434,6 +444,10 @@ void AVIDecoder::readNextPacket() {
 	for (uint idx = 0; idx < _videoTracks.size(); ++idx)
 		handleNextPacket(_videoTracks[idx]);
 
+	// Handle any transparency track
+	if (_transparencyTrack.track)
+		handleNextPacket(_transparencyTrack);
+
 	// Handle audio tracks next
 	for (uint idx = 0; idx < _audioTracks.size(); ++idx)
 		handleNextPacket(_audioTracks[idx]);
@@ -715,41 +729,9 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
 		videoTrack->decodeFrame(chunk);
 	}
 
-	// Update any secondary video track for transparencies
-	if (_videoTracks.size() == 2) {
-		// Find the index entry for the frame
-		int indexFrame = frame;
-		OldIndex *entry = nullptr;
-		do {
-			entry = _indexEntries.find(_videoTracks.back().index, indexFrame);
-		} while (!entry && indexFrame-- > 0);
-		assert(entry);
-
-		// Set it's frame number
-		AVIVideoTrack *videoTrack2 = static_cast<AVIVideoTrack *>(_videoTracks.back().track);
-		videoTrack2->setCurFrame(indexFrame - 1);
-
-		// Read in the frame
-		Common::SeekableReadStream *chunk = nullptr;
-		_fileStream->seek(entry->offset + 8);
-		_videoTracks.back().chunkSearchOffset = entry->offset;
-
-		if (entry->size != 0)
-			chunk = _fileStream->readStream(entry->size);
-		videoTrack2->decodeFrame(chunk);
-
-		if (indexFrame < (int)frame) {
-			TrackStatus &status = _videoTracks.back();
-			while (status.chunkSearchOffset < _movieListEnd && indexFrame++ < (int)frame) {
-				// There was no index entry for the desired frame, so an earlier one was decoded.
-				// We now have to sequentially decode frames until we get to the desired frame
-				handleNextPacket(status);
-			}
-		}
-
-		videoTrack2->setCurFrame((int)frame - 1);
-		videoTrack2->setFrameRate(videoTrack->getFrameRate());
-	}
+	// Update any transparency track if present
+	if (_transparencyTrack.track)
+		seekTransparencyFrame(frame);
 
 	// Set the video track's frame
 	videoTrack->setCurFrame((int)frame - 1);
@@ -759,6 +741,44 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
 	return true;
 }
 
+void AVIDecoder::seekTransparencyFrame(int frame) {
+	TrackStatus &status = _transparencyTrack;
+	AVIVideoTrack *transTrack = static_cast<AVIVideoTrack *>(status.track);
+
+	// Find the index entry for the frame
+	int indexFrame = frame;
+	OldIndex *entry = nullptr;
+	do {
+		entry = _indexEntries.find(status.index, indexFrame);
+	} while (!entry && indexFrame-- > 0);
+	assert(entry);
+
+	// Set it's frame number
+	transTrack->setCurFrame(indexFrame - 1);
+
+	// Read in the frame
+	Common::SeekableReadStream *chunk = nullptr;
+	_fileStream->seek(entry->offset + 8);
+	status.chunkSearchOffset = entry->offset;
+
+	if (entry->size != 0)
+		chunk = _fileStream->readStream(entry->size);
+	transTrack->decodeFrame(chunk);
+
+	if (indexFrame < (int)frame) {
+		while (status.chunkSearchOffset < _movieListEnd && indexFrame++ < (int)frame) {
+			// There was no index entry for the desired frame, so an earlier one was decoded.
+			// We now have to sequentially skip frames until we get to the desired frame
+			_fileStream->readUint32BE();
+			uint32 size = _fileStream->readUint32LE() - 8;
+			_fileStream->skip(size & 1);
+			status.chunkSearchOffset = _fileStream->pos();
+		}
+	}
+
+	transTrack->setCurFrame((int)frame - 1);
+}
+
 byte AVIDecoder::getStreamIndex(uint32 tag) {
 	char string[3];
 	WRITE_BE_UINT16(string, tag >> 16);
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 541c73e..a3dbddf 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -337,8 +337,10 @@ protected:
 
 	void handleNextPacket(TrackStatus& status);
 	bool shouldQueueAudio(TrackStatus& status);
-	Common::Array<TrackStatus> _videoTracks, _audioTracks;
+	void seekTransparencyFrame(int frame);
 
+	Common::Array<TrackStatus> _videoTracks, _audioTracks;
+	TrackStatus _transparencyTrack;
 public:
 	virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo);
 


Commit: e4ba3fccc3b3c231849e1304dd8ab2c9a37d8ee6
    https://github.com/scummvm/scummvm/commit/e4ba3fccc3b3c231849e1304dd8ab2c9a37d8ee6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-06-30T21:33:09-04:00

Commit Message:
TITANIC: Update AVISurface to use refactored AVIDecoder

Changed paths:
    engines/titanic/support/avi_surface.cpp
    engines/titanic/support/avi_surface.h


diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp
index 85b98e9..0308465 100644
--- a/engines/titanic/support/avi_surface.cpp
+++ b/engines/titanic/support/avi_surface.cpp
@@ -55,7 +55,7 @@ AVISurface::AVISurface(const CResourceKey &key) : _movieName(key.getString()) {
 	if (!_decoder->loadFile(_movieName))
 		error("Could not open video - %s", key.getString().c_str());
 
-	_streamCount = _decoder->videoTrackCount();
+	_streamCount = _decoder->getTransparencyTrack() ? 2 : 1;
 
 	_soundManager = nullptr;
 	_hasAudio = false;
@@ -222,7 +222,7 @@ void AVISurface::setVideoSurface(CVideoSurface *surface) {
 
 	// Handling for secondary video stream
 	if (_streamCount == 2) {
-		const Common::String &streamName = _decoder->getVideoTrack(1).getName();
+		const Common::String &streamName = _decoder->getTransparencyTrack()->getName();
 
 		if (streamName == "mask0") {
 			_videoSurface->_transparencyMode = TRANS_MASK0;
@@ -243,7 +243,9 @@ void AVISurface::setupDecompressor() {
 		return;
 
 	for (int idx = 0; idx < _streamCount; ++idx) {
-		Graphics::PixelFormat format = _decoder->getVideoTrack(idx).getPixelFormat();
+		Graphics::PixelFormat format = (idx == 0) ?
+			_decoder->getVideoTrack(0).getPixelFormat() :
+			_decoder->getTransparencyTrack()->getPixelFormat();
 		int decoderPitch = _decoder->getWidth() * format.bytesPerPixel;
 		bool flag = false;
 
diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h
index d3442a1..5e7e5d4 100644
--- a/engines/titanic/support/avi_surface.h
+++ b/engines/titanic/support/avi_surface.h
@@ -57,6 +57,13 @@ public:
 	 * Returns the specified video track
 	 */
 	Video::AVIDecoder::AVIVideoTrack &getVideoTrack(uint idx);
+
+	/**
+	 * Returns the transparency video track, if present
+	 */
+	AVIVideoTrack *getTransparencyTrack() {
+		return static_cast<AVIVideoTrack *>(_transparencyTrack.track);
+	}
 };
 
 class AVISurface {





More information about the Scummvm-git-logs mailing list