From a4a2f9112b1ffb54f0c677523cc8e6a0e384d751 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 11 Mar 2007 17:50:23 +0100 Subject: [PATCH] aac_afh.c: Kill global variable num_chunks It's already stored in afi->chunks_total --- aac_afh.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/aac_afh.c b/aac_afh.c index 1633c00f..cd374c81 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -36,7 +36,7 @@ static struct audio_format_handler *af; static FILE *infile; static unsigned char *inbuf; -static size_t inbuf_len, num_chunks; +static size_t inbuf_len; static void aac_close_audio_file(void) { @@ -87,10 +87,10 @@ static int read_chunk_table(struct audio_format_info *afi, size_t skip) return -E_AAC_READ; PARA_INFO_LOG("next buffer: %d bytes\n", ret); } - num_chunks = ret; - PARA_INFO_LOG("sz table has %zu entries\n", num_chunks); - afi->chunk_table = para_malloc((num_chunks + 1) * sizeof(size_t)); - for (i = 1; i <= num_chunks; i++) { + afi->chunks_total = ret; + PARA_INFO_LOG("sz table has %lu entries\n", afi->chunks_total); + afi->chunk_table = para_malloc((afi->chunks_total + 1) * sizeof(size_t)); + for (i = 1; i <= afi->chunks_total; i++) { if (skip + 4 > inbuf_len) { skip = inbuf_len - skip; memmove(inbuf, inbuf + inbuf_len - skip, skip); @@ -104,7 +104,7 @@ static int read_chunk_table(struct audio_format_info *afi, size_t skip) sum += aac_read_int32(inbuf + skip); afi->chunk_table[i] = sum; skip += 4; - if (i < 10 || i + 10 > num_chunks) + if (i < 10 || i + 10 > afi->chunks_total) PARA_DEBUG_LOG("offset #%d: %zu\n", i, afi->chunk_table[i]); } return 1; @@ -114,14 +114,14 @@ static long unsigned aac_set_chunk_tv(struct audio_format_info *afi, mp4AudioSpecificConfig *mp4ASC) { float tmp = mp4ASC->sbr_present_flag == 1? 2047 : 1023, - ms = 1000.0 * num_chunks * tmp / mp4ASC->samplingFrequency; + ms = 1000.0 * afi->chunks_total * tmp / mp4ASC->samplingFrequency; struct timeval total; ms2tv(ms, &total); - tv_divide(num_chunks, &total, &afi->chunk_tv); - PARA_INFO_LOG("%luHz, %fs (%zd x %lums)\n", + tv_divide(afi->chunks_total, &total, &afi->chunk_tv); + PARA_INFO_LOG("%luHz, %fs (%lu x %lums)\n", mp4ASC->samplingFrequency, ms / 1000, - num_chunks, tv2ms(&afi->chunk_tv)); + afi->chunks_total, tv2ms(&afi->chunk_tv)); return ms / 1000; } @@ -162,7 +162,6 @@ static int aac_get_file_info(FILE *file, struct audio_format_info *afi) ret = read_chunk_table(afi, skip); if (ret < 0) return ret; - afi->chunks_total = num_chunks; afi->seconds_total = aac_set_chunk_tv(afi, &mp4ASC); for (;;) { ret = aac_find_entry_point(inbuf, inbuf_len, &skip); @@ -174,12 +173,12 @@ static int aac_get_file_info(FILE *file, struct audio_format_info *afi) PARA_INFO_LOG("next buffer: %d bytes\n", ret); } afi->chunk_table[0] = ret; - for (i = 1; i<= num_chunks; i++) + for (i = 1; i<= afi->chunks_total; i++) afi->chunk_table[i] += ret; - sprintf(afi->info_string, "audio_file_info1:%zu x %lums\n" + sprintf(afi->info_string, "audio_file_info1:%lu x %lums\n" "audio_file_info2:\n" "audio_file_info3:\n", - num_chunks, + afi->chunks_total, tv2ms(&afi->chunk_tv)); tv_scale(20, &afi->chunk_tv, &afi->eof_tv); return 1; -- 2.39.5