winegstreamer: Introduce a new check_video_transform_support helper.

This commit is contained in:
Rémi Bernon 2024-04-30 17:51:49 +02:00 committed by Alexandre Julliard
parent cc82780c22
commit 067d4f0472
5 changed files with 68 additions and 73 deletions

View file

@ -907,39 +907,28 @@ static const IPropertyStoreVtbl property_store_vtbl =
HRESULT color_convert_create(IUnknown *outer, IUnknown **out)
{
static const struct wg_format input_format =
const MFVIDEOFORMAT input_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_I420,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_I420,
};
static const struct wg_format output_format =
const MFVIDEOFORMAT output_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_NV12,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_NV12,
};
struct wg_transform_attrs attrs = {0};
wg_transform_t transform;
struct color_convert *impl;
HRESULT hr;
TRACE("outer %p, out %p.\n", outer, out);
if (!(transform = wg_transform_create(&input_format, &output_format, &attrs)))
if (FAILED(hr = check_video_transform_support(&input_format, &output_format)))
{
ERR_(winediag)("GStreamer doesn't support video conversion, please install appropriate plugins.\n");
return E_FAIL;
return hr;
}
wg_transform_destroy(transform);
if (!(impl = calloc(1, sizeof(*impl))))
return E_OUTOFMEMORY;

View file

@ -96,6 +96,7 @@ void wg_transform_notify_qos(wg_transform_t transform,
bool underflow, double proportion, int64_t diff, uint64_t timestamp);
HRESULT check_audio_transform_support(const WAVEFORMATEX *input, const WAVEFORMATEX *output);
HRESULT check_video_transform_support(const MFVIDEOFORMAT *input, const MFVIDEOFORMAT *output);
HRESULT wg_muxer_create(const char *format, wg_muxer_t *muxer);
void wg_muxer_destroy(wg_muxer_t muxer);

View file

@ -661,6 +661,31 @@ HRESULT check_audio_transform_support(const WAVEFORMATEX *input, const WAVEFORMA
return hr;
}
HRESULT check_video_transform_support(const MFVIDEOFORMAT *input, const MFVIDEOFORMAT *output)
{
IMFMediaType *input_type, *output_type;
struct wg_transform_attrs attrs = {0};
wg_transform_t transform;
HRESULT hr;
if (FAILED(hr = MFCreateMediaType(&input_type)))
return hr;
if (FAILED(hr = MFCreateMediaType(&output_type)))
{
IMFMediaType_Release(input_type);
return hr;
}
if (SUCCEEDED(hr = MFInitMediaTypeFromMFVideoFormat(input_type, input, input->dwSize))
&& SUCCEEDED(hr = MFInitMediaTypeFromMFVideoFormat(output_type, output, output->dwSize))
&& SUCCEEDED(hr = wg_transform_create_mf(input_type, output_type, &attrs, &transform)))
wg_transform_destroy(transform);
IMFMediaType_Release(output_type);
IMFMediaType_Release(input_type);
return hr;
}
#define ALIGN(n, alignment) (((n) + (alignment) - 1) & ~((alignment) - 1))
unsigned int wg_format_get_stride(const struct wg_format *format)

View file

@ -1530,30 +1530,27 @@ static const GUID *const h264_decoder_input_types[] =
HRESULT h264_decoder_create(REFIID riid, void **out)
{
static const struct wg_format output_format =
const MFVIDEOFORMAT output_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_I420,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_I420,
};
const MFVIDEOFORMAT input_format =
{
.dwSize = sizeof(MFVIDEOFORMAT),
.guidFormat = MFVideoFormat_H264,
};
static const struct wg_format input_format = {.major_type = WG_MAJOR_TYPE_VIDEO_H264};
struct wg_transform_attrs attrs = {0};
struct video_decoder *decoder;
wg_transform_t transform;
HRESULT hr;
TRACE("riid %s, out %p.\n", debugstr_guid(riid), out);
if (!(transform = wg_transform_create(&input_format, &output_format, &attrs)))
if (FAILED(hr = check_video_transform_support(&input_format, &output_format)))
{
ERR_(winediag)("GStreamer doesn't support H.264 decoding, please install appropriate plugins\n");
return E_FAIL;
return hr;
}
wg_transform_destroy(transform);
if (FAILED(hr = video_decoder_create_with_types(h264_decoder_input_types, ARRAY_SIZE(h264_decoder_input_types),
video_decoder_output_types, ARRAY_SIZE(video_decoder_output_types), NULL, &decoder)))
@ -1652,34 +1649,28 @@ static const GUID *const wmv_decoder_output_types[] =
HRESULT wmv_decoder_create(IUnknown *outer, IUnknown **out)
{
static const struct wg_format input_format =
const MFVIDEOFORMAT output_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO_WMV,
.u.video.format = WG_VIDEO_FORMAT_WMV3,
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_I420,
};
static const struct wg_format output_format =
const MFVIDEOFORMAT input_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_NV12,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_WMV3,
};
struct wg_transform_attrs attrs = {0};
struct video_decoder *decoder;
wg_transform_t transform;
HRESULT hr;
TRACE("outer %p, out %p.\n", outer, out);
if (!(transform = wg_transform_create(&input_format, &output_format, &attrs)))
if (FAILED(hr = check_video_transform_support(&input_format, &output_format)))
{
ERR_(winediag)("GStreamer doesn't support WMV decoding, please install appropriate plugins.\n");
return E_FAIL;
ERR_(winediag)("GStreamer doesn't support WMV decoding, please install appropriate plugins\n");
return hr;
}
wg_transform_destroy(transform);
if (FAILED(hr = video_decoder_create_with_types(wmv_decoder_input_types, ARRAY_SIZE(wmv_decoder_input_types),
wmv_decoder_output_types, ARRAY_SIZE(wmv_decoder_output_types), outer, &decoder)))

View file

@ -700,39 +700,28 @@ static const IMFTransformVtbl video_processor_vtbl =
HRESULT video_processor_create(REFIID riid, void **ret)
{
static const struct wg_format input_format =
const MFVIDEOFORMAT input_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_I420,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_I420,
};
static const struct wg_format output_format =
const MFVIDEOFORMAT output_format =
{
.major_type = WG_MAJOR_TYPE_VIDEO,
.u.video =
{
.format = WG_VIDEO_FORMAT_NV12,
.width = 1920,
.height = 1080,
},
.dwSize = sizeof(MFVIDEOFORMAT),
.videoInfo = {.dwWidth = 1920, .dwHeight = 1080},
.guidFormat = MFVideoFormat_NV12,
};
struct wg_transform_attrs attrs = {0};
wg_transform_t transform;
struct video_processor *impl;
HRESULT hr;
TRACE("riid %s, ret %p.\n", debugstr_guid(riid), ret);
if (!(transform = wg_transform_create(&input_format, &output_format, &attrs)))
if (FAILED(hr = check_video_transform_support(&input_format, &output_format)))
{
ERR_(winediag)("GStreamer doesn't support video conversion, please install appropriate plugins.\n");
return E_FAIL;
return hr;
}
wg_transform_destroy(transform);
if (!(impl = calloc(1, sizeof(*impl))))
return E_OUTOFMEMORY;