Search code examples
c++winapiaudioms-media-foundation

MFTEnumEx cannot find MFAudioFormat_MP3 decoder on Windows 7?


As an offshoot question from: IMFTransform SetInputType()/SetOutputType() fails

When I try to enumerate MP3 decoders on Windows 7 it fails to find any MP3 decoders? However it appears to find one when I set a partial media type for a IMFSourceReader for an MP3 file created by MFCreateSourceReaderFromURL.

I have tried:

MFT_REGISTER_TYPE_INFO outType{ MFMediaType_Audio, MFAudioFormat_Float };   //  And MFAudioFormat_PCM, MFAudioFormat_Float
MFT_REGISTER_TYPE_INFO inType{ MFMediaType_Audio, MFAudioFormat_MP3 };
IMFActivate** decoders;
UINT32 decoderCount;
HRESULT hr;

hr = MFTEnumEx(MFT_CATEGORY_AUDIO_DECODER, MFT_ENUM_FLAG_SYNCMFT, &inType, &outType, &decoders, &decoderCount);
SUCCEEDED(hr);

I believe I have tried all the different flags to MFTEnumEx but decoderCount still gives zero?


Solution

  • Windows 7 SP1 decoder:

    MP3 Decoder MFT

    • MFT_TRANSFORM_CLSID_Attribute: {BBEEA841-0A63-4F52-A7AB-A9B3A84ED38A} (Type VT_CLSID)
    • MF_TRANSFORM_FLAGS_Attribute: MFT_ENUM_FLAG_SYNCMFT
    • MFT_INPUT_TYPES_Attributes: MFAudioFormat_MP3
    • MFT_OUTPUT_TYPES_Attributes: MFAudioFormat_PCM

    The decoder does not advertise support for MFAudioFormat_Float for decoding (even tough it can support it too once instantiated). When you enumerate decoders limiting output to MFAudioFormat_Float the decoder is excluded. Newer versions of OS might either have updated decoder with more output format options.

    If you did it this way:

    MFT_REGISTER_TYPE_INFO outType { MFMediaType_Audio, MFAudioFormat_PCM };

    or nullptr output media type, the decoder would be enumerated.

    Also Source Reader API, generally speaking, uses the same MFTEnum logic in order to fit actual source media type to requested media type.

    When enumerating also pay attention to flags: it might be not so important to you to pick exactly synchronous MFT, but your API call suggests you are requesting to skip asynchronous.