aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2013-09-01 17:19:58 -0400
committerMatthew Hoops2014-08-17 12:24:28 -0400
commit422922fec206b768de8e2a9333851b366bd13fd4 (patch)
treeab6e955d04af83cffcc288b19d409f1901e7ab6b
parent9a5b3bfddabd86205eefacc459a7887b4e735122 (diff)
downloadscummvm-rg350-422922fec206b768de8e2a9333851b366bd13fd4.tar.gz
scummvm-rg350-422922fec206b768de8e2a9333851b366bd13fd4.tar.bz2
scummvm-rg350-422922fec206b768de8e2a9333851b366bd13fd4.zip
VIDEO: Add wrapper around setEndTime() to specify an end frame
-rw-r--r--video/video_decoder.cpp25
-rw-r--r--video/video_decoder.h11
2 files changed, 36 insertions, 0 deletions
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index c6171c4450..dce96aae03 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -778,6 +778,31 @@ void VideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
}
}
+void VideoDecoder::setEndFrame(uint frame) {
+ VideoTrack *track = 0;
+
+ for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
+ if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
+ // We only allow this when one video track is present
+ if (track)
+ return;
+
+ track = (VideoTrack *)*it;
+ }
+ }
+
+ // If we didn't find a video track, we can't set the final frame (of course)
+ if (!track)
+ return;
+
+ Audio::Timestamp time = track->getFrameTime(frame + 1);
+
+ if (time < 0)
+ return;
+
+ setEndTime(time);
+}
+
VideoDecoder::Track *VideoDecoder::getTrack(uint track) {
if (track > _internalTracks.size())
return 0;
diff --git a/video/video_decoder.h b/video/video_decoder.h
index 2faec0fb3e..c3879e9144 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -214,6 +214,17 @@ public:
void setEndTime(const Audio::Timestamp &endTime);
/**
+ * Set the end frame.
+ *
+ * The passed frame will be the last frame to show.
+ *
+ * Like seekToFrame(), this only works when one video track is present,
+ * and that track supports getFrameTime(). This calls setEndTime()
+ * internally.
+ */
+ void setEndFrame(uint frame);
+
+ /**
* Get the stop time of the video (if not set, zero)
*/
Audio::Timestamp getEndTime() const { return _endTime; }