mfreadwrite/reader: Use current stream type to set up sample allocator.

It's normal to have incomplete type description for SetCurrentMediaType(),
with just major/subtype attributes. Allocator will need at least frame size.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-03-23 19:04:47 +03:00 committed by Alexandre Julliard
parent 33c6a6cb28
commit 482f977b34
1 changed files with 4 additions and 5 deletions

View File

@ -1629,15 +1629,14 @@ static HRESULT source_reader_set_compatible_media_type(struct source_reader *rea
return type_set ? S_OK : S_FALSE;
}
static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader, unsigned int index,
IMFMediaType *media_type)
static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader, unsigned int index)
{
struct media_stream *stream = &reader->streams[index];
IMFVideoSampleAllocatorCallback *callback;
GUID major = { 0 };
HRESULT hr;
IMFMediaType_GetMajorType(media_type, &major);
IMFMediaType_GetMajorType(stream->current, &major);
if (!IsEqualGUID(&major, &MFMediaType_Video))
return S_OK;
@ -1666,7 +1665,7 @@ static HRESULT source_reader_setup_sample_allocator(struct source_reader *reader
return hr;
}
if (FAILED(hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(stream->allocator, 2, 8, NULL, media_type)))
if (FAILED(hr = IMFVideoSampleAllocatorEx_InitializeSampleAllocatorEx(stream->allocator, 2, 8, NULL, stream->current)))
WARN("Failed to initialize sample allocator, hr %#x.\n", hr);
if (SUCCEEDED(IMFVideoSampleAllocatorEx_QueryInterface(stream->allocator, &IID_IMFVideoSampleAllocatorCallback, (void **)&callback)))
@ -1837,7 +1836,7 @@ static HRESULT WINAPI src_reader_SetCurrentMediaType(IMFSourceReader *iface, DWO
if (hr == S_FALSE)
hr = source_reader_create_decoder_for_stream(reader, index, type);
if (SUCCEEDED(hr))
hr = source_reader_setup_sample_allocator(reader, index, type);
hr = source_reader_setup_sample_allocator(reader, index);
LeaveCriticalSection(&reader->cs);