gecko/media/liboggz/seek.patch

63 lines
1.9 KiB
Diff
Raw Normal View History

diff --git a/mozilla/media/liboggz/src/liboggz/oggz_seek.c b/mozilla/media/liboggz/src/liboggz/oggz_seek.c
index f933d4d..23ffb57 100644
--- a/mozilla/media/liboggz/src/liboggz/oggz_seek.c
+++ b/mozilla/media/liboggz/src/liboggz/oggz_seek.c
@@ -486,16 +486,18 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target,
serialno = ogg_page_serialno (og);
granule_at = ogg_page_granulepos (og);
unit_at = oggz_get_unit (oggz, serialno, granule_at);
break;
#else
do {
offset_at = oggz_get_prev_start_page(oggz, og, &granule_at, &serialno);
+ if (offset_at == -1)
+ return -1;
unit_at = oggz_get_unit(oggz, serialno, granule_at);
} while (unit_at > unit_target);
return offset_at;
#endif
} else if (unit_at == unit_target) {
#ifdef DEBUG
printf (" scan: (%lld) == (%lld)\n", unit_at, unit_target);
#endif
@@ -552,16 +554,19 @@ oggz_seek_guess (ogg_int64_t unit_at, ogg_int64_t unit_target,
printf ("oggz_seek_guess: unit_end <= unit_begin (ERROR)\n");
#endif
offset_guess = -1;
} else {
offset_guess = guess (unit_at, unit_target, unit_begin, unit_end,
offset_begin, offset_end);
}
+ if (offset_end != -1 && guess >= offset_end)
+ offset_guess = offset_begin + (offset_end - offset_begin)/2;
+
#ifdef DEBUG
printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess);
#endif
return offset_guess;
}
static oggz_off_t
@@ -759,16 +764,18 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
} else {
break;
}
}
found:
do {
offset_at = oggz_get_prev_start_page (oggz, og, &granule_at, &serialno);
+ if (offset_at == -1)
+ break;
unit_at = oggz_get_unit (oggz, serialno, granule_at);
} while (unit_at > unit_target);
if (offset_at < 0) {
oggz_reset (oggz, offset_orig, -1, SEEK_SET);
return -1;
}