mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
segment: Modifiy inside segment condition
There is a special case that segment_start == segment_stop == start. It's inside of segment https://bugzilla.gnome.org/show_bug.cgi?id=764707
This commit is contained in:
parent
94da8f5d8d
commit
15f2898e87
2 changed files with 61 additions and 2 deletions
|
@ -884,8 +884,11 @@ gst_segment_clip (const GstSegment * segment, GstFormat format, guint64 start,
|
||||||
g_return_val_if_fail (segment->format == format, FALSE);
|
g_return_val_if_fail (segment->format == format, FALSE);
|
||||||
|
|
||||||
/* if we have a stop position and a valid start and start is bigger,
|
/* if we have a stop position and a valid start and start is bigger,
|
||||||
* we're outside of the segment */
|
* we're outside of the segment. (Special case) segment start and
|
||||||
if (G_UNLIKELY (segment->stop != -1 && start != -1 && start >= segment->stop))
|
* segment stop can be identical. In this case, if start is also identical,
|
||||||
|
* it's inside of segment */
|
||||||
|
if (G_UNLIKELY (segment->stop != -1 && start != -1 && (start > segment->stop
|
||||||
|
|| (segment->start != segment->stop && start == segment->stop))))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* if a stop position is given and is before the segment start,
|
/* if a stop position is given and is before the segment start,
|
||||||
|
|
|
@ -345,6 +345,62 @@ GST_START_TEST (segment_seek_size)
|
||||||
fail_unless (update == FALSE);
|
fail_unless (update == FALSE);
|
||||||
check_times (&segment, 200, 200, 0);
|
check_times (&segment, 200, 200, 0);
|
||||||
|
|
||||||
|
/* special case, segment's start and stop are identical */
|
||||||
|
/* completely outside */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, 100, &cstart, &cstop);
|
||||||
|
fail_unless (res == FALSE);
|
||||||
|
|
||||||
|
/* completely outside also */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
||||||
|
250, 300, &cstart, &cstop);
|
||||||
|
fail_unless (res == FALSE);
|
||||||
|
|
||||||
|
/* stop at boundary point. it's outside because stop is exclusive */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
||||||
|
100, 200, &cstart, &cstop);
|
||||||
|
fail_unless (res == FALSE);
|
||||||
|
|
||||||
|
/* touching boundary point. it's inside because start at segment start */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
||||||
|
200, 300, &cstart, &cstop);
|
||||||
|
fail_unless (res == TRUE);
|
||||||
|
fail_unless (cstart == 200);
|
||||||
|
fail_unless (cstop == 200);
|
||||||
|
|
||||||
|
/* completely inside */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
||||||
|
200, 200, &cstart, &cstop);
|
||||||
|
fail_unless (res == TRUE);
|
||||||
|
fail_unless (cstart == 200);
|
||||||
|
fail_unless (cstop == 200);
|
||||||
|
|
||||||
|
/* exclusively cover boundary point */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES,
|
||||||
|
150, 250, &cstart, &cstop);
|
||||||
|
fail_unless (res == TRUE);
|
||||||
|
fail_unless (cstart == 200);
|
||||||
|
fail_unless (cstop == 200);
|
||||||
|
|
||||||
|
/* invalid start */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, -1, 200, &cstart, &cstop);
|
||||||
|
fail_unless (res == FALSE);
|
||||||
|
|
||||||
|
/* start outside */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 50, -1, &cstart, &cstop);
|
||||||
|
fail_unless (res == TRUE);
|
||||||
|
fail_unless (cstart == 200);
|
||||||
|
fail_unless (cstop == 200);
|
||||||
|
|
||||||
|
/* start on boundary point */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 200, -1, &cstart, &cstop);
|
||||||
|
fail_unless (res == TRUE);
|
||||||
|
fail_unless (cstart == 200);
|
||||||
|
fail_unless (cstop == 200);
|
||||||
|
|
||||||
|
/* start completely outside */
|
||||||
|
res = gst_segment_clip (&segment, GST_FORMAT_BYTES, 250, -1, &cstart, &cstop);
|
||||||
|
fail_unless (res == FALSE);
|
||||||
|
|
||||||
/* seek relative to end */
|
/* seek relative to end */
|
||||||
gst_segment_do_seek (&segment, 1.0,
|
gst_segment_do_seek (&segment, 1.0,
|
||||||
GST_FORMAT_BYTES,
|
GST_FORMAT_BYTES,
|
||||||
|
|
Loading…
Reference in a new issue