winegstreamer: Implement IWMSyncReader::GetOutputFormat().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
95ffc87988
commit
b3655b5be5
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue