Published by alax on 26 Jul 2008 at 03:14 pm
How To: Implement DirectShow Filter using DirectX Media Object DMO (Part 5: In-Place Processing)
Previously on the topic:
- Part 1: Starting the Project
- Part 2: Video Processing
- Part 3: Persistence, Automation and Property Pages
- Part 4: Merit
Due to the nature of the brightness and constract correction processing, it would make sense to combine and simplify processing to apply correction “in-place”, that is without copying data from input to output buffer, but instead processing the same buffer before it is passed further downstream.
DMO API offers additional optional IMediaObjectInPlace interface to be implemented on the DMO which the hosting object might prefer to regular IMediaObject.
The interface itself is simple with basically the only Process method to actually handle the processing:
// IMediaObjectInPlace STDMETHOD(Process)(ULONG nSize, BYTE* pnData, REFERENCE_TIME nStartTime, DWORD nFlags) STDMETHOD(Clone)(IMediaObjectInPlace** ppMediaObject) STDMETHOD(GetLatency)(REFERENCE_TIME* pnLatencyTime)
Still the interest in in-place processing in DMO is more abstract because current DMO Wrapper Filter implementation does not take advantage of in-place processing and chooses to always work through IMediaObject.
However if the object is hosted directly, in-place processing might make sense and be important.
To support in-place processing in the DMO it is required to inherit from interface and add it to the COM map:
class ATL_NO_VTABLE CBrightnessContrastObject : public CComObjectRootEx<CComMultiThreadModel>, ... public IMediaObjectInPlace ... BEGIN_COM_MAP(CBrightnessContrastObject) ... COM_INTERFACE_ENTRY(IMediaObjectInPlace) END_COM_MAP()
And implement the IMediaObjectInPlace methods, of which IMediaObjectInPlace::Process is the essential.
Source code: DmoBrightnessContrastSample.05.zip (note that Release build binary is included)
Tags: ATL, directshow, dmo, howto, WTL
One Response to “How To: Implement DirectShow Filter using DirectX Media Object DMO (Part 5: In-Place Processing)”
Leave a Reply
You must be logged in to post a comment.

alax on 24 Aug 2008 at 8:57 am #
It appeared in Visual Studio 2008, just comment it out.
Yes, it is an undocumented [yet] feature but generated by default project wizard.
I am pretty sure Microsoft will document it soon and it will be quite useful: it will allow registration of COM classes from under non-admin account. However it might be still not useful enough for DMOs because they will need additional entries under HKEY_CLASSES_ROOT for which there will still be insufficient permissions.
See also: ATL and Visual Studio C++.NET 2008 Goodies