[xiph-commits] r8641 - in trunk/oggdsf: sln/oggdsf_all
src/lib/core/ogg/libOOOggSeek src/tools/OOOggSeekFileReader
ozone at motherfish-iii.xiph.org
ozone at motherfish-iii.xiph.org
Thu Jan 6 04:37:59 PST 2005
Author: ozone
Date: 2005-01-06 04:37:58 -0800 (Thu, 06 Jan 2005)
New Revision: 8641
Modified:
trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.h
trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.cpp
trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.vcproj
Log:
oggdsf:
* Add buildTableFrom{Buffer,File} methods to AutoOggSeekTable class
* Add getSeekMap method to OggSeekTable class
* Add a bit more documentation to libOOOggSeek's classes
Modified: trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln
===================================================================
--- trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/sln/oggdsf_all/oggdsf_all.sln 2005-01-06 12:37:58 UTC (rev 8641)
@@ -1089,6 +1089,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OOOggSeekFileReader", "..\..\src\tools\OOOggSeekFileReader\OOOggSeekFileReader.vcproj", "{F6B75B61-4BEF-4323-B15E-37AFFC9CB52A}"
ProjectSection(ProjectDependencies) = postProject
+ {223ACC19-608E-4E1B-A054-067F0CACB272} = {223ACC19-608E-4E1B-A054-067F0CACB272}
+ {9A14F6AC-BC6E-401A-A300-07369BD6C5FE} = {9A14F6AC-BC6E-401A-A300-07369BD6C5FE}
{2DA569EC-3E22-4BC9-A242-C7A56EB9C6F4} = {2DA569EC-3E22-4BC9-A242-C7A56EB9C6F4}
EndProjectSection
EndProject
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp 2005-01-06 12:37:58 UTC (rev 8641)
@@ -279,3 +279,60 @@
return true;
}
+
+bool AutoOggSeekTable::buildTableFromBuffer(const unsigned char *inBuffer, const unsigned long inBufferSize)
+{
+ for (const unsigned char *locBufferPosition = inBuffer; locBufferPosition < inBuffer + inBufferSize; ) {
+ LOOG_INT64 locTimePoint = iLE_Math::CharArrToInt64(locBufferPosition);
+ locBufferPosition += 8;
+
+ unsigned long locBytePosition = iLE_Math::charArrToULong(locBufferPosition);
+ locBufferPosition += 4;
+
+ addSeekPoint(locTimePoint, locBytePosition);
+ }
+
+ return true;
+}
+
+/** Note that this method does not do any verification that the file is
+ up-to-date or valid (i.e. if you are using the serialised seek table
+ as a cache, you must check yourself that the cached seek table is not
+ out of date).
+ */
+bool AutoOggSeekTable::buildTableFromFile(const string inCachedSeekTableFilename)
+{
+ LOOG_INT64 locTimePoint;
+ unsigned long locBytePosition;
+
+ fstream locSeekFile;
+ locSeekFile.open(inCachedSeekTableFilename.c_str(), ios_base::in | ios_base::binary);
+
+ // Look ma, we got us zergling-size buffer
+ unsigned char* locBuffer = new unsigned char[16];
+
+ while (!locSeekFile.eof()) {
+ locSeekFile.read((char*)locBuffer, 8);
+ if (locSeekFile.gcount() == 8) {
+ locTimePoint = iLE_Math::CharArrToInt64(locBuffer);
+
+ locSeekFile.read((char*)locBuffer, 4);
+ if (locSeekFile.gcount() == 4) {
+ locBytePosition = iLE_Math::charArrToULong(locBuffer);
+ } else {
+ delete[] locBuffer;
+ return false;
+ }
+
+ addSeekPoint(locTimePoint, locBytePosition);
+ } else {
+ delete [] locBuffer;
+ return false;
+ }
+ }
+
+ delete [] locBuffer;
+
+ return true;
+}
+
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h 2005-01-06 12:37:58 UTC (rev 8641)
@@ -51,26 +51,38 @@
, public IOggCallback
{
public:
+
+ // TODO: We really should modify AutoOggSeekTable so that passing in a
+ // filename isn't required, if all we want is a seek table with no
+ // associated file ...
+
+ /// Create a new AutoOggSeekTable associated with the filename passed into inFileName.
AutoOggSeekTable(string inFileName);
virtual ~AutoOggSeekTable(void);
static const LOOG_INT64 DS_UNITS = 10000000;
static const unsigned long LINT_MAX = 4294967295UL;
- /// Builds the actual seek table: only works if we have random access to the file
+ /// Builds the actual seek table: only works if we have random access to the file.
virtual bool buildTable();
//IOggCallback interface
virtual bool acceptOggPage(OggPage* inOggPage);
- /// The duration of the file, in DirectShow time units
+ /// The duration of the file, in DirectShow time units.
LOOG_INT64 fileDuration();
unsigned long serialisedSize();
- /// Serialise the seek table into a memory buffer, which may be useful for e.g. caching
+ /// Serialise the seek table into a memory buffer, which may be useful for e.g. caching.
bool serialiseInto(unsigned char* inBuff, unsigned long inBuffSize);
+ /// Build a seek table from a buffer previously written to with serialiseInto().
+ virtual bool buildTableFromBuffer(const unsigned char *inBuffer, const unsigned long inBufferSize);
+
+ /// Build a seek table from a file previously serialised into with serialiseInto().
+ virtual bool buildTableFromFile(const string inCachedSeekTableFilename);
+
protected:
unsigned long mFilePos;
unsigned long mPacketCount;
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.cpp 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.cpp 2005-01-06 12:37:58 UTC (rev 8641)
@@ -49,7 +49,8 @@
bool OggSeekTable::enabled() {
return mEnabled;
}
-bool OggSeekTable::addSeekPoint(LOOG_INT64 inTime, unsigned long mStartPos) {
+bool OggSeekTable::addSeekPoint(LOOG_INT64 inTime, unsigned long mStartPos)
+{
//stDebug<< "Add Point : Time = "<<inTime<<" -- Byte Pos : "<<mStartPos<<endl;
mSeekMap.insert(tSeekMap::value_type(inTime, mStartPos));
@@ -61,8 +62,10 @@
/** Returns a tSeekPair whose first element is the
actual closest possible time that can be seeked to (which will always be either before or at
the requested seek position). The second element is the number of bytes into the stream where
- the first page of the actual seek time occurs. */
-OggSeekTable::tSeekPair OggSeekTable::getStartPos(LOOG_INT64 inTime) {
+ the first page of the actual seek time occurs.
+ */
+OggSeekTable::tSeekPair OggSeekTable::getStartPos(LOOG_INT64 inTime)
+{
// Finds the upper bound of the requested time in mSeekMap, which will always be in the range
// (0, maxItems], and return the element _before_ the upper bound
return *(--(mSeekMap.upper_bound(inTime)));
@@ -70,3 +73,13 @@
//stDebug<<"Get Point : Time Req = "<<inTime<<" -- Time Given = "<<mRealStartPos<<" -- Byte Pos : "<<locValue.second<<endl;
//return locValue.second;
}
+
+/** Note that this method returns a copy of the seek table, not the actual seek table used by
+ the class. So, feel free to corrupt your copy to your heart's leisure.
+ */
+OggSeekTable::tSeekMap OggSeekTable::getSeekMap()
+{
+ tSeekMap locSeekMap = mSeekMap;
+
+ return locSeekMap;
+}
Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.h 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/OggSeekTable.h 2005-01-06 12:37:58 UTC (rev 8641)
@@ -46,10 +46,15 @@
virtual ~OggSeekTable(void);
typedef pair<LOOG_INT64, unsigned long> tSeekPair;
+ typedef map<LOOG_INT64, unsigned long> tSeekMap;
- bool addSeekPoint(LOOG_INT64 inTime, unsigned long mStartPos);
+ /// Returns a copy of the seek table.
+ tSeekMap getSeekMap();
- /// Given a requested seek time in nanoseconds, returns the closest time and byte to the seek time.
+ /// Add a seek point (which consists of a time in DirectShow units, and a byte offset corresponding to that time) to the seek table.
+ bool addSeekPoint(LOOG_INT64 inTime, unsigned long inStartPos);
+
+ /// Given a requested seek time in DirectShow units, returns the closest time and byte to the seek time.
tSeekPair getStartPos(LOOG_INT64 inTime);
//LOOG_INT64 getRealStartPos();
@@ -59,7 +64,6 @@
OggSeekTable &operator=(const OggSeekTable&); // Don't assign men
protected:
- typedef map<LOOG_INT64, unsigned long> tSeekMap;
tSeekMap mSeekMap;
tSeekMap::value_type mSeekValue;
LOOG_INT64 mRealStartPos;
Modified: trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.cpp 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.cpp 2005-01-06 12:37:58 UTC (rev 8641)
@@ -5,8 +5,12 @@
#include <libilliCore/illicoreconfig.h>
#include <libilliCore/iLE_Math.h>
+
+#include <libOOOggSeek/AutoOggSeekTable.h>
+
#include <iostream>
#include <fstream>
+
using namespace std;
#ifdef WIN32
@@ -20,6 +24,7 @@
cout << "Usage : OOOggSeekFileReader <seek_table_file>"<<endl;
} else {
+#if 0
LOOG_INT64 timePoint;
unsigned long bytePos;
@@ -44,6 +49,21 @@
}
delete [] buff;
+#else
+ AutoOggSeekTable *locSeekTable = new AutoOggSeekTable("foo"); // Filename doesn't matter
+ locSeekTable->buildTableFromFile(argv[1]);
+ OggSeekTable::tSeekMap locSeekMap = locSeekTable->getSeekMap();
+
+ for (map<LOOG_INT64, unsigned long>::iterator i = locSeekMap.begin(); i != locSeekMap.end(); i++) {
+ OggSeekTable::tSeekPair locSeekPair = *i;
+ LOOG_UINT64 locTimePoint = locSeekPair.first;
+ unsigned long locBytePosition = locSeekPair.second;
+ cout << "Seek point: time " << locTimePoint << " at byte offset " << locBytePosition << endl;
+ }
+
+ delete [] locSeekTable;
+
+#endif
}
return 0;
}
Modified: trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.vcproj
===================================================================
--- trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.vcproj 2005-01-06 12:32:19 UTC (rev 8640)
+++ trunk/oggdsf/src/tools/OOOggSeekFileReader/OOOggSeekFileReader.vcproj 2005-01-06 12:37:58 UTC (rev 8641)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\lib\helper"
+ AdditionalIncludeDirectories="..\..\lib\helper;..\..\lib\core\ogg"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -68,7 +68,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\..\lib\helper"
+ AdditionalIncludeDirectories="..\..\lib\helper;..\..\lib\core\ogg"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="3"
More information about the commits
mailing list