user1757226
user1757226

Reputation: 338

DirectShow ColorConverterDMO filter won't accept input formats that it advertises?

I'm trying to use the ColorConverterDMO in my DirectShow filter graph to convert from UYVY to RGB32, but it is particularly uncooperative in allowing connections to it's input pin.

For example, if I enumerate the input pin's media types, and then, for each media type, call the pin's QueryAccept() with that media type, it returns S_FALSE. What's going on here? How can I get the filter to allow it's input pin to be connected to my source filter's output pin?

Here's the example code that shows the creation of the filter and it's unwillingness to accept any of the media types that it advertises. Inside this code, the QueryAccept call always returns S_FALSE.

Any help would be very much appreciated, thanks!

// create filter and put it in the graph
CComPtr<IBaseFilter> colorConvert;
CComPtr<IPin> colorOut, colorIn;
CComPtr<IDMOWrapperFilter> colorConvertIface;

if(FAILED(hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&colorConvert)))
    return hr;

if(FAILED(hr = colorConvert->QueryInterface(IID_IDMOWrapperFilter, (void **)&colorConvertIface)))
    return hr;

if(FAILED(hr = colorConvertIface->Init(CLSID_CColorConvertDMO, DMOCATEGORY_VIDEO_EFFECT)))
    return hr;

if(FAILED(hr = g_pGB->AddFilter(colorConvert, _T("Converter"))))
    return hr;

if(FAILED(hr = colorConvert->FindPin(L"in0",  &colorIn)))
    return hr;

if(FAILED(hr = colorConvert->FindPin(L"out0",  &colorOut)))
    return hr;

// try to get a little info about the frame input source's output pin offering...
CComPtr<IEnumMediaTypes> pMediaTypeEnum;
AM_MEDIA_TYPE *pMediaType;
hr = colorIn->EnumMediaTypes(&pMediaTypeEnum);
int cnt = 1;
while (pMediaTypeEnum->Next(1, &pMediaType, &fetched) == S_OK)
{
    TCHAR str[100];
    _stprintf(str, _T("Input Media Type [%d]:"), cnt++);
    DisplayType(str, pMediaType);

    hr = colorIn->QueryAccept(pMediaType);
    if (hr == S_FALSE)
    {
        //WHY?? You just told me you accepted this type!?!
    }

    DeleteMediaType(pMediaType);
}
pMediaTypeEnum.Release();

Upvotes: 1

Views: 1149

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69724

Color Converter DMO/DSP is not a DirectShow components. It belongs to Windows Media and though it can be (potentially) plugged into DirectShow pipeline through DMO Wrapper Filter, I suspect it had never been an intended scenario undergone any testing.

I have sample code for another DMO and with certain effort it works in DirectShow: Using Vista Video Resizer DSP in DirectShow, via DMO Wrapper Filter. I am under impression that I read in past that someone managed to have Color Converter DMO running in a similar way, in which case the code snippet might be helpful.

Upvotes: 1

Related Questions