[xiph-commits] r7342 - in trunk/oggdsf/src: lib/core/ogg/libOOOgg

illiminable at dactyl.lonelymoon.com illiminable
Sun Jul 25 20:20:22 PDT 2004


tools/OOOggDump tools/OOOggStat tools/OOOggValidate
Message-ID: <20040726032022.36C059AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Sun Jul 25 20:20:22 2004
New Revision: 7342

Modified:
trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h
trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggSegmentTable.h
trunk/oggdsf/src/tools/OOOggDump/OOOggDump.cpp
trunk/oggdsf/src/tools/OOOggStat/OOOggStat.cpp
trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp
Log:
* More changes to the demuxer

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/CircularBuffer.cpp	2004-07-26 03:20:21 UTC (rev 7342)
@@ -64,10 +64,7 @@
////


-		return (mBufferSize + mWritePtr - mReadPtr);
-
-
-
+		return  (mBufferSize + mWritePtr - mReadPtr);
} else {
//if (mReadPtr <= mWritePtr)
return mWritePtr - mReadPtr;

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/IFIFOBuffer.h	2004-07-26 03:20:21 UTC (rev 7342)
@@ -1,3 +1,5 @@
+#pragma once
+#include "dllstuff.h"
class LIBOOOGG_API IFIFOBuffer {
public:
virtual unsigned long read(unsigned char* outData, unsigned long inBytesToRead) = 0;

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2004-07-26 03:20:21 UTC (rev 7342)
@@ -33,7 +33,10 @@
#include ".\oggdatabuffer.h"

OggDataBuffer::OggDataBuffer(void)
+	:	mBuffer(NULL)
{
+	mBuffer = new CircularBuffer(MAX_OGG_PAGE_SIZE);
+
debugLog.open("G:\\logs\\OggDataBuffer.log", ios_base::out);
pendingPage = NULL;
mState = AWAITING_BASE_HEADER;
@@ -42,7 +45,10 @@

//Debug only
OggDataBuffer::OggDataBuffer(bool x)
+	:	mBuffer(NULL)
{
+	mBuffer = new CircularBuffer(MAX_OGG_PAGE_SIZE);
+
debugLog.open("G:\\logs\\OggDataBufferSeek.log", ios_base::out);
pendingPage = NULL;
mState = AWAITING_BASE_HEADER;
@@ -52,6 +58,7 @@

OggDataBuffer::~OggDataBuffer(void)
{
+	delete mBuffer;
debugLog.close();
delete pendingPage;
}
@@ -85,7 +92,8 @@

unsigned long OggDataBuffer::numBytesAvail() {
//Returns how many bytes are available in the buffer
-	unsigned long locBytesAvail = mStream.tellp() - mStream.tellg();
+
+	unsigned long locBytesAvail = mBuffer->numBytesAvail();				//mStream.tellp() - mStream.tellg();
debugLog<<"Bytes avail = "<<locBytesAvail<<endl;
return locBytesAvail;
}
@@ -129,7 +137,7 @@
return true;
}

-OggDataBuffer::eFeedResult OggDataBuffer::feed(const char* inData, unsigned long inNumBytes) {
+OggDataBuffer::eFeedResult OggDataBuffer::feed(const unsigned char* inData, unsigned long inNumBytes) {
if (inNumBytes != 0) {
if (inData != NULL) {
//Buffer is not null and there is at least 1 byte of data.
@@ -138,12 +146,15 @@

///STREAM ACCESS::: WRite
//Write the data into the stream buffer
-			mStream.write(inData, inNumBytes);
+
+			//mStream.write(inData, inNumBytes);
+			mBuffer->write(inData, inNumBytes);

-			if(mStream.fail()) {
-				debugLog<<"ProcessBaseHeader : Buffer write Write FAILED"<<endl;
-				return FEED_BUFFER_WRITE_ERROR;
-			}
+
+			//if(mStream.fail()) {
+			//	debugLog<<"ProcessBaseHeader : Buffer write Write FAILED"<<endl;
+			//	return FEED_BUFFER_WRITE_ERROR;
+			//}

return (eFeedResult)processBuffer();

@@ -178,13 +189,14 @@

//STREAM ACCESS::: Read
//Read from the stream buffer to it
-		mStream.read((char*)locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);
+		//mStream.read((char*)locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);
+		mBuffer->read(locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);

-		if(mStream.fail()) {
-			debugLog<<"ProcessBaseHeader : File Read FAILED"<<endl;
-			delete locBuff;
-			return PROCESS_STREAM_READ_ERROR;
-		}
+		//if(mStream.fail()) {
+		//	debugLog<<"ProcessBaseHeader : File Read FAILED"<<endl;
+		//	delete locBuff;
+		//	return PROCESS_STREAM_READ_ERROR;
+		//}

//Set the base header into the pending page

@@ -225,13 +237,14 @@

debugLog<<"ProcessSegTable : Reading from buffer..."<<endl;

-	//Read from the stream buffer to it
-	mStream.read((char*)locBuff, (std::streamsize)locNumSegs);
-	if(mStream.fail()) {
-		debugLog<<"ProcessSegTable : Read FAILED"<<endl;
-		delete locBuff;
-		return PROCESS_STREAM_READ_ERROR;
-	}
+	//Read the segment table from the buffer to locBuff
+	//mStream.read((char*)locBuff, (std::streamsize)locNumSegs);
+	mBuffer->read(locBuff, (std::streamsize)locNumSegs);
+	//if(mStream.fail()) {
+	//	debugLog<<"ProcessSegTable : Read FAILED"<<endl;
+	//	delete locBuff;
+	//	return PROCESS_STREAM_READ_ERROR;
+	//}

//TODAY::: Check out the page header class.

@@ -303,8 +316,10 @@

//STREAM ACCESS:::
//Read data from the stream into the local buffer.
-			mStream.read((char*)(locBuff), locCurrPackSize);
+			//mStream.read((char*)(locBuff), locCurrPackSize);
+			mBuffer->read(locBuff, locCurrPackSize);

+
//FIX::: check for stream failure.

debugLog<<"ProcessDataSegment : Adding packet size = "<<locCurrPackSize<<endl;
@@ -337,16 +352,18 @@

}
void OggDataBuffer::clearData() {
-	mStream.clear();
-	mStream.flush();
-	mStream.seekg(0, ios_base::beg);
-	mStream.seekp(0, ios_base::beg);
+	mBuffer->reset();
+	//mStream.clear();
+	//mStream.flush();
+	//mStream.seekg(0, ios_base::beg);
+	//mStream.seekp(0, ios_base::beg);

debugLog<<"ClearData : Transition back to AWAITING_BASE_HEADER"<<endl;

+
+	mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
mState = eState::AWAITING_BASE_HEADER;
-	mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
-
+
debugLog<<"ClearData : Num bytes needed = "<<mNumBytesNeeded<<endl;
}


Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2004-07-26 03:20:21 UTC (rev 7342)
@@ -30,10 +30,12 @@
//===========================================================================

#pragma once
-#include <sstream>
+//#include <sstream>
+#include "CircularBuffer.h"
#include "OggPage.h"
#include "SerialNoRego.h"
#include "IOggCallback.h"
+#include "IFIFOBuffer.h"

//Only needed for debugging
#include <fstream>
@@ -68,6 +70,12 @@
PROCESS_LOST_SYNC

};
+
+	static const int MAX_OGG_PAGE_SIZE =	OggPageHeader::OGG_BASE_HEADER_SIZE +											//Header
+											(OggSegmentTable::MAX_NUM_SEGMENTS * OggSegmentTable::MAX_SEGMENT_SIZE) +		//Page Data
+											(OggSegmentTable::SEGMENT_WIDTH * OggSegmentTable::MAX_NUM_SEGMENTS);			//Segment table
+
+
OggDataBuffer(void);
//Debug only
OggDataBuffer::OggDataBuffer(bool x);
@@ -80,7 +88,7 @@

void clearData();

-	OggDataBuffer::eFeedResult feed(const char* inData, unsigned long inNumBytes);
+	OggDataBuffer::eFeedResult feed(const unsigned char* inData, unsigned long inNumBytes);

//FIX ::: Add later
//void unRegisterSerialNo(unsigned long inSerialNo);
@@ -94,7 +102,9 @@
//

protected:
-	stringstream mStream;
+
+	//stringstream mStream;
+	IFIFOBuffer* mBuffer;
eState mState;

eProcessResult processBuffer();

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPageHeader.h	2004-07-26 03:20:21 UTC (rev 7342)
@@ -136,8 +136,10 @@
unsigned long mPageSequenceNo;
unsigned long mCRCChecksum;
unsigned char mNumPageSegments;
-	OggSegmentTable* mSegmentTable;

+	unsigned char[255] mSegmentTable;
+	//OggSegmentTable* mSegmentTable;
+
ePageState mPageState;

};

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggSegmentTable.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggSegmentTable.h	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggSegmentTable.h	2004-07-26 03:20:21 UTC (rev 7342)
@@ -35,6 +35,11 @@

{
public:
+
+	static const int MAX_NUM_SEGMENTS = 255;
+	static const int MAX_SEGMENT_SIZE = 255;
+	static const int SEGMENT_WIDTH = 1;
+
OggSegmentTable();
~OggSegmentTable(void);
OggSegmentTable* clone();

Modified: trunk/oggdsf/src/tools/OOOggDump/OOOggDump.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggDump/OOOggDump.cpp	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/tools/OOOggDump/OOOggDump.cpp	2004-07-26 03:20:21 UTC (rev 7342)
@@ -90,7 +90,7 @@
while (!testFile.eof()) {
testFile.read(locBuff, BUFF_SIZE);
unsigned long locBytesRead = testFile.gcount();
-    		testOggBuff.feed(locBuff, locBytesRead);
+    		testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
}

delete locBuff;

Modified: trunk/oggdsf/src/tools/OOOggStat/OOOggStat.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggStat/OOOggStat.cpp	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/tools/OOOggStat/OOOggStat.cpp	2004-07-26 03:20:21 UTC (rev 7342)
@@ -115,7 +115,7 @@
while (!testFile.eof()) {
testFile.read(locBuff, BUFF_SIZE);
unsigned long locBytesRead = testFile.gcount();
-    		testOggBuff.feed(locBuff, locBytesRead);
+    		testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
}

delete locBuff;

Modified: trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp
===================================================================
--- trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp	2004-07-26 00:54:52 UTC (rev 7341)
+++ trunk/oggdsf/src/tools/OOOggValidate/OOOggValidate.cpp	2004-07-26 03:20:21 UTC (rev 7342)
@@ -190,7 +190,7 @@
while (!testFile.eof()) {
testFile.read(locBuff, BUFF_SIZE);
unsigned long locBytesRead = testFile.gcount();
-    		locResult = testOggBuff.feed(locBuff, locBytesRead);
+    		locResult = testOggBuff.feed((const unsigned char*)locBuff, locBytesRead);
switch(locResult) {
case OVE_OK:
break;



More information about the commits mailing list