Nikolay Sivov (@nsivov) commented about dlls/mfplat/mediatype.c:
WAVEFORMATEXTENSIBLE *format_ext = CONTAINING_RECORD(format, WAVEFORMATEXTENSIBLE, Format);
format_ext->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
format_ext->SubFormat = subtype; if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, &value))) format_ext->Samples.wSamplesPerBlock = value; if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_CHANNEL_MASK, &value))) format_ext->dwChannelMask = value;
memcpy(&format_ext->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM, sizeof(format_ext->SubFormat));
else if (format_ext->Format.nChannels < ARRAY_SIZE(default_channel_mask))
format_ext->dwChannelMask = default_channel_mask[format_ext->Format.nChannels];
}IMFMediaType_GetBlob(mediatype, &MF_MT_USER_DATA, (BYTE *)(format_ext + 1), user_size, NULL);
I don't know if you'll see it as an improvement, but checking for flags equality here is another option, switching blocks around. Up to you.