Commit f830f6f4 authored by Wim Taymans's avatar Wim Taymans

gst/gstsegment.c: Fix boundary checking in to_running_time() and to_stream_time().

Original commit message from CVS:
* gst/gstsegment.c: (gst_segment_set_seek),
(gst_segment_set_newsegment_full), (gst_segment_to_stream_time),
(gst_segment_to_running_time):
Fix boundary checking in to_running_time() and to_stream_time().
Fixes #377183.
* tests/check/gst/gstsegment.c: (GST_START_TEST):
stream and running time can now be calculated for the complete
clipped segment.
parent c0ce6209
2006-11-20 Wim Taymans <wim@fluendo.com>
* gst/gstsegment.c: (gst_segment_set_seek),
(gst_segment_set_newsegment_full), (gst_segment_to_stream_time),
(gst_segment_to_running_time):
Fix boundary checking in to_running_time() and to_stream_time().
Fixes #377183.
* tests/check/gst/gstsegment.c: (GST_START_TEST):
stream and running time can now be calculated for the complete
clipped segment.
2006-11-15 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstpad.c: (gst_pad_push_event):
......
......@@ -512,7 +512,7 @@ gst_segment_to_stream_time (GstSegment * segment, GstFormat format,
g_return_val_if_fail (segment->format == format, -1);
/* outside of the segment boundary stop */
if (G_UNLIKELY (segment->stop != -1 && position >= segment->stop))
if (G_UNLIKELY (segment->stop != -1 && position > segment->stop))
return -1;
/* before the segment boundary */
......@@ -589,7 +589,7 @@ gst_segment_to_running_time (GstSegment * segment, GstFormat format,
if (segment->rate > 0.0) {
/* outside of the segment boundary stop */
if (G_UNLIKELY (segment->stop != -1 && position >= segment->stop))
if (G_UNLIKELY (segment->stop != -1 && position > segment->stop))
return -1;
/* bring to uncorrected position in segment */
......@@ -597,7 +597,7 @@ gst_segment_to_running_time (GstSegment * segment, GstFormat format,
} else {
/* cannot continue if no stop position set or outside of
* the segment. */
if (G_UNLIKELY (segment->stop == -1 || position >= segment->stop))
if (G_UNLIKELY (segment->stop == -1 || position > segment->stop))
return -1;
/* bring to uncorrected position in segment */
......
......@@ -581,10 +581,10 @@ GST_START_TEST (segment_newsegment_streamtime)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 100);
fail_unless (result == 100);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 200);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -635,10 +635,10 @@ GST_START_TEST (segment_newsegment_streamtime)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
fail_unless (result == 100);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
fail_unless (result == -1);
fail_unless (result == 200);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == -1);
......@@ -664,10 +664,10 @@ GST_START_TEST (segment_newsegment_streamtime)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 600);
fail_unless (result == 300);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 700);
fail_unless (result == -1);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == -1);
}
......@@ -712,10 +712,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 150);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 200);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -740,10 +740,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 250);
fail_unless (result == 150);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
fail_unless (result == 200);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
fail_unless (result == -1);
......@@ -784,10 +784,10 @@ GST_START_TEST (segment_newsegment_streamtime_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == 300);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 400);
fail_unless (result == -1);
}
......@@ -835,10 +835,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 50);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -876,10 +876,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 300);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -917,10 +917,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 100);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -959,10 +959,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
}
......@@ -1011,10 +1011,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 300);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -1052,10 +1052,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 50);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -1093,10 +1093,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 50);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 0);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -1133,10 +1133,10 @@ GST_START_TEST (segment_newsegment_streamtime_applied_rate_rate)
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 150);
fail_unless (result == 300);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_stream_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
}
......@@ -1178,10 +1178,11 @@ GST_START_TEST (segment_newsegment_runningtime)
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 100);
fail_unless (result == 100);
/* outside of the segment */
/* at edge is exactly the segment duration */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 200);
fail_unless (result == -1);
fail_unless (result == 200);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 300);
fail_unless (result == -1);
......@@ -1236,10 +1237,10 @@ GST_START_TEST (segment_newsegment_runningtime)
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
fail_unless (result == 400);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
fail_unless (result == -1);
fail_unless (result == 500);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == -1);
......@@ -1268,10 +1269,10 @@ GST_START_TEST (segment_newsegment_runningtime)
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
fail_unless (result == 600);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
fail_unless (result == -1);
fail_unless (result == 500);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == -1);
......@@ -1301,10 +1302,10 @@ GST_START_TEST (segment_newsegment_runningtime)
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 600);
fail_unless (result == 750);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 700);
fail_unless (result == -1);
fail_unless (result == 700);
/* outside of the segment */
result = gst_segment_to_running_time (&segment, GST_FORMAT_TIME, 800);
fail_unless (result == -1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment