Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/gst_private.h | 2 + dlls/winegstreamer/wm_reader.c | 62 ++++++++++++++++++++++++++++++ dlls/winegstreamer/wm_syncreader.c | 12 +++--- dlls/wmvcore/tests/wmvcore.c | 2 +- 4 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index db715a9ad70..da36d53abff 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -153,6 +153,8 @@ struct wm_reader_ops
void wm_reader_cleanup(struct wm_reader *reader); HRESULT wm_reader_close(struct wm_reader *reader); +HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output, + DWORD index, IWMOutputMediaProps **props); HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output, IWMOutputMediaProps **props); void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops); diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index cd08bc96869..f6820121bf0 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1290,6 +1290,68 @@ HRESULT wm_reader_get_output_props(struct wm_reader *reader, DWORD output, IWMOu return *props ? S_OK : E_OUTOFMEMORY; }
+static const enum wg_video_format video_formats[] = +{ + /* Try to prefer YUV formats over RGB ones. Most decoders output in the + * YUV color space, and it's generally much less expensive for + * videoconvert to do YUV -> YUV transformations. */ + WG_VIDEO_FORMAT_NV12, + WG_VIDEO_FORMAT_YV12, + WG_VIDEO_FORMAT_YUY2, + WG_VIDEO_FORMAT_UYVY, + WG_VIDEO_FORMAT_YVYU, + WG_VIDEO_FORMAT_BGRx, + WG_VIDEO_FORMAT_BGR, + WG_VIDEO_FORMAT_RGB16, + WG_VIDEO_FORMAT_RGB15, +}; + +HRESULT wm_reader_get_output_format(struct wm_reader *reader, DWORD output, + DWORD index, IWMOutputMediaProps **props) +{ + struct wm_stream *stream; + struct wg_format format; + + EnterCriticalSection(&reader->cs); + + if (!(stream = get_stream_by_output_number(reader, output))) + { + LeaveCriticalSection(&reader->cs); + return E_INVALIDARG; + } + + wg_parser_stream_get_preferred_format(stream->wg_stream, &format); + + switch (format.major_type) + { + case WG_MAJOR_TYPE_VIDEO: + if (index >= ARRAY_SIZE(video_formats)) + { + LeaveCriticalSection(&reader->cs); + return NS_E_INVALID_OUTPUT_FORMAT; + } + format.u.video.format = video_formats[index]; + break; + + case WG_MAJOR_TYPE_AUDIO: + if (index) + { + LeaveCriticalSection(&reader->cs); + return NS_E_INVALID_OUTPUT_FORMAT; + } + format.u.audio.format = WG_AUDIO_FORMAT_S16LE; + break; + + case WG_MAJOR_TYPE_UNKNOWN: + break; + } + + LeaveCriticalSection(&reader->cs); + + *props = output_props_create(&format); + return *props ? S_OK : E_OUTOFMEMORY; +} + void wm_reader_init(struct wm_reader *reader, const struct wm_reader_ops *ops) { reader->IWMHeaderInfo3_iface.lpVtbl = &header_info_vtbl; diff --git a/dlls/winegstreamer/wm_syncreader.c b/dlls/winegstreamer/wm_syncreader.c index c89fb782a11..7becd88b63e 100644 --- a/dlls/winegstreamer/wm_syncreader.c +++ b/dlls/winegstreamer/wm_syncreader.c @@ -97,12 +97,14 @@ static HRESULT WINAPI WMSyncReader_GetOutputCount(IWMSyncReader2 *iface, DWORD * return S_OK; }
-static HRESULT WINAPI WMSyncReader_GetOutputFormat(IWMSyncReader2 *iface, DWORD output_num, DWORD format_num, - IWMOutputMediaProps **props) +static HRESULT WINAPI WMSyncReader_GetOutputFormat(IWMSyncReader2 *iface, + DWORD output, DWORD index, IWMOutputMediaProps **props) { - struct sync_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%u %u %p): stub!\n", This, output_num, format_num, props); - return E_NOTIMPL; + struct sync_reader *reader = impl_from_IWMSyncReader2(iface); + + TRACE("reader %p, output %u, index %u, props %p.\n", reader, output, index, props); + + return wm_reader_get_output_format(&reader->reader, output, index, props); }
static HRESULT WINAPI WMSyncReader_GetOutputFormatCount(IWMSyncReader2 *iface, DWORD output_num, DWORD *formats) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 6fc74b62dba..5c1a47b65d1 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -856,7 +856,7 @@ static void test_sync_reader_types(void)
output_props = (void *)0xdeadbeef; hr = IWMSyncReader_GetOutputFormat(reader, 2, 0, &output_props); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); ok(output_props == (void *)0xdeadbeef, "Got output props %p.\n", output_props);
IWMProfile_Release(profile);