diff --git a/patches/mfplat-streaming-support/0084-winegstreamer-Reimplement-AAC-decoder-using-wg_trans.patch b/patches/mfplat-streaming-support/0084-winegstreamer-Reimplement-AAC-decoder-using-wg_trans.patch deleted file mode 100644 index a51af9a4..00000000 --- a/patches/mfplat-streaming-support/0084-winegstreamer-Reimplement-AAC-decoder-using-wg_trans.patch +++ /dev/null @@ -1,878 +0,0 @@ -From 9d7af078fcee25d78c5da2d366872f1c3e57f68c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?R=C3=A9mi=20Bernon?= -Date: Fri, 21 Jan 2022 14:36:32 +0100 -Subject: [PATCH 84/88] winegstreamer: Reimplement AAC decoder using - wg_transform. - -For Call of Duty III, possibly others. This will need to be split. - -Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47084 -CW-Bug-Id: #19362 ---- - dlls/winegstreamer/Makefile.in | 1 + - dlls/winegstreamer/aac_decoder.c | 622 ++++++++++++++++++++++++++++++ - dlls/winegstreamer/gst_private.h | 1 + - dlls/winegstreamer/mfplat.c | 72 ++++ - dlls/winegstreamer/unixlib.h | 8 + - dlls/winegstreamer/wg_transform.c | 48 +++ - 6 files changed, 752 insertions(+) - create mode 100644 dlls/winegstreamer/aac_decoder.c - -diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in -index c4f0f1cad2c..d9746534c2b 100644 ---- a/dlls/winegstreamer/Makefile.in -+++ b/dlls/winegstreamer/Makefile.in -@@ -7,6 +7,7 @@ EXTRAINCL = $(GSTREAMER_CFLAGS) - EXTRALIBS = $(GSTREAMER_LIBS) $(PTHREAD_LIBS) - - C_SRCS = \ -+ aac_decoder.c \ - audioconvert.c \ - colorconvert.c \ - decode_transform.c \ -diff --git a/dlls/winegstreamer/aac_decoder.c b/dlls/winegstreamer/aac_decoder.c -new file mode 100644 -index 00000000000..3b3383a52ab ---- /dev/null -+++ b/dlls/winegstreamer/aac_decoder.c -@@ -0,0 +1,622 @@ -+/* AAC Decoder Transform -+ * -+ * Copyright 2022 RĂ©mi Bernon for CodeWeavers -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -+ */ -+ -+#include "gst_private.h" -+ -+#include "mfapi.h" -+#include "mferror.h" -+#include "mfobjects.h" -+#include "mftransform.h" -+#include "wmcodecdsp.h" -+ -+#include "wine/debug.h" -+#include "wine/heap.h" -+ -+WINE_DEFAULT_DEBUG_CHANNEL(mfplat); -+ -+static const GUID *aac_decoder_input_types[] = -+{ -+ &MFAudioFormat_AAC, -+}; -+static const GUID *aac_decoder_output_types[] = -+{ -+ &MFAudioFormat_PCM, -+ &MFAudioFormat_Float, -+}; -+ -+struct aac_decoder -+{ -+ IMFTransform IMFTransform_iface; -+ LONG refcount; -+ IMFMediaType *input_type; -+ IMFMediaType *output_type; -+ -+ IMFSample *input_sample; -+ struct wg_transform *wg_transform; -+}; -+ -+static struct aac_decoder *impl_from_IMFTransform(IMFTransform *iface) -+{ -+ return CONTAINING_RECORD(iface, struct aac_decoder, IMFTransform_iface); -+} -+ -+static void try_create_wg_transform(struct aac_decoder *decoder) -+{ -+ struct wg_encoded_format input_format; -+ struct wg_format output_format; -+ -+ if (!decoder->input_type || !decoder->output_type) -+ return; -+ -+ if (decoder->wg_transform) -+ wg_transform_destroy(decoder->wg_transform); -+ -+ mf_media_type_to_wg_encoded_format(decoder->input_type, &input_format); -+ if (input_format.encoded_type == WG_ENCODED_TYPE_UNKNOWN) -+ return; -+ -+ mf_media_type_to_wg_format(decoder->output_type, &output_format); -+ if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN) -+ return; -+ -+ decoder->wg_transform = wg_transform_create(&input_format, &output_format); -+ if (!decoder->wg_transform) -+ WARN("Failed to create wg_transform.\n"); -+} -+ -+static HRESULT WINAPI aac_decoder_QueryInterface(IMFTransform *iface, REFIID iid, void **out) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ -+ TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); -+ -+ if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IMFTransform)) -+ *out = &decoder->IMFTransform_iface; -+ else -+ { -+ *out = NULL; -+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); -+ return E_NOINTERFACE; -+ } -+ -+ IUnknown_AddRef((IUnknown *)*out); -+ return S_OK; -+} -+ -+static ULONG WINAPI aac_decoder_AddRef(IMFTransform *iface) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ ULONG refcount = InterlockedIncrement(&decoder->refcount); -+ -+ TRACE("iface %p increasing refcount to %lu.\n", decoder, refcount); -+ -+ return refcount; -+} -+ -+static ULONG WINAPI aac_decoder_Release(IMFTransform *iface) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ ULONG refcount = InterlockedDecrement(&decoder->refcount); -+ -+ TRACE("iface %p decreasing refcount to %lu.\n", decoder, refcount); -+ -+ if (!refcount) -+ { -+ if (decoder->input_sample) -+ IMFSample_Release(decoder->input_sample); -+ if (decoder->wg_transform) -+ wg_transform_destroy(decoder->wg_transform); -+ if (decoder->input_type) -+ IMFMediaType_Release(decoder->input_type); -+ if (decoder->output_type) -+ IMFMediaType_Release(decoder->output_type); -+ free(decoder); -+ } -+ -+ return refcount; -+} -+ -+static HRESULT WINAPI aac_decoder_GetStreamLimits(IMFTransform *iface, DWORD *input_minimum, DWORD *input_maximum, -+ DWORD *output_minimum, DWORD *output_maximum) -+{ -+ FIXME("iface %p, input_minimum %p, input_maximum %p, output_minimum %p, output_maximum %p stub!\n", -+ iface, input_minimum, input_maximum, output_minimum, output_maximum); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetStreamCount(IMFTransform *iface, DWORD *inputs, DWORD *outputs) -+{ -+ FIXME("iface %p, inputs %p, outputs %p stub!\n", iface, inputs, outputs); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetStreamIDs(IMFTransform *iface, DWORD input_size, DWORD *inputs, -+ DWORD output_size, DWORD *outputs) -+{ -+ FIXME("iface %p, input_size %lu, inputs %p, output_size %lu, outputs %p stub!\n", -+ iface, input_size, inputs, output_size, outputs); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetInputStreamInfo(IMFTransform *iface, DWORD id, MFT_INPUT_STREAM_INFO *info) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ UINT32 block_alignment; -+ HRESULT hr; -+ -+ TRACE("iface %p, id %#lx, info %p.\n", iface, id, info); -+ -+ if (!decoder->input_type || !decoder->output_type) -+ return MF_E_TRANSFORM_TYPE_NOT_SET; -+ -+ if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment))) -+ return hr; -+ -+ info->hnsMaxLatency = 0; -+ info->dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES|MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER -+ |MFT_INPUT_STREAM_FIXED_SAMPLE_SIZE|MFT_INPUT_STREAM_HOLDS_BUFFERS; -+ info->cbSize = 0; -+ info->cbMaxLookahead = 0; -+ info->cbAlignment = 0; -+ -+ return S_OK; -+} -+ -+static HRESULT WINAPI aac_decoder_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ UINT32 channel_count, block_alignment; -+ HRESULT hr; -+ -+ TRACE("iface %p, id %#lx, info %p.\n", iface, id, info); -+ -+ if (!decoder->input_type || !decoder->output_type) -+ return MF_E_TRANSFORM_TYPE_NOT_SET; -+ -+ if (FAILED(hr = IMFMediaType_GetUINT32(decoder->output_type, &MF_MT_AUDIO_NUM_CHANNELS, &channel_count))) -+ return hr; -+ if (FAILED(hr = IMFMediaType_GetUINT32(decoder->output_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &block_alignment))) -+ return hr; -+ -+ info->dwFlags = 0; -+ info->cbSize = 0x1800 * block_alignment * channel_count; -+ info->cbAlignment = 0; -+ -+ return S_OK; -+} -+ -+static HRESULT WINAPI aac_decoder_GetAttributes(IMFTransform *iface, IMFAttributes **attributes) -+{ -+ FIXME("iface %p, attributes %p stub!\n", iface, attributes); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetInputStreamAttributes(IMFTransform *iface, DWORD id, -+ IMFAttributes **attributes) -+{ -+ FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetOutputStreamAttributes(IMFTransform *iface, DWORD id, -+ IMFAttributes **attributes) -+{ -+ FIXME("iface %p, id %#lx, attributes %p stub!\n", iface, id, attributes); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_DeleteInputStream(IMFTransform *iface, DWORD id) -+{ -+ FIXME("iface %p, id %#lx stub!\n", iface, id); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_AddInputStreams(IMFTransform *iface, DWORD streams, DWORD *ids) -+{ -+ FIXME("iface %p, streams %lu, ids %p stub!\n", iface, streams, ids); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetInputAvailableType(IMFTransform *iface, DWORD id, DWORD index, -+ IMFMediaType **type) -+{ -+ FIXME("iface %p, id %#lx, index %#lx, type %p stub!\n", iface, id, index, type); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetOutputAvailableType(IMFTransform *iface, DWORD id, DWORD index, -+ IMFMediaType **type) -+{ -+ UINT32 channel_count, sample_size, sample_rate, block_alignment; -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ IMFMediaType *media_type; -+ const GUID *output_type; -+ HRESULT hr; -+ -+ TRACE("iface %p, id %#lx, index %#lx, type %p.\n", iface, id, index, type); -+ -+ if (!decoder->input_type) -+ return MF_E_TRANSFORM_TYPE_NOT_SET; -+ -+ *type = NULL; -+ -+ if (index >= ARRAY_SIZE(aac_decoder_output_types)) -+ return MF_E_NO_MORE_TYPES; -+ index = ARRAY_SIZE(aac_decoder_output_types) - index - 1; -+ output_type = aac_decoder_output_types[index]; -+ -+ if (FAILED(hr = MFCreateMediaType(&media_type))) -+ return hr; -+ -+ if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio))) -+ goto done; -+ if (FAILED(hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, output_type))) -+ goto done; -+ -+ if (IsEqualGUID(output_type, &MFAudioFormat_Float)) -+ sample_size = 32; -+ else if (IsEqualGUID(output_type, &MFAudioFormat_PCM)) -+ sample_size = 16; -+ else -+ { -+ FIXME("Subtype %s not implemented!\n", debugstr_guid(output_type)); -+ hr = E_NOTIMPL; -+ goto done; -+ } -+ -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) -+ goto done; -+ -+ if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_NUM_CHANNELS, &channel_count))) -+ goto done; -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, channel_count))) -+ goto done; -+ -+ if (FAILED(hr = IMFMediaType_GetUINT32(decoder->input_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &sample_rate))) -+ goto done; -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, sample_rate))) -+ goto done; -+ -+ block_alignment = sample_size * channel_count / 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, sample_rate * block_alignment))) -+ goto done; -+ -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_ALL_SAMPLES_INDEPENDENT, 1))) -+ goto done; -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_FIXED_SIZE_SAMPLES, 1))) -+ goto done; -+ if (FAILED(hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1))) -+ goto done; -+ -+done: -+ if (SUCCEEDED(hr)) -+ IMFMediaType_AddRef((*type = media_type)); -+ -+ IMFMediaType_Release(media_type); -+ return hr; -+} -+ -+static HRESULT WINAPI aac_decoder_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ MF_ATTRIBUTE_TYPE item_type; -+ GUID major, subtype; -+ HRESULT hr; -+ ULONG i; -+ -+ TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags); -+ -+ if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || -+ FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) -+ return hr; -+ -+ if (!IsEqualGUID(&major, &MFMediaType_Audio)) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ for (i = 0; i < ARRAY_SIZE(aac_decoder_input_types); ++i) -+ if (IsEqualGUID(&subtype, aac_decoder_input_types[i])) -+ break; -+ if (i == ARRAY_SIZE(aac_decoder_input_types)) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_USER_DATA, &item_type)) || -+ item_type != MF_ATTRIBUTE_BLOB) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_PREFER_WAVEFORMATEX, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ if (!decoder->input_type && FAILED(hr = MFCreateMediaType(&decoder->input_type))) -+ return hr; -+ -+ if (decoder->output_type) -+ { -+ IMFMediaType_Release(decoder->output_type); -+ decoder->output_type = NULL; -+ } -+ -+ return IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->input_type); -+} -+ -+static HRESULT WINAPI aac_decoder_SetOutputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ MF_ATTRIBUTE_TYPE item_type; -+ ULONG i, sample_size; -+ GUID major, subtype; -+ HRESULT hr; -+ -+ TRACE("iface %p, id %#lx, type %p, flags %#lx.\n", iface, id, type, flags); -+ -+ if (FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major)) || -+ FAILED(hr = IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype))) -+ return hr; -+ -+ if (!IsEqualGUID(&major, &MFMediaType_Audio)) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ for (i = 0; i < ARRAY_SIZE(aac_decoder_output_types); ++i) -+ if (IsEqualGUID(&subtype, aac_decoder_output_types[i])) -+ break; -+ if (i == ARRAY_SIZE(aac_decoder_output_types)) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ if (IsEqualGUID(&subtype, &MFAudioFormat_Float)) -+ sample_size = 32; -+ else if (IsEqualGUID(&subtype, &MFAudioFormat_PCM)) -+ sample_size = 16; -+ else -+ { -+ FIXME("Subtype %s not implemented!\n", debugstr_guid(&subtype)); -+ hr = E_NOTIMPL; -+ return hr; -+ } -+ -+ if (FAILED(IMFMediaType_SetUINT32(decoder->input_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, sample_size))) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_AVG_BYTES_PER_SECOND, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_NUM_CHANNELS, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ if (FAILED(IMFMediaType_GetItemType(type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, &item_type)) || -+ item_type != MF_ATTRIBUTE_UINT32) -+ return MF_E_INVALIDMEDIATYPE; -+ -+ if (!decoder->output_type && FAILED(hr = MFCreateMediaType(&decoder->output_type))) -+ return hr; -+ -+ if (FAILED(hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *)decoder->output_type))) -+ return hr; -+ -+ try_create_wg_transform(decoder); -+ return S_OK; -+} -+ -+static HRESULT WINAPI aac_decoder_GetInputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) -+{ -+ FIXME("iface %p, id %#lx, type %p stub!\n", iface, id, type); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetOutputCurrentType(IMFTransform *iface, DWORD id, IMFMediaType **type) -+{ -+ FIXME("iface %p, id %#lx, type %p stub!\n", iface, id, type); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetInputStatus(IMFTransform *iface, DWORD id, DWORD *flags) -+{ -+ FIXME("iface %p, id %#lx, flags %p stub!\n", iface, id, flags); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_GetOutputStatus(IMFTransform *iface, DWORD *flags) -+{ -+ FIXME("iface %p, flags %p stub!\n", iface, flags); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_SetOutputBounds(IMFTransform *iface, LONGLONG lower, LONGLONG upper) -+{ -+ FIXME("iface %p, lower %s, upper %s stub!\n", iface, -+ wine_dbgstr_longlong(lower), wine_dbgstr_longlong(upper)); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_ProcessEvent(IMFTransform *iface, DWORD id, IMFMediaEvent *event) -+{ -+ FIXME("iface %p, id %#lx, event %p stub!\n", iface, id, event); -+ return E_NOTIMPL; -+} -+ -+static HRESULT WINAPI aac_decoder_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_TYPE message, ULONG_PTR param) -+{ -+ FIXME("iface %p, message %#x, param %p stub!\n", iface, message, (void *)param); -+ return S_OK; -+} -+ -+static HRESULT WINAPI aac_decoder_ProcessInput(IMFTransform *iface, DWORD id, IMFSample *sample, DWORD flags) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ IMFMediaBuffer *media_buffer; -+ MFT_INPUT_STREAM_INFO info; -+ DWORD buffer_size; -+ BYTE *buffer; -+ HRESULT hr; -+ -+ TRACE("iface %p, id %#lx, sample %p, flags %#lx.\n", iface, id, sample, flags); -+ -+ if (FAILED(hr = IMFTransform_GetInputStreamInfo(iface, 0, &info))) -+ return hr; -+ -+ if (!decoder->wg_transform) -+ return MF_E_TRANSFORM_TYPE_NOT_SET; -+ -+ if (decoder->input_sample) -+ return MF_E_NOTACCEPTING; -+ -+ if (FAILED(hr = IMFSample_ConvertToContiguousBuffer(sample, &media_buffer))) -+ return hr; -+ -+ if (FAILED(hr = IMFMediaBuffer_Lock(media_buffer, &buffer, NULL, &buffer_size))) -+ goto done; -+ -+ if (SUCCEEDED(hr = wg_transform_push_data(decoder->wg_transform, buffer, buffer_size))) -+ IMFSample_AddRef((decoder->input_sample = sample)); -+ -+ IMFMediaBuffer_Unlock(media_buffer); -+ -+done: -+ IMFMediaBuffer_Release(media_buffer); -+ return hr; -+} -+ -+static HRESULT WINAPI aac_decoder_ProcessOutput(IMFTransform *iface, DWORD flags, DWORD count, -+ MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) -+{ -+ struct aac_decoder *decoder = impl_from_IMFTransform(iface); -+ struct wg_sample wg_sample = {0}; -+ IMFMediaBuffer *media_buffer; -+ MFT_OUTPUT_STREAM_INFO info; -+ DWORD buffer_size; -+ HRESULT hr; -+ -+ TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status); -+ -+ if (count > 1) -+ { -+ FIXME("Not implemented count %lu\n", count); -+ return E_NOTIMPL; -+ } -+ -+ if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) -+ return hr; -+ -+ if (!decoder->wg_transform) -+ return MF_E_TRANSFORM_TYPE_NOT_SET; -+ -+ *status = 0; -+ samples[0].dwStatus = 0; -+ if (!samples[0].pSample) -+ { -+ samples[0].dwStatus = MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE; -+ return MF_E_TRANSFORM_NEED_MORE_INPUT; -+ } -+ -+ if (FAILED(hr = IMFSample_ConvertToContiguousBuffer(samples[0].pSample, &media_buffer))) -+ return hr; -+ -+ if (FAILED(hr = IMFMediaBuffer_Lock(media_buffer, &wg_sample.data, &buffer_size, NULL))) -+ goto done; -+ wg_sample.size = buffer_size; -+ -+ if (wg_sample.size < info.cbSize) -+ hr = MF_E_BUFFERTOOSMALL; -+ else if (SUCCEEDED(hr = wg_transform_read_data(decoder->wg_transform, &wg_sample))) -+ { -+ if (wg_sample.flags & WG_SAMPLE_FLAG_INCOMPLETE) -+ samples[0].dwStatus |= MFT_OUTPUT_DATA_BUFFER_INCOMPLETE; -+ } -+ else -+ { -+ if (decoder->input_sample) -+ IMFSample_Release(decoder->input_sample); -+ decoder->input_sample = NULL; -+ } -+ -+ IMFMediaBuffer_Unlock(media_buffer); -+ -+done: -+ IMFMediaBuffer_SetCurrentLength(media_buffer, wg_sample.size); -+ IMFMediaBuffer_Release(media_buffer); -+ return hr; -+} -+ -+static const IMFTransformVtbl aac_decoder_vtbl = -+{ -+ aac_decoder_QueryInterface, -+ aac_decoder_AddRef, -+ aac_decoder_Release, -+ aac_decoder_GetStreamLimits, -+ aac_decoder_GetStreamCount, -+ aac_decoder_GetStreamIDs, -+ aac_decoder_GetInputStreamInfo, -+ aac_decoder_GetOutputStreamInfo, -+ aac_decoder_GetAttributes, -+ aac_decoder_GetInputStreamAttributes, -+ aac_decoder_GetOutputStreamAttributes, -+ aac_decoder_DeleteInputStream, -+ aac_decoder_AddInputStreams, -+ aac_decoder_GetInputAvailableType, -+ aac_decoder_GetOutputAvailableType, -+ aac_decoder_SetInputType, -+ aac_decoder_SetOutputType, -+ aac_decoder_GetInputCurrentType, -+ aac_decoder_GetOutputCurrentType, -+ aac_decoder_GetInputStatus, -+ aac_decoder_GetOutputStatus, -+ aac_decoder_SetOutputBounds, -+ aac_decoder_ProcessEvent, -+ aac_decoder_ProcessMessage, -+ aac_decoder_ProcessInput, -+ aac_decoder_ProcessOutput, -+}; -+ -+HRESULT aac_decoder_create(REFIID riid, void **ret) -+{ -+ struct aac_decoder *decoder; -+ -+ TRACE("riid %s, ret %p.\n", debugstr_guid(riid), ret); -+ -+ if (!(decoder = calloc(1, sizeof(*decoder)))) -+ return E_OUTOFMEMORY; -+ -+ decoder->IMFTransform_iface.lpVtbl = &aac_decoder_vtbl; -+ decoder->refcount = 1; -+ -+ *ret = &decoder->IMFTransform_iface; -+ TRACE("Created decoder %p\n", *ret); -+ return S_OK; -+} -diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h -index fa73fecb10d..d60e904e87f 100644 ---- a/dlls/winegstreamer/gst_private.h -+++ b/dlls/winegstreamer/gst_private.h -@@ -128,6 +128,7 @@ void mf_media_type_to_wg_encoded_format(IMFMediaType *type, struct wg_encoded_fo - - HRESULT winegstreamer_stream_handler_create(REFIID riid, void **obj); - -+HRESULT aac_decoder_create(REFIID riid, void **ret); - HRESULT h264_decoder_create(REFIID riid, void **ret); - HRESULT audio_converter_create(REFIID riid, void **ret); - HRESULT color_converter_create(REFIID riid, void **ret); -diff --git a/dlls/winegstreamer/mfplat.c b/dlls/winegstreamer/mfplat.c -index f2cdd04070d..e4ffb988b0b 100644 ---- a/dlls/winegstreamer/mfplat.c -+++ b/dlls/winegstreamer/mfplat.c -@@ -30,6 +30,7 @@ - WINE_DEFAULT_DEBUG_CHANNEL(mfplat); - - DEFINE_MEDIATYPE_GUID(MFAudioFormat_XMAudio2, 0x0166); -+DEFINE_MEDIATYPE_GUID(MFAudioFormat_RAW_AAC, WAVE_FORMAT_RAW_AAC1); - - struct video_processor - { -@@ -448,6 +449,19 @@ static const GUID *const audio_converter_supported_types[] = - &MFAudioFormat_Float, - }; - -+static WCHAR aac_decoderW[] = L"AAC Audio Decoder MFT"; -+static const GUID *aac_decoder_input_types[] = -+{ -+ &MFAudioFormat_AAC, -+ &MFAudioFormat_RAW_AAC, -+ &MFAudioFormat_ADTS, -+}; -+static const GUID *aac_decoder_output_types[] = -+{ -+ &MFAudioFormat_Float, -+ &MFAudioFormat_PCM, -+}; -+ - static WCHAR wma_decoderW[] = L"WMAudio Decoder MFT"; - static const GUID *const wma_decoder_input_types[] = - { -@@ -521,6 +535,17 @@ mfts[] = - ARRAY_SIZE(audio_converter_supported_types), - audio_converter_supported_types, - }, -+ { -+ &CLSID_MSAACDecMFT, -+ &MFT_CATEGORY_AUDIO_DECODER, -+ aac_decoderW, -+ MFT_ENUM_FLAG_SYNCMFT, -+ &MFMediaType_Audio, -+ ARRAY_SIZE(aac_decoder_input_types), -+ aac_decoder_input_types, -+ ARRAY_SIZE(aac_decoder_output_types), -+ aac_decoder_output_types, -+ }, - { - &CLSID_WMADecMediaObject, - &MFT_CATEGORY_AUDIO_DECODER, -@@ -938,6 +963,51 @@ static void mf_media_type_to_wg_encoded_format_xwma(IMFMediaType *type, struct w - memcpy(format->u.xwma.codec_data, codec_data, codec_data_len); - } - -+static void mf_media_type_to_wg_encoded_format_aac(IMFMediaType *type, struct wg_encoded_format *format) -+{ -+ UINT32 codec_data_len, payload_type, profile_level_indication; -+ BYTE codec_data[64]; -+ -+ /* Audio specific config is stored at after HEAACWAVEINFO in MF_MT_USER_DATA -+ * https://docs.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-heaacwaveformat -+ */ -+ struct -+ { -+ WORD payload_type; -+ WORD profile_level_indication; -+ WORD type; -+ WORD reserved1; -+ DWORD reserved2; -+ } *aac_info = (void *)codec_data; -+ -+ if (FAILED(IMFMediaType_GetBlob(type, &MF_MT_USER_DATA, codec_data, sizeof(codec_data), &codec_data_len))) -+ { -+ FIXME("Codec data is not set.\n"); -+ return; -+ } -+ if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AAC_PAYLOAD_TYPE, &payload_type))) -+ { -+ FIXME("AAC payload type is not set.\n"); -+ payload_type = aac_info->payload_type; -+ } -+ if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AAC_AUDIO_PROFILE_LEVEL_INDICATION, &profile_level_indication))) -+ { -+ FIXME("AAC provile level indication is not set.\n"); -+ profile_level_indication = aac_info->profile_level_indication; -+ } -+ -+ format->encoded_type = WG_ENCODED_TYPE_AAC; -+ format->u.aac.payload_type = payload_type; -+ format->u.aac.profile_level_indication = profile_level_indication; -+ format->u.aac.codec_data_len = 0; -+ -+ if (codec_data_len > sizeof(*aac_info)) -+ { -+ format->u.aac.codec_data_len = codec_data_len - sizeof(*aac_info); -+ memcpy(format->u.aac.codec_data, codec_data + sizeof(*aac_info), codec_data_len - sizeof(*aac_info)); -+ } -+} -+ - static void mf_media_type_to_wg_encoded_format_h264(IMFMediaType *type, struct wg_encoded_format *format) - { - UINT64 frame_rate, frame_size; -@@ -997,6 +1067,8 @@ void mf_media_type_to_wg_encoded_format(IMFMediaType *type, struct wg_encoded_fo - mf_media_type_to_wg_encoded_format_xwma(type, format, WG_ENCODED_TYPE_WMA, 4); - else if (IsEqualGUID(&subtype, &MFAudioFormat_XMAudio2)) - mf_media_type_to_wg_encoded_format_xwma(type, format, WG_ENCODED_TYPE_XMA, 2); -+ else if (IsEqualGUID(&subtype, &MFAudioFormat_AAC)) -+ mf_media_type_to_wg_encoded_format_aac(type, format); - else - FIXME("Unimplemented audio subtype %s.\n", debugstr_guid(&subtype)); - } -diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h -index 1beeed8f1a2..2cf75c4320e 100644 ---- a/dlls/winegstreamer/unixlib.h -+++ b/dlls/winegstreamer/unixlib.h -@@ -132,6 +132,7 @@ struct wg_encoded_format - WG_ENCODED_TYPE_UNKNOWN, - WG_ENCODED_TYPE_WMA, - WG_ENCODED_TYPE_XMA, -+ WG_ENCODED_TYPE_AAC, - WG_ENCODED_TYPE_H264, - } encoded_type; - -@@ -149,6 +150,13 @@ struct wg_encoded_format - unsigned char codec_data[64]; - } xwma; - struct -+ { -+ uint32_t payload_type; -+ uint32_t profile_level_indication; -+ uint32_t codec_data_len; -+ unsigned char codec_data[64]; -+ } aac; -+ struct - { - int32_t width, height; - uint32_t fps_n, fps_d; -diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c -index 1c9dc6f72bb..775ac14e6a5 100644 ---- a/dlls/winegstreamer/wg_transform.c -+++ b/dlls/winegstreamer/wg_transform.c -@@ -99,6 +99,52 @@ static GstCaps *wg_format_to_caps_xwma(const struct wg_encoded_format *format) - return caps; - } - -+static GstCaps *wg_format_to_caps_aac(const struct wg_encoded_format *format) -+{ -+ const char *profile, *level, *stream_format; -+ GstBuffer *buffer; -+ GstCaps *caps; -+ -+ caps = gst_caps_new_empty_simple("audio/mpeg"); -+ gst_caps_set_simple(caps, "mpegversion", G_TYPE_INT, 4, NULL); -+ -+ switch (format->u.aac.payload_type) -+ { -+ case 0: stream_format = "raw"; break; -+ case 1: stream_format = "adts"; break; -+ case 2: stream_format = "adif"; break; -+ case 3: stream_format = "loas"; break; -+ default: stream_format = "raw"; break; -+ } -+ if (stream_format) -+ gst_caps_set_simple(caps, "stream-format", G_TYPE_STRING, stream_format, NULL); -+ -+ switch (format->u.aac.profile_level_indication) -+ { -+ case 0x29: profile = "lc"; level = "2"; break; -+ case 0x2A: profile = "lc"; level = "4"; break; -+ case 0x2B: profile = "lc"; level = "5"; break; -+ default: -+ GST_FIXME("Unrecognized profile-level-indication %u\n", format->u.aac.profile_level_indication); -+ /* fallthrough */ -+ case 0x00: case 0xFE: profile = level = NULL; break; /* unspecified */ -+ } -+ if (profile) -+ gst_caps_set_simple(caps, "profile", G_TYPE_STRING, profile, NULL); -+ if (level) -+ gst_caps_set_simple(caps, "level", G_TYPE_STRING, level, NULL); -+ -+ if (format->u.aac.codec_data_len) -+ { -+ buffer = gst_buffer_new_and_alloc(format->u.aac.codec_data_len); -+ gst_buffer_fill(buffer, 0, format->u.aac.codec_data, format->u.aac.codec_data_len); -+ gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL); -+ gst_buffer_unref(buffer); -+ } -+ -+ return caps; -+} -+ - static GstCaps *wg_format_to_caps_h264(const struct wg_encoded_format *format) - { - const char *profile, *level; -@@ -166,6 +212,8 @@ static GstCaps *wg_encoded_format_to_caps(const struct wg_encoded_format *format - case WG_ENCODED_TYPE_WMA: - case WG_ENCODED_TYPE_XMA: - return wg_format_to_caps_xwma(format); -+ case WG_ENCODED_TYPE_AAC: -+ return wg_format_to_caps_aac(format); - case WG_ENCODED_TYPE_H264: - return wg_format_to_caps_h264(format); - } --- -2.34.1 - diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 1be12f9c..6aeac6d3 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -51,7 +51,7 @@ usage() # Get the upstream commit sha upstream_commit() { - echo "f87ad783e23a2b6f5e9b8cf78dbf99bad4471a25" + echo "e3f00bf7c944f1cde6151fde969f2b49649c3de7" } # Show version information diff --git a/staging/upstream-commit b/staging/upstream-commit index c243f648..d6fd3f6c 100644 --- a/staging/upstream-commit +++ b/staging/upstream-commit @@ -1 +1 @@ -fded20df6c7422e85dbcd5a20475fd0c5d38d3c6 +e3f00bf7c944f1cde6151fde969f2b49649c3de7