Commit 1f42bd08 authored by conrad's avatar conrad

removed use of double in guess_ratio()


git-svn-id: http://svn.annodex.net/liboggz/trunk@423 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4d0a1ac4
...@@ -790,6 +790,8 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target, ...@@ -790,6 +790,8 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target,
return offset_at; return offset_at;
} }
#define GUESS_MULTIPLIER (1<<16)
static long static long
oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
{ {
...@@ -801,7 +803,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -801,7 +803,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
ogg_int64_t granule_at; ogg_int64_t granule_at;
ogg_int64_t unit_at, unit_begin = 0, unit_end = -1; ogg_int64_t unit_at, unit_begin = 0, unit_end = -1;
long serialno; long serialno;
double guess_ratio; ogg_int64_t guess_ratio;
ogg_page * og; ogg_page * og;
if (oggz == NULL) { if (oggz == NULL) {
...@@ -896,16 +898,17 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -896,16 +898,17 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
printf ("*G2*"); printf ("*G2*");
#endif #endif
guess_ratio = guess_ratio =
(double)(unit_target - unit_begin) / GUESS_MULTIPLIER * (unit_target - unit_begin) /
(double)(unit_at - unit_begin); (unit_at - unit_begin);
#ifdef DEBUG #ifdef DEBUG
printf ("\nguess_ration %f = (%ld - %ld) / (%ld - %ld)\n", printf ("\nguess_ratio %ld = (%ld - %ld) / (%ld - %ld)\n",
guess_ratio, unit_target, unit_begin, unit_at, unit_begin); guess_ratio, unit_target, unit_begin, unit_at, unit_begin);
#endif #endif
offset_guess = offset_begin + offset_guess = offset_begin +
(oggz_off_t)((offset_at - offset_begin) * guess_ratio); (oggz_off_t)(((offset_at - offset_begin) * guess_ratio) /
GUESS_MULTIPLIER);
} }
} else if (unit_end <= unit_begin) { } else if (unit_end <= unit_begin) {
#ifdef DEBUG #ifdef DEBUG
...@@ -915,11 +918,12 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -915,11 +918,12 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
} else { } else {
#if 1 #if 1
guess_ratio = guess_ratio =
(double)(unit_target - unit_begin) / GUESS_MULTIPLIER * (unit_target - unit_begin) /
(double)(unit_end - unit_begin); (unit_end - unit_begin);
offset_guess = offset_begin + offset_guess = offset_begin +
(oggz_off_t)((offset_end - offset_begin) * guess_ratio); (oggz_off_t)(((offset_end - offset_begin) * guess_ratio) /
GUESS_MULTIPLIER);
/* /*
if (offset_guess <= offset_begin) { if (offset_guess <= offset_begin) {
......
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