[Scummvm-cvs-logs] scummvm master -> 254f0fcc0639c48228c776858e4d0986d5874c88
clone2727
clone2727 at gmail.com
Wed Aug 28 06:19:37 CEST 2013
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2d8d80177e VIDEO: Make getFrameAtTime() public
85614b0de4 VIDEO: Separate external and internal tracks
7a8689538a VIDEO: Use the main isSeekable() in seekToFrame()
254f0fcc06 VIDEO: Improve accuracy of getFrameTime() and getFrameAtTime()
Commit: 2d8d80177e9f548263cf47f729053d3a8e990020
https://github.com/scummvm/scummvm/commit/2d8d80177e9f548263cf47f729053d3a8e990020
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-08-27T21:04:57-07:00
Commit Message:
VIDEO: Make getFrameAtTime() public
Changed paths:
video/video_decoder.h
diff --git a/video/video_decoder.h b/video/video_decoder.h
index 7811734..b36c31d 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -594,17 +594,17 @@ protected:
virtual Audio::Timestamp getDuration() const;
Audio::Timestamp getFrameTime(uint frame) const;
- protected:
- /**
- * Get the rate at which this track is played.
- */
- virtual Common::Rational getFrameRate() const = 0;
-
/**
* Get the frame that should be displaying at the given time. This is
* helpful for someone implementing seek().
*/
uint getFrameAtTime(const Audio::Timestamp &time) const;
+
+ protected:
+ /**
+ * Get the rate at which this track is played.
+ */
+ virtual Common::Rational getFrameRate() const = 0;
};
/**
Commit: 85614b0de470b8a324b1f54827b2aa14ba07c1fe
https://github.com/scummvm/scummvm/commit/85614b0de470b8a324b1f54827b2aa14ba07c1fe
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-08-27T21:05:05-07:00
Commit Message:
VIDEO: Separate external and internal tracks
Prevents subclasses from having access to any audio track added from another file
Changed paths:
video/video_decoder.cpp
video/video_decoder.h
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index a512a49..106e1db 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -62,6 +62,8 @@ void VideoDecoder::close() {
delete *it;
_tracks.clear();
+ _internalTracks.clear();
+ _externalTracks.clear();
_dirtyPalette = false;
_palette = 0;
_startTime = 0;
@@ -340,6 +342,11 @@ bool VideoDecoder::seek(const Audio::Timestamp &time) {
if (!seekIntern(time))
return false;
+ // Seek any external track too
+ for (TrackListIterator it = _externalTracks.begin(); it != _externalTracks.end(); it++)
+ if (!(*it)->seek(time))
+ return false;
+
_lastTimeChange = time;
// Now that we've seeked, start all tracks again
@@ -472,7 +479,7 @@ Audio::Timestamp VideoDecoder::getDuration() const {
}
bool VideoDecoder::seekIntern(const Audio::Timestamp &time) {
- for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++)
+ for (TrackList::iterator it = _internalTracks.begin(); it != _internalTracks.end(); it++)
if (!(*it)->seek(time))
return false;
@@ -649,9 +656,14 @@ bool VideoDecoder::StreamFileAudioTrack::loadFromFile(const Common::String &base
return _stream != 0;
}
-void VideoDecoder::addTrack(Track *track) {
+void VideoDecoder::addTrack(Track *track, bool isExternal) {
_tracks.push_back(track);
+ if (isExternal)
+ _externalTracks.push_back(track);
+ else
+ _internalTracks.push_back(track);
+
if (track->getTrackType() == Track::kTrackTypeAudio) {
// Update volume settings if it's an audio track
((AudioTrack *)track)->setVolume(_audioVolume);
@@ -681,7 +693,7 @@ bool VideoDecoder::addStreamFileTrack(const Common::String &baseName) {
bool result = track->loadFromFile(baseName);
if (result)
- addTrack(track);
+ addTrack(track, true);
else
delete track;
@@ -712,17 +724,17 @@ void VideoDecoder::setEndTime(const Audio::Timestamp &endTime) {
}
VideoDecoder::Track *VideoDecoder::getTrack(uint track) {
- if (track > _tracks.size())
+ if (track > _internalTracks.size())
return 0;
- return _tracks[track];
+ return _internalTracks[track];
}
const VideoDecoder::Track *VideoDecoder::getTrack(uint track) const {
- if (track > _tracks.size())
+ if (track > _internalTracks.size())
return 0;
- return _tracks[track];
+ return _internalTracks[track];
}
bool VideoDecoder::endOfVideoTracks() const {
diff --git a/video/video_decoder.h b/video/video_decoder.h
index b36c31d..ac6586d 100644
--- a/video/video_decoder.h
+++ b/video/video_decoder.h
@@ -761,8 +761,11 @@ protected:
* Define a track to be used by this class.
*
* The pointer is then owned by this base class.
+ *
+ * @param track The track to add
+ * @param isExternal Is this an external track not found by loadStream()?
*/
- void addTrack(Track *track);
+ void addTrack(Track *track, bool isExternal = false);
/**
* Whether or not getTime() will sync with a playing audio track.
@@ -814,12 +817,12 @@ protected:
/**
* Get the begin iterator of the tracks
*/
- TrackListIterator getTrackListBegin() { return _tracks.begin(); }
+ TrackListIterator getTrackListBegin() { return _internalTracks.begin(); }
/**
* Get the end iterator of the tracks
*/
- TrackListIterator getTrackListEnd() { return _tracks.end(); }
+ TrackListIterator getTrackListEnd() { return _internalTracks.end(); }
/**
* The internal seek function that does the actual seeking.
@@ -833,6 +836,8 @@ protected:
private:
// Tracks owned by this VideoDecoder
TrackList _tracks;
+ TrackList _internalTracks;
+ TrackList _externalTracks;
// Current playback status
bool _needsUpdate;
Commit: 7a8689538adcfaafa193be6780557a7bd5e8643d
https://github.com/scummvm/scummvm/commit/7a8689538adcfaafa193be6780557a7bd5e8643d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-08-27T21:05:13-07:00
Commit Message:
VIDEO: Use the main isSeekable() in seekToFrame()
Changed paths:
video/video_decoder.cpp
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 106e1db..6424d6f 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -363,12 +363,12 @@ bool VideoDecoder::seek(const Audio::Timestamp &time) {
}
bool VideoDecoder::seekToFrame(uint frame) {
+ if (!isSeekable())
+ return false;
+
VideoTrack *track = 0;
for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
- if (!(*it)->isSeekable())
- return false;
-
if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
// We only allow seeking by frame when one video track
// is present
Commit: 254f0fcc0639c48228c776858e4d0986d5874c88
https://github.com/scummvm/scummvm/commit/254f0fcc0639c48228c776858e4d0986d5874c88
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2013-08-27T21:05:18-07:00
Commit Message:
VIDEO: Improve accuracy of getFrameTime() and getFrameAtTime()
Changed paths:
video/video_decoder.cpp
diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp
index 6424d6f..0ab1478 100644
--- a/video/video_decoder.cpp
+++ b/video/video_decoder.cpp
@@ -531,10 +531,9 @@ Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) con
if (frameRate == frameRate.toInt()) // The nice case (a whole number)
return Audio::Timestamp(0, frame, frameRate.toInt());
- // Just convert to milliseconds.
- Common::Rational time = frame * 1000;
- time /= frameRate;
- return Audio::Timestamp(time.toInt(), 1000);
+ // Convert as best as possible
+ Common::Rational time = frameRate.getInverse() * frame;
+ return Audio::Timestamp(0, time.getNumerator(), time.getDenominator());
}
uint VideoDecoder::FixedRateVideoTrack::getFrameAtTime(const Audio::Timestamp &time) const {
@@ -544,8 +543,10 @@ uint VideoDecoder::FixedRateVideoTrack::getFrameAtTime(const Audio::Timestamp &t
if (frameRate == time.framerate())
return time.totalNumberOfFrames();
- // Default case
- return (time.totalNumberOfFrames() * frameRate / time.framerate()).toInt();
+ // Create the rational based on the time first to hopefully cancel out
+ // *something* when multiplying by the frameRate (which can be large in
+ // some AVI videos).
+ return (Common::Rational(time.totalNumberOfFrames(), time.framerate()) * frameRate).toInt();
}
Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getDuration() const {
More information about the Scummvm-git-logs
mailing list