[xiph-commits] r7721 - trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Thu Sep 9 07:03:00 PDT 2004


Author: illiminable
Date: 2004-09-09 07:03:00 -0700 (Thu, 09 Sep 2004)
New Revision: 7721

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/dsfTheoraDecoder.vcproj
Log:
* New theora pretty much fleshed out.

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2004-09-09 13:51:51 UTC (rev 7720)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.cpp	2004-09-09 14:03:00 UTC (rev 7721)
@@ -56,12 +56,12 @@
 TheoraDecodeFilter::TheoraDecodeFilter() 
 	:	CVideoTransformFilter( NAME("Theora Decode Filter"), NULL, CLSID_TheoraDecodeFilter)
 {
-
+	debugLog.open("G:\\logs\\newtheofilter.log", ios_base::out);
 }
 
 TheoraDecodeFilter::~TheoraDecodeFilter() {
+	debugLog.close();
 
-
 }
 
 CUnknown* WINAPI TheoraDecodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
@@ -73,22 +73,213 @@
     }
 	return pNewObject;
 } 
+void TheoraDecodeFilter::FillMediaType(CMediaType* outMediaType, unsigned long inSampleSize) {
+	outMediaType->SetType(&MEDIATYPE_Video);
+	outMediaType->SetSubtype(&MEDIASUBTYPE_YV12);
+	outMediaType->SetFormatType(&FORMAT_VideoInfo);
+	outMediaType->SetTemporalCompression(FALSE);
+	outMediaType->SetSampleSize(inSampleSize);		
 
+}
+bool TheoraDecodeFilter::FillVideoInfoHeader(VIDEOINFOHEADER* inFormatBuffer) {
+	TheoraDecodeFilter* locFilter = this;
 
-HRESULT TheoraDecodeFilter::CheckInputType(const CMediaType* inMediaType) {
+	inFormatBuffer->AvgTimePerFrame = (UNITS * locFilter->mTheoraFormatInfo->frameRateDenominator) / locFilter->mTheoraFormatInfo->frameRateNumerator;
+	inFormatBuffer->dwBitRate = locFilter->mTheoraFormatInfo->targetBitrate;
+	
+	inFormatBuffer->bmiHeader.biBitCount = 12;   //12 bits per pixel
+	inFormatBuffer->bmiHeader.biClrImportant = 0;   //All colours important
+	inFormatBuffer->bmiHeader.biClrUsed = 0;        //Use max colour depth
+	inFormatBuffer->bmiHeader.biCompression = MAKEFOURCC('Y','V','1','2');
+	inFormatBuffer->bmiHeader.biHeight = locFilter->mTheoraFormatInfo->frameHeight;   //Not sure
+	inFormatBuffer->bmiHeader.biPlanes = 1;    //Must be 1
+	inFormatBuffer->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);    //????? Size of what ?
+	inFormatBuffer->bmiHeader.biSizeImage = ((locFilter->mTheoraFormatInfo->frameHeight * locFilter->mTheoraFormatInfo->frameWidth) * 3)/2;    //Size in bytes of image ??
+	inFormatBuffer->bmiHeader.biWidth = locFilter->mTheoraFormatInfo->frameWidth;
+	inFormatBuffer->bmiHeader.biXPelsPerMeter = 2000;   //Fuck knows
+	inFormatBuffer->bmiHeader.biYPelsPerMeter = 2000;   //" " " " " 
+	
+	inFormatBuffer->rcSource.top = 0;
+	inFormatBuffer->rcSource.bottom = locFilter->mTheoraFormatInfo->frameHeight;
+	inFormatBuffer->rcSource.left = 0;
+	inFormatBuffer->rcSource.right = locFilter->mTheoraFormatInfo->frameWidth;
 
+	inFormatBuffer->rcTarget.top = 0;
+	inFormatBuffer->rcTarget.bottom = locFilter->mTheoraFormatInfo->frameHeight;
+	inFormatBuffer->rcTarget.left = 0;
+	inFormatBuffer->rcTarget.right = locFilter->mTheoraFormatInfo->frameWidth;
+
+	inFormatBuffer->dwBitErrorRate=0;
+	return true;
 }
-HRESULT TheoraDecodeFilter::CheckTransform(const CMediaType* inInputMediaType, const CMediaType* inOutputMediaType) {
 
+HRESULT TheoraDecodeFilter::CheckInputType(const CMediaType* inMediaType) {
+	
+	if	( (inMediaType->majortype == MEDIATYPE_Video) &&
+			(inMediaType->subtype == MEDIASUBTYPE_Theora) && (inMediaType->formattype == FORMAT_Theora)
+		)
+	{
+		return S_OK;
+	} else {
+		return S_FALSE;
+	}
 }
+HRESULT TheoraDecodeFilter::CheckTransform(const CMediaType* inInputMediaType, const CMediaType* inOutputMediaType) {
+	return S_OK;
+}
 HRESULT TheoraDecodeFilter::DecideBufferSize(IMemAllocator* inAllocator, ALLOCATOR_PROPERTIES* inPropertyRequest) {
+	debugLog<<endl;
	debugLog<<"DecideBufferSize :"<<endl;
	//FIX::: Abstract this out properly	
 
+	debugLog<<"Allocator is "<<(unsigned long)inAllocator<<endl;
+	//Our error variable
+	HRESULT locHR = S_OK;
+
+	//Create the structures for setproperties to use
+	ALLOCATOR_PROPERTIES locReqAlloc;
+	ALLOCATOR_PROPERTIES locActualAlloc;
+
+	debugLog<<"DecideBufferSize : Requested :"<<endl;
+	debugLog<<"DecideBufferSize : Align     : "<<inPropertyRequest->cbAlign<<endl;
+	debugLog<<"DecideBufferSize : BuffSize  : "<<inPropertyRequest->cbBuffer<<endl;
+	debugLog<<"DecideBufferSize : Prefix    : "<<inPropertyRequest->cbPrefix<<endl;
+	debugLog<<"DecideBufferSize : NumBuffs  : "<<inPropertyRequest->cBuffers<<endl;
+
+
+	const unsigned long MIN_BUFFER_SIZE = 16*16;			//What should this be ????
+	const unsigned long DEFAULT_BUFFER_SIZE = 1024*1024;
+	const unsigned long MIN_NUM_BUFFERS = 1;
+	const unsigned long DEFAULT_NUM_BUFFERS = 1;
+
+	
+	//Validate and change what we have been requested to do.
+	//Allignment of data
+	if (inPropertyRequest->cbAlign <= 0) {
+		locReqAlloc.cbAlign = 1;
+	} else {
+		locReqAlloc.cbAlign = inPropertyRequest->cbAlign;
+	}
+
+	//Size of each buffer
+	if (inPropertyRequest->cbBuffer < MIN_BUFFER_SIZE) {
+		locReqAlloc.cbBuffer = DEFAULT_BUFFER_SIZE;
+	} else {
+		locReqAlloc.cbBuffer = inPropertyRequest->cbBuffer;
+	}
+
+	//How many prefeixed bytes
+	if (inPropertyRequest->cbPrefix < 0) {
+			locReqAlloc.cbPrefix = 0;
+	} else {
+		locReqAlloc.cbPrefix = inPropertyRequest->cbPrefix;
+	}
+
+	//Number of buffers in the allcoator
+	if (inPropertyRequest->cBuffers < MIN_NUM_BUFFERS) {
+		locReqAlloc.cBuffers = DEFAULT_NUM_BUFFERS;
+	} else {
+
+		locReqAlloc.cBuffers = inPropertyRequest->cBuffers;
+	}
+
+	debugLog<<"DecideBufferSize : Modified Request :"<<endl;
+	debugLog<<"DecideBufferSize : Align     : "<<locReqAlloc.cbAlign<<endl;
+	debugLog<<"DecideBufferSize : BuffSize  : "<<locReqAlloc.cbBuffer<<endl;
+	debugLog<<"DecideBufferSize : Prefix    : "<<locReqAlloc.cbPrefix<<endl;
+	debugLog<<"DecideBufferSize : NumBuffs  : "<<locReqAlloc.cBuffers<<endl;
+
+
+	//Set the properties in the allocator
+	locHR = inAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
+
+	debugLog<<"DecideBufferSize : SetProperties returns "<<locHR<<endl;
+	debugLog<<"DecideBufferSize : Actual Params :"<<endl;
+	debugLog<<"DecideBufferSize : Align     : "<<locActualAlloc.cbAlign<<endl;
+	debugLog<<"DecideBufferSize : BuffSize  : "<<locActualAlloc.cbBuffer<<endl;
+	debugLog<<"DecideBufferSize : Prefix    : "<<locActualAlloc.cbPrefix<<endl;
+	debugLog<<"DecideBufferSize : NumBuffs  : "<<locActualAlloc.cBuffers<<endl;
+
+	//Check the response
+	switch (locHR) {
+		case E_POINTER:
+			debugLog<<"DecideBufferSize : SetProperties - NULL POINTER"<<endl;
+			return locHR;
+			
+
+		case VFW_E_ALREADY_COMMITTED:
+			debugLog<<"DecideBufferSize : SetProperties - Already COMMITED"<<endl;
+			return locHR;
+			
+		case VFW_E_BADALIGN:
+			debugLog<<"DecideBufferSize : SetProperties - Bad ALIGN"<<endl;
+			return locHR;
+			
+		case VFW_E_BUFFERS_OUTSTANDING:
+			debugLog<<"DecideBufferSize : SetProperties - BUFFS OUTSTANDING"<<endl;
+			return locHR;
+			
+
+		case S_OK:
+
+			break;
+		default:
+			debugLog<<"DecideBufferSize : SetProperties - UNKNOWN ERROR"<<endl;
+			break;
+
+	}
+
+	
+	//TO DO::: Do we commit ?
+	//RESOLVED ::: Yep !
+	
+	locHR = inAllocator->Commit();
+	debugLog<<"DecideBufferSize : Commit Returned "<<locHR<<endl;
+
+
+	switch (locHR) {
+		case E_FAIL:
+			debugLog<<"DecideBufferSize : Commit - FAILED "<<endl;
+			return locHR;
+		case E_POINTER:
+			debugLog<<"DecideBufferSize : Commit - NULL POINTER "<<endl;
+			return locHR;
+		case E_INVALIDARG:
+			debugLog<<"DecideBufferSize : Commit - INVALID ARG "<<endl;
+			return locHR;
+		case E_NOTIMPL:
+			debugLog<<"DecideBufferSize : Commit - NOT IMPL"<<endl;
+			return locHR;
+		case S_OK:
+			debugLog<<"DecideBufferSize : Commit - ** SUCCESS **"<<endl;
+			break;
+		default:
+			debugLog<<"DecideBufferSize : Commit - UNKNOWN ERROR "<<endl;
+			return locHR;
+	}
+
+
+	return S_OK;
 }
 HRESULT TheoraDecodeFilter::GetMediaType(int inPosition, CMediaType* outOutputMediaType) {
-
+	if (inPosition < 0) {
+		return E_INVALIDARG;
+	}
+	
+	if (inPosition == 0) {
+		
+		VIDEOINFOHEADER* locVideoFormat = (VIDEOINFOHEADER*)outOutputMediaType->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
+		FillVideoInfoHeader(locVideoFormat);
+		FillMediaType(outOutputMediaType, locVideoFormat->bmiHeader.biSizeImage);
+		debugLog<<"Vid format size "<<locVideoFormat->bmiHeader.biSizeImage<<endl;
+		//outMediaType->SetSampleSize(locVideoFormat->bmiHeader.biSizeImage);
+		debugLog<<"Returning from GetMediaType"<<endl;
+		return S_OK;
+	} else {
+		return VFW_S_NO_MORE_ITEMS;
+	}
 }
 HRESULT TheoraDecodeFilter::Transform(IMediaSample* inInputSample, IMediaSample* outOutputSample) {
 
+	return S_OK;
 }
 
 

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h	2004-09-09 13:51:51 UTC (rev 7720)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/TheoraDecodeFilter.h	2004-09-09 14:03:00 UTC (rev 7721)
@@ -33,6 +33,8 @@
 
 #include "Theoradecoderdllstuff.h"
 
+#include <fstream>
+using namespace std;
 class TheoraDecodeFilter 
 	:	public CVideoTransformFilter
 
@@ -51,8 +53,12 @@
 	virtual HRESULT GetMediaType(int inPosition, CMediaType* outOutputMediaType);
 	virtual HRESULT Transform(IMediaSample* inInputSample, IMediaSample* outOutputSample);
 
-
-
+protected:
+	void FillMediaType(CMediaType* outMediaType, unsigned long inSampleSize);
+	bool FillVideoInfoHeader(VIDEOINFOHEADER* inFormatBuffer);
+	//Format Block
+	sTheoraFormatBlock* mTheoraFormatInfo;
+	fstream debugLog;
 };
 //---------------------------------------
 //OLD IMPLOEMENTATION....

Modified: trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/dsfTheoraDecoder.vcproj
===================================================================
--- trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/dsfTheoraDecoder.vcproj	2004-09-09 13:51:51 UTC (rev 7720)
+++ trunk/oggdsf/src/lib/codecs/theora/filters/dsfTheoraDecoder/dsfTheoraDecoder.vcproj	2004-09-09 14:03:00 UTC (rev 7721)
@@ -296,12 +296,6 @@
 				RelativePath="TheoraDecodeFilter.cpp">
 			</File>
 			<File
-				RelativePath="TheoraDecodeInputPin.cpp">
-			</File>
-			<File
-				RelativePath="TheoraDecodeOutputPin.cpp">
-			</File>
-			<File
 				RelativePath="theoradecoder.def">
 			</File>
 		</Filter>
@@ -315,12 +309,6 @@
 				RelativePath="TheoraDecodeFilter.h">
 			</File>
 			<File
-				RelativePath="TheoraDecodeInputPin.h">
-			</File>
-			<File
-				RelativePath="TheoraDecodeOutputPin.h">
-			</File>
-			<File
 				RelativePath="theoradecoderdllstuff.h">
 			</File>
 		</Filter>



More information about the commits mailing list