From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/aac_decoder.c | 18 ++++-------------- dlls/winegstreamer/color_convert.c | 18 ++++-------------- dlls/winegstreamer/gst_private.h | 2 ++ dlls/winegstreamer/main.c | 18 ++++++++++++++++++ dlls/winegstreamer/resampler.c | 18 ++++-------------- dlls/winegstreamer/video_decoder.c | 22 ++++------------------ dlls/winegstreamer/video_processor.c | 18 ++++-------------- 7 files changed, 40 insertions(+), 74 deletions(-)
diff --git a/dlls/winegstreamer/aac_decoder.c b/dlls/winegstreamer/aac_decoder.c index 5844de33ceb..8e5d76f516a 100644 --- a/dlls/winegstreamer/aac_decoder.c +++ b/dlls/winegstreamer/aac_decoder.c @@ -73,25 +73,15 @@ static struct aac_decoder *impl_from_IMFTransform(IMFTransform *iface)
static HRESULT try_create_wg_transform(struct aac_decoder *decoder) { - struct wg_format input_format, output_format; struct wg_transform_attrs attrs = {0};
if (decoder->wg_transform) + { wg_transform_destroy(decoder->wg_transform); - decoder->wg_transform = 0; - - mf_media_type_to_wg_format(decoder->input_type, &input_format); - if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - mf_media_type_to_wg_format(decoder->output_type, &output_format); - if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (!(decoder->wg_transform = wg_transform_create(&input_format, &output_format, &attrs))) - return E_FAIL; + decoder->wg_transform = 0; + }
- return S_OK; + return wg_transform_create_mf(decoder->input_type, decoder->output_type, &attrs, &decoder->wg_transform); }
static HRESULT WINAPI transform_QueryInterface(IMFTransform *iface, REFIID iid, void **out) diff --git a/dlls/winegstreamer/color_convert.c b/dlls/winegstreamer/color_convert.c index 41e5bcf3b60..b5a1261b669 100644 --- a/dlls/winegstreamer/color_convert.c +++ b/dlls/winegstreamer/color_convert.c @@ -97,25 +97,15 @@ static inline struct color_convert *impl_from_IUnknown(IUnknown *iface)
static HRESULT try_create_wg_transform(struct color_convert *impl) { - struct wg_format input_format, output_format; struct wg_transform_attrs attrs = {0};
if (impl->wg_transform) + { wg_transform_destroy(impl->wg_transform); - impl->wg_transform = 0; - - mf_media_type_to_wg_format(impl->input_type, &input_format); - if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - mf_media_type_to_wg_format(impl->output_type, &output_format); - if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format, &attrs))) - return E_FAIL; + impl->wg_transform = 0; + }
- return S_OK; + return wg_transform_create_mf(impl->input_type, impl->output_type, &attrs, &impl->wg_transform); }
static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out) diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 92805818ff4..c594ab99f3f 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -83,6 +83,8 @@ void wg_parser_stream_seek(wg_parser_stream_t stream, double rate,
wg_transform_t wg_transform_create(const struct wg_format *input_format, const struct wg_format *output_format, const struct wg_transform_attrs *attrs); +HRESULT wg_transform_create_mf(IMFMediaType *input_type, IMFMediaType *output_type, + const struct wg_transform_attrs *attrs, wg_transform_t *transform); HRESULT wg_transform_create_quartz(const AM_MEDIA_TYPE *input_format, const AM_MEDIA_TYPE *output_format, const struct wg_transform_attrs *attrs, wg_transform_t *transform); void wg_transform_destroy(wg_transform_t transform); diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index 8c5ad931e83..03f8d658fe6 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -31,6 +31,7 @@ #include "dmoreg.h" #include "gst_guids.h" #include "wmcodecdsp.h" +#include "mferror.h"
WINE_DEFAULT_DEBUG_CHANNEL(quartz); WINE_DECLARE_DEBUG_CHANNEL(mfplat); @@ -357,6 +358,23 @@ wg_transform_t wg_transform_create(const struct wg_format *input_format, return params.transform; }
+HRESULT wg_transform_create_mf(IMFMediaType *input_type, IMFMediaType *output_type, + const struct wg_transform_attrs *attrs, wg_transform_t *transform) +{ + struct wg_format input_format, output_format; + + mf_media_type_to_wg_format(input_type, &input_format); + if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + return MF_E_INVALIDMEDIATYPE; + mf_media_type_to_wg_format(output_type, &output_format); + if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + return MF_E_INVALIDMEDIATYPE; + + if (!(*transform = wg_transform_create(&input_format, &output_format, attrs))) + return E_FAIL; + return S_OK; +} + HRESULT wg_transform_create_quartz(const AM_MEDIA_TYPE *input_type, const AM_MEDIA_TYPE *output_type, const struct wg_transform_attrs *attrs, wg_transform_t *transform) { diff --git a/dlls/winegstreamer/resampler.c b/dlls/winegstreamer/resampler.c index b5b62d58800..12da0d35c8e 100644 --- a/dlls/winegstreamer/resampler.c +++ b/dlls/winegstreamer/resampler.c @@ -56,25 +56,15 @@ struct resampler
static HRESULT try_create_wg_transform(struct resampler *impl) { - struct wg_format input_format, output_format; struct wg_transform_attrs attrs = {0};
if (impl->wg_transform) + { wg_transform_destroy(impl->wg_transform); - impl->wg_transform = 0; - - mf_media_type_to_wg_format(impl->input_type, &input_format); - if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - mf_media_type_to_wg_format(impl->output_type, &output_format); - if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format, &attrs))) - return E_FAIL; + impl->wg_transform = 0; + }
- return S_OK; + return wg_transform_create_mf(impl->input_type, impl->output_type, &attrs, &impl->wg_transform); }
static inline struct resampler *impl_from_IUnknown(IUnknown *iface) diff --git a/dlls/winegstreamer/video_decoder.c b/dlls/winegstreamer/video_decoder.c index 5b5d0ec6d97..d0ce9b407a8 100644 --- a/dlls/winegstreamer/video_decoder.c +++ b/dlls/winegstreamer/video_decoder.c @@ -245,32 +245,18 @@ static HRESULT try_create_wg_transform(struct video_decoder *decoder) * transform to be able to queue its input buffers. We need to use a buffer list * to match its expectations. */ - struct wg_format input_format; - struct wg_format output_format; UINT32 low_latency;
if (decoder->wg_transform) + { wg_transform_destroy(decoder->wg_transform); - decoder->wg_transform = 0; - - mf_media_type_to_wg_format(decoder->input_type, &input_format); - if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - mf_media_type_to_wg_format(decoder->output_type, &output_format); - if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; + decoder->wg_transform = 0; + }
if (SUCCEEDED(IMFAttributes_GetUINT32(decoder->attributes, &MF_LOW_LATENCY, &low_latency))) decoder->wg_transform_attrs.low_latency = !!low_latency;
- if (!(decoder->wg_transform = wg_transform_create(&input_format, &output_format, &decoder->wg_transform_attrs))) - { - ERR("Failed to create transform with input major_type %u.\n", input_format.major_type); - return E_FAIL; - } - - return S_OK; + return wg_transform_create_mf(decoder->input_type, decoder->output_type, &decoder->wg_transform_attrs, &decoder->wg_transform); }
static HRESULT create_output_media_type(struct video_decoder *decoder, const GUID *subtype, diff --git a/dlls/winegstreamer/video_processor.c b/dlls/winegstreamer/video_processor.c index cce077ae63b..6f0e5bdae11 100644 --- a/dlls/winegstreamer/video_processor.c +++ b/dlls/winegstreamer/video_processor.c @@ -87,25 +87,15 @@ struct video_processor
static HRESULT try_create_wg_transform(struct video_processor *impl) { - struct wg_format input_format, output_format; struct wg_transform_attrs attrs = {0};
if (impl->wg_transform) + { wg_transform_destroy(impl->wg_transform); - impl->wg_transform = 0; - - mf_media_type_to_wg_format(impl->input_type, &input_format); - if (input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - mf_media_type_to_wg_format(impl->output_type, &output_format); - if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (!(impl->wg_transform = wg_transform_create(&input_format, &output_format, &attrs))) - return E_FAIL; + impl->wg_transform = 0; + }
- return S_OK; + return wg_transform_create_mf(impl->input_type, impl->output_type, &attrs, &impl->wg_transform); }
static struct video_processor *impl_from_IMFTransform(IMFTransform *iface)