[xiph-commits] r7271 -

illiminable at dactyl.lonelymoon.com illiminable
Thu Jul 22 21:45:28 PDT 2004


trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder
Message-ID: <20040723044528.D06049AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Thu Jul 22 21:45:28 2004
New Revision: 7271

Modified:
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.cpp
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.h
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.cpp
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.h
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.cpp
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.h
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoder.def
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.cpp
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.h
Log:
* Roughly fleshed out flac encoder filter.

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.cpp	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.cpp	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,10 +1,86 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#include "StdAfx.h"
-#include ".\flacencodefilter.h"

+
+#include "FLACencodefilter.h"
+
+
+//COM Factory Template
+CFactoryTemplate g_Templates[] =
+{
+    {
+		L"FLAC Encode Filter",						// Name
+	    &CLSID_FLACEncodeFilter,            // CLSID
+	    FLACEncodeFilter::CreateInstance,	// Method to create an instance of MyComponent
+        NULL,									// Initialization function
+        NULL									// Set-up information (for filters)
+    }
+
+};
+
+// Generic way of determining the number of items in the template
+int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
+
+CUnknown* WINAPI FLACEncodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
+{
+	//This routine is the COM implementation to create a new Filter
+	FLACEncodeFilter *pNewObject = new FLACEncodeFilter();
+    if (pNewObject == NULL) {
+        *pHr = E_OUTOFMEMORY;
+    }
+	return pNewObject;
+}
+
FLACEncodeFilter::FLACEncodeFilter(void)
+	:	AbstractAudioEncodeFilter(NAME("FLAC Encoder"), CLSID_FLACEncodeFilter, AbstractAudioEncodeFilter::FLAC)
{
+	bool locWasConstructed = ConstructPins();
}

FLACEncodeFilter::~FLACEncodeFilter(void)
{
}
+
+bool FLACEncodeFilter::ConstructPins()
+{
+
+	CMediaType* locOutputMediaType = new CMediaType(&MEDIATYPE_Audio);
+	locOutputMediaType->subtype = MEDIASUBTYPE_FLAC;
+	locOutputMediaType->formattype = FORMAT_FLAC;
+	//Output pin must be done first because it's passed to the input pin.
+	mOutputPin = new FLACEncodeOutputPin(this, m_pLock, locOutputMediaType);
+
+
+	mInputPin = new FLACEncodeInputPin(this, m_pLock, mOutputPin);
+	return true;
+}
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.h	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeFilter.h	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,8 +1,59 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#pragma once

+#include "FLACencoderdllstuff.h"
+#include "AbstractAudioEncodeFilter.h"
+
+//Forward Declarations
+struct sFLACFormatBlock;
+class FLACEncodeInputPin;
+class FLACEncodeOutputPin;
+
class FLACEncodeFilter
+	:	public AbstractAudioEncodeFilter
{
public:
+
+	friend class FLACEncodeOutputPin;
FLACEncodeFilter(void);
-	~FLACEncodeFilter(void);
+	virtual ~FLACEncodeFilter(void);
+
+	static CUnknown* WINAPI FLACEncodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
+
+	//PURE VIRTUAL IMPLEMENTATION
+	virtual bool ConstructPins();
+
+protected:
+	sFLACFormatBlock mFLACFormatBlock;
+
};

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.cpp	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.cpp	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,10 +1,176 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#include "StdAfx.h"
-#include ".\flacencodeinputpin.h"
+#include "FLACencodeinputpin.h"

-FLACEncodeInputPin::FLACEncodeInputPin(void)
+FLACEncodeInputPin::FLACEncodeInputPin(AbstractAudioEncodeFilter* inParentFilter, CCritSec* inFilterLock, AbstractAudioEncodeOutputPin* inOutputPin)
+	:	AbstractAudioEncodeInputPin(inParentFilter, inFilterLock, inOutputPin, NAME("FLACEncodeInputPin"), L"PCM In")
+	,	mFishSound(NULL)
{
+	//debugLog.open("C:\\temp\\FLACenc.log", ios_base::out);
}

FLACEncodeInputPin::~FLACEncodeInputPin(void)
{
+	//debugLog.close();
+	DestroyCodec();
}
+
+
+//PURE VIRTUALS
+long FLACEncodeInputPin::encodeData(unsigned char* inBuf, long inNumBytes) {
+
+
+	//debugLog << "encodeData receives : "<<inNumBytes<<" bytes"<<endl;
+
+	float* locFloatBuf = new float[inNumBytes/2];
+	short locTempShort = 0;
+	float locTempFloat = 0;
+
+	//__int64 locGranPos = 0;
+	//Removed hack for gran pos
+	//fish_sound_command(mFishSound, 8, &locGranPos, sizeof(__int64));
+	//
+	//locGranPos = fish_sound_get_frameno(mFishSound);
+	//mUptoFrame = locGranPos;
+	//__int64 locTemp = ((FishSoundFLACInfo*)mFishSound->codec_data)->vd.pcm_returned;
+	for (int i = 0; i < inNumBytes; i += 2) {
+		locTempShort = *((short*)(inBuf + i));
+		locTempFloat = (float)locTempShort;
+		locTempFloat /= 32767.0;
+		locFloatBuf[i/2] = locTempFloat;;
+	}
+	//debugLog<<"Calling encode"<<endl;
+	//FIX::: The 2 is the size of a sample ie 16 bits
+	long locErr = fish_sound_encode(mFishSound, (float**)locFloatBuf, inNumBytes/(mFishInfo.channels*2));
+	delete locFloatBuf;
+	//FIX::: Do something here ?
+	if (locErr < 0) {
+		//debugLog<<"Fishsound reports error"<<endl;
+	} else {
+
+	}
+	return locErr;
+}
+bool FLACEncodeInputPin::ConstructCodec() {
+	//mFishInfo.channels = mWaveFormat->nChannels;
+	//mFishInfo.format = FISH_SOUND_FLAC;
+	//mFishInfo.samplerate = mWaveFormat->nSamplesPerSec;
+
+
+	//
+	//mFishSound = fish_sound_new (FISH_SOUND_ENCODE, &mFishInfo);
+
+	//int i = 1;
+	////FIX::: Use new API for interleave setting
+	//fish_sound_command(mFishSound, FISH_SOUND_SET_INTERLEAVE, &i, sizeof(int));
+
+	//fish_sound_set_encoded_callback (mFishSound, SpeexEncodeInputPin::SpeexEncoded, this);
+	////FIX::: Proper return value
+	//return true;
+
+}
+void FLACEncodeInputPin::DestroyCodec() {
+	//fish_sound_delete(mFishSound);
+	//mFishSound = NULL;
+}
+
+
+//Encoded callback
+int FLACEncodeInputPin::FLACEncoded (FishSound* inFishSound, unsigned char* inPacketData, long inNumBytes, void* inThisPointer)
+{
+
+	//For convenience we do all these cast once and for all here.
+	FLACEncodeInputPin* locThis = reinterpret_cast<FLACEncodeInputPin*> (inThisPointer);
+	FLACEncodeFilter* locFilter = reinterpret_cast<FLACEncodeFilter*>(locThis->m_pFilter);
+	//locThis->debugLog << "FLACEncoded called with "<<inNumBytes<< " byte of data"<<endl;
+
+	//Time stamps are granule pos not directshow times
+	LONGLONG locFrameStart = locThis->mUptoFrame;
+	LONGLONG locFrameEnd	= locThis->mUptoFrame
+							= fish_sound_get_frameno(locThis->mFishSound);
+
+
+	//locThis->debugLog << "Stamping packet "<<locFrameStart<< " to "<<locFrameEnd<<endl;
+	//Get a pointer to a new sample stamped with our time
+	IMediaSample* locSample;
+	HRESULT locHR = locThis->mOutputPin->GetDeliveryBuffer(&locSample, &locFrameStart, &locFrameEnd, NULL);
+
+	if (FAILED(locHR)) {
+		//We get here when the application goes into stop mode usually.
+		//locThis->debugLog<<"Getting buffer failed"<<endl;
+		return locHR;
+	}
+
+	BYTE* locBuffer = NULL;
+
+
+	//Make our pointers set to point to the samples buffer
+	locSample->GetPointer(&locBuffer);
+
+
+
+	if (locSample->GetSize() >= inNumBytes) {
+
+		memcpy((void*)locBuffer, (const void*)inPacketData, inNumBytes);
+
+		//Set the sample parameters.
+		locThis->SetSampleParams(locSample, inNumBytes, &locFrameStart, &locFrameEnd);
+
+		{
+			CAutoLock locLock(locThis->m_pLock);
+
+			//Add a reference so it isn't deleted en route.
+			//locSample->AddRef();
+			HRESULT locHR = locThis->mOutputPin->mDataQueue->Receive(locSample);						//->DownstreamFilter()->Receive(locSample);
+			if (locHR != S_OK) {
+				//locThis->debugLog<<"Sample rejected"<<endl;
+			} else {
+				//locThis->debugLog<<"Sample Delivered"<<endl;
+			}
+		}
+
+		return 0;
+	} else {
+		throw 0;
+	}
+}
+
+
+HRESULT FLACEncodeInputPin::SetMediaType(const CMediaType* inMediaType) {
+	AbstractAudioEncodeInputPin::SetMediaType(inMediaType);
+
+	ConstructCodec();
+
+	return S_OK;
+
+}
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.h	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeInputPin.h	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,8 +1,72 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#pragma once

+
+#include "AbstractAudioEncodeInputPin.h"
+#include "FLACEncodeInputPin.h"
+
+#include "FLACEncodeFilter.h"
+
+//extern "C" {
+//#include <fishsound/fishsound.h>
+////#include <../src/libfishsound/private.h>
+//}
+
+//#include <fstream>
+//using namespace std;
class FLACEncodeInputPin
+	:	public AbstractAudioEncodeInputPin
{
public:
-	FLACEncodeInputPin(void);
-	~FLACEncodeInputPin(void);
+	FLACEncodeInputPin(AbstractAudioEncodeFilter* inFilter, CCritSec* inFilterLock, AbstractAudioEncodeOutputPin* inOutputPin);
+	virtual ~FLACEncodeInputPin(void);
+
+	static int FLACEncodeInputPin::FLACEncoded (FishSound* inFishSound, unsigned char* inPacketData, long inNumBytes, void* inThisPointer) ;
+	//PURE VIRTUALS
+	virtual long encodeData(unsigned char* inBuf, long inNumBytes);
+	virtual bool ConstructCodec();
+	virtual void DestroyCodec();
+	virtual HRESULT SetMediaType(const CMediaType* inMediaType);
+
+protected:
+	HRESULT mHR;
+	bool mBegun;
+	//SpeexDecodeOutputPin* mOutputPin;
+	//__int64 mUptoFrame;
+
+	//fstream debugLog;
+/*	FishSound* mFishSound;
+	FishSoundInfo mFishInfo;*/
+
+
};

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.cpp	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.cpp	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,10 +1,51 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#include "StdAfx.h"
-#include ".\flacencodeoutputpin.h"
+#include "FLACencodeoutputpin.h"

-FLACEncodeOutputPin::FLACEncodeOutputPin(void)
+FLACEncodeOutputPin::FLACEncodeOutputPin(FLACEncodeFilter* inParentFilter,CCritSec* inFilterLock, CMediaType* inOutputMediaType)
+	:	AbstractAudioEncodeOutputPin(inParentFilter, inFilterLock,NAME("FLACDecodeOutputPin"), L"FLAC Out", inOutputMediaType)
{
}

FLACEncodeOutputPin::~FLACEncodeOutputPin(void)
{
}
+
+bool FLACEncodeOutputPin::FillFormatBuffer(BYTE* inFormatBuffer) {
+	FLACEncodeFilter* locParentFilter = (FLACEncodeFilter*)mParentFilter;
+	memcpy((void*)inFormatBuffer, (const void*) &(locParentFilter->mFLACFormatBlock), sizeof(sFLACFormatBlock));
+	return true;
+}
+unsigned long FLACEncodeOutputPin::FormatBufferSize() {
+	return sizeof(sFLACFormatBlock);
+}

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.h	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/FLACEncodeOutputPin.h	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,8 +1,54 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#pragma once

+#include "FLACencoderdllstuff.h"
+#include "AbstractAudioEncodeOutputPin.h"
+
+class FLACEncodeFilter;
+struct sFLACFormatBlock;
+
class FLACEncodeOutputPin
+	:	public	AbstractAudioEncodeOutputPin
{
public:
-	FLACEncodeOutputPin(void);
-	~FLACEncodeOutputPin(void);
+	FLACEncodeOutputPin(FLACEncodeFilter* inParentFilter, CCritSec* inFilterLock, CMediaType* inOutputMediaType);
+	virtual ~FLACEncodeOutputPin(void);
+
+	//PURE VIRTUAL IMPLEMENTATION
+	virtual bool FillFormatBuffer(BYTE* inFormatBuffer);
+	virtual unsigned long FormatBufferSize();
+
+
+protected:
+
};

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoder.def
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoder.def	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoder.def	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1 +1,7 @@
LIBRARY	dsfFLACEncoder
+EXPORTS
+	DllMain				PRIVATE
+    DllGetClassObject   PRIVATE
+    DllCanUnloadNow     PRIVATE
+    DllRegisterServer   PRIVATE
+    DllUnregisterServer PRIVATE
\ No newline at end of file

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.cpp	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.cpp	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,10 +1,98 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#include "StdAfx.h"
-#include ".\flacencoderdllstuff.h"
+#include "flacencoderdllstuff.h"

-flacencoderdllstuff::flacencoderdllstuff(void)
+extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
+BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
+    return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}

-flacencoderdllstuff::~flacencoderdllstuff(void)
+
+//The folowing two functions do the registration and deregistration of the dll and it's contained com objects.
+STDAPI DllRegisterServer()
{
+
+    HRESULT hr;
+    IFilterMapper2* locFilterMapper = NULL;
+
+    hr = AMovieDllRegisterServer2(TRUE);
+
+
+
+
+    hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void **)&locFilterMapper);
+
+
+	hr = locFilterMapper->RegisterFilter(
+		CLSID_FLACEncodeFilter,						// Filter CLSID.
+		L"FLAC Encode Filter",							// Filter name.
+        NULL,										// Device moniker.
+        &CLSID_LegacyAmFilterCategory,				// Direct Show general category
+        L"FLAC Encode Filter",							// Instance data. ???????
+        &FLACEncodeFilterReg								// Pointer to filter information.
+    );
+
+    locFilterMapper->Release();
+
+    return hr;
+
}
+
+STDAPI DllUnregisterServer()
+{
+   HRESULT hr;
+    IFilterMapper2* locFilterMapper = NULL;
+
+    hr = AMovieDllRegisterServer2(FALSE);
+	if (FAILED(hr)) {
+
+        return hr;
+	}
+
+    hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
+            IID_IFilterMapper2, (void **)&locFilterMapper);
+
+	if (FAILED(hr)) {
+        return hr;
+	}
+
+
+    hr = locFilterMapper->UnregisterFilter(&CLSID_LegacyAmFilterCategory, L"FLAC Encode Filter", CLSID_FLACEncodeFilter);
+
+
+	//
+    locFilterMapper->Release();
+    return hr;
+
+}

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.h	2004-07-23 04:36:58 UTC (rev 7270)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACEncoder/flacencoderdllstuff.h	2004-07-23 04:45:27 UTC (rev 7271)
@@ -1,8 +1,117 @@
+//===========================================================================
+//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+//- Redistributions of source code must retain the above copyright
+//  notice, this list of conditions and the following disclaimer.
+//
+//- Redistributions in binary form must reproduce the above copyright
+//  notice, this list of conditions and the following disclaimer in the
+//  documentation and/or other materials provided with the distribution.
+//
+//- Neither the name of Zentaro Kavanagh nor the names of contributors
+//  may be used to endorse or promote products derived from this software
+//  without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+//PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+//EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+//PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+//LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//===========================================================================
+
#pragma once

-class flacencoderdllstuff
-{
-public:
-	flacencoderdllstuff(void);
-	~flacencoderdllstuff(void);
+
+#ifdef DSFABSTRACOGGAUDIODECODER_EXPORTS
+#pragma message("----> Exporting from Abstract Library...")
+#define ABS_AUDIO_DEC_API __declspec(dllexport)
+#else
+#pragma message("<---- Importing from Abstract Library...")
+#define ABS_AUDIO_DEC_API __declspec(dllimport)
+#endif
+
+//struct sSpeexFormatBlock {
+//	unsigned long speexVersion;
+//	unsigned long samplesPerSec;
+//	unsigned long minBitsPerSec;
+//	unsigned long avgBitsPerSec;
+//	unsigned long maxBitsPerSec;
+//	unsigned long numChannels;
+//
+//};
+#include "AbstractAudioEncodeFilter.h"
+#include "AbstractAudioEncodeInputPin.h"
+#include "AbstractAudioEncodeOutputPin.h"
+#include "FLACEncodeInputPin.h"
+#include "FLACEncodeOutputPin.h"
+#include "FLACEncodeFilter.h"
+
+#ifdef LIBOOOGG_EXPORTS
+#define LIBOOOGG_API __declspec(dllexport)
+#else
+#define LIBOOOGG_API __declspec(dllimport)
+#endif
+
+
+
+
+
+
+const REGPINTYPES FLACEncodeInputTypes = {
+    &MEDIATYPE_Audio,
+	&MEDIASUBTYPE_PCM
};
+
+const REGPINTYPES FLACEncodeOutputTypes = {
+	&MEDIATYPE_Audio,
+	&MEDIASUBTYPE_FLAC
+};
+
+const REGFILTERPINS FLACEncodePinReg[] = {
+	{
+    L"PCM Input",						//Name (obsoleted)
+	FALSE,								//Renders from this pin ?? Not sure about this.
+	FALSE,								//Not an output pin
+	FALSE,								//Cannot have zero instances of this pin
+	FALSE,								//Cannot have more than one instance of this pin
+	NULL,								//Connects to filter (obsoleted)
+	NULL,								//Connects to pin (obsoleted)
+	1,									//upport two media type
+	&FLACEncodeInputTypes				//Pointer to media type (Audio/FLAC or Audio/FLAC)
+	} ,
+
+	{
+	L"FLAC Output",						//Name (obsoleted)
+	FALSE,								//Renders from this pin ?? Not sure about this.
+	TRUE,								//Is an output pin
+	FALSE,								//Cannot have zero instances of this pin
+	FALSE,								//Cannot have more than one instance of this pin
+	NULL,								//Connects to filter (obsoleted)
+	NULL,								//Connects to pin (obsoleted)
+	1,									//Only support one media type
+	&FLACEncodeOutputTypes					//Pointer to media type (Audio/PCM)
+
+	}
+};
+
+
+
+const REGFILTER2 FLACEncodeFilterReg = {
+		1,
+		MERIT_NORMAL,
+		2,
+        FLACEncodePinReg
+
+};
+
+



More information about the commits mailing list