From: Andre Noll Date: Mon, 16 Nov 2009 22:40:53 +0000 (+0100) Subject: wma_afh: Compute the chunk time more accurately. X-Git-Tag: v0.4.1~19 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=3f24334e12773c5d4c9a602073e5f9a7c4a6d3f4;hp=e5a8a6805e12baade86cdab549b80863c2d1a843 wma_afh: Compute the chunk time more accurately. We already know the exact chunk time: It's a multiple of frames_per_chunk. --- diff --git a/wma_afh.c b/wma_afh.c index 94e6848b..e78802ee 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -185,16 +185,15 @@ next: } } -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 * 2048 * 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("chunk time: %lums\n", tv2ms(result)); } /* Must be called on a frame boundary. */ @@ -235,7 +234,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align, } } afhi->chunks_total = j; - set_chunk_tv(num_frames * 2048, j + 10 /* FIXME */, afhi->frequency, &afhi->chunk_tv); + set_chunk_tv(frames_per_chunk, afhi->frequency, &afhi->chunk_tv); return 1; fail: free(afhi->chunk_table);