[xiph-commits] r16925 - in trunk/oggdsf/src/lib: codecs/theora/filters/dsfTheoraDecoder codecs/theora/libs/libOOTheora core/directshow/dsfOggDemux2 core/directshow/dsfOggMux core/ogg/libOOOgg helper/common

cristianadam at svn.xiph.org cristianadam at svn.xiph.org
Fri Feb 19 18:38:34 PST 2010


Author: cristianadam
Date: 2010-02-19 18:38:34 -0800 (Fri, 19 Feb 2010)
New Revision: 16925

Modified:
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.cpp
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.h
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/stdafx.h
   trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
   trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
   trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
   trunk/oggdsf/src/lib/helper/common/util.h
Log:
Fixed bug #1490 - Theroa video resumes after starting to play in wmp 9 (win xp)
Added support for 4:2:2 and 4:4:4 pixel formats.

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -4,7 +4,7 @@
 //Copyright (C) 2003 Commonwealth Scientific and Industrial Research
 //Organisation (CSIRO) Australia
 //
-//Copyright (C) 2008-2009 Cristian Adam
+//Copyright (C) 2008-2010 Cristian Adam
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -156,80 +156,14 @@
 	LOG(logDEBUG) << "Created Theora Decoder Filter";
 
 	m_currentOutputSubType = MEDIASUBTYPE_None;
-	sOutputVideoParams videoParams;
 
-	CMediaType* acceptMediaType = NULL;
-
-	//YUY2 Media Type VideoInfo2
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_YUY2;
-	acceptMediaType->formattype = FORMAT_VideoInfo2;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 16;
-	videoParams.fourCC = MAKEFOURCC('Y','U','Y','2');
-	m_outputVideoParams.push_back(videoParams);
-
-	//YUY2 Media Type VideoInfo
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_YUY2;
-	acceptMediaType->formattype = FORMAT_VideoInfo;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 16;
-	videoParams.fourCC = MAKEFOURCC('Y','U','Y','2');
-	m_outputVideoParams.push_back(videoParams);
-
-	//YV12 media type VideoInfo2
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_YV12;
-	acceptMediaType->formattype = FORMAT_VideoInfo2;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 12;
-	videoParams.fourCC = MAKEFOURCC('Y','V','1','2');
-	m_outputVideoParams.push_back(videoParams);
-
-	//YV12 media type VideoInfo
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_YV12;
-	acceptMediaType->formattype = FORMAT_VideoInfo;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 12;
-	videoParams.fourCC = MAKEFOURCC('Y','V','1','2');
-	m_outputVideoParams.push_back(videoParams);
- 
-	//RGB32 Media Type
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_RGB32;
-	acceptMediaType->formattype = FORMAT_VideoInfo;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 32;
-	videoParams.fourCC = BI_RGB;
-	m_outputVideoParams.push_back(videoParams);
-
-	//RGB565 Media Type
-	acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
-	acceptMediaType->subtype = MEDIASUBTYPE_RGB565;
-	acceptMediaType->formattype = FORMAT_VideoInfo;
-	m_outputMediaTypesList.push_back(acceptMediaType);
-
-	videoParams.bitsPerPixel = 16;
-	videoParams.fourCC = BI_BITFIELDS;
-	m_outputVideoParams.push_back(videoParams);
-
 	m_theoraDecoder = new TheoraDecoder;
 	m_theoraDecoder->initCodec();
 }
 
 TheoraDecodeFilter::~TheoraDecodeFilter() 
 {
-	for (size_t i = 0; i < m_outputMediaTypesList.size(); i++) 
-    {
-		delete m_outputMediaTypesList[i];
-	}
+    std::for_each(m_outputMediaTypesList.begin(), m_outputMediaTypesList.end(), util::Deleter());
 
 	delete m_theoraDecoder;
 	m_theoraDecoder = NULL;
@@ -583,7 +517,8 @@
 
 HRESULT TheoraDecodeFilter::NewSegment(REFERENCE_TIME inStart, REFERENCE_TIME inEnd, double inRate) 
 {
-	LOG(logDEBUG) << "Resetting frame count";
+	LOG(logDEBUG) << __FUNCTIONW__ << " (" << ReferenceTime(inStart) << ", " << ReferenceTime(inEnd) << ", "
+        << inRate << ")";
 	
     ResetFrameCount();
 	m_segStart = inStart;
@@ -601,16 +536,15 @@
 
 	if (locHR != S_OK) 
     {
-		//LOG(logDEBUG) << "Receive : Get pointer failed..." << locHR;	
+        LOG(logERROR) << __FUNCTIONW__ << " Get pointer failed, error: 0x" << std::hex << locHR;	
 		return S_FALSE;
 	}
 
 	if (inInputSample->GetActualDataLength() > 0 && (locBuff[0] & 128) != 0) 
     {
 		//inInputSample->Release();
-
-		//This is a header, so ignore it
-		return S_OK;
+        LOG(logDEBUG) << __FUNCTIONW__ << " This is a header, so ignore it";
+        return S_OK;
 	}
 	
     //Make a copy of the packet buffer
@@ -621,10 +555,12 @@
 	REFERENCE_TIME locEnd = 0;
 	inInputSample->GetTime(&locStart, &locEnd);
 
-	LOG(logDEBUG) << "Theora::Receive - Sample: Size = " << inInputSample->GetActualDataLength() << " Time: " << locStart << " - " << locEnd;
+	LOG(logDEBUG) << __FUNCTIONW__ << " Sample: Size = " << inInputSample->GetActualDataLength() << " Time: " 
+        << locStart << " - " << locEnd;
 
 	//This packet is given to the decoder or buffered for later
-	StampedOggPacket* locPacket = new StampedOggPacket(locNewBuff, inInputSample->GetActualDataLength(), false, false, locStart, locEnd, StampedOggPacket::OGG_END_ONLY);
+	StampedOggPacket* locPacket = new StampedOggPacket(locNewBuff, inInputSample->GetActualDataLength(), 
+                                        false, false, locStart, locEnd, StampedOggPacket::OGG_END_ONLY);
 
 	//Buffer all packets, even if we are about to send them anyway
 	m_bufferedPackets.push_back(locPacket);
@@ -657,20 +593,13 @@
 		locGlobalOffset = locInputPin->GetOutputPinInterface()->getGlobalBaseTime();
 	}
 	
-	LOG(logDEBUG) << "Theora::Receive - " << locNumBufferedFrames << " frames buffered";
+	LOG(logDEBUG) << __FUNCTIONW__ << " " << locNumBufferedFrames << " frames buffered";
 
 	for (unsigned long i = 0; i < locNumBufferedFrames; i++) 
     {
-		LOG(logDEBUG) << "Theora::Receive - Processing buffered frame " << i;
-
 		bool locIsKeyFrame = m_theoraDecoder->isKeyFrame(m_bufferedPackets[i]);
-
-		LOG(logDEBUG) << "Pre theora decode";
-		
         yuv_buffer* locYUV = m_theoraDecoder->decodeTheora(m_bufferedPackets[i]);		//This accept the packet and deletes it
 		
-        LOG(logDEBUG) << "Post theora decode";
-		
         locEnd = locStart + m_frameDuration;
 		REFERENCE_TIME locAdjustedStart = locStart - m_segStart - locGlobalOffset;
 		REFERENCE_TIME locAdjustedEnd = locEnd - m_segStart - locGlobalOffset;
@@ -682,76 +611,68 @@
 
 		if (locAdjustedEnd >= 0) 
         { 
-			if (locYUV != NULL) 
+            if (locYUV == NULL) 
             {
-				IMediaSample* locOutSample = NULL;
+                //XTODO::: We need to trash our buffered packets
+                LOG(logERROR) << __FUNCTIONW__ << " locYUV == NULL";
 
-				LOG(logDEBUG) << "Theora::Receive - Pre output sample initialisation";
+                DeleteBufferedPacketsAfter(i);
+                return S_FALSE;
+            }
+
+			IMediaSample* locOutSample = NULL;
+			
+            locHR = InitializeOutputSample(inInputSample, &locOutSample);
+			if (locHR != S_OK) 
+            {
+				//XTODO::: We need to trash our buffered packets
+                LOG(logERROR) << __FUNCTIONW__ << " Output sample initialization failed, error: 0x" << std::hex << locHR;
 				
-                locHR = InitializeOutputSample(inInputSample, &locOutSample);
-				if (locHR != S_OK) 
+				DeleteBufferedPacketsAfter(i);
+				return S_FALSE;
+			}
+			
+			//REFERENCE_TIME locAdjustedStart = (locStart * RATE_DENOMINATOR) / mRateNumerator;
+			//REFERENCE_TIME locAdjustedEnd = (locEnd * RATE_DENOMINATOR) / mRateNumerator;
+
+			//Fill the sample info
+			if (TheoraDecoded(locYUV, locOutSample, locIsKeyFrame, locAdjustedStart, locAdjustedEnd) != S_OK) 
+            {							
+				//XTODO::: We need to trash our buffered packets
+				locOutSample->Release();
+				DeleteBufferedPacketsAfter(i);
+
+                LOG(logERROR) << __FUNCTIONW__ << " TheoraDecoded failed!";
+				return S_FALSE;
+			} 
+            else 
+            {
+				//Deliver the sample
+				LOG(logDEBUG) << __FUNCTIONW__ << " Delivering: " << ReferenceTime(locAdjustedStart) << " to " << 
+                    ReferenceTime(locAdjustedEnd) << (locIsKeyFrame ? " KEYFRAME": " ");
+				
+				locHR = m_pOutput->Deliver(locOutSample);
+				ULONG locTempRefCount = locOutSample->Release();
+
+				LOG(logDEBUG) << __FUNCTIONW__ << " After deliver refcount = " << locTempRefCount;
+				
+                if (locHR != S_OK) 
                 {
 					//XTODO::: We need to trash our buffered packets
-					LOG(logDEBUG) << "Theora::Receive - Output sample initialisation failed";
-					
-					DeleteBufferedPacketsAfter(i);
-					
-					return S_FALSE;
-				}
-				
-                LOG(logDEBUG) << "Theora::Receive - Output sample initialisation suceeded";
+                    LOG(logERROR) << __FUNCTIONW__ << " Delivery failed, error: 0x" << std::hex << locHR;
 
-				//REFERENCE_TIME locAdjustedStart = (locStart * RATE_DENOMINATOR) / mRateNumerator;
-				//REFERENCE_TIME locAdjustedEnd = (locEnd * RATE_DENOMINATOR) / mRateNumerator;
-
-				//Fill the sample info
-				if (TheoraDecoded(locYUV, locOutSample, locIsKeyFrame, locAdjustedStart, locAdjustedEnd) != S_OK) 
-                {							
-					//XTODO::: We need to trash our buffered packets
-					locOutSample->Release();
+					//locOutSample->Release();
 					DeleteBufferedPacketsAfter(i);
 					return S_FALSE;
-				} 
-                else 
-                {
-					//Deliver the sample
-					LOG(logDEBUG) << "Theora::Receive - Delivering: " << locAdjustedStart << " to " << locAdjustedEnd << (locIsKeyFrame ? "KEYFRAME": " ");
-					
-					locHR = m_pOutput->Deliver(locOutSample);
-					ULONG locTempRefCount = locOutSample->Release();
-
-					LOG(logDEBUG) << "Theora::Receive - After deliver refcount = " << locTempRefCount;
-					LOG(logDEBUG) << "Theora::Receive - Post delivery";
-					
-                    if (locHR != S_OK) 
-                    {
-						//XTODO::: We need to trash our buffered packets
-						LOG(logDEBUG) << "Theora::Receive - Delivery failed";
-						LOG(logDEBUG) << "Theora::Receive - locHR = " << locHR;
-
-						//locOutSample->Release();
-						DeleteBufferedPacketsAfter(i);
-						return S_FALSE;
-					}
-					LOG(logDEBUG) << "Theora::Receive - Delivery Suceeded";
 				}
-			} 
-            else 
-            {
-				//XTODO::: We need to trash our buffered packets
-				LOG(logDEBUG) << "locYUV == NULL";
-
-				DeleteBufferedPacketsAfter(i);
-				return S_FALSE;
 			}
 		}
 		locStart = locEnd;
 	}
 
 	m_bufferedPackets.clear();
+	LOG(logDEBUG) << __FUNCTIONW__ << " Leaving with S_OK";
 
-	LOG(logDEBUG) << "Leaving receive method with S_OK";
-
 	return S_OK;
 }
 
@@ -770,7 +691,7 @@
 	return E_NOTIMPL;
 }
 
-HRESULT TheoraDecodeFilter::DecodeToRGB565(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd)
+void TheoraDecodeFilter::DecodeToRGB565(yuv_buffer* inYUVBuffer, IMediaSample* outSample)
 {
     LOG(logDEBUG) << __FUNCTIONW__;
 
@@ -826,71 +747,119 @@
 		}
 		ptro += m_bmiWidth * 2;
 	}
+}
 
-    SetSampleParams(outSample, m_bmiFrameSize, &inStart, &inEnd, inIsKeyFrame ? TRUE : FALSE);
+void TheoraDecodeFilter::DecodeToRGB32(yuv_buffer* inYUVBuffer, IMediaSample* outSample)
+{
+    th_pixel_fmt pixelFmt = m_theoraDecoder->GetPixelFormat();
 
-	return S_OK;
+    switch (pixelFmt) 
+    {
+    case TH_PF_420:
+        DecodeToRGB32_42x(inYUVBuffer, outSample, false);
+        break;
+    case TH_PF_422:
+        DecodeToRGB32_42x(inYUVBuffer, outSample, true);
+        break;
+    case TH_PF_444:
+        DecodeToRGB32_444(inYUVBuffer, outSample);
+        break;
+    default:
+        LOG(logERROR) << __FUNCTIONW__ << " Unhanded pixel format: " << pixelFmt;
+    }
 }
 
-HRESULT TheoraDecodeFilter::DecodeToRGB32(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd)
+void TheoraDecodeFilter::DecodeToRGB32_42x( yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool fullHeight)
 {
     LOG(logDEBUG) << __FUNCTIONW__;
 
-	unsigned char* locBuffer = NULL;
-	outSample->GetPointer(&locBuffer);
+    unsigned char* locBuffer = NULL;
+    outSample->GetPointer(&locBuffer);
 
     unsigned char * ptry = inYUVBuffer->y + m_yOffset * inYUVBuffer->y_stride;
     unsigned char * ptru = inYUVBuffer->u + (m_yOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptrv = inYUVBuffer->v + (m_yOffset / 2) * inYUVBuffer->uv_stride;
-	unsigned char * ptro = locBuffer;
+    unsigned char * ptro = locBuffer;
 
-	for (unsigned long i = 0; i < m_pictureHeight; i++) 
-	{
-		unsigned char* ptro2 = ptro;
-		for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; j += 2) 
-		{
-			short pr, pg, pb, y;
-			short r, g, b;
+    for (unsigned long i = 0; i < m_pictureHeight; i++) 
+    {
+        unsigned char* ptro2 = ptro;
+        for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; j += 2) 
+        {
+            short pr, pg, pb, y;
+            short r, g, b;
 
-			pr = (-56992 + ptrv[j / 2] * 409) >> 8;
-			pg = (34784 - ptru[j / 2] * 100 - ptrv[j / 2] * 208) >> 8;
-			pb = (short)((-70688 + ptru[j / 2] * 516) >> 8);
+            pr = (-56992 + ptrv[j / 2] * 409) >> 8;
+            pg = (34784 - ptru[j / 2] * 100 - ptrv[j / 2] * 208) >> 8;
+            pb = (short)((-70688 + ptru[j / 2] * 516) >> 8);
 
-			y = 298*ptry[j] >> 8;
-			r = y + pr;
-			g = y + pg;
-			b = y + pb;
+            y = 298*ptry[j] >> 8;
+            r = y + pr;
+            g = y + pg;
+            b = y + pb;
 
-			*ptro2++ = CLAMP(b);
-			*ptro2++ = CLAMP(g);
-			*ptro2++ = CLAMP(r);
-			*ptro2++ = 255;
+            *ptro2++ = CLAMP(b);
+            *ptro2++ = CLAMP(g);
+            *ptro2++ = CLAMP(r);
+            *ptro2++ = 255;
 
-			y = 298*ptry[j + 1] >> 8;
-			r = y + pr;
-			g = y + pg;
-			b = y + pb;
+            y = 298*ptry[j + 1] >> 8;
+            r = y + pr;
+            g = y + pg;
+            b = y + pb;
 
-			*ptro2++ = CLAMP(b);
-			*ptro2++ = CLAMP(g);
-			*ptro2++ = CLAMP(r);
-			*ptro2++ = 255;
-		}
-		ptry += inYUVBuffer->y_stride;
-		if (i & 1) 
-		{
-			ptru += inYUVBuffer->uv_stride;
-			ptrv += inYUVBuffer->uv_stride;
-		}
-		ptro += m_bmiWidth * 4;
-	}
+            *ptro2++ = CLAMP(b);
+            *ptro2++ = CLAMP(g);
+            *ptro2++ = CLAMP(r);
+            *ptro2++ = 255;
+        }
+        ptry += inYUVBuffer->y_stride;
+        if (fullHeight || i & 1) 
+        {
+            ptru += inYUVBuffer->uv_stride;
+            ptrv += inYUVBuffer->uv_stride;
+        }
+        ptro += m_bmiWidth * 4;
+    }
+}
 
-    SetSampleParams(outSample, m_bmiFrameSize, &inStart, &inEnd, inIsKeyFrame ? TRUE : FALSE);
+void TheoraDecodeFilter::DecodeToRGB32_444( yuv_buffer* inYUVBuffer, IMediaSample* outSample )
+{
+    LOG(logDEBUG) << __FUNCTIONW__;
 
-	return S_OK;
+    unsigned char* locBuffer = NULL;
+    outSample->GetPointer(&locBuffer);
+
+    unsigned char * ptry = inYUVBuffer->y + m_yOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + m_yOffset * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + m_yOffset * inYUVBuffer->uv_stride;
+    unsigned char * ptro = locBuffer;
+
+    for (unsigned long i = 0; i < m_pictureHeight; i++) 
+    {
+        unsigned char* ptro2 = ptro;
+        for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; ++j) 
+        {
+            int r = (1904000 * ptry[j] + 2609823 * ptrv[j] - 363703744) / 1635200;
+            int g = (3827562 * ptry[j] - 1287801 * ptru[j] - 2672387 * ptrv[j] + 447306710) / 3287200;
+            int b = (952000 * ptry[j] + 1649289 * ptru[j] - 225932192) / 817600;
+            
+            *ptro2++ = CLAMP(b);
+            *ptro2++ = CLAMP(g);
+            *ptro2++ = CLAMP(r);
+            *ptro2++ = 255;
+        }
+
+        ptry += inYUVBuffer->y_stride;
+        ptru += inYUVBuffer->uv_stride;
+        ptrv += inYUVBuffer->uv_stride;
+
+        ptro += m_bmiWidth * 4;
+    }
 }
 
-HRESULT TheoraDecodeFilter::DecodeToYUY2(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) 
+
+void TheoraDecodeFilter::DecodeToAYUV(yuv_buffer* inYUVBuffer, IMediaSample* outSample)
 {
     LOG(logDEBUG) << __FUNCTIONW__;
 
@@ -898,6 +867,55 @@
     outSample->GetPointer(&locBuffer);
 
     unsigned char * ptry = inYUVBuffer->y + m_yOffset * inYUVBuffer->y_stride;
+    unsigned char * ptru = inYUVBuffer->u + m_yOffset * inYUVBuffer->uv_stride;
+    unsigned char * ptrv = inYUVBuffer->v + m_yOffset * inYUVBuffer->uv_stride;
+    unsigned char * ptro = locBuffer;
+
+    for (unsigned long i = 0; i < m_pictureHeight; ++i) 
+    {
+        unsigned char* ptro2 = ptro;
+        for (unsigned long j = m_xOffset; j < m_pictureWidth + m_xOffset; ++j) 
+        {
+            *ptro2++ = ptrv[j];
+            *ptro2++ = ptru[j];
+            *ptro2++ = ptry[j];
+            *ptro2++ = 255;
+        }
+
+        ptry += inYUVBuffer->y_stride;
+        ptru += inYUVBuffer->uv_stride;
+        ptrv += inYUVBuffer->uv_stride;
+
+        ptro += m_bmiWidth * 4;
+    }
+}
+
+void TheoraDecodeFilter::DecodeToYUY2(yuv_buffer* inYUVBuffer, IMediaSample* outSample) 
+{
+    th_pixel_fmt pixelFmt = m_theoraDecoder->GetPixelFormat();
+
+    switch (pixelFmt) 
+    {
+    case TH_PF_420:
+        DecodeToYUY2_42x(inYUVBuffer, outSample, false);
+        break;
+    case TH_PF_422:
+        DecodeToYUY2_42x(inYUVBuffer, outSample, true);
+        break;
+    default:
+        LOG(logERROR) << __FUNCTIONW__ << " Unhanded pixel format: " << pixelFmt;
+    }
+}
+
+
+void TheoraDecodeFilter::DecodeToYUY2_42x(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool fullHeight)
+{
+    LOG(logDEBUG) << __FUNCTIONW__;
+
+    unsigned char* locBuffer = NULL;
+    outSample->GetPointer(&locBuffer);
+
+    unsigned char * ptry = inYUVBuffer->y + m_yOffset * inYUVBuffer->y_stride;
     unsigned char * ptru = inYUVBuffer->u + (m_yOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptrv = inYUVBuffer->v + (m_yOffset / 2) * inYUVBuffer->uv_stride;
     unsigned char * ptro = locBuffer;
@@ -914,20 +932,16 @@
         }
 
         ptry += inYUVBuffer->y_stride;
-        if (i & 1) 
+        if (fullHeight || i & 1) 
         {
             ptru += inYUVBuffer->uv_stride;
             ptrv += inYUVBuffer->uv_stride;
         }
         ptro += m_bmiWidth * 2;
     }
-
-    SetSampleParams(outSample, m_bmiFrameSize, &inStart, &inEnd, inIsKeyFrame ? TRUE : FALSE);
-
-	return S_OK;
 }
 
-HRESULT TheoraDecodeFilter::DecodeToYV12(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) 
+void TheoraDecodeFilter::DecodeToYV12(yuv_buffer* inYUVBuffer, IMediaSample* outSample) 
 {
     LOG(logDEBUG) << __FUNCTIONW__;
 
@@ -942,7 +956,7 @@
 	for (unsigned long line = 0; line < m_pictureHeight; ++line) 
     {
 		memcpy(ptro, ptry + m_xOffset, m_pictureWidth);
-
+    
 		ptry += inYUVBuffer->y_stride;
 		ptro += m_bmiWidth;
 	}
@@ -960,10 +974,6 @@
         ptru += inYUVBuffer->uv_stride;
         ptro += m_bmiWidth / 2;
     }
-
-    SetSampleParams(outSample, m_bmiFrameSize, &inStart, &inEnd, inIsKeyFrame ? TRUE : FALSE);
-	
-	return S_OK;
 }
 
 HRESULT TheoraDecodeFilter::TheoraDecoded (yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) 
@@ -982,25 +992,33 @@
 
 	if (sampleMediaSubType == MEDIASUBTYPE_YV12) 
 	{
-		return DecodeToYV12(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
+		DecodeToYV12(inYUVBuffer, outSample);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_YUY2) 
 	{
-		return DecodeToYUY2(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
+		DecodeToYUY2(inYUVBuffer, outSample);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_RGB565) 
 	{
-		return DecodeToRGB565(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
+		DecodeToRGB565(inYUVBuffer, outSample);
 	} 
 	else if (sampleMediaSubType == MEDIASUBTYPE_RGB32) 
 	{
-		return DecodeToRGB32(inYUVBuffer, outSample, inIsKeyFrame, inStart, inEnd);
-	} 
+		DecodeToRGB32(inYUVBuffer, outSample);
+	}
+    else if (sampleMediaSubType == MEDIASUBTYPE_AYUV)
+    {
+        DecodeToAYUV(inYUVBuffer, outSample);
+    }
 	else 
 	{
 		LOG(logERROR) << "Decoding to unknown type - failure";
 		return E_FAIL;
 	}
+
+    SetSampleParams(outSample, m_bmiFrameSize, &inStart, &inEnd, inIsKeyFrame ? TRUE : FALSE);
+
+    return S_OK;
 }
 
 HRESULT TheoraDecodeFilter::SetMediaType(PIN_DIRECTION inDirection, const CMediaType* inMediaType) 
@@ -1011,6 +1029,16 @@
         {
 			//LOG(logDEBUG) << "Setting format block";
 			SetTheoraFormat(inMediaType->pbFormat);
+
+            if (m_theoraFormatInfo->pixelFormat == TH_PF_420 ||
+                m_theoraFormatInfo->pixelFormat == TH_PF_422)
+            {
+                Setup42xMediaTypes();
+            }
+            else if (m_theoraFormatInfo->pixelFormat == TH_PF_444)
+            {
+                Setup444MediaTypes();
+            }
 			
             // TODO: after using th_decode_headerin to get the theora informations
             // remove the vertical flip of the yoffset
@@ -1079,7 +1107,7 @@
 	//0		-	55			theora ident						0	-	6
 	//56	-	63			ver major							7	-	7
 	//64	-	71			ver minor							8	-	8
-	//72	-	79			ver subversion						9	=	9
+	//72	-	79			ver subversion						9	-	9
 	//80	-	95			width/16							10	-	11
 	//96	-	111			height/16							12	-	13
 	//112	-	135			framewidth							14	-	16
@@ -1094,9 +1122,10 @@
 	//296	-	319			targetbitrate						37	-	39
 	//320	-	325			targetqual							40	-	40.75
 	//326	-	330			keyframintlog						40.75-  41.375
+    //331   -   333         pixel format                        41.375 - 41.625
 
 	unsigned char* locIdentHeader = inFormatBlock;
-	m_theoraFormatInfo->theoraVersion = (iBE_Math::charArrToULong(locIdentHeader + 7)) >>8;
+    m_theoraFormatInfo->theoraVersion = (iBE_Math::charArrToULong(locIdentHeader + 7)) >>8;
 	m_theoraFormatInfo->outerFrameWidth = (iBE_Math::charArrToUShort(locIdentHeader + 10)) * 16;
 	m_theoraFormatInfo->outerFrameHeight = (iBE_Math::charArrToUShort(locIdentHeader + 12)) * 16;
 	m_theoraFormatInfo->pictureWidth = (iBE_Math::charArrToULong(locIdentHeader + 14)) >>8;
@@ -1110,8 +1139,8 @@
 	m_theoraFormatInfo->colourSpace = locIdentHeader[36];
 	m_theoraFormatInfo->targetBitrate = (iBE_Math::charArrToULong(locIdentHeader + 37)) >>8;
 	m_theoraFormatInfo->targetQuality = (locIdentHeader[40]) >> 2;
-
 	m_theoraFormatInfo->maxKeyframeInterval= (((locIdentHeader[40]) % 4) << 3) + (locIdentHeader[41] >> 5);
+    m_theoraFormatInfo->pixelFormat = (locIdentHeader[41] >> 3) & 3;
 
     LOG(logINFO) << "Theora Format: ";
     LOG(logINFO) << "\ttheoraVersion: " << m_theoraFormatInfo->theoraVersion;
@@ -1129,6 +1158,7 @@
     LOG(logINFO) << "\ttargetBitrate: " << m_theoraFormatInfo->targetBitrate;
     LOG(logINFO) << "\ttargetQuality: " << m_theoraFormatInfo->targetQuality;
     LOG(logINFO) << "\tmaxKeyframeInterval: " << m_theoraFormatInfo->maxKeyframeInterval;
+    LOG(logINFO) << "\tpixelFormat: " << m_theoraFormatInfo->pixelFormat;
 }
 
 CBasePin* TheoraDecodeFilter::GetPin(int inPinNo)
@@ -1156,3 +1186,145 @@
         return NULL;
     }
 }
+
+void TheoraDecodeFilter::Setup42xMediaTypes()
+{
+    // Cleanup previously set media types
+    std::for_each(m_outputMediaTypesList.begin(), m_outputMediaTypesList.end(), util::Deleter());
+    m_outputMediaTypesList.clear();
+    m_outputVideoParams.clear();
+
+    sOutputVideoParams videoParams;
+    CMediaType* acceptMediaType = NULL;
+
+    //YUY2 Media Type VideoInfo2
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_YUY2;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 16;
+    videoParams.fourCC = MAKEFOURCC('Y','U','Y','2');
+    m_outputVideoParams.push_back(videoParams);
+
+    //YUY2 Media Type VideoInfo
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_YUY2;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 16;
+    videoParams.fourCC = MAKEFOURCC('Y','U','Y','2');
+    m_outputVideoParams.push_back(videoParams);
+
+    //YV12 media type VideoInfo2
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_YV12;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 12;
+    videoParams.fourCC = MAKEFOURCC('Y','V','1','2');
+    m_outputVideoParams.push_back(videoParams);
+
+    //YV12 media type VideoInfo
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_YV12;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 12;
+    videoParams.fourCC = MAKEFOURCC('Y','V','1','2');
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB32 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB32;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = BI_RGB;
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB32 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB32;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = BI_RGB;
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB565 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB565;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 16;
+    videoParams.fourCC = BI_BITFIELDS;
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB565 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB565;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 16;
+    videoParams.fourCC = BI_BITFIELDS;
+    m_outputVideoParams.push_back(videoParams);
+}
+
+void TheoraDecodeFilter::Setup444MediaTypes()
+{
+    // Cleanup previously set media types
+    std::for_each(m_outputMediaTypesList.begin(), m_outputMediaTypesList.end(), util::Deleter());
+    m_outputMediaTypesList.clear();
+    m_outputVideoParams.clear();
+
+    sOutputVideoParams videoParams;
+    CMediaType* acceptMediaType = NULL;
+
+    //AYUV Media Type VideoInfo2
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_AYUV;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = MAKEFOURCC('A','Y','U','V');
+    m_outputVideoParams.push_back(videoParams);
+
+    //AYUV Media Type VideoInfo
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_AYUV;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = MAKEFOURCC('A','Y','U','V');
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB32 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB32;
+    acceptMediaType->formattype = FORMAT_VideoInfo2;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = BI_RGB;
+    m_outputVideoParams.push_back(videoParams);
+
+    //RGB32 Media Type
+    acceptMediaType = new CMediaType(&MEDIATYPE_Video);		//Deleted in pin destructor
+    acceptMediaType->subtype = MEDIASUBTYPE_RGB32;
+    acceptMediaType->formattype = FORMAT_VideoInfo;
+    m_outputMediaTypesList.push_back(acceptMediaType);
+
+    videoParams.bitsPerPixel = 32;
+    videoParams.fourCC = BI_RGB;
+    m_outputVideoParams.push_back(videoParams);
+}

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -91,11 +91,19 @@
 	bool SetSampleParams(IMediaSample* outMediaSample, unsigned long inDataSize, REFERENCE_TIME* inStartTime, REFERENCE_TIME* inEndTime, BOOL inIsSync);
 
     HRESULT TheoraDecoded (yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd);
-    HRESULT DecodeToYUY2(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) ;
-    HRESULT DecodeToYV12(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) ;
-    HRESULT DecodeToRGB565(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) ;
-    HRESULT DecodeToRGB32(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool inIsKeyFrame, REFERENCE_TIME inStart, REFERENCE_TIME inEnd) ;
 
+    void DecodeToAYUV(yuv_buffer* inYUVBuffer, IMediaSample* outSample);    
+    void DecodeToYUY2(yuv_buffer* inYUVBuffer, IMediaSample* outSample);    
+    void DecodeToYUY2_42x(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool fullHeight);
+    void DecodeToYV12(yuv_buffer* inYUVBuffer, IMediaSample* outSample);
+    void DecodeToRGB565(yuv_buffer* inYUVBuffer, IMediaSample* outSample);
+    void DecodeToRGB32(yuv_buffer* inYUVBuffer, IMediaSample* outSample);
+    void DecodeToRGB32_42x(yuv_buffer* inYUVBuffer, IMediaSample* outSample, bool fullHeight);
+    void DecodeToRGB32_444(yuv_buffer* inYUVBuffer, IMediaSample* outSample);
+
+    void Setup42xMediaTypes();
+    void Setup444MediaTypes();
+
 protected:
     static const unsigned long THEORA_IDENT_HEADER_SIZE = 42;
 

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -63,9 +63,9 @@
 HRESULT TheoraDecodeInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps)
 {
 	TheoraDecodeFilter* locParent = (TheoraDecodeFilter*)m_pFilter;
-	unsigned long locBuffSize = (locParent->m_theoraFormatInfo->outerFrameHeight * locParent->m_theoraFormatInfo->outerFrameWidth * 3) >> 3;
+	unsigned long locBuffSize = (locParent->m_theoraFormatInfo->outerFrameHeight * locParent->m_theoraFormatInfo->outerFrameWidth * 3) >> 2;
 
-    LOG(logDEBUG) << "Unadjusted Buffer size = " << locBuffSize;
+    LOG(logDEBUG) << __FUNCTIONW__ << " Buffer Size: " << locBuffSize;
 
 #ifdef WINCE
 	if (locBuffSize < 4096) 
@@ -79,8 +79,6 @@
 	}
 #endif
 
-	LOG(logDEBUG) << "Buffer size = " << locBuffSize;
-
 	outRequestedProps->cbBuffer =  locBuffSize;
 	outRequestedProps->cBuffers = THEORA_NUM_BUFFERS;
 	outRequestedProps->cbAlign = 1;

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeInputPin.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -71,9 +71,9 @@
 protected:
 
 #ifdef WINCE
-	static const unsigned long THEORA_NUM_BUFFERS = 20;
+	static const unsigned long THEORA_NUM_BUFFERS = 15;
 #else
-	static const unsigned long THEORA_NUM_BUFFERS = 50;
+	static const unsigned long THEORA_NUM_BUFFERS = 30;
 #endif
 
 	enum eTheoraSetupState 

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/stdafx.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/stdafx.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/stdafx.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -42,6 +42,7 @@
 
 #include <vector>
 #include <string>
+#include <algorithm>
 
 #include "common/log.h"
 

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/theoradecoderdllstuff.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -83,4 +83,5 @@
 	unsigned char xOffset;
 	unsigned char yOffset;
 	unsigned char colourSpace;
+    unsigned char pixelFormat;
 };

Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -108,17 +108,8 @@
 		//
 		//Need to probably use the theora-exp buffer type and change all the
 		// uses of yuv_buffer to handle this, and avoid assumptions about
-		// the relative size of the Y and U and V buffers
+		// the relative size of the Y and U and V buffer
 
-		if (	!	(	(mYCbCrBuffer[1].width == mYCbCrBuffer[2].width)
-					&&	(mYCbCrBuffer[1].height == mYCbCrBuffer[2].height)
-					&&	(mYCbCrBuffer[1].stride == mYCbCrBuffer[2].stride)
-					)) 
-        {
-            LOG(logERROR) << "Not 4:2:0 - OOTheora needs fixing";
-			throw "Not 4:2:0 - OOTheora needs fixing";
-		}
-
 		mYUVBuffer.y_width = mYCbCrBuffer[0].width;
 		mYUVBuffer.y_height = mYCbCrBuffer[0].height;
 		mYUVBuffer.y_stride = mYCbCrBuffer[0].stride;
@@ -188,3 +179,8 @@
     mPacketCount++;
 	return true;
 }
+
+th_pixel_fmt TheoraDecoder::GetPixelFormat() const
+{
+    return mTheoraInfo.pixel_fmt;
+}

Modified: trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/codecs/theora/libs/libOOTheora/TheoraDecoder.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -56,7 +56,7 @@
 	/// Returns true if the packet is a keyframe.
 	bool isKeyFrame(StampedOggPacket* inPacket);
 
-    th_info mTheoraInfo;
+    th_pixel_fmt GetPixelFormat() const;
 
 protected:
 
@@ -68,6 +68,7 @@
 
 	//theora_info mTheoraInfo;
 
+    th_info mTheoraInfo;
     th_ycbcr_buffer mYCbCrBuffer;
 	th_comment mTheoraComment;
 	th_setup_info* mTheoraSetup;

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourceFilter.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -871,7 +871,7 @@
     *pLatest = mSeekTable->fileDuration();
 
     LOG(logDEBUG3) << "IMediaSeeking::GetAvailable(" << ToString(*pEarliest) << ", " << ToString(*pLatest)
-        << ") -> 0x" << std::hex << S_OK;
+                   << ") -> 0x" << std::hex << S_OK;
 
     return S_OK;
 }
@@ -890,7 +890,7 @@
     }
 
     LOG(logDEBUG3) << "IMediaSeeking::SetRate(" << std::setprecision(3) << std::showpoint
-        << dRate << ") -> 0x" << std::hex << result;
+                   << dRate << ") -> 0x" << std::hex << result;
 
     return result;
 }
@@ -900,7 +900,7 @@
     *dRate = 1.0;
 
     LOG(logDEBUG3) << "IMediaSeeking::GetRate(" << std::setprecision(3) << std::showpoint
-        << *dRate << ") -> 0x" << std::hex << S_OK;
+                   << *dRate << ") -> 0x" << std::hex << S_OK;
 
     return S_OK;
 }

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -31,6 +31,7 @@
 #include "StdAfx.h"
 #include "ds_guids.h"
 #include ".\OggDemuxPacketsourcepin.h"
+#include "common/Log.h"
 
 OggDemuxPacketSourcePin::	OggDemuxPacketSourcePin(		TCHAR* inObjectName
 												,	OggDemuxPacketSourceFilter* inParentFilter
@@ -53,24 +54,25 @@
 
 	mPacketiserLock = new CCritSec;
 	
-		//(BYTE*)inBOSPage->createRawPageData();
+	//(BYTE*)inBOSPage->createRawPageData();
 	mPacketiser.setPacketSink(this);
 
-
 	//Subvert COM and do this directly... this way, the source filter won't expose the interface to the
 	// graph but we can still delegate to it.
-	IMediaSeeking* locSeeker = NULL;
-	locSeeker = (IMediaSeeking*)inParentFilter;
+	IMediaSeeking* locSeeker = (IMediaSeeking*)inParentFilter;
 	SetDelegate(locSeeker);
 }
 STDMETHODIMP OggDemuxPacketSourcePin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
 {
-	if (riid == IID_IMediaSeeking) {
+	if (riid == IID_IMediaSeeking) 
+    {
 		//debugLog<<"Pin queried for IMediaSeeking"<<endl;
 		*ppv = (IMediaSeeking*)this;
 		((IUnknown*)*ppv)->AddRef();
 		return NOERROR;
-	} else if (riid == IID_IOggOutputPin) {
+	} 
+    else if (riid == IID_IOggOutputPin) 
+    {
 		*ppv = (IOggOutputPin*)this;
 		//((IUnknown*)*ppv)->AddRef();
 		return NOERROR;		
@@ -78,7 +80,8 @@
 
 	return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv); 
 }
-OggDemuxPacketSourcePin::~OggDemuxPacketSourcePin(void)
+
+OggDemuxPacketSourcePin::~OggDemuxPacketSourcePin()
 {
 	//Since we didn't addref the filter when we set the seek delegate onto it, we have to avoid
 	//	it getting released, so set it to NULL, to avoid the destructor releasing it.
@@ -89,20 +92,22 @@
 	delete mDataQueue;
 
 	delete mPacketiserLock;
-
-
 }
 
 bool OggDemuxPacketSourcePin::acceptOggPage(OggPage* inOggPage)
 {
 	CAutoLock locPackLock(mPacketiserLock);
-	if (mIsStreamReady) {
+	if (mIsStreamReady) 
+    {
 		mAcceptingData = true;
 		return mPacketiser.acceptOggPage(inOggPage);
-	} else {
+	} 
+    else 
+    {
 		delete inOggPage;
 	}
-	return false;
+	
+    return false;
 }
 BYTE* OggDemuxPacketSourcePin::getIdentAsFormatBlock()
 {
@@ -121,11 +126,14 @@
 
 IOggDecoder* OggDemuxPacketSourcePin::getDecoderInterface()
 {
-	if (mDecoderInterface == NULL) {
+	if (mDecoderInterface == NULL) 
+    {
 		IOggDecoder* locDecoder = NULL;
-		if (IsConnected()) {
+		if (IsConnected()) 
+        {
 			IPin* locPin = GetConnected();
-			if (locPin != NULL) {
+			if (locPin != NULL) 
+            {
 				locPin->QueryInterface(IID_IOggDecoder, (void**)&locDecoder);
 			}
 		}
@@ -138,7 +146,8 @@
 HRESULT OggDemuxPacketSourcePin::GetMediaType(int inPosition, CMediaType* outMediaType) 
 {
 	//Put it in from the info we got in the constructor.
-	if (inPosition == 0) {
+	if (inPosition == 0) 
+    {
 		AM_MEDIA_TYPE locAMMediaType;
 		locAMMediaType.majortype = MEDIATYPE_OggPacketStream;
 
@@ -153,21 +162,23 @@
 		CMediaType locMediaType(locAMMediaType);		
 		*outMediaType = locMediaType;
 		return S_OK;
-	} else {
-		return VFW_S_NO_MORE_ITEMS;
-	}
+    }
+        
+    return VFW_S_NO_MORE_ITEMS;
 }
+
 HRESULT OggDemuxPacketSourcePin::CheckMediaType(const CMediaType* inMediaType) {
 	if (		(inMediaType->majortype == MEDIATYPE_OggPacketStream) 
 			&&	(inMediaType->subtype == MEDIASUBTYPE_None)
-			&&	(inMediaType->formattype == FORMAT_OggIdentHeader)) {
+			&&	(inMediaType->formattype == FORMAT_OggIdentHeader)) 
+    {
 			//&&	(inMediaType->cbFormat == mBOSPage->pageSize()) {
-
 		return S_OK;
-	} else {
-		return E_FAIL;
-	}
+    }
+    
+    return E_FAIL;
 }
+
 HRESULT OggDemuxPacketSourcePin::DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest) 
 {
 	HRESULT locHR = S_OK;
@@ -182,16 +193,17 @@
 
 	locHR = inoutAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
 
-	if (locHR != S_OK) {
+	if (locHR != S_OK) 
+    {
 		return locHR;
 	}
 
 	mNumBuffers = locActualAlloc.cBuffers;
-	
 	locHR = inoutAllocator->Commit();
 
+    LOG(logINFO) << __FUNCTIONW__ << " BufferSize: " << locActualAlloc.cbBuffer << ", Buffers: " << locActualAlloc.cBuffers;
+
 	return locHR;
-
 }
 
 
@@ -202,45 +214,51 @@
 	mDataQueue = NULL;
 	return CBaseOutputPin::BreakConnect();
 }
+
 HRESULT OggDemuxPacketSourcePin::CompleteConnect(IPin *inReceivePin)
 {
 	IOggDecoder* locDecoder = NULL;
 	inReceivePin->QueryInterface(IID_IOggDecoder, (void**)&locDecoder);
-	if (locDecoder != NULL) {
+	if (locDecoder != NULL) 
+    {
 		mDecoderInterface = locDecoder;
 
 		IOggDecoder::eAcceptHeaderResult locResult = mDecoderInterface->showHeaderPacket(mIdentHeader->clone());
-		if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
+		if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) 
+        {
 			mIsStreamReady = true;
 
-		} else {
+		} 
+        else 
+        {
 			OggPacketiser locPacketiser;
 			locPacketiser.setPacketSink(this);
 			OggDemuxPacketSourceFilter* locParent = (OggDemuxPacketSourceFilter*)m_pFilter;
 			vector<OggPage*> locList = locParent->getMatchingBufferedPages(mSerialNo);
 			
-			for (size_t i = 0; i < locList.size(); i++) {
+			for (size_t i = 0; i < locList.size(); i++) 
+            {
 				locPacketiser.acceptOggPage(locList[i]);
 			}
 
-			locParent->removeMatchingBufferedPages(mSerialNo);
-
-			
+			locParent->removeMatchingBufferedPages(mSerialNo);	
 		}
 
-		if (mIsStreamReady) {
+		if (mIsStreamReady) 
+        {
 			HRESULT locHR = CBaseOutputPin::CompleteConnect(inReceivePin);
-			if (locHR == S_OK) {
+			if (locHR == S_OK) 
+            {
 				((OggDemuxPacketSourceFilter*)m_pFilter)->notifyPinConnected();
 				mDataQueue = new COutputQueue (inReceivePin, &mFilterHR, FALSE, TRUE,1,TRUE, mNumBuffers);
-				return S_OK;
-			}  else {
+				
+                return S_OK;
+			}  
+            else 
+            {
 				return locHR;
 			}
-			
 		}	
-
-		
 	}
 	return E_FAIL;
 	
@@ -250,7 +268,6 @@
 {
 	CAutoLock locStreamLock(((OggDemuxPacketSourceFilter*)m_pFilter)->streamLock());
 
-
 	//Set up the sample info
 	IMediaSample* locSample = NULL;
 	REFERENCE_TIME locStart = inPacket->startTime();
@@ -260,8 +277,9 @@
 	HRESULT	locHR = GetDeliveryBuffer(&locSample, &locStart, &locStop, NULL);
 	
 	//Error checks
-	if (locHR != S_OK) {
-		//Stopping, fluching or error
+	if (locHR != S_OK) 
+    {
+		//Stopping, flushing or error
 
 		delete inPacket;
 		return false;
@@ -278,38 +296,50 @@
 	BYTE* locBuffer = NULL;
 	locSample->GetPointer(&locBuffer);
 
-	if (locSample->GetSize() >= inPacket->packetSize()) {
+	if (locSample->GetSize() >= inPacket->packetSize()) 
+    {
 
 		memcpy((void*)locBuffer, (const void*)inPacket->packetData(), inPacket->packetSize());
 		locSample->SetActualDataLength(inPacket->packetSize());
 
 		locHR = mDataQueue->Receive(locSample);
 
-		if (locHR != S_OK) {
-			//debugLog << "Failure... Queue rejected sample..."<<endl;
+		if (locHR != S_OK) 
+        {
+            LOG(logERROR) << __FUNCTIONW__ << " Failure... Queue rejected sample, error: 0x" << std::hex << locHR;
 			//Stopping ??
 
 			delete inPacket;
 			return false;
-		} else {
+		} 
+        else 
+        {
 			delete inPacket;
 			return true;
 		}
-	} else {
-		//DbgLog((LOG_TRACE, 2, "* BUFFER TOO SMALL... FATALITY !!"));
+	} 
+    else 
+    {
+		LOG(logERROR) << __FUNCTIONW__ << " Buffer to small. " << locSample->GetSize() << " vs " << inPacket->packetSize();
 		throw 0;
 	}	
 }
+
 bool OggDemuxPacketSourcePin::acceptStampedOggPacket(StampedOggPacket* inPacket)
 {
-	if (mAcceptingData) {
+	if (mAcceptingData) 
+    {
 		return dispatchPacket(inPacket);
-	} else {
+	} 
+    else 
+    {
 		//This handles callbacks with header packets
 		IOggDecoder::eAcceptHeaderResult locResult;
-		if ((mDecoderInterface != NULL) && (!mIsStreamReady)) {
+		if ((mDecoderInterface != NULL) && (!mIsStreamReady)) 
+        {
 			locResult = mDecoderInterface->showHeaderPacket(inPacket);
-			if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) {
+			if (locResult == IOggDecoder::AHR_ALL_HEADERS_RECEIVED) 
+            {
 				mIsStreamReady = true;
 			}
 		}
@@ -323,25 +353,29 @@
 {
 	NewSegment(tStart, tStop, dRate);
 
-	if (mDataQueue != NULL) {
+	if (mDataQueue != NULL) 
+    {
 		mDataQueue->NewSegment(tStart, tStop, dRate);
 	}
 
 	return S_OK;
 }
-HRESULT OggDemuxPacketSourcePin::DeliverEndOfStream(void)
+
+HRESULT OggDemuxPacketSourcePin::DeliverEndOfStream()
 {
-	if (mDataQueue != NULL) {
+	if (mDataQueue != NULL) 
+    {
 		mDataQueue->EOS();
 	}
     return S_OK;
 }
 
-HRESULT OggDemuxPacketSourcePin::DeliverEndFlush(void)
+HRESULT OggDemuxPacketSourcePin::DeliverEndFlush()
 {
 	CAutoLock locPackLock(mPacketiserLock);
 	
-	if (mDataQueue != NULL) {
+	if (mDataQueue != NULL) 
+    {
 		mDataQueue->EndFlush();
 	}
 
@@ -349,9 +383,10 @@
     return S_OK;
 }
 
-HRESULT OggDemuxPacketSourcePin::DeliverBeginFlush(void)
+HRESULT OggDemuxPacketSourcePin::DeliverBeginFlush()
 {
-	if (mDataQueue != NULL) {
+	if (mDataQueue != NULL) 
+    {
 		mDataQueue->BeginFlush();
 	}
 	

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux2/OggDemuxPacketSourcePin.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -47,7 +47,7 @@
 
 	DECLARE_IUNKNOWN
 	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
-	//OggDemuxPacketSourcePin(void);
+	//OggDemuxPacketSourcePin();
 	OggDemuxPacketSourcePin(	TCHAR* inObjectName, 
 							OggDemuxPacketSourceFilter* inParentFilter,
 							CCritSec* inFilterLock,
@@ -59,7 +59,7 @@
 							//bool inAllowSeek,
 							//unsigned long inNumBuffers,
 							//unsigned long inBufferSize);
-	virtual ~OggDemuxPacketSourcePin(void);
+	virtual ~OggDemuxPacketSourcePin();
 
 	static const unsigned long NUM_PAGE_BUFFERS = 100;
 
@@ -83,9 +83,9 @@
 
 	//Pin streaming methods
 	virtual HRESULT DeliverNewSegment(REFERENCE_TIME inStart, REFERENCE_TIME inStop, double inRate);
-	virtual HRESULT DeliverEndOfStream(void);
-	virtual HRESULT DeliverEndFlush(void);
-	virtual HRESULT DeliverBeginFlush(void);
+	virtual HRESULT DeliverEndOfStream();
+	virtual HRESULT DeliverEndFlush();
+	virtual HRESULT DeliverBeginFlush();
 
 	//IOggOutputPin interface
 	virtual bool notifyStreamBaseTime(__int64 inStreamTime);

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggMux/oggmuxdllstuff.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -244,6 +244,7 @@
 	unsigned char xOffset;
 	unsigned char yOffset;
 	unsigned char colourSpace;
+    unsigned char pixelFormat;
 };
 struct sOggRawAudioFormatBlock {
 	unsigned long samplesPerSec;

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.cpp	2010-02-20 02:38:34 UTC (rev 16925)
@@ -31,8 +31,8 @@
 
 #include "stdafx.h"
 #include <libOOOgg/OggDataBuffer.h>
+#include "common/Log.h"
 
-
 //LEAK CHECKED - 2004/10/17		-	OK.
 //LEAK FOUND - 2004/11/29  -  acceptOggPage
 OggDataBuffer::OggDataBuffer(void)
@@ -43,7 +43,6 @@
 	,	mNumBytesNeeded(OggPageHeader::OGG_BASE_HEADER_SIZE)
 {
 	mBuffer = new CircularBuffer(MAX_OGG_PAGE_SIZE);			//Deleted in destructor
-	//debugLog.open("G:\\logs\\OggDataBuffer.log", ios_base::out);
 }
 
 //Debug only
@@ -66,8 +65,6 @@
 	mBuffer = 0;
 	delete pendingPage;
 	pendingPage = 0;
-	//debugLog.close();
-	
 }
 
 
@@ -104,45 +101,58 @@
     IOggCallback class for more information.
   */
 
-bool OggDataBuffer::registerVirtualCallback(IOggCallback* inPageCallback) {
+bool OggDataBuffer::registerVirtualCallback(IOggCallback* inPageCallback) 
+{
 	//Holds the virtual callback and nulls the static one.
 	mVirtualCallback = inPageCallback;
 	mStaticCallback = NULL;
 
-	return true;
-	
+	return true;	
 }
 
 
-unsigned long OggDataBuffer::numBytesAvail() {
+unsigned long OggDataBuffer::numBytesAvail() 
+{
 	//Returns how many bytes are available in the buffer
 	unsigned long locBytesAvail = mBuffer->numBytesAvail();	
 
-	//debugLog<<"Bytes avail = "<<locBytesAvail<<endl;
+	// LOG(logDEBUG1) << "Bytes avail = " << locBytesAvail;
 	return locBytesAvail;
 }
 
-OggDataBuffer::eState OggDataBuffer::state() {
+OggDataBuffer::eState OggDataBuffer::state() 
+{
 	//returns the state of the stream
 	return mState;
 }
+
 //This function accepts the responsibility for the incoming page.
-OggDataBuffer::eDispatchResult OggDataBuffer::dispatch(OggPage* inOggPage) {
+OggDataBuffer::eDispatchResult OggDataBuffer::dispatch(OggPage* inOggPage) 
+{
 	//TODO::: Who owns this pointer inOggPage ?
+    // LOG(logDEBUG1) << "Dispatching page to: " << mVirtualCallback;
 
-	//debugLog<<"Dispatching page..."<<endl<<endl;
-
 	//Fire off the oggpage to whoever is registered to get it
-	if (mVirtualCallback != NULL) {
-		if (mVirtualCallback->acceptOggPage(inOggPage) == true) {		//Page given away, never used again.
+	if (mVirtualCallback != NULL) 
+    {
+		if (mVirtualCallback->acceptOggPage(inOggPage) == true) 
+        {		
+            //Page given away, never used again.
 			return DISPATCH_OK;
-		} else {
+		} 
+        else 
+        {
 			return DISPATCH_FALSE;
 		}
-	} else if (mStaticCallback != NULL) {
-		if (mStaticCallback(inOggPage, mStaticCallbackUserData) == true) {
+	} 
+    else if (mStaticCallback != NULL) 
+    {
+		if (mStaticCallback(inOggPage, mStaticCallbackUserData) == true) 
+        {
 			return DISPATCH_OK;	
-		} else {
+		} 
+        else 
+        {
 			return DISPATCH_FALSE;
 		}
 	}
@@ -154,44 +164,50 @@
 	return DISPATCH_NO_CALLBACK;
 }
 
-OggDataBuffer::eFeedResult OggDataBuffer::feed(const unsigned char* inData, unsigned long inNumBytes) {
-	if (inNumBytes != 0) {
-		if (inData != NULL) {
+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.
 			
-			//debugLog<<"Fed "<<inNumBytes<<" bytes..."<<endl;
+			// LOG(logDEBUG1) << "Fed " << inNumBytes << " bytes...";
 			unsigned long locNumWritten = mBuffer->write(inData, inNumBytes);
 
-			if (locNumWritten < inNumBytes) {
+			if (locNumWritten < inNumBytes) 
+            {
 				//TODO::: What does happen in this case.
 
 				//Handle this case... you lose data.
 				//Buffer is full
 				
-				//debugLog<<"Feed : Could count feed in " <<inNumBytes<<" bytes"<<endl
-				//		<<"Feed : ** "<<mBuffer->numBytesAvail()<<" avail, "<<mBuffer->spaceLeft()<<" space left."<<endl;
+				// LOG(logDEBUG1) << "Feed : Could count feed in " << inNumBytes <<" bytes";
+				// LOG(logDEBUG1) << "Feed : ** "<< mBuffer->numBytesAvail() << " avail, " << mBuffer->spaceLeft() << " space left.";
 
 				locNumWritten = locNumWritten;
 			}
 			return (eFeedResult)processBuffer();
-		} else {
+		} 
+        else 
+        {
 			//Numbytes not equal to zero but inData pointer is NULL
 
-			//debugLog<<"Feed : Fed NULL Pointer"<<endl;
+			// LOG(logDEBUG1) << "Feed : Fed NULL Pointer";
 			return FEED_NULL_POINTER;
 		}
-	} else {
+	} 
+    else 
+    {
 		//numbytes was zero... we do nothing and it's not an error.
 		
-		//debugLog<<"Feed : Fed *zero* bytes... Not an error, do nothing, return ok."<<endl;
+		// LOG(logDEBUG1) << "Feed : Fed *zero* bytes... Not an error, do nothing, return ok.";
 		return FEED_OK;
-	}
-		
-	
+	}	
 }
 OggDataBuffer::eProcessResult OggDataBuffer::processBaseHeader() 
 {
-		//debugLog<<"Processing base header..."<<endl;
+		// LOG(logDEBUG1) << "Processing base header..." <<endl;
 		
 		//Delete the previous page
 		delete pendingPage;
@@ -202,23 +218,25 @@
 		//Make a local buffer for the header
 		unsigned char* locBuff = new unsigned char[OggPageHeader::OGG_BASE_HEADER_SIZE];		//deleted before this function returns
 		
-		//debugLog<<"ProcessBaseHeader : Reading from stream..."<<endl;
+		// LOG(logDEBUG1) << "ProcessBaseHeader : Reading from stream...";
 		
 		//STREAM ACCESS::: Read
 		unsigned long locNumRead = mBuffer->read(locBuff, OggPageHeader::OGG_BASE_HEADER_SIZE);
 		
-		if (locNumRead < OggPageHeader::OGG_BASE_HEADER_SIZE) {
+		if (locNumRead < OggPageHeader::OGG_BASE_HEADER_SIZE) 
+        {
 			//TODO::: Handle this case... we read less than we expected.
 			//The buffer handles it for us, it won't let us read less, and will return 0
 			//	This is fine for valid files, but still needs to be reviewed.
 
-			//debugLog<<"ProcessBaseHeader : ###### Read was short."<<endl;
-			//debugLog<<"ProcessBaseHeader : ** "<<mBuffer->numBytesAvail()<<" avail, "<<mBuffer->spaceLeft()<<" space left."<<endl;
+			// LOG(logDEBUG1) << "ProcessBaseHeader : ###### Read was short.";
+			// LOG(logDEBUG1) << "ProcessBaseHeader : ** "<< mBuffer->numBytesAvail() <<" avail, " << mBuffer->spaceLeft() <<" space left.";
 			locNumRead = locNumRead;
 		}
 
 		bool locRetVal = pendingPage->header()->setBaseHeader((unsigned char*)locBuff);		//Views pointer only.
-		if (locRetVal == false) {
+		if (locRetVal == false) 
+        {
 			delete[] locBuff;
 			return PROCESS_FAILED_TO_SET_HEADER;
 		}
@@ -226,12 +244,13 @@
 		//Set the number of bytes we want for next time
 		mNumBytesNeeded = pendingPage->header()->NumPageSegments();
 
-		//debugLog<<"Setting state to AWAITING_SEG_TABLE"<<endl;
-		//Change the state.
+		// LOG(logDEBUG1) << "Setting state to AWAITING_SEG_TABLE";
+
+        //Change the state.
 		mState = AWAITING_SEG_TABLE;
 
 		delete[] locBuff;
-		//debugLog<<"Bytes needed for seg table = "<<mNumBytesNeeded<<endl;	
+		// LOG(logDEBUG1) << "Bytes needed for seg table = " << mNumBytesNeeded<<endl;	
 		return PROCESS_OK;
 }
 OggDataBuffer::eProcessResult OggDataBuffer::processSegTable() 
@@ -244,29 +263,28 @@
 	//Assumes a valid pending page, with numPagesegments set in the header already.
 	//creates a chunk of memory size numpagesegments and stores it,.
 
-	//debugLog<<"Processing Segment Table..."<<endl;
+	// LOG(logDEBUG1) << "Processing Segment Table...";
 
 	//TODAY::: What happens when numpage segments is zero.
 
 	//Save a local copy of the number of page segments - Get this from the already set header.
 	unsigned char locNumSegs = pendingPage->header()->NumPageSegments();
 
-	//debugLog<<"Num segments = "<<(int)locNumSegs<<endl;
+	// LOG(logDEBUG1) << "Num segments = " <<(int)locNumSegs;
 
 	//Make a local buffer the size of the segment table. 0 - 255
 	unsigned char* locBuff = new unsigned char[locNumSegs];				//Given to setSegmentTable. Not deleted here.
 	
-	////debugLog<<"ProcessSegTable : Reading from buffer..."<<endl;
+	// LOG(logDEBUG1) << "ProcessSegTable : Reading from buffer...";
 
 	//Read the segment table from the buffer to locBuff
 	unsigned long locNumRead = mBuffer->read(locBuff, (unsigned long)locNumSegs);
 	
-	if (locNumRead < locNumSegs) {
+	if (locNumRead < locNumSegs) 
+    {
 		//TODO::: Handle this case
-
-		//debugLog<<"ProcessSegTable : ##### Short read"<<endl;
-		//debugLog<<"ProcessSegTable : ** "<<mBuffer->numBytesAvail()<<" avail, "<<mBuffer->spaceLeft()<<" space left."<<endl;
-		
+		// LOG(logDEBUG1) << "ProcessSegTable : ##### Short read";
+		// LOG(logDEBUG1) << "ProcessSegTable : ** "<< mBuffer->numBytesAvail() << " avail, " << mBuffer->spaceLeft() << " space left.";		
 	}
 
 
@@ -277,8 +295,8 @@
 	//Set the number of bytes we want for next time - which is the size of the page data.
 	mNumBytesNeeded = pendingPage->header()->calculateDataSize();
 
-	//debugLog<<"Num bytes needed for data = "<< mNumBytesNeeded<<endl;
-	//debugLog<<"Transition to AWAITING_DATA"<<endl;
+	// LOG(logDEBUG1) << "Num bytes needed for data = " << mNumBytesNeeded;
+	// LOG(logDEBUG1) << "Transition to AWAITING_DATA";
 	
 	mState = AWAITING_DATA;
 	return PROCESS_OK;
@@ -287,9 +305,9 @@
 
 OggDataBuffer::eProcessResult OggDataBuffer::processDataSegment() 
 {
-	//unsigned long locPageDataSize = pendingPage->header()->dataSize();  //unused
-	
-	//debugLog<<"ProcessDataSegment : Page data size = "<<locPageDataSize<<endl;
+	unsigned long locPageDataSize = pendingPage->header()->dataSize();  //unused	
+	// LOG(logDEBUG1) << "ProcessDataSegment : Page data size = " << locPageDataSize;
+
 	unsigned char* locBuff = NULL;
 	//unsigned long locPacketOffset = 0;
 
@@ -298,14 +316,14 @@
 	unsigned char* locSegTable = pendingPage->header()->SegmentTable();			//View only don't delete.
 	unsigned int locNumSegs = pendingPage->header()->NumPageSegments();
 	
-	//debugLog<<"ProcessDataSegment : Num segs = "<<locNumSegs<<endl;
+	// LOG(logDEBUG1) << "ProcessDataSegment : Num segs = " << locNumSegs;
 
-
 	unsigned long locCurrPackSize = 0;
 	bool locIsFirstPacket = true;
 	LOOG_INT64 locPrevGranPos = 0;
 
-	for (unsigned long i = 0; i < locNumSegs; i++) {
+	for (unsigned long i = 0; i < locNumSegs; i++) 
+    {
 		//Packet sums the lacing values of the segment table.
 		locCurrPackSize += locSegTable[i];
 
@@ -324,7 +342,8 @@
 			Lacing values for a Packet never end with 255... if multiple of 255 have a next 0 lacing value.
 		*/
 		
-		if ( (locSegTable[i] != 255) || (locNumSegs - 1 == i) ) {
+		if ( (locSegTable[i] != 255) || (locNumSegs - 1 == i) ) 
+        {
 			//If its the last lacing value or the the lacing value is not 255 (ie packet boundry)
 			
 			//This pointer is given to the packet... it deletes it.
@@ -335,22 +354,24 @@
 			
 			unsigned long locNumRead = mBuffer->read(locBuff, locCurrPackSize);
 			
-			if (locNumRead < locCurrPackSize) {
+			if (locNumRead < locCurrPackSize) 
+            {
 				//TODO::: Handle this case.
 
-				//debugLog<<"ProcessDataSegment : ###### Short read"<<endl;
-				//debugLog<<"ProcessDataSegment : ** "<<mBuffer->numBytesAvail()<<" avail, "<<mBuffer->spaceLeft()<<" space left."<<endl;
+				// LOG(logDEBUG1) << "ProcessDataSegment : ###### Short read";
+				// LOG(logDEBUG1) << "ProcessDataSegment : ** " << mBuffer->numBytesAvail() << " avail, " << mBuffer->spaceLeft() << " space left.";
 				locNumRead = locNumRead;
 			}
 
-			//debugLog<<"Adding packet - size = "<<locCurrPackSize<<endl;
+			// LOG(logDEBUG1) << "Adding packet - size = "<<locCurrPackSize;
 			
 			//A packet ends when a lacing value is not 255. So the check for != 255 means the isComplete property of the packet is not set unless the
 			// lacing value is not equal to 255.
 			//ERROR CHECK:::
 			bool locIsContinuation = false;
 			
-			if (locIsFirstPacket) {
+			if (locIsFirstPacket) 
+            {
 				locIsFirstPacket = false;
 
 				//Remember what the granule pos was and get it from the new page.
@@ -376,29 +397,35 @@
 	//Update the state for how many bytes are now needed
 	mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
 	
-	//debugLog<<"ProcessDataSegment : num bytes needed = "<<mNumBytesNeeded<<endl;
+	// LOG(logDEBUG1) << "ProcessDataSegment : num bytes needed = "<<mNumBytesNeeded;
 
 	//Dispatch the finished pagbve
 	eDispatchResult locRet = dispatch(pendingPage);			//The dispatch function takes responsibility for this page.
 	pendingPage = NULL;   //We give away the pointer
 	
-	if (locRet == DISPATCH_OK) {
-        //debugLog<<"ProcessDataSegment : Transition to AWAITING_BASE_HEADER"<<endl;
+	if (locRet == DISPATCH_OK) 
+    {
+        // LOG(logDEBUG1) << "ProcessDataSegment : Transition to AWAITING_BASE_HEADER";
 		mState = AWAITING_BASE_HEADER;
 		return PROCESS_OK;
-	} else if (locRet == DISPATCH_FALSE) {
+	} 
+    else if (locRet == DISPATCH_FALSE) 
+    {
 		mState = AWAITING_BASE_HEADER;
 		return PROCESS_DISPATCH_FALSE;	
-	} else {
-		//debugLog<<"ProcessDataSegment : Dispatch failed."<<endl;
+	} 
+    else 
+    {
+		// LOG(logDEBUG1) << "ProcessDataSegment : Dispatch failed.";
 		return PROCESS_DISPATCH_FAILED;
-	}
-		
+	}		
 }
-void OggDataBuffer::clearData() {
+
+void OggDataBuffer::clearData() 
+{
 	mBuffer->reset();
 	mPrevGranPos = 0;
-	//debugLog<<"ClearData : Transition back to AWAITING_BASE_HEADER"<<endl;
+	// LOG(logDEBUG1) << "ClearData : Transition back to AWAITING_BASE_HEADER";
 	
 	// This might leak, but fixes crash with invalid data
 	pendingPage = 0;
@@ -406,28 +433,32 @@
 	mNumBytesNeeded = OggPageHeader::OGG_BASE_HEADER_SIZE;
 	mState = AWAITING_BASE_HEADER;
 
-	////debugLog<<"ClearData : Num bytes needed = "<<mNumBytesNeeded<<endl;
+	// LOG(logDEBUG1) << "ClearData : Num bytes needed = " << mNumBytesNeeded;
 }
 
-OggDataBuffer::eProcessResult OggDataBuffer::processBuffer() {
-		
+OggDataBuffer::eProcessResult OggDataBuffer::processBuffer() 
+{		
 	eProcessResult locResult = PROCESS_OK;
 
-	while (numBytesAvail() >= mNumBytesNeeded) {
-		////debugLog<<"ProcessBuffer : Bytes Needed = "<<mNumBytesNeeded<<" --- "<<"Bytes avail = "<<numBytesAvail()<<endl;
-		switch (mState) {
+	while (numBytesAvail() >= mNumBytesNeeded) 
+    {
+		// LOG(logDEBUG1) << "ProcessBuffer : Bytes Needed = " << mNumBytesNeeded << " --- " << "Bytes avail = "<< numBytesAvail();
+		switch (mState) 
+        {
 
 			//QUERY:::	Should it be a bug when the if state inside the switch falls through,... potential for infinite loop.
 			case AWAITING_BASE_HEADER:
-				//debugLog<<"ProcessBuffer : State = AWAITING_BASE_HEADER"<<endl;
+				// LOG(logDEBUG1) << "ProcessBuffer : State = AWAITING_BASE_HEADER";
 				
 				//If theres enough data to form the base header
-				if (numBytesAvail() >= OggPageHeader::OGG_BASE_HEADER_SIZE) {
-					//debugLog<<"ProcessBuffer : Enough to process..."<<endl;
+				if (numBytesAvail() >= OggPageHeader::OGG_BASE_HEADER_SIZE) 
+                {
+					// LOG(logDEBUG1) << "ProcessBuffer : Enough to process...";
 					
 					locResult = processBaseHeader();
                     
-					if (locResult != PROCESS_OK) {
+					if (locResult != PROCESS_OK) 
+                    {
 						mState = LOST_PAGE_SYNC;
 						//Base header process failed
 						return locResult;
@@ -436,15 +467,17 @@
 				break;
 			
 			case AWAITING_SEG_TABLE:
-				//debugLog<<"ProcessBuffer : State = AWAITING_SEG_TABLE"<<endl;
+				// LOG(logDEBUG1) << "ProcessBuffer : State = AWAITING_SEG_TABLE";
 				
 				//If there is enough data to get the segt table
-				if (numBytesAvail() >= pendingPage->header()->NumPageSegments()) {
-					//debugLog<<"ProcessBuffer : Enough to process..."<<endl;
+				if (numBytesAvail() >= pendingPage->header()->NumPageSegments()) 
+                {
+					// LOG(logDEBUG1) << "ProcessBuffer : Enough to process...";
 					
 					locResult = processSegTable();
                
-					if (locResult != PROCESS_OK) {
+					if (locResult != PROCESS_OK) 
+                    {
 						mState = LOST_PAGE_SYNC;
 						//segment table process failed
 						return locResult;
@@ -453,31 +486,32 @@
 				break;
 
 			case AWAITING_DATA:
-				//debugLog<<"ProcessBuffer : State = AWAITING_DATA"<<endl;
+				// LOG(logDEBUG1) << "ProcessBuffer : State = AWAITING_DATA";
 				//If all the data segment is available
-				if (numBytesAvail() >= pendingPage->header()->dataSize()) {
-					//debugLog<<"ProcessBuffer : Enough to process..."<<endl;
+				if (numBytesAvail() >= pendingPage->header()->dataSize()) 
+                {
+					// LOG(logDEBUG1) << "ProcessBuffer : Enough to process...";
 
 					//FIX::: Need error check.
 					locResult = processDataSegment();
 					
-					if (locResult == PROCESS_DISPATCH_FAILED) {
+					if (locResult == PROCESS_DISPATCH_FAILED) 
+                    {
 						mState = LOST_PAGE_SYNC;
 						//segment table process failed
 						return locResult;
 					}
-
 				}	
 				break;
 			case LOST_PAGE_SYNC:
 				//TODO::: Insert resync code here.
 
-				//debugLog<<"ProcessBuffer : State = LOST_PAGE_SYNC"<<endl;
+				// LOG(logDEBUG1) << "ProcessBuffer : State = LOST_PAGE_SYNC";
 				return PROCESS_LOST_SYNC;
 			default:
 				//TODO::: What are we supposed to do with this. Anything need cleaning up ?
 				
-				//debugLog<<"ProcessBuffer : Ogg Buffer Error"<<endl;
+				LOG(logDEBUG1) << __FUNCTIONW__ << " Ogg Buffer Error";
 				return PROCESS_UNKNOWN_INTERNAL_ERROR;
 				break;
 		}
@@ -485,10 +519,5 @@
 
 	//There wasn't enough data to progress if we are here.
 	return locResult;
-
 }
 
-//Debug Only
-void OggDataBuffer::debugWrite(string inString) {
-	//debugLog<<inString<<endl;
-}

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggDataBuffer.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -74,14 +74,9 @@
 											(OggPageHeader::MAX_NUM_SEGMENTS * OggPageHeader::MAX_SEGMENT_SIZE) +		//Page Data
 											(OggPageHeader::SEGMENT_WIDTH * OggPageHeader::MAX_NUM_SEGMENTS);			//Segment table
 
-	//Debug only
-	//OggDataBuffer::OggDataBuffer(bool x);
-	void debugWrite(string inString);
-	//
-
 	//Constructors
-	OggDataBuffer(void);
-	virtual ~OggDataBuffer(void);
+	OggDataBuffer();
+	virtual ~OggDataBuffer();
 
 	/// Register as a callback, which gets called when data is received via our feed() method.
 	bool registerStaticCallback(fPageCallback inPageCallback, void* inUserData);

Modified: trunk/oggdsf/src/lib/helper/common/util.h
===================================================================
--- trunk/oggdsf/src/lib/helper/common/util.h	2010-02-19 15:14:04 UTC (rev 16924)
+++ trunk/oggdsf/src/lib/helper/common/util.h	2010-02-20 02:38:34 UTC (rev 16925)
@@ -128,6 +128,15 @@
         }
     }
 
+    struct Deleter
+    {	
+        template<typename T>
+        void operator()(const T* arg) const
+        {	
+            delete arg;
+        }
+    };
+
 }
 
 #endif // UTIL_H
\ No newline at end of file



More information about the commits mailing list