Previously on the topic:

The implemented so far filter/DMO shown a problem related to its unexpectedly high “importance” in the system with the symptom of “auto-insertion” the filter when it is not necessary. For example, let us render an AVI file through Infinite Tee Pin Filter:

The problem is that DirectShow auto-inserts our Brightness/Contrast filter into the graph while it is obviously not expected, wanted or necessary:

The problem is high filter/DMO merit value and a popular YUY2 video format the filter is advertised to accept on input during DMO registration.

The merit is 0×00600800 and defined values are:

enum
{
    MERIT_PREFERRED     = 0x800000,
    MERIT_NORMAL        = 0x600000,
    MERIT_UNLIKELY      = 0x400000,
    MERIT_DO_NOT_USE    = 0x200000,
    MERIT_SW_COMPRESSOR = 0x100000,
    MERIT_HW_COMPRESSOR = 0x100050
};

So the filter’s merit is MERIT_NORMAL plus 0×800 DMO API adds to give DMOs an advantage over regular filters. If we followed merit choice guidelines (”A filter that should never be considered for ordinary playback should have a merit of MERIT_DO_NOT_USE or less“), we would have taken MERIT_DO_NOT_USE value or MERIT_UNLIKELY at the very most, because the nature of this filter is to provide additional processing feature when it is explicitly requested by the graph creator.

So in order to resolve the problem we need to override DMO’s default merit and review the registration step. To provide our own merit value for the filter, we need to create a REG_DWORD Merit value in advance under coclass registry key in HKEY_CLASSES_ROOT:

OLECHAR pszClassIdentifier[64] = { 0 };
ATLVERIFY(StringFromGUID2(GetObjectCLSID(), pszClassIdentifier, _countof(pszClassIdentifier)));
CRegKey Key;
CString sKeyName;
sKeyName.Format(_T("CLSID\\%ls"), pszClassIdentifier);
__C(HRESULT_FROM_WIN32(Key.Create(HKEY_CLASSES_ROOT, sKeyName)));
static const DWORD g_nMerit = MERIT_DO_NOT_USE;
__C(HRESULT_FROM_WIN32(Key.SetDWORDValue(_T("Merit"), g_nMerit)));

Note that another (even easier) way to pre-create this registry value is putting it into .RGS registration script file (MERIT_DO_NOT_USE = 0×00200000 = 2097152):

HKCR
{
	...
	NoRemove CLSID
	{
		ForceRemove {334BE85B-9DE4-4405-8EEE-9CBB2650F83D} = s 'BrightnessContrastObject Class'
		{
			...
			val Merit = d '2097152'

Source code: DmoBrightnessContrastSample.04.zip (note that Release build binary is included)

See also:

Continued by:

Tags: , , , , ,