winegstreamer: Use H264 input media type frame size when specified.

Updating the internal stream format frame size accordingly.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45988
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47084
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49715
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52183
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
This commit is contained in:
Rémi Bernon 2022-06-23 14:09:01 +02:00 committed by Alexandre Julliard
parent e15af49029
commit 51bd7f86b6
2 changed files with 48 additions and 100 deletions

View file

@ -7157,144 +7157,98 @@ static void test_h264_decoder(void)
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_H264_ES),
},
};
static const media_type_desc default_outputs[] =
static const DWORD input_width = 120, input_height = 248;
const media_type_desc default_outputs[] =
{
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 1920),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, input_width),
ATTR_UINT32(MF_MT_INTERLACE_MODE, 7),
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1),
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, input_width * input_height * 3 / 2),
/* ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0), missing on Win7 */
},
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_YV12),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 1920),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, input_width),
ATTR_UINT32(MF_MT_INTERLACE_MODE, 7),
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1),
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, input_width * input_height * 3 / 2),
/* ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0), missing on Win7 */
},
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_IYUV),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 1920),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, input_width),
ATTR_UINT32(MF_MT_INTERLACE_MODE, 7),
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1),
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, input_width * input_height * 3 / 2),
/* ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0), missing on Win7 */
},
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_I420),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 1920),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, input_width),
ATTR_UINT32(MF_MT_INTERLACE_MODE, 7),
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1),
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, input_width * input_height * 3 / 2),
/* ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0), missing on Win7 */
},
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_YUY2),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 1),
ATTR_RATIO(MF_MT_FRAME_RATE, 30000, 1001),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 3840),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, input_width * 2),
ATTR_UINT32(MF_MT_INTERLACE_MODE, 7),
ATTR_UINT32(MF_MT_FIXED_SIZE_SAMPLES, 1),
ATTR_UINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, input_width * input_height * 2),
/* ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0), missing on Win7 */
},
};
static const media_type_desc default_outputs_extra[] =
{
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3110400),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3110400),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3110400),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3110400),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 4147200),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
},
};
static const media_type_desc default_outputs_win7[] =
{
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3133440),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3133440),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3133440),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3133440),
},
{
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 4177920),
},
};
static const struct attribute_desc input_type_desc[] =
const struct attribute_desc input_type_desc[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_H264),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
{0},
};
static const struct attribute_desc minimal_output_type_desc[] =
const struct attribute_desc minimal_output_type_desc[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12),
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
{0},
};
static const struct attribute_desc output_type_desc[] =
const struct attribute_desc output_type_desc[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12),
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1080),
ATTR_RATIO(MF_MT_FRAME_SIZE, input_width, input_height),
ATTR_RATIO(MF_MT_FRAME_RATE, 60000, 1000),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 2, 1),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 3840),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3840 * 1080 * 3 / 2),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
{0},
};
static const struct attribute_desc output_type_desc_win7[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12),
ATTR_RATIO(MF_MT_FRAME_SIZE, 1920, 1088),
ATTR_RATIO(MF_MT_FRAME_RATE, 60000, 1000),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 2, 1),
ATTR_UINT32(MF_MT_DEFAULT_STRIDE, 3840),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3840 * 1088 * 3 / 2),
ATTR_UINT32(MF_MT_SAMPLE_SIZE, 3840 * input_height * 3 / 2),
ATTR_UINT32(MF_MT_VIDEO_ROTATION, 0),
{0},
};
@ -7307,15 +7261,6 @@ static void test_h264_decoder(void)
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 2),
{0},
};
static const struct attribute_desc new_output_type_desc_win7[] =
{
ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video),
ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_I420),
ATTR_RATIO(MF_MT_FRAME_SIZE, 96, 96),
ATTR_RATIO(MF_MT_FRAME_RATE, 1, 1),
ATTR_RATIO(MF_MT_PIXEL_ASPECT_RATIO, 1, 2),
{0},
};
static const MFVideoArea actual_aperture = {.Area={82,84}};
static const DWORD actual_width = 96, actual_height = 96;
const media_type_desc actual_outputs[] =
@ -7407,7 +7352,6 @@ static void test_h264_decoder(void)
IMFMediaType *media_type;
LONGLONG time, duration;
IMFTransform *transform;
BOOL is_win7 = FALSE;
ULONG i, ret, flags;
HANDLE output_file;
IMFSample *sample;
@ -7502,6 +7446,9 @@ static void test_h264_decoder(void)
init_media_type(media_type, input_type_desc, 2);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
ok(hr == S_OK, "SetInputType returned %#lx.\n", hr);
init_media_type(media_type, input_type_desc, -1);
hr = IMFTransform_SetInputType(transform, 0, media_type, 0);
ok(hr == S_OK, "SetInputType returned %#lx.\n", hr);
ret = IMFMediaType_Release(media_type);
ok(ret == 1, "Release returned %lu\n", ret);
@ -7511,8 +7458,7 @@ static void test_h264_decoder(void)
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 == 1920 * 1080 * 2 || broken(output_info.cbSize == 1920 * 1088 * 2) /* Win7 */,
"got cbSize %#lx\n", output_info.cbSize);
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);
/* output types can now be enumerated (though they are actually the same for all input types) */
@ -7523,9 +7469,6 @@ static void test_h264_decoder(void)
winetest_push_context("out %lu", i);
ok(hr == S_OK, "GetOutputAvailableType returned %#lx\n", hr);
check_media_type(media_type, default_outputs[i], -1);
hr = IMFMediaType_GetItem(media_type, &MF_MT_VIDEO_ROTATION, NULL);
is_win7 = broken(FAILED(hr));
check_media_type(media_type, is_win7 ? default_outputs_win7[i] : default_outputs_extra[i], -1);
ret = IMFMediaType_Release(media_type);
ok(ret == 0, "Release returned %lu\n", ret);
winetest_pop_context();
@ -7553,8 +7496,8 @@ static void test_h264_decoder(void)
init_media_type(media_type, minimal_output_type_desc, i + 1);
}
hr = IMFTransform_SetOutputType(transform, 0, media_type, 0);
ok(hr == (is_win7 ? MF_E_INVALIDMEDIATYPE : S_OK), "SetOutputType returned %#lx.\n", hr);
init_media_type(media_type, is_win7 ? output_type_desc_win7 : output_type_desc, -1);
ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr);
init_media_type(media_type, output_type_desc, -1);
hr = IMFTransform_SetOutputType(transform, 0, media_type, 0);
ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr);
ret = IMFMediaType_Release(media_type);
@ -7562,7 +7505,7 @@ static void test_h264_decoder(void)
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == S_OK, "GetOutputCurrentType returned %#lx\n", hr);
check_media_type(media_type, is_win7 ? output_type_desc_win7 : output_type_desc, -1);
check_media_type(media_type, output_type_desc, -1);
ret = IMFMediaType_Release(media_type);
ok(ret == 0, "Release returned %lu\n", ret);
@ -7574,7 +7517,6 @@ static void test_h264_decoder(void)
winetest_push_context("out %lu", i);
ok(hr == S_OK, "GetOutputAvailableType returned %#lx\n", hr);
check_media_type(media_type, default_outputs[i], -1);
check_media_type(media_type, is_win7 ? default_outputs_win7[i] : default_outputs_extra[i], -1);
ret = IMFMediaType_Release(media_type);
ok(ret == 0, "Release returned %lu\n", ret);
winetest_pop_context();
@ -7598,8 +7540,7 @@ static void test_h264_decoder(void)
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 == 1920 * 1080 * 2 || broken(output_info.cbSize == 1920 * 1088 * 2) /* Win7 */,
"got cbSize %#lx\n", output_info.cbSize);
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);
input_count = output_count = 0xdeadbeef;
@ -7710,7 +7651,7 @@ static void test_h264_decoder(void)
/* current output type is still the one we selected */
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == S_OK, "GetOutputCurrentType returned %#lx\n", hr);
check_media_type(media_type, is_win7 ? output_type_desc_win7 : output_type_desc, -1);
check_media_type(media_type, output_type_desc, -1);
hr = IMFMediaType_GetItemType(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, NULL);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "GetItemType returned %#lx\n", hr);
ret = IMFMediaType_Release(media_type);
@ -7794,10 +7735,10 @@ static void test_h264_decoder(void)
/* we can change it, but only with the correct frame size */
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "MFCreateMediaType returned %#lx\n", hr);
init_media_type(media_type, is_win7 ? output_type_desc_win7 : output_type_desc, -1);
init_media_type(media_type, output_type_desc, -1);
hr = IMFTransform_SetOutputType(transform, 0, media_type, 0);
ok(hr == MF_E_INVALIDMEDIATYPE, "SetOutputType returned %#lx.\n", hr);
init_media_type(media_type, is_win7 ? new_output_type_desc_win7 : new_output_type_desc, -1);
init_media_type(media_type, new_output_type_desc, -1);
hr = IMFTransform_SetOutputType(transform, 0, media_type, 0);
ok(hr == S_OK, "SetOutputType returned %#lx.\n", hr);
ret = IMFMediaType_Release(media_type);
@ -7805,7 +7746,7 @@ static void test_h264_decoder(void)
hr = IMFTransform_GetOutputCurrentType(transform, 0, &media_type);
ok(hr == S_OK, "GetOutputCurrentType returned %#lx\n", hr);
check_media_type(media_type, is_win7 ? new_output_type_desc_win7 : new_output_type_desc, -1);
check_media_type(media_type, new_output_type_desc, -1);
hr = IMFMediaType_GetItemType(media_type, &MF_MT_MINIMUM_DISPLAY_APERTURE, NULL);
ok(hr == MF_E_ATTRIBUTENOTFOUND, "GetItemType returned %#lx\n", hr);
ret = IMFMediaType_Release(media_type);

View file

@ -401,6 +401,7 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
{
struct h264_decoder *decoder = impl_from_IMFTransform(iface);
GUID major, subtype;
UINT64 frame_size;
HRESULT hr;
ULONG i;
@ -429,6 +430,12 @@ static HRESULT WINAPI transform_SetInputType(IMFTransform *iface, DWORD id, IMFM
IMFMediaType_Release(decoder->input_type);
IMFMediaType_AddRef((decoder->input_type = type));
if (SUCCEEDED(IMFMediaType_GetUINT64(type, &MF_MT_FRAME_SIZE, &frame_size)))
{
decoder->wg_format.u.video.width = frame_size >> 32;
decoder->wg_format.u.video.height = (UINT32)frame_size;
}
return S_OK;
}