diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tagcache.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 79c96ff186..9ffb6f86fe 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -772,9 +772,19 @@ static long check_virtual_tags(int tag, const struct index_entry *idx) } else { - data = 100 * idx->tag_seek[tag_playtime] - / idx->tag_seek[tag_length] - / idx->tag_seek[tag_playcount]; + /* A straight calculus gives: + autoscore = 100 * playtime / length / playcout (1) + Now, consider the euclidian division of playtime by length: + playtime = alpha * length + beta + With: + 0 <= beta < length + Now, (1) becomes: + autoscore = 100 * (alpha / playcout + beta / length / playcount) + Both terms should be small enough to avoid any overflow + */ + data = 100 * (idx->tag_seek[tag_playtime] / idx->tag_seek[tag_length]) + + (100 * (idx->tag_seek[tag_playtime] % idx->tag_seek[tag_length])) / idx->tag_seek[tag_length]; + data /= idx->tag_seek[tag_playcount]; } break; |