+ p += 4;
+ return read_tags(p, buflen - (p - buf), afhi);
+ }
+}
+
+static void aac_get_taginfo(char *buf, size_t buflen, struct afh_info *afhi)
+{
+ int i;
+ uint64_t subsize;
+ char type[5];
+
+ for (i = 0; i + 24 < buflen; i++) {
+ char *p = buf + i;
+ if (p[0] != 'm' || p[1] != 'e' || p[2] != 't' || p[3] != 'a')
+ continue;
+ PARA_INFO_LOG("found metadata at offset %d\n", i);
+ i += 8;
+ p = buf + i;
+ i += read_atom_header(p, &subsize, type);
+ p = buf + i;
+ return read_meta(p, buflen - i, afhi);
+ }
+ PARA_INFO_LOG("no meta data\n");
+}
+
+static ssize_t aac_compute_chunk_table(struct afh_info *afhi,
+ char *map, size_t numbytes)
+{
+ int ret, i;
+ size_t sum = 0;
+ off_t skip;
+
+ ret = aac_find_stsz(map, numbytes, &skip);
+ if (ret < 0)
+ return ret;
+ afhi->chunks_total = ret;
+ PARA_DEBUG_LOG("sz table has %" PRIu32 " entries\n", afhi->chunks_total);
+ afhi->chunk_table = para_malloc((afhi->chunks_total + 1) * sizeof(size_t));
+ for (i = 1; i <= afhi->chunks_total; i++) {
+ if (skip + 4 > numbytes)
+ break;
+ sum += read_u32_be(map + skip);
+ afhi->chunk_table[i] = sum;