X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ogg_afh_common.c;h=61ded4dc99a9a8bd0bbcb508ccf325db277abc44;hp=ad5963ebc1488ca32d6c2055ee5009fd377d4c8c;hb=f189411b9986564c2652ef87e54189e5fa0d5d11;hpb=85d1f19df312c38936cf7721d67dcfb7ca034cfc diff --git a/ogg_afh_common.c b/ogg_afh_common.c index ad5963eb..61ded4dc 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -1,10 +1,10 @@ /* - * Copyright (C) 2004-2011 Andre Noll + * Copyright (C) 2004 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ -/** \file ogg_afh_common.c Functions common to ogg/vorbis and ogg/speex. */ +/** \file ogg_afh_common.c Functions common to all ogg/ codecs. */ #include #include @@ -93,16 +93,15 @@ out: return ret; } -static void set_chunk_tv(int num_frames, int num_chunks, int frequency, +static void set_chunk_tv(int frames_per_chunk, int frequency, struct timeval *result) { - uint64_t x = (uint64_t)num_frames * 1000 * 1000 - / frequency / num_chunks; + uint64_t x = (uint64_t)frames_per_chunk * 1000 * 1000 / frequency; result->tv_sec = x / 1000 / 1000; result->tv_usec = x % (1000 * 1000); - PARA_INFO_LOG("%d chunks, chunk time: %lums\n", num_chunks, - tv2ms(result)); + PARA_INFO_LOG("%d frames per chunk, chunk time: %lums\n", + frames_per_chunk, tv2ms(result)); } /** @@ -150,7 +149,7 @@ int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, afhi->header_len = oss.returned; oss.returned = 0; oss.fill = numbytes; - /* count ogg packages and get duration of the file */ + /* count ogg pages and get duration of the file */ for (i = 0; ogg_sync_pageseek(&oss, &op) > 0; i++) num_frames = ogg_page_granulepos(&op); PARA_INFO_LOG("%d pages, %llu frames\n", i, num_frames); @@ -171,7 +170,7 @@ int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, for (j = 1; ogg_sync_pageseek(&oss, &op) > 0; /* nothing */) { int granule = ogg_page_granulepos(&op); - while (granule > j * frames_per_chunk) { + while (granule >= (j + 1) * frames_per_chunk) { j++; if (j >= ct_size) { ct_size *= 2; @@ -183,7 +182,7 @@ int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, } } afhi->chunks_total = j; - set_chunk_tv(num_frames, j, afhi->frequency, &afhi->chunk_tv); + set_chunk_tv(frames_per_chunk, afhi->frequency, &afhi->chunk_tv); ret = 0; out: ogg_sync_clear(&oss);