mfmediaengine: Improve AddRange() behavior for intersecting ranges.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4c61027967
commit
9b17bd1754
|
@ -653,13 +653,35 @@ static BOOL WINAPI time_range_ContainsTime(IMFMediaTimeRange *iface, double time
|
|||
static HRESULT WINAPI time_range_AddRange(IMFMediaTimeRange *iface, double start, double end)
|
||||
{
|
||||
struct time_range *range = impl_from_IMFMediaTimeRange(iface);
|
||||
struct range *c;
|
||||
size_t i;
|
||||
|
||||
TRACE("%p, %.8e, %.8e.\n", iface, start, end);
|
||||
|
||||
if (range->count)
|
||||
for (i = 0; i < range->count; ++i)
|
||||
{
|
||||
FIXME("Range merging is not implemented.\n");
|
||||
return E_NOTIMPL;
|
||||
c = &range->ranges[i];
|
||||
|
||||
/* New range is fully contained within existing one. */
|
||||
if (c->start <= start && c->end >= end)
|
||||
return S_OK;
|
||||
|
||||
/* New range fully contains existing one. */
|
||||
if (c->start >= start && c->end <= end)
|
||||
{
|
||||
c->start = start;
|
||||
c->end = end;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* Merge if ranges intersect. */
|
||||
if ((start >= c->start && start <= c->end) ||
|
||||
(end >= c->start && end <= c->end))
|
||||
{
|
||||
c->start = min(c->start, start);
|
||||
c->end = max(c->end, end);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mf_array_reserve((void **)&range->ranges, &range->capacity, range->count + 1, sizeof(*range->ranges)))
|
||||
|
|
|
@ -729,7 +729,6 @@ static void test_time_range(void)
|
|||
ok(end == 1.0, "Unexpected end %.e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 2.0, 3.0);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
|
@ -737,49 +736,129 @@ todo_wine
|
|||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
todo_wine
|
||||
ok(start == 2.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
todo_wine
|
||||
ok(end == 3.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 10.0, 9.0);
|
||||
todo_wine
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
todo_wine
|
||||
ok(count == 2, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
todo_wine
|
||||
ok(start == 2.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
todo_wine
|
||||
ok(end == 3.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
start = 0.0;
|
||||
hr = IMFMediaTimeRange_GetStart(range, 1, &start);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 10.0, "Unexpected start %.8e.\n", start);
|
||||
}
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 1, &end);
|
||||
todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 9.0, "Unexpected end %.8e.\n", end);
|
||||
}
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 2.0, 9.1);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 2, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 2.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 9.1, "Unexpected end %.8e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 1, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 10.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 1, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 9.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 8.5, 2.5);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 2, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 2.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 9.1, "Unexpected end %.8e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 20.0, 20.0);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 3, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_Clear(range);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(!count, "Unexpected range count.\n");
|
||||
|
||||
/* Intersect */
|
||||
hr = IMFMediaTimeRange_AddRange(range, 5.0, 10.0);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 6.0, 12.0);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 5.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 12.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 1, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 4.0, 6.0);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 1, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 4.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 12.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
hr = IMFMediaTimeRange_AddRange(range, 5.0, 3.0);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
count = IMFMediaTimeRange_GetLength(range);
|
||||
ok(count == 1, "Unexpected range count.\n");
|
||||
|
||||
hr = IMFMediaTimeRange_GetStart(range, 0, &start);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(start == 4.0, "Unexpected start %.8e.\n", start);
|
||||
|
||||
hr = IMFMediaTimeRange_GetEnd(range, 0, &end);
|
||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||
ok(end == 12.0, "Unexpected end %.8e.\n", end);
|
||||
|
||||
IMFMediaTimeRange_Release(range);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue