[Scummvm-git-logs] scummvm master -> 43c5d3e7c9933fdb8da19491f0b7a69d6b688390

bluegr noreply at scummvm.org
Sun Jan 18 10:37:02 UTC 2026


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

Summary:
43c5d3e7c9 VIDEO: fix TheoraDecoder handling of dup frames


Commit: 43c5d3e7c9933fdb8da19491f0b7a69d6b688390
    https://github.com/scummvm/scummvm/commit/43c5d3e7c9933fdb8da19491f0b7a69d6b688390
Author: Dario Scarpa (3518552+darioscarpa at users.noreply.github.com)
Date: 2026-01-18T12:36:58+02:00

Commit Message:
VIDEO: fix TheoraDecoder handling of dup frames

Before this fix, `decodePacket` adjusted `_nextFrameStartTime` and
`_curFrame` only when `th_decode_packetin` returned `0`. But there's
another "non-error" value which can be returned by such function,
`TH_DUPFRAME` (1). This value shows up when a "dup" frame gets decoded,
meaning that playback is proceeding, but there's no need to update
`_surface` (because the contents of the decoded frame buffer have not
changed). Still, one should update `_curFrame` and
`_nextFrameStartTime` to prevent a/v/subtitle sync issues.

Changed paths:
    video/theora_decoder.cpp


diff --git a/video/theora_decoder.cpp b/video/theora_decoder.cpp
index ba771cdf49b..4218a6a4b44 100644
--- a/video/theora_decoder.cpp
+++ b/video/theora_decoder.cpp
@@ -303,13 +303,21 @@ TheoraDecoder::TheoraVideoTrack::~TheoraVideoTrack() {
 }
 
 bool TheoraDecoder::TheoraVideoTrack::decodePacket(ogg_packet &oggPacket) {
-	if (th_decode_packetin(_theoraDecode, &oggPacket, 0) == 0) {
-		_curFrame++;
+	int decodeRes = th_decode_packetin(_theoraDecode, &oggPacket, 0);
+
+	bool gotNewFrame = decodeRes == 0;           // new frame, decoding needed
+	bool gotDupFrame = decodeRes == TH_DUPFRAME; // no decoding needed, just update timing
+	
+	if (gotNewFrame || gotDupFrame) {
+		if (gotNewFrame) {
+			// Convert YUV data to RGB data
+			th_ycbcr_buffer yuv;
+			th_decode_ycbcr_out(_theoraDecode, yuv);
+			translateYUVtoRGBA(yuv);
+		}
 
-		// Convert YUV data to RGB data
-		th_ycbcr_buffer yuv;
-		th_decode_ycbcr_out(_theoraDecode, yuv);
-		translateYUVtoRGBA(yuv);
+		// We set the current frame counter, delegating the calculation to libtheora 
+		_curFrame = (int) th_granule_frame(_theoraDecode, oggPacket.granulepos);
 
 		double time = th_granule_time(_theoraDecode, oggPacket.granulepos);
 




More information about the Scummvm-git-logs mailing list