/** A macro defining the atoms we care about. It gets expanded twice. */
#define ATOM_ITEMS \
- ATOM_ITEM(MOOV, 'm', 'o', 'o', 'v') \
- ATOM_ITEM(TRAK, 't', 'r', 'a', 'k') \
- ATOM_ITEM(MDIA, 'm', 'd', 'i', 'a') \
- ATOM_ITEM(MINF, 'm', 'i', 'n', 'f') \
- ATOM_ITEM(STBL, 's', 't', 'b', 'l') \
- ATOM_ITEM(UDTA, 'u', 'd', 't', 'a') \
+ ATOM_ITEM(MOOV, 'm', 'o', 'o', 'v') /* movie (top-level container) */ \
+ ATOM_ITEM(TRAK, 't', 'r', 'a', 'k') /* container for a single track */ \
+ ATOM_ITEM(MDIA, 'm', 'd', 'i', 'a') /* media information */ \
+ ATOM_ITEM(MINF, 'm', 'i', 'n', 'f') /* extends mdia */ \
+ ATOM_ITEM(STBL, 's', 't', 'b', 'l') /* sample table container */ \
+ ATOM_ITEM(UDTA, 'u', 'd', 't', 'a') /* user data */ \
ATOM_ITEM(ILST, 'i', 'l', 's', 't') /* iTunes Metadata list */ \
- ATOM_ITEM(ARTIST, 0xa9, 'A', 'R', 'T') \
- ATOM_ITEM(TITLE, 0xa9, 'n', 'a', 'm') \
- ATOM_ITEM(ALBUM, 0xa9, 'a', 'l', 'b') \
- ATOM_ITEM(DATE, 0xa9, 'd', 'a', 'y') \
- ATOM_ITEM(COMMENT, 0xa9, 'c', 'm', 't') \
+ ATOM_ITEM(ARTIST, 0xa9, 'A', 'R', 'T') /* artist */ \
+ ATOM_ITEM(TITLE, 0xa9, 'n', 'a', 'm') /* title */ \
+ ATOM_ITEM(ALBUM, 0xa9, 'a', 'l', 'b') /* album */ \
+ ATOM_ITEM(DATE, 0xa9, 'd', 'a', 'y') /* date */ \
+ ATOM_ITEM(COMMENT, 0xa9, 'c', 'm', 't') /* comment */ \
ATOM_ITEM(MDHD, 'm', 'd', 'h', 'd') /* track header */ \
ATOM_ITEM(STSD, 's', 't', 's', 'd') /* sample description box */ \
ATOM_ITEM(STTS, 's', 't', 't', 's') /* time to sample box */ \
ATOM_ITEM(STSZ, 's', 't', 's', 'z') /* sample size box */ \
ATOM_ITEM(STCO, 's', 't', 'c', 'o') /* chunk offset box */ \
ATOM_ITEM(STSC, 's', 't', 's', 'c') /* sample to chunk box */ \
- ATOM_ITEM(MP4A, 'm', 'p', '4', 'a') \
+ ATOM_ITEM(MP4A, 'm', 'p', '4', 'a') /* mp4 audio */ \
ATOM_ITEM(META, 'm', 'e', 't', 'a') /* iTunes Metadata box */ \
ATOM_ITEM(DATA, 'd', 'a', 't', 'a') /* iTunes Metadata data box */ \
return ret;
if (t->stsz_sample_size != 0)
return 1;
- t->stsz_table = para_malloc(t->stsz_sample_count * sizeof(int32_t));
+ t->stsz_table = arr_alloc(t->stsz_sample_count, sizeof(int32_t));
for (uint32_t n = 0; n < t->stsz_sample_count; n++) {
ret = read_int32(f, &t->stsz_table[n]);
if (ret <= 0)
ret = read_int32(f, &t->stts_entry_count);
if (ret <= 0)
return ret;
- t->stts_sample_count = para_malloc(t->stts_entry_count
- * sizeof(int32_t));
+ t->stts_sample_count = arr_alloc(t->stts_entry_count, sizeof(int32_t));
for (uint32_t n = 0; n < t->stts_entry_count; n++) {
ret = read_int32(f, &t->stts_sample_count[n]);
if (ret <= 0)
ret = read_int32(f, &t->stsc_entry_count);
if (ret <= 0)
return ret;
- t->stsc_first_chunk = para_malloc(t->stsc_entry_count * sizeof(int32_t));
- t->stsc_samples_per_chunk = para_malloc(t->stsc_entry_count
- * sizeof (int32_t));
+ t->stsc_first_chunk = arr_alloc(t->stsc_entry_count, sizeof(int32_t));
+ t->stsc_samples_per_chunk = arr_alloc(t->stsc_entry_count,
+ sizeof (int32_t));
for (uint32_t n = 0; n < t->stsc_entry_count; n++) {
ret = read_int32(f, &t->stsc_first_chunk[n]);
if (ret <= 0)
ret = read_int32(f, &t->stco_entry_count);
if (ret <= 0)
return ret;
- t->stco_chunk_offset = para_malloc(t->stco_entry_count
- * sizeof(int32_t));
+ t->stco_chunk_offset = arr_alloc(t->stco_entry_count, sizeof(int32_t));
for (uint32_t n = 0; n < t->stco_entry_count; n++) {
ret = read_int32(f, &t->stco_chunk_offset[n]);
if (ret <= 0)
goto fail;
len = subsize - (header_size + 8);
free(value);
- value = para_malloc(len + 1);
+ value = alloc(len + 1);
ret = read_data(f, value, len);
if (ret <= 0)
goto fail;
int ret;
uint64_t size;
uint8_t atom_type, header_size;
- struct mp4 *f = para_calloc(sizeof(*f));
+ struct mp4 *f = zalloc(sizeof(*f));
f->cb = cb;
while ((ret = atom_read_header(f, &atom_type, &header_size, &size)) > 0) {
new_ilst_size += TAG_LEN(strlen(f->meta.tags[n].value));
size_delta = new_ilst_size - (f->ilst_size - 8);
*out_size = total_size + size_delta;
- out_buffer = para_malloc(*out_size);
+ out_buffer = alloc(*out_size);
p_out = out_buffer;
set_position(f, total_base);
ret = read_data(f, p_out, f->udta_offset - total_base);
* function also returns NULL. Otherwise a copy of the tag value is returned
* and the caller should free this memory when it is no longer needed.
*/
-char *mp4_get_tag_value(const struct mp4 *f, const char *item)
+__malloc char *mp4_get_tag_value(const struct mp4 *f, const char *item)
{
for (unsigned n = 0; n < f->meta.count; n++)
if (!strcasecmp(f->meta.tags[n].item, item))