Browse Source

Merge pull request #1944 from MellowArpeggiation/main

Fix #1943 - Duplicate frames being skipped when decoding Theora
Sasha Szpakowski 2 years ago
parent
commit
6563aec89d
1 changed files with 7 additions and 3 deletions
  1. 7 3
      src/modules/video/theora/TheoraVideoStream.cpp

+ 7 - 3
src/modules/video/theora/TheoraVideoStream.cpp

@@ -232,14 +232,18 @@ void TheoraVideoStream::threadedFillBackBuffer(double dt)
 		th_decode_ycbcr_out(decoder, bufferinfo);
 		hasFrame = true;
 
-		ogg_int64_t granulePosition;
+		ogg_int64_t decoderPosition;
 		do
 		{
 			if (demuxer.readPacket(packet))
 				return;
-		} while (th_decode_packetin(decoder, &packet, &granulePosition) != 0);
+
+			if (packet.granulepos > 0)
+				th_decode_ctl(decoder, TH_DECCTL_SET_GRANPOS, &packet.granulepos, sizeof(packet.granulepos));
+		} while (th_decode_packetin(decoder, &packet, &decoderPosition) != 0);
+
 		lastFrame = nextFrame;
-		nextFrame = th_granule_time(decoder, granulePosition);
+		nextFrame = th_granule_time(decoder, decoderPosition);
 	}
 
 	// Only swap once, even if we read many frames to get here