Performance issues can occur when a video output sample has a 2D buffer, because winegstreamer currently outputs only to a linear buffer, which must then be copied into the 2D buffer. Worse, a linear lock of the 2D buffer requires the current contents to be copied to a linear buffer, even when we intend to overwrite it, because MF linear buffers do not support write-only locking.
-- v4: mf/tests: Test H.264 sink media type height alignment. winegstreamer: Support 2D sample buffer. mf: Test color convert 2D buffers. mf: Test WMV decoder 2D buffers. mf: Test H.264 decoder 2D buffers. mf: Test sample copier 2D buffers. mfplat/tests: Test NV12 negative stride in MFCreateMediaBufferFromMediaType(). mf/tests: Remove todo for an H.264 decoder test. mf/tests: Stop checking samples at the end of the expected array.
From: Conor McCarthy cmccarthy@codeweavers.com
Prevents crashing in test_h264_decoder_concat_streams() when too many samples are emitted. --- dlls/mf/tests/transform.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 8a80275b8d5..6a1272f7145 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -1164,7 +1164,8 @@ static void enum_mf_media_buffers(IMFSample *sample, const struct sample_desc *s ok(hr == S_OK, "GetBufferByIndex returned %#lx\n", hr); ok(i < sample_desc->buffer_count, "got unexpected buffer\n");
- callback(buffer, sample_desc->buffers + i, context); + if (i < sample_desc->buffer_count) + callback(buffer, sample_desc->buffers + i, context);
IMFMediaBuffer_Release(buffer); winetest_pop_context(); @@ -1200,6 +1201,8 @@ static void enum_mf_samples(IMFCollection *samples, const struct sample_desc *co
IMFSample_Release(sample); winetest_pop_context(); + if (!state.sample.buffer_count) + break; } ok(hr == E_INVALIDARG, "GetElement returned %#lx\n", hr); }
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mf/tests/transform.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 6a1272f7145..f4b53e6e382 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -5051,7 +5051,6 @@ static void test_h264_decoder(void) ok(ref == 1, "Release returned %ld\n", ref);
ret = check_mf_sample_collection(output_samples, &expect_output_sample_i420, L"i420frame.bmp"); - todo_wine /* wg_transform_set_output_format() should convert already processed samples instead of dropping */ ok(ret == 0, "got %lu%% diff\n", ret); IMFCollection_Release(output_samples);
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mfplat/tests/mfplat.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 21bcc86c8d1..34b58f942d9 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -8167,6 +8167,40 @@ static void test_MFCreateMediaBufferFromMediaType(void)
IMFMediaBuffer_Release(buffer);
+ hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFVideoFormat_NV12); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT64(media_type, &MF_MT_FRAME_SIZE, (UINT64)96 << 32 | 96); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, 96); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = pMFCreateMediaBufferFromMediaType(media_type, 0, 0, 0, &buffer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&buffer_2d); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMF2DBuffer_Lock2D(buffer_2d, &data, &pitch); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(pitch == 128, "got pitch %ld.\n", pitch); + hr = IMF2DBuffer_Unlock2D(buffer_2d); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMF2DBuffer_Release(buffer_2d); + + IMFMediaBuffer_Release(buffer); + + /* A linear buffer is created for YUV if MF_MT_DEFAULT_STRIDE is negative */ + hr = IMFMediaType_SetUINT32(media_type, &MF_MT_DEFAULT_STRIDE, -128); + ok(hr == S_OK, "Failed to set attribute, hr %#lx.\n", hr); + hr = pMFCreateMediaBufferFromMediaType(media_type, 0, 0, 0, &buffer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaBuffer_QueryInterface(buffer, &IID_IMF2DBuffer, (void **)&buffer_2d); + todo_wine + ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + IMF2DBuffer_Release(buffer_2d); + + IMFMediaBuffer_Release(buffer); + /* MF_MT_FRAME_SIZE doesn't work with compressed formats */ hr = IMFMediaType_DeleteItem(media_type, &MF_MT_FRAME_SIZE); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mf/tests/transform.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index f4b53e6e382..754f27cf42b 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -1756,7 +1756,7 @@ static BOOL is_sample_copier_available_type(IMFMediaType *type) return IsEqualGUID(&major, &MFMediaType_Video) || IsEqualGUID(&major, &MFMediaType_Audio); }
-static void test_sample_copier(void) +static void test_sample_copier(BOOL use_2d_buffer) { static const struct attribute_desc expect_transform_attributes[] = { @@ -1779,8 +1779,13 @@ static void test_sample_copier(void) win_skip("MFCreateSampleCopierMFT() is not available.\n"); return; } + if (use_2d_buffer && !pMFCreateMediaBufferFromMediaType) + { + win_skip("MFCreateMediaBufferFromMediaType() is unsupported.\n"); + return; + }
- winetest_push_context("copier"); + winetest_push_context("copier %s", use_2d_buffer ? "2d" : "1d");
hr = pMFCreateSampleCopierMFT(&copier); ok(hr == S_OK, "Failed to create sample copier, hr %#lx.\n", hr); @@ -1910,7 +1915,10 @@ static void test_sample_copier(void) ok(!flags, "Unexpected flags %#lx.\n", flags);
/* Pushing samples. */ - hr = MFCreateAlignedMemoryBuffer(output_info.cbSize, output_info.cbAlignment, &media_buffer); + if (use_2d_buffer) + hr = pMFCreateMediaBufferFromMediaType(mediatype, 0, 0, 0, &media_buffer); + else + hr = MFCreateAlignedMemoryBuffer(output_info.cbSize, output_info.cbAlignment, &media_buffer); ok(hr == S_OK, "Failed to create media buffer, hr %#lx.\n", hr);
hr = IMFSample_AddBuffer(sample, media_buffer); @@ -11144,7 +11152,8 @@ START_TEST(transform)
init_functions();
- test_sample_copier(); + test_sample_copier(FALSE); + test_sample_copier(TRUE); test_sample_copier_output_processing(); test_aac_encoder(); test_aac_decoder();
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mf/tests/i420frame-2d.bmp | Bin 0 -> 67638 bytes dlls/mf/tests/resource.rc | 4 ++ dlls/mf/tests/transform.c | 108 +++++++++++++++++++++++++++++---- 3 files changed, 99 insertions(+), 13 deletions(-) create mode 100644 dlls/mf/tests/i420frame-2d.bmp
diff --git a/dlls/mf/tests/i420frame-2d.bmp b/dlls/mf/tests/i420frame-2d.bmp new file mode 100644 index 0000000000000000000000000000000000000000..90889b2dbe858574bc4ab1afe1ace6fccea3bd7a GIT binary patch literal 67638 zcmZ?rH9Non24)Nl3>pj!3=Iqn3<(Sj42%p4U~vYhJcI)wUpF-TAH@R~24~Nn{XdX+ zH0}p3?m=NckZ}*P8{~#jJaB0M6bA!|N8^6r;vN+C0~z-qyFqRk#RHcHKyfgTcr@+@ zF782LKag<`vK!=vQ9N*I02BuUiAUpp;Nl(>_5&IBAiF_s7{vpZ20(Ezka#ri2QKbG zVLy;@53(ENhEY6lX#f-l1BplDe&FIB6!rrd_aM732~7GwiU%$XKyfgTcr@+@F782L zKag<`vK!=vQ9N*I02BuUiAUpp;Nl(>_5&IBAiF_s7{vpZ20(Ezka#ri2QKbGVLy;@ z53(ENhEY6lX#f-l1BplDe&FIB6!rrd_aM7LZWzS_mj*y_FpzjO?guXJL190TaSyT^ z<c3i^aA^P(2Lp*m<9^`c9u)Qi8TTN&S1l9xKZ*w~3_x)(ka#ri2QKbGVLy;@53(EN zhEY6lX#f-l1BplDe&FIB6!rrd_aM7LZWzS_mj*y_FpzjO?guXJL190TaSyT^<c3i^ zaA^P(2Lp*m<9^`c9u)Qi8TTN&L2eku1D6IsaWIg0H0}p3?m=NckZ}*P8{~#jJaB0M z6bA!|N8^6r;vN+C0~z-qyC<3{{U5~x7Y3j>7)U%C_X8LAps*jvxChw{a>FPdxHJHY zgMq}OaX)Zz4+{H%jC+vXAUBNSflC9RI2cGg8utSi_n@#J$hZgD4RXUM9=J3Bii3f~ zqj5iQaSsanfsA{Q-5@uN;(<#8pg0&vJR0`{7x$pBAIP`|*$r~TC?2>p0E&Zw#G`RP zaB&X``+<ymklk6Q?)@Ld0~ZFMI2cGg8utSi_n@#J$hZgD4RXUM9=J3Bii3f~qj5iQ zaSsanfsA{Q-5@uN;(<#8pg0&vJR0`{7x$pBAIP`|*$r~TC?2>p0E&Zw#G`RPaB&X` z`+<ymkli3RjN*Yy1E4q<NIV+%0~hz8uph{{2iXmB!zdoOGysZ&fyAS6KX7pm3j2YK zdyw6MQ6K(~;(-eTP#g>-9*z5fi+fPm4`kef>;}1E6c1b)0L8&T;?cMtxVQ&}{XoV& z$Zn7uM)AO<0Z<$aBp!|Xfs1=k*bijfgX{*mVH6Ks8UV$?K;qH3AGo*&h5bOrJ;-j5 z8%FWKr2$YJ3?v?n`+<vlP}mP-+=J`}xnUF!Tp9qy!9e2CxF5K<2ZjAW#y!Yx%@2A1 zNAbXg0Voaz5|76Hz{Nc%><2RLL3V@OFp38*4S?ccAn|D24_w@X!hRs*9%MJj4WoGA z(f}w91`?0P{lLXNDC`F^?m>2g+%Sp<E)9U<U?A~m+z(vbgTj6w;~r!;$PJ@-;L-pn z4h9mB#{Iy>Jt*u4GVVckgWNER2QCeO;$R^0XxtB6+=Ie?AmbinH^>d6c;M0iC=Lb^ zkH-DL#XTtO2QuzKc7xn7iU%$YfZ|{v@o3x+T-<}gejwu>WH-nSqj=!b04NRy5|76H zz{Nc%><2RLL3V@OFp38*4S?ccAn|D24_w@X!hRs*9%MJj4WoGA(f}w91`?0P{lLXN zDC`F^?m>2g+%Sp<E)9U<U?A~m+z(vbgTj6w;~r%9YZ`;I1OSb#e@(#pv!nLYHUvh) zAAbnYHuPVQrhojwKjQQMB^m<)!GD&<)?XU6AAbmphCgjX0DtJ89ZmnV4gS&mPapxV zqA?&~{aG4YziQNe{2?$J{<IAN{Goq#H2u>y_($_Ufdn{_#(;qJXK8Hx#8Lb4hrnp~ z(>4U~hyK~o^iSL1AI<*+5?~gM0RijJ(%AZ}QTy?Sz-ai>HU#j8{@Ky=Put)h&Hn@v zU?7bF0qf7w*!sXx`|*dsX!z4M1n`Ic+0pb*+u$F~{{#}CCXE3B>(A2Idd*S$@rS@@ z_|rB7@Q41{(ezK-;2+KZ1QH;PgMT#qN5da)2#lsb+J*q$z&|@$|Ijw{H3xn9*FYjb zPfsLjZy42&8Ug|&0#w~+&yuKJU{pV92rMHJpz1z*mPGB#M)jkHfEkGZRrlGmBx*Ms z)sGqir$_{-y3d{^QTwS;{iq=jMIu1eefBJg+M`DGqlUl-5&^32vu8=v{$W%<Y6y&m zA88?g8hVtcztQ$PX(50f{-o({!07)>A`zh5Ponloqxw<7X#a_{5I_w*%KM*6Bm#8% zNz|@1svk83?vV&kb)P*;qV{{E`cXrGwA%l}X!{X0_$Y3F=aC4|tUpVl_PkO3s39;K Pex!u}YUrJ%IQ;<t8njuL
literal 0 HcmV?d00001
diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc index dff5719dd3b..2efb52d91ae 100644 --- a/dlls/mf/tests/resource.rc +++ b/dlls/mf/tests/resource.rc @@ -121,6 +121,10 @@ nv12frame-flip-2d.bmp RCDATA nv12frame-flip-2d.bmp /* @makedep: i420frame.bmp */ i420frame.bmp RCDATA i420frame.bmp
+/* Generated from running the tests on Windows */ +/* @makedep: i420frame.bmp */ +i420frame-2d.bmp RCDATA i420frame-2d.bmp + /* Generated from running the tests on Windows */ /* @makedep: rgb32frame.bmp */ rgb32frame.bmp RCDATA rgb32frame.bmp diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 754f27cf42b..bc3f85ae3e5 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -4477,7 +4477,7 @@ failed: CoUninitialize(); }
-static void test_h264_decoder(void) +static void test_h264_decoder(BOOL use_2d_buffer) { const GUID *const class_id = &CLSID_MSH264DecoderMFT; const struct transform_info expect_mft_info = @@ -4519,7 +4519,7 @@ static void test_h264_decoder(void) ATTR_UINT32(CODECAPI_AVDecVideoAcceleration_H264, 1), {0}, }; - static const DWORD input_width = 120, input_height = 248; + static const DWORD input_width = 120, input_height = 248, aligned_width_2d = 128; const media_type_desc default_outputs[] = { { @@ -4763,6 +4763,20 @@ static void test_h264_decoder(void) .cbSize = 0x1000, };
+ const struct attribute_desc nv12_default_stride[] = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), + {0}, + }; + const struct attribute_desc i420_default_stride[] = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video, .required = TRUE), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_I420, .required = TRUE), + ATTR_RATIO(MF_MT_FRAME_SIZE, actual_width, actual_height, .required = TRUE), + {0}, + }; const struct attribute_desc output_sample_attributes[] = { ATTR_UINT32(MFSampleExtension_CleanPoint, 1), @@ -4780,6 +4794,25 @@ static void test_h264_decoder(void) .sample_time = 0, .sample_duration = 333667, .buffer_count = 1, .buffers = &output_buffer_desc_nv12, }; + const struct sample_desc output_sample_desc_nv12_1d = + { + .attributes = output_sample_attributes, + .sample_time = 0, .sample_duration = 333667, + .total_length = aligned_width_2d * actual_height * 3 / 2, + .buffer_count = 1, .buffers = &output_buffer_desc_nv12, .todo_length = TRUE, + }; + const struct buffer_desc output_buffer_desc_nv12_2d = + { + .length = aligned_width_2d * actual_height * 3 / 2, + .compare = compare_nv12, .compare_rect = {.right = 82, .bottom = 84}, + .dump = dump_nv12, .size = {.cx = aligned_width_2d, .cy = actual_height}, + }; + const struct sample_desc output_sample_desc_nv12_2d = + { + .attributes = output_sample_attributes, + .sample_time = 0, .sample_duration = 333667, + .buffer_count = 1, .buffers = &output_buffer_desc_nv12_2d, + }; const struct buffer_desc output_buffer_desc_i420 = { .length = actual_width * actual_height * 3 / 2, @@ -4792,9 +4825,29 @@ static void test_h264_decoder(void) .sample_time = 333667, .sample_duration = 333667, .buffer_count = 1, .buffers = &output_buffer_desc_i420, }; + const struct sample_desc output_sample_desc_i420_1d = + { + .attributes = output_sample_attributes, + .sample_time = 333667, .sample_duration = 333667, + .total_length = aligned_width_2d * actual_height * 3 / 2, + .buffer_count = 1, .buffers = &output_buffer_desc_i420, .todo_length = TRUE, + }; + const struct buffer_desc output_buffer_desc_i420_2d = + { + .length = aligned_width_2d * actual_height * 3 / 2, + .compare = compare_i420, .compare_rect = {.right = 82, .bottom = 84}, + .dump = dump_i420, .size = {.cx = aligned_width_2d, .cy = actual_height}, + }; + const struct sample_desc output_sample_desc_i420_2d = + { + .attributes = output_sample_attributes, + .sample_time = 333667, .sample_duration = 333667, + .buffer_count = 1, .buffers = &output_buffer_desc_i420_2d, + };
MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_H264}; MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; + const struct attribute_desc *sample_attr_desc; IMFSample *input_sample, *output_sample; const BYTE *h264_encoded_data; IMFCollection *output_samples; @@ -4807,10 +4860,16 @@ static void test_h264_decoder(void) DWORD flags; HRESULT hr;
+ if (use_2d_buffer && !pMFCreateMediaBufferFromMediaType) + { + win_skip("MFCreateMediaBufferFromMediaType() is unsupported.\n"); + return; + } + hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- winetest_push_context("h264dec"); + winetest_push_context("h264dec %s", use_2d_buffer ? "2d" : "1d");
if (!check_mft_enum(MFT_CATEGORY_VIDEO_DECODER, &input_type, &output_type, class_id)) goto failed; @@ -4919,10 +4978,11 @@ static void test_h264_decoder(void) ok(output_status == 0, "got output[0].dwStatus %#lx\n", output_status);
i = 0; + sample_attr_desc = use_2d_buffer ? nv12_default_stride : NULL; input_sample = next_h264_sample(&h264_encoded_data, &h264_encoded_data_len); while (1) { - output_sample = create_sample(NULL, output_info.cbSize); + output_sample = create_sample_(NULL, actual_width * actual_height * 3 / 2, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); if (hr != MF_E_TRANSFORM_NEED_MORE_INPUT) break;
@@ -4992,7 +5052,7 @@ static void test_h264_decoder(void) hr = MFCreateCollection(&output_samples); ok(hr == S_OK, "MFCreateCollection returned %#lx\n", hr);
- output_sample = create_sample(NULL, output_info.cbSize); + output_sample = create_sample_(NULL, actual_width * actual_height * 3 / 2, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); ok(hr == S_OK, "ProcessOutput returned %#lx\n", hr); ok(output_status == 0, "got output[0].dwStatus %#lx\n", output_status); @@ -5001,8 +5061,18 @@ static void test_h264_decoder(void) ref = IMFSample_Release(output_sample); ok(ref == 1, "Release returned %ld\n", ref);
- ret = check_mf_sample_collection(output_samples, &output_sample_desc_nv12, L"nv12frame.bmp"); - ok(ret == 0, "got %lu%% diff\n", ret); + if (!use_2d_buffer) + { + ret = check_mf_sample_collection(output_samples, &output_sample_desc_nv12, L"nv12frame.bmp"); + ok(ret == 0, "got %lu%% diff\n", ret); + } + else + { + ret = check_mf_sample_collection(output_samples, &output_sample_desc_nv12_1d, L"nv12frame.bmp"); + ok(ret == 0, "got %lu%% diff\n", ret); + ret = check_2d_mf_sample_collection(output_samples, &output_sample_desc_nv12_2d, L"nv12frame-2d.bmp"); + ok(ret == 0, "2d got %lu%% diff\n", ret); + } IMFCollection_Release(output_samples);
/* we can change it, but only with the correct frame size */ @@ -5019,7 +5089,8 @@ static void test_h264_decoder(void)
check_mft_get_output_current_type_(__LINE__, transform, expect_new_output_type_desc, FALSE, TRUE);
- output_sample = create_sample(NULL, actual_width * actual_height * 2); + sample_attr_desc = use_2d_buffer ? i420_default_stride : NULL; + output_sample = create_sample_(NULL, actual_width * actual_height * 3 / 2, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); todo_wine ok(hr == MF_E_TRANSFORM_STREAM_CHANGE, "ProcessOutput returned %#lx\n", hr); @@ -5049,7 +5120,7 @@ static void test_h264_decoder(void) hr = MFCreateCollection(&output_samples); ok(hr == S_OK, "MFCreateCollection returned %#lx\n", hr);
- output_sample = create_sample(NULL, actual_width * actual_height * 2); + output_sample = create_sample_(NULL, actual_width * actual_height * 3 / 2, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); ok(hr == S_OK, "ProcessOutput returned %#lx\n", hr); ok(output_status == 0, "got output[0].dwStatus %#lx\n", output_status); @@ -5058,11 +5129,21 @@ static void test_h264_decoder(void) ref = IMFSample_Release(output_sample); ok(ref == 1, "Release returned %ld\n", ref);
- ret = check_mf_sample_collection(output_samples, &expect_output_sample_i420, L"i420frame.bmp"); - ok(ret == 0, "got %lu%% diff\n", ret); + if (!use_2d_buffer) + { + ret = check_mf_sample_collection(output_samples, &expect_output_sample_i420, L"i420frame.bmp"); + ok(ret == 0, "got %lu%% diff\n", ret); + } + else + { + ret = check_mf_sample_collection(output_samples, &output_sample_desc_i420_1d, L"i420frame.bmp"); + ok(ret == 0, "got %lu%% diff\n", ret); + ret = check_2d_mf_sample_collection(output_samples, &output_sample_desc_i420_2d, L"i420frame-2d.bmp"); + ok(ret == 0, "2d got %lu%% diff\n", ret); + } IMFCollection_Release(output_samples);
- output_sample = create_sample(NULL, actual_width * actual_height * 2); + output_sample = create_sample_(NULL, actual_width * actual_height * 3 / 2, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); todo_wine_if(hr == S_OK) /* when VA-API plugin is used */ ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); @@ -11163,7 +11244,8 @@ START_TEST(transform) test_wma_decoder_dmo_input_type(); test_wma_decoder_dmo_output_type(); test_h264_encoder(); - test_h264_decoder(); + test_h264_decoder(FALSE); + test_h264_decoder(TRUE); test_h264_decoder_timestamps(); test_wmv_encoder(); test_wmv_decoder();
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mf/tests/transform.c | 75 ++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 9 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index bc3f85ae3e5..a317e6fec6c 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -6654,7 +6654,7 @@ failed: CoUninitialize(); }
-static void test_wmv_decoder(void) +static void test_wmv_decoder(BOOL use_2d_buffer) { const GUID *const class_id = &CLSID_CWMVDecMediaObject; const struct transform_info expect_mft_info = @@ -6737,7 +6737,7 @@ static void test_wmv_decoder(void) {ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_VC1S)}, }; static const MFVideoArea actual_aperture = {.Area={96,96}}; - static const DWORD actual_width = 96, actual_height = 96; + static const DWORD actual_width = 96, actual_height = 96, nv12_aligned_width = 128; const struct attribute_desc expect_output_attributes[] = { ATTR_BLOB(MF_MT_GEOMETRIC_APERTURE, &actual_aperture, sizeof(actual_aperture)), @@ -6984,6 +6984,12 @@ static void test_wmv_decoder(void) .compare = compare_nv12, .compare_rect = {.right = 82, .bottom = 84}, .dump = dump_nv12, .size = {.cx = actual_width, .cy = actual_height}, }; + const struct buffer_desc output_buffer_desc_nv12_2d = + { + .length = nv12_aligned_width * actual_height * 3 / 2, + .compare = compare_nv12, .compare_rect = {.right = 82, .bottom = 84}, + .dump = dump_nv12, .size = {.cx = nv12_aligned_width, .cy = actual_height}, + }; const struct buffer_desc output_buffer_desc_rgb = { .length = actual_width * actual_height * 4, @@ -6996,6 +7002,12 @@ static void test_wmv_decoder(void) .sample_time = 0, .sample_duration = 333333, .buffer_count = 1, .buffers = &output_buffer_desc_nv12, }; + const struct sample_desc output_sample_desc_nv12_2d = + { + .attributes = output_sample_attributes, + .sample_time = 0, .sample_duration = 333333, + .buffer_count = 1, .buffers = &output_buffer_desc_nv12_2d, + }; const struct sample_desc output_sample_desc_rgb = { .attributes = output_sample_attributes, @@ -7010,8 +7022,11 @@ static void test_wmv_decoder(void) const MFT_INPUT_STREAM_INFO *expect_input_info; const MFT_OUTPUT_STREAM_INFO *expect_output_info; const struct sample_desc *output_sample_desc; + const struct sample_desc *output_sample_desc_2d; const WCHAR *result_bitmap; + const WCHAR *result_bitmap_2d; ULONG delta; + BOOL skip_; BOOL new_transform; BOOL todo; } @@ -7024,7 +7039,9 @@ static void test_wmv_decoder(void) .expect_input_info = &expect_input_info, .expect_output_info = &expect_output_info, .output_sample_desc = &output_sample_desc_nv12, + .output_sample_desc_2d = &output_sample_desc_nv12_2d, .result_bitmap = L"nv12frame.bmp", + .result_bitmap_2d = L"nv12frame-2d.bmp", .delta = 0, },
@@ -7037,6 +7054,19 @@ static void test_wmv_decoder(void) .output_sample_desc = &output_sample_desc_nv12, .result_bitmap = L"nv12frame.bmp", .delta = 0, + .skip_ = use_2d_buffer, /* negative stride is invalid for 2D YUV */ + }, + + { + /* WMV1 -> RGB (negative stride) instead of YUV for 2D */ + .output_type_desc = output_type_desc_rgb_negative_stride, + .expect_output_type_desc = expect_output_type_desc_rgb_negative_stride, + .expect_input_info = &expect_input_info_rgb, + .expect_output_info = &expect_output_info_rgb, + .output_sample_desc = &output_sample_desc_rgb, + .result_bitmap = L"rgb32frame-flip.bmp", + .delta = 5, + .skip_ = !use_2d_buffer, },
{ @@ -7046,8 +7076,9 @@ static void test_wmv_decoder(void) .expect_input_info = &expect_input_info_rgb, .expect_output_info = &expect_output_info_rgb, .output_sample_desc = &output_sample_desc_rgb, - .result_bitmap = L"rgb32frame-flip.bmp", + .result_bitmap = use_2d_buffer ? L"rgb32frame.bmp" : L"rgb32frame-flip.bmp", .delta = 5, + .todo = use_2d_buffer, },
{ @@ -7068,8 +7099,9 @@ static void test_wmv_decoder(void) .expect_input_info = &expect_input_info_rgb, .expect_output_info = &expect_output_info_rgb, .output_sample_desc = &output_sample_desc_rgb, - .result_bitmap = L"rgb32frame-flip.bmp", + .result_bitmap = use_2d_buffer ? L"rgb32frame.bmp" : L"rgb32frame-flip.bmp", .delta = 5, + .todo = use_2d_buffer, },
{ @@ -7091,8 +7123,9 @@ static void test_wmv_decoder(void) .expect_input_info = &expect_input_info_rgb, .expect_output_info = &expect_output_info_rgb, .output_sample_desc = &output_sample_desc_rgb, - .result_bitmap = L"rgb32frame.bmp", + .result_bitmap = use_2d_buffer ? L"rgb32frame-flip.bmp" : L"rgb32frame.bmp", .delta = 5, + .todo = use_2d_buffer, },
{ @@ -7122,6 +7155,7 @@ static void test_wmv_decoder(void)
MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_WMV1}; + const struct attribute_desc *sample_attr_desc; IMFSample *input_sample, *output_sample; MFT_OUTPUT_STREAM_INFO output_info; MFT_INPUT_STREAM_INFO input_info; @@ -7134,10 +7168,16 @@ static void test_wmv_decoder(void) ULONG i, j, ret, ref; HRESULT hr;
+ if (use_2d_buffer && !pMFCreateMediaBufferFromMediaType) + { + win_skip("MFCreateMediaBufferFromMediaType() is unsupported.\n"); + return; + } + hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- winetest_push_context("wmvdec"); + winetest_push_context("wmvdec %s", use_2d_buffer ? "2d" : "1d");
if (!has_video_processor) { @@ -7240,6 +7280,12 @@ static void test_wmv_decoder(void) check_mft_set_input_type(transform, input_type_desc, S_OK); }
+ if (transform_tests[j].skip_) + { + winetest_pop_context(); + continue; + } + check_mft_set_output_type_required(transform, transform_tests[j].output_type_desc); check_mft_set_output_type(transform, transform_tests[j].output_type_desc, S_OK); check_mft_get_output_current_type_(__LINE__, transform, transform_tests[j].expect_output_type_desc, FALSE, TRUE); @@ -7282,7 +7328,8 @@ static void test_wmv_decoder(void) hr = MFCreateCollection(&output_samples); ok(hr == S_OK, "MFCreateCollection returned %#lx\n", hr);
- output_sample = create_sample(NULL, transform_tests[j].expect_output_info->cbSize); + sample_attr_desc = use_2d_buffer ? transform_tests[j].output_type_desc : NULL; + output_sample = create_sample_(NULL, transform_tests[j].expect_output_info->cbSize, sample_attr_desc); for (i = 0; SUCCEEDED(hr = check_mft_process_output(transform, output_sample, &output_status)); i++) { winetest_push_context("%lu", i); @@ -7291,7 +7338,7 @@ static void test_wmv_decoder(void) ok(hr == S_OK, "AddElement returned %#lx\n", hr); ref = IMFSample_Release(output_sample); ok(ref == 1, "Release returned %ld\n", ref); - output_sample = create_sample(NULL, transform_tests[j].expect_output_info->cbSize); + output_sample = create_sample_(NULL, transform_tests[j].expect_output_info->cbSize, sample_attr_desc); winetest_pop_context(); } ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); @@ -7303,6 +7350,15 @@ static void test_wmv_decoder(void) transform_tests[j].result_bitmap); todo_wine_if(transform_tests[j].todo) ok(ret <= transform_tests[j].delta, "got %lu%% diff\n", ret); + if (use_2d_buffer) + { + ret = check_2d_mf_sample_collection(output_samples, transform_tests[j].output_sample_desc_2d + ? transform_tests[j].output_sample_desc_2d : transform_tests[j].output_sample_desc, + transform_tests[j].result_bitmap_2d ? transform_tests[j].result_bitmap_2d + : transform_tests[j].result_bitmap); + todo_wine_if(transform_tests[j].todo) + ok(ret <= transform_tests[j].delta, "got %lu%% diff\n", ret); + } IMFCollection_Release(output_samples);
hr = IMFTransform_SetOutputType(transform, 0, NULL, 0); @@ -11248,7 +11304,8 @@ START_TEST(transform) test_h264_decoder(TRUE); test_h264_decoder_timestamps(); test_wmv_encoder(); - test_wmv_decoder(); + test_wmv_decoder(FALSE); + test_wmv_decoder(TRUE); test_wmv_decoder_timestamps(); test_wmv_decoder_dmo_input_type(); test_wmv_decoder_dmo_output_type();
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/mf/tests/transform.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index a317e6fec6c..1be319a7ba5 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -8408,7 +8408,7 @@ static void test_wmv_decoder_media_object(void) winetest_pop_context(); }
-static void test_color_convert(void) +static void test_color_convert(BOOL use_2d_buffer) { const GUID *const class_id = &CLSID_CColorConvertDMO; const struct transform_info expect_mft_info = @@ -8691,6 +8691,7 @@ static void test_color_convert(void)
MFT_REGISTER_TYPE_INFO output_type = {MFMediaType_Video, MFVideoFormat_NV12}; MFT_REGISTER_TYPE_INFO input_type = {MFMediaType_Video, MFVideoFormat_I420}; + const struct attribute_desc *sample_attr_desc; IMFSample *input_sample, *output_sample; IMFCollection *output_samples; DWORD length, output_status; @@ -8701,10 +8702,16 @@ static void test_color_convert(void) ULONG i, ret, ref; HRESULT hr;
+ if (use_2d_buffer && !pMFCreateMediaBufferFromMediaType) + { + win_skip("MFCreateMediaBufferFromMediaType() is unsupported.\n"); + return; + } + hr = CoInitialize(NULL); ok(hr == S_OK, "Failed to initialize, hr %#lx.\n", hr);
- winetest_push_context("colorconv"); + winetest_push_context("colorconv %s", use_2d_buffer ? "2d" : "1d");
if (!check_mft_enum(MFT_CATEGORY_VIDEO_EFFECT, &input_type, &output_type, class_id)) goto failed; @@ -8795,7 +8802,8 @@ static void test_color_convert(void) hr = MFCreateCollection(&output_samples); ok(hr == S_OK, "MFCreateCollection returned %#lx\n", hr);
- output_sample = create_sample(NULL, output_info.cbSize); + sample_attr_desc = use_2d_buffer ? color_conversion_tests[i].output_type_desc : NULL; + output_sample = create_sample_(NULL, output_info.cbSize, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); ok(hr == S_OK, "ProcessOutput returned %#lx\n", hr); ok(output_status == 0, "got output[0].dwStatus %#lx\n", output_status); @@ -8806,15 +8814,20 @@ static void test_color_convert(void)
ret = check_mf_sample_collection(output_samples, &output_sample_desc, color_conversion_tests[i].result_bitmap); ok(ret <= color_conversion_tests[i].delta, "got %lu%% diff\n", ret); + if (use_2d_buffer) + { + ret = check_2d_mf_sample_collection(output_samples, &output_sample_desc, color_conversion_tests[i].result_bitmap); + ok(ret <= color_conversion_tests[i].delta, "got %lu%% diff\n", ret); + } IMFCollection_Release(output_samples);
- output_sample = create_sample(NULL, output_info.cbSize); + output_sample = create_sample_(NULL, output_info.cbSize, sample_attr_desc); hr = check_mft_process_output(transform, output_sample, &output_status); ok(hr == MF_E_TRANSFORM_NEED_MORE_INPUT, "ProcessOutput returned %#lx\n", hr); ok(output_status == 0, "got output[0].dwStatus %#lx\n", output_status); hr = IMFSample_GetTotalLength(output_sample, &length); ok(hr == S_OK, "GetTotalLength returned %#lx\n", hr); - ok(length == 0, "got length %lu\n", length); + ok(length == 0 || broken(use_2d_buffer && length == output_info.cbSize), "got length %lu\n", length); ret = IMFSample_Release(output_sample); ok(ret == 0, "Release returned %lu\n", ret); winetest_pop_context(); @@ -11312,7 +11325,8 @@ START_TEST(transform) test_wmv_decoder_dmo_get_size_info(); test_wmv_decoder_media_object(); test_audio_convert(); - test_color_convert(); + test_color_convert(FALSE); + test_color_convert(TRUE); test_video_processor(FALSE); test_video_processor(TRUE); test_mp3_decoder();
From: Conor McCarthy cmccarthy@codeweavers.com
Performance issues can occur when a video output sample has a 2D buffer, because winegstreamer currently outputs only to a linear buffer, which must then be copied into the 2D buffer. Worse, a linear lock of the 2D buffer requires the current contents to be copied to a linear buffer, even when we intend to overwrite it, because MF linear buffers do not support write-only locking. --- dlls/mf/tests/transform.c | 2 +- dlls/winegstreamer/aac_decoder.c | 2 +- dlls/winegstreamer/color_convert.c | 7 ++- dlls/winegstreamer/gst_private.h | 3 +- dlls/winegstreamer/resampler.c | 2 +- dlls/winegstreamer/unixlib.h | 2 + dlls/winegstreamer/video_decoder.c | 3 +- dlls/winegstreamer/video_encoder.c | 2 +- dlls/winegstreamer/video_processor.c | 5 ++- dlls/winegstreamer/wg_sample.c | 66 +++++++++++++++++++++++++--- dlls/winegstreamer/wg_transform.c | 42 +++++++++++++++--- dlls/winegstreamer/wma_decoder.c | 2 +- 12 files changed, 115 insertions(+), 23 deletions(-)
diff --git a/dlls/mf/tests/transform.c b/dlls/mf/tests/transform.c index 1be319a7ba5..4cfc2afde14 100644 --- a/dlls/mf/tests/transform.c +++ b/dlls/mf/tests/transform.c @@ -4799,7 +4799,7 @@ static void test_h264_decoder(BOOL use_2d_buffer) .attributes = output_sample_attributes, .sample_time = 0, .sample_duration = 333667, .total_length = aligned_width_2d * actual_height * 3 / 2, - .buffer_count = 1, .buffers = &output_buffer_desc_nv12, .todo_length = TRUE, + .buffer_count = 1, .buffers = &output_buffer_desc_nv12, }; const struct buffer_desc output_buffer_desc_nv12_2d = { diff --git a/dlls/winegstreamer/aac_decoder.c b/dlls/winegstreamer/aac_decoder.c index 9e6c5c20cb2..b78102bc1b0 100644 --- a/dlls/winegstreamer/aac_decoder.c +++ b/dlls/winegstreamer/aac_decoder.c @@ -558,7 +558,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, if (!samples->pSample) return E_INVALIDARG;
- if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample, &samples->dwStatus, NULL))) + if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample, 0, &samples->dwStatus, NULL))) wg_sample_queue_flush(decoder->wg_sample_queue, false); else samples->dwStatus = MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE; diff --git a/dlls/winegstreamer/color_convert.c b/dlls/winegstreamer/color_convert.c index 938d8b7b6f2..c5c7141f4ce 100644 --- a/dlls/winegstreamer/color_convert.c +++ b/dlls/winegstreamer/color_convert.c @@ -651,6 +651,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) { struct color_convert *impl = impl_from_IMFTransform(iface); + MFT_OUTPUT_STREAM_INFO info; HRESULT hr;
TRACE("iface %p, flags %#lx, count %lu, samples %p, status %p.\n", iface, flags, count, samples, status); @@ -665,7 +666,11 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, if (!samples->pSample) return E_INVALIDARG;
- if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample, &samples->dwStatus, NULL))) + if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) + return hr; + + if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample, + info.cbSize, &samples->dwStatus, NULL))) wg_sample_queue_flush(impl->wg_sample_queue, false);
return hr; diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 84b7db4a14c..d88b9c83635 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -164,7 +164,8 @@ HRESULT wg_transform_push_quartz(wg_transform_t transform, struct wg_sample *sam struct wg_sample_queue *queue); HRESULT wg_transform_push_dmo(wg_transform_t transform, IMediaBuffer *media_buffer, DWORD flags, REFERENCE_TIME time_stamp, REFERENCE_TIME time_length, struct wg_sample_queue *queue); -HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, DWORD *flags, bool *preserve_timestamps); +HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, + DWORD plane_size, DWORD *flags, bool *preserve_timestamps); HRESULT wg_transform_read_quartz(wg_transform_t transform, struct wg_sample *sample); HRESULT wg_transform_read_dmo(wg_transform_t transform, DMO_OUTPUT_DATA_BUFFER *buffer);
diff --git a/dlls/winegstreamer/resampler.c b/dlls/winegstreamer/resampler.c index 910d109c2c6..287d02a8015 100644 --- a/dlls/winegstreamer/resampler.c +++ b/dlls/winegstreamer/resampler.c @@ -536,7 +536,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, return MF_E_TRANSFORM_NEED_MORE_INPUT; }
- if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample, &samples->dwStatus, NULL))) + if (SUCCEEDED(hr = wg_transform_read_mf(impl->wg_transform, samples->pSample, 0, &samples->dwStatus, NULL))) wg_sample_queue_flush(impl->wg_sample_queue, false);
return hr; diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h index 179f15f78f7..5d11934fac2 100644 --- a/dlls/winegstreamer/unixlib.h +++ b/dlls/winegstreamer/unixlib.h @@ -192,6 +192,7 @@ struct wg_sample UINT32 flags; UINT32 max_size; UINT32 size; + UINT32 stride; UINT64 data; /* pointer to user memory */ };
@@ -334,6 +335,7 @@ struct wg_parser_stream_seek_params struct wg_transform_attrs { UINT32 output_plane_align; + UINT32 output_plane_stride; UINT32 input_queue_length; BOOL allow_format_change; BOOL low_latency; diff --git a/dlls/winegstreamer/video_decoder.c b/dlls/winegstreamer/video_decoder.c index becf148aeef..e56f7b9baf7 100644 --- a/dlls/winegstreamer/video_decoder.c +++ b/dlls/winegstreamer/video_decoder.c @@ -994,7 +994,8 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, } }
- if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, sample, &samples->dwStatus, &preserve_timestamps))) + if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, sample, + sample_size, &samples->dwStatus, &preserve_timestamps))) { wg_sample_queue_flush(decoder->wg_sample_queue, false);
diff --git a/dlls/winegstreamer/video_encoder.c b/dlls/winegstreamer/video_encoder.c index 41291928660..f26bec66c84 100644 --- a/dlls/winegstreamer/video_encoder.c +++ b/dlls/winegstreamer/video_encoder.c @@ -541,7 +541,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, if (!samples->pSample) return E_INVALIDARG;
- if (SUCCEEDED(hr = wg_transform_read_mf(encoder->wg_transform, samples->pSample, &samples->dwStatus, NULL))) + if (SUCCEEDED(hr = wg_transform_read_mf(encoder->wg_transform, samples->pSample, 0, &samples->dwStatus, NULL))) wg_sample_queue_flush(encoder->wg_sample_queue, false);
return hr; diff --git a/dlls/winegstreamer/video_processor.c b/dlls/winegstreamer/video_processor.c index 8b45cfbb52a..9b86d4c5089 100644 --- a/dlls/winegstreamer/video_processor.c +++ b/dlls/winegstreamer/video_processor.c @@ -696,6 +696,7 @@ static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD f MFT_OUTPUT_DATA_BUFFER *samples, DWORD *status) { struct video_processor *impl = impl_from_IMFTransform(iface); + MFT_OUTPUT_STREAM_INFO info; IMFSample *output_sample; HRESULT hr; BOOL playback_mode, provide_samples; @@ -709,6 +710,8 @@ static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD f return MF_E_TRANSFORM_TYPE_NOT_SET;
samples->dwStatus = 0; + if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) + return hr;
if (FAILED(IMFAttributes_GetUINT32(impl->attributes, &MF_XVP_PLAYBACK_MODE, (UINT32 *) &playback_mode))) playback_mode = FALSE; @@ -729,7 +732,7 @@ static HRESULT WINAPI video_processor_ProcessOutput(IMFTransform *iface, DWORD f IMFSample_AddRef(output_sample); }
- if (FAILED(hr = wg_transform_read_mf(impl->wg_transform, output_sample, &samples->dwStatus, NULL))) + if (FAILED(hr = wg_transform_read_mf(impl->wg_transform, output_sample, info.cbSize, &samples->dwStatus, NULL))) goto done; wg_sample_queue_flush(impl->wg_sample_queue, false);
diff --git a/dlls/winegstreamer/wg_sample.c b/dlls/winegstreamer/wg_sample.c index 2fc2679337f..94dfe483fb6 100644 --- a/dlls/winegstreamer/wg_sample.c +++ b/dlls/winegstreamer/wg_sample.c @@ -52,6 +52,7 @@ struct sample { IMFSample *sample; IMFMediaBuffer *buffer; + IMF2DBuffer2 *buffer2d; } mf; struct { @@ -79,8 +80,16 @@ static void mf_sample_destroy(struct wg_sample *wg_sample)
TRACE_(mfplat)("wg_sample %p.\n", wg_sample);
- IMFMediaBuffer_Unlock(sample->u.mf.buffer); - IMFMediaBuffer_Release(sample->u.mf.buffer); + if (sample->u.mf.buffer2d) + { + IMF2DBuffer2_Unlock2D(sample->u.mf.buffer2d); + IMF2DBuffer2_Release(sample->u.mf.buffer2d); + } + else + { + IMFMediaBuffer_Unlock(sample->u.mf.buffer); + IMFMediaBuffer_Release(sample->u.mf.buffer); + } IMFSample_Release(sample->u.mf.sample); }
@@ -92,21 +101,49 @@ static const struct wg_sample_ops mf_sample_ops = HRESULT wg_sample_create_mf(IMFSample *mf_sample, struct wg_sample **out) { DWORD current_length, max_length; + BYTE *scanline0, *buffer = NULL; + IMF2DBuffer2 *buffer2d; struct sample *sample; - BYTE *buffer; - HRESULT hr; + HRESULT hr = S_OK; + LONG pitch = 0;
if (!(sample = calloc(1, sizeof(*sample)))) return E_OUTOFMEMORY; if (FAILED(hr = IMFSample_ConvertToContiguousBuffer(mf_sample, &sample->u.mf.buffer))) goto fail; - if (FAILED(hr = IMFMediaBuffer_Lock(sample->u.mf.buffer, &buffer, &max_length, ¤t_length))) + if (SUCCEEDED(IMFMediaBuffer_QueryInterface(sample->u.mf.buffer, &IID_IMF2DBuffer2, (void **)&buffer2d))) + { + /* The result of ConvertToContiguousBuffer() can be an existing 2D buffer, which does + * not need to be contiguous by the definition of 'contiguous' for buffers. For 2D + * buffers, call Lock2DSize() and set up GStreamer to output with the correct stride. + * This avoids Lock() copying the entire contents into a linear buffer even though the + * current contents are about to be overwritten, and avoids Unlock() copying the new + * contents. Resolves performance issues on lower spec hardware. */ + if (SUCCEEDED(hr = IMF2DBuffer2_Lock2DSize(buffer2d, MF2DBuffer_LockFlags_ReadWrite, &scanline0, &pitch, &buffer, &max_length))) + { + IMFMediaBuffer_Release(sample->u.mf.buffer); + sample->u.mf.buffer = NULL; + sample->u.mf.buffer2d = buffer2d; + IMF2DBuffer2_GetContiguousLength(buffer2d, ¤t_length); + if (pitch < 0) + pitch = -pitch; + } + else + { + IMF2DBuffer2_Release(buffer2d); + } + if (FAILED(hr)) + goto fail; + } + + if (!buffer && FAILED(hr = IMFMediaBuffer_Lock(sample->u.mf.buffer, &buffer, &max_length, ¤t_length))) goto fail;
IMFSample_AddRef((sample->u.mf.sample = mf_sample)); sample->wg_sample.data = (UINT_PTR)buffer; sample->wg_sample.size = current_length; sample->wg_sample.max_size = max_length; + sample->wg_sample.stride = pitch; sample->ops = &mf_sample_ops;
*out = &sample->wg_sample; @@ -338,10 +375,12 @@ HRESULT wg_transform_push_mf(wg_transform_t transform, IMFSample *sample, return hr; }
-HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, DWORD *flags, bool *preserve_timestamps) +HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, + DWORD plane_size, DWORD *flags, bool *preserve_timestamps) { struct wg_sample *wg_sample; IMFMediaBuffer *buffer; + DWORD sample_size; HRESULT hr;
TRACE_(mfplat)("transform %#I64x, sample %p, flags %p.\n", transform, sample, flags); @@ -372,7 +411,20 @@ HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, DWORD
if (SUCCEEDED(hr = IMFSample_ConvertToContiguousBuffer(sample, &buffer))) { - hr = IMFMediaBuffer_SetCurrentLength(buffer, wg_sample->size); + if (wg_sample->stride && plane_size) + { + /* The sample size must match the frame size, which differs from the contiguous length + * if the buffer has extra width. MF allows a frame to be placed in a wider 2D buffer. */ + sample_size = min(plane_size, wg_sample->size); + } + else + { + if (wg_sample->stride) + FIXME("Expected a plane size.\n"); + sample_size = wg_sample->size; + } + + hr = IMFMediaBuffer_SetCurrentLength(buffer, sample_size); IMFMediaBuffer_Release(buffer); }
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index f8bf4474756..e7bbdccb4e9 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -104,7 +104,7 @@ static struct wg_transform *get_transform(wg_transform_t trans) return (struct wg_transform *)(ULONG_PTR)trans; }
-static void align_video_info_planes(MFVideoInfo *video_info, gsize plane_align, +static void align_video_info_planes(MFVideoInfo *video_info, gsize plane_align, guint stride, GstVideoInfo *info, GstVideoAlignment *align) { bool fix_nv12 = !plane_align && info->finfo->format == GST_VIDEO_FORMAT_NV12 && (info->width & 3) && (info->width & 3) != 3; @@ -123,6 +123,27 @@ static void align_video_info_planes(MFVideoInfo *video_info, gsize plane_align, align->padding_left = aperture->OffsetY.value; }
+ if (stride) + { + /* The MF sample has a 2D buffer. Set padding_right to match its stride. */ + guint width = align->padding_left + info->width + align->padding_right; + const GstVideoFormatInfo *finfo = info->finfo; + gint comp[GST_VIDEO_MAX_COMPONENTS]; + gint pixel_stride; + + gst_video_format_info_component(finfo, 0, comp); + pixel_stride = finfo->pixel_stride[comp[0]]; + + if (stride % pixel_stride) + GST_ERROR("Stride %u not aligned to pixel size", stride); + stride /= pixel_stride; + + if (stride < width) + GST_ERROR("Invalid stride %u", stride); + else + align->padding_right += stride - width; + } + if (video_info->VideoFlags & MFVideoFlag_BottomUpLinearRep) { gsize top = align->padding_top; @@ -217,7 +238,7 @@ static void wg_video_buffer_pool_class_init(WgVideoBufferPoolClass *klass) pool_class->alloc_buffer = wg_video_buffer_pool_alloc_buffer; }
-static WgVideoBufferPool *wg_video_buffer_pool_create(GstCaps *caps, gsize plane_align, +static WgVideoBufferPool *wg_video_buffer_pool_create(GstCaps *caps, gsize plane_align, gsize output_plane_stride, GstAllocator *allocator, MFVideoInfo *video_info, GstVideoAlignment *align) { WgVideoBufferPool *pool; @@ -229,7 +250,7 @@ static WgVideoBufferPool *wg_video_buffer_pool_create(GstCaps *caps, gsize plane
gst_video_info_from_caps(&pool->info, caps); max_size = pool->info.size; - align_video_info_planes(video_info, plane_align, &pool->info, align); + align_video_info_planes(video_info, plane_align, output_plane_stride, &pool->info, align); /* GStreamer assumes NV12 pools must accommodate a stride alignment of 4, but we use 2 */ max_size = max(max_size, pool->info.size);
@@ -313,7 +334,7 @@ static gboolean transform_sink_query_allocation(struct wg_transform *transform, return false;
if (!(pool = wg_video_buffer_pool_create(caps, transform->attrs.output_plane_align, - transform->allocator, &transform->output_info, &align))) + transform->attrs.output_plane_stride, transform->allocator, &transform->output_info, &align))) return false;
if ((params = gst_structure_new("video-meta", @@ -896,7 +917,7 @@ NTSTATUS wg_transform_push_data(void *args) }
if (!(buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, wg_sample_data(sample), sample->max_size, - 0, sample->size, sample, wg_sample_free_notify))) + 0, sample->stride ? sample->max_size : sample->size, sample, wg_sample_free_notify))) { GST_ERROR("Failed to allocate input buffer"); return STATUS_NO_MEMORY; @@ -911,7 +932,7 @@ NTSTATUS wg_transform_push_data(void *args) if (!strcmp(input_mime, "video/x-raw") && gst_video_info_from_caps(&video_info, transform->input_caps)) { GstVideoAlignment align; - align_video_info_planes(&transform->input_info, 0, &video_info, &align); + align_video_info_planes(&transform->input_info, 0, sample->stride, &video_info, &align); buffer_add_video_meta(buffer, &video_info); }
@@ -1214,6 +1235,13 @@ NTSTATUS wg_transform_read_data(void *args) bool discard_data; NTSTATUS status;
+ if (sample->stride != transform->attrs.output_plane_stride) + { + GST_INFO("Reconfiguring to stride %u", sample->stride); + transform->attrs.output_plane_stride = sample->stride; + push_event(transform->my_sink, gst_event_new_reconfigure()); + } + if (!transform->output_sample && !get_transform_output(transform, sample)) { sample->size = 0; @@ -1237,7 +1265,7 @@ NTSTATUS wg_transform_read_data(void *args) dst_video_info = src_video_info;
/* set the desired output buffer alignment and stride on the dest video info */ - align_video_info_planes(&transform->output_info, plane_align, &dst_video_info, &align); + align_video_info_planes(&transform->output_info, plane_align, sample->stride, &dst_video_info, &align);
/* copy the actual output buffer alignment and stride to the src video info */ if ((meta = gst_buffer_get_video_meta(output_buffer))) diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index ca7a5f278bf..8ff4d09cfaa 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -552,7 +552,7 @@ static HRESULT WINAPI transform_ProcessOutput(IMFTransform *iface, DWORD flags, return MF_E_TRANSFORM_NEED_MORE_INPUT; }
- if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample, &samples->dwStatus, NULL))) + if (SUCCEEDED(hr = wg_transform_read_mf(decoder->wg_transform, samples->pSample, 0, &samples->dwStatus, NULL))) wg_sample_queue_flush(decoder->wg_sample_queue, false);
return hr;
From: Conor McCarthy cmccarthy@codeweavers.com
H.264 uses a 16-pixel alignment, and the stream sink media type should have the aligned height after the session has started. --- dlls/mf/tests/mf.c | 115 +++++++++++++++++++++++++++++++ dlls/mf/tests/resource.rc | 9 +++ dlls/mf/tests/test-unaligned.mp4 | Bin 0 -> 3988 bytes 3 files changed, 124 insertions(+) create mode 100644 dlls/mf/tests/test-unaligned.mp4
diff --git a/dlls/mf/tests/mf.c b/dlls/mf/tests/mf.c index c56e59fbc6c..daddeb580bd 100644 --- a/dlls/mf/tests/mf.c +++ b/dlls/mf/tests/mf.c @@ -8055,6 +8055,120 @@ static void test_media_session_seek(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); }
+static void test_h264_output_alignment(void) +{ + media_type_desc video_nv12_desc = + { + ATTR_GUID(MF_MT_MAJOR_TYPE, MFMediaType_Video), + ATTR_GUID(MF_MT_SUBTYPE, MFVideoFormat_NV12), + }; + struct test_grabber_callback *grabber_callback; + IMFTopology *topology, *resolved_topology; + IMFMediaTypeHandler *handler; + IMFActivate *sink_activate; + IMFTopoLoader *topo_loader; + IMFStreamSink *stream_sink; + IMFAsyncCallback *callback; + IMFMediaType *output_type; + IMFMediaSession *session; + IMFMediaSink *media_sink; + IMFMediaSource *source; + PROPVARIANT propvar; + UINT64 frame_size; + HRESULT hr; + + hr = MFStartup(MF_VERSION, MFSTARTUP_FULL); + ok(hr == S_OK, "Failed to start up, hr %#lx.\n", hr); + + if (!(source = create_media_source(L"test-unaligned.mp4", L"video/mp4"))) + { + todo_wine /* Gitlab CI Debian runner */ + win_skip("MP4 media source is not supported, skipping tests.\n"); + MFShutdown(); + return; + } + + grabber_callback = impl_from_IMFSampleGrabberSinkCallback(create_test_grabber_callback()); + hr = MFCreateMediaType(&output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + init_media_type(output_type, video_nv12_desc, -1); + hr = MFCreateSampleGrabberSinkActivate(output_type, &grabber_callback->IMFSampleGrabberSinkCallback_iface, &sink_activate); + ok(hr == S_OK, "Failed to create grabber sink, hr %#lx.\n", hr); + IMFMediaType_Release(output_type); + + IMFActivate_ActivateObject(sink_activate, &IID_IMFMediaSink, (void **)&media_sink); + hr = IMFMediaSink_GetStreamSinkByIndex(media_sink, 0, &stream_sink); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFActivate_Release(sink_activate); + topology = create_test_topology_unk(source, (IUnknown *)stream_sink, NULL, NULL); + hr = MFCreateTopoLoader(&topo_loader); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFTopoLoader_Load(topo_loader, topology, &resolved_topology, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFTopology_Release(topology); + IMFTopoLoader_Release(topo_loader); + + hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &handler); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(output_type, &MF_MT_FRAME_SIZE, &frame_size); + ok(hr == MF_E_ATTRIBUTENOTFOUND, "Unexpected hr %#lx.\n", hr); + IMFMediaType_Release(output_type); + + hr = MFCreateMediaSession(NULL, &session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_SetTopology(session, 0, resolved_topology); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IMFTopology_Release(resolved_topology); + callback = create_test_callback(TRUE); + hr = wait_media_event(session, callback, MESessionTopologySet, 1000, &propvar); + + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(output_type, &MF_MT_FRAME_SIZE, &frame_size); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok((UINT32)frame_size == 72, "Unexpected frame size %u\n", (UINT32)frame_size); + IMFMediaType_Release(output_type); + + propvar.vt = VT_EMPTY; + hr = IMFMediaSession_Start(session, &GUID_NULL, &propvar); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = wait_media_event(session, callback, MESessionStarted, 5000, &propvar); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, &output_type); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaType_GetUINT64(output_type, &MF_MT_FRAME_SIZE, &frame_size); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + todo_wine + ok((UINT32)frame_size == 80, "Unexpected frame size %u\n", (UINT32)frame_size); + IMFMediaType_Release(output_type); + + hr = IMFMediaSession_Stop(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_Close(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = wait_media_event(session, callback, MESessionClosed, 1000, &propvar); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMFMediaSource_Shutdown(source); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + hr = IMFMediaSession_Shutdown(session); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + IMFMediaTypeHandler_Release(handler); + IMFAsyncCallback_Release(callback); + IMFMediaSession_Release(session); + IMFStreamSink_Release(stream_sink); + IMFMediaSink_Release(media_sink); + IMFSampleGrabberSinkCallback_Release(&grabber_callback->IMFSampleGrabberSinkCallback_iface); + IMFMediaSource_Release(source); + + hr = MFShutdown(); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); +} + START_TEST(mf) { init_functions(); @@ -8093,4 +8207,5 @@ START_TEST(mf) test_media_session_source_shutdown(); test_media_session_thinning(); test_media_session_seek(); + test_h264_output_alignment(); } diff --git a/dlls/mf/tests/resource.rc b/dlls/mf/tests/resource.rc index 2efb52d91ae..6a70ba62d9d 100644 --- a/dlls/mf/tests/resource.rc +++ b/dlls/mf/tests/resource.rc @@ -189,3 +189,12 @@ rgb24frame.bmp RCDATA rgb24frame.bmp */ /* @makedep: test.mp4 */ test.mp4 RCDATA test.mp4 + +/* Generated with: + * gst-launch-1.0 videotestsrc num-buffers=60 pattern=smpte100 ! \ + * video/x-raw,format=I420,width=72,height=64,framerate=30000/1001 ! \ + * videoflip method=clockwise ! videoconvert ! \ + * x264enc ! mp4mux ! filesink location=dlls/mf/tests/test-unaligned.mp4 + */ +/* @makedep: test-unaligned.mp4 */ +test-unaligned.mp4 RCDATA test-unaligned.mp4 diff --git a/dlls/mf/tests/test-unaligned.mp4 b/dlls/mf/tests/test-unaligned.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5920da40daaf55dc69a5a02577891c70906fed94 GIT binary patch literal 3988 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 V7(l&F1_lOOsKKVB7|a1O7yw{rbdCT3
literal 0 HcmV?d00001
Rebase. Also bump 😉
On Fri Aug 22 13:43:58 2025 +0000, Conor McCarthy wrote:
`test_video_processor()` is run with 2D buffers. Looks like that option can be added to `test_h264_decoder()` and `test_wmv_decoder()` too, if you think that's a good idea. Maybe some of the others as well.
The new tests are in.
``` + if (FAILED(hr = IMFTransform_GetOutputStreamInfo(iface, 0, &info))) + return hr; ```
No need to call a method on yourself, you can just access impl->output_info.
``` + if (pitch < 0) + pitch = -pitch; ```
Well, in a sense yes, but we also don't actually handle this case. It probably would be better to just spit an ERR, and ideally return failure, than to pretend to handle it and not actually do so.
``` +HRESULT wg_transform_read_mf(wg_transform_t transform, IMFSample *sample, + DWORD plane_size, DWORD *flags, bool *preserve_timestamps) ```
As far as I can tell both the callers and the function expect the size of the entire frame, not just (the first) plane.
``` + if (wg_sample->stride && plane_size) + { + /* The sample size must match the frame size, which differs from the contiguous length + * if the buffer has extra width. MF allows a frame to be placed in a wider 2D buffer. */ + sample_size = min(plane_size, wg_sample->size); + } ```
So the length we set is supposed to *exclude* padding? But it doesn't exclude the padding that the sample has according to normal YUV rules?
No need to call a method on yourself, you can just access impl->output_info.
Fixed.
but we also don't actually handle this case
The negative stride tests pass, and erroring out here causes the first to fail and crash.
As far as I can tell both the callers and the function expect the size of the entire frame, not just (the first) plane.
Renamed.
So the length we set is supposed to _exclude_ padding? But it doesn't exclude the padding that the sample has according to normal YUV rules?
No, it includes padding according to the frame size set with MF_MT_FRAME_SIZE, which can have extra width. Without extra width, it's padded according to normal YUV rules. This is covered in tests.
Rebased, changed commit message prefixes to "mf/test:" where needed, and got rid of an extra test commit which crept in somewhere and is now upstream anyway.