X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mp4.c;h=5ca1307f680d366c155b2e98257ba807c5a4fb92;hb=HEAD;hp=4b8607b185a9a87c845940d86412843654a13c7d;hpb=b142089267ef501e438c3dc77ecf19bead3d4e58;p=paraslash.git diff --git a/mp4.c b/mp4.c index 4b8607b1..fe9d4b37 100644 --- a/mp4.c +++ b/mp4.c @@ -131,7 +131,8 @@ static int read_int16(struct mp4 *f, uint16_t *result) return ret; } -/** A macro defining the atoms we care about. It gets expanded twice. */ +/** \cond atom_items */ +/* A macro defining the atoms we care about. It gets expanded twice. */ #define ATOM_ITEMS \ ATOM_ITEM(MOOV, 'm', 'o', 'o', 'v') /* movie (top-level container) */ \ ATOM_ITEM(TRAK, 't', 'r', 'a', 'k') /* container for a single track */ \ @@ -155,6 +156,8 @@ static int read_int16(struct mp4 *f, uint16_t *result) ATOM_ITEM(META, 'm', 'e', 't', 'a') /* iTunes Metadata box */ \ ATOM_ITEM(DATA, 'd', 'a', 't', 'a') /* iTunes Metadata data box */ \ +/** \endcond atom_items */ + /** For the C enumeration we concatenate ATOM_ with the first argument. */ #define ATOM_ITEM(_name, a, b, c, d) ATOM_ ## _name, /** The enumeration of interesting atoms. */ @@ -240,7 +243,7 @@ static int read_stsz(struct mp4 *f) 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) @@ -260,8 +263,7 @@ static int read_stts(struct mp4 *f) 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) @@ -284,9 +286,9 @@ static int read_stsc(struct mp4 *f) 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) @@ -310,8 +312,7 @@ static int read_stco(struct mp4 *f) 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) @@ -396,7 +397,7 @@ static int parse_tag(struct mp4 *f, uint8_t parent, int32_t size) 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; @@ -609,7 +610,7 @@ static int open_file(const struct mp4_callback *cb, bool meta_only, struct mp4 * 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) { @@ -918,7 +919,7 @@ static void *modify_moov(struct mp4 *f, uint32_t *out_size) 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); @@ -1046,7 +1047,7 @@ free_moov: * 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))