+ p += 4;
+ return read_tags(p, buflen - (p - buf), afhi);
+ }
+}
+
+static void aac_get_taginfo(unsigned char *buf, size_t buflen,
+ struct afh_info *afhi)
+{
+ int i;
+ uint64_t subsize;
+ unsigned char type[5];
+
+ for (i = 0; i + 24 < buflen; i++) {
+ unsigned 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,
+ unsigned 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 %lu 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 += aac_read_int32(map + skip);
+ afhi->chunk_table[i] = sum;