-struct membuffer {
- void *data;
- unsigned written;
- unsigned allocated;
-};
-
-static struct membuffer *membuffer_create(void)
-{
- struct membuffer *buf = para_calloc(sizeof(*buf));
-
- buf->allocated = 256;
- buf->data = para_malloc(buf->allocated);
- return buf;
-}
-
-static void membuffer_write(struct membuffer *buf, const void *ptr,
- unsigned bytes)
-{
- unsigned dest_size = buf->written + bytes;
-
- if (dest_size > buf->allocated) {
- do {
- buf->allocated <<= 1;
- } while (dest_size > buf->allocated);
- buf->data = para_realloc(buf->data, buf->allocated);
- }
-
- if (ptr)
- memcpy((char *) buf->data + buf->written, ptr, bytes);
- buf->written += bytes;
-}
-
-static void membuffer_write_atom_name(struct membuffer *buf, const char *data)
-{
- membuffer_write(buf, data, 4);
-}
-
-static void membuffer_write_int32(struct membuffer *buf, uint32_t data)
+/** Total length of an on-disk metadata tag. */
+#define TAG_LEN(_len) (24 + (_len))
+static void create_ilst(const struct mp4_metadata *meta, uint8_t *out)