winegstreamer: Set MFT_OUTPUT_DATA_BUFFER_INCOMPLETE in wg_transform_read_mf.
[wine.git] / dlls / winegstreamer / color_convert.c
blob2b8d06b991c5785d942029270e72c2838b07849e
1 /* Copyright 2022 RĂ©mi Bernon for CodeWeavers
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #include "gst_private.h"
20 #include "mfapi.h"
21 #include "mferror.h"
22 #include "mfobjects.h"
23 #include "mftransform.h"
24 #include "wmcodecdsp.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
29 WINE_DECLARE_DEBUG_CHANNEL(winediag);
31 static const GUID *const input_types[] =
33 &MFVideoFormat_YV12,
34 &MFVideoFormat_YUY2,
35 &MFVideoFormat_UYVY,
36 &MFVideoFormat_AYUV,
37 &MFVideoFormat_NV12,
38 &MFVideoFormat_RGB32,
39 &MFVideoFormat_RGB565,
40 &MFVideoFormat_I420,
41 &MFVideoFormat_IYUV,
42 &MFVideoFormat_YVYU,
43 &MFVideoFormat_RGB24,
44 &MFVideoFormat_RGB555,
45 &MEDIASUBTYPE_RGB8,
46 &MEDIASUBTYPE_V216,
47 &MEDIASUBTYPE_V410,
48 &MFVideoFormat_NV11,
49 &MFVideoFormat_Y41P,
50 &MFVideoFormat_Y41T,
51 &MFVideoFormat_Y42T,
52 &MFVideoFormat_YVU9,
54 static const GUID *const output_types[] =
56 &MFVideoFormat_YV12,
57 &MFVideoFormat_YUY2,
58 &MFVideoFormat_UYVY,
59 &MFVideoFormat_AYUV,
60 &MFVideoFormat_NV12,
61 &MFVideoFormat_RGB32,
62 &MFVideoFormat_RGB565,
63 &MFVideoFormat_I420,
64 &MFVideoFormat_IYUV,
65 &MFVideoFormat_YVYU,
66 &MFVideoFormat_RGB24,
67 &MFVideoFormat_RGB555,
68 &MEDIASUBTYPE_RGB8,
69 &MEDIASUBTYPE_V216,
70 &MEDIASUBTYPE_V410,
71 &MFVideoFormat_NV11,
74 struct color_convert
76 IUnknown IUnknown_inner;
77 IMFTransform IMFTransform_iface;
78 IMediaObject IMediaObject_iface;
79 IPropertyBag IPropertyBag_iface;
80 IPropertyStore IPropertyStore_iface;
81 IUnknown *outer;
82 LONG refcount;
83 IMFMediaType *input_type;
84 IMFMediaType *output_type;
86 struct wg_transform *wg_transform;
87 struct wg_sample_queue *wg_sample_queue;
90 static inline struct color_convert *impl_from_IUnknown(IUnknown *iface)
92 return CONTAINING_RECORD(iface, struct color_convert, IUnknown_inner);
95 static HRESULT try_create_wg_transform(struct color_convert *impl)
97 struct wg_format input_format, output_format;
99 if (impl->wg_transform)
100 wg_transform_destroy(impl->wg_transform);
101 impl->wg_transform = NULL;
103 mf_media_type_to_wg_format(impl->input_type, &input_format);
104 if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
105 return MF_E_INVALIDMEDIATYPE;
107 mf_media_type_to_wg_format(impl->output_type, &output_format);
108 if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
109 return MF_E_INVALIDMEDIATYPE;
111 if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format)))
112 return E_FAIL;
114 return S_OK;
117 static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out)
119 struct color_convert *impl = impl_from_IUnknown(iface);
121 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
123 if (IsEqualGUID(iid, &IID_IUnknown))
124 *out = &impl->IUnknown_inner;
125 else if (IsEqualGUID(iid, &IID_IMFTransform))
126 *out = &impl->IMFTransform_iface;
127 else if (IsEqualGUID(iid, &IID_IMediaObject))
128 *out = &impl->IMediaObject_iface;
129 else if (IsEqualIID(iid, &IID_IPropertyBag))
130 *out = &impl->IPropertyBag_iface;
131 else if (IsEqualIID(iid, &IID_IPropertyStore))
132 *out = &impl->IPropertyStore_iface;
133 else
135 *out = NULL;
136 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
137 return E_NOINTERFACE;
140 IUnknown_AddRef((IUnknown *)*out);
141 return S_OK;
144 static ULONG WINAPI unknown_AddRef(IUnknown *iface)
146 struct color_convert *impl = impl_from_IUnknown(iface);
147 ULONG refcount = InterlockedIncrement(&impl->refcount);
149 TRACE("iface %p increasing refcount to %lu.\n", iface, refcount);
151 return refcount;
154 static ULONG WINAPI unknown_Release(IUnknown *iface)
156 struct color_convert *impl = impl_from_IUnknown(iface);
157 ULONG refcount = InterlockedDecrement(&impl->refcount);
159 TRACE("iface %p decreasing refcount to %lu.\n", iface, refcount);
161 if (!refcount)
163 if (impl->wg_transform)
164 wg_transform_destroy(impl->wg_transform);
165 if (impl->input_type)
166 IMFMediaType_Release(impl->input_type);
167 if (impl->output_type)
168 IMFMediaType_Release(impl->output_type);
170 wg_sample_queue_destroy(impl->wg_sample_queue);
171 free(impl);
174 return refcount;
177 static const IUnknownVtbl unknown_vtbl =
179 unknown_QueryInterface,
180 unknown_AddRef,
181 unknown_Release,
184 static struct color_convert *impl_from_IMFTransform(IMFTransform *iface)
186 return CONTAINING_RECORD(iface, struct color_convert, IMFTransform_iface);
189 static HRESULT WINAPI transform_QueryInterface(IMFTransform *iface, REFIID iid, void **out)
191 return IUnknown_QueryInterface(impl_from_IMFTransform(iface)->outer, iid, out);
194 static ULONG WINAPI transform_AddRef(IMFTransform *iface)
196 return IUnknown_AddRef(impl_from_IMFTransform(iface)->outer);
199 static ULONG WINAPI transform_Release(IMFTransform *iface)
201 return IUnknown_Release(impl_from_IMFTransform(iface)->outer);
204 static HRESULT WINAPI transform_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum,
205 DWORD *input_maximum, DWORD *output_minimum, DWORD *output_maximum)
207 TRACE("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p.\n",
208 iface, input_minimum, input_maximum, output_minimum, output_maximum);
209 *input_minimum = *input_maximum = *output_minimum = *output_maximum = 1;
210 return S_OK;
213 static HRESULT WINAPI transform_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs)
215 TRACE("iface %p, inputs %p, outputs %p.\n", iface, inputs, outputs);
216 *inputs = *outputs = 1;
217 return S_OK;
220 static HRESULT WINAPI transform_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs,
221 DWORD output_size, DWORD *outputs)
223 FIXME("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p stub!\n", iface,
224 input_size, inputs, output_size, outputs);
225 return E_NOTIMPL;
228 static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info)
230 struct color_convert *impl = impl_from_IMFTransform(iface);
231 UINT32 sample_size;
232 UINT64 framesize;
233 GUID subtype;
234 HRESULT hr;
236 TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
238 if (!impl->input_type || !impl->output_type)
239 return MF_E_TRANSFORM_TYPE_NOT_SET;
241 if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->input_type, &MF_MT_SUBTYPE, &subtype)) &&
242 SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->input_type, &MF_MT_FRAME_SIZE, &framesize)))
243 MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
244 else
245 sample_size = 0;
247 info->dwFlags = 0;
248 info->cbSize = sample_size;
249 info->cbAlignment = 1;
250 info->hnsMaxLatency = 0;
251 info->cbMaxLookahead = 0;
253 return S_OK;
256 static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info)
258 struct color_convert *impl = impl_from_IMFTransform(iface);
259 UINT32 sample_size;
260 UINT64 framesize;
261 GUID subtype;
262 HRESULT hr;
264 TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
266 if (!impl->input_type || !impl->output_type)
267 return MF_E_TRANSFORM_TYPE_NOT_SET;
269 if (SUCCEEDED(hr = IMFMediaType_GetGUID(impl->output_type, &MF_MT_SUBTYPE, &subtype)) &&
270 SUCCEEDED(hr = IMFMediaType_GetUINT64(impl->output_type, &MF_MT_FRAME_SIZE, &framesize)))
271 MFCalculateImageSize(&subtype, framesize >> 32, (UINT32)framesize, &sample_size);
272 else
273 sample_size = 0;
275 info->dwFlags = 0;
276 info->cbSize = sample_size;
277 info->cbAlignment = 1;
279 return S_OK;
282 static HRESULT WINAPI transform_GetAttributes(IMFTransform *iface, IMFAttributes **attributes)
284 FIXME("iface %p, attributes %p stub!\n", iface, attributes);
285 return E_NOTIMPL;
288 static HRESULT WINAPI transform_GetInputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes)
290 FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes);
291 return MFCreateAttributes(attributes, 0);
294 static HRESULT WINAPI transform_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, IMFAttributes **attributes)
296 FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes);
297 return E_NOTIMPL;
300 static HRESULT WINAPI transform_DeleteInputStream(IMFTransform *iface, DWORD id)
302 FIXME("iface %p, id %#lx stub!\n", iface, id);
303 return E_NOTIMPL;
306 static HRESULT WINAPI transform_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids)
308 FIXME("iface %p, streams %lu, ids %p stub!\n", iface, streams, ids);
309 return E_NOTIMPL;
312 static HRESULT WINAPI transform_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
313 IMFMediaType **type)
315 IMFMediaType *media_type;
316 const GUID *subtype;
317 HRESULT hr;
319 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type);
321 *type = NULL;
323 if (index >= ARRAY_SIZE(input_types))
324 return MF_E_NO_MORE_TYPES;
325 subtype = input_types[index];
327 if (FAILED(hr = MFCreateMediaType(&media_type)))
328 return hr;
330 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video)))
331 goto done;
332 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, subtype)))
333 goto done;
334 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1)))
335 goto done;
336 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1)))
337 goto done;
339 IMFMediaType_AddRef((*type = media_type));
341 done:
342 IMFMediaType_Release(media_type);
343 return hr;
346 static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index,
347 IMFMediaType **type)
349 IMFMediaType *media_type;
350 const GUID *subtype;
351 HRESULT hr;
353 TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type);
355 *type = NULL;
357 if (index >= ARRAY_SIZE(output_types))
358 return MF_E_NO_MORE_TYPES;
359 subtype = output_types[index];
361 if (FAILED(hr = MFCreateMediaType(&media_type)))
362 return hr;
364 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Video)))
365 goto done;
366 if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, subtype)))
367 goto done;
368 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1)))
369 goto done;
370 if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1)))
371 goto done;
373 IMFMediaType_AddRef((*type = media_type));
375 done:
376 IMFMediaType_Release(media_type);
377 return hr;
380 static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
382 struct color_convert *impl = impl_from_IMFTransform(iface);
383 MF_ATTRIBUTE_TYPE item_type;
384 GUID major, subtype;
385 HRESULT hr;
386 ULONG i;
388 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
390 if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) ||
391 FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
392 return MF_E_ATTRIBUTENOTFOUND;
394 if (!IsEqualGUID(&major, &MFMediaType_Video)
395 || FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
396 || item_type != MF_ATTRIBUTE_UINT64)
397 return E_INVALIDARG;
399 for (i = 0; i < ARRAY_SIZE(input_types); ++i)
400 if (IsEqualGUID(&subtype, input_types[i]))
401 break;
402 if (i == ARRAY_SIZE(input_types))
403 return MF_E_INVALIDMEDIATYPE;
404 if (flags & MFT_SET_TYPE_TEST_ONLY)
405 return S_OK;
407 if (!impl->input_type && FAILED(hr = MFCreateMediaType(&impl->input_type)))
408 return hr;
410 if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->input_type)))
412 IMFMediaType_Release(impl->input_type);
413 impl->input_type = NULL;
416 if (impl->output_type && FAILED(hr = try_create_wg_transform(impl)))
418 IMFMediaType_Release(impl->input_type);
419 impl->input_type = NULL;
422 return hr;
425 static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
427 struct color_convert *impl = impl_from_IMFTransform(iface);
428 MF_ATTRIBUTE_TYPE item_type;
429 GUID major, subtype;
430 HRESULT hr;
431 ULONG i;
433 TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags);
435 if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) ||
436 FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
437 return MF_E_ATTRIBUTENOTFOUND;
439 if (!IsEqualGUID(&major, &MFMediaType_Video)
440 || FAILED(IMFMediaType_GetItemType(type, &MF_MT_FRAME_SIZE, &item_type))
441 || item_type != MF_ATTRIBUTE_UINT64)
442 return E_INVALIDARG;
444 for (i = 0; i < ARRAY_SIZE(output_types); ++i)
445 if (IsEqualGUID(&subtype, output_types[i]))
446 break;
447 if (i == ARRAY_SIZE(output_types))
448 return MF_E_INVALIDMEDIATYPE;
449 if (flags & MFT_SET_TYPE_TEST_ONLY)
450 return S_OK;
452 if (!impl->output_type && FAILED(hr = MFCreateMediaType(&impl->output_type)))
453 return hr;
455 if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)impl->output_type)))
457 IMFMediaType_Release(impl->output_type);
458 impl->output_type = NULL;
461 if (impl->input_type && FAILED(hr = try_create_wg_transform(impl)))
463 IMFMediaType_Release(impl->output_type);
464 impl->output_type = NULL;
467 return hr;
470 static HRESULT WINAPI transform_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
472 struct color_convert *impl = impl_from_IMFTransform(iface);
473 HRESULT hr;
475 TRACE("iface %p, id %#lx, type %p.\n", iface, id, type);
477 if (id != 0)
478 return MF_E_INVALIDSTREAMNUMBER;
480 if (!impl->input_type)
481 return MF_E_TRANSFORM_TYPE_NOT_SET;
483 if (FAILED(hr = MFCreateMediaType(type)))
484 return hr;
486 if (FAILED(hr = IMFMediaType_CopyAllItems(impl->input_type, (IMFAttributes *)*type)))
487 IMFMediaType_Release(*type);
489 return hr;
492 static HRESULT WINAPI transform_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type)
494 struct color_convert *impl = impl_from_IMFTransform(iface);
495 HRESULT hr;
497 TRACE("iface %p, id %#lx, type %p.\n", iface, id, type);
499 if (id != 0)
500 return MF_E_INVALIDSTREAMNUMBER;
502 if (!impl->output_type)
503 return MF_E_TRANSFORM_TYPE_NOT_SET;
505 if (FAILED(hr = MFCreateMediaType(type)))
506 return hr;
508 if (FAILED(hr = IMFMediaType_CopyAllItems(impl->output_type, (IMFAttributes *)*type)))
509 IMFMediaType_Release(*type);
511 return hr;
514 static HRESULT WINAPI transform_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags)
516 FIXME("iface %p, id %#lx, flags %p stub!\n", iface, id, flags);
517 return E_NOTIMPL;
520 static HRESULT WINAPI transform_GetOutputStatus(IMFTransform *iface, DWORD *flags)
522 FIXME("iface %p, flags %p stub!\n", iface, flags);
523 return E_NOTIMPL;
526 static HRESULT WINAPI transform_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper)
528 FIXME("iface %p, lower %I64d, upper %I64d stub!\n", iface, lower, upper);
529 return E_NOTIMPL;
532 static HRESULT WINAPI transform_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event)
534 FIXME("iface %p, id %#lx, event %p stub!\n", iface, id, event);
535 return E_NOTIMPL;
538 static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param)
540 FIXME("iface %p, message %#x, param %#Ix stub!\n", iface, message, param);
541 return S_OK;
544 static HRESULT WINAPI transform_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags)
546 struct color_convert *impl = impl_from_IMFTransform(iface);
547 struct wg_sample *wg_sample;
548 MFT_INPUT_STREAM_INFO info;
549 HRESULT hr;
551 TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface, id, sample, flags);
553 if (FAILED(hr = IMFTransform_GetInputStreamInfo(iface, 0, &info)))
554 return hr;
556 if (!impl->wg_transform)
557 return MF_E_TRANSFORM_TYPE_NOT_SET;
559 if (FAILED(hr = wg_sample_create_mf(sample, &wg_sample)))
560 return hr;
562 return wg_transform_push_mf(impl->wg_transform, wg_sample,
563 impl->wg_sample_queue);
566 static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count,
567 MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status)
569 struct color_convert *impl = impl_from_IMFTransform(iface);
570 MFT_OUTPUT_STREAM_INFO info;
571 struct wg_sample *wg_sample;
572 HRESULT hr;
574 TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status);
576 if (count != 1)
577 return E_INVALIDARG;
579 if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info)))
580 return hr;
582 if (!impl->wg_transform)
583 return MF_E_TRANSFORM_TYPE_NOT_SET;
585 *status = 0;
586 samples[0].dwStatus = 0;
587 if (!samples[0].pSample) return E_INVALIDARG;
589 if (FAILED(hr = wg_sample_create_mf(samples[0].pSample, &wg_sample)))
590 return hr;
592 if (wg_sample->max_size < info.cbSize)
594 wg_sample_release(wg_sample);
595 return MF_E_BUFFERTOOSMALL;
598 if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, wg_sample, NULL,
599 &samples[0].dwStatus)))
600 wg_sample_queue_flush(impl->wg_sample_queue, false);
602 wg_sample_release(wg_sample);
604 if (hr == MF_E_TRANSFORM_STREAM_CHANGE)
606 FIXME("Unexpected stream format change!\n");
607 samples[0].dwStatus |= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE;
608 *status |= MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE;
611 return hr;
614 static const IMFTransformVtbl transform_vtbl =
616 transform_QueryInterface,
617 transform_AddRef,
618 transform_Release,
619 transform_GetStreamLimits,
620 transform_GetStreamCount,
621 transform_GetStreamIDs,
622 transform_GetInputStreamInfo,
623 transform_GetOutputStreamInfo,
624 transform_GetAttributes,
625 transform_GetInputStreamAttributes,
626 transform_GetOutputStreamAttributes,
627 transform_DeleteInputStream,
628 transform_AddInputStreams,
629 transform_GetInputAvailableType,
630 transform_GetOutputAvailableType,
631 transform_SetInputType,
632 transform_SetOutputType,
633 transform_GetInputCurrentType,
634 transform_GetOutputCurrentType,
635 transform_GetInputStatus,
636 transform_GetOutputStatus,
637 transform_SetOutputBounds,
638 transform_ProcessEvent,
639 transform_ProcessMessage,
640 transform_ProcessInput,
641 transform_ProcessOutput,
644 static inline struct color_convert *impl_from_IMediaObject(IMediaObject *iface)
646 return CONTAINING_RECORD(iface, struct color_convert, IMediaObject_iface);
649 static HRESULT WINAPI media_object_QueryInterface(IMediaObject *iface, REFIID iid, void **obj)
651 return IUnknown_QueryInterface(impl_from_IMediaObject(iface)->outer, iid, obj);
654 static ULONG WINAPI media_object_AddRef(IMediaObject *iface)
656 return IUnknown_AddRef(impl_from_IMediaObject(iface)->outer);
659 static ULONG WINAPI media_object_Release(IMediaObject *iface)
661 return IUnknown_Release(impl_from_IMediaObject(iface)->outer);
664 static HRESULT WINAPI media_object_GetStreamCount(IMediaObject *iface, DWORD *input, DWORD *output)
666 FIXME("iface %p, input %p, output %p stub!\n", iface, input, output);
667 return E_NOTIMPL;
670 static HRESULT WINAPI media_object_GetInputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags)
672 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
673 return E_NOTIMPL;
676 static HRESULT WINAPI media_object_GetOutputStreamInfo(IMediaObject *iface, DWORD index, DWORD *flags)
678 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
679 return E_NOTIMPL;
682 static HRESULT WINAPI media_object_GetInputType(IMediaObject *iface, DWORD index, DWORD type_index,
683 DMO_MEDIA_TYPE *type)
685 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface, index, type_index, type);
686 return E_NOTIMPL;
689 static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD index, DWORD type_index,
690 DMO_MEDIA_TYPE *type)
692 FIXME("iface %p, index %lu, type_index %lu, type %p stub!\n", iface, index, type_index, type);
693 return E_NOTIMPL;
696 static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index,
697 const DMO_MEDIA_TYPE *type, DWORD flags)
699 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface, index, type, flags);
700 return E_NOTIMPL;
703 static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD index,
704 const DMO_MEDIA_TYPE *type, DWORD flags)
706 FIXME("iface %p, index %lu, type %p, flags %#lx stub!\n", iface, index, type, flags);
707 return E_NOTIMPL;
710 static HRESULT WINAPI media_object_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type)
712 FIXME("iface %p, index %lu, type %p stub!\n", iface, index, type);
713 return E_NOTIMPL;
716 static HRESULT WINAPI media_object_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type)
718 FIXME("iface %p, index %lu, type %p stub!\n", iface, index, type);
719 return E_NOTIMPL;
722 static HRESULT WINAPI media_object_GetInputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size,
723 DWORD *lookahead, DWORD *alignment)
725 FIXME("iface %p, index %lu, size %p, lookahead %p, alignment %p stub!\n", iface, index, size,
726 lookahead, alignment);
727 return E_NOTIMPL;
730 static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment)
732 FIXME("iface %p, index %lu, size %p, alignment %p stub!\n", iface, index, size, alignment);
733 return E_NOTIMPL;
736 static HRESULT WINAPI media_object_GetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME *latency)
738 FIXME("iface %p, index %lu, latency %p stub!\n", iface, index, latency);
739 return E_NOTIMPL;
742 static HRESULT WINAPI media_object_SetInputMaxLatency(IMediaObject *iface, DWORD index, REFERENCE_TIME latency)
744 FIXME("iface %p, index %lu, latency %s stub!\n", iface, index, wine_dbgstr_longlong(latency));
745 return E_NOTIMPL;
748 static HRESULT WINAPI media_object_Flush(IMediaObject *iface)
750 FIXME("iface %p stub!\n", iface);
751 return E_NOTIMPL;
754 static HRESULT WINAPI media_object_Discontinuity(IMediaObject *iface, DWORD index)
756 FIXME("iface %p, index %lu stub!\n", iface, index);
757 return E_NOTIMPL;
760 static HRESULT WINAPI media_object_AllocateStreamingResources(IMediaObject *iface)
762 FIXME("iface %p stub!\n", iface);
763 return E_NOTIMPL;
766 static HRESULT WINAPI media_object_FreeStreamingResources(IMediaObject *iface)
768 FIXME("iface %p stub!\n", iface);
769 return E_NOTIMPL;
772 static HRESULT WINAPI media_object_GetInputStatus(IMediaObject *iface, DWORD index, DWORD *flags)
774 FIXME("iface %p, index %lu, flags %p stub!\n", iface, index, flags);
775 return E_NOTIMPL;
778 static HRESULT WINAPI media_object_ProcessInput(IMediaObject *iface, DWORD index,
779 IMediaBuffer *buffer, DWORD flags, REFERENCE_TIME timestamp, REFERENCE_TIME timelength)
781 FIXME("iface %p, index %lu, buffer %p, flags %#lx, timestamp %s, timelength %s stub!\n", iface,
782 index, buffer, flags, wine_dbgstr_longlong(timestamp), wine_dbgstr_longlong(timelength));
783 return E_NOTIMPL;
786 static HRESULT WINAPI media_object_ProcessOutput(IMediaObject *iface, DWORD flags, DWORD count,
787 DMO_OUTPUT_DATA_BUFFER *buffers, DWORD *status)
789 FIXME("iface %p, flags %#lx, count %lu, buffers %p, status %p stub!\n", iface, flags, count, buffers, status);
790 return E_NOTIMPL;
793 static HRESULT WINAPI media_object_Lock(IMediaObject *iface, LONG lock)
795 FIXME("iface %p, lock %ld stub!\n", iface, lock);
796 return E_NOTIMPL;
799 static const IMediaObjectVtbl media_object_vtbl =
801 media_object_QueryInterface,
802 media_object_AddRef,
803 media_object_Release,
804 media_object_GetStreamCount,
805 media_object_GetInputStreamInfo,
806 media_object_GetOutputStreamInfo,
807 media_object_GetInputType,
808 media_object_GetOutputType,
809 media_object_SetInputType,
810 media_object_SetOutputType,
811 media_object_GetInputCurrentType,
812 media_object_GetOutputCurrentType,
813 media_object_GetInputSizeInfo,
814 media_object_GetOutputSizeInfo,
815 media_object_GetInputMaxLatency,
816 media_object_SetInputMaxLatency,
817 media_object_Flush,
818 media_object_Discontinuity,
819 media_object_AllocateStreamingResources,
820 media_object_FreeStreamingResources,
821 media_object_GetInputStatus,
822 media_object_ProcessInput,
823 media_object_ProcessOutput,
824 media_object_Lock,
827 static inline struct color_convert *impl_from_IPropertyBag(IPropertyBag *iface)
829 return CONTAINING_RECORD(iface, struct color_convert, IPropertyBag_iface);
832 static HRESULT WINAPI property_bag_QueryInterface(IPropertyBag *iface, REFIID iid, void **out)
834 return IUnknown_QueryInterface(impl_from_IPropertyBag(iface)->outer, iid, out);
837 static ULONG WINAPI property_bag_AddRef(IPropertyBag *iface)
839 return IUnknown_AddRef(impl_from_IPropertyBag(iface)->outer);
842 static ULONG WINAPI property_bag_Release(IPropertyBag *iface)
844 return IUnknown_Release(impl_from_IPropertyBag(iface)->outer);
847 static HRESULT WINAPI property_bag_Read(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value,
848 IErrorLog *error_log)
850 FIXME("iface %p, prop_name %s, value %p, error_log %p stub!\n", iface, debugstr_w(prop_name), value, error_log);
851 return E_NOTIMPL;
854 static HRESULT WINAPI property_bag_Write(IPropertyBag *iface, const WCHAR *prop_name, VARIANT *value)
856 FIXME("iface %p, prop_name %s, value %p stub!\n", iface, debugstr_w(prop_name), value);
857 return S_OK;
860 static const IPropertyBagVtbl property_bag_vtbl =
862 property_bag_QueryInterface,
863 property_bag_AddRef,
864 property_bag_Release,
865 property_bag_Read,
866 property_bag_Write,
869 static inline struct color_convert *impl_from_IPropertyStore(IPropertyStore *iface)
871 return CONTAINING_RECORD(iface, struct color_convert, IPropertyStore_iface);
874 static HRESULT WINAPI property_store_QueryInterface(IPropertyStore *iface, REFIID iid, void **out)
876 return IUnknown_QueryInterface(impl_from_IPropertyStore(iface)->outer, iid, out);
879 static ULONG WINAPI property_store_AddRef(IPropertyStore *iface)
881 return IUnknown_AddRef(impl_from_IPropertyStore(iface)->outer);
884 static ULONG WINAPI property_store_Release(IPropertyStore *iface)
886 return IUnknown_Release(impl_from_IPropertyStore(iface)->outer);
889 static HRESULT WINAPI property_store_GetCount(IPropertyStore *iface, DWORD *count)
891 FIXME("iface %p, count %p stub!\n", iface, count);
892 return E_NOTIMPL;
895 static HRESULT WINAPI property_store_GetAt(IPropertyStore *iface, DWORD index, PROPERTYKEY *key)
897 FIXME("iface %p, index %lu, key %p stub!\n", iface, index, key);
898 return E_NOTIMPL;
901 static HRESULT WINAPI property_store_GetValue(IPropertyStore *iface, REFPROPERTYKEY key, PROPVARIANT *value)
903 FIXME("iface %p, key %p, value %p stub!\n", iface, key, value);
904 return E_NOTIMPL;
907 static HRESULT WINAPI property_store_SetValue(IPropertyStore *iface, REFPROPERTYKEY key, REFPROPVARIANT value)
909 FIXME("iface %p, key %p, value %p stub!\n", iface, key, value);
910 return E_NOTIMPL;
913 static HRESULT WINAPI property_store_Commit(IPropertyStore *iface)
915 FIXME("iface %p stub!\n", iface);
916 return E_NOTIMPL;
919 static const IPropertyStoreVtbl property_store_vtbl =
921 property_store_QueryInterface,
922 property_store_AddRef,
923 property_store_Release,
924 property_store_GetCount,
925 property_store_GetAt,
926 property_store_GetValue,
927 property_store_SetValue,
928 property_store_Commit,
931 HRESULT color_convert_create(IUnknown *outer, IUnknown **out)
933 static const struct wg_format input_format =
935 .major_type = WG_MAJOR_TYPE_VIDEO,
936 .u.video =
938 .format = WG_VIDEO_FORMAT_I420,
939 .width = 1920,
940 .height = 1080,
943 static const struct wg_format output_format =
945 .major_type = WG_MAJOR_TYPE_VIDEO,
946 .u.video =
948 .format = WG_VIDEO_FORMAT_NV12,
949 .width = 1920,
950 .height = 1080,
953 struct wg_transform *transform;
954 struct color_convert *impl;
955 HRESULT hr;
957 TRACE("outer %p, out %p.\n", outer, out);
959 if (!(transform = wg_transform_create(&input_format, &output_format)))
961 ERR_(winediag)("GStreamer doesn't support video conversion, please install appropriate plugins.\n");
962 return E_FAIL;
964 wg_transform_destroy(transform);
966 if (!(impl = calloc(1, sizeof(*impl))))
967 return E_OUTOFMEMORY;
969 if (FAILED(hr = wg_sample_queue_create(&impl->wg_sample_queue)))
971 free(impl);
972 return hr;
975 impl->IUnknown_inner.lpVtbl = &unknown_vtbl;
976 impl->IMFTransform_iface.lpVtbl = &transform_vtbl;
977 impl->IMediaObject_iface.lpVtbl = &media_object_vtbl;
978 impl->IPropertyBag_iface.lpVtbl = &property_bag_vtbl;
979 impl->IPropertyStore_iface.lpVtbl = &property_store_vtbl;
980 impl->refcount = 1;
981 impl->outer = outer ? outer : &impl->IUnknown_inner;
983 *out = &impl->IUnknown_inner;
984 TRACE("Created %p\n", *out);
985 return S_OK;