2 * Copyright 2020 Nikolay Sivov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "evr_classes.h"
28 #include "evr_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(evr
);
38 #define MAX_MIXER_INPUT_SUBSTREAMS (15)
39 #define MAX_MIXER_INPUT_STREAMS (MAX_MIXER_INPUT_SUBSTREAMS + 1)
44 IMFAttributes
*attributes
;
45 IMFMediaType
*media_type
;
46 MFVideoNormalizedRect rect
;
50 unsigned int sample_requested
: 1;
57 IMFMediaType
*media_type
;
62 IMFMediaType
*media_type
;
63 struct rt_format
*rt_formats
;
64 unsigned int rt_formats_count
;
69 IMFTransform IMFTransform_iface
;
70 IMFVideoDeviceID IMFVideoDeviceID_iface
;
71 IMFTopologyServiceLookupClient IMFTopologyServiceLookupClient_iface
;
72 IMFVideoMixerControl2 IMFVideoMixerControl2_iface
;
73 IMFGetService IMFGetService_iface
;
74 IMFVideoMixerBitmap IMFVideoMixerBitmap_iface
;
75 IMFVideoPositionMapper IMFVideoPositionMapper_iface
;
76 IMFVideoProcessor IMFVideoProcessor_iface
;
77 IMFAttributes IMFAttributes_iface
;
78 IMFQualityAdvise IMFQualityAdvise_iface
;
79 IMFClockStateSink IMFClockStateSink_iface
;
80 IUnknown IUnknown_inner
;
84 struct input_stream inputs
[MAX_MIXER_INPUT_STREAMS
];
85 unsigned int input_ids
[MAX_MIXER_INPUT_STREAMS
];
86 struct input_stream
*zorder
[MAX_MIXER_INPUT_STREAMS
];
87 unsigned int input_count
;
88 struct output_stream output
;
90 IDirect3DDeviceManager9
*device_manager
;
91 IDirectXVideoProcessor
*processor
;
94 IMediaEventSink
*event_sink
;
95 IMFAttributes
*attributes
;
96 IMFAttributes
*internal_attributes
;
97 unsigned int mixing_flags
;
98 unsigned int is_streaming
: 1;
99 unsigned int output_rendered
: 1;
103 DXVA2_AYUVSample16 ayuv
;
105 MFVideoArea aperture
;
106 LONGLONG lower_bound
;
107 LONGLONG upper_bound
;
111 static struct video_mixer
*impl_from_IUnknown(IUnknown
*iface
)
113 return CONTAINING_RECORD(iface
, struct video_mixer
, IUnknown_inner
);
116 static struct video_mixer
*impl_from_IMFTransform(IMFTransform
*iface
)
118 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFTransform_iface
);
121 static struct video_mixer
*impl_from_IMFVideoDeviceID(IMFVideoDeviceID
*iface
)
123 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoDeviceID_iface
);
126 static struct video_mixer
*impl_from_IMFTopologyServiceLookupClient(IMFTopologyServiceLookupClient
*iface
)
128 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFTopologyServiceLookupClient_iface
);
131 static struct video_mixer
*impl_from_IMFVideoMixerControl2(IMFVideoMixerControl2
*iface
)
133 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoMixerControl2_iface
);
136 static struct video_mixer
*impl_from_IMFGetService(IMFGetService
*iface
)
138 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFGetService_iface
);
141 static struct video_mixer
*impl_from_IMFVideoMixerBitmap(IMFVideoMixerBitmap
*iface
)
143 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoMixerBitmap_iface
);
146 static struct video_mixer
*impl_from_IMFVideoPositionMapper(IMFVideoPositionMapper
*iface
)
148 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoPositionMapper_iface
);
151 static struct video_mixer
*impl_from_IMFVideoProcessor(IMFVideoProcessor
*iface
)
153 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoProcessor_iface
);
156 static struct video_mixer
*impl_from_IMFAttributes(IMFAttributes
*iface
)
158 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFAttributes_iface
);
161 static struct video_mixer
*impl_from_IMFQualityAdvise(IMFQualityAdvise
*iface
)
163 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFQualityAdvise_iface
);
166 static struct video_mixer
*impl_from_IMFClockStateSink(IMFClockStateSink
*iface
)
168 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFClockStateSink_iface
);
171 static int __cdecl
video_mixer_compare_input_id(const void *a
, const void *b
)
173 const unsigned int *key
= a
;
174 const struct input_stream
*input
= b
;
176 if (*key
> input
->id
) return 1;
177 if (*key
< input
->id
) return -1;
181 static HRESULT
video_mixer_get_input(const struct video_mixer
*mixer
, unsigned int id
, struct input_stream
**stream
)
183 *stream
= bsearch(&id
, mixer
->inputs
, mixer
->input_count
, sizeof(*mixer
->inputs
), video_mixer_compare_input_id
);
184 return *stream
? S_OK
: MF_E_INVALIDSTREAMNUMBER
;
187 static void video_mixer_init_input(struct input_stream
*stream
)
189 if (SUCCEEDED(MFCreateAttributes(&stream
->attributes
, 1)))
190 IMFAttributes_SetUINT32(stream
->attributes
, &MF_SA_REQUIRED_SAMPLE_COUNT
, 1);
191 stream
->rect
.left
= stream
->rect
.top
= 0.0f
;
192 stream
->rect
.right
= stream
->rect
.bottom
= 1.0f
;
195 static int __cdecl
video_mixer_zorder_sort_compare(const void *a
, const void *b
)
197 const struct input_stream
*left
= *(void **)a
, *right
= *(void **)b
;
198 return left
->zorder
!= right
->zorder
? (left
->zorder
< right
->zorder
? -1 : 1) : 0;
201 static void video_mixer_update_zorder_map(struct video_mixer
*mixer
)
205 for (i
= 0; i
< mixer
->input_count
; ++i
)
206 mixer
->zorder
[i
] = &mixer
->inputs
[i
];
208 qsort(mixer
->zorder
, mixer
->input_count
, sizeof(*mixer
->zorder
), video_mixer_zorder_sort_compare
);
211 static void video_mixer_flush_input(struct video_mixer
*mixer
)
215 for (i
= 0; i
< mixer
->input_count
; ++i
)
217 if (mixer
->inputs
[i
].sample
)
218 IMFSample_Release(mixer
->inputs
[i
].sample
);
219 mixer
->inputs
[i
].sample
= NULL
;
220 mixer
->inputs
[i
].sample_requested
= 0;
222 mixer
->output_rendered
= 0;
225 static void video_mixer_clear_types(struct video_mixer
*mixer
)
229 for (i
= 0; i
< mixer
->input_count
; ++i
)
231 if (mixer
->inputs
[i
].media_type
)
232 IMFMediaType_Release(mixer
->inputs
[i
].media_type
);
233 mixer
->inputs
[i
].media_type
= NULL
;
235 video_mixer_flush_input(mixer
);
236 for (i
= 0; i
< mixer
->output
.rt_formats_count
; ++i
)
238 IMFMediaType_Release(mixer
->output
.rt_formats
[i
].media_type
);
240 free(mixer
->output
.rt_formats
);
241 if (mixer
->output
.media_type
)
242 IMFMediaType_Release(mixer
->output
.media_type
);
243 memset(&mixer
->output
, 0, sizeof(mixer
->output
));
246 static HRESULT WINAPI
video_mixer_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **obj
)
248 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
250 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
252 if (IsEqualIID(riid
, &IID_IUnknown
))
256 else if (IsEqualIID(riid
, &IID_IMFTransform
))
258 *obj
= &mixer
->IMFTransform_iface
;
260 else if (IsEqualIID(riid
, &IID_IMFVideoDeviceID
))
262 *obj
= &mixer
->IMFVideoDeviceID_iface
;
264 else if (IsEqualIID(riid
, &IID_IMFTopologyServiceLookupClient
))
266 *obj
= &mixer
->IMFTopologyServiceLookupClient_iface
;
268 else if (IsEqualIID(riid
, &IID_IMFVideoMixerControl2
) ||
269 IsEqualIID(riid
, &IID_IMFVideoMixerControl
))
271 *obj
= &mixer
->IMFVideoMixerControl2_iface
;
273 else if (IsEqualIID(riid
, &IID_IMFGetService
))
275 *obj
= &mixer
->IMFGetService_iface
;
277 else if (IsEqualIID(riid
, &IID_IMFVideoMixerBitmap
))
279 *obj
= &mixer
->IMFVideoMixerBitmap_iface
;
281 else if (IsEqualIID(riid
, &IID_IMFVideoPositionMapper
))
283 *obj
= &mixer
->IMFVideoPositionMapper_iface
;
285 else if (IsEqualIID(riid
, &IID_IMFVideoProcessor
))
287 *obj
= &mixer
->IMFVideoProcessor_iface
;
289 else if (IsEqualIID(riid
, &IID_IMFAttributes
))
291 *obj
= &mixer
->IMFAttributes_iface
;
293 else if (IsEqualIID(riid
, &IID_IMFQualityAdvise
))
295 *obj
= &mixer
->IMFQualityAdvise_iface
;
297 else if (IsEqualIID(riid
, &IID_IMFClockStateSink
))
299 *obj
= &mixer
->IMFClockStateSink_iface
;
303 WARN("Unsupported interface %s.\n", debugstr_guid(riid
));
305 return E_NOINTERFACE
;
308 IUnknown_AddRef((IUnknown
*)*obj
);
312 static ULONG WINAPI
video_mixer_inner_AddRef(IUnknown
*iface
)
314 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
315 ULONG refcount
= InterlockedIncrement(&mixer
->refcount
);
317 TRACE("%p, refcount %lu.\n", iface
, refcount
);
322 static void video_mixer_release_device_manager(struct video_mixer
*mixer
)
324 if (mixer
->processor
)
325 IDirectXVideoProcessor_Release(mixer
->processor
);
326 if (mixer
->device_manager
)
328 IDirect3DDeviceManager9_CloseDeviceHandle(mixer
->device_manager
, mixer
->device_handle
);
329 IDirect3DDeviceManager9_Release(mixer
->device_manager
);
331 mixer
->device_handle
= NULL
;
332 mixer
->device_manager
= NULL
;
333 mixer
->processor
= NULL
;
336 static ULONG WINAPI
video_mixer_inner_Release(IUnknown
*iface
)
338 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
339 ULONG refcount
= InterlockedDecrement(&mixer
->refcount
);
342 TRACE("%p, refcount %lu.\n", iface
, refcount
);
346 for (i
= 0; i
< mixer
->input_count
; ++i
)
348 if (mixer
->inputs
[i
].attributes
)
349 IMFAttributes_Release(mixer
->inputs
[i
].attributes
);
351 video_mixer_clear_types(mixer
);
352 video_mixer_release_device_manager(mixer
);
353 if (mixer
->attributes
)
354 IMFAttributes_Release(mixer
->attributes
);
355 if (mixer
->internal_attributes
)
356 IMFAttributes_Release(mixer
->internal_attributes
);
357 DeleteCriticalSection(&mixer
->cs
);
364 static const IUnknownVtbl video_mixer_inner_vtbl
=
366 video_mixer_inner_QueryInterface
,
367 video_mixer_inner_AddRef
,
368 video_mixer_inner_Release
,
371 static HRESULT WINAPI
video_mixer_transform_QueryInterface(IMFTransform
*iface
, REFIID riid
, void **obj
)
373 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
374 return IUnknown_QueryInterface(mixer
->outer_unk
, riid
, obj
);
377 static ULONG WINAPI
video_mixer_transform_AddRef(IMFTransform
*iface
)
379 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
380 return IUnknown_AddRef(mixer
->outer_unk
);
383 static ULONG WINAPI
video_mixer_transform_Release(IMFTransform
*iface
)
385 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
386 return IUnknown_Release(mixer
->outer_unk
);
389 static HRESULT WINAPI
video_mixer_transform_GetStreamLimits(IMFTransform
*iface
, DWORD
*input_minimum
,
390 DWORD
*input_maximum
, DWORD
*output_minimum
, DWORD
*output_maximum
)
392 TRACE("%p, %p, %p, %p, %p.\n", iface
, input_minimum
, input_maximum
, output_minimum
, output_maximum
);
395 *input_maximum
= MAX_MIXER_INPUT_STREAMS
;
402 static HRESULT WINAPI
video_mixer_transform_GetStreamCount(IMFTransform
*iface
, DWORD
*inputs
, DWORD
*outputs
)
404 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
406 TRACE("%p, %p, %p.\n", iface
, inputs
, outputs
);
408 EnterCriticalSection(&mixer
->cs
);
409 if (inputs
) *inputs
= mixer
->input_count
;
410 if (outputs
) *outputs
= 1;
411 LeaveCriticalSection(&mixer
->cs
);
416 static HRESULT WINAPI
video_mixer_transform_GetStreamIDs(IMFTransform
*iface
, DWORD input_size
, DWORD
*inputs
,
417 DWORD output_size
, DWORD
*outputs
)
419 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
422 TRACE("%p, %lu, %p, %lu, %p.\n", iface
, input_size
, inputs
, output_size
, outputs
);
424 EnterCriticalSection(&mixer
->cs
);
425 if (mixer
->input_count
> input_size
|| !output_size
)
426 hr
= MF_E_BUFFERTOOSMALL
;
428 memcpy(inputs
, mixer
->input_ids
, mixer
->input_count
* sizeof(*inputs
));
429 if (outputs
) *outputs
= 0;
430 LeaveCriticalSection(&mixer
->cs
);
435 static HRESULT WINAPI
video_mixer_transform_GetInputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_INPUT_STREAM_INFO
*info
)
437 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
438 struct input_stream
*input
;
441 TRACE("%p, %lu, %p.\n", iface
, id
, info
);
443 EnterCriticalSection(&mixer
->cs
);
445 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
447 memset(info
, 0, sizeof(*info
));
449 info
->dwFlags
|= MFT_INPUT_STREAM_REMOVABLE
| MFT_INPUT_STREAM_OPTIONAL
;
452 LeaveCriticalSection(&mixer
->cs
);
457 static HRESULT WINAPI
video_mixer_transform_GetOutputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_OUTPUT_STREAM_INFO
*info
)
459 TRACE("%p, %lu, %p.\n", iface
, id
, info
);
462 return MF_E_INVALIDSTREAMNUMBER
;
464 memset(info
, 0, sizeof(*info
));
469 static HRESULT WINAPI
video_mixer_transform_GetAttributes(IMFTransform
*iface
, IMFAttributes
**attributes
)
471 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
473 TRACE("%p, %p.\n", iface
, attributes
);
478 *attributes
= mixer
->attributes
;
479 IMFAttributes_AddRef(*attributes
);
484 static HRESULT WINAPI
video_mixer_transform_GetInputStreamAttributes(IMFTransform
*iface
, DWORD id
,
485 IMFAttributes
**attributes
)
487 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
488 struct input_stream
*input
;
491 TRACE("%p, %lu, %p.\n", iface
, id
, attributes
);
493 EnterCriticalSection(&mixer
->cs
);
495 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
497 *attributes
= input
->attributes
;
499 IMFAttributes_AddRef(*attributes
);
502 LeaveCriticalSection(&mixer
->cs
);
507 static HRESULT WINAPI
video_mixer_transform_GetOutputStreamAttributes(IMFTransform
*iface
, DWORD id
,
508 IMFAttributes
**attributes
)
510 TRACE("%p, %lu, %p.\n", iface
, id
, attributes
);
515 static HRESULT WINAPI
video_mixer_transform_DeleteInputStream(IMFTransform
*iface
, DWORD id
)
517 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
518 struct input_stream
*input
;
522 TRACE("%p, %lu.\n", iface
, id
);
525 return MF_E_INVALIDSTREAMNUMBER
;
527 EnterCriticalSection(&mixer
->cs
);
529 /* Can't delete reference stream. */
530 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
532 mixer
->input_count
--;
533 idx
= input
- mixer
->inputs
;
534 if (idx
< mixer
->input_count
)
536 if (mixer
->inputs
[idx
].attributes
)
537 IMFAttributes_Release(mixer
->inputs
[idx
].attributes
);
538 memmove(&mixer
->inputs
[idx
], &mixer
->inputs
[idx
+ 1], (mixer
->input_count
- idx
) * sizeof(*mixer
->inputs
));
539 memmove(&mixer
->input_ids
[idx
], &mixer
->input_ids
[idx
+ 1], (mixer
->input_count
- idx
) *
540 sizeof(*mixer
->input_ids
));
541 video_mixer_update_zorder_map(mixer
);
545 LeaveCriticalSection(&mixer
->cs
);
550 static int __cdecl
video_mixer_add_input_sort_compare(const void *a
, const void *b
)
552 const struct input_stream
*left
= a
, *right
= b
;
553 return left
->id
!= right
->id
? (left
->id
< right
->id
? -1 : 1) : 0;
556 static HRESULT WINAPI
video_mixer_transform_AddInputStreams(IMFTransform
*iface
, DWORD count
, DWORD
*ids
)
558 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
559 struct input_stream inputs
[MAX_MIXER_INPUT_STREAMS
] = { {0} };
560 struct input_stream
*input
;
564 TRACE("%p, %lu, %p.\n", iface
, count
, ids
);
569 EnterCriticalSection(&mixer
->cs
);
570 if (count
> ARRAY_SIZE(mixer
->inputs
) - mixer
->input_count
)
574 /* Test for collisions. */
575 memcpy(inputs
, mixer
->inputs
, mixer
->input_count
* sizeof(*inputs
));
576 for (i
= 0; i
< count
; ++i
)
577 inputs
[i
+ mixer
->input_count
].id
= ids
[i
];
579 len
= mixer
->input_count
+ count
;
581 qsort(inputs
, len
, sizeof(*inputs
), video_mixer_add_input_sort_compare
);
583 for (i
= 1; i
< len
; ++i
)
585 if (inputs
[i
- 1].id
== inputs
[i
].id
)
594 unsigned int zorder
= mixer
->input_count
;
596 for (i
= 0; i
< count
; ++i
)
598 if ((input
= bsearch(&ids
[i
], inputs
, len
, sizeof(*inputs
), video_mixer_compare_input_id
)))
599 video_mixer_init_input(input
);
601 memcpy(&mixer
->input_ids
[mixer
->input_count
], ids
, count
* sizeof(*ids
));
602 memcpy(mixer
->inputs
, inputs
, len
* sizeof(*inputs
));
603 mixer
->input_count
+= count
;
605 for (i
= 0; i
< count
; ++i
)
607 if (SUCCEEDED(video_mixer_get_input(mixer
, ids
[i
], &input
)))
608 input
->zorder
= zorder
;
612 video_mixer_update_zorder_map(mixer
);
615 LeaveCriticalSection(&mixer
->cs
);
620 static HRESULT WINAPI
video_mixer_transform_GetInputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
623 TRACE("%p, %lu, %lu, %p.\n", iface
, id
, index
, type
);
628 static HRESULT WINAPI
video_mixer_transform_GetOutputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
631 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
634 TRACE("%p, %lu, %lu, %p.\n", iface
, id
, index
, type
);
637 return MF_E_INVALIDSTREAMNUMBER
;
639 EnterCriticalSection(&mixer
->cs
);
641 if (!mixer
->inputs
[0].media_type
)
642 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
643 else if (index
>= mixer
->output
.rt_formats_count
)
644 hr
= MF_E_NO_MORE_TYPES
;
647 if (SUCCEEDED(hr
= MFCreateMediaType(type
)))
648 hr
= IMFMediaType_CopyAllItems(mixer
->output
.rt_formats
[index
].media_type
, (IMFAttributes
*)*type
);
651 LeaveCriticalSection(&mixer
->cs
);
656 static HRESULT
video_mixer_init_dxva_videodesc(IMFMediaType
*media_type
, DXVA2_VideoDesc
*video_desc
)
658 const MFVIDEOFORMAT
*video_format
;
659 IMFVideoMediaType
*video_type
;
660 BOOL is_compressed
= TRUE
;
663 if (FAILED(IMFMediaType_QueryInterface(media_type
, &IID_IMFVideoMediaType
, (void **)&video_type
)))
664 return MF_E_INVALIDMEDIATYPE
;
666 video_format
= IMFVideoMediaType_GetVideoFormat(video_type
);
667 IMFVideoMediaType_IsCompressedFormat(video_type
, &is_compressed
);
669 if (!video_format
|| !video_format
->videoInfo
.dwWidth
|| !video_format
->videoInfo
.dwHeight
|| is_compressed
)
671 hr
= MF_E_INVALIDMEDIATYPE
;
675 memset(video_desc
, 0, sizeof(*video_desc
));
676 video_desc
->SampleWidth
= video_format
->videoInfo
.dwWidth
;
677 video_desc
->SampleHeight
= video_format
->videoInfo
.dwHeight
;
678 video_desc
->Format
= video_format
->surfaceInfo
.Format
;
681 IMFVideoMediaType_Release(video_type
);
686 static void video_mixer_append_rt_format(struct rt_format
*rt_formats
, unsigned int *count
,
687 const GUID
*device
, D3DFORMAT format
)
691 for (i
= 0; i
< *count
; ++i
)
693 if (rt_formats
[i
].format
== format
) return;
696 rt_formats
[*count
].format
= format
;
697 rt_formats
[*count
].device
= *device
;
701 static unsigned int video_mixer_get_interlace_mode_from_video_desc(const DXVA2_VideoDesc
*video_desc
)
703 switch (video_desc
->SampleFormat
.SampleFormat
)
705 case DXVA2_SampleFieldInterleavedEvenFirst
:
706 return MFVideoInterlace_FieldInterleavedUpperFirst
;
707 case DXVA2_SampleFieldInterleavedOddFirst
:
708 return MFVideoInterlace_FieldInterleavedLowerFirst
;
709 case DXVA2_SampleFieldSingleEven
:
710 return MFVideoInterlace_FieldSingleUpper
;
711 case DXVA2_SampleFieldSingleOdd
:
712 return MFVideoInterlace_FieldSingleLower
;
714 return MFVideoInterlace_Progressive
;
718 static void mf_get_attribute_uint32(IMFMediaType
*media_type
, const GUID
*key
, UINT32
*value
,
719 UINT32 default_value
)
721 if (FAILED(IMFMediaType_GetUINT32(media_type
, key
, value
)))
722 *value
= default_value
;
725 static void mf_get_attribute_uint64(IMFMediaType
*media_type
, const GUID
*key
, UINT64
*value
,
726 UINT64 default_value
)
728 if (FAILED(IMFMediaType_GetUINT64(media_type
, key
, value
)))
729 *value
= default_value
;
732 static HRESULT
video_mixer_collect_output_types(struct video_mixer
*mixer
, const DXVA2_VideoDesc
*video_desc
,
733 IMFMediaType
*media_type
, IDirectXVideoProcessorService
*service
, unsigned int device_count
,
734 const GUID
*devices
, unsigned int flags
)
736 struct rt_format
*rt_formats
= NULL
, *ptr
;
737 unsigned int i
, j
, format_count
, count
;
738 HRESULT hr
= MF_E_INVALIDMEDIATYPE
;
743 for (i
= 0; i
< device_count
; ++i
)
745 if (SUCCEEDED(IDirectXVideoProcessorService_GetVideoProcessorRenderTargets(service
, &devices
[i
], video_desc
,
746 &format_count
, &formats
)))
748 if (!(ptr
= realloc(rt_formats
, (count
+ format_count
) * sizeof(*rt_formats
))))
752 CoTaskMemFree(formats
);
757 for (j
= 0; j
< format_count
; ++j
)
758 video_mixer_append_rt_format(rt_formats
, &count
, &devices
[i
], formats
[j
]);
760 CoTaskMemFree(formats
);
764 if (count
&& !(flags
& MFT_SET_TYPE_TEST_ONLY
))
766 UINT32 fixed_samples
, interlace_mode
;
767 MFVideoArea aperture
;
770 if (!(mixer
->output
.rt_formats
= calloc(count
, sizeof(*mixer
->output
.rt_formats
))))
773 return E_OUTOFMEMORY
;
776 memcpy(&subtype
, &MFVideoFormat_Base
, sizeof(subtype
));
777 memset(&aperture
, 0, sizeof(aperture
));
778 if (FAILED(IMFMediaType_GetBlob(media_type
, &MF_MT_GEOMETRIC_APERTURE
, (UINT8
*)&aperture
,
779 sizeof(aperture
), NULL
)))
781 aperture
.Area
.cx
= video_desc
->SampleWidth
;
782 aperture
.Area
.cy
= video_desc
->SampleHeight
;
784 interlace_mode
= video_mixer_get_interlace_mode_from_video_desc(video_desc
);
785 mf_get_attribute_uint64(media_type
, &MF_MT_PIXEL_ASPECT_RATIO
, &par
, (UINT64
)1 << 32 | 1);
786 mf_get_attribute_uint32(media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, &fixed_samples
, 1);
788 for (i
= 0; i
< count
; ++i
)
790 IMFMediaType
*rt_media_type
;
792 subtype
.Data1
= rt_formats
[i
].format
;
793 mixer
->output
.rt_formats
[i
] = rt_formats
[i
];
795 MFCreateMediaType(&rt_media_type
);
796 IMFMediaType_CopyAllItems(media_type
, (IMFAttributes
*)rt_media_type
);
797 IMFMediaType_SetGUID(rt_media_type
, &MF_MT_SUBTYPE
, &subtype
);
798 IMFMediaType_SetUINT64(rt_media_type
, &MF_MT_FRAME_SIZE
, (UINT64
)aperture
.Area
.cx
<< 32 | aperture
.Area
.cy
);
799 IMFMediaType_SetBlob(rt_media_type
, &MF_MT_GEOMETRIC_APERTURE
, (const UINT8
*)&aperture
, sizeof(aperture
));
800 IMFMediaType_SetBlob(rt_media_type
, &MF_MT_MINIMUM_DISPLAY_APERTURE
, (const UINT8
*)&aperture
, sizeof(aperture
));
801 IMFMediaType_SetUINT32(rt_media_type
, &MF_MT_INTERLACE_MODE
, interlace_mode
);
802 IMFMediaType_SetUINT64(rt_media_type
, &MF_MT_PIXEL_ASPECT_RATIO
, par
);
803 IMFMediaType_SetUINT32(rt_media_type
, &MF_MT_FIXED_SIZE_SAMPLES
, fixed_samples
);
805 mixer
->output
.rt_formats
[i
].media_type
= rt_media_type
;
807 mixer
->output
.rt_formats_count
= count
;
812 return count
? S_OK
: hr
;
815 static HRESULT
video_mixer_open_device_handle(struct video_mixer
*mixer
)
817 IDirect3DDeviceManager9_CloseDeviceHandle(mixer
->device_manager
, mixer
->device_handle
);
818 mixer
->device_handle
= NULL
;
819 return IDirect3DDeviceManager9_OpenDeviceHandle(mixer
->device_manager
, &mixer
->device_handle
);
822 static HRESULT
video_mixer_get_processor_service(struct video_mixer
*mixer
, IDirectXVideoProcessorService
**service
)
826 if (!mixer
->device_handle
)
828 if (FAILED(hr
= IDirect3DDeviceManager9_OpenDeviceHandle(mixer
->device_manager
, &mixer
->device_handle
)))
834 hr
= IDirect3DDeviceManager9_GetVideoService(mixer
->device_manager
, mixer
->device_handle
,
835 &IID_IDirectXVideoProcessorService
, (void **)service
);
836 if (hr
== DXVA2_E_NEW_VIDEO_DEVICE
)
838 if (SUCCEEDED(hr
= video_mixer_open_device_handle(mixer
)))
847 static HRESULT WINAPI
video_mixer_transform_SetInputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*media_type
, DWORD flags
)
849 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
850 IDirectXVideoProcessorService
*service
;
851 DXVA2_VideoDesc video_desc
;
852 HRESULT hr
= E_NOTIMPL
;
856 TRACE("%p, %lu, %p, %#lx.\n", iface
, id
, media_type
, flags
);
858 if (!media_type
&& (flags
& MFT_SET_TYPE_TEST_ONLY
))
861 EnterCriticalSection(&mixer
->cs
);
863 if (!(flags
& MFT_SET_TYPE_TEST_ONLY
))
864 video_mixer_clear_types(mixer
);
868 else if (!mixer
->device_manager
)
869 hr
= MF_E_NOT_INITIALIZED
;
872 if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
874 if (SUCCEEDED(hr
= video_mixer_init_dxva_videodesc(media_type
, &video_desc
)))
878 if (SUCCEEDED(hr
= IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(service
, &video_desc
,
881 if (SUCCEEDED(hr
= video_mixer_collect_output_types(mixer
, &video_desc
, media_type
,
882 service
, count
, guids
, flags
)) && !(flags
& MFT_SET_TYPE_TEST_ONLY
))
884 if (mixer
->inputs
[0].media_type
)
885 IMFMediaType_Release(mixer
->inputs
[0].media_type
);
886 mixer
->inputs
[0].media_type
= media_type
;
887 mixer
->inputs
[0].frame_size
.cx
= video_desc
.SampleWidth
;
888 mixer
->inputs
[0].frame_size
.cy
= video_desc
.SampleHeight
;
889 IMFMediaType_AddRef(mixer
->inputs
[0].media_type
);
891 CoTaskMemFree(guids
);
896 FIXME("Unimplemented for substreams.\n");
900 IDirectXVideoProcessorService_Release(service
);
904 LeaveCriticalSection(&mixer
->cs
);
909 static HRESULT WINAPI
video_mixer_transform_SetOutputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*type
, DWORD flags
)
911 const unsigned int equality_flags
= MF_MEDIATYPE_EQUAL_MAJOR_TYPES
| MF_MEDIATYPE_EQUAL_FORMAT_TYPES
;
912 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
913 HRESULT hr
= MF_E_INVALIDMEDIATYPE
;
914 BOOL is_compressed
= TRUE
;
918 TRACE("%p, %lu, %p, %#lx.\n", iface
, id
, type
, flags
);
921 return MF_E_INVALIDSTREAMNUMBER
;
926 if (FAILED(IMFMediaType_IsCompressedFormat(type
, &is_compressed
)) || is_compressed
)
927 return MF_E_INVALIDMEDIATYPE
;
929 EnterCriticalSection(&mixer
->cs
);
931 for (i
= 0; i
< mixer
->output
.rt_formats_count
; ++i
)
934 if (FAILED(IMFMediaType_IsEqual(type
, mixer
->output
.rt_formats
[i
].media_type
, &compare_flags
)))
937 if ((compare_flags
& equality_flags
) == equality_flags
)
944 if (SUCCEEDED(hr
) && !(flags
& MFT_SET_TYPE_TEST_ONLY
))
946 IDirectXVideoProcessorService
*service
;
948 if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
950 DXVA2_VideoDesc video_desc
;
951 GUID subtype
= { 0 };
954 if (mixer
->processor
)
955 IDirectXVideoProcessor_Release(mixer
->processor
);
956 mixer
->processor
= NULL
;
958 video_mixer_init_dxva_videodesc(mixer
->inputs
[0].media_type
, &video_desc
);
959 IMFMediaType_GetGUID(type
, &MF_MT_SUBTYPE
, &subtype
);
960 rt_format
= subtype
.Data1
;
962 if (SUCCEEDED(hr
= IDirectXVideoProcessorService_CreateVideoProcessor(service
, &mixer
->output
.rt_formats
[i
].device
,
963 &video_desc
, rt_format
, MAX_MIXER_INPUT_SUBSTREAMS
, &mixer
->processor
)))
965 if (FAILED(IMFMediaType_GetBlob(type
, &MF_MT_GEOMETRIC_APERTURE
, (UINT8
*)&mixer
->aperture
,
966 sizeof(mixer
->aperture
), NULL
)))
968 memset(&mixer
->aperture
, 0, sizeof(mixer
->aperture
));
970 if (mixer
->output
.media_type
)
971 IMFMediaType_Release(mixer
->output
.media_type
);
972 mixer
->output
.media_type
= type
;
973 IMFMediaType_AddRef(mixer
->output
.media_type
);
976 IDirectXVideoProcessorService_Release(service
);
980 LeaveCriticalSection(&mixer
->cs
);
985 static HRESULT WINAPI
video_mixer_transform_GetInputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
987 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
988 struct input_stream
*stream
;
991 TRACE("%p, %lu, %p.\n", iface
, id
, type
);
993 EnterCriticalSection(&mixer
->cs
);
995 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
997 if (!stream
->media_type
)
998 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1001 *type
= stream
->media_type
;
1002 IMFMediaType_AddRef(*type
);
1006 LeaveCriticalSection(&mixer
->cs
);
1011 static HRESULT WINAPI
video_mixer_transform_GetOutputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
1013 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1016 TRACE("%p, %lu, %p.\n", iface
, id
, type
);
1019 return MF_E_INVALIDSTREAMNUMBER
;
1021 EnterCriticalSection(&mixer
->cs
);
1023 if (!mixer
->output
.media_type
)
1024 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1027 *type
= mixer
->output
.media_type
;
1028 IMFMediaType_AddRef(*type
);
1031 LeaveCriticalSection(&mixer
->cs
);
1036 static HRESULT WINAPI
video_mixer_transform_GetInputStatus(IMFTransform
*iface
, DWORD id
, DWORD
*status
)
1038 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1039 struct input_stream
*stream
;
1042 TRACE("%p, %lu, %p.\n", iface
, id
, status
);
1047 EnterCriticalSection(&mixer
->cs
);
1049 if (!mixer
->output
.media_type
)
1050 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1051 else if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1053 *status
= stream
->sample
? 0 : MFT_INPUT_STATUS_ACCEPT_DATA
;
1056 LeaveCriticalSection(&mixer
->cs
);
1061 static HRESULT WINAPI
video_mixer_transform_GetOutputStatus(IMFTransform
*iface
, DWORD
*status
)
1063 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1067 TRACE("%p, %p.\n", iface
, status
);
1072 EnterCriticalSection(&mixer
->cs
);
1074 if (!mixer
->output
.media_type
)
1075 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1078 *status
= MFT_OUTPUT_STATUS_SAMPLE_READY
;
1079 for (i
= 0; i
< mixer
->input_count
; ++i
)
1081 if (!mixer
->inputs
[i
].sample
)
1089 LeaveCriticalSection(&mixer
->cs
);
1094 static HRESULT WINAPI
video_mixer_transform_SetOutputBounds(IMFTransform
*iface
, LONGLONG lower
, LONGLONG upper
)
1096 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1098 TRACE("%p, %s, %s.\n", iface
, wine_dbgstr_longlong(lower
), wine_dbgstr_longlong(upper
));
1100 EnterCriticalSection(&mixer
->cs
);
1102 mixer
->lower_bound
= lower
;
1103 mixer
->upper_bound
= upper
;
1105 LeaveCriticalSection(&mixer
->cs
);
1110 static HRESULT WINAPI
video_mixer_transform_ProcessEvent(IMFTransform
*iface
, DWORD id
, IMFMediaEvent
*event
)
1112 FIXME("%p, %lu, %p.\n", iface
, id
, event
);
1117 static void video_mixer_request_sample(struct video_mixer
*mixer
, unsigned int idx
)
1119 if (!mixer
->event_sink
|| mixer
->inputs
[idx
].sample_requested
)
1122 IMediaEventSink_Notify(mixer
->event_sink
, EC_SAMPLE_NEEDED
, idx
, 0);
1123 mixer
->inputs
[idx
].sample_requested
= 1;
1126 static HRESULT WINAPI
video_mixer_transform_ProcessMessage(IMFTransform
*iface
, MFT_MESSAGE_TYPE message
, ULONG_PTR param
)
1128 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1132 TRACE("%p, %#x, %Iu.\n", iface
, message
, param
);
1134 EnterCriticalSection(&mixer
->cs
);
1138 case MFT_MESSAGE_SET_D3D_MANAGER
:
1139 video_mixer_release_device_manager(mixer
);
1141 hr
= IUnknown_QueryInterface((IUnknown
*)param
, &IID_IDirect3DDeviceManager9
, (void **)&mixer
->device_manager
);
1145 case MFT_MESSAGE_COMMAND_FLUSH
:
1146 video_mixer_flush_input(mixer
);
1150 case MFT_MESSAGE_NOTIFY_BEGIN_STREAMING
:
1151 case MFT_MESSAGE_NOTIFY_END_STREAMING
:
1152 if (mixer
->is_streaming
)
1153 video_mixer_flush_input(mixer
);
1156 for (i
= 0; i
< mixer
->input_count
; ++i
)
1157 video_mixer_request_sample(mixer
, i
);
1160 mixer
->is_streaming
= message
== MFT_MESSAGE_NOTIFY_BEGIN_STREAMING
;
1164 case MFT_MESSAGE_COMMAND_DRAIN
:
1168 WARN("Message not handled %d.\n", message
);
1172 LeaveCriticalSection(&mixer
->cs
);
1177 static HRESULT WINAPI
video_mixer_transform_ProcessInput(IMFTransform
*iface
, DWORD id
, IMFSample
*sample
, DWORD flags
)
1179 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1180 struct input_stream
*input
;
1183 TRACE("%p, %lu, %p, %#lx.\n", iface
, id
, sample
, flags
);
1188 EnterCriticalSection(&mixer
->cs
);
1190 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
1192 if (!input
->media_type
|| !mixer
->output
.media_type
)
1193 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1194 else if (input
->sample
&& !mixer
->output_rendered
)
1195 hr
= MF_E_NOTACCEPTING
;
1198 if (input
->sample
&& mixer
->output_rendered
)
1199 video_mixer_flush_input(mixer
);
1200 mixer
->is_streaming
= 1;
1201 input
->sample_requested
= 0;
1202 input
->sample
= sample
;
1203 IMFSample_AddRef(input
->sample
);
1207 LeaveCriticalSection(&mixer
->cs
);
1212 static HRESULT
video_mixer_get_sample_surface(IMFSample
*sample
, IDirect3DSurface9
**surface
)
1214 IMFMediaBuffer
*buffer
;
1218 if (FAILED(hr
= IMFSample_GetBufferByIndex(sample
, 0, &buffer
)))
1221 hr
= IMFMediaBuffer_QueryInterface(buffer
, &IID_IMFGetService
, (void **)&gs
);
1222 IMFMediaBuffer_Release(buffer
);
1226 hr
= IMFGetService_GetService(gs
, &MR_BUFFER_SERVICE
, &IID_IDirect3DSurface9
, (void **)surface
);
1227 IMFGetService_Release(gs
);
1231 static HRESULT
video_mixer_get_d3d_device(struct video_mixer
*mixer
, IDirect3DDevice9
**device
)
1237 hr
= IDirect3DDeviceManager9_LockDevice(mixer
->device_manager
, mixer
->device_handle
,
1239 if (hr
== DXVA2_E_NEW_VIDEO_DEVICE
)
1241 if (SUCCEEDED(hr
= video_mixer_open_device_handle(mixer
)))
1250 static BOOL
video_mixer_rect_needs_scaling(const MFVideoNormalizedRect
*scale
)
1252 return scale
->left
!= 0.0f
|| scale
->top
!= 0.0f
|| scale
->right
!= 1.0f
|| scale
->bottom
!= 1.0f
;
1255 static void video_mixer_scale_rect(RECT
*rect
, unsigned int width
, unsigned int height
,
1256 const MFVideoNormalizedRect
*scale
)
1258 if (video_mixer_rect_needs_scaling(scale
))
1260 rect
->left
= width
* scale
->left
;
1261 rect
->right
= width
* scale
->right
;
1262 rect
->top
= height
* scale
->top
;
1263 rect
->bottom
= height
* scale
->bottom
;
1266 SetRect(rect
, 0, 0, width
, height
);
1269 static void video_mixer_correct_aspect_ratio(const RECT
*src
, RECT
*dst
)
1271 unsigned int src_width
= src
->right
- src
->left
, src_height
= src
->bottom
- src
->top
;
1272 unsigned int dst_width
= dst
->right
- dst
->left
, dst_height
= dst
->bottom
- dst
->top
;
1274 if (src_width
* dst_height
> dst_width
* src_height
)
1276 /* src is "wider" than dst. */
1277 unsigned int dst_center
= (dst
->top
+ dst
->bottom
) / 2;
1278 unsigned int scaled_height
= src_height
* dst_width
/ src_width
;
1280 dst
->top
= dst_center
- scaled_height
/ 2;
1281 dst
->bottom
= dst
->top
+ scaled_height
;
1283 else if (src_width
* dst_height
< dst_width
* src_height
)
1285 /* src is "taller" than dst. */
1286 unsigned int dst_center
= (dst
->left
+ dst
->right
) / 2;
1287 unsigned int scaled_width
= src_width
* dst_height
/ src_height
;
1289 dst
->left
= dst_center
- scaled_width
/ 2;
1290 dst
->right
= dst
->left
+ scaled_width
;
1294 static void video_mixer_render(struct video_mixer
*mixer
, IDirect3DSurface9
*rt
)
1296 DXVA2_VideoSample samples
[MAX_MIXER_INPUT_STREAMS
] = {{ 0 }};
1297 DXVA2_VideoProcessBltParams params
= { 0 };
1298 MFVideoNormalizedRect zoom_rect
;
1299 struct input_stream
*stream
;
1304 if (FAILED(IMFAttributes_GetBlob(mixer
->attributes
, &VIDEO_ZOOM_RECT
, (UINT8
*)&zoom_rect
,
1305 sizeof(zoom_rect
), NULL
)))
1307 zoom_rect
.left
= zoom_rect
.top
= 0.0f
;
1308 zoom_rect
.right
= zoom_rect
.bottom
= 1.0f
;
1311 SetRect(&dst
, 0, 0, mixer
->aperture
.Area
.cx
, mixer
->aperture
.Area
.cy
);
1312 OffsetRect(&dst
, mixer
->aperture
.OffsetX
.value
, mixer
->aperture
.OffsetY
.value
);
1314 for (i
= 0; i
< mixer
->input_count
; ++i
)
1316 DXVA2_VideoSample
*sample
= &samples
[i
];
1317 IDirect3DSurface9
*surface
;
1319 stream
= mixer
->zorder
[i
];
1321 if (FAILED(hr
= video_mixer_get_sample_surface(stream
->sample
, &surface
)))
1323 WARN("Failed to get source surface for stream %u, hr %#lx.\n", i
, hr
);
1327 /* Full input frame corrected to full destination rectangle. */
1329 video_mixer_scale_rect(&sample
->SrcRect
, stream
->frame_size
.cx
, stream
->frame_size
.cy
, &zoom_rect
);
1330 CopyRect(&sample
->DstRect
, &dst
);
1331 video_mixer_correct_aspect_ratio(&sample
->SrcRect
, &sample
->DstRect
);
1333 if (video_mixer_rect_needs_scaling(&stream
->rect
))
1334 WARN("Ignoring stream %u rectangle %s.\n", stream
->id
, debugstr_normalized_rect(&stream
->rect
));
1336 sample
->SampleFormat
.SampleFormat
= stream
->id
== 0 ? DXVA2_SampleProgressiveFrame
: DXVA2_SampleSubStream
;
1337 sample
->SrcSurface
= surface
;
1338 sample
->PlanarAlpha
= DXVA2_Fixed32OpaqueAlpha();
1343 SetRect(¶ms
.TargetRect
, 0, 0, mixer
->aperture
.Area
.cx
, mixer
->aperture
.Area
.cy
);
1344 OffsetRect(¶ms
.TargetRect
, mixer
->aperture
.OffsetX
.value
, mixer
->aperture
.OffsetY
.value
);
1346 params
.BackgroundColor
= mixer
->bkgnd_color
.ayuv
;
1347 params
.Alpha
= DXVA2_Fixed32OpaqueAlpha();
1349 if (FAILED(hr
= IDirectXVideoProcessor_VideoProcessBlt(mixer
->processor
, rt
, ¶ms
, samples
,
1350 mixer
->input_count
, NULL
)))
1352 WARN("Failed to process samples, hr %#lx.\n", hr
);
1356 for (i
= 0; i
< mixer
->input_count
; ++i
)
1358 if (samples
[i
].SrcSurface
)
1359 IDirect3DSurface9_Release(samples
[i
].SrcSurface
);
1363 static HRESULT
video_mixer_get_sample_desired_time(IMFSample
*sample
, LONGLONG
*timestamp
, LONGLONG
*duration
)
1365 IMFDesiredSample
*desired
;
1368 *timestamp
= *duration
= 0;
1369 if (SUCCEEDED(hr
= IMFSample_QueryInterface(sample
, &IID_IMFDesiredSample
, (void **)&desired
)))
1371 hr
= IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired
, timestamp
, duration
);
1372 IMFDesiredSample_Release(desired
);
1378 static BOOL
video_mixer_has_input(const struct video_mixer
*mixer
)
1382 for (i
= 0; i
< mixer
->input_count
; ++i
)
1384 if (!mixer
->inputs
[i
].sample
) return FALSE
;
1390 static HRESULT WINAPI
video_mixer_transform_ProcessOutput(IMFTransform
*iface
, DWORD flags
, DWORD count
,
1391 MFT_OUTPUT_DATA_BUFFER
*buffers
, DWORD
*status
)
1393 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1394 LONGLONG timestamp
, duration
;
1395 IDirect3DSurface9
*surface
;
1396 IDirect3DDevice9
*device
;
1397 BOOL repaint
= FALSE
;
1401 TRACE("%p, %#lx, %lu, %p, %p.\n", iface
, flags
, count
, buffers
, status
);
1403 if (!buffers
|| !count
|| count
> 1 || !buffers
->pSample
)
1404 return E_INVALIDARG
;
1406 if (buffers
->dwStreamID
)
1407 return MF_E_INVALIDSTREAMNUMBER
;
1411 EnterCriticalSection(&mixer
->cs
);
1413 if (SUCCEEDED(hr
= video_mixer_get_sample_surface(buffers
->pSample
, &surface
)))
1415 if (mixer
->is_streaming
)
1417 /* Desired timestamp is ignored, duration is required to be non-zero but is not used either. */
1418 if (SUCCEEDED(video_mixer_get_sample_desired_time(buffers
->pSample
, ×tamp
, &duration
)))
1420 if (!(repaint
= !!duration
))
1422 WARN("Unexpected sample duration.\n");
1427 /* Not enough input, or no new input. */
1428 if (SUCCEEDED(hr
) && (!video_mixer_has_input(mixer
) || (!repaint
&& mixer
->output_rendered
)))
1429 hr
= MF_E_TRANSFORM_NEED_MORE_INPUT
;
1433 video_mixer_render(mixer
, surface
);
1435 timestamp
= duration
= 0;
1436 if (SUCCEEDED(IMFSample_GetSampleTime(mixer
->inputs
[0].sample
, ×tamp
)))
1438 IMFSample_GetSampleDuration(mixer
->inputs
[0].sample
, &duration
);
1439 IMFSample_SetSampleTime(buffers
->pSample
, timestamp
);
1440 IMFSample_SetSampleDuration(buffers
->pSample
, duration
);
1442 mixer
->output_rendered
= 1;
1445 if (SUCCEEDED(hr
) && !repaint
)
1447 for (i
= 0; i
< mixer
->input_count
; ++i
)
1448 video_mixer_request_sample(mixer
, i
);
1453 if (SUCCEEDED(video_mixer_get_sample_desired_time(buffers
->pSample
, ×tamp
, &duration
)))
1455 if (SUCCEEDED(hr
= video_mixer_get_d3d_device(mixer
, &device
)))
1457 IDirect3DDevice9_ColorFill(device
, surface
, NULL
, 0);
1458 IDirect3DDeviceManager9_UnlockDevice(mixer
->device_manager
, mixer
->device_handle
, FALSE
);
1459 IDirect3DDevice9_Release(device
);
1463 hr
= MF_E_TRANSFORM_NEED_MORE_INPUT
;
1465 IDirect3DSurface9_Release(surface
);
1468 LeaveCriticalSection(&mixer
->cs
);
1473 static const IMFTransformVtbl video_mixer_transform_vtbl
=
1475 video_mixer_transform_QueryInterface
,
1476 video_mixer_transform_AddRef
,
1477 video_mixer_transform_Release
,
1478 video_mixer_transform_GetStreamLimits
,
1479 video_mixer_transform_GetStreamCount
,
1480 video_mixer_transform_GetStreamIDs
,
1481 video_mixer_transform_GetInputStreamInfo
,
1482 video_mixer_transform_GetOutputStreamInfo
,
1483 video_mixer_transform_GetAttributes
,
1484 video_mixer_transform_GetInputStreamAttributes
,
1485 video_mixer_transform_GetOutputStreamAttributes
,
1486 video_mixer_transform_DeleteInputStream
,
1487 video_mixer_transform_AddInputStreams
,
1488 video_mixer_transform_GetInputAvailableType
,
1489 video_mixer_transform_GetOutputAvailableType
,
1490 video_mixer_transform_SetInputType
,
1491 video_mixer_transform_SetOutputType
,
1492 video_mixer_transform_GetInputCurrentType
,
1493 video_mixer_transform_GetOutputCurrentType
,
1494 video_mixer_transform_GetInputStatus
,
1495 video_mixer_transform_GetOutputStatus
,
1496 video_mixer_transform_SetOutputBounds
,
1497 video_mixer_transform_ProcessEvent
,
1498 video_mixer_transform_ProcessMessage
,
1499 video_mixer_transform_ProcessInput
,
1500 video_mixer_transform_ProcessOutput
,
1503 static HRESULT WINAPI
video_mixer_device_id_QueryInterface(IMFVideoDeviceID
*iface
, REFIID riid
, void **obj
)
1505 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1506 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1509 static ULONG WINAPI
video_mixer_device_id_AddRef(IMFVideoDeviceID
*iface
)
1511 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1512 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1515 static ULONG WINAPI
video_mixer_device_id_Release(IMFVideoDeviceID
*iface
)
1517 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1518 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1521 static HRESULT WINAPI
video_mixer_device_id_GetDeviceID(IMFVideoDeviceID
*iface
, IID
*device_id
)
1523 TRACE("%p, %p.\n", iface
, device_id
);
1528 memcpy(device_id
, &IID_IDirect3DDevice9
, sizeof(*device_id
));
1533 static const IMFVideoDeviceIDVtbl video_mixer_device_id_vtbl
=
1535 video_mixer_device_id_QueryInterface
,
1536 video_mixer_device_id_AddRef
,
1537 video_mixer_device_id_Release
,
1538 video_mixer_device_id_GetDeviceID
,
1541 static HRESULT WINAPI
video_mixer_service_client_QueryInterface(IMFTopologyServiceLookupClient
*iface
,
1542 REFIID riid
, void **obj
)
1544 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1545 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1548 static ULONG WINAPI
video_mixer_service_client_AddRef(IMFTopologyServiceLookupClient
*iface
)
1550 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1551 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1554 static ULONG WINAPI
video_mixer_service_client_Release(IMFTopologyServiceLookupClient
*iface
)
1556 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1557 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1560 static HRESULT WINAPI
video_mixer_service_client_InitServicePointers(IMFTopologyServiceLookupClient
*iface
,
1561 IMFTopologyServiceLookup
*service_lookup
)
1563 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1567 TRACE("%p, %p.\n", iface
, service_lookup
);
1569 if (!service_lookup
)
1572 EnterCriticalSection(&mixer
->cs
);
1575 if (FAILED(hr
= IMFTopologyServiceLookup_LookupService(service_lookup
, MF_SERVICE_LOOKUP_GLOBAL
, 0,
1576 &MR_VIDEO_RENDER_SERVICE
, &IID_IMediaEventSink
, (void **)&mixer
->event_sink
, &count
)))
1578 WARN("Failed to get renderer event sink, hr %#lx.\n", hr
);
1581 LeaveCriticalSection(&mixer
->cs
);
1586 static HRESULT WINAPI
video_mixer_service_client_ReleaseServicePointers(IMFTopologyServiceLookupClient
*iface
)
1588 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1590 TRACE("%p.\n", iface
);
1592 EnterCriticalSection(&mixer
->cs
);
1594 if (mixer
->event_sink
)
1595 IMediaEventSink_Release(mixer
->event_sink
);
1596 mixer
->event_sink
= NULL
;
1598 LeaveCriticalSection(&mixer
->cs
);
1603 static const IMFTopologyServiceLookupClientVtbl video_mixer_service_client_vtbl
=
1605 video_mixer_service_client_QueryInterface
,
1606 video_mixer_service_client_AddRef
,
1607 video_mixer_service_client_Release
,
1608 video_mixer_service_client_InitServicePointers
,
1609 video_mixer_service_client_ReleaseServicePointers
,
1612 static HRESULT WINAPI
video_mixer_control_QueryInterface(IMFVideoMixerControl2
*iface
, REFIID riid
, void **obj
)
1614 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1615 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1618 static ULONG WINAPI
video_mixer_control_AddRef(IMFVideoMixerControl2
*iface
)
1620 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1621 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1624 static ULONG WINAPI
video_mixer_control_Release(IMFVideoMixerControl2
*iface
)
1626 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1627 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1630 static HRESULT WINAPI
video_mixer_control_SetStreamZOrder(IMFVideoMixerControl2
*iface
, DWORD id
, DWORD zorder
)
1632 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1633 struct input_stream
*stream
;
1636 TRACE("%p, %lu, %lu.\n", iface
, id
, zorder
);
1638 /* Can't change reference stream. */
1640 return E_INVALIDARG
;
1642 EnterCriticalSection(&mixer
->cs
);
1644 if (zorder
>= mixer
->input_count
)
1646 else if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1648 /* Lowest zorder only applies to reference stream. */
1650 hr
= MF_E_INVALIDREQUEST
;
1651 else if (stream
->zorder
!= zorder
)
1653 stream
->zorder
= zorder
;
1654 video_mixer_update_zorder_map(mixer
);
1658 LeaveCriticalSection(&mixer
->cs
);
1663 static HRESULT WINAPI
video_mixer_control_GetStreamZOrder(IMFVideoMixerControl2
*iface
, DWORD id
, DWORD
*zorder
)
1665 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1666 struct input_stream
*stream
;
1669 TRACE("%p, %lu, %p.\n", iface
, id
, zorder
);
1674 EnterCriticalSection(&mixer
->cs
);
1676 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1677 *zorder
= stream
->zorder
;
1679 LeaveCriticalSection(&mixer
->cs
);
1684 static HRESULT WINAPI
video_mixer_control_SetStreamOutputRect(IMFVideoMixerControl2
*iface
, DWORD id
,
1685 const MFVideoNormalizedRect
*rect
)
1687 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1688 struct input_stream
*stream
;
1691 TRACE("%p, %lu, %s.\n", iface
, id
, debugstr_normalized_rect(rect
));
1696 if (rect
->left
> rect
->right
|| rect
->top
> rect
->bottom
||
1697 rect
->left
< 0.0f
|| rect
->top
< 0.0f
|| rect
->right
> 1.0f
|| rect
->bottom
> 1.0f
)
1699 return E_INVALIDARG
;
1702 EnterCriticalSection(&mixer
->cs
);
1704 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1705 stream
->rect
= *rect
;
1707 LeaveCriticalSection(&mixer
->cs
);
1712 static HRESULT WINAPI
video_mixer_control_GetStreamOutputRect(IMFVideoMixerControl2
*iface
, DWORD id
,
1713 MFVideoNormalizedRect
*rect
)
1715 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1716 struct input_stream
*stream
;
1719 TRACE("%p, %lu, %p.\n", iface
, id
, rect
);
1724 EnterCriticalSection(&mixer
->cs
);
1726 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1727 *rect
= stream
->rect
;
1729 LeaveCriticalSection(&mixer
->cs
);
1734 static HRESULT WINAPI
video_mixer_control_SetMixingPrefs(IMFVideoMixerControl2
*iface
, DWORD flags
)
1736 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1738 TRACE("%p, %#lx.\n", iface
, flags
);
1740 EnterCriticalSection(&mixer
->cs
);
1741 mixer
->mixing_flags
= flags
;
1742 LeaveCriticalSection(&mixer
->cs
);
1747 static HRESULT WINAPI
video_mixer_control_GetMixingPrefs(IMFVideoMixerControl2
*iface
, DWORD
*flags
)
1749 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1751 TRACE("%p, %p.\n", iface
, flags
);
1756 EnterCriticalSection(&mixer
->cs
);
1757 *flags
= mixer
->mixing_flags
;
1758 LeaveCriticalSection(&mixer
->cs
);
1763 static const IMFVideoMixerControl2Vtbl video_mixer_control_vtbl
=
1765 video_mixer_control_QueryInterface
,
1766 video_mixer_control_AddRef
,
1767 video_mixer_control_Release
,
1768 video_mixer_control_SetStreamZOrder
,
1769 video_mixer_control_GetStreamZOrder
,
1770 video_mixer_control_SetStreamOutputRect
,
1771 video_mixer_control_GetStreamOutputRect
,
1772 video_mixer_control_SetMixingPrefs
,
1773 video_mixer_control_GetMixingPrefs
,
1776 static HRESULT WINAPI
video_mixer_getservice_QueryInterface(IMFGetService
*iface
, REFIID riid
, void **obj
)
1778 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1779 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1782 static ULONG WINAPI
video_mixer_getservice_AddRef(IMFGetService
*iface
)
1784 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1785 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1788 static ULONG WINAPI
video_mixer_getservice_Release(IMFGetService
*iface
)
1790 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1791 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1794 static HRESULT WINAPI
video_mixer_getservice_GetService(IMFGetService
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1796 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(service
), debugstr_guid(riid
), obj
);
1798 if (IsEqualGUID(service
, &MR_VIDEO_MIXER_SERVICE
))
1800 if (IsEqualIID(riid
, &IID_IMFVideoMixerBitmap
) ||
1801 IsEqualIID(riid
, &IID_IMFVideoProcessor
) ||
1802 IsEqualIID(riid
, &IID_IMFVideoPositionMapper
) ||
1803 IsEqualIID(riid
, &IID_IMFVideoMixerControl
) ||
1804 IsEqualIID(riid
, &IID_IMFVideoMixerControl2
))
1806 return IMFGetService_QueryInterface(iface
, riid
, obj
);
1809 return E_NOINTERFACE
;
1812 FIXME("Unsupported service %s, riid %s.\n", debugstr_guid(service
), debugstr_guid(riid
));
1814 return MF_E_UNSUPPORTED_SERVICE
;
1817 static const IMFGetServiceVtbl video_mixer_getservice_vtbl
=
1819 video_mixer_getservice_QueryInterface
,
1820 video_mixer_getservice_AddRef
,
1821 video_mixer_getservice_Release
,
1822 video_mixer_getservice_GetService
,
1825 static HRESULT WINAPI
video_mixer_bitmap_QueryInterface(IMFVideoMixerBitmap
*iface
, REFIID riid
, void **obj
)
1827 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1828 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1831 static ULONG WINAPI
video_mixer_bitmap_AddRef(IMFVideoMixerBitmap
*iface
)
1833 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1834 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1837 static ULONG WINAPI
video_mixer_bitmap_Release(IMFVideoMixerBitmap
*iface
)
1839 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1840 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1843 static HRESULT WINAPI
video_mixer_bitmap_SetAlphaBitmap(IMFVideoMixerBitmap
*iface
, const MFVideoAlphaBitmap
*bitmap
)
1845 FIXME("%p, %p.\n", iface
, bitmap
);
1850 static HRESULT WINAPI
video_mixer_bitmap_ClearAlphaBitmap(IMFVideoMixerBitmap
*iface
)
1852 FIXME("%p.\n", iface
);
1857 static HRESULT WINAPI
video_mixer_bitmap_UpdateAlphaBitmapParameters(IMFVideoMixerBitmap
*iface
,
1858 const MFVideoAlphaBitmapParams
*params
)
1860 FIXME("%p, %p.\n", iface
, params
);
1865 static HRESULT WINAPI
video_mixer_bitmap_GetAlphaBitmapParameters(IMFVideoMixerBitmap
*iface
, MFVideoAlphaBitmapParams
*params
)
1867 FIXME("%p, %p.\n", iface
, params
);
1872 static const IMFVideoMixerBitmapVtbl video_mixer_bitmap_vtbl
=
1874 video_mixer_bitmap_QueryInterface
,
1875 video_mixer_bitmap_AddRef
,
1876 video_mixer_bitmap_Release
,
1877 video_mixer_bitmap_SetAlphaBitmap
,
1878 video_mixer_bitmap_ClearAlphaBitmap
,
1879 video_mixer_bitmap_UpdateAlphaBitmapParameters
,
1880 video_mixer_bitmap_GetAlphaBitmapParameters
,
1883 static HRESULT WINAPI
video_mixer_position_mapper_QueryInterface(IMFVideoPositionMapper
*iface
, REFIID riid
, void **obj
)
1885 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1886 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1889 static ULONG WINAPI
video_mixer_position_mapper_AddRef(IMFVideoPositionMapper
*iface
)
1891 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1892 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1895 static ULONG WINAPI
video_mixer_position_mapper_Release(IMFVideoPositionMapper
*iface
)
1897 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1898 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1901 static HRESULT WINAPI
video_mixer_position_mapper_MapOutputCoordinateToInputStream(IMFVideoPositionMapper
*iface
,
1902 float x_out
, float y_out
, DWORD output_stream
, DWORD input_stream
, float *x_in
, float *y_in
)
1904 FIXME("%p, %f, %f, %lu, %lu, %p, %p.\n", iface
, x_out
, y_out
, output_stream
, input_stream
, x_in
, y_in
);
1909 static const IMFVideoPositionMapperVtbl video_mixer_position_mapper_vtbl
=
1911 video_mixer_position_mapper_QueryInterface
,
1912 video_mixer_position_mapper_AddRef
,
1913 video_mixer_position_mapper_Release
,
1914 video_mixer_position_mapper_MapOutputCoordinateToInputStream
,
1917 static HRESULT WINAPI
video_mixer_processor_QueryInterface(IMFVideoProcessor
*iface
, REFIID riid
, void **obj
)
1919 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1920 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1923 static ULONG WINAPI
video_mixer_processor_AddRef(IMFVideoProcessor
*iface
)
1925 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1926 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1929 static ULONG WINAPI
video_mixer_processor_Release(IMFVideoProcessor
*iface
)
1931 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1932 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1935 static HRESULT WINAPI
video_mixer_processor_GetAvailableVideoProcessorModes(IMFVideoProcessor
*iface
, UINT
*count
,
1938 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1939 IDirectXVideoProcessorService
*service
;
1940 DXVA2_VideoDesc video_desc
;
1943 TRACE("%p, %p, %p.\n", iface
, count
, modes
);
1945 EnterCriticalSection(&mixer
->cs
);
1947 if (!mixer
->inputs
[0].media_type
|| !mixer
->output
.media_type
)
1948 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1949 else if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
1951 video_mixer_init_dxva_videodesc(mixer
->inputs
[0].media_type
, &video_desc
);
1952 hr
= IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(service
, &video_desc
, count
, modes
);
1953 IDirectXVideoProcessorService_Release(service
);
1956 LeaveCriticalSection(&mixer
->cs
);
1961 static HRESULT WINAPI
video_mixer_processor_GetVideoProcessorCaps(IMFVideoProcessor
*iface
, GUID
*mode
,
1962 DXVA2_VideoProcessorCaps
*caps
)
1964 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1965 IDirectXVideoProcessorService
*service
;
1966 DXVA2_VideoDesc video_desc
;
1967 GUID subtype
= { 0 };
1970 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(mode
), caps
);
1972 EnterCriticalSection(&mixer
->cs
);
1974 if (!mixer
->inputs
[0].media_type
|| !mixer
->output
.media_type
)
1975 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1976 else if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
1978 video_mixer_init_dxva_videodesc(mixer
->inputs
[0].media_type
, &video_desc
);
1979 IMFMediaType_GetGUID(mixer
->output
.media_type
, &MF_MT_SUBTYPE
, &subtype
);
1981 hr
= IDirectXVideoProcessorService_GetVideoProcessorCaps(service
, mode
, &video_desc
, subtype
.Data1
, caps
);
1982 IDirectXVideoProcessorService_Release(service
);
1985 LeaveCriticalSection(&mixer
->cs
);
1990 static HRESULT WINAPI
video_mixer_processor_GetVideoProcessorMode(IMFVideoProcessor
*iface
, GUID
*mode
)
1992 FIXME("%p, %p.\n", iface
, mode
);
1997 static HRESULT WINAPI
video_mixer_processor_SetVideoProcessorMode(IMFVideoProcessor
*iface
, GUID
*mode
)
1999 FIXME("%p, %s.\n", iface
, debugstr_guid(mode
));
2004 static HRESULT WINAPI
video_mixer_processor_GetProcAmpRange(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_ValueRange
*range
)
2006 FIXME("%p, %#lx, %p.\n", iface
, prop
, range
);
2011 static HRESULT WINAPI
video_mixer_processor_GetProcAmpValues(IMFVideoProcessor
*iface
, DWORD flags
, DXVA2_ProcAmpValues
*values
)
2013 FIXME("%p, %#lx, %p.\n", iface
, flags
, values
);
2018 static HRESULT WINAPI
video_mixer_processor_SetProcAmpValues(IMFVideoProcessor
*iface
, DWORD flags
, DXVA2_ProcAmpValues
*values
)
2020 FIXME("%p, %#lx, %p.\n", iface
, flags
, values
);
2025 static HRESULT WINAPI
video_mixer_processor_GetFilteringRange(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_ValueRange
*range
)
2027 FIXME("%p, %#lx, %p.\n", iface
, prop
, range
);
2032 static HRESULT WINAPI
video_mixer_processor_GetFilteringValue(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_Fixed32
*value
)
2034 FIXME("%p, %#lx, %p.\n", iface
, prop
, value
);
2039 static HRESULT WINAPI
video_mixer_processor_SetFilteringValue(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_Fixed32
*value
)
2041 FIXME("%p, %#lx, %p.\n", iface
, prop
, value
);
2046 static HRESULT WINAPI
video_mixer_processor_GetBackgroundColor(IMFVideoProcessor
*iface
, COLORREF
*color
)
2048 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
2050 TRACE("%p, %p.\n", iface
, color
);
2055 EnterCriticalSection(&mixer
->cs
);
2056 *color
= mixer
->bkgnd_color
.rgba
;
2057 LeaveCriticalSection(&mixer
->cs
);
2062 static void video_mixer_rgb_to_ycbcr(COLORREF rgb
, DXVA2_AYUVSample16
*ayuv
)
2064 int y
, cb
, cr
, r
, g
, b
;
2066 r
= GetRValue(rgb
); g
= GetGValue(rgb
); b
= GetBValue(rgb
);
2067 /* Coefficients according to SDTV ITU-R BT.601 */
2068 y
= (77 * r
+ 150 * g
+ 29 * b
+ 128) / 256 + 16;
2069 cb
= (-44 * r
- 87 * g
+ 131 * b
+ 128) / 256 + 128;
2070 cr
= (131 * r
- 110 * g
- 21 * b
+ 128) / 256 + 128;
2072 ayuv
->Y
= y
* 0x100;
2073 ayuv
->Cb
= cb
* 0x100;
2074 ayuv
->Cr
= cr
* 0x100;
2075 ayuv
->Alpha
= 0xffff;
2078 static HRESULT WINAPI
video_mixer_processor_SetBackgroundColor(IMFVideoProcessor
*iface
, COLORREF color
)
2080 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
2082 TRACE("%p, %#lx.\n", iface
, color
);
2084 EnterCriticalSection(&mixer
->cs
);
2085 if (mixer
->bkgnd_color
.rgba
!= color
)
2087 video_mixer_rgb_to_ycbcr(color
, &mixer
->bkgnd_color
.ayuv
);
2088 mixer
->bkgnd_color
.rgba
= color
;
2090 LeaveCriticalSection(&mixer
->cs
);
2095 static const IMFVideoProcessorVtbl video_mixer_processor_vtbl
=
2097 video_mixer_processor_QueryInterface
,
2098 video_mixer_processor_AddRef
,
2099 video_mixer_processor_Release
,
2100 video_mixer_processor_GetAvailableVideoProcessorModes
,
2101 video_mixer_processor_GetVideoProcessorCaps
,
2102 video_mixer_processor_GetVideoProcessorMode
,
2103 video_mixer_processor_SetVideoProcessorMode
,
2104 video_mixer_processor_GetProcAmpRange
,
2105 video_mixer_processor_GetProcAmpValues
,
2106 video_mixer_processor_SetProcAmpValues
,
2107 video_mixer_processor_GetFilteringRange
,
2108 video_mixer_processor_GetFilteringValue
,
2109 video_mixer_processor_SetFilteringValue
,
2110 video_mixer_processor_GetBackgroundColor
,
2111 video_mixer_processor_SetBackgroundColor
,
2114 static HRESULT WINAPI
video_mixer_attributes_QueryInterface(IMFAttributes
*iface
, REFIID riid
, void **out
)
2116 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2117 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
2120 static ULONG WINAPI
video_mixer_attributes_AddRef(IMFAttributes
*iface
)
2122 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2123 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
2126 static ULONG WINAPI
video_mixer_attributes_Release(IMFAttributes
*iface
)
2128 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2129 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
2132 static HRESULT WINAPI
video_mixer_attributes_GetItem(IMFAttributes
*iface
, REFGUID key
, PROPVARIANT
*value
)
2134 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2136 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2138 return IMFAttributes_GetItem(mixer
->internal_attributes
, key
, value
);
2141 static HRESULT WINAPI
video_mixer_attributes_GetItemType(IMFAttributes
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
2143 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2145 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), type
);
2147 return IMFAttributes_GetItemType(mixer
->internal_attributes
, key
, type
);
2150 static HRESULT WINAPI
video_mixer_attributes_CompareItem(IMFAttributes
*iface
, REFGUID key
,
2151 REFPROPVARIANT value
, BOOL
*result
)
2153 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2155 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, result
);
2157 return IMFAttributes_CompareItem(mixer
->internal_attributes
, key
, value
, result
);
2160 static HRESULT WINAPI
video_mixer_attributes_Compare(IMFAttributes
*iface
, IMFAttributes
*theirs
,
2161 MF_ATTRIBUTES_MATCH_TYPE match_type
, BOOL
*ret
)
2163 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2165 TRACE("%p, %p, %d, %p.\n", iface
, theirs
, match_type
, ret
);
2167 return IMFAttributes_Compare(mixer
->internal_attributes
, theirs
, match_type
, ret
);
2170 static HRESULT WINAPI
video_mixer_attributes_GetUINT32(IMFAttributes
*iface
, REFGUID key
, UINT32
*value
)
2172 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2174 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2176 return IMFAttributes_GetUINT32(mixer
->internal_attributes
, key
, value
);
2179 static HRESULT WINAPI
video_mixer_attributes_GetUINT64(IMFAttributes
*iface
, REFGUID key
, UINT64
*value
)
2181 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2183 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2185 return IMFAttributes_GetUINT64(mixer
->internal_attributes
, key
, value
);
2188 static HRESULT WINAPI
video_mixer_attributes_GetDouble(IMFAttributes
*iface
, REFGUID key
, double *value
)
2190 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2192 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2194 return IMFAttributes_GetDouble(mixer
->internal_attributes
, key
, value
);
2197 static HRESULT WINAPI
video_mixer_attributes_GetGUID(IMFAttributes
*iface
, REFGUID key
, GUID
*value
)
2199 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2201 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2203 return IMFAttributes_GetGUID(mixer
->internal_attributes
, key
, value
);
2206 static HRESULT WINAPI
video_mixer_attributes_GetStringLength(IMFAttributes
*iface
, REFGUID key
, UINT32
*length
)
2208 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2210 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), length
);
2212 return IMFAttributes_GetStringLength(mixer
->internal_attributes
, key
, length
);
2215 static HRESULT WINAPI
video_mixer_attributes_GetString(IMFAttributes
*iface
, REFGUID key
, WCHAR
*value
,
2216 UINT32 size
, UINT32
*length
)
2218 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2220 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), value
, size
, length
);
2222 return IMFAttributes_GetString(mixer
->internal_attributes
, key
, value
, size
, length
);
2225 static HRESULT WINAPI
video_mixer_attributes_GetAllocatedString(IMFAttributes
*iface
, REFGUID key
,
2226 WCHAR
**value
, UINT32
*length
)
2228 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2230 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, length
);
2232 return IMFAttributes_GetAllocatedString(mixer
->internal_attributes
, key
, value
, length
);
2235 static HRESULT WINAPI
video_mixer_attributes_GetBlobSize(IMFAttributes
*iface
, REFGUID key
, UINT32
*size
)
2237 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2239 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), size
);
2241 return IMFAttributes_GetBlobSize(mixer
->internal_attributes
, key
, size
);
2244 static HRESULT WINAPI
video_mixer_attributes_GetBlob(IMFAttributes
*iface
, REFGUID key
, UINT8
*buf
,
2245 UINT32 bufsize
, UINT32
*blobsize
)
2247 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2249 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), buf
, bufsize
, blobsize
);
2251 return IMFAttributes_GetBlob(mixer
->internal_attributes
, key
, buf
, bufsize
, blobsize
);
2254 static HRESULT WINAPI
video_mixer_attributes_GetAllocatedBlob(IMFAttributes
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
2256 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2258 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), buf
, size
);
2260 return IMFAttributes_GetAllocatedBlob(mixer
->internal_attributes
, key
, buf
, size
);
2263 static HRESULT WINAPI
video_mixer_attributes_GetUnknown(IMFAttributes
*iface
, REFGUID key
, REFIID riid
, void **out
)
2265 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2267 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(key
), debugstr_guid(riid
), out
);
2269 return IMFAttributes_GetUnknown(mixer
->internal_attributes
, key
, riid
, out
);
2272 static HRESULT WINAPI
video_mixer_attributes_SetItem(IMFAttributes
*iface
, REFGUID key
, REFPROPVARIANT value
)
2274 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2276 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2278 return IMFAttributes_SetItem(mixer
->internal_attributes
, key
, value
);
2281 static HRESULT WINAPI
video_mixer_attributes_DeleteItem(IMFAttributes
*iface
, REFGUID key
)
2283 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2285 TRACE("%p, %s.\n", iface
, debugstr_guid(key
));
2287 return IMFAttributes_DeleteItem(mixer
->internal_attributes
, key
);
2290 static HRESULT WINAPI
video_mixer_attributes_DeleteAllItems(IMFAttributes
*iface
)
2292 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2294 TRACE("%p.\n", iface
);
2296 return IMFAttributes_DeleteAllItems(mixer
->internal_attributes
);
2299 static HRESULT WINAPI
video_mixer_attributes_SetUINT32(IMFAttributes
*iface
, REFGUID key
, UINT32 value
)
2301 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2303 TRACE("%p, %s, %u.\n", iface
, debugstr_guid(key
), value
);
2305 return IMFAttributes_SetUINT32(mixer
->internal_attributes
, key
, value
);
2308 static HRESULT WINAPI
video_mixer_attributes_SetUINT64(IMFAttributes
*iface
, REFGUID key
, UINT64 value
)
2310 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2312 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), wine_dbgstr_longlong(value
));
2314 return IMFAttributes_SetUINT64(mixer
->internal_attributes
, key
, value
);
2317 static HRESULT WINAPI
video_mixer_attributes_SetDouble(IMFAttributes
*iface
, REFGUID key
, double value
)
2319 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2321 TRACE("%p, %s, %f.\n", iface
, debugstr_guid(key
), value
);
2323 return IMFAttributes_SetDouble(mixer
->internal_attributes
, key
, value
);
2326 static HRESULT WINAPI
video_mixer_attributes_SetGUID(IMFAttributes
*iface
, REFGUID key
, REFGUID value
)
2328 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2330 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_guid(value
));
2332 return IMFAttributes_SetGUID(mixer
->internal_attributes
, key
, value
);
2335 static HRESULT WINAPI
video_mixer_attributes_SetString(IMFAttributes
*iface
, REFGUID key
, const WCHAR
*value
)
2337 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2339 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_w(value
));
2341 return IMFAttributes_SetString(mixer
->internal_attributes
, key
, value
);
2344 static HRESULT WINAPI
video_mixer_attributes_SetBlob(IMFAttributes
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
2346 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2348 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_guid(key
), buf
, size
);
2350 return IMFAttributes_SetBlob(mixer
->internal_attributes
, key
, buf
, size
);
2353 static HRESULT WINAPI
video_mixer_attributes_SetUnknown(IMFAttributes
*iface
, REFGUID key
, IUnknown
*unknown
)
2355 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2357 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), unknown
);
2359 return IMFAttributes_SetUnknown(mixer
->internal_attributes
, key
, unknown
);
2362 static HRESULT WINAPI
video_mixer_attributes_LockStore(IMFAttributes
*iface
)
2364 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2366 TRACE("%p.\n", iface
);
2368 return IMFAttributes_LockStore(mixer
->internal_attributes
);
2371 static HRESULT WINAPI
video_mixer_attributes_UnlockStore(IMFAttributes
*iface
)
2373 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2375 TRACE("%p.\n", iface
);
2377 return IMFAttributes_UnlockStore(mixer
->internal_attributes
);
2380 static HRESULT WINAPI
video_mixer_attributes_GetCount(IMFAttributes
*iface
, UINT32
*count
)
2382 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2384 TRACE("%p, %p.\n", iface
, count
);
2386 return IMFAttributes_GetCount(mixer
->internal_attributes
, count
);
2389 static HRESULT WINAPI
video_mixer_attributes_GetItemByIndex(IMFAttributes
*iface
, UINT32 index
,
2390 GUID
*key
, PROPVARIANT
*value
)
2392 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2394 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
2396 return IMFAttributes_GetItemByIndex(mixer
->internal_attributes
, index
, key
, value
);
2399 static HRESULT WINAPI
video_mixer_attributes_CopyAllItems(IMFAttributes
*iface
, IMFAttributes
*dest
)
2401 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2403 TRACE("%p, %p.\n", iface
, dest
);
2405 return IMFAttributes_CopyAllItems(mixer
->internal_attributes
, dest
);
2408 static const IMFAttributesVtbl video_mixer_attributes_vtbl
=
2410 video_mixer_attributes_QueryInterface
,
2411 video_mixer_attributes_AddRef
,
2412 video_mixer_attributes_Release
,
2413 video_mixer_attributes_GetItem
,
2414 video_mixer_attributes_GetItemType
,
2415 video_mixer_attributes_CompareItem
,
2416 video_mixer_attributes_Compare
,
2417 video_mixer_attributes_GetUINT32
,
2418 video_mixer_attributes_GetUINT64
,
2419 video_mixer_attributes_GetDouble
,
2420 video_mixer_attributes_GetGUID
,
2421 video_mixer_attributes_GetStringLength
,
2422 video_mixer_attributes_GetString
,
2423 video_mixer_attributes_GetAllocatedString
,
2424 video_mixer_attributes_GetBlobSize
,
2425 video_mixer_attributes_GetBlob
,
2426 video_mixer_attributes_GetAllocatedBlob
,
2427 video_mixer_attributes_GetUnknown
,
2428 video_mixer_attributes_SetItem
,
2429 video_mixer_attributes_DeleteItem
,
2430 video_mixer_attributes_DeleteAllItems
,
2431 video_mixer_attributes_SetUINT32
,
2432 video_mixer_attributes_SetUINT64
,
2433 video_mixer_attributes_SetDouble
,
2434 video_mixer_attributes_SetGUID
,
2435 video_mixer_attributes_SetString
,
2436 video_mixer_attributes_SetBlob
,
2437 video_mixer_attributes_SetUnknown
,
2438 video_mixer_attributes_LockStore
,
2439 video_mixer_attributes_UnlockStore
,
2440 video_mixer_attributes_GetCount
,
2441 video_mixer_attributes_GetItemByIndex
,
2442 video_mixer_attributes_CopyAllItems
2445 static HRESULT WINAPI
video_mixer_quality_advise_QueryInterface(IMFQualityAdvise
*iface
, REFIID riid
, void **out
)
2447 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2448 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
2451 static ULONG WINAPI
video_mixer_quality_advise_AddRef(IMFQualityAdvise
*iface
)
2453 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2454 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
2457 static ULONG WINAPI
video_mixer_quality_advise_Release(IMFQualityAdvise
*iface
)
2459 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2460 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
2463 static HRESULT WINAPI
video_mixer_quality_advise_SetDropMode(IMFQualityAdvise
*iface
, MF_QUALITY_DROP_MODE mode
)
2465 FIXME("%p, %u.\n", iface
, mode
);
2470 static HRESULT WINAPI
video_mixer_quality_advise_SetQualityLevel(IMFQualityAdvise
*iface
, MF_QUALITY_LEVEL level
)
2472 FIXME("%p, %u.\n", iface
, level
);
2477 static HRESULT WINAPI
video_mixer_quality_advise_GetDropMode(IMFQualityAdvise
*iface
, MF_QUALITY_DROP_MODE
*mode
)
2479 FIXME("%p, %p.\n", iface
, mode
);
2484 static HRESULT WINAPI
video_mixer_quality_advise_GetQualityLevel(IMFQualityAdvise
*iface
, MF_QUALITY_LEVEL
*level
)
2486 FIXME("%p, %p.\n", iface
, level
);
2491 static HRESULT WINAPI
video_mixer_quality_advise_DropTime(IMFQualityAdvise
*iface
, LONGLONG interval
)
2493 FIXME("%p, %s.\n", iface
, wine_dbgstr_longlong(interval
));
2498 static const IMFQualityAdviseVtbl video_mixer_quality_advise_vtbl
=
2500 video_mixer_quality_advise_QueryInterface
,
2501 video_mixer_quality_advise_AddRef
,
2502 video_mixer_quality_advise_Release
,
2503 video_mixer_quality_advise_SetDropMode
,
2504 video_mixer_quality_advise_SetQualityLevel
,
2505 video_mixer_quality_advise_GetDropMode
,
2506 video_mixer_quality_advise_GetQualityLevel
,
2507 video_mixer_quality_advise_DropTime
,
2510 static HRESULT WINAPI
video_mixer_clock_state_sink_QueryInterface(IMFClockStateSink
*iface
,
2511 REFIID riid
, void **out
)
2513 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2514 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
2517 static ULONG WINAPI
video_mixer_clock_state_sink_AddRef(IMFClockStateSink
*iface
)
2519 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2520 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
2523 static ULONG WINAPI
video_mixer_clock_state_sink_Release(IMFClockStateSink
*iface
)
2525 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2526 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
2529 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockStart(IMFClockStateSink
*iface
,
2530 MFTIME systime
, LONGLONG offset
)
2532 FIXME("%p.\n", iface
);
2537 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockStop(IMFClockStateSink
*iface
,
2540 FIXME("%p.\n", iface
);
2545 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockPause(IMFClockStateSink
*iface
,
2548 FIXME("%p.\n", iface
);
2553 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockRestart(IMFClockStateSink
*iface
,
2556 FIXME("%p.\n", iface
);
2561 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockSetRate(IMFClockStateSink
*iface
,
2562 MFTIME systime
, float rate
)
2564 FIXME("%p, %f.\n", iface
, rate
);
2569 static const IMFClockStateSinkVtbl video_mixer_clock_state_sink_vtbl
=
2571 video_mixer_clock_state_sink_QueryInterface
,
2572 video_mixer_clock_state_sink_AddRef
,
2573 video_mixer_clock_state_sink_Release
,
2574 video_mixer_clock_state_sink_OnClockStart
,
2575 video_mixer_clock_state_sink_OnClockStop
,
2576 video_mixer_clock_state_sink_OnClockPause
,
2577 video_mixer_clock_state_sink_OnClockRestart
,
2578 video_mixer_clock_state_sink_OnClockSetRate
,
2581 HRESULT WINAPI
MFCreateVideoMixer(IUnknown
*owner
, REFIID riid_device
, REFIID riid
, void **obj
)
2583 TRACE("%p, %s, %s, %p.\n", owner
, debugstr_guid(riid_device
), debugstr_guid(riid
), obj
);
2587 if (!IsEqualIID(riid_device
, &IID_IDirect3DDevice9
))
2588 return E_INVALIDARG
;
2590 return CoCreateInstance(&CLSID_MFVideoMixer9
, owner
, CLSCTX_INPROC_SERVER
, riid
, obj
);
2593 HRESULT
evr_mixer_create(IUnknown
*outer
, void **out
)
2595 struct video_mixer
*object
;
2596 MFVideoNormalizedRect rect
;
2599 if (!(object
= calloc(1, sizeof(*object
))))
2600 return E_OUTOFMEMORY
;
2602 object
->IMFTransform_iface
.lpVtbl
= &video_mixer_transform_vtbl
;
2603 object
->IMFVideoDeviceID_iface
.lpVtbl
= &video_mixer_device_id_vtbl
;
2604 object
->IMFTopologyServiceLookupClient_iface
.lpVtbl
= &video_mixer_service_client_vtbl
;
2605 object
->IMFVideoMixerControl2_iface
.lpVtbl
= &video_mixer_control_vtbl
;
2606 object
->IMFGetService_iface
.lpVtbl
= &video_mixer_getservice_vtbl
;
2607 object
->IMFVideoMixerBitmap_iface
.lpVtbl
= &video_mixer_bitmap_vtbl
;
2608 object
->IMFVideoPositionMapper_iface
.lpVtbl
= &video_mixer_position_mapper_vtbl
;
2609 object
->IMFVideoProcessor_iface
.lpVtbl
= &video_mixer_processor_vtbl
;
2610 object
->IMFAttributes_iface
.lpVtbl
= &video_mixer_attributes_vtbl
;
2611 object
->IMFQualityAdvise_iface
.lpVtbl
= &video_mixer_quality_advise_vtbl
;
2612 object
->IMFClockStateSink_iface
.lpVtbl
= &video_mixer_clock_state_sink_vtbl
;
2613 object
->IUnknown_inner
.lpVtbl
= &video_mixer_inner_vtbl
;
2614 object
->outer_unk
= outer
? outer
: &object
->IUnknown_inner
;
2615 object
->refcount
= 1;
2616 object
->input_count
= 1;
2617 object
->lower_bound
= MFT_OUTPUT_BOUND_LOWER_UNBOUNDED
;
2618 object
->upper_bound
= MFT_OUTPUT_BOUND_UPPER_UNBOUNDED
;
2619 video_mixer_init_input(&object
->inputs
[0]);
2620 video_mixer_update_zorder_map(object
);
2621 video_mixer_rgb_to_ycbcr(object
->bkgnd_color
.rgba
, &object
->bkgnd_color
.ayuv
);
2622 InitializeCriticalSection(&object
->cs
);
2623 if (FAILED(hr
= MFCreateAttributes(&object
->attributes
, 0)))
2625 IUnknown_Release(&object
->IUnknown_inner
);
2628 if (FAILED(hr
= MFCreateAttributes(&object
->internal_attributes
, 0)))
2630 IUnknown_Release(&object
->IUnknown_inner
);
2634 /* Default attributes configuration. */
2636 rect
.left
= rect
.top
= 0.0f
;
2637 rect
.right
= rect
.bottom
= 1.0f
;
2638 IMFAttributes_SetBlob(object
->attributes
, &VIDEO_ZOOM_RECT
, (const UINT8
*)&rect
, sizeof(rect
));
2640 IMFAttributes_SetUINT32(object
->internal_attributes
, &MF_SA_D3D_AWARE
, 1);
2642 *out
= &object
->IUnknown_inner
;