[xiph-commits] r10364 - in branches/oggdsf_new_demux:
build/oggcodecs src/lib/codecs/ogm/filters/dsfOGMDecoder
illiminable at svn.xiph.org
illiminable at svn.xiph.org
Thu Nov 10 23:28:25 PST 2005
Author: illiminable
Date: 2005-11-10 23:28:09 -0800 (Thu, 10 Nov 2005)
New Revision: 10364
Added:
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoder.def
Modified:
branches/oggdsf_new_demux/build/oggcodecs/oggcodecs.vdproj
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.cpp
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.h
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.cpp
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.h
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/dsfOGMDecoder.vcproj
branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoderdllstuff.h
Log:
* More improvements to ogm support.
Modified: branches/oggdsf_new_demux/build/oggcodecs/oggcodecs.vdproj
===================================================================
--- branches/oggdsf_new_demux/build/oggcodecs/oggcodecs.vdproj 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/build/oggcodecs/oggcodecs.vdproj 2005-11-11 07:28:09 UTC (rev 10364)
@@ -33,6 +33,12 @@
}
"Entry"
{
+ "MsmKey" = "8:_0CADC4E67409461481DE8E39EA059436"
+ "OwnerKey" = "8:_UNDEFINED"
+ "MsmSig" = "8:_UNDEFINED"
+ }
+ "Entry"
+ {
"MsmKey" = "8:_0D0DD40A31F842C68B09BE0CBDE1996B"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
@@ -124,6 +130,12 @@
"Entry"
{
"MsmKey" = "8:_46A378A9B03E4612A645053EDB884C20"
+ "OwnerKey" = "8:_0CADC4E67409461481DE8E39EA059436"
+ "MsmSig" = "8:_UNDEFINED"
+ }
+ "Entry"
+ {
+ "MsmKey" = "8:_46A378A9B03E4612A645053EDB884C20"
"OwnerKey" = "8:_FD547F0196C24DFBB9CAFCCEC06561BC"
"MsmSig" = "8:_UNDEFINED"
}
@@ -400,6 +412,12 @@
"Entry"
{
"MsmKey" = "8:_655D5383153A6AB10D15352A7EABCC7A"
+ "OwnerKey" = "8:_0CADC4E67409461481DE8E39EA059436"
+ "MsmSig" = "8:_UNDEFINED"
+ }
+ "Entry"
+ {
+ "MsmKey" = "8:_655D5383153A6AB10D15352A7EABCC7A"
"OwnerKey" = "8:_FD547F0196C24DFBB9CAFCCEC06561BC"
"MsmSig" = "8:_UNDEFINED"
}
@@ -1159,7 +1177,7 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:oggcodecs"
"ProductCode" = "8:{D65F0073-A820-4085-B997-A061171595A7}"
- "PackageCode" = "8:{37D1931B-F37E-4C8C-B337-5416AF0325F7}"
+ "PackageCode" = "8:{41C2F111-483A-400F-92BF-B99A31111F5F}"
"UpgradeCode" = "8:{1A644FEB-7597-4FAB-AADE-C2C7C64C5984}"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
@@ -3861,6 +3879,34 @@
{
}
}
+ "{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_0CADC4E67409461481DE8E39EA059436"
+ {
+ "SourcePath" = "8:..\\..\\src\\lib\\codecs\\ogm\\filters\\dsfogmdecoder\\debug\\dsfOGMDecoder.dll"
+ "TargetName" = "8:"
+ "Tag" = "8:"
+ "Folder" = "8:_371AD289B6DB4693BDF7568485051F1E"
+ "Condition" = "8:"
+ "Transitive" = "11:FALSE"
+ "Vital" = "11:TRUE"
+ "ReadOnly" = "11:FALSE"
+ "Hidden" = "11:FALSE"
+ "System" = "11:FALSE"
+ "Permanent" = "11:FALSE"
+ "SharedLegacy" = "11:FALSE"
+ "PackageAs" = "3:1"
+ "Register" = "3:1"
+ "Exclude" = "11:FALSE"
+ "IsDependency" = "11:FALSE"
+ "IsolateTo" = "8:"
+ "ProjectOutputGroupRegister" = "3:4"
+ "OutputConfiguration" = "8:"
+ "OutputGroupCanonicalName" = "8:Built"
+ "OutputProjectGuid" = "8:{1C4F9412-B1DE-4E65-96C1-89522EF02997}"
+ "ShowKeyOutput" = "11:TRUE"
+ "ExcludeFilters"
+ {
+ }
+ }
"{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_0D0DD40A31F842C68B09BE0CBDE1996B"
{
"SourcePath" = "8:..\\..\\src\\lib\\codecs\\flac\\filters\\dsfFLACEncoder\\Debug\\dsfFLACEncoder.dll"
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.cpp 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.cpp 2005-11-11 07:28:09 UTC (rev 10364)
@@ -55,6 +55,7 @@
: CTransformFilter(NAME("OGM Video Decoder"), NULL, CLSID_OGMDecodeFilter)
, mInputPin(NULL)
, mOutputPin(NULL)
+ , mFramesBuffered(0)
{
@@ -87,10 +88,53 @@
return S_OK;
}
-HRESULT OGMDecodeFilter::DecideBufferSize(IMemAllocator* inAllocator, ALLOCATOR_PROPERTIES* inPropInputRequest)
+HRESULT OGMDecodeFilter::DecideBufferSize(IMemAllocator* inAllocator, ALLOCATOR_PROPERTIES* inPropertyRequest)
{
+ HRESULT locHR = S_OK;
- return S_OK;
+ ALLOCATOR_PROPERTIES locReqAlloc;
+ ALLOCATOR_PROPERTIES locActualAlloc;
+
+ if (inPropertyRequest->cbAlign <= 0) {
+ locReqAlloc.cbAlign = 1;
+ } else {
+ locReqAlloc.cbAlign = inPropertyRequest->cbAlign;
+ }
+
+
+ if (inPropertyRequest->cbBuffer == 0) {
+ locReqAlloc.cbBuffer = 65536*16;
+ } else {
+ locReqAlloc.cbBuffer = inPropertyRequest->cbBuffer;
+ }
+
+
+ if (inPropertyRequest->cbPrefix < 0) {
+ locReqAlloc.cbPrefix = 0;
+ } else {
+ locReqAlloc.cbPrefix = inPropertyRequest->cbPrefix;
+ }
+
+ if (inPropertyRequest->cBuffers == 0) {
+ locReqAlloc.cBuffers = 5;
+ } else {
+ locReqAlloc.cBuffers = inPropertyRequest->cBuffers;
+ }
+
+
+ locHR = inAllocator->SetProperties(&locReqAlloc, &locActualAlloc);
+
+ if (locHR != S_OK) {
+ //TODO::: Handle a fail state here.
+ return locHR;
+ } else {
+ //TODO::: Need to save this pointer to decommit in destructor ???
+ locHR = inAllocator->Commit();
+
+
+ return locHR;
+ }
+
}
HRESULT OGMDecodeFilter::GetMediaType(int inPosition, CMediaType* outMediaType)
{
@@ -104,6 +148,9 @@
VIDEOINFOHEADER* locVideoFormat = (VIDEOINFOHEADER*)outMediaType->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
*locVideoFormat = *mInputPin->getVideoFormatBlock();
//FillMediaType(outMediaType, locVideoFormat->bmiHeader.biSizeImage);
+ outMediaType->majortype = MEDIATYPE_Video;
+ outMediaType->subtype = (GUID)(FOURCCMap(locVideoFormat->bmiHeader.biCompression));;
+ outMediaType->formattype = FORMAT_VideoInfo;
return S_OK;
} else {
@@ -112,9 +159,137 @@
}
+
+HRESULT OGMDecodeFilter::Receive(IMediaSample* inSample)
+{
+ BYTE* locInBuff = NULL;
+ HRESULT locHR = inSample->GetPointer(&locInBuff);
+
+ if (locHR == S_OK) {
+ REFERENCE_TIME locStart = -1;
+ REFERENCE_TIME locEnd = -1;
+ inSample->GetTime(&locStart, &locEnd);
+ if ((locInBuff[0] & 1) != 0) {
+ return S_OK;
+ }
+ unsigned long locLength = inSample->GetActualDataLength();
+ unsigned char* locBuff = new unsigned char[locLength];
+ sSimplePack locPack;
+ memcpy((void*)locBuff, (const void*)locInBuff, locLength);
+ locPack.mBuff = locBuff;
+ locPack.mLength = locLength;
+
+ unsigned long locNumLenBytes = locInBuff[0];
+
+
+ //Find out how many bytes of the header are the length field
+ const unsigned char LEN_MASK = 0x43; //01000011
+ locNumLenBytes &= LEN_MASK;
+ locNumLenBytes = (locNumLenBytes >> 6) | ((locNumLenBytes&2) << 1);
+
+ __int64 locPackTime = 0;
+ for (int i = 0; i < locNumLenBytes; i++) {
+ locPackTime |= ((__int64)locInBuff[1+i] << (i * 8));
+ }
+
+ mFramesBuffered += locPackTime;
+ locPack.mDuration = locPackTime;
+ locPack.mHeaderSize = locNumLenBytes + 1;
+ locPack.mIsKeyframe = ((locInBuff[0] & (1<<3)) != 0);
+
+ mPacketBuffer.push_back(locPack);
+
+ if (locEnd > 0) {
+ REFERENCE_TIME locGlobalStart = 0;
+ REFERENCE_TIME locGlobalEnd = 0;
+
+ __int64 locFrameDuration = mInputPin->getVideoFormatBlock()->AvgTimePerFrame;
+ __int64 locNumBuffered = mPacketBuffer.size();
+
+ locGlobalEnd = locEnd * locFrameDuration;
+ locGlobalStart = locGlobalEnd - (mFramesBuffered * locFrameDuration);
+
+ __int64 locUptoStart = locGlobalStart;
+ __int64 locUptoEnd = locGlobalStart;
+ for (int i = 0; i < locNumBuffered; i++) {
+ IMediaSample* locOutSample = NULL;
+
+ locHR = InitializeOutputSample(inSample, &locOutSample);
+ if (locHR == S_OK) {
+ locUptoEnd = locUptoStart + (mPacketBuffer[i].mDuration * locFrameDuration);
+ locOutSample->SetTime(&locUptoStart, &locUptoEnd);
+ locOutSample->SetMediaTime(&locUptoStart, &locUptoEnd);
+ locOutSample->SetSyncPoint(mPacketBuffer[i].mIsKeyframe);
+ locOutSample->SetActualDataLength(mPacketBuffer[i].mLength - mPacketBuffer[i].mHeaderSize);
+ BYTE* locOutBuff = NULL;
+ locOutSample->GetPointer(&locOutBuff);
+ memcpy((void*)locOutBuff, (const void*)(mPacketBuffer[i].mBuff + mPacketBuffer[i].mHeaderSize), mPacketBuffer[i].mLength - mPacketBuffer[i].mHeaderSize);
+ locHR = m_pOutput->Deliver(locOutSample);
+ locOutSample->Release();
+
+ if (locHR != S_OK) {
+ deleteBufferedPackets();
+ return S_FALSE;
+ }
+
+
+
+
+
+ } else {
+ deleteBufferedPackets();
+ return S_FALSE;
+ }
+
+ }
+
+ deleteBufferedPackets();
+ return S_OK;
+
+
+
+
+
+ } else {
+ return S_OK;
+ }
+
+ }
+}
+
+void OGMDecodeFilter::deleteBufferedPackets()
+{
+ for (size_t i = 0; i < mPacketBuffer.size(); i++) {
+ delete[] mPacketBuffer[i].mBuff;
+ }
+ mPacketBuffer.clear();
+ mFramesBuffered = 0;
+}
HRESULT OGMDecodeFilter::Transform(IMediaSample* inInputSample, IMediaSample* inOutputSample)
{
+ //BYTE* locInBuff = NULL;
+ //HRESULT locHR = inInputSample->GetPointer(&locInBuff);
+
+ //if (locHR == S_OK) {
+ // REFERENCE_TIME locStart = -1;
+ // REFERENCE_TIME locEnd = -1;
+ // inInputSample->GetTime(&locStart, &locEnd);
+ // unsigned long locLength = inInputSample->GetActualDataLength();
+ // unsigned char* locBuff = new unsigned char[locLength];
+ // sSimplePack locPack;
+ // memcpy((void*)locBuff, (const void*)locInBuff, locLength);
+ // locPack.mBuff = locBuff;
+ // locPack.mLength = locLength;
+ // mPacketBuffer.push_back(sSimplePack);
+
+
+
+ //
+
+ //}
+
+
return S_OK;
}
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.h 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeFilter.h 2005-11-11 07:28:09 UTC (rev 10364)
@@ -63,11 +63,25 @@
virtual HRESULT GetMediaType(int iPosition, CMediaType* outMediaType);
virtual HRESULT Transform(IMediaSample* inInputSample, IMediaSample* inOutputSample);
+ virtual HRESULT Receive(IMediaSample* inSample);
+
virtual CBasePin* GetPin(int inPinNo);
protected:
+ void deleteBufferedPackets();
+
OGMDecodeInputPin* mInputPin;
CTransformOutputPin* mOutputPin;
-
+ struct sSimplePack {
+ unsigned char* mBuff;
+ unsigned long mLength;
+ unsigned long mDuration;
+ unsigned long mHeaderSize;
+ bool mIsKeyframe;
+
+ };
+ unsigned long mFramesBuffered;
+
+ vector<sSimplePack> mPacketBuffer;
};
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.cpp 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.cpp 2005-11-11 07:28:09 UTC (rev 10364)
@@ -35,6 +35,7 @@
OGMDecodeInputPin::OGMDecodeInputPin(OGMDecodeFilter* inParentFilter, HRESULT* outHR)
: CTransformInputPin(NAME("OGMDecodeInputPin"), inParentFilter, outHR, L"OGM In")
, mVideoFormatBlock(NULL)
+ , mSetupState(VSS_SEEN_NOTHING)
{
}
@@ -44,8 +45,22 @@
}
+STDMETHODIMP OGMDecodeInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
+{
+ if (riid == IID_IMediaSeeking) {
+ *ppv = (IMediaSeeking*)this;
+ ((IUnknown*)*ppv)->AddRef();
+ return NOERROR;
+ } else if (riid == IID_IOggDecoder) {
+ *ppv = (IOggDecoder*)this;
+ //((IUnknown*)*ppv)->AddRef();
+ return NOERROR;
+ }
+ return CBaseInputPin::NonDelegatingQueryInterface(riid, ppv);
+}
+
HRESULT OGMDecodeInputPin::SetMediaType(const CMediaType* inMediaType)
{
//FIX:::Error checking
@@ -86,7 +101,7 @@
}
LOOG_INT64 OGMDecodeInputPin::convertGranuleToTime(LOOG_INT64 inGranule)
{
- return inGranule;
+ return inGranule * mVideoFormatBlock->AvgTimePerFrame;
}
LOOG_INT64 OGMDecodeInputPin::mustSeekBefore(LOOG_INT64 inGranule)
@@ -100,11 +115,18 @@
case VSS_SEEN_NOTHING:
if (strncmp((char*)inCodecHeaderPacket->packetData(), "\001video\000\000\000", 9) == 0) {
handleHeaderPacket(inCodecHeaderPacket);
+ mSetupState = VSS_SEEN_BOS;
+ return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
+ }
+ mSetupState = VSS_ERROR;
+ return IOggDecoder::AHR_INVALID_HEADER;
+
+ case VSS_SEEN_BOS:
+ if (inCodecHeaderPacket->packetData()[0] == 0x03) {
+ mSetupState = VSS_ALL_HEADERS_SEEN;
return IOggDecoder::AHR_ALL_HEADERS_RECEIVED;
}
return IOggDecoder::AHR_INVALID_HEADER;
-
-
case VSS_ALL_HEADERS_SEEN:
@@ -114,8 +136,8 @@
}
}
-
+
bool OGMDecodeInputPin::handleHeaderPacket(OggPacket* inHeaderPack)
{
delete mVideoFormatBlock;
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.h 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/OGMDecodeInputPin.h 2005-11-11 07:28:09 UTC (rev 10364)
@@ -10,12 +10,18 @@
, public IOggDecoder
{
public:
+ DECLARE_IUNKNOWN
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
+
OGMDecodeInputPin(OGMDecodeFilter* inParent, HRESULT* outHR);
virtual ~OGMDecodeInputPin(void);
virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
virtual HRESULT SetMediaType(const CMediaType* inMediaType);
virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
+
+
+
//IOggDecoder Interface
virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
@@ -38,7 +44,7 @@
VIDEOINFOHEADER* mVideoFormatBlock;
- static const unsigned long OGM_IDENT_HEADER_SIZE = 80;
+ static const unsigned long OGM_IDENT_HEADER_SIZE = 57;
static const unsigned long OGM_NUM_BUFFERS = 50;
static const unsigned long OGM_BUFFER_SIZE = 1024*512*3;;
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/dsfOGMDecoder.vcproj
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/dsfOGMDecoder.vcproj 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/dsfOGMDecoder.vcproj 2005-11-11 07:28:09 UTC (rev 10364)
@@ -37,6 +37,7 @@
OutputFile="$(OutDir)/dsfOGMDecoder.dll"
LinkIncremental="2"
AdditionalLibraryDirectories=""C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug""
+ ModuleDefinitionFile="ogmdecoder.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/dsfOGMDecoder.pdb"
SubSystem="2"
@@ -86,6 +87,7 @@
OutputFile="$(OutDir)/dsfOGMDecoder.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=""C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Release""
+ ModuleDefinitionFile="ogmdecoder.def"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
@@ -131,6 +133,9 @@
RelativePath=".\OGMDecodeOutputPin.cpp">
</File>
<File
+ RelativePath=".\ogmdecoder.def">
+ </File>
+ <File
RelativePath=".\ogmdecoderdllstuff.cpp">
</File>
<File
Added: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoder.def
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoder.def 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoder.def 2005-11-11 07:28:09 UTC (rev 10364)
@@ -0,0 +1,7 @@
+LIBRARY dsfOGMDecoder
+EXPORTS
+ DllMain PRIVATE
+ DllGetClassObject PRIVATE
+ DllCanUnloadNow PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
\ No newline at end of file
Modified: branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoderdllstuff.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoderdllstuff.h 2005-11-10 23:47:09 UTC (rev 10363)
+++ branches/oggdsf_new_demux/src/lib/codecs/ogm/filters/dsfOGMDecoder/ogmdecoderdllstuff.h 2005-11-11 07:28:09 UTC (rev 10364)
@@ -70,10 +70,10 @@
// {43F0F818-10B0-4c86-B9F1-F6B6E2D33462}
DEFINE_GUID(IID_IOggDecoder,
0x43f0f818, 0x10b0, 0x4c86, 0xb9, 0xf1, 0xf6, 0xb6, 0xe2, 0xd3, 0x34, 0x62);
-
-//const REGPINTYPES SpeexDecodeOutputTypes = {
-// &MEDIATYPE_Video,
-// &MEDIASUBTYPE_PCM
+//
+//const REGPINTYPES OGMDecodeOutputTypes = {
+// &MEDIATYPE_None,
+// &MEDIASUBTYPE_None
//};
const REGPINTYPES OGMDecodeInputTypes = {
More information about the commits
mailing list