X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=wma_afh.c;h=cfa7304043704bcda166f6050a16392689b00ff8;hp=94e6848b517c490487870ca29b25767baeb4ff43;hb=47a9983cc65ef57ad25c4ba3e16cabe48fd57b23;hpb=9342a7de77e5b2279813051ae225da3b01eeb430 diff --git a/wma_afh.c b/wma_afh.c index 94e6848b..cfa73040 100644 --- a/wma_afh.c +++ b/wma_afh.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Andre Noll + * Copyright (C) 2009-2014 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -132,7 +132,7 @@ static const char album_tag_header[] = { /* WM/AlbumTitle */ static void read_asf_tags(const char *buf, int buf_size, struct taginfo *ti) { const char *p, *end = buf + buf_size, *q; - uint16_t len1, len2, len3, len4, len5; + uint16_t len1, len2, len3, len4; p = search_pattern(comment_header, sizeof(comment_header), buf, buf_size); @@ -149,7 +149,7 @@ static void read_asf_tags(const char *buf, int buf_size, struct taginfo *ti) p += 2; len4 = read_u16(p); p += 2; - len5 = read_u16(p); + /* ignore length of the rating information */ p += 2; if (p + len1 >= end) goto next; @@ -158,10 +158,10 @@ static void read_asf_tags(const char *buf, int buf_size, struct taginfo *ti) if (p + len2 >= end) goto next; ti->artist = get_str16(p, len2); - p += len2 + len3 + len4; - if (p + len5 >= end) + p += len2 + len3; + if (p + len4 >= end) goto next; - ti->comment = get_str16(p, len5); + ti->comment = get_str16(p, len4); next: p = search_pattern(extended_content_header, sizeof(extended_content_header), buf, buf_size); @@ -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. */ @@ -202,7 +201,7 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align, struct afh_info *afhi) { const uint8_t *f, *start = (uint8_t *)buf; - int i, j, frames_per_chunk; + int j, frames_per_chunk; size_t ct_size = 250; int ret, count = 0, num_frames, num_superframes; @@ -217,9 +216,8 @@ static int wma_make_chunk_table(char *buf, size_t buf_size, int block_align, goto fail; afhi->seconds_total = num_frames * 2048 /* FIXME */ / afhi->frequency; - frames_per_chunk = num_frames / num_superframes; + frames_per_chunk = num_frames / num_superframes / 2; PARA_INFO_LOG("%d frames per chunk\n", frames_per_chunk); - i = 0; j = 1; FOR_EACH_FRAME(f, start, buf_size, block_align) { count += f[WMA_FRAME_SKIP] & 0x0f; @@ -235,7 +233,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); @@ -259,7 +257,15 @@ static int wma_get_file_info(char *map, size_t numbytes, __a_unused int fd, afhi->frequency = ahi.sample_rate; afhi->channels = ahi.channels; afhi->header_len = ahi.header_len; - afhi->header_offset = 0; + + afhi->techinfo = make_message("%s%s%s%s%s", + ahi.use_exp_vlc? "exp vlc" : "", + (ahi.use_bit_reservoir && ahi.use_exp_vlc)? ", " : "", + ahi.use_bit_reservoir? "bit reservoir" : "", + (ahi.use_variable_block_len && + (ahi.use_exp_vlc || ahi.use_bit_reservoir)? ", " : ""), + ahi.use_variable_block_len? "vbl" : "" + ); wma_make_chunk_table(map + ahi.header_len, numbytes - ahi.header_len, ahi.block_align, afhi); read_asf_tags(map, ahi.header_len, &afhi->tags);