Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/mixer.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c index 0d4bf8bc500..ba4624e0f51 100644 --- a/dlls/evr/mixer.c +++ b/dlls/evr/mixer.c @@ -642,13 +642,19 @@ done: return hr; }
-static int __cdecl rt_formats_sort_compare(const void *left, const void *right) +static void video_mixer_append_rt_format(struct rt_format *rt_formats, unsigned int *count, + const GUID *device, D3DFORMAT format) { - const struct rt_format *format1 = left, *format2 = right; + unsigned int i;
- if (format1->format < format2->format) return -1; - if (format1->format > format2->format) return 1; - return 0; + for (i = 0; i < *count; ++i) + { + if (rt_formats[i].format == format) return; + } + + rt_formats[*count].format = format; + rt_formats[*count].device = *device; + *count += 1; }
static HRESULT video_mixer_collect_output_types(struct video_mixer *mixer, const DXVA2_VideoDesc *video_desc, @@ -677,11 +683,7 @@ static HRESULT video_mixer_collect_output_types(struct video_mixer *mixer, const rt_formats = ptr;
for (j = 0; j < format_count; ++j) - { - rt_formats[count + j].format = formats[j]; - rt_formats[count + j].device = devices[i]; - } - count += format_count; + video_mixer_append_rt_format(rt_formats, &count, &devices[i], formats[j]);
CoTaskMemFree(formats); } @@ -689,18 +691,6 @@ static HRESULT video_mixer_collect_output_types(struct video_mixer *mixer, const
if (count && !(flags & MFT_SET_TYPE_TEST_ONLY)) { - qsort(rt_formats, count, sizeof(*rt_formats), rt_formats_sort_compare); - - j = 0; - for (i = j + 1; i < count; ++i) - { - if (rt_formats[i].format != rt_formats[j].format) - { - rt_formats[++j] = rt_formats[i]; - } - } - count = j + 1; - memcpy(&subtype, &MFVideoFormat_Base, sizeof(subtype)); if ((mixer->output.rt_formats = calloc(count, sizeof(*mixer->output.rt_formats)))) {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/evr/mixer.c | 4 ++-- dlls/evr/tests/evr.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c index ba4624e0f51..554fb0725e8 100644 --- a/dlls/evr/mixer.c +++ b/dlls/evr/mixer.c @@ -603,8 +603,8 @@ static HRESULT WINAPI video_mixer_transform_GetOutputAvailableType(IMFTransform hr = MF_E_NO_MORE_TYPES; else { - *type = mixer->output.rt_formats[index].media_type; - IMFMediaType_AddRef(*type); + if (SUCCEEDED(hr = MFCreateMediaType(type))) + hr = IMFMediaType_CopyAllItems(mixer->output.rt_formats[index].media_type, (IMFAttributes *)*type); }
LeaveCriticalSection(&mixer->cs); diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c index 2643f6ee92a..dd38a75ca2b 100644 --- a/dlls/evr/tests/evr.c +++ b/dlls/evr/tests/evr.c @@ -1045,9 +1045,11 @@ static void test_default_mixer_type_negotiation(void) while (SUCCEEDED(IMFTransform_GetOutputAvailableType(transform, 0, index++, &media_type))) { UINT64 frame_size; - GUID subtype; + GUID subtype, major; UINT32 value;
+ hr = IMFMediaType_GetGUID(media_type, &MF_MT_MAJOR_TYPE, &major); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = IMFMediaType_GetGUID(media_type, &MF_MT_SUBTYPE, &subtype); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); hr = IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size); @@ -1059,6 +1061,15 @@ static void test_default_mixer_type_negotiation(void) } ok(index > 1, "Unexpected number of available types.\n");
+ /* Cloned type is returned. */ + hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + hr = IMFTransform_GetOutputAvailableType(transform, 0, 0, &media_type2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(media_type != media_type2, "Unexpected media type instance.\n"); + IMFMediaType_Release(media_type); + IMFMediaType_Release(media_type2); + hr = IMFTransform_QueryInterface(transform, &IID_IMFVideoProcessor, (void **)&processor); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);