[xiph-commits] r8085 - in trunk/oggdsf/src/lib/codecs: dirac/filters/dsfDiracDecodeSource flac/filters/dsfNativeFLACSource

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Mon Oct 25 00:17:11 PDT 2004


Author: illiminable
Date: 2004-10-25 00:17:11 -0700 (Mon, 25 Oct 2004)
New Revision: 8085

Added:
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.cpp
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.h
Modified:
   trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.cpp
   trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.h
   trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.cpp
   trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.h
   trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/dsfNativeFLACSource.vcproj
Log:
* Skeleton of native FLAC filter.

Modified: trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.cpp	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.cpp	2004-10-25 07:17:11 UTC (rev 8085)
@@ -1,3 +1,33 @@
+//===========================================================================
+//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 ".\DiracDecodeSourceFilter.h"
 

Modified: trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.h	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourceFilter.h	2004-10-25 07:17:11 UTC (rev 8085)
@@ -1,4 +1,33 @@
-
+//===========================================================================
+//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 "dsfDiracDecodeSource.h"
 

Modified: trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.cpp	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.cpp	2004-10-25 07:17:11 UTC (rev 8085)
@@ -1,3 +1,33 @@
+//===========================================================================
+//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 ".\DiracDecodeSourcePin.h"
 

Modified: trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.h	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/dirac/filters/dsfDiracDecodeSource/DiracDecodeSourcePin.h	2004-10-25 07:17:11 UTC (rev 8085)
@@ -1,9 +1,6 @@
 //===========================================================================
 //Copyright (C) 2003, 2004 Zentaro Kavanagh
 //
-//Copyright (C) 2003, 2004 Commonwealth Scientific and Industrial Research
-//   Organisation (CSIRO) Australia
-//
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
 //are met:

Added: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.cpp	2004-10-25 07:17:11 UTC (rev 8085)
@@ -0,0 +1,318 @@
+//===========================================================================
+//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 ".\NativeFLACSourceFilter.h"
+
+CFactoryTemplate g_Templates[] = 
+{
+    { 
+		L"NativeFLACSourceFilter",						// Name
+	    &CLSID_NativeFLACSourceFilter,            // CLSID
+	    NativeFLACSourceFilter::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 NativeFLACSourceFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
+{
+	NativeFLACSourceFilter *pNewObject = new NativeFLACSourceFilter();
+    if (pNewObject == NULL) {
+        *pHr = E_OUTOFMEMORY;
+    }
+    return pNewObject;
+} 
+
+NativeFLACSourceFilter::NativeFLACSourceFilter(void)
+	:	CBaseFilter(NAME("NativeFLACSourceFilter"), NULL, m_pLock, CLSID_NativeFLACSourceFilter)
+	,	mDecoder(NULL)
+{
+	mDiracSourcePin = new NativeFLACSourcePin(this, m_pLock);
+}
+
+NativeFLACSourceFilter::~NativeFLACSourceFilter(void)
+{
+	delete mFLACSourcePin;
+	mFLACSourcePin = NULL;
+}
+
+//BaseFilter Interface
+int NativeFLACSourceFilter::GetPinCount() {
+	return 1;
+}
+CBasePin* NativeFLACSourceFilter::GetPin(int inPinNo) {
+
+	if (inPinNo == 0) {
+		return mFLACSourcePin;
+	} else {
+		return NULL;
+	}
+}
+
+//IAMFilterMiscFlags Interface
+ULONG NativeFLACSourceFilter::GetMiscFlags(void) {
+	return AM_FILTER_MISC_FLAGS_IS_SOURCE;
+}
+
+	//IFileSource Interface
+STDMETHODIMP NativeFLACSourceFilter::GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType) {
+	//Return the filename and mediatype of the raw data
+
+	 
+	LPOLESTR x = SysAllocString(mFileName.c_str());
+	*outFileName = x;
+	
+	return S_OK;
+}
+
+//ANX::: Seek table will need modifying to handle this.
+STDMETHODIMP NativeFLACSourceFilter::Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType) {
+	//Initialise the file here and setup all the streams
+	CAutoLock locLock(m_pLock);
+	mFileName = inFileName;
+
+	//Strip the extension...
+	//size_t locDotPos = mFileName.find_last_of('.');
+	//if (locDotPos != ios_base::npos) {
+	//	mHDRFileName = mFileName.substr(0, locDotPos);
+	//	mHDRFileName += ".hdr";
+	//} else {
+	//	return S_FALSE;
+	//}
+
+	mInputFile.open(StringHelper::toNarrowStr(mFileName), ios_base::in | ios_base::binary);
+
+	if (!mInputFile.is_open()) {
+		return S_FALSE;
+	}
+
+
+	
+	return S_OK;
+}
+
+STDMETHODIMP NativeFLACSourceFilter::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+{
+
+	return CBaseFilter::NonDelegatingQueryInterface(riid, ppv); 
+}
+
+
+//IMEdiaStreaming
+STDMETHODIMP NativeFLACSourceFilter::Run(REFERENCE_TIME tStart) {
+	const REFERENCE_TIME A_LONG_TIME = UNITS * 1000;
+	CAutoLock locLock(m_pLock);
+	//debugLog<<"Run  :  time = "<<tStart<<endl;
+	//DeliverNewSegment(tStart, tStart + A_LONG_TIME, 1.0);
+	return CBaseFilter::Run(tStart);
+	
+
+}
+STDMETHODIMP NativeFLACSourceFilter::Pause(void) {
+	CAutoLock locLock(m_pLock);
+	//debugLog << "** Pause called **"<<endl;
+	if (m_State == State_Stopped) {
+		//debugLog << "Was in stopped state... starting thread"<<endl;
+		if (ThreadExists() == FALSE) {
+			Create();
+		}
+		CallWorker(THREAD_RUN);
+	}
+	//debugLog<<"Was NOT is stopped state, not doing much at all..."<<endl;
+	
+	HRESULT locHR = CBaseFilter::Pause();
+	
+	return locHR;
+	
+}
+STDMETHODIMP NativeFLACSourceFilter::Stop(void) {
+	CAutoLock locLock(m_pLock);
+	//debugLog<<"** Stop Called ** "<<endl;
+	CallWorker(THREAD_EXIT);
+	Close();
+	//DeliverBeginFlush();
+	//DeliverEndFlush();
+	return CBaseFilter::Stop();
+}
+
+HRESULT NativeFLACSourceFilter::DataProcessLoop() {
+
+    do 
+    {
+        /* parse the input data */
+        state = dirac_parse(decoder);
+        
+        switch (state)
+        {
+        case STATE_BUFFER:
+            /*
+            * parser is out of data. Read data from input stream and pass it
+            * on to the parser
+            */
+            bytes = fread (buffer, 1, sizeof(buffer), ifp);
+            if (bytes)
+                dirac_buffer (decoder, buffer, buffer + bytes);
+            break;
+
+        case STATE_SEQUENCE:
+            {
+            /*
+            * Start of sequence detected. Allocate for the frame buffers and
+            * pass this buffer to the parser
+            */
+            unsigned char *buf[3];
+
+            if (verbose)
+            {
+                fprintf (stderr, "SEQUENCE : width=%d height=%d chroma=%s chroma_width=%d chroma_height=%d num_frames=%d frame_rate=%d, interlace=%s topfieldfirst=%s\n", 
+                decoder->seq_params.width,
+                decoder->seq_params.height,
+                chroma2string(decoder->seq_params.chroma),
+                decoder->seq_params.chroma_width,
+                decoder->seq_params.chroma_height,
+                decoder->seq_params.num_frames,
+                decoder->seq_params.frame_rate,
+                decoder->seq_params.interlace ? "yes" : "no",
+                decoder->seq_params.interlace ? "yes" : "no");
+            }
+
+            FreeFrameBuffer(decoder);
+
+            buf[0] = buf[1] = buf[2] = 0;
+
+            buf[0] = (unsigned char *)malloc (decoder->seq_params.width * decoder->seq_params.height);
+            if (decoder->seq_params.chroma != Yonly)
+            {
+                buf[1] = (unsigned char *)malloc (decoder->seq_params.chroma_width * decoder->seq_params.chroma_height);
+                buf[2] = (unsigned char *)malloc (decoder->seq_params.chroma_width * decoder->seq_params.chroma_height);
+            }
+            dirac_set_buf (decoder, buf, NULL);
+
+            /* write the header file */
+            WritePicHeader(decoder, fphdr);
+            }
+            break;
+
+        case STATE_SEQUENCE_END:
+            /*
+            * End of Sequence detected. Free the frame buffers
+            */
+            if (verbose)
+                fprintf (stderr, "SEQUENCE_END\n");
+            
+            FreeFrameBuffer(decoder);
+            break;
+        
+        case STATE_PICTURE_START:
+            /*
+            * Start of frame detected. If decoder is too slow and frame can be
+            * skipped, inform the parser to skip decoding the frame
+            */
+            num_frames++;
+            if (verbose)
+            {
+                fprintf (stderr, "PICTURE_START : frame_type=%s frame_num=%d\n",
+                    ftype2string(decoder->frame_params.ftype),
+                    decoder->frame_params.fnum);
+            }
+            /* Just for testing skip every L2_frame */
+            if (skip && decoder->frame_params.ftype == L2_frame)
+            {
+                if (verbose)
+                    fprintf (stderr, "              : Skipping frame\n");
+
+                dirac_skip (decoder, 1);
+            }
+            else
+                dirac_skip (decoder, 0);
+            break;
+
+        case STATE_PICTURE_AVAIL:
+            if (verbose)
+            {
+                fprintf (stderr, "PICTURE_AVAIL : frame_type=%s frame_num=%d\n",
+                    ftype2string(decoder->frame_params.ftype),
+                    decoder->frame_params.fnum);
+            }
+            /* picture available for display */
+            WritePicData(decoder, fpdata);
+            break;
+
+        case STATE_INVALID:
+            /* Invalid state. Stop all processing */
+            fprintf (stderr, "Error processing file %s\n", iname);
+            break;
+
+        default:
+            continue;
+        }
+    } while (bytes > 0 && state != STATE_INVALID);
+
+
+
+
+
+	return S_OK;
+}
+
+//CAMThread Stuff
+DWORD NativeFLACSourceFilter::ThreadProc(void) {
+	//debugLog << "Thread Proc Called..."<<endl;
+	while(true) {
+		DWORD locThreadCommand = GetRequest();
+		//debugLog << "Command = "<<locThreadCommand<<endl;
+		switch(locThreadCommand) {
+			case THREAD_EXIT:
+				//debugLog << "EXIT ** "<<endl;
+				Reply(S_OK);
+				return S_OK;
+
+			//case THREAD_PAUSE:
+			//	// we are paused already
+			//	Reply(S_OK);
+			//	break;
+
+			case THREAD_RUN:
+				//debugLog << "RUN ** "<<endl;
+				Reply(S_OK);
+				DataProcessLoop();
+				break;
+		}
+	
+	
+	}
+	return S_OK;
+}
\ No newline at end of file

Added: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourceFilter.h	2004-10-25 07:17:11 UTC (rev 8085)
@@ -0,0 +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.
+//===========================================================================
+#pragma once
+#include "dsfNativeFLACSource.h"
+
+#include <string>
+using namespace std;
+
+
+class NativeFLACSourcePin;
+class NativeFLACSourceFilter
+	:	public CBaseFilter
+	,	public IFileSourceFilter
+	,	public IAMFilterMiscFlags
+	,	public CAMThread
+{
+public:
+	enum eThreadCommands {
+		THREAD_EXIT = 0,
+		THREAD_PAUSE = 1,
+		THREAD_RUN = 2
+	};
+	DECLARE_IUNKNOWN
+	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+
+	NativeFLACSourceFilter(void);
+	virtual ~NativeFLACSourceFilter(void);
+
+	static CUnknown* WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
+
+	//IBaseFilter Pure Virtuals
+	virtual int GetPinCount();
+	virtual CBasePin* GetPin(int inPinNo);
+
+	//IAMFilterMiscFlags Interface
+	ULONG STDMETHODCALLTYPE GetMiscFlags(void);
+	//
+
+	//IFileSource Interface
+	virtual STDMETHODIMP GetCurFile(LPOLESTR* outFileName, AM_MEDIA_TYPE* outMediaType);
+	virtual STDMETHODIMP Load(LPCOLESTR inFileName, const AM_MEDIA_TYPE* inMediaType);
+
+	//Streaming MEthods
+	STDMETHODIMP Run(REFERENCE_TIME tStart);
+	STDMETHODIMP Pause(void);
+	STDMETHODIMP Stop(void);
+
+	//CAMThread
+	virtual DWORD ThreadProc(void);
+protected:
+
+	HRESULT DataProcessLoop();
+	NativeFLACSourcePin* mFLACSourcePin;
+	wstring mFileName;
+	wstring mHDRFileName;
+
+
+};

Added: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.cpp	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.cpp	2004-10-25 07:17:11 UTC (rev 8085)
@@ -0,0 +1,150 @@
+//===========================================================================
+//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 ".\NativeFLACSourcePin.h"
+
+NativeFLACSourcePin::NativeFLACSourcePin(NativeFLACSourceFilter* inParentFilter, CCritSec* inFilterLock)
+	:	CBaseOutputPin(NAME("Native FLAC Source Pin"), inParentFilter, inFilterLock, &mFilterHR, L"PCM Out")
+{
+}
+
+NativeFLACSourcePin::~NativeFLACSourcePin(void)
+{
+}
+
+STDMETHODIMP NativeFLACSourcePin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+{
+	
+	return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv); 
+}
+
+HRESULT NativeFLACSourcePin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
+{
+	
+	mDataQueue->NewSegment(tStart, tStop, dRate);
+
+	return S_OK;
+}
+HRESULT NativeFLACSourcePin::DeliverEndOfStream(void)
+{
+	
+	mDataQueue->EOS();
+    return S_OK;
+}
+
+HRESULT NativeFLACSourcePin::DeliverEndFlush(void)
+{
+	mDataQueue->EndFlush();
+    return S_OK;
+}
+
+HRESULT NativeFLACSourcePin::DeliverBeginFlush(void)
+{
+	
+	mDataQueue->BeginFlush();
+    return S_OK;
+}
+
+HRESULT NativeFLACSourcePin::CompleteConnect (IPin *inReceivePin)
+{
+	mFilterHR = S_OK;
+	//Set the delegate for seeking
+	//((BasicSeekable*)(inReceivePin))->SetDelegate(this);
+	//This may cause issue if pins are disconnected and reconnected
+	//DELETE in DEStructor
+	mDataQueue = new COutputQueue (inReceivePin, &mFilterHR, FALSE, TRUE,1,TRUE, NUM_BUFFERS);
+	if (FAILED(mFilterHR)) {
+		mFilterHR = mFilterHR;
+	}
+	
+	return CBaseOutputPin::CompleteConnect(inReceivePin);
+}
+
+HRESULT NativeFLACSourcePin::BreakConnect(void) {
+	delete mDataQueue;
+	mDataQueue = NULL;
+	return CBaseOutputPin::BreakConnect();
+}
+
+	//CSourceStream virtuals
+HRESULT NativeFLACSourcePin::GetMediaType(int inPosition, CMediaType* outMediaType) {
+	//Put it in from the info we got in the constructor.
+	//NOTE::: May have missed some fields ????
+	//NOTE::: May want to check for null pointers
+	//outMediaType->SetFormat(mMediaType->Format(), mMediaType->FormatLength());
+	if (inPosition == 0) {
+		CMediaType locMediaType;
+
+		locMediaType.majortype = MEDIATYPE_Audio;
+		locMediaType.subtype = MEDIASUBTYPE_PCM;
+		locMediaType.formattype = FORMAT_WaveFormatEx;
+		locMediaType.cbFormat = sizeof(WAVEFORMATEX);
+		locMediaType.pbFormat = NULL; //(BYTE*)mCMMLFormatBlock; //(BYTE*)locSpeexFormatInfo;
+		locMediaType.pUnk = NULL;
+		*outMediaType = locMediaType;
+		return S_OK;
+	} else {
+		return VFW_S_NO_MORE_ITEMS;
+	}
+}
+HRESULT NativeFLACSourcePin::CheckMediaType(const CMediaType* inMediaType) {
+	if ((inMediaType->majortype == MEDIATYPE_Audio) && (inMediaType->subtype == MEDIASUBTYPE_PCM)) {
+		return S_OK;
+	} else {
+		return E_FAIL;
+	}
+}
+HRESULT NativeFLACSourcePin::DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest) {
+
+	HRESULT locHR = S_OK;
+
+	ALLOCATOR_PROPERTIES locReqAlloc;
+	ALLOCATOR_PROPERTIES locActualAlloc;
+
+
+	locReqAlloc.cbAlign = 1;
+	locReqAlloc.cbBuffer = BUFFER_SIZE;
+	locReqAlloc.cbPrefix = 0;
+	locReqAlloc.cBuffers = NUM_BUFFERS;
+
+	locHR = inoutAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
+
+	if (locHR != S_OK) {
+		return locHR;
+	}
+	
+	locHR = inoutAllocator->Commit();
+
+	return locHR;
+
+}
+
+

Added: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.h	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/NativeFLACSourcePin.h	2004-10-25 07:17:11 UTC (rev 8085)
@@ -0,0 +1,70 @@
+//===========================================================================
+//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 "dsfNativeFLACSource.h"
+#include "NativeFLACSourceFilter.h"
+#include <fstream>
+using namespace std;
+class NativeFLACSourcePin
+	:	public CBaseOutputPin
+{
+public:
+
+	DECLARE_IUNKNOWN
+	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+
+	NativeFLACSourcePin(	NativeFLACSourceFilter* inParentFilter, CCritSec* inFilterLock);
+					
+	virtual ~NativeFLACSourcePin(void);
+
+	static const unsigned long BUFFER_SIZE = 65536;			//What should this be ????
+	static const unsigned long NUM_BUFFERS = 10;
+
+	//CBaseOutputPin virtuals
+	virtual HRESULT GetMediaType(int inPosition, CMediaType* outMediaType);
+	virtual HRESULT CheckMediaType(const CMediaType* inMediaType);
+	virtual HRESULT DecideBufferSize(IMemAllocator* inoutAllocator, ALLOCATOR_PROPERTIES* inoutInputRequest);
+
+
+	//IPin
+	virtual HRESULT CompleteConnect (IPin *inReceivePin);
+	virtual HRESULT BreakConnect(void);
+	virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+	virtual HRESULT DeliverEndOfStream(void);
+	virtual HRESULT DeliverEndFlush(void);
+	virtual HRESULT DeliverBeginFlush(void);
+protected:
+	//fstream debugLog;
+	HRESULT mFilterHR;
+	COutputQueue* mDataQueue;
+	
+};

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/dsfNativeFLACSource.vcproj
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/dsfNativeFLACSource.vcproj	2004-10-25 07:09:21 UTC (rev 8084)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfNativeFLACSource/dsfNativeFLACSource.vcproj	2004-10-25 07:17:11 UTC (rev 8085)
@@ -118,6 +118,12 @@
 				RelativePath=".\dsfNativeFLACSource.cpp">
 			</File>
 			<File
+				RelativePath=".\NativeFLACSourceFilter.cpp">
+			</File>
+			<File
+				RelativePath=".\NativeFLACSourcePin.cpp">
+			</File>
+			<File
 				RelativePath=".\stdafx.cpp">
 				<FileConfiguration
 					Name="Debug|Win32">
@@ -138,6 +144,12 @@
 			Filter="h;hpp;hxx;hm;inl;inc;xsd"
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
 			<File
+				RelativePath=".\NativeFLACSourceFilter.h">
+			</File>
+			<File
+				RelativePath=".\NativeFLACSourcePin.h">
+			</File>
+			<File
 				RelativePath=".\stdafx.h">
 			</File>
 		</Filter>



More information about the commits mailing list