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

sdelamarre noreply at scummvm.org
Sun Nov 15 01:10:33 UTC 2026


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

Summary:
f40e460790 VIDEO: Add support for "safe" seek in VMD decoder
f8e977d831 VIDEO: Add support for external key frames files (.KEY) in VMD decoder
1cadabc49c GOB: Add support for video sequence files (.VMS)
bec9ffe330 GOB: Fix some voiceovers not interrupted by right-clicking (Adi4/Anglais)
b48a7e9c3f GOB: Fix frame number written in game variables by updateVideos


Commit: f40e4607904c94ef1218bfa03e8a85b82a1fa272
    https://github.com/scummvm/scummvm/commit/f40e4607904c94ef1218bfa03e8a85b82a1fa272
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-11-15T02:03:16+01:00

Commit Message:
VIDEO: Add support for "safe" seek in VMD decoder

Allows to safely seek to an arbitrary frame in the video, by returning
to the closest full frame preceding and decoding the video from there.
We must also load sound slices from previous frames, as the sound is
stored ahead of the video by _soundSlicesCount - 2 slices.

Needed by video resources in Adi4/Anglais

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


diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index a5978bc5e79..da4590c951d 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -66,6 +66,11 @@ CoktelDecoder::CoktelDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundT
 CoktelDecoder::~CoktelDecoder() {
 }
 
+bool CoktelDecoder::safeSeekFromPreviousFullFrame(int32 frame, int whence) {
+	// Not supported by this decoder variant: fall back to a plain seek
+	return seek(frame, whence, true);
+}
+
 bool CoktelDecoder::evaluateSeekFrame(int32 &frame, int whence) const {
 	if (!isVideoLoaded())
 		// Nothing to do
@@ -2227,6 +2232,7 @@ void VMDDecoder::close() {
 
 	_files.clear();
 
+	_safeSeekDirtyRect = Common::Rect();
 
 	_stream = 0;
 
@@ -2296,6 +2302,12 @@ void VMDDecoder::processFrame() {
 
 	_dirtyRects.clear();
 
+	// Area changed by the frames silently decoded while safe seeking
+	if (!_safeSeekDirtyRect.isEmpty()) {
+		_dirtyRects.push_back(_safeSeekDirtyRect);
+		_safeSeekDirtyRect = Common::Rect();
+	}
+
 	_subtitle     = -1;
 
 	bool startSound = false;
@@ -2431,6 +2443,145 @@ void VMDDecoder::processFrame() {
 	}
 }
 
+bool VMDDecoder::isFullFrame(int32 frame) const {
+	if (frame < 0 || (uint32)frame >= _frameCount)
+		return false;
+
+	// A video part that is neither a sparse block nor a delta
+	for (uint16 i = 0; i < _partsPerFrame; i++) {
+		const Part &part = _frames[frame].parts[i];
+		if (part.type == kPartTypeSeparator)
+			break;
+
+		if (part.type == kPartTypeVideo)
+			return !(part.field_E & 0x01) && !(part.flags & 0x40);
+	}
+
+	return false;
+}
+
+int32 VMDDecoder::findPreviousFullFrame(int32 frame) const {
+	for (int32 i = frame; i > 0; i--) {
+		if (isFullFrame(i))
+			return i;
+	}
+
+	return 0;
+}
+
+bool VMDDecoder::safeSeekFromPreviousFullFrame(int32 frame, int whence) {
+	if (!evaluateSeekFrame(frame, whence))
+		return false;
+
+	int32 nextFrame = frame + 1;
+	if ((uint32)nextFrame >= _frameCount)
+		// Nothing to decode after it: plain seek
+		return seek(nextFrame, SEEK_SET, true);
+
+	int32 curNextFrame = _curFrame + 1;
+	if (nextFrame != curNextFrame) {
+		int32 startFrame = findPreviousFullFrame(nextFrame);
+
+		// If the current position lies in between, continue from there instead
+		if (startFrame < curNextFrame && curNextFrame < nextFrame)
+			startFrame = curNextFrame;
+
+		seek(startFrame, SEEK_SET, true);
+
+		// Decode the frames up to the wanted one, without their sound.
+		bool savedSoundEnabled = _soundEnabled;
+		_soundEnabled = false;
+
+		Common::Rect seekRect;
+		while (_curFrame + 1 < nextFrame) {
+			createSurface();
+			processFrame();
+
+			for (const Common::Rect &rect : _dirtyRects) {
+				if (seekRect.isEmpty())
+					seekRect = rect;
+				else
+					seekRect.extend(rect);
+			}
+		}
+
+		_soundEnabled = savedSoundEnabled;
+		_safeSeekDirtyRect = seekRect;
+	}
+
+	_startTime = g_system->getMillis() - ((nextFrame + 1) * getStaticTimeToNextFrame());
+	restartSoundAt(nextFrame);
+	return true;
+}
+
+VMDDecoder::Part *VMDDecoder::findPartOfFrame(int32 frame, PartType type, uint32 &offset) {
+	if ((uint32)frame >= _frameCount)
+		return nullptr;
+
+	offset = _frames[frame].offset;
+	for (uint16 i = 0; i < _partsPerFrame; i++) {
+		Part &part = _frames[frame].parts[i];
+		if (part.type == type) {
+			return ∂
+		}
+
+		offset += part.size;
+	}
+
+	return nullptr;
+}
+
+void VMDDecoder::restartSoundAt(int32 nextFrame) {
+	if (!_hasSound || _soundStereo == 1 || _mixer->getOutputRate() == 0)
+		return;
+
+	if (_audioStream) {
+		if (_soundStage == kSoundPlaying || _soundStage == kSoundFinished) {
+			_audioStream->finish();
+			_mixer->stopHandle(_audioHandle);
+		}
+
+		delete _audioStream;
+		_audioStream = nullptr;
+	}
+
+	createAudioStream();
+	_soundEnabled = true;
+	_soundStage   = kSoundLoaded;
+
+	if (nextFrame == 0)
+		return; // Nothing more to do for frame 0, which contains the initial sound slices.
+
+	// Otherwise, we need to look for sound slices in the previous frames, as the sound
+	// is stored ahead of the video by _soundSlicesCount - 2 slices.
+	int32 frame = nextFrame - (_soundSlicesCount - 2);
+	if (frame <= 0) {
+		// Some slices must be taken from the initial slices of frame 0.
+		uint32 offset = 0;
+		Part *soundPart = findPartOfFrame(0, kPartTypeAudio, offset);
+		if (soundPart && soundPart->flags == 2 && _soundSlicesCount <= 32) {
+			_stream->seek(offset);
+			uint32 mask = _stream->readUint32LE();
+			filledSoundSlices(soundPart->size - /* mask size */ 4, mask, nextFrame);
+		} else {
+			for (int32 i = nextFrame; i < _soundSlicesCount - 1; i++)
+				emptySoundSlice(_soundDataSize * _soundBytesPerSample);
+		}
+
+		frame = 1;
+	}
+
+	for (; frame < nextFrame; ++frame) {
+		uint32 offset = 0;
+		Part *soundPart = findPartOfFrame(frame, kPartTypeAudio, offset);
+		if (soundPart && soundPart->flags == 1) {
+			_stream->seek(offset);
+			filledSoundSlice(soundPart->size);
+		} else
+			emptySoundSlice(_soundDataSize * _soundBytesPerSample);
+	}
+}
+
 bool VMDDecoder::renderFrame(Common::Rect &rect) {
 	Common::Rect realRect, fakeRect;
 	if (!getRenderRects(rect, realRect, fakeRect))
@@ -2704,7 +2855,10 @@ void VMDDecoder::filledSoundSlice(uint32 size) {
 		_audioStream->queueAudioStream(sliceStream);
 }
 
-void VMDDecoder::filledSoundSlices(uint32 size, uint32 mask) {
+void VMDDecoder::filledSoundSlices(uint32 size, uint32 mask, uint8 firstSlice) {
+	// The slices past the 32nd are a single block, which cannot be started in its middle
+	assert((firstSlice == 0) || (_soundSlicesCount <= 32));
+
 	bool fillInfo[32];
 
 	uint8 max;
@@ -2726,7 +2880,10 @@ void VMDDecoder::filledSoundSlices(uint32 size, uint32 mask) {
 		extraSize = 0;
 
 	for (uint8 i = 0; i < max; i++)
-		if (fillInfo[i])
+		if (i < firstSlice) {
+			if (fillInfo[i])
+				_stream->skip(_soundDataSize + extraSize);
+		} else if (fillInfo[i])
 			filledSoundSlice(_soundDataSize + extraSize);
 		else
 			emptySoundSlice(_soundDataSize * _soundBytesPerSample);
diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h
index 7933bb47144..a380dbf7cdc 100644
--- a/video/coktel_decoder.h
+++ b/video/coktel_decoder.h
@@ -90,6 +90,11 @@ public:
 
 	virtual bool seek(int32 frame, int whence = SEEK_SET, bool restart = false) = 0;
 
+	/**
+	 * "Safe" seek: ensure the image is complete by re-decoding from the previous full frame,
+	 *  and restart the sound in sync at the wanted frame
+	 */
+	virtual bool safeSeekFromPreviousFullFrame(int32 frame, int whence = SEEK_SET);
 	/** Draw directly onto the specified video memory. */
 	void setSurfaceMemory(void *mem, uint16 width, uint16 height, uint8 bpp);
 	/** Reset the video memory. */
@@ -422,6 +427,7 @@ public:
 	bool reloadStream(Common::SeekableReadStream *stream) override;
 
 	bool seek(int32 frame, int whence = SEEK_SET, bool restart = false) override;
+	bool safeSeekFromPreviousFullFrame(int32 frame, int whence = SEEK_SET) override;
 
 	void setXY(uint16 x, uint16 y) override;
 
@@ -561,6 +567,8 @@ private:
 
 	bool _isPaletted;
 
+	Common::Rect _safeSeekDirtyRect; ///< Area changed by the frames decoded while safe seeking.
+
 	// Loading helper functions
 	bool assessVideoProperties();
 	bool assessAudioProperties();
@@ -571,6 +579,10 @@ private:
 	// Frame decoding
 	void processFrame();
 
+	bool isFullFrame(int32 frame) const;
+	int32 findPreviousFullFrame(int32 frame) const;
+	VMDDecoder::Part *findPartOfFrame(int32 frame, PartType type, uint32 &offset);
+
 	// Video
 	bool renderFrame(Common::Rect &rect);
 	bool getRenderRects(const Common::Rect &rect,
@@ -581,7 +593,8 @@ private:
 	// Sound
 	void emptySoundSlice  (uint32 size);
 	void filledSoundSlice (uint32 size);
-	void filledSoundSlices(uint32 size, uint32 mask);
+	void filledSoundSlices(uint32 size, uint32 mask, uint8 firstSlice = 0);
+	void restartSoundAt(int32 nextFrame);
 	void createAudioStream();
 
 	uint8 evaluateMask(uint32 mask, bool *fillInfo, uint8 &max);


Commit: f8e977d8316fd3dd46318922084331c4d2f68342
    https://github.com/scummvm/scummvm/commit/f8e977d8316fd3dd46318922084331c4d2f68342
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-11-15T02:03:16+01:00

Commit Message:
VIDEO: Add support for external key frames files (.KEY) in VMD decoder

External key frames files (.KEY) contain some full video frames indexed
by frame numbers. They are used to facilitate safe-seeking into it
(by adding more full frames, see safeSeekFromPreviousFullFrame).

Used in Adi4/Anglais

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


diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp
index da4590c951d..f1608109524 100644
--- a/video/coktel_decoder.cpp
+++ b/video/coktel_decoder.cpp
@@ -269,6 +269,12 @@ bool CoktelDecoder::isPaletted() const {
 	return true;
 }
 
+bool CoktelDecoder::loadKeyFrames(Common::SeekableReadStream *stream) {
+	warning("CoktelDecoder::loadKeyFrames(): This decoder variant does not support key frames");
+	delete stream;
+	return false;
+}
+
 int CoktelDecoder::getCurFrame() const {
 	return _curFrame;
 }
@@ -1733,7 +1739,8 @@ VMDDecoder::VMDDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) :
 	_soundLastFilledFrame(0), _audioFormat(kAudioFormat8bitRaw),
 	_hasVideo(false), _hasVideoData(false), _videoCodec(0), _blitMode(0), _bytesPerPixel(0),
 	_firstFramePos(0), _videoBufferSize(0), _externalCodec(false), _codec(0),
-	_subtitle(-1), _isPaletted(true), _autoStartSound(true), _oldStereoBuffer(nullptr) {
+	_subtitle(-1), _isPaletted(true), _autoStartSound(true), _oldStereoBuffer(nullptr),
+	_externalKeyFrameStream(nullptr), _externalKeyFrameToRender(-1) {
 
 	_videoBuffer   [0] = 0;
 	_videoBuffer   [1] = 0;
@@ -1799,7 +1806,9 @@ bool VMDDecoder::seek(int32 frame, int whence, bool restart) {
 	}
 
 	// Seek
-	_stream->seek(_frames[frame + 1].offset);
+	_externalKeyFrameToRender = -1;
+	if ((uint32)(frame + 1) < _frameCount)
+		_stream->seek(_frames[frame + 1].offset);
 	_curFrame = frame;
 	_nbFramesPastEnd = 0;
 	_startTime = g_system->getMillis() - ((frame + 2) * getStaticTimeToNextFrame());
@@ -2232,6 +2241,11 @@ void VMDDecoder::close() {
 
 	_files.clear();
 
+	delete _externalKeyFrameStream;
+	_externalKeyFrameStream = nullptr;
+	_externalKeyFrameOffsets.clear();
+	_externalKeyFrameSizes.clear();
+	_externalKeyFrameToRender = -1;
 	_safeSeekDirtyRect = Common::Rect();
 
 	_stream = 0;
@@ -2312,6 +2326,12 @@ void VMDDecoder::processFrame() {
 
 	bool startSound = false;
 
+	bool externalKeyFrameUsed = false;
+	if (_externalKeyFrameToRender == _curFrame) {
+		externalKeyFrameUsed = renderExternalKeyFrame(_externalKeyFrameToRender);
+		_externalKeyFrameToRender = -1;
+	}
+
 	_stream->seek(_frames[_curFrame].offset, SEEK_SET);
 
 	for (uint16 i = 0; i < _partsPerFrame; i++) {
@@ -2370,6 +2390,11 @@ void VMDDecoder::processFrame() {
 			warning("VMDDecoder::processFrame(): Header claims there's no video, but video found (%d)", part.size);
 			_stream->skip(part.size);
 
+		} else if ((part.type == kPartTypeVideo) && externalKeyFrameUsed) {
+
+			// This video frame was replaced by an external one from a KEY file
+			_stream->skip(part.size);
+
 		} else if ((part.type == kPartTypeVideo) && _hasVideo) {
 
 			uint32 size = part.size;
@@ -2443,6 +2468,52 @@ void VMDDecoder::processFrame() {
 	}
 }
 
+bool VMDDecoder::loadKeyFrames(Common::SeekableReadStream *stream) {
+	delete _externalKeyFrameStream;
+	_externalKeyFrameStream = nullptr;
+	_externalKeyFrameOffsets.clear();
+	_externalKeyFrameSizes.clear();
+
+	if (!stream)
+		return false;
+
+	uint16 frameCount = stream->readUint16LE();
+	stream->seek(10);
+	stream->readUint32LE(); // Max size of the frame data
+	stream->readUint32LE(); // Max size of the unpacked frame data
+	uint32 tableOffset = stream->readUint32LE();
+
+	if (frameCount != _frameCount)
+		warning("VMDDecoder::loadKeyFrames(): Frame count mismatch (%d, video has %d)", frameCount, _frameCount);
+
+	// Tables of offsets and sizes of the key frames data (frame offset = 0 means "no key frame")
+	_externalKeyFrameOffsets.resize(frameCount);
+	_externalKeyFrameSizes.resize(frameCount);
+	stream->seek(tableOffset);
+	for (uint16 frame = 0; frame < frameCount; frame++)
+		_externalKeyFrameOffsets[frame] = stream->readUint32LE();
+	for (uint16 frame = 0; frame < frameCount; frame++)
+		_externalKeyFrameSizes[frame] = stream->readUint32LE();
+
+	if (stream->err() || stream->eos()) {
+		warning("VMDDecoder::loadKeyFrames(): Failed reading the key frames table");
+		_externalKeyFrameOffsets.clear();
+		_externalKeyFrameSizes.clear();
+		delete stream;
+		return false;
+	}
+
+	_externalKeyFrameStream = stream;
+	return true;
+}
+
+bool VMDDecoder::hasExternalKeyFrame(int32 frame) const {
+	return _externalKeyFrameStream &&
+		   frame >= 0 &&
+		   (uint32)frame < _externalKeyFrameOffsets.size() &&
+		   _externalKeyFrameOffsets[frame] != 0;
+}
+
 bool VMDDecoder::isFullFrame(int32 frame) const {
 	if (frame < 0 || (uint32)frame >= _frameCount)
 		return false;
@@ -2462,13 +2533,39 @@ bool VMDDecoder::isFullFrame(int32 frame) const {
 
 int32 VMDDecoder::findPreviousFullFrame(int32 frame) const {
 	for (int32 i = frame; i > 0; i--) {
-		if (isFullFrame(i))
+		if (hasExternalKeyFrame(i) || isFullFrame(i))
 			return i;
 	}
 
 	return 0;
 }
 
+bool VMDDecoder::renderExternalKeyFrame(int32 frame) {
+	if (!hasExternalKeyFrame(frame) || !_hasVideo || _externalCodec || (_blitMode != 0))
+		return false;
+
+	uint32 size = _externalKeyFrameSizes[frame];
+	if ((size == 0) || (size > _videoBufferSize)) {
+		warning("VMDDecoder::renderExternalKeyFrame(): Invalid key frame %d size (%u, max %u)", frame, size, _videoBufferSize);
+		return false;
+	}
+
+	if (!_externalKeyFrameStream->seek(_externalKeyFrameOffsets[frame]) ||
+	    (_externalKeyFrameStream->read(_videoBuffer[0], size) != size)) {
+		warning("VMDDecoder::renderExternalKeyFrame(): Failed reading key frame %d", frame);
+		return false;
+	}
+
+	_videoBufferLen[0] = size;
+
+	// The key frame covers the whole video area
+	Common::Rect rect(_x, _y, _x + _width, _y + _height);
+	if (renderFrame(rect))
+		_dirtyRects.push_back(rect);
+
+	return true;
+}
+
 bool VMDDecoder::safeSeekFromPreviousFullFrame(int32 frame, int whence) {
 	if (!evaluateSeekFrame(frame, whence))
 		return false;
@@ -2488,6 +2585,9 @@ bool VMDDecoder::safeSeekFromPreviousFullFrame(int32 frame, int whence) {
 
 		seek(startFrame, SEEK_SET, true);
 
+		if (hasExternalKeyFrame(startFrame))
+			_externalKeyFrameToRender = startFrame;
+
 		// Decode the frames up to the wanted one, without their sound.
 		bool savedSoundEnabled = _soundEnabled;
 		_soundEnabled = false;
diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h
index a380dbf7cdc..5a98ebf6975 100644
--- a/video/coktel_decoder.h
+++ b/video/coktel_decoder.h
@@ -152,6 +152,12 @@ public:
 	/** Is the video paletted or true color? */
 	virtual bool isPaletted() const;
 
+	/**
+	 * Load a table of key frames (".KEY" files found alongside some VMDs),
+	 * used for safe seeking.
+	 */
+	virtual bool loadKeyFrames(Common::SeekableReadStream *stream);
+
 	virtual uint32 getVideoBufferSize() const = 0;
 
 	/**
@@ -445,6 +451,8 @@ public:
 	bool hasVideoData() const override;
 	bool isPaletted() const override;
 
+	bool loadKeyFrames(Common::SeekableReadStream *stream) override;
+
 	bool loadStream(Common::SeekableReadStream *stream) override;
 	void close();
 
@@ -567,6 +575,11 @@ private:
 
 	bool _isPaletted;
 
+	// Key frames
+	Common::SeekableReadStream *_externalKeyFrameStream;
+	Common::Array<uint32> _externalKeyFrameOffsets; ///< Offset of the key frame of each frame (0: no key frame).
+	Common::Array<uint32> _externalKeyFrameSizes;
+	int32 _externalKeyFrameToRender; ///< When reaching this frame, render the external key frame instead of the VMD one
 	Common::Rect _safeSeekDirtyRect; ///< Area changed by the frames decoded while safe seeking.
 
 	// Loading helper functions
@@ -583,6 +596,10 @@ private:
 	int32 findPreviousFullFrame(int32 frame) const;
 	VMDDecoder::Part *findPartOfFrame(int32 frame, PartType type, uint32 &offset);
 
+	// External key frames
+	bool hasExternalKeyFrame(int32 frame) const;
+	bool renderExternalKeyFrame(int32 frame);
+
 	// Video
 	bool renderFrame(Common::Rect &rect);
 	bool getRenderRects(const Common::Rect &rect,


Commit: 1cadabc49c60c2c76e72a9e43a63ca8613456662
    https://github.com/scummvm/scummvm/commit/1cadabc49c60c2c76e72a9e43a63ca8613456662
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-11-15T02:03:16+01:00

Commit Message:
GOB: Add support for video sequence files (.VMS)

These .VMS files are found alongside VMD files and define some sequences
(start frame/end frame) in the VMD, associated with an ID, which can
be used by the playVmdOrMusic opcode. As they require safe seeking, they
are often associated with a .KEY file

Used in interactive films of Adi4/Anglais

Changed paths:
    engines/gob/inter_v7.cpp
    engines/gob/videoplayer.cpp
    engines/gob/videoplayer.h


diff --git a/engines/gob/inter_v7.cpp b/engines/gob/inter_v7.cpp
index 0e294ce9723..4408854603b 100644
--- a/engines/gob/inter_v7.cpp
+++ b/engines/gob/inter_v7.cpp
@@ -753,6 +753,84 @@ void Inter_v7::o7_playVmdOrMusic() {
 			props.x, props.y, props.startFrame, props.lastFrame,
 			props.palCmd, props.palStart, props.palEnd, props.flags);
 
+	if (props.flags & VideoPlayer::kFlagVideoSequence) {
+		// Video split into sequences described in a ".VMS" file alongside the ".VMD"
+		int32 command = props.lastFrame;
+		int32 sequenceId = props.startFrame;
+
+		_vm->_vidPlayer->evaluateFlags(props);
+		props.reuseSlotWitSameFilename = true;
+		int slot = _vm->_vidPlayer->openVideo(true, file, props);
+		if (slot < 0) {
+			WRITE_VAR(11, (uint32) -1);
+			return;
+		}
+
+		_vm->_vidPlayer->loadSequences(slot);
+
+		bool noSound = props.flags & 0x400;
+		if (noSound)
+			_vm->_vidPlayer->stopSound(slot);
+
+		int32 startFrame = 0;
+		int32 endFrame   = 0;
+		if (!_vm->_vidPlayer->findSequence(slot, sequenceId, startFrame, endFrame)) {
+			// Unknown sequence: fall back to frame 0
+			warning("Unknown sequence %d for video \"%s\" (using frame 0)", sequenceId, file.c_str());
+			props.startFrame = 0;
+			props.lastFrame  = 0;
+			WRITE_VAR(11, 0);
+		} else {
+			_vm->_vidPlayer->setAutoUpdate(slot, true);
+
+			if (command == 2) {
+				_vm->_vidPlayer->setAutoUpdate(slot, false);
+				_vm->_vidPlayer->stopSound(slot);
+			}
+
+			if (command == 1) {
+				// Only query the sequence frames
+				WRITE_VAR(11, endFrame - startFrame + 1);
+				WRITE_VAR(10, startFrame);
+			}
+
+			if (command > 0)
+				return;
+
+			if (command >= -1 || command == -3 || command == -5 || command == -6) {
+				_vm->_vidPlayer->seek(slot, startFrame);
+				if (noSound)
+					_vm->_vidPlayer->stopSound(slot); // Stop the sound again, as seek() restarts it
+			}
+
+			if (command == -5)
+				return;
+
+			if (command == -4)
+				props.startFrame = -1; // Continue from the current frame, up to the end of the sequence
+			else
+				props.startFrame = startFrame;
+
+			if (command < 0 && command != -3 && command != -6)
+				props.lastFrame = endFrame;  // Play the whole sequence
+			else
+				props.lastFrame = startFrame; // Only show the first frame
+
+			WRITE_VAR(11, endFrame - startFrame + 1);
+			WRITE_VAR(10, startFrame);
+		}
+
+		props.noBlock = false;
+		_vm->_vidPlayer->play(slot, props);
+
+		if (command > -3 && (command < 0 || noSound)) {
+			_vm->_vidPlayer->stopSound(slot);
+			_vm->_vidPlayer->setAutoUpdate(slot, false);
+		}
+
+		return;
+	}
+
 	bool close = false;
 	if (props.lastFrame == -1) {
 		close = true;
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 187cb2eb72d..4813aa631c9 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -51,7 +51,7 @@ VideoPlayer::Properties::Properties() : type(kVideoTypeTry), sprite(Draw::kFront
 }
 
 
-VideoPlayer::Video::Video() : decoder(nullptr),
+VideoPlayer::Video::Video() : decoder(nullptr), sequencesLoaded(false),
 	doubleVideoDestX(0), doubleVideoDestY(0), doubleVideo(false),
 	live(false), useBackSurface(false), autoUpdate(false),
 	highColorMap(nullptr) {
@@ -66,6 +66,8 @@ void VideoPlayer::Video::close() {
 
 	decoder = nullptr;
 	fileName.clear();
+	sequences.clear();
+	sequencesLoaded = false;
 	surface.reset();
 	tmpSurfDouble.reset();
 	doubleVideoDestX = 0;
@@ -547,6 +549,73 @@ void VideoPlayer::waitEndFrame(int slot, bool onlySound) {
 	}
 }
 
+void VideoPlayer::loadSequences(int slot) {
+	Video *video = getVideoBySlot(slot);
+	if (!video || video->sequencesLoaded)
+		return;
+
+	video->sequencesLoaded = true;
+	video->sequences.clear();
+
+	Common::String vmsFilename = Util::setExtension(video->fileName, ".VMS");
+
+	// The ".VMS" file holds three arrays of 16-bit values: the sequence IDs, their start frames and end frames
+	Common::SeekableReadStream *vms = _vm->_dataIO->getFile(vmsFilename);
+	if (vms) {
+		uint32 count = vms->size() / 6;
+		video->sequences.resize(count);
+		for (uint32 i = 0; i < count; i++)
+			video->sequences[i].id = vms->readSint16LE();
+		for (uint32 i = 0; i < count; i++)
+			video->sequences[i].startFrame = vms->readSint16LE();
+		for (uint32 i = 0; i < count; i++)
+			video->sequences[i].endFrame = vms->readSint16LE();
+
+		delete vms;
+	} else
+		warning("VideoPlayer::loadSequences(): No sequences file for video \"%s\"", video->fileName.c_str());
+
+	Common::String keyFilename = Util::setExtension(video->fileName, ".KEY");
+	Common::SeekableReadStream *keyFrames = _vm->_dataIO->getFile(keyFilename);
+	if (keyFrames)
+		video->decoder->loadKeyFrames(keyFrames);
+
+	debugC(1, kDebugVideo, "VideoPlayer::loadSequences(): %u sequences loaded for %s, %s key frames",
+		   video->sequences.size(), video->fileName.c_str(), keyFrames != nullptr ? "with" : "without");
+}
+
+bool VideoPlayer::findSequence(int slot, int16 id, int32 &startFrame, int32 &endFrame) const {
+	const Video *video = getVideoBySlot(slot);
+	if (!video)
+		return false;
+
+	for (const Sequence &sequence : video->sequences) {
+		if (sequence.id == id) {
+			startFrame = sequence.startFrame;
+			endFrame   = sequence.endFrame;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void VideoPlayer::seek(int slot, int32 frame) {
+	Video *video = getVideoBySlot(slot);
+	if (!video || !video->decoder)
+		return;
+
+	video->decoder->safeSeekFromPreviousFullFrame(frame);
+}
+
+void VideoPlayer::stopSound(int slot) {
+	Video *video = getVideoBySlot(slot);
+	if (!video || !video->decoder)
+		return;
+
+	video->decoder->disableSound();
+}
+
 int32 VideoPlayer::getExpectedFrameFromCurrentTime(int slot) {
 	Video *video = getVideoBySlot(slot);
 	if (!video)
@@ -708,14 +777,17 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
 		if (properties.startFrame != -1) {
 			// Seek into the middle of the video
 
-			if (video->decoder->hasSound()) {
+			if (_vm->getGameType() == kGameTypeAdi4) {
+				// Always use safe seeking, which ensures the image is complete and
+				// is able to restart sound from anywhere in the video
+				video->decoder->safeSeekFromPreviousFullFrame(properties.startFrame + 1);
+			} else if (video->decoder->hasSound()) {
 				// But there's sound
 
 				if (properties.forceSeek) {
 					// And we force seeking => Seek
-
-					video->decoder->disableSound();
-					video->decoder->seek(properties.startFrame + 1, SEEK_SET, true);
+						video->decoder->disableSound();
+						video->decoder->seek(properties.startFrame + 1, SEEK_SET, true);
 				}
 
 			} else
@@ -763,28 +835,28 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
 	}
 
 	const Graphics::Surface *surface = video->decoder->decodeNextFrame();
+	const Common::List<Common::Rect> &dirtyRects = video->decoder->getDirtyRects();
 	if (surface != nullptr && surface->w > 0 && surface->h > 0 && video->decoder->isPaletted() && video->surface && video->surface->getBPP() > 1) {
 		// High color conversion from paletted
-		Surface *bppTarget = (video->doubleVideo && video->tmpSurfDouble) ?
-			video->tmpSurfDouble.get() : video->surface.get();
-		int16 x = 0;
-		int16 y = 0;
-		int16 width = 0;
-		int16 height = 0;
-		if (video->decoder->getFrameCoords(video->decoder->getCurFrame(), x, y, width, height)
-				&& x >= 0 && y >= 0 && width > 0 && height > 0) {
-			Graphics::crossBlitMap(bppTarget->getData(x, y), static_cast<const byte *>(surface->getBasePtr(x, y)),
+		Surface *bppTarget = (video->doubleVideo && video->tmpSurfDouble) ? video->tmpSurfDouble.get() : video->surface.get();
+		for (Common::Rect rect : dirtyRects) {
+			rect.clip(Common::Rect(surface->w, surface->h));
+			rect.clip(Common::Rect(bppTarget->getWidth(), bppTarget->getHeight()));
+			if (rect.isEmpty())
+				continue;
+
+			Graphics::crossBlitMap(bppTarget->getData(rect.left, rect.top),
+								   static_cast<const byte *>(surface->getBasePtr(rect.left, rect.top)),
 								   bppTarget->getWidth() * bppTarget->getBPP(),
 								   surface->pitch,
-								   width, height,
+								   rect.width(), rect.height(),
 								   bppTarget->getBPP(), video->highColorMap);
 		}
 	}
 
 	if (video->doubleVideo && video->tmpSurfDouble && video->surface) {
 		// Double the video
-		const Common::List<Common::Rect> &rects = video->decoder->getDirtyRects();
-		for (Common::List<Common::Rect>::const_iterator rect = rects.begin(); rect != rects.end(); ++rect) {
+		for (Common::List<Common::Rect>::const_iterator rect = dirtyRects.begin(); rect != dirtyRects.end(); ++rect) {
 			video->surface->blitScaled(*video->tmpSurfDouble,
 				rect->left, rect->top, rect->right - 1, rect->bottom - 1,
 				video->doubleVideoDestX + rect->left * 2,
@@ -825,8 +897,6 @@ bool VideoPlayer::playFrame(int slot, Properties &properties) {
 				_vm->_draw->_applyPal = true;
 		}
 
-		const Common::List<Common::Rect> &dirtyRects = video->decoder->getDirtyRects();
-
 		if (modifiedPal && (properties.palCmd == 8) && (video->surface == _vm->_draw->_backSurface))
 			_vm->_video->setFullPalette(_vm->_global->_pPaletteDesc);
 
diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h
index 28e77bbe098..54ccf9068ac 100644
--- a/engines/gob/videoplayer.h
+++ b/engines/gob/videoplayer.h
@@ -56,6 +56,7 @@ public:
 		kFlagFrontSurface                       = 0x000080, ///< Draw directly into the front surface.
 		kFlagNoVideo                            = 0x000100, ///< Only sound.
 		kFlagOtherSurface                       = 0x000800, ///< Draw into a specific sprite.
+		kFlagVideoSequence                      = 0x008000, ///< Play a video sequence defined in a "VMS" file alongside the VMD.
 		kFlagScreenSurface                      = 0x400000  ///< Draw into a newly created sprite of screen dimensions.
 	};
 
@@ -133,6 +134,12 @@ public:
 
 	bool play(int slot, Properties &properties);
 	void waitEndFrame(int slot, bool onlySound = false);
+
+	// Videos split into sequences (".VMS" file), with key frames (".KEY" file)
+	void loadSequences(int slot);
+	bool findSequence(int slot, int16 id, int32 &startFrame, int32 &endFrame) const;
+	void seek(int slot, int32 frame);
+	void stopSound(int slot);
 	int32 getExpectedFrameFromCurrentTime(int slot);
 
 	bool isPlayingLive() const;
@@ -175,10 +182,19 @@ public:
 			int32 transp = -1, bool yAxisReflexion = false) const;
 
 private:
+	struct Sequence {
+		int16 id;
+		int16 startFrame;
+		int16 endFrame;
+	};
+
 	struct Video {
 		::Video::CoktelDecoder *decoder;
 		Common::String fileName;
 
+		Common::Array<Sequence> sequences; ///< Sequences defined in a ".VMS" file alongside the VMD.
+		bool sequencesLoaded;
+
 		SurfacePtr surface;
 		SurfacePtr tmpSurfDouble; ///< Intermediate 1x surface for video doubling
 		int16 doubleVideoDestX;   ///< Saved destination X on target surface for the doubled video


Commit: bec9ffe3307f71d5fd0705a2dd0e6f49b30f3629
    https://github.com/scummvm/scummvm/commit/bec9ffe3307f71d5fd0705a2dd0e6f49b30f3629
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-11-15T02:03:16+01:00

Commit Message:
GOB: Fix some voiceovers not interrupted by right-clicking (Adi4/Anglais)

Changed paths:
    engines/gob/inter_v7.cpp


diff --git a/engines/gob/inter_v7.cpp b/engines/gob/inter_v7.cpp
index 4408854603b..a6b483b7911 100644
--- a/engines/gob/inter_v7.cpp
+++ b/engines/gob/inter_v7.cpp
@@ -916,6 +916,8 @@ void Inter_v7::o7_playVmdOrMusic() {
 
 		if (props.lastFrame <= -20)
 			props.noBlock    = true;
+		else if (props.startFrame >= 0)
+			close = true;
 
 		props.slot = (-props.lastFrame) % 10;
 	}
@@ -939,10 +941,6 @@ void Inter_v7::o7_playVmdOrMusic() {
 		return;
 	}
 
-	if (_vm->_vidPlayer->getVideoBufferSize(slot) == 0 || !_vm->_vidPlayer->hasVideo(slot)) {
-		props.noBlock = true;
-	}
-
 	if ((props.slot == 1 && !(props.flags & VideoPlayer::kFlagNoVideo) && _vm->_vidPlayer->hasVideo(slot)) ||
 		startFrameCopy == -20) {
 		props.loop = true;


Commit: b48a7e9c3f3f1760fe0a56ebcdf211d9b88ca51b
    https://github.com/scummvm/scummvm/commit/b48a7e9c3f3f1760fe0a56ebcdf211d9b88ca51b
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2026-11-15T02:03:16+01:00

Commit Message:
GOB: Fix frame number written in game variables by updateVideos

The next frame to decode should be written instead of the current one

Fix some song videos not being played until the end in Adi4/Anglais

Changed paths:
    engines/gob/videoplayer.cpp


diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index 4813aa631c9..dc3538c1842 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -678,7 +678,7 @@ void VideoPlayer::updateVideos(bool force, int exceptSlot) {
 
 			Video *video = getVideoBySlot(i);
 			if (video) {
-				WRITE_VAR(53 + i, video->decoder->getCurFrame() + video->decoder->getNbFramesPastEnd());
+				WRITE_VAR(53 + i, video->decoder->getCurFrame() + video->decoder->getNbFramesPastEnd() + 1);
 			}
 		}
 
@@ -750,7 +750,7 @@ void VideoPlayer::updateVideo(int slot, bool force) {
 
 	if ((_vm->getGameType() == kGameTypeAdibou2 || _vm->getGameType() == kGameTypeAdi4)
 			&& slot < kVideoSlotWithCurFrameVarCount)
-		WRITE_VAR(53 + slot, video->decoder->getCurFrame() + video->decoder->getNbFramesPastEnd());
+		WRITE_VAR(53 + slot, video->decoder->getCurFrame() + video->decoder->getNbFramesPastEnd() + 1);
 
 	if (video->properties.fade) {
 		_vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0);




More information about the Scummvm-git-logs mailing list