]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Replace mp4ff prefix by mp4.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 11 Aug 2021 16:31:55 +0000 (18:31 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
The additional "ff" does not convey any useful information.

This patch was produced by running

sed -i 's/mp4ff/mp4/g' mp4.c mp4.h aac_afh.c

followed by

sed -i 's/MP4FF/MP4/g' aac_afh.c error.h

and the manual removal of the "ff" suffix in the error strings.

aac_afh.c
error.h
mp4.c
mp4.h

index 0993913a9e16766dde1c7902e50679f000de34e3..aed2153608fc56616be17a291230f6d8be4b5f4c 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -23,8 +23,8 @@ struct aac_afh_context {
        size_t mapsize;
        size_t fpos;
        int32_t track;
-       struct mp4ff *mp4ff;
-       struct mp4ff_callback cb;
+       struct mp4 *mp4;
+       struct mp4_callback cb;
 };
 
 static uint32_t aac_afh_read_cb(void *user_data, void *dest, uint32_t want)
@@ -49,16 +49,16 @@ static uint32_t aac_afh_seek_cb(void *user_data, uint64_t pos)
        return 0;
 }
 
-static int32_t aac_afh_get_track(struct mp4ff *mp4ff)
+static int32_t aac_afh_get_track(struct mp4 *mp4)
 {
-       int32_t i, rc, num_tracks = mp4ff_total_tracks(mp4ff);
+       int32_t i, rc, num_tracks = mp4_total_tracks(mp4);
 
        assert(num_tracks >= 0);
        for (i = 0; i < num_tracks; i++) {
                unsigned char *buf = NULL;
                unsigned buf_size = 0;
 
-               mp4ff_get_decoder_config(mp4ff, i, &buf, &buf_size);
+               mp4_get_decoder_config(mp4, i, &buf, &buf_size);
                if (buf) {
                        mp4AudioSpecificConfig masc;
                        rc = NeAACDecAudioSpecificConfig(buf, buf_size, &masc);
@@ -83,18 +83,18 @@ static int aac_afh_open(const void *map, size_t mapsize, void **afh_context)
        c->cb.seek = aac_afh_seek_cb;
        c->cb.user_data = c;
 
-       ret = -E_MP4FF_OPEN;
-       c->mp4ff = mp4ff_open_read(&c->cb);
-       if (!c->mp4ff)
+       ret = -E_MP4_OPEN;
+       c->mp4 = mp4_open_read(&c->cb);
+       if (!c->mp4)
                goto free_ctx;
-       c->track = aac_afh_get_track(c->mp4ff);
-       ret = -E_MP4FF_TRACK;
+       c->track = aac_afh_get_track(c->mp4);
+       ret = -E_MP4_TRACK;
        if (c->track < 0)
-               goto close_mp4ff;
+               goto close_mp4;
        *afh_context = c;
        return 0;
-close_mp4ff:
-       mp4ff_close(c->mp4ff);
+close_mp4:
+       mp4_close(c->mp4);
 free_ctx:
        free(c);
        *afh_context = NULL;
@@ -104,7 +104,7 @@ free_ctx:
 static void aac_afh_close(void *afh_context)
 {
        struct aac_afh_context *c = afh_context;
-       mp4ff_close(c->mp4ff);
+       mp4_close(c->mp4);
        free(c);
 }
 
@@ -116,24 +116,24 @@ static int aac_afh_get_chunk(uint32_t chunk_num, void *afh_context,
        size_t offset;
 
        assert(chunk_num <= INT_MAX);
-       mp4ff_set_sample_position(c->mp4ff, c->track, chunk_num);
+       mp4_set_sample_position(c->mp4, c->track, chunk_num);
        offset = c->fpos;
-       ss = mp4ff_get_sample_size(c->mp4ff, c->track, chunk_num);
+       ss = mp4_get_sample_size(c->mp4, c->track, chunk_num);
        if (ss <= 0)
-               return -E_MP4FF_BAD_SAMPLE;
+               return -E_MP4_BAD_SAMPLE;
        assert(ss + offset <= c->mapsize);
        *buf = c->map + offset;
        *len = ss;
        return 1;
 }
 
-static void _aac_afh_get_taginfo(const struct mp4ff *mp4ff, struct taginfo *tags)
+static void _aac_afh_get_taginfo(const struct mp4 *mp4, struct taginfo *tags)
 {
-       mp4ff_meta_get_artist(mp4ff, &tags->artist);
-       mp4ff_meta_get_title(mp4ff, &tags->title);
-       mp4ff_meta_get_date(mp4ff, &tags->year);
-       mp4ff_meta_get_album(mp4ff, &tags->album);
-       mp4ff_meta_get_comment(mp4ff, &tags->comment);
+       mp4_meta_get_artist(mp4, &tags->artist);
+       mp4_meta_get_title(mp4, &tags->title);
+       mp4_meta_get_date(mp4, &tags->year);
+       mp4_meta_get_album(mp4, &tags->album);
+       mp4_meta_get_comment(mp4, &tags->comment);
 }
 
 /*
@@ -153,20 +153,20 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
        if (ret < 0)
                return ret;
 
-       ret = -E_MP4FF_BAD_SAMPLERATE;
-       rv = mp4ff_get_sample_rate(c->mp4ff, c->track);
+       ret = -E_MP4_BAD_SAMPLERATE;
+       rv = mp4_get_sample_rate(c->mp4, c->track);
        if (rv <= 0)
                goto close;
        afhi->frequency = rv;
 
-       ret = -E_MP4FF_BAD_CHANNEL_COUNT;
-       rv = mp4ff_get_channel_count(c->mp4ff, c->track);
+       ret = -E_MP4_BAD_CHANNEL_COUNT;
+       rv = mp4_get_channel_count(c->mp4, c->track);
        if (rv <= 0)
                goto close;
        afhi->channels = rv;
 
-       ret = -E_MP4FF_BAD_SAMPLE_COUNT;
-       rv = mp4ff_num_samples(c->mp4ff, c->track);
+       ret = -E_MP4_BAD_SAMPLE_COUNT;
+       rv = mp4_num_samples(c->mp4, c->track);
        if (rv <= 0)
                goto close;
        afhi->chunks_total = rv;
@@ -176,13 +176,13 @@ static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
                        break;
                afhi->max_chunk_size = PARA_MAX(afhi->max_chunk_size, len);
        }
-       milliseconds = mp4ff_get_duration(c->mp4ff, c->track);
+       milliseconds = mp4_get_duration(c->mp4, c->track);
        afhi->seconds_total = milliseconds / 1000;
        ms2tv(milliseconds / afhi->chunks_total, &afhi->chunk_tv);
        if (aac_afh_get_chunk(0, c, &buf, &len) >= 0)
                numbytes -= buf - map;
        afhi->bitrate = 8 * numbytes / afhi->seconds_total / 1000;
-       _aac_afh_get_taginfo(c->mp4ff, &afhi->tags);
+       _aac_afh_get_taginfo(c->mp4, &afhi->tags);
        ret = 1;
 close:
        aac_afh_close(c);
@@ -214,14 +214,14 @@ static uint32_t aac_afh_meta_truncate_cb(void *user_data)
        return ftruncate(fd, offset);
 }
 
-static void replace_tag(struct mp4ff_tag *tag, const char *new_val, bool *found)
+static void replace_tag(struct mp4_tag *tag, const char *new_val, bool *found)
 {
        free(tag->value);
        tag->value = para_strdup(new_val);
        *found = true;
 }
 
-static void add_tag(struct mp4ff_metadata *md, const char *item, const char *value)
+static void add_tag(struct mp4_metadata *md, const char *item, const char *value)
 {
        md->tags[md->count].item = para_strdup(item);
        md->tags[md->count].value = para_strdup(value);
@@ -233,9 +233,9 @@ static int aac_afh_rewrite_tags(const char *map, size_t mapsize,
 {
        int ret, i;
        int32_t rv;
-       struct mp4ff_metadata metadata;
-       struct mp4ff *mp4ff;
-       struct mp4ff_callback cb = {
+       struct mp4_metadata metadata;
+       struct mp4 *mp4;
+       struct mp4_callback cb = {
                .read = aac_afh_meta_read_cb,
                .seek = aac_afh_meta_seek_cb,
                .write = aac_afh_meta_write_cb,
@@ -250,23 +250,23 @@ static int aac_afh_rewrite_tags(const char *map, size_t mapsize,
                return ret;
        lseek(fd, 0, SEEK_SET);
 
-       mp4ff = mp4ff_open_meta(&cb);
-       if (!mp4ff)
-               return -E_MP4FF_OPEN;
+       mp4 = mp4_open_meta(&cb);
+       if (!mp4)
+               return -E_MP4_OPEN;
 
-       ret = -E_MP4FF_META_READ;
-       rv = mp4ff_meta_get_num_items(mp4ff);
+       ret = -E_MP4_META_READ;
+       rv = mp4_meta_get_num_items(mp4);
        if (rv < 0)
                goto close;
        metadata.count = rv;
        PARA_NOTICE_LOG("%d metadata item(s) found\n", rv);
 
-       metadata.tags = para_malloc((metadata.count + 5) * sizeof(struct mp4ff_tag));
+       metadata.tags = para_malloc((metadata.count + 5) * sizeof(struct mp4_tag));
        for (i = 0; i < metadata.count; i++) {
-               struct mp4ff_tag *tag = metadata.tags + i;
+               struct mp4_tag *tag = metadata.tags + i;
 
-               ret = -E_MP4FF_META_READ;
-               if (!mp4ff_meta_get_by_index(mp4ff, i, &tag->item, &tag->value))
+               ret = -E_MP4_META_READ;
+               if (!mp4_meta_get_by_index(mp4, i, &tag->item, &tag->value))
                        goto free_tags;
                PARA_INFO_LOG("found: %s: %s\n", tag->item, tag->value);
                if (!strcmp(tag->item, "artist"))
@@ -290,8 +290,8 @@ static int aac_afh_rewrite_tags(const char *map, size_t mapsize,
                add_tag(&metadata, "date", tags->year);
        if (!found_comment)
                add_tag(&metadata, "comment", tags->comment);
-       ret = -E_MP4FF_META_WRITE;
-       if (!mp4ff_meta_update(&cb, &metadata))
+       ret = -E_MP4_META_WRITE;
+       if (!mp4_meta_update(&cb, &metadata))
                goto free_tags;
        ret = 1;
 free_tags:
@@ -301,7 +301,7 @@ free_tags:
        }
        free(metadata.tags);
 close:
-       mp4ff_close(mp4ff);
+       mp4_close(mp4);
        return ret;
 }
 
diff --git a/error.h b/error.h
index 60c23294d1270c9aa8b4f56d69a1def2f1fac9b8..c69a192ef694ace681aeac1232e9e196ba27aaef 100644 (file)
--- a/error.h
+++ b/error.h
        PARA_ERROR(MP3DEC_CORRUPT, "too many corrupt frames"), \
        PARA_ERROR(MP3DEC_EOF, "mp3dec: end of file"), \
        PARA_ERROR(MP3_INFO, "could not read mp3 info"), \
-       PARA_ERROR(MP4FF_BAD_CHANNEL_COUNT, "mp4ff: invalid number of channels"), \
-       PARA_ERROR(MP4FF_BAD_SAMPLE, "mp4ff: invalid sample number"), \
-       PARA_ERROR(MP4FF_BAD_SAMPLERATE, "mp4ff: invalid sample rate"), \
-       PARA_ERROR(MP4FF_BAD_SAMPLE_COUNT, "mp4ff: invalid number of samples"), \
-       PARA_ERROR(MP4FF_META_READ, "mp4ff: could not read mp4 metadata"), \
-       PARA_ERROR(MP4FF_META_WRITE, "mp4ff: could not update mp4 metadata"), \
-       PARA_ERROR(MP4FF_OPEN, "mp4ff: open failed"), \
-       PARA_ERROR(MP4FF_TRACK, "mp4ff: no audio track"), \
+       PARA_ERROR(MP4_BAD_CHANNEL_COUNT, "mp4: invalid number of channels"), \
+       PARA_ERROR(MP4_BAD_SAMPLE, "mp4: invalid sample number"), \
+       PARA_ERROR(MP4_BAD_SAMPLERATE, "mp4: invalid sample rate"), \
+       PARA_ERROR(MP4_BAD_SAMPLE_COUNT, "mp4: invalid number of samples"), \
+       PARA_ERROR(MP4_META_READ, "mp4: could not read mp4 metadata"), \
+       PARA_ERROR(MP4_META_WRITE, "mp4: could not update mp4 metadata"), \
+       PARA_ERROR(MP4_OPEN, "mp4: open failed"), \
+       PARA_ERROR(MP4_TRACK, "mp4: no audio track"), \
        PARA_ERROR(MPI_SCAN, "could not scan multi-precision integer"), \
        PARA_ERROR(NAME_TOO_LONG, "name too long for struct sockaddr_un"), \
        PARA_ERROR(NO_AFHI, "audio format handler info required"), \
diff --git a/mp4.c b/mp4.c
index 3bf2ae4eed7dcc0a5695b87ac0bacbe90332be5f..d9f86fc7414685c5448252f8e8048c2979935d88 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -12,7 +12,7 @@
 #include "string.h"
 #include "mp4.h"
 
-struct mp4ff_track {
+struct mp4_track {
        int32_t type;
        int32_t channelCount;
        int32_t sampleSize;
@@ -60,9 +60,9 @@ struct mp4ff_track {
 
 #define MAX_TRACKS 1024
 
-struct mp4ff {
+struct mp4 {
        /* stream to read from */
-       struct mp4ff_callback *stream;
+       struct mp4_callback *stream;
        int64_t current_position;
 
        uint64_t moov_offset;
@@ -79,18 +79,18 @@ struct mp4ff {
        int32_t total_tracks;
 
        /* track data */
-       struct mp4ff_track *track[MAX_TRACKS];
+       struct mp4_track *track[MAX_TRACKS];
 
        /* metadata */
-       struct mp4ff_metadata tags;
+       struct mp4_metadata tags;
 };
 
-int32_t mp4ff_total_tracks(const struct mp4ff *f)
+int32_t mp4_total_tracks(const struct mp4 *f)
 {
        return f->total_tracks;
 }
 
-static int32_t read_data(struct mp4ff *f, void *data, uint32_t size)
+static int32_t read_data(struct mp4 *f, void *data, uint32_t size)
 {
        int32_t result = 1;
 
@@ -104,7 +104,7 @@ static int32_t read_data(struct mp4ff *f, void *data, uint32_t size)
        return result;
 }
 
-static uint64_t read_int64(struct mp4ff *f)
+static uint64_t read_int64(struct mp4 *f)
 {
        uint8_t data[8];
 
@@ -368,7 +368,7 @@ static uint8_t atom_name_to_type(int8_t a, int8_t b, int8_t c, int8_t d)
 }
 
 /* read atom header, return atom size, atom size is with header included */
-static uint64_t atom_read_header(struct mp4ff *f, uint8_t * atom_type,
+static uint64_t atom_read_header(struct mp4 *f, uint8_t * atom_type,
                                uint8_t * header_size)
 {
        uint64_t size;
@@ -392,7 +392,7 @@ static uint64_t atom_read_header(struct mp4ff *f, uint8_t * atom_type,
        return size;
 }
 
-static int64_t get_position(const struct mp4ff *f)
+static int64_t get_position(const struct mp4 *f)
 {
        return f->current_position;
 }
@@ -418,7 +418,7 @@ static int need_parse_when_meta_only(uint8_t atom_type)
        }
 }
 
-static int32_t set_position(struct mp4ff *f, int64_t position)
+static int32_t set_position(struct mp4 *f, int64_t position)
 {
        f->stream->seek(f->stream->user_data, position);
        f->current_position = position;
@@ -426,7 +426,7 @@ static int32_t set_position(struct mp4ff *f, int64_t position)
        return 0;
 }
 
-static void track_add(struct mp4ff *f)
+static void track_add(struct mp4 *f)
 {
        f->total_tracks++;
 
@@ -435,17 +435,17 @@ static void track_add(struct mp4ff *f)
                f->error++;
                return;
        }
-       f->track[f->total_tracks - 1] = para_calloc(sizeof(struct mp4ff_track));
+       f->track[f->total_tracks - 1] = para_calloc(sizeof(struct mp4_track));
 }
 
-static uint8_t read_char(struct mp4ff *f)
+static uint8_t read_char(struct mp4 *f)
 {
        uint8_t output;
        read_data(f, &output, 1);
        return output;
 }
 
-static uint32_t read_int24(struct mp4ff *f)
+static uint32_t read_int24(struct mp4 *f)
 {
        int8_t data[4];
 
@@ -453,7 +453,7 @@ static uint32_t read_int24(struct mp4ff *f)
        return read_u24_be(data);
 }
 
-static uint32_t read_int32(struct mp4ff *f)
+static uint32_t read_int32(struct mp4 *f)
 {
        int8_t data[4];
 
@@ -461,10 +461,10 @@ static uint32_t read_int32(struct mp4ff *f)
        return read_u32_be(data);
 }
 
-static int32_t read_stsz(struct mp4ff *f)
+static int32_t read_stsz(struct mp4 *f)
 {
        int32_t i;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -481,10 +481,10 @@ static int32_t read_stsz(struct mp4ff *f)
        return 0;
 }
 
-static int32_t read_stts(struct mp4ff *f)
+static int32_t read_stts(struct mp4 *f)
 {
        int32_t i;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        /* CVE-2017-9223 */
        if (f->total_tracks == 0)
@@ -508,10 +508,10 @@ static int32_t read_stts(struct mp4ff *f)
        return 1;
 }
 
-static int32_t read_ctts(struct mp4ff *f)
+static int32_t read_ctts(struct mp4 *f)
 {
        int32_t i;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -536,10 +536,10 @@ static int32_t read_ctts(struct mp4ff *f)
        return 1;
 }
 
-static int32_t read_stsc(struct mp4ff *f)
+static int32_t read_stsc(struct mp4 *f)
 {
        int32_t i;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -563,10 +563,10 @@ static int32_t read_stsc(struct mp4ff *f)
        return 0;
 }
 
-static int32_t read_stco(struct mp4ff *f)
+static int32_t read_stco(struct mp4 *f)
 {
        int32_t i;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -583,7 +583,7 @@ static int32_t read_stco(struct mp4ff *f)
        return 0;
 }
 
-static uint16_t read_int16(struct mp4ff *f)
+static uint16_t read_int16(struct mp4 *f)
 {
        int8_t data[2];
 
@@ -591,7 +591,7 @@ static uint16_t read_int16(struct mp4ff *f)
        return read_u16_be(data);
 }
 
-static uint32_t read_mp4_descr_length(struct mp4ff *f)
+static uint32_t read_mp4_descr_length(struct mp4 *f)
 {
        uint8_t b;
        uint8_t numBytes = 0;
@@ -605,11 +605,11 @@ static uint32_t read_mp4_descr_length(struct mp4ff *f)
 
        return length;
 }
-static int32_t read_esds(struct mp4ff *f)
+static int32_t read_esds(struct mp4 *f)
 {
        uint8_t tag;
        uint32_t temp;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -659,12 +659,12 @@ static int32_t read_esds(struct mp4ff *f)
        return 0;
 }
 
-static int32_t read_mp4a(struct mp4ff *f)
+static int32_t read_mp4a(struct mp4 *f)
 {
        int32_t i;
        uint8_t atom_type = 0;
        uint8_t header_size = 0;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        if (f->total_tracks == 0)
                return f->error++;
@@ -694,11 +694,11 @@ static int32_t read_mp4a(struct mp4ff *f)
        return 0;
 }
 
-static int32_t read_stsd(struct mp4ff *f)
+static int32_t read_stsd(struct mp4 *f)
 {
        int32_t i;
        uint8_t header_size = 0;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        /* CVE-2017-9218 */
        if (f->total_tracks == 0)
@@ -734,7 +734,7 @@ static int32_t read_stsd(struct mp4ff *f)
        return 0;
 }
 
-static int32_t read_mvhd(struct mp4ff *f)
+static int32_t read_mvhd(struct mp4 *f)
 {
        int32_t i;
 
@@ -760,13 +760,13 @@ static int32_t read_mvhd(struct mp4ff *f)
        return 0;
 }
 
-static int32_t tag_add_field(struct mp4ff_metadata *tags, const char *item,
+static int32_t tag_add_field(struct mp4_metadata *tags, const char *item,
                const char *value, int32_t len)
 {
        if (!item || (item && !*item) || !value)
                return 0;
        tags->tags = para_realloc(tags->tags,
-               (tags->count + 1) * sizeof(struct mp4ff_tag));
+               (tags->count + 1) * sizeof(struct mp4_tag));
        tags->tags[tags->count].item = para_strdup(item);
        tags->tags[tags->count].len = len;
        if (len >= 0) {
@@ -820,7 +820,7 @@ static const char *meta_index_to_genre(uint32_t idx)
        }
 }
 
-static char *read_string(struct mp4ff *f, uint32_t length)
+static char *read_string(struct mp4 *f, uint32_t length)
 {
        char *str = para_malloc(length + 1);
        if ((uint32_t)read_data(f, str, length) != length) {
@@ -968,7 +968,7 @@ static uint32_t min_body_size(uint8_t atom_type)
        }
 }
 
-static int32_t parse_tag(struct mp4ff *f, uint8_t parent, int32_t size)
+static int32_t parse_tag(struct mp4 *f, uint8_t parent, int32_t size)
 {
        uint8_t atom_type;
        uint8_t header_size = 0;
@@ -1059,10 +1059,10 @@ static int32_t parse_tag(struct mp4ff *f, uint8_t parent, int32_t size)
        return 1;
 }
 
-static int32_t read_mdhd(struct mp4ff *f)
+static int32_t read_mdhd(struct mp4 *f)
 {
        uint32_t version;
-       struct mp4ff_track *t;
+       struct mp4_track *t;
 
        /* CVE-2017-9221 */
        if (f->total_tracks == 0)
@@ -1090,7 +1090,7 @@ static int32_t read_mdhd(struct mp4ff *f)
        return 1;
 }
 
-static int32_t parse_metadata(struct mp4ff *f, int32_t size)
+static int32_t parse_metadata(struct mp4 *f, int32_t size)
 {
        uint64_t subsize, sumsize = 0;
        uint8_t atom_type;
@@ -1107,7 +1107,7 @@ static int32_t parse_metadata(struct mp4ff *f, int32_t size)
        return 0;
 }
 
-static int32_t read_meta(struct mp4ff *f, uint64_t size)
+static int32_t read_meta(struct mp4 *f, uint64_t size)
 {
        uint64_t subsize, sumsize = 0;
        uint8_t atom_type;
@@ -1131,7 +1131,7 @@ static int32_t read_meta(struct mp4ff *f, uint64_t size)
        return 0;
 }
 
-static int32_t atom_read(struct mp4ff *f, int32_t size, uint8_t atom_type)
+static int32_t atom_read(struct mp4 *f, int32_t size, uint8_t atom_type)
 {
        uint64_t dest_position = get_position(f) + size - 8;
        if (atom_type == ATOM_STSZ) {
@@ -1168,7 +1168,7 @@ static int32_t atom_read(struct mp4ff *f, int32_t size, uint8_t atom_type)
 }
 
 /* parse atoms that are sub atoms of other atoms */
-static int32_t parse_sub_atoms(struct mp4ff *f, uint64_t total_size, int meta_only)
+static int32_t parse_sub_atoms(struct mp4 *f, uint64_t total_size, int meta_only)
 {
        uint64_t size;
        uint8_t atom_type = 0;
@@ -1202,7 +1202,7 @@ static int32_t parse_sub_atoms(struct mp4ff *f, uint64_t total_size, int meta_on
 }
 
 /* parse root atoms */
-static int32_t parse_atoms(struct mp4ff *f, int meta_only)
+static int32_t parse_atoms(struct mp4 *f, int meta_only)
 {
        uint64_t size;
        uint8_t atom_type = 0;
@@ -1235,7 +1235,7 @@ static int32_t parse_atoms(struct mp4ff *f, int meta_only)
        return 0;
 }
 
-void mp4ff_get_decoder_config(const struct mp4ff *f, int track,
+void mp4_get_decoder_config(const struct mp4 *f, int track,
                unsigned char **ppBuf, unsigned int *pBufSize)
 {
        if (track >= f->total_tracks) {
@@ -1256,9 +1256,9 @@ void mp4ff_get_decoder_config(const struct mp4ff *f, int track,
        }
 }
 
-struct mp4ff *mp4ff_open_read(struct mp4ff_callback *f)
+struct mp4 *mp4_open_read(struct mp4_callback *f)
 {
-       struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+       struct mp4 *ff = para_calloc(sizeof(struct mp4));
 
        ff->stream = f;
 
@@ -1272,7 +1272,7 @@ struct mp4ff *mp4ff_open_read(struct mp4ff_callback *f)
        return ff;
 }
 
-static int32_t tag_delete(struct mp4ff_metadata *tags)
+static int32_t tag_delete(struct mp4_metadata *tags)
 {
        uint32_t i;
 
@@ -1287,7 +1287,7 @@ static int32_t tag_delete(struct mp4ff_metadata *tags)
        return 0;
 }
 
-void mp4ff_close(struct mp4ff *ff)
+void mp4_close(struct mp4 *ff)
 {
        int32_t i;
 
@@ -1311,7 +1311,7 @@ void mp4ff_close(struct mp4ff *ff)
        free(ff);
 }
 
-static int32_t chunk_of_sample(const struct mp4ff *f, int32_t track,
+static int32_t chunk_of_sample(const struct mp4 *f, int32_t track,
                int32_t sample, int32_t *chunk_sample, int32_t *chunk)
 {
        int32_t total_entries = 0;
@@ -1357,10 +1357,10 @@ static int32_t chunk_of_sample(const struct mp4ff *f, int32_t track,
        return 0;
 }
 
-static int32_t chunk_to_offset(const struct mp4ff *f, int32_t track,
+static int32_t chunk_to_offset(const struct mp4 *f, int32_t track,
                int32_t chunk)
 {
-       const struct mp4ff_track *p_track = f->track[track];
+       const struct mp4_track *p_track = f->track[track];
 
        if (p_track->stco_entry_count && (chunk > p_track->stco_entry_count)) {
                return p_track->stco_chunk_offset[p_track->stco_entry_count -
@@ -1374,11 +1374,11 @@ static int32_t chunk_to_offset(const struct mp4ff *f, int32_t track,
        return 0;
 }
 
-static int32_t sample_range_size(const struct mp4ff *f, int32_t track,
+static int32_t sample_range_size(const struct mp4 *f, int32_t track,
                int32_t chunk_sample, int32_t sample)
 {
        int32_t i, total;
-       const struct mp4ff_track *p_track = f->track[track];
+       const struct mp4_track *p_track = f->track[track];
 
        if (p_track->stsz_sample_size) {
                return (sample - chunk_sample) * p_track->stsz_sample_size;
@@ -1394,7 +1394,7 @@ static int32_t sample_range_size(const struct mp4ff *f, int32_t track,
        return total;
 }
 
-static int32_t sample_to_offset(const struct mp4ff *f, int32_t track,
+static int32_t sample_to_offset(const struct mp4 *f, int32_t track,
                int32_t sample)
 {
        int32_t chunk, chunk_sample, chunk_offset1, chunk_offset2;
@@ -1410,47 +1410,47 @@ static int32_t sample_to_offset(const struct mp4ff *f, int32_t track,
 /**
  * Return the number of milliseconds of the given track.
  *
- * \param f As returned by \ref mp4ff_open_read(), must not be NULL.
- * \param track Between zero and the value returned by \ref mp4ff_total_tracks().
+ * \param f As returned by \ref mp4_open_read(), must not be NULL.
+ * \param track Between zero and the value returned by \ref mp4_total_tracks().
  *
  * The function returns zero if the audio file is of zero length or contains a
  * corrupt track header.
  */
-uint64_t mp4ff_get_duration(const struct mp4ff *f, int32_t track)
+uint64_t mp4_get_duration(const struct mp4 *f, int32_t track)
 {
-       const struct mp4ff_track *t = f->track[track];
+       const struct mp4_track *t = f->track[track];
 
        if (t->timeScale == 0)
                return 0;
        return t->duration * 1000 / t->timeScale;
 }
 
-void mp4ff_set_sample_position(struct mp4ff *f, int32_t track, int32_t sample)
+void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample)
 {
        int32_t offset = sample_to_offset(f, track, sample);
        set_position(f, offset);
 }
 
-int32_t mp4ff_get_sample_size(const struct mp4ff *f, int track, int sample)
+int32_t mp4_get_sample_size(const struct mp4 *f, int track, int sample)
 {
-       const struct mp4ff_track *t = f->track[track];
+       const struct mp4_track *t = f->track[track];
 
        if (t->stsz_sample_size != 0)
                return t->stsz_sample_size;
        return t->stsz_table[sample];
 }
 
-uint32_t mp4ff_get_sample_rate(const struct mp4ff *f, int32_t track)
+uint32_t mp4_get_sample_rate(const struct mp4 *f, int32_t track)
 {
        return f->track[track]->sampleRate;
 }
 
-uint32_t mp4ff_get_channel_count(const struct mp4ff *f, int32_t track)
+uint32_t mp4_get_channel_count(const struct mp4 *f, int32_t track)
 {
        return f->track[track]->channelCount;
 }
 
-int32_t mp4ff_num_samples(const struct mp4ff *f, int32_t track)
+int32_t mp4_num_samples(const struct mp4 *f, int32_t track)
 {
        int32_t i;
        int32_t total = 0;
@@ -1461,9 +1461,9 @@ int32_t mp4ff_num_samples(const struct mp4ff *f, int32_t track)
        return total;
 }
 
-struct mp4ff *mp4ff_open_meta(struct mp4ff_callback *f)
+struct mp4 *mp4_open_meta(struct mp4_callback *f)
 {
-       struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+       struct mp4 *ff = para_calloc(sizeof(struct mp4));
 
        ff->stream = f;
 
@@ -1477,12 +1477,12 @@ struct mp4ff *mp4ff_open_meta(struct mp4ff_callback *f)
        return ff;
 }
 
-int32_t mp4ff_meta_get_num_items(const struct mp4ff *f)
+int32_t mp4_meta_get_num_items(const struct mp4 *f)
 {
        return f->tags.count;
 }
 
-int32_t mp4ff_meta_get_by_index(const struct mp4ff *f, uint32_t index,
+int32_t mp4_meta_get_by_index(const struct mp4 *f, uint32_t index,
                                char **item, char **value)
 {
        if (index >= f->tags.count) {
@@ -1496,7 +1496,7 @@ int32_t mp4ff_meta_get_by_index(const struct mp4ff *f, uint32_t index,
        }
 }
 
-static uint32_t find_atom(struct mp4ff *f, uint64_t base, uint32_t size,
+static uint32_t find_atom(struct mp4 *f, uint64_t base, uint32_t size,
                          const char *name)
 {
        uint32_t remaining = size;
@@ -1525,7 +1525,7 @@ static uint32_t find_atom(struct mp4ff *f, uint64_t base, uint32_t size,
        return 0;
 }
 
-static uint32_t find_atom_v2(struct mp4ff *f, uint64_t base, uint32_t size,
+static uint32_t find_atom_v2(struct mp4 *f, uint64_t base, uint32_t size,
                const char *name, uint32_t extraheaders, const char *name_inside)
 {
        uint64_t first_base = (uint64_t) (-1);
@@ -1775,7 +1775,7 @@ static void *membuffer_detach(struct membuffer *buf)
        return ret;
 }
 
-static uint32_t create_ilst(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_ilst(const struct mp4_metadata *data, void **out_buffer,
                uint32_t * out_size)
 {
        struct membuffer *buf = membuffer_create();
@@ -1786,7 +1786,7 @@ static uint32_t create_ilst(const struct mp4ff_metadata *data, void **out_buffer
        const char *genre_ptr = 0, *tempo_ptr = 0;
 
        for (metaptr = 0; metaptr < data->count; metaptr++) {
-               struct mp4ff_tag *tag = &data->tags[metaptr];
+               struct mp4_tag *tag = &data->tags[metaptr];
                if (!strcasecmp(tag->item, "tracknumber")
                                || !strcasecmp(tag->item, "track")) {
                        if (tracknumber_ptr == 0)
@@ -1833,7 +1833,7 @@ static uint32_t create_ilst(const struct mp4ff_metadata *data, void **out_buffer
                        membuffer_write_int16_tag(buf, "gnre", index);
        }
        for (metaptr = 0; metaptr < data->count; metaptr++) {
-               struct mp4ff_tag *tag;
+               struct mp4_tag *tag;
                const char *std_meta_atom;
 
                if (mask[metaptr])
@@ -1877,7 +1877,7 @@ static void membuffer_set_error(struct membuffer *buf)
        buf->error = 1;
 }
 
-static unsigned membuffer_transfer_from_file(struct membuffer *buf, struct mp4ff *src,
+static unsigned membuffer_transfer_from_file(struct membuffer *buf, struct mp4 *src,
                unsigned bytes)
 {
        unsigned oldsize;
@@ -1900,7 +1900,7 @@ static unsigned membuffer_transfer_from_file(struct membuffer *buf, struct mp4ff
        return bytes;
 }
 
-static uint32_t create_meta(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_meta(const struct mp4_metadata *data, void **out_buffer,
                uint32_t * out_size)
 {
        struct membuffer *buf;
@@ -1922,7 +1922,7 @@ static uint32_t create_meta(const struct mp4ff_metadata *data, void **out_buffer
        return 1;
 }
 
-static uint32_t create_udta(const struct mp4ff_metadata *data, void **out_buffer,
+static uint32_t create_udta(const struct mp4_metadata *data, void **out_buffer,
 uint32_t * out_size)
 {
        struct membuffer *buf;
@@ -1949,7 +1949,7 @@ static uint32_t fix_byte_order_32(uint32_t src)
        return read_u32_be(&src);
 }
 
-static uint32_t modify_moov(struct mp4ff *f, const struct mp4ff_metadata *data,
+static uint32_t modify_moov(struct mp4 *f, const struct mp4_metadata *data,
                void **out_buffer, uint32_t * out_size)
 {
        uint64_t total_base = f->moov_offset + 8;
@@ -2063,7 +2063,7 @@ static uint32_t modify_moov(struct mp4ff *f, const struct mp4ff_metadata *data,
        return 1;
 }
 
-static int32_t write_data(struct mp4ff *f, void *data, uint32_t size)
+static int32_t write_data(struct mp4 *f, void *data, uint32_t size)
 {
        int32_t result = 1;
 
@@ -2074,31 +2074,31 @@ static int32_t write_data(struct mp4ff *f, void *data, uint32_t size)
        return result;
 }
 
-static int32_t write_int32(struct mp4ff *f, uint32_t data)
+static int32_t write_int32(struct mp4 *f, uint32_t data)
 {
        int8_t temp[4];
        write_u32_be(temp, data);
        return write_data(f, temp, sizeof(temp));
 }
 
-static int32_t truncate_stream(struct mp4ff *f)
+static int32_t truncate_stream(struct mp4 *f)
 {
        return f->stream->truncate(f->stream->user_data);
 }
 
-int32_t mp4ff_meta_update(struct mp4ff_callback *f, const struct mp4ff_metadata *data)
+int32_t mp4_meta_update(struct mp4_callback *f, const struct mp4_metadata *data)
 {
        void *new_moov_data;
        uint32_t new_moov_size;
 
-       struct mp4ff *ff = para_calloc(sizeof(struct mp4ff));
+       struct mp4 *ff = para_calloc(sizeof(struct mp4));
        ff->stream = f;
        set_position(ff, 0);
 
        parse_atoms(ff, 1);
 
        if (!modify_moov(ff, data, &new_moov_data, &new_moov_size)) {
-               mp4ff_close(ff);
+               mp4_close(ff);
                return 0;
        }
 
@@ -2123,13 +2123,13 @@ int32_t mp4ff_meta_update(struct mp4ff_callback *f, const struct mp4ff_metadata
 
        truncate_stream(ff);
 
-       mp4ff_close(ff);
+       mp4_close(ff);
        return 1;
 }
 
 /* find a metadata item by name */
 /* returns 0 if item found, 1 if no such item */
-static int32_t meta_find_by_name(const struct mp4ff *f, const char *item,
+static int32_t meta_find_by_name(const struct mp4 *f, const char *item,
                char **value)
 {
        uint32_t i;
@@ -2147,27 +2147,27 @@ static int32_t meta_find_by_name(const struct mp4ff *f, const char *item,
        return 0;
 }
 
-int32_t mp4ff_meta_get_artist(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_artist(const struct mp4 *f, char **value)
 {
        return meta_find_by_name(f, "artist", value);
 }
 
-int32_t mp4ff_meta_get_title(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_title(const struct mp4 *f, char **value)
 {
        return meta_find_by_name(f, "title", value);
 }
 
-int32_t mp4ff_meta_get_date(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_date(const struct mp4 *f, char **value)
 {
        return meta_find_by_name(f, "date", value);
 }
 
-int32_t mp4ff_meta_get_album(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_album(const struct mp4 *f, char **value)
 {
        return meta_find_by_name(f, "album", value);
 }
 
-int32_t mp4ff_meta_get_comment(const struct mp4ff *f, char **value)
+int32_t mp4_meta_get_comment(const struct mp4 *f, char **value)
 {
        return meta_find_by_name(f, "comment", value);
 }
diff --git a/mp4.h b/mp4.h
index 98a8e70cf87441e29efc392e8c7dc3e90971430a..225c92c0fa7fdb21f2b8ad9df5be9783fa3e7457 100644 (file)
--- a/mp4.h
+++ b/mp4.h
@@ -1,4 +1,4 @@
-struct mp4ff_callback {
+struct mp4_callback {
     uint32_t (*read)(void *user_data, void *buffer, uint32_t length);
     uint32_t (*write)(void *udata, void *buffer, uint32_t length);
     uint32_t (*seek)(void *user_data, uint64_t position);
@@ -7,39 +7,39 @@ struct mp4ff_callback {
     uint32_t read_error;
 };
 
-struct mp4ff_tag {
+struct mp4_tag {
     char *item;
     char *value;
     uint32_t len;
 };
 
-struct mp4ff_metadata {
-    struct mp4ff_tag *tags;
+struct mp4_metadata {
+    struct mp4_tag *tags;
     uint32_t count;
 };
 
-struct mp4ff; /* opaque */
+struct mp4; /* opaque */
 
-void mp4ff_set_sample_position(struct mp4ff *f, int32_t track, int32_t sample);
-int32_t mp4ff_total_tracks(const struct mp4ff *f);
-void mp4ff_get_decoder_config(const struct mp4ff *f, int track,
+void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample);
+int32_t mp4_total_tracks(const struct mp4 *f);
+void mp4_get_decoder_config(const struct mp4 *f, int track,
                unsigned char** ppBuf, unsigned int* pBufSize);
-struct mp4ff *mp4ff_open_read(struct mp4ff_callback *f);
-void mp4ff_close(struct mp4ff *f);
-int32_t mp4ff_get_sample_size(const struct mp4ff *f, int track, int sample);
-uint32_t mp4ff_get_sample_rate(const struct mp4ff *f, int32_t track);
-uint32_t mp4ff_get_channel_count(const struct mp4ff * f, int32_t track);
-int32_t mp4ff_num_samples(const struct mp4ff *f, int track);
-uint64_t mp4ff_get_duration(const struct mp4ff *f, int32_t track);
-struct mp4ff *mp4ff_open_meta(struct mp4ff_callback *f);
+struct mp4 *mp4_open_read(struct mp4_callback *f);
+void mp4_close(struct mp4 *f);
+int32_t mp4_get_sample_size(const struct mp4 *f, int track, int sample);
+uint32_t mp4_get_sample_rate(const struct mp4 *f, int32_t track);
+uint32_t mp4_get_channel_count(const struct mp4 * f, int32_t track);
+int32_t mp4_num_samples(const struct mp4 *f, int track);
+uint64_t mp4_get_duration(const struct mp4 *f, int32_t track);
+struct mp4 *mp4_open_meta(struct mp4_callback *f);
 
-int mp4ff_meta_get_by_index(const struct mp4ff *f, unsigned int index,
+int mp4_meta_get_by_index(const struct mp4 *f, unsigned int index,
                             char **item, char **value);
-int32_t mp4ff_meta_update(struct mp4ff_callback *f,const struct mp4ff_metadata * data);
+int32_t mp4_meta_update(struct mp4_callback *f,const struct mp4_metadata * data);
 
-int mp4ff_meta_get_num_items(const struct mp4ff *f);
-int mp4ff_meta_get_artist(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_title(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_date(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_album(const struct mp4ff *f, char **value);
-int mp4ff_meta_get_comment(const struct mp4ff *f, char **value);
+int mp4_meta_get_num_items(const struct mp4 *f);
+int mp4_meta_get_artist(const struct mp4 *f, char **value);
+int mp4_meta_get_title(const struct mp4 *f, char **value);
+int mp4_meta_get_date(const struct mp4 *f, char **value);
+int mp4_meta_get_album(const struct mp4 *f, char **value);
+int mp4_meta_get_comment(const struct mp4 *f, char **value);