g_return_val_if_fail (segment != NULL, -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;
- time = segment->time;
- } else {
- start = 0;
- stop = -1;
- time = 0;
- }
+ stop = segment->stop;
/* outside of the segment boundary stop */
if (G_UNLIKELY (stop != -1 && position > stop))
return -1;
+ start = segment->start;
+
/* before the segment boundary */
if (G_UNLIKELY (position < start))
return -1;
+ time = segment->time;
+
/* time must be known */
if (G_UNLIKELY (time == -1))
return -1;
guint64 position)
{
guint64 result;
- guint64 start, stop, base;
+ guint64 start, stop;
gdouble abs_rate;
if (G_UNLIKELY (position == -1))
g_return_val_if_fail (segment != NULL, -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;
- base = segment->base;
- } else {
- start = 0;
- stop = -1;
- base = 0;
- }
+ start = segment->start;
/* before the segment boundary */
if (G_UNLIKELY (position < start))
return -1;
+ stop = segment->stop;
+
if (G_LIKELY (segment->rate > 0.0)) {
/* outside of the segment boundary stop */
if (G_UNLIKELY (stop != -1 && position > stop))
result /= abs_rate;
/* correct for base of the segment */
- result += base;
+ result += segment->base;
return result;
}
g_return_val_if_fail (segment != NULL, -1);
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;
- } else {
- start = 0;
- stop = -1;
- base = 0;
- }
+ base = segment->base;
/* this running_time was for a previous segment */
if (running_time < base)
if (G_UNLIKELY (abs_rate != 1.0))
result = ceil (result * abs_rate);
+ start = segment->start;
+ stop = segment->stop;
+
if (G_LIKELY (segment->rate > 0.0)) {
/* bring to corrected position in segment */
result += start;