[Scummvm-cvs-logs] SF.net SVN: scummvm:[55202] scummvm/trunk/graphics/video

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Jan 11 18:27:31 CET 2011


Revision: 55202
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55202&view=rev
Author:   mthreepwood
Date:     2011-01-11 17:27:31 +0000 (Tue, 11 Jan 2011)

Log Message:
-----------
VIDEO: Add a SeekableVideoDecoder class

Modified Paths:
--------------
    scummvm/trunk/graphics/video/video_decoder.cpp
    scummvm/trunk/graphics/video/video_decoder.h

Modified: scummvm/trunk/graphics/video/video_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/video_decoder.cpp	2011-01-11 16:50:26 UTC (rev 55201)
+++ scummvm/trunk/graphics/video/video_decoder.cpp	2011-01-11 17:27:31 UTC (rev 55202)
@@ -121,4 +121,16 @@
 	return beginTime.toInt();
 }
 
+VideoTimestamp::VideoTimestamp() : _units(0), _scale(1) {
+}
+
+VideoTimestamp::VideoTimestamp(uint units, uint scale) : _units(units), _scale(scale) {
+	assert(_scale);
+}
+
+uint VideoTimestamp::getUnitsInScale(uint scale) const {
+	assert(scale);
+	return (_scale == scale) ? _units : _units * scale / _scale;
+}
+
 } // End of namespace Graphics

Modified: scummvm/trunk/graphics/video/video_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/video_decoder.h	2011-01-11 16:50:26 UTC (rev 55201)
+++ scummvm/trunk/graphics/video/video_decoder.h	2011-01-11 17:27:31 UTC (rev 55202)
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef GRAPHICS_VIDEO_PLAYER_H
-#define GRAPHICS_VIDEO_PLAYER_H
+#ifndef GRAPHICS_VIDEO_DECODER_H
+#define GRAPHICS_VIDEO_DECODER_H
 
 #include "common/events.h"
 #include "common/list.h"
@@ -177,7 +177,7 @@
 	virtual void addPauseTime(uint32 ms) { _startTime += ms; }
 
 	int32 _curFrame;
-	uint32 _startTime;
+	int32 _startTime;
 
 private:
 	uint32 _pauseLevel;
@@ -214,6 +214,72 @@
 	virtual void rewind() = 0;
 };
 
+/**
+ * A simple video timestamp that holds time according to a specific scale.
+ *
+ * The scale is in terms of 1/x. For example, if you set units to 1 and the scale to 
+ * 1000, the timestamp will hold the value of 1/1000s or 1ms.
+ */
+class VideoTimestamp {
+public:
+	VideoTimestamp();
+	VideoTimestamp(uint units, uint scale = 1000);
+
+	/**
+	 * Get the units in terms of _scale
+	 */
+	uint getUnits() const { return _units; }
+
+	/**
+	 * Get the scale of this timestamp
+	 */
+	uint getScale() const { return _scale; }
+
+	/**
+	 * Get the value of the units in terms of the specified scale
+	 */
+	uint getUnitsInScale(uint scale) const;
+
+	// TODO: Simple comparisons (<, <=, >, >=, ==, !=)
+
+private:
+	uint _units, _scale;
+};
+
+/**
+ * A VideoDecoder that can seek to a frame or point in time.
+ */
+class SeekableVideoDecoder : public virtual RewindableVideoDecoder {
+public:
+	/**
+	 * Seek to the frame specified
+	 * If seekToFrame(0) is called, frame 0 will be decoded next in decodeNextFrame()
+	 */
+	virtual void seekToFrame(uint32 frame) = 0;
+
+	/**
+	 * Seek to the time specified
+	 *
+	 * This will round to the previous frame showing. If the time would happen to
+	 * land while a frame is showing, this function will seek to the beginning of that
+	 * frame. In other words, there is *no* subframe accuracy. This may change in a
+	 * later revision of the API.
+	 */
+	virtual void seekToTime(VideoTimestamp time) = 0;
+
+	/**
+	 * Seek to the frame specified (in ms)
+	 *
+	 * See seekToTime(VideoTimestamp)
+	 */
+	void seekToTime(uint32 time) { seekToTime(VideoTimestamp(time)); }
+
+	/**
+	 * Implementation of RewindableVideoDecoder::rewind()
+	 */
+	virtual void rewind() { seekToTime(0); }
+};
+
 } // End of namespace Graphics
 
 #endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list