segment: remove redundant checks

We don't need to check the segment format anymore because we asserted on them
being equal before.
This commit is contained in:
Wim Taymans 2012-07-27 13:02:52 +02:00
parent dbb6d68999
commit 90e32338c8

View file

@ -383,26 +383,20 @@ gst_segment_to_stream_time (const GstSegment * segment, GstFormat format,
g_return_val_if_fail (segment != NULL, -1); g_return_val_if_fail (segment != NULL, -1);
g_return_val_if_fail (segment->format == format, -1); g_return_val_if_fail (segment->format == format, -1);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
if (G_LIKELY (segment->format == format)) {
start = segment->start;
stop = segment->stop; stop = segment->stop;
time = segment->time;
} else {
start = 0;
stop = -1;
time = 0;
}
/* outside of the segment boundary stop */ /* outside of the segment boundary stop */
if (G_UNLIKELY (stop != -1 && position > stop)) if (G_UNLIKELY (stop != -1 && position > stop))
return -1; return -1;
start = segment->start;
/* before the segment boundary */ /* before the segment boundary */
if (G_UNLIKELY (position < start)) if (G_UNLIKELY (position < start))
return -1; return -1;
time = segment->time;
/* time must be known */ /* time must be known */
if (G_UNLIKELY (time == -1)) if (G_UNLIKELY (time == -1))
return -1; return -1;
@ -457,7 +451,7 @@ gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
guint64 position) guint64 position)
{ {
guint64 result; guint64 result;
guint64 start, stop, base; guint64 start, stop;
gdouble abs_rate; gdouble abs_rate;
if (G_UNLIKELY (position == -1)) if (G_UNLIKELY (position == -1))
@ -466,22 +460,14 @@ gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
g_return_val_if_fail (segment != NULL, -1); g_return_val_if_fail (segment != NULL, -1);
g_return_val_if_fail (segment->format == format, -1); g_return_val_if_fail (segment->format == format, -1);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
if (G_LIKELY (segment->format == format)) {
start = segment->start; start = segment->start;
stop = segment->stop;
base = segment->base;
} else {
start = 0;
stop = -1;
base = 0;
}
/* before the segment boundary */ /* before the segment boundary */
if (G_UNLIKELY (position < start)) if (G_UNLIKELY (position < start))
return -1; return -1;
stop = segment->stop;
if (G_LIKELY (segment->rate > 0.0)) { if (G_LIKELY (segment->rate > 0.0)) {
/* outside of the segment boundary stop */ /* outside of the segment boundary stop */
if (G_UNLIKELY (stop != -1 && position > stop)) if (G_UNLIKELY (stop != -1 && position > stop))
@ -506,7 +492,7 @@ gst_segment_to_running_time (const GstSegment * segment, GstFormat format,
result /= abs_rate; result /= abs_rate;
/* correct for base of the segment */ /* correct for base of the segment */
result += base; result += segment->base;
return result; return result;
} }
@ -603,17 +589,7 @@ gst_segment_to_position (const GstSegment * segment, GstFormat format,
g_return_val_if_fail (segment != NULL, -1); g_return_val_if_fail (segment != NULL, -1);
g_return_val_if_fail (segment->format == format, FALSE); g_return_val_if_fail (segment->format == format, FALSE);
/* if we have the position for the same format as the segment, we can compare
* the start and stop values, otherwise we assume 0 and -1 */
if (G_LIKELY (segment->format == format)) {
start = segment->start;
stop = segment->stop;
base = segment->base; base = segment->base;
} else {
start = 0;
stop = -1;
base = 0;
}
/* this running_time was for a previous segment */ /* this running_time was for a previous segment */
if (running_time < base) if (running_time < base)
@ -627,6 +603,9 @@ gst_segment_to_position (const GstSegment * segment, GstFormat format,
if (G_UNLIKELY (abs_rate != 1.0)) if (G_UNLIKELY (abs_rate != 1.0))
result = ceil (result * abs_rate); result = ceil (result * abs_rate);
start = segment->start;
stop = segment->stop;
if (G_LIKELY (segment->rate > 0.0)) { if (G_LIKELY (segment->rate > 0.0)) {
/* bring to corrected position in segment */ /* bring to corrected position in segment */
result += start; result += start;