Commit 98d20975 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Initialize media source video types from a wg_video_format array.

The mf_media_type_from_wg_format function will use the video format to calculate stride.
parent 93c5adbf
...@@ -866,15 +866,15 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) ...@@ -866,15 +866,15 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
if (format.major_type == WG_MAJOR_TYPE_VIDEO) if (format.major_type == WG_MAJOR_TYPE_VIDEO)
{ {
/* These are the most common native output types of decoders: /* Try to prefer YUV formats over RGB ones. Most decoders output in the
https://docs.microsoft.com/en-us/windows/win32/medfound/mft-decoder-expose-output-types-in-native-order */ * YUV color space, and it's generally much less expensive for
static const GUID *const video_types[] = * videoconvert to do YUV -> YUV transformations. */
static const enum wg_video_format video_formats[] =
{ {
&MFVideoFormat_NV12, WG_VIDEO_FORMAT_NV12,
&MFVideoFormat_YV12, WG_VIDEO_FORMAT_YV12,
&MFVideoFormat_YUY2, WG_VIDEO_FORMAT_YUY2,
&MFVideoFormat_IYUV, WG_VIDEO_FORMAT_I420,
&MFVideoFormat_I420,
}; };
IMFMediaType *base_type = mf_media_type_from_wg_format(&format); IMFMediaType *base_type = mf_media_type_from_wg_format(&format);
...@@ -891,21 +891,32 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) ...@@ -891,21 +891,32 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
stream_types[0] = base_type; stream_types[0] = base_type;
type_count = 1; type_count = 1;
for (i = 0; i < ARRAY_SIZE(video_types); i++) for (i = 0; i < ARRAY_SIZE(video_formats); ++i)
{ {
struct wg_format new_format = format;
IMFMediaType *new_type; IMFMediaType *new_type;
if (IsEqualGUID(&base_subtype, video_types[i])) new_format.u.video.format = video_formats[i];
continue;
if (FAILED(hr = MFCreateMediaType(&new_type))) if (!(new_type = mf_media_type_from_wg_format(&new_format)))
{
hr = E_OUTOFMEMORY;
goto done; goto done;
}
stream_types[type_count++] = new_type; stream_types[type_count++] = new_type;
if (FAILED(hr = IMFMediaType_CopyAllItems(base_type, (IMFAttributes *) new_type))) if (video_formats[i] == WG_VIDEO_FORMAT_I420)
goto done; {
if (FAILED(hr = IMFMediaType_SetGUID(new_type, &MF_MT_SUBTYPE, video_types[i]))) IMFMediaType *iyuv_type;
goto done;
if (FAILED(hr = MFCreateMediaType(&iyuv_type)))
goto done;
if (FAILED(hr = IMFMediaType_CopyAllItems(iyuv_type, (IMFAttributes *)iyuv_type)))
goto done;
if (FAILED(hr = IMFMediaType_SetGUID(iyuv_type, &MF_MT_SUBTYPE, &MFVideoFormat_IYUV)))
goto done;
stream_types[type_count++] = iyuv_type;
}
} }
} }
else if (format.major_type == WG_MAJOR_TYPE_AUDIO) else if (format.major_type == WG_MAJOR_TYPE_AUDIO)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment