aboutsummaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorTorbjörn Andersson2018-06-26 19:16:28 +0200
committerThierry Crozat2018-11-04 22:33:22 +0100
commita5b5b68a1a1a5453b9aa8025e3a95cc10d0718d4 (patch)
treeff326b71177dbe1f9b165f77db99f401611cda65 /video
parent1255e8de4db11e3bdfaa2461cc72be6a74daa16c (diff)
downloadscummvm-rg350-a5b5b68a1a1a5453b9aa8025e3a95cc10d0718d4.tar.gz
scummvm-rg350-a5b5b68a1a1a5453b9aa8025e3a95cc10d0718d4.tar.bz2
scummvm-rg350-a5b5b68a1a1a5453b9aa8025e3a95cc10d0718d4.zip
VIDEO: Use all video PTS's
Sometimes (only at the very start of a movie?) there will be a video packet that has a PTS but no frame to display. Save that PTS and use it for the next frame. This doesn't actually improve anything, as far as I can tell, but feels right.
Diffstat (limited to 'video')
-rw-r--r--video/mpegps_decoder.cpp17
-rw-r--r--video/mpegps_decoder.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/video/mpegps_decoder.cpp b/video/mpegps_decoder.cpp
index ee71ce268d..01db2b4e8a 100644
--- a/video/mpegps_decoder.cpp
+++ b/video/mpegps_decoder.cpp
@@ -440,6 +440,7 @@ MPEGPSDecoder::MPEGVideoTrack::MPEGVideoTrack(Common::SeekableReadStream *firstP
_surface = 0;
_endOfTrack = false;
_curFrame = -1;
+ _framePts = 0xFFFFFFFF;
_nextFrameStartTime = Audio::Timestamp(0, 27000000); // 27 MHz timer
findDimensions(firstPacket, format);
@@ -481,21 +482,27 @@ const Graphics::Surface *MPEGPSDecoder::MPEGVideoTrack::decodeNextFrame() {
bool MPEGPSDecoder::MPEGVideoTrack::sendPacket(Common::SeekableReadStream *packet, uint32 pts, uint32 dts) {
#ifdef USE_MPEG2
+ if (pts != 0xFFFFFFFF) {
+ _framePts = pts;
+ }
+
uint32 framePeriod;
bool foundFrame = _mpegDecoder->decodePacket(*packet, framePeriod, _surface);
if (foundFrame) {
_curFrame++;
- // If there is a presentation timestamp, use that for sync. Almost all
- // packets with a presentation timestamp will have a found frame, so
- // it is probably not worth the trouble worrying about when they don't.
+ // If there has been a timestamp since the previous frame, use that for
+ // syncing. Usually it will be the timestamp from the current packet,
+ // but it might not be.
- if (pts != 0xFFFFFFFF) {
- _nextFrameStartTime = Audio::Timestamp(pts / 90, 27000000);
+ if (_framePts != 0xFFFFFFFF) {
+ _nextFrameStartTime = Audio::Timestamp(_framePts / 90, 27000000);
} else {
_nextFrameStartTime = _nextFrameStartTime.addFrames(framePeriod);
}
+
+ _framePts = 0xFFFFFFFF;
}
#endif
diff --git a/video/mpegps_decoder.h b/video/mpegps_decoder.h
index 74167a714f..6111fe8b45 100644
--- a/video/mpegps_decoder.h
+++ b/video/mpegps_decoder.h
@@ -100,6 +100,7 @@ private:
private:
bool _endOfTrack;
int _curFrame;
+ uint32 _framePts;
Audio::Timestamp _nextFrameStartTime;
Graphics::Surface *_surface;