From: Rémi Bernon rbernon@codeweavers.com
And calculate the sizes when media type is successfully changed. --- dlls/mf/tests/transform.c | 5 ----- dlls/winegstreamer/h264_decoder.c | 35 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 8845df2eb12..21f7b44cdde 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -2818,15 +2818,12 @@ static void test_h264_decoder(void) hr = IMFTransform_GetInputStreamInfo(transform, 0, &input_info); todo_wine ok(hr == S_OK, "GetInputStreamInfo returned %#lx\n", hr); - todo_wine ok(input_info.hnsMaxLatency == 0, "got hnsMaxLatency %s\n", wine_dbgstr_longlong(input_info.hnsMaxLatency)); todo_wine ok(input_info.dwFlags == flags, "got dwFlags %#lx\n", input_info.dwFlags); todo_wine ok(input_info.cbSize == 0x1000, "got cbSize %lu\n", input_info.cbSize); - todo_wine ok(input_info.cbMaxLookahead == 0, "got cbMaxLookahead %#lx\n", input_info.cbMaxLookahead); - todo_wine ok(input_info.cbAlignment == 0, "got cbAlignment %#lx\n", input_info.cbAlignment);
flags = MFT_OUTPUT_STREAM_WHOLE_SAMPLES | MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE; @@ -2865,7 +2862,6 @@ static void test_h264_decoder(void) hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); ok(output_info.dwFlags == flags, "got dwFlags %#lx\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize == input_width * input_height * 2, "got cbSize %#lx\n", output_info.cbSize); ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
@@ -2930,7 +2926,6 @@ static void test_h264_decoder(void) hr = IMFTransform_GetOutputStreamInfo(transform, 0, &output_info); ok(hr == S_OK, "GetOutputStreamInfo returned %#lx\n", hr); ok(output_info.dwFlags == flags, "got dwFlags %#lx\n", output_info.dwFlags); - todo_wine ok(output_info.cbSize == input_width * input_height * 2, "got cbSize %#lx\n", output_info.cbSize); ok(output_info.cbAlignment == 0, "got cbAlignment %#lx\n", output_info.cbAlignment);
diff --git a/dlls/winegstreamer/h264_decoder.c b/dlls/winegstreamer/h264_decoder.c index 12031588365..aaed3213633 100644 --- a/dlls/winegstreamer/h264_decoder.c +++ b/dlls/winegstreamer/h264_decoder.c @@ -29,6 +29,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mfplat); WINE_DECLARE_DEBUG_CHANNEL(winediag);
+#define ALIGN_SIZE(size, alignment) (((size) + (alignment)) & ~((alignment))) + static const GUID *const h264_decoder_input_types[] = { &MFVideoFormat_H264, @@ -50,8 +52,11 @@ struct h264_decoder
IMFAttributes *attributes; IMFAttributes *output_attributes; + IMFMediaType *input_type; + MFT_INPUT_STREAM_INFO input_info; IMFMediaType *output_type; + MFT_OUTPUT_STREAM_INFO output_info;
struct wg_format wg_format; struct wg_transform *wg_transform; @@ -284,31 +289,22 @@ static HRESULT WINAPI transform_GetInputStreamInfo(IMFTransform *iface, DWORD id TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
if (!decoder->input_type) + { + memset(info, 0, sizeof(*info)); return MF_E_TRANSFORM_TYPE_NOT_SET; + }
- info->hnsMaxLatency = 0; - info->dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES | MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | MFT_INPUT_STREAM_FIXED_SAMPLE_SIZE; - info->cbSize = 0x1000; - info->cbMaxLookahead = 0; - info->cbAlignment = 0; - + *info = decoder->input_info; return S_OK; }
static HRESULT WINAPI transform_GetOutputStreamInfo(IMFTransform *iface, DWORD id, MFT_OUTPUT_STREAM_INFO *info) { struct h264_decoder *decoder = impl_from_IMFTransform(iface); - UINT32 actual_width, actual_height;
TRACE("iface %p, id %#lx, info %p.\n", iface, id, info);
- actual_width = (decoder->wg_format.u.video.width + 15) & ~15; - actual_height = (decoder->wg_format.u.video.height + 15) & ~15; - - info->dwFlags = MFT_OUTPUT_STREAM_WHOLE_SAMPLES | MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER | MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE; - info->cbSize = actual_width * actual_height * 2; - info->cbAlignment = 0; - + *info = decoder->output_info; return S_OK; }
@@ -460,6 +456,8 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM { decoder->wg_format.u.video.width = frame_size >> 32; decoder->wg_format.u.video.height = (UINT32)frame_size; + decoder->output_info.cbSize = decoder->wg_format.u.video.width + * decoder->wg_format.u.video.height * 2; }
return S_OK; @@ -643,6 +641,8 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { decoder->wg_format = wg_format; + decoder->output_info.cbSize = ALIGN_SIZE(decoder->wg_format.u.video.width, 0xf) + * ALIGN_SIZE(decoder->wg_format.u.video.height, 0xf) * 2;
/* keep the frame rate that was requested, GStreamer doesn't provide any */ if (SUCCEEDED(IMFMediaType_GetUINT64(decoder->output_type, &MF_MT_FRAME_RATE, &frame_rate))) @@ -725,6 +725,13 @@ HRESULT h264_decoder_create(REFIID riid, void **ret) decoder->wg_format.u.video.fps_n = 30000; decoder->wg_format.u.video.fps_d = 1001;
+ decoder->input_info.dwFlags = MFT_INPUT_STREAM_WHOLE_SAMPLES | MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER + | MFT_INPUT_STREAM_FIXED_SAMPLE_SIZE; + decoder->input_info.cbSize = 0x1000; + decoder->output_info.dwFlags = MFT_OUTPUT_STREAM_WHOLE_SAMPLES | MFT_OUTPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER + | MFT_OUTPUT_STREAM_FIXED_SAMPLE_SIZE; + decoder->output_info.cbSize = 1920 * 1088 * 2; + if (FAILED(hr = MFCreateAttributes(&decoder->attributes, 16))) goto failed; if (FAILED(hr = IMFAttributes_SetUINT32(decoder->attributes, &MF_LOW_LATENCY, 0)))