mfplat: Initial support for WAVE_FORMAT_EXTENSIBLE in MFInitMediaTypeFromWaveFormatEx().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d5c5e73638
commit
1ff8014a77
|
@ -2107,6 +2107,7 @@ static void mediatype_set_guid(IMFMediaType *mediatype, const GUID *attr, const
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size)
|
HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size)
|
||||||
{
|
{
|
||||||
|
const WAVEFORMATEXTENSIBLE *wfex = (const WAVEFORMATEXTENSIBLE *)format;
|
||||||
GUID subtype;
|
GUID subtype;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
@ -2115,21 +2116,35 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA
|
||||||
if (!mediatype || !format)
|
if (!mediatype || !format)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
if (format->cbSize && format->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
|
||||||
{
|
return E_INVALIDARG;
|
||||||
FIXME("WAVE_FORMAT_EXTENSIBLE is not supported.\n");
|
|
||||||
return E_NOTIMPL;
|
if (format->cbSize + sizeof(*format) > size)
|
||||||
}
|
return E_INVALIDARG;
|
||||||
else
|
|
||||||
{
|
|
||||||
hr = IMFMediaType_DeleteAllItems(mediatype);
|
hr = IMFMediaType_DeleteAllItems(mediatype);
|
||||||
|
|
||||||
mediatype_set_guid(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio, &hr);
|
mediatype_set_guid(mediatype, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio, &hr);
|
||||||
|
|
||||||
|
if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
||||||
|
{
|
||||||
|
mediatype_set_guid(mediatype, &MF_MT_SUBTYPE, &wfex->SubFormat, &hr);
|
||||||
|
|
||||||
|
if (wfex->dwChannelMask)
|
||||||
|
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_CHANNEL_MASK, wfex->dwChannelMask, &hr);
|
||||||
|
|
||||||
|
if (format->wBitsPerSample && wfex->Samples.wValidBitsPerSample)
|
||||||
|
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, wfex->Samples.wValidBitsPerSample, &hr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
memcpy(&subtype, &MFAudioFormat_Base, sizeof(subtype));
|
memcpy(&subtype, &MFAudioFormat_Base, sizeof(subtype));
|
||||||
subtype.Data1 = format->wFormatTag;
|
subtype.Data1 = format->wFormatTag;
|
||||||
mediatype_set_guid(mediatype, &MF_MT_SUBTYPE, &subtype, &hr);
|
mediatype_set_guid(mediatype, &MF_MT_SUBTYPE, &subtype, &hr);
|
||||||
|
|
||||||
|
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1, &hr);
|
||||||
|
}
|
||||||
|
|
||||||
if (format->nChannels)
|
if (format->nChannels)
|
||||||
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_NUM_CHANNELS, format->nChannels, &hr);
|
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_NUM_CHANNELS, format->nChannels, &hr);
|
||||||
|
|
||||||
|
@ -2145,17 +2160,10 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA
|
||||||
if (format->wBitsPerSample)
|
if (format->wBitsPerSample)
|
||||||
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_BITS_PER_SAMPLE, format->wBitsPerSample, &hr);
|
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_BITS_PER_SAMPLE, format->wBitsPerSample, &hr);
|
||||||
|
|
||||||
mediatype_set_uint32(mediatype, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1, &hr);
|
if (IsEqualGUID(&subtype, &MFAudioFormat_PCM) ||
|
||||||
}
|
IsEqualGUID(&subtype, &MFAudioFormat_Float))
|
||||||
|
|
||||||
switch (subtype.Data1)
|
|
||||||
{
|
{
|
||||||
case WAVE_FORMAT_PCM:
|
|
||||||
case WAVE_FORMAT_IEEE_FLOAT:
|
|
||||||
mediatype_set_uint32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1, &hr);
|
mediatype_set_uint32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1, &hr);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
FIXME("Unhandled type %d.\n", subtype.Data1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#include "initguid.h"
|
#include "initguid.h"
|
||||||
#include "d3d11_4.h"
|
#include "d3d11_4.h"
|
||||||
#include "d3d9types.h"
|
#include "d3d9types.h"
|
||||||
|
#include "ks.h"
|
||||||
|
#include "ksmedia.h"
|
||||||
|
|
||||||
DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19);
|
DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19);
|
||||||
DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21);
|
DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21);
|
||||||
|
@ -5099,6 +5101,22 @@ static void validate_media_type(IMFMediaType *mediatype, const WAVEFORMATEX *for
|
||||||
|
|
||||||
if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
if (format->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
|
const WAVEFORMATEXTENSIBLE *fex = (const WAVEFORMATEXTENSIBLE *)format;
|
||||||
|
ok(IsEqualGUID(&guid, &fex->SubFormat), "Unexpected subtype %s.\n", wine_dbgstr_guid(&guid));
|
||||||
|
|
||||||
|
if (fex->dwChannelMask)
|
||||||
|
{
|
||||||
|
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_CHANNEL_MASK, &value);
|
||||||
|
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
|
||||||
|
ok(value == fex->dwChannelMask, "Unexpected CHANNEL_MASK %#x.\n", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format->wBitsPerSample && fex->Samples.wValidBitsPerSample)
|
||||||
|
{
|
||||||
|
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, &value);
|
||||||
|
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
|
||||||
|
ok(value == fex->Samples.wValidBitsPerSample, "Unexpected VALID_BITS_PER_SAMPLE %#x.\n", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5106,6 +5124,11 @@ static void validate_media_type(IMFMediaType *mediatype, const WAVEFORMATEX *for
|
||||||
subtype.Data1 = format->wFormatTag;
|
subtype.Data1 = format->wFormatTag;
|
||||||
ok(IsEqualGUID(&guid, &subtype), "Unexpected subtype %s.\n", wine_dbgstr_guid(&guid));
|
ok(IsEqualGUID(&guid, &subtype), "Unexpected subtype %s.\n", wine_dbgstr_guid(&guid));
|
||||||
|
|
||||||
|
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, &value);
|
||||||
|
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
|
||||||
|
ok(value, "Unexpected value.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (format->nChannels)
|
if (format->nChannels)
|
||||||
{
|
{
|
||||||
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_NUM_CHANNELS, &value);
|
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_NUM_CHANNELS, &value);
|
||||||
|
@ -5141,14 +5164,16 @@ static void validate_media_type(IMFMediaType *mediatype, const WAVEFORMATEX *for
|
||||||
ok(value == format->wBitsPerSample, "Unexpected BITS_PER_SAMPLE %u.\n", value);
|
ok(value == format->wBitsPerSample, "Unexpected BITS_PER_SAMPLE %u.\n", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, &value);
|
|
||||||
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
|
|
||||||
ok(value, "Unexpected value.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only set for uncompressed formats. */
|
/* Only set for uncompressed formats. */
|
||||||
if (SUCCEEDED(IMFMediaType_GetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value)))
|
hr = IMFMediaType_GetUINT32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, &value);
|
||||||
|
if (IsEqualGUID(&guid, &MFAudioFormat_Float) ||
|
||||||
|
IsEqualGUID(&guid, &MFAudioFormat_PCM))
|
||||||
|
{
|
||||||
|
ok(hr == S_OK, "Failed to get attribute, hr %#x.\n", hr);
|
||||||
ok(value, "Unexpected ALL_SAMPLES_INDEPENDENT value.\n");
|
ok(value, "Unexpected ALL_SAMPLES_INDEPENDENT value.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok(FAILED(hr), "Unexpected ALL_SAMPLES_INDEPENDENT.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_MFInitMediaTypeFromWaveFormatEx(void)
|
static void test_MFInitMediaTypeFromWaveFormatEx(void)
|
||||||
|
@ -5159,9 +5184,29 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
|
||||||
{ WAVE_FORMAT_PCM, 2, 44100, 1, 2, 8 },
|
{ WAVE_FORMAT_PCM, 2, 44100, 1, 2, 8 },
|
||||||
{ WAVE_FORMAT_PCM, 0, 44100, 0, 0, 0 },
|
{ WAVE_FORMAT_PCM, 0, 44100, 0, 0, 0 },
|
||||||
{ WAVE_FORMAT_PCM, 0, 0, 0, 0, 0 },
|
{ WAVE_FORMAT_PCM, 0, 0, 0, 0, 0 },
|
||||||
|
{ WAVE_FORMAT_IEEE_FLOAT, 2, 44100, 1, 2, 8 },
|
||||||
{ 1234, 0, 0, 0, 0, 0 },
|
{ 1234, 0, 0, 0, 0, 0 },
|
||||||
{ WAVE_FORMAT_MPEGLAYER3, 0, 0, 0, 0, 0 },
|
{ WAVE_FORMAT_ALAW },
|
||||||
|
{ WAVE_FORMAT_CREATIVE_ADPCM },
|
||||||
|
{ WAVE_FORMAT_MPEGLAYER3 },
|
||||||
|
{ WAVE_FORMAT_MPEG_ADTS_AAC },
|
||||||
|
{ WAVE_FORMAT_ALAC },
|
||||||
|
{ WAVE_FORMAT_AMR_NB },
|
||||||
|
{ WAVE_FORMAT_AMR_WB },
|
||||||
|
{ WAVE_FORMAT_AMR_WP },
|
||||||
|
{ WAVE_FORMAT_DOLBY_AC3_SPDIF },
|
||||||
|
{ WAVE_FORMAT_DRM },
|
||||||
|
{ WAVE_FORMAT_DTS },
|
||||||
|
{ WAVE_FORMAT_FLAC },
|
||||||
|
{ WAVE_FORMAT_MPEG },
|
||||||
|
{ WAVE_FORMAT_WMAVOICE9 },
|
||||||
|
{ WAVE_FORMAT_OPUS },
|
||||||
|
{ WAVE_FORMAT_WMAUDIO2 },
|
||||||
|
{ WAVE_FORMAT_WMAUDIO3 },
|
||||||
|
{ WAVE_FORMAT_WMAUDIO_LOSSLESS },
|
||||||
|
{ WAVE_FORMAT_WMASPDIF },
|
||||||
};
|
};
|
||||||
|
WAVEFORMATEXTENSIBLE waveformatext;
|
||||||
IMFMediaType *mediatype;
|
IMFMediaType *mediatype;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -5172,9 +5217,21 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
|
||||||
for (i = 0; i < ARRAY_SIZE(waveformatex_tests); ++i)
|
for (i = 0; i < ARRAY_SIZE(waveformatex_tests); ++i)
|
||||||
{
|
{
|
||||||
hr = MFInitMediaTypeFromWaveFormatEx(mediatype, &waveformatex_tests[i], sizeof(waveformatex_tests[i]));
|
hr = MFInitMediaTypeFromWaveFormatEx(mediatype, &waveformatex_tests[i], sizeof(waveformatex_tests[i]));
|
||||||
ok(hr == S_OK, "Failed to initialize media type, hr %#x.\n", hr);
|
ok(hr == S_OK, "%d: format %#x, failed to initialize media type, hr %#x.\n", i, waveformatex_tests[i].wFormatTag, hr);
|
||||||
|
|
||||||
validate_media_type(mediatype, &waveformatex_tests[i]);
|
validate_media_type(mediatype, &waveformatex_tests[i]);
|
||||||
|
|
||||||
|
waveformatext.Format = waveformatex_tests[i];
|
||||||
|
waveformatext.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
|
||||||
|
waveformatext.Format.cbSize = sizeof(waveformatext) - sizeof(waveformatext.Format);
|
||||||
|
waveformatext.Samples.wSamplesPerBlock = 123;
|
||||||
|
waveformatext.dwChannelMask = 0x8;
|
||||||
|
memcpy(&waveformatext.SubFormat, &MFAudioFormat_Base, sizeof(waveformatext.SubFormat));
|
||||||
|
waveformatext.SubFormat.Data1 = waveformatex_tests[i].wFormatTag;
|
||||||
|
hr = MFInitMediaTypeFromWaveFormatEx(mediatype, &waveformatext.Format, sizeof(waveformatext));
|
||||||
|
ok(hr == S_OK, "Failed to initialize media type, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
validate_media_type(mediatype, &waveformatext.Format);
|
||||||
}
|
}
|
||||||
|
|
||||||
IMFMediaType_Release(mediatype);
|
IMFMediaType_Release(mediatype);
|
||||||
|
|
Loading…
Reference in New Issue