]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
ogg_afh: Compute chunk time more accurately.
authorAndre Noll <maan@systemlinux.org>
Mon, 17 Jan 2011 07:24:37 +0000 (08:24 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 13 Feb 2011 22:14:48 +0000 (23:14 +0100)
The chunk table is constructed so that each chunk corresponds to
frames_per_chunk samples as determined by the granule position of
the ogg page. Use this exact value for computing the duration of a
chunk rather than the avaerage num_frames / num_chunks.

ogg_afh_common.c

index 474bbe412d27f997ff01f0bc6b67cad3e8965875..72fab7c14db9caeb8e5459dbead0798fb2e46c67 100644 (file)
@@ -91,16 +91,15 @@ out:
        return ret;
 }
 
        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)
 {
                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);
 
        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));
 }
 
 /**
 }
 
 /**
@@ -178,7 +177,7 @@ int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi,
                }
        }
        afhi->chunks_total = j;
                }
        }
        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);
        ret = 0;
 out:
        ogg_sync_clear(&oss);