]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - wma_afh.c
Various wma fixes.
[paraslash.git] / wma_afh.c
index 335ab890b4e129bb9f257f58c4158003770c0b63..2d463900e7be81d148cd3ab6dce554d61ce3044a 100644 (file)
--- a/wma_afh.c
+++ b/wma_afh.c
@@ -191,16 +191,15 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        const uint8_t *f, *start = (uint8_t *)buf;
        int i, j, frames_per_chunk, chunk_time;
        size_t ct_size = 250;
+       int count = 0, num_frames;
+
        afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t));
        afhi->chunk_table[0] = 0;
        afhi->chunk_table[1] = afhi->header_len;
 
-
-       int count = 0, num_frames;
-
        num_frames = count_frames(buf, buf_size, block_align,
                &afhi->chunks_total);
-       PARA_ERROR_LOG("%d frames\n", num_frames);
+       PARA_INFO_LOG("%d frames\n", num_frames);
        afhi->seconds_total = num_frames * 2048 /* FIXME */
                / afhi->frequency;
        frames_per_chunk = num_frames / afhi->chunks_total;
@@ -208,7 +207,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        j = 1;
        FOR_EACH_FRAME(f, start, buf_size, block_align) {
                count += f[WMA_FRAME_SKIP] & 0x0f;
-               while (count > j * frames_per_chunk) {
+               while (count > j * frames_per_chunk && f > start) {
                        j++;
                        if (j >= ct_size) {
                                ct_size *= 2;
@@ -223,7 +222,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        afhi->chunks_total = j;
        chunk_time = num_frames * 1000 / afhi->frequency * 2048
                / afhi->chunks_total;
-       PARA_ERROR_LOG("ct: %d\n", chunk_time);
+       PARA_INFO_LOG("ct: %d\n", chunk_time);
        afhi->chunk_tv.tv_sec = chunk_time / 1000;
        afhi->chunk_tv.tv_usec = (chunk_time % 1000) * 1000;
        //set_chunk_tv(num_frames, j, afhi->frequency, &afhi->chunk_tv);