Commit 3a9ecc58 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfplat/mediatype: Store extra format data as MF_MT_USER_DATA when initializing from WAVEFORMATEX.

parent 141c55a7
......@@ -2943,6 +2943,13 @@ static void mediatype_set_guid(IMFMediaType *mediatype, const GUID *attr, const
*hr = IMFMediaType_SetGUID(mediatype, attr, value);
}
static void mediatype_set_blob(IMFMediaType *mediatype, const GUID *attr, const UINT8 *data,
unsigned int size, HRESULT *hr)
{
if (SUCCEEDED(*hr))
*hr = IMFMediaType_SetBlob(mediatype, attr, data, size);
}
/***********************************************************************
* MFInitMediaTypeFromWaveFormatEx (mfplat.@)
*/
......@@ -2957,9 +2964,6 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA
if (!mediatype || !format)
return E_POINTER;
if (format->cbSize && format->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
return E_INVALIDARG;
if (format->cbSize + sizeof(*format) > size)
return E_INVALIDARG;
......@@ -3007,6 +3011,9 @@ HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WA
mediatype_set_uint32(mediatype, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1, &hr);
}
if (format->cbSize)
mediatype_set_blob(mediatype, &MF_MT_USER_DATA, (const UINT8 *)(format + 1), format->cbSize, &hr);
return hr;
}
......
......@@ -5600,9 +5600,12 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
{ WAVE_FORMAT_WMAUDIO_LOSSLESS },
{ WAVE_FORMAT_WMASPDIF },
};
UINT8 buff[MPEGLAYER3_WFX_EXTRA_BYTES];
WAVEFORMATEXTENSIBLE waveformatext;
MPEGLAYER3WAVEFORMAT mp3format;
IMFMediaType *mediatype;
unsigned int i;
unsigned int i, size;
HRESULT hr;
hr = MFCreateMediaType(&mediatype);
......@@ -5628,6 +5631,29 @@ static void test_MFInitMediaTypeFromWaveFormatEx(void)
validate_media_type(mediatype, &waveformatext.Format);
}
/* MPEGLAYER3WAVEFORMAT */
mp3format.wfx.wFormatTag = WAVE_FORMAT_MPEGLAYER3;
mp3format.wfx.nChannels = 2;
mp3format.wfx.nSamplesPerSec = 44100;
mp3format.wfx.nAvgBytesPerSec = 16000;
mp3format.wfx.nBlockAlign = 1;
mp3format.wfx.wBitsPerSample = 0;
mp3format.wfx.cbSize = MPEGLAYER3_WFX_EXTRA_BYTES;
mp3format.wID = MPEGLAYER3_ID_MPEG;
mp3format.fdwFlags = 0;
mp3format.nBlockSize = 417;
mp3format.nFramesPerBlock = 0;
mp3format.nCodecDelay = 0;
hr = MFInitMediaTypeFromWaveFormatEx(mediatype, (WAVEFORMATEX *)&mp3format, sizeof(mp3format));
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
validate_media_type(mediatype, &mp3format.wfx);
hr = IMFMediaType_GetBlob(mediatype, &MF_MT_USER_DATA, buff, sizeof(buff), &size);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(size == mp3format.wfx.cbSize, "Unexpected size %u.\n", size);
ok(!memcmp(buff, (WAVEFORMATEX *)&mp3format + 1, size), "Unexpected user data.\n");
IMFMediaType_Release(mediatype);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment