]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - wma_afh.c
wma: Fix chunk_table computation.
[paraslash.git] / wma_afh.c
index 2d463900e7be81d148cd3ab6dce554d61ce3044a..9e5f5c60fd01afa7045a8afa2941d5554a91b367 100644 (file)
--- a/wma_afh.c
+++ b/wma_afh.c
@@ -205,6 +205,8 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
        frames_per_chunk = num_frames / afhi->chunks_total;
        i = 0;
        j = 1;
+       start += afhi->header_len;
+       buf_size -= afhi->header_len;
        FOR_EACH_FRAME(f, start, buf_size, block_align) {
                count += f[WMA_FRAME_SKIP] & 0x0f;
                while (count > j * frames_per_chunk && f > start) {
@@ -216,7 +218,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align,
                                        ct_size * sizeof(uint32_t));
                        }
                        PARA_DEBUG_LOG("ct[%d]: %zu\n", j, f - start);
-                       afhi->chunk_table[j] = f - start;
+                       afhi->chunk_table[j] = f - start + afhi->header_len;
                }
        }
        afhi->chunks_total = j;
@@ -244,8 +246,7 @@ static int wma_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        afhi->header_len = ahi.header_len;
        afhi->header_offset = 0;
        read_asf_tags(map, ahi.header_len, &afhi->tags);
-       wma_make_chunk_table(map + ahi.header_len, numbytes - ahi.header_len,
-               ahi.block_align, afhi);
+       wma_make_chunk_table(map, numbytes, ahi.block_align, afhi);
        return 0;
 }