From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winegstreamer/gst_private.h | 2 + dlls/winegstreamer/main.c | 15 +++ dlls/winegstreamer/quartz_parser.c | 5 - dlls/winegstreamer/quartz_transform.c | 13 +-- dlls/winegstreamer/wma_decoder.c | 151 ++++++++++++-------------- dlls/winegstreamer/wmv_decoder.c | 82 ++++++++------ 6 files changed, 140 insertions(+), 128 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 4bdef90e045..92805818ff4 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_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); bool wg_transform_set_output_format(wg_transform_t transform, struct wg_format *format); bool wg_transform_get_status(wg_transform_t transform, bool *accepts_input); diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c index 4d38a2bf66c..0c3768e7538 100644 --- a/dlls/winegstreamer/main.c +++ b/dlls/winegstreamer/main.c @@ -357,6 +357,21 @@ wg_transform_t wg_transform_create(const struct wg_format *input_format, return params.transform; }
+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) +{ + struct wg_format input_format, output_format; + + TRACE("input_type %p, output_type %p.\n", input_type, output_type); + + amt_to_wg_format(input_type, &input_format); + amt_to_wg_format(output_type, &output_format); + if (!(*transform = wg_transform_create(&input_format, &output_format, attrs))) + return E_FAIL; + + return S_OK; +} + void wg_transform_destroy(wg_transform_t transform) { TRACE("transform %#I64x.\n", transform); diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index 32eb6e1a4a0..e09cad7ec22 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -873,11 +873,6 @@ static bool amt_to_wg_format_audio_wma(const AM_MEDIA_TYPE *mt, struct wg_format FIXME("Unknown format type %s.\n", debugstr_guid(&mt->formattype)); return false; } - if (mt->cbFormat < sizeof(*audio_format) || !mt->pbFormat) - { - ERR("Unexpected format size %lu.\n", mt->cbFormat); - return false; - }
if (IsEqualGUID(&mt->subtype, &MEDIASUBTYPE_MSAUDIO1)) format->u.audio.version = 1; diff --git a/dlls/winegstreamer/quartz_transform.c b/dlls/winegstreamer/quartz_transform.c index ad0c3077733..b85b24f4278 100644 --- a/dlls/winegstreamer/quartz_transform.c +++ b/dlls/winegstreamer/quartz_transform.c @@ -98,26 +98,19 @@ static HRESULT transform_query_interface(struct strmbase_filter *iface, REFIID i static HRESULT transform_init_stream(struct strmbase_filter *iface) { struct transform *filter = impl_from_strmbase_filter(iface); - struct wg_format input_format, output_format; struct wg_transform_attrs attrs = {0}; HRESULT hr;
if (filter->source.pin.peer) { - if (!amt_to_wg_format(&filter->sink.pin.mt, &input_format)) - return E_FAIL; - - if (!amt_to_wg_format(&filter->source.pin.mt, &output_format)) - return E_FAIL; - if (FAILED(hr = wg_sample_queue_create(&filter->sample_queue))) return hr;
- filter->transform = wg_transform_create(&input_format, &output_format, &attrs); - if (!filter->transform) + if (FAILED(hr = wg_transform_create_quartz(&filter->sink.pin.mt, &filter->source.pin.mt, + &attrs, &filter->transform))) { wg_sample_queue_destroy(filter->sample_queue); - return E_FAIL; + return hr; }
hr = IMemAllocator_Commit(filter->source.pAllocator); diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index ee128dd7905..e08aff5923d 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -53,8 +53,8 @@ struct wma_decoder IUnknown *outer; LONG refcount;
- struct wg_format input_format; - struct wg_format output_format; + DMO_MEDIA_TYPE input_type; + DMO_MEDIA_TYPE output_type;
DWORD input_buf_size; DWORD output_buf_size; @@ -73,19 +73,13 @@ static HRESULT try_create_wg_transform(struct wma_decoder *decoder) struct wg_transform_attrs attrs = {0};
if (decoder->wg_transform) + { wg_transform_destroy(decoder->wg_transform); - decoder->wg_transform = 0; - - if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (decoder->output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) - return MF_E_INVALIDMEDIATYPE; - - if (!(decoder->wg_transform = wg_transform_create(&decoder->input_format, &decoder->output_format, &attrs))) - return E_FAIL; + decoder->wg_transform = 0; + }
- return S_OK; + return wg_transform_create_quartz(&decoder->input_type, &decoder->output_type, + &attrs, &decoder->wg_transform); }
static HRESULT WINAPI unknown_QueryInterface(IUnknown *iface, REFIID iid, void **out) @@ -202,8 +196,8 @@ static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id
TRACE("iface %p, id %lu, info %p.\n", iface, id, info);
- if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN - || decoder->output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL) + || IsEqualGUID(&decoder->output_type.majortype, &GUID_NULL)) { memset(info, 0, sizeof(*info)); return MF_E_TRANSFORM_TYPE_NOT_SET; @@ -223,8 +217,8 @@ static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD i
TRACE("iface %p, id %lu, info %p.\n", iface, id, info);
- if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN - || decoder->output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL) + || IsEqualGUID(&decoder->output_type.majortype, &GUID_NULL)) { memset(info, 0, sizeof(*info)); return MF_E_TRANSFORM_TYPE_NOT_SET; @@ -280,11 +274,12 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR struct wma_decoder *decoder = impl_from_IMFTransform(iface); IMFMediaType *media_type; const GUID *output_type; + WAVEFORMATEX *wfx; HRESULT hr;
TRACE("iface %p, id %lu, index %lu, type %p.\n", iface, id, index, type);
- if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return MF_E_TRANSFORM_TYPE_NOT_SET;
*type = NULL; @@ -316,20 +311,16 @@ static HRESULT WINAPI transform_GetOutputAvailableType(IMFTransform *iface, DWOR sample_size))) goto done;
- if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, - decoder->input_format.u.audio.channels))) + wfx = (WAVEFORMATEX *)decoder->input_type.pbFormat; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, wfx->nChannels))) goto done; - - if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, - decoder->input_format.u.audio.rate))) + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, wfx->nSamplesPerSec))) goto done;
- block_alignment = sample_size * decoder->input_format.u.audio.channels / 8; - if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, - block_alignment))) + block_alignment = sample_size * wfx->nChannels / 8; + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, block_alignment))) goto done; - if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, - decoder->input_format.u.audio.rate * block_alignment))) + if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, wfx->nSamplesPerSec * block_alignment))) goto done;
if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1))) @@ -385,9 +376,13 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM if (flags & MFT_SET_TYPE_TEST_ONLY) return S_OK;
- mf_media_type_to_wg_format(type, &decoder->input_format); - decoder->input_buf_size = block_alignment; - decoder->output_format.major_type = WG_MAJOR_TYPE_UNKNOWN; + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type)); + FreeMediaType(&decoder->input_type); + memset(&decoder->input_type, 0, sizeof(decoder->input_type)); + + if (SUCCEEDED(hr = MFInitAMMediaTypeFromMFMediaType(type, GUID_NULL, &decoder->input_type))) + decoder->input_buf_size = block_alignment;
return hr; } @@ -403,7 +398,7 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF
TRACE("iface %p, id %lu, type %p, flags %#lx.\n", iface, id, type, flags);
- if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return MF_E_TRANSFORM_TYPE_NOT_SET;
if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || @@ -446,10 +441,15 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF if (flags & MFT_SET_TYPE_TEST_ONLY) return S_OK;
- decoder->input_format.u.audio.depth = sample_size; + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type));
- mf_media_type_to_wg_format(type, &decoder->output_format); - decoder->output_buf_size = 1024 * block_alignment * channel_count; + if (SUCCEEDED(hr = MFInitAMMediaTypeFromMFMediaType(type, GUID_NULL, &decoder->output_type))) + { + WAVEFORMATEX *wfx = (WAVEFORMATEX *)decoder->input_type.pbFormat; + wfx->wBitsPerSample = sample_size; + decoder->output_buf_size = 1024 * block_alignment * channel_count; + }
if (FAILED(hr = try_create_wg_transform(decoder))) goto failed; @@ -457,7 +457,8 @@ static HRESULT WINAPI transform_SetOutputType(IMFTransform *iface, DWORD id, IMF return S_OK;
failed: - decoder->output_format.major_type = WG_MAJOR_TYPE_UNKNOWN; + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type)); return hr; }
@@ -656,7 +657,9 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde DMO_MEDIA_TYPE *type) { struct wma_decoder *decoder = impl_from_IMediaObject(iface); - WAVEFORMATEX *wfx; + IMFMediaType *media_type; + UINT32 depth; + HRESULT hr;
TRACE("iface %p, index %lu, type_index %lu, type %p\n", iface, index, type_index, type);
@@ -664,42 +667,34 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde return DMO_E_INVALIDSTREAMINDEX; if (type_index >= 1) return DMO_E_NO_MORE_ITEMS; - if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET; if (!type) return S_OK;
- memset(type, 0, sizeof(*type)); - type->majortype = MFMediaType_Audio; - type->subtype = MEDIASUBTYPE_PCM; - type->formattype = FORMAT_WaveFormatEx; - type->bFixedSizeSamples = FALSE; - type->bTemporalCompression = TRUE; - type->lSampleSize = 0; - - type->cbFormat = sizeof(WAVEFORMATEX); - type->pbFormat = CoTaskMemAlloc(type->cbFormat); - memset(type->pbFormat, 0, type->cbFormat); + if (FAILED(hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, + &decoder->input_type, &media_type))) + return hr;
- wfx = (WAVEFORMATEX *)type->pbFormat; - if (decoder->input_format.u.audio.depth == 32) - wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + if (SUCCEEDED(IMFMediaType_GetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &depth)) + && depth == 32) + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_Float); else - wfx->wFormatTag = WAVE_FORMAT_PCM; - wfx->nChannels = decoder->input_format.u.audio.channels; - wfx->nSamplesPerSec = decoder->input_format.u.audio.rate; - wfx->wBitsPerSample = decoder->input_format.u.audio.depth; - wfx->nAvgBytesPerSec = wfx->nChannels * wfx->nSamplesPerSec * wfx->wBitsPerSample / 8; - wfx->nBlockAlign = wfx->nChannels * wfx->wBitsPerSample / 8; + hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
- return S_OK; + if (SUCCEEDED(hr)) + hr = IMFMediaType_DeleteItem(media_type, &MF_MT_USER_DATA); + if (SUCCEEDED(hr)) + hr = MFInitAMMediaTypeFromMFMediaType(media_type, GUID_NULL, type); + + IMFMediaType_Release(media_type); + return hr; }
static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { struct wma_decoder *decoder = impl_from_IMediaObject(iface); - struct wg_format wg_format; unsigned int i;
TRACE("iface %p, index %lu, type %p, flags %#lx.\n", iface, index, type, flags); @@ -711,7 +706,8 @@ static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index { if (flags != DMO_SET_TYPEF_CLEAR) return E_INVALIDARG; - memset(&decoder->input_format, 0, sizeof(decoder->input_format)); + FreeMediaType(&decoder->input_type); + memset(&decoder->input_type, 0, sizeof(decoder->input_type)); if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -733,14 +729,13 @@ static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index if (i == ARRAY_SIZE(wma_decoder_input_types)) return DMO_E_TYPE_NOT_ACCEPTED;
- if (!amt_to_wg_format((const AM_MEDIA_TYPE *)type, &wg_format)) - return DMO_E_TYPE_NOT_ACCEPTED; - assert(wg_format.major_type == WG_MAJOR_TYPE_AUDIO_WMA); - if (flags & DMO_SET_TYPEF_TEST_ONLY) return S_OK;
- decoder->input_format = wg_format; + FreeMediaType(&decoder->input_type); + memset(&decoder->input_type, 0, sizeof(decoder->input_type)); + CopyMediaType(&decoder->input_type, type); + if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -755,8 +750,8 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde { struct wma_decoder *decoder = impl_from_IMediaObject(iface); struct wg_transform_attrs attrs = {0}; - struct wg_format wg_format; unsigned int i; + HRESULT hr;
TRACE("iface %p, index %lu, type %p, flags %#lx,\n", iface, index, type, flags);
@@ -767,7 +762,8 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde { if (flags != DMO_SET_TYPEF_CLEAR) return E_INVALIDARG; - memset(&decoder->output_format, 0, sizeof(decoder->output_format)); + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type)); if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -789,18 +785,14 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde if (i == ARRAY_SIZE(wma_decoder_output_types)) return DMO_E_TYPE_NOT_ACCEPTED;
- - if (!amt_to_wg_format((const AM_MEDIA_TYPE *)type, &wg_format)) - return DMO_E_TYPE_NOT_ACCEPTED; - assert(wg_format.major_type == WG_MAJOR_TYPE_AUDIO); - - if (decoder->input_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET; - if (flags & DMO_SET_TYPEF_TEST_ONLY) return S_OK;
- decoder->output_format = wg_format; + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type)); + CopyMediaType(&decoder->output_type, type);
/* Set up wg_transform. */ if (decoder->wg_transform) @@ -808,8 +800,9 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde wg_transform_destroy(decoder->wg_transform); decoder->wg_transform = 0; } - if (!(decoder->wg_transform = wg_transform_create(&decoder->input_format, &decoder->output_format, &attrs))) - return E_FAIL; + if (FAILED(hr = wg_transform_create_quartz(&decoder->input_type, &decoder->output_type, + &attrs, &decoder->wg_transform))) + return hr;
return S_OK; } @@ -844,7 +837,7 @@ static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD return E_POINTER; if (index > 0) return DMO_E_INVALIDSTREAMINDEX; - if (decoder->output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) + if (IsEqualGUID(&decoder->output_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET;
*size = 8192; diff --git a/dlls/winegstreamer/wmv_decoder.c b/dlls/winegstreamer/wmv_decoder.c index ea8b4b19eb6..e63448427b8 100644 --- a/dlls/winegstreamer/wmv_decoder.c +++ b/dlls/winegstreamer/wmv_decoder.c @@ -81,19 +81,13 @@ struct wmv_decoder IUnknown *outer; LONG refcount;
- struct wg_format input_format; - struct wg_format output_format; - GUID output_subtype; + DMO_MEDIA_TYPE input_type; + DMO_MEDIA_TYPE output_type;
wg_transform_t wg_transform; struct wg_sample_queue *wg_sample_queue; };
-static bool wg_format_is_set(struct wg_format *format) -{ - return format->major_type != WG_MAJOR_TYPE_UNKNOWN; -} - static inline struct wmv_decoder *impl_from_IUnknown(IUnknown *iface) { return CONTAINING_RECORD(iface, struct wmv_decoder, IUnknown_inner); @@ -428,6 +422,8 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde DMO_MEDIA_TYPE *type) { struct wmv_decoder *decoder = impl_from_IMediaObject(iface); + UINT64 frame_size, frame_rate; + IMFMediaType *media_type; VIDEOINFOHEADER *info; const GUID *subtype; LONG width, height; @@ -442,15 +438,25 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde return DMO_E_NO_MORE_ITEMS; if (!type) return S_OK; - if (!wg_format_is_set(&decoder->input_format)) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET;
- width = decoder->input_format.u.video.width; - height = abs(decoder->input_format.u.video.height); + if (FAILED(hr = MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, + &decoder->input_type, &media_type))) + return hr; + + if (FAILED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_SIZE, &frame_size))) + frame_size = 0; + if (FAILED(IMFMediaType_GetUINT64(media_type, &MF_MT_FRAME_RATE, &frame_rate))) + frame_rate = 0; + + width = frame_size >> 32; + height = (UINT32)frame_size; subtype = wmv_decoder_output_types[type_index].subtype; if (FAILED(hr = MFCalculateImageSize(subtype, width, height, &image_size))) { FIXME("Failed to get image size of subtype %s.\n", debugstr_guid(subtype)); + IMFMediaType_Release(media_type); return hr; }
@@ -470,8 +476,8 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde info->rcSource.bottom = height; info->rcTarget.right = width; info->rcTarget.bottom = height; - info->AvgTimePerFrame = MulDiv(10000000, decoder->input_format.u.video.fps_d, - decoder->input_format.u.video.fps_n); + if (frame_rate) + MFFrameRateToAverageTimePerFrame(frame_rate >> 32, frame_rate, (UINT64 *)&info->AvgTimePerFrame); info->bmiHeader.biSize = sizeof(info->bmiHeader); info->bmiHeader.biWidth = width; info->bmiHeader.biHeight = height; @@ -480,6 +486,7 @@ static HRESULT WINAPI media_object_GetOutputType(IMediaObject *iface, DWORD inde info->bmiHeader.biCompression = wmv_decoder_output_types[type_index].compression; info->bmiHeader.biSizeImage = image_size;
+ IMFMediaType_Release(media_type); return S_OK; }
@@ -487,7 +494,7 @@ static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index const DMO_MEDIA_TYPE *type, DWORD flags) { struct wmv_decoder *decoder = impl_from_IMediaObject(iface); - struct wg_format wg_format; + IMFMediaType *media_type; unsigned int i;
TRACE("iface %p, index %lu, type %p, flags %#lx.\n", iface, index, type, flags); @@ -499,7 +506,8 @@ static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index { if (flags & DMO_SET_TYPEF_CLEAR) { - memset(&decoder->input_format, 0, sizeof(decoder->input_format)); + FreeMediaType(&decoder->input_type); + memset(&decoder->input_type, 0, sizeof(decoder->input_type)); if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -519,14 +527,16 @@ static HRESULT WINAPI media_object_SetInputType(IMediaObject *iface, DWORD index if (i == ARRAY_SIZE(wmv_decoder_input_types)) return DMO_E_TYPE_NOT_ACCEPTED;
- if (!amt_to_wg_format((const AM_MEDIA_TYPE *)type, &wg_format)) + if (FAILED(MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, + (void *)type, &media_type))) return DMO_E_TYPE_NOT_ACCEPTED; - assert(wg_format.major_type == WG_MAJOR_TYPE_VIDEO_WMV); + IMFMediaType_Release(media_type);
if (flags & DMO_SET_TYPEF_TEST_ONLY) return S_OK;
- decoder->input_format = wg_format; + FreeMediaType(&decoder->input_type); + CopyMediaType(&decoder->input_type, type); if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -541,8 +551,9 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde { struct wmv_decoder *decoder = impl_from_IMediaObject(iface); struct wg_transform_attrs attrs = {0}; - struct wg_format wg_format; + IMFMediaType *media_type; unsigned int i; + HRESULT hr;
TRACE("iface %p, index %lu, type %p, flags %#lx,\n", iface, index, type, flags);
@@ -553,7 +564,8 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde { if (flags & DMO_SET_TYPEF_CLEAR) { - memset(&decoder->output_format, 0, sizeof(decoder->output_format)); + FreeMediaType(&decoder->output_type); + memset(&decoder->output_type, 0, sizeof(decoder->output_type)); if (decoder->wg_transform) { wg_transform_destroy(decoder->wg_transform); @@ -564,7 +576,7 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde return E_POINTER; }
- if (!wg_format_is_set(&decoder->input_format)) + if (IsEqualGUID(&decoder->input_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET;
if (!IsEqualGUID(&type->majortype, &MEDIATYPE_Video)) @@ -576,15 +588,16 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde if (i == ARRAY_SIZE(wmv_decoder_output_types)) return DMO_E_TYPE_NOT_ACCEPTED;
- if (!amt_to_wg_format((const AM_MEDIA_TYPE *)type, &wg_format)) + if (FAILED(MFCreateMediaTypeFromRepresentation(AM_MEDIA_TYPE_REPRESENTATION, + (void *)type, &media_type))) return DMO_E_TYPE_NOT_ACCEPTED; - assert(wg_format.major_type == WG_MAJOR_TYPE_VIDEO); + IMFMediaType_Release(media_type);
if (flags & DMO_SET_TYPEF_TEST_ONLY) return S_OK;
- decoder->output_subtype = type->subtype; - decoder->output_format = wg_format; + FreeMediaType(&decoder->output_type); + CopyMediaType(&decoder->output_type, type);
/* Set up wg_transform. */ if (decoder->wg_transform) @@ -592,8 +605,9 @@ static HRESULT WINAPI media_object_SetOutputType(IMediaObject *iface, DWORD inde wg_transform_destroy(decoder->wg_transform); decoder->wg_transform = 0; } - if (!(decoder->wg_transform = wg_transform_create(&decoder->input_format, &decoder->output_format, &attrs))) - return E_FAIL; + if (FAILED(hr = wg_transform_create_quartz(&decoder->input_type, type, + &attrs, &decoder->wg_transform))) + return hr;
return S_OK; } @@ -621,22 +635,22 @@ static HRESULT WINAPI media_object_GetInputSizeInfo(IMediaObject *iface, DWORD i static HRESULT WINAPI media_object_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) { struct wmv_decoder *decoder = impl_from_IMediaObject(iface); + IMFMediaType *media_type; HRESULT hr;
TRACE("iface %p, index %lu, size %p, alignment %p.\n", iface, index, size, alignment);
if (index > 0) return DMO_E_INVALIDSTREAMINDEX; - if (!wg_format_is_set(&decoder->output_format)) + if (IsEqualGUID(&decoder->output_type.majortype, &GUID_NULL)) return DMO_E_TYPE_NOT_SET;
- if (FAILED(hr = MFCalculateImageSize(&decoder->output_subtype, - decoder->output_format.u.video.width, abs(decoder->output_format.u.video.height), (UINT32 *)size))) - { - FIXME("Failed to get image size of subtype %s.\n", debugstr_guid(&decoder->output_subtype)); + if (FAILED(hr = MFCreateMediaType(&media_type))) return hr; - } - *alignment = 1; + if (SUCCEEDED(hr = MFInitMediaTypeFromAMMediaType(media_type, &decoder->output_type)) + && SUCCEEDED(hr = IMFMediaType_GetUINT32(media_type, &MF_MT_SAMPLE_SIZE, (UINT32 *)size))) + *alignment = 1; + IMFMediaType_Release(media_type);
return S_OK; }