return read_u32_be(&src);
}
-static uint32_t modify_moov(struct mp4 *f, void **out_buffer,
- uint32_t *out_size)
+static void *modify_moov(struct mp4 *f, uint32_t *out_size)
{
uint64_t total_base = f->moov_offset + 8;
uint32_t total_size = (uint32_t) (f->moov_size - 8);
uint32_t udta_size, meta_size, ilst_size;
uint32_t new_ilst_size;
- void *new_ilst_buffer;
+ void *new_ilst_buffer, *out_buffer;
uint8_t *p_out;
int32_t size_delta;
void *new_udta_buffer;
uint32_t new_udta_size;
if (!create_udta(&f->meta, &new_udta_buffer, &new_udta_size))
- return 0;
+ return NULL;
buf = membuffer_create();
set_position(f, total_base);
free(new_udta_buffer);
*out_size = membuffer_get_size(buf);
- *out_buffer = membuffer_detach(buf);
+ out_buffer = membuffer_detach(buf);
membuffer_free(buf);
- return 1;
+ return out_buffer;
}
udta_offset = get_position(f);
udta_size = read_int32(f);
uint32_t new_meta_size;
if (!create_meta(&f->meta, &new_meta_buffer, &new_meta_size))
- return 0;
+ return NULL;
buf = membuffer_create();
set_position(f, total_base);
free(new_meta_buffer);
*out_size = membuffer_get_size(buf);
- *out_buffer = membuffer_detach(buf);
+ out_buffer = membuffer_detach(buf);
membuffer_free(buf);
- return 1;
+ return out_buffer;
}
meta_offset = get_position(f);
meta_size = read_int32(f);
+ /* shouldn't happen, find_atom_v2 above takes care of it */
if (!find_atom(f, meta_offset + 12, meta_size - 12, "ilst"))
- return 0; /* shouldn't happen, find_atom_v2 above takes care of it */
+ return NULL;
ilst_offset = get_position(f);
ilst_size = read_int32(f);
if (!create_ilst(&f->meta, &new_ilst_buffer, &new_ilst_size))
- return 0;
+ return NULL;
size_delta = new_ilst_size - (ilst_size - 8);
*out_size = total_size + size_delta;
- *out_buffer = para_malloc(*out_size);
- p_out = (uint8_t *)*out_buffer;
+ out_buffer = para_malloc(*out_size);
+ p_out = out_buffer;
set_position(f, total_base);
read_data(f, p_out, (uint32_t) (udta_offset - total_base));
p_out += (uint32_t) (udta_offset - total_base);
read_data(f, p_out, (uint32_t) (total_size
- (ilst_offset - total_base) - ilst_size));
free(new_ilst_buffer);
- return 1;
+ return out_buffer;
}
static int32_t write_data(struct mp4 *f, void *data, uint32_t size)
uint32_t new_moov_size;
set_position(f, 0);
- if (!modify_moov(f, &new_moov_data, &new_moov_size)) {
+ new_moov_data = modify_moov(f, &new_moov_size);
+ if (!new_moov_data ) {
mp4_close(f);
return 0;
}