[PATCH 1/6] evr/mixer: Set timestamp and duration for output samples.
Nikolay Sivov
nsivov at codeweavers.com
Tue Nov 17 04:41:35 CST 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/evr/mixer.c | 11 +++++++++
dlls/evr/tests/evr.c | 56 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/dlls/evr/mixer.c b/dlls/evr/mixer.c
index 997c5054f12..ddf34d05f44 100644
--- a/dlls/evr/mixer.c
+++ b/dlls/evr/mixer.c
@@ -1272,8 +1272,19 @@ static HRESULT WINAPI video_mixer_transform_ProcessOutput(IMFTransform *iface, D
}
if (SUCCEEDED(hr))
+ {
video_mixer_render(mixer, surface);
+ timestamp = duration = 0;
+ if (SUCCEEDED(IMFSample_GetSampleTime(mixer->inputs[0].sample, ×tamp)))
+ {
+ IMFSample_SetSampleTime(buffers->pSample, timestamp);
+
+ IMFSample_GetSampleDuration(mixer->inputs[0].sample, &duration);
+ IMFSample_SetSampleDuration(buffers->pSample, duration);
+ }
+ }
+
if (SUCCEEDED(hr))
{
for (i = 0; i < mixer->input_count; ++i)
diff --git a/dlls/evr/tests/evr.c b/dlls/evr/tests/evr.c
index c456bcf5653..c83ce0374eb 100644
--- a/dlls/evr/tests/evr.c
+++ b/dlls/evr/tests/evr.c
@@ -2219,13 +2219,14 @@ static void test_mixer_samples(void)
IMFDesiredSample *desired;
IDirect3DDevice9 *device;
IMFMediaType *video_type;
- DWORD color, status;
+ DWORD count, flags, color, status;
IMFTransform *mixer;
- IMFSample *sample;
+ IMFSample *sample, *sample2;
IDirect3D9 *d3d;
HWND window;
UINT token;
HRESULT hr;
+ LONGLONG pts, duration;
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
@@ -2395,6 +2396,57 @@ static void test_mixer_samples(void)
hr = IMFTransform_ProcessInput(mixer, 5, sample, 0);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
+ /* ProcessOutput() sets sample time and duration. */
+ hr = MFCreateVideoSampleFromSurface((IUnknown *)surface, &sample2);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_SetUINT32(sample2, &IID_IMFSample, 1);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_SetSampleFlags(sample2, 0x123);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_GetSampleTime(sample2, &pts);
+ ok(hr == MF_E_NO_SAMPLE_TIMESTAMP, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_GetSampleDuration(sample2, &duration);
+ ok(hr == MF_E_NO_SAMPLE_DURATION, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_SetSampleTime(sample, 0);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_SetSampleDuration(sample, 0);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ memset(buffers, 0, sizeof(buffers));
+ buffers[0].pSample = sample2;
+ hr = IMFTransform_ProcessOutput(mixer, 0, 1, buffers, &status);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = IMFSample_GetSampleTime(sample2, &pts);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!pts, "Unexpected sample time.\n");
+
+ hr = IMFSample_GetSampleDuration(sample2, &duration);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!duration, "Unexpected duration\n");
+
+ /* Flags are not copied. */
+ hr = IMFSample_GetSampleFlags(sample2, &flags);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(flags == 0x123, "Unexpected flags %#x.\n", flags);
+
+ /* Attributes are not removed. */
+ hr = IMFSample_GetCount(sample2, &count);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(count == 1, "Unexpected attribute count %u.\n", count);
+
+ hr = IMFSample_GetCount(sample, &count);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!count, "Unexpected attribute count %u.\n", count);
+
+ IMFSample_Release(sample2);
+
hr = IMFTransform_ProcessMessage(mixer, MFT_MESSAGE_COMMAND_DRAIN, 0);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
--
2.29.2
More information about the wine-devel
mailing list