]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Rename mp4_open_read() to mp4_open().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index e60f18f59b1adc26350ae25055df7c822f6f174c..2121155ccebeed885c78221e994e81acca3de846 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -617,7 +617,7 @@ fail:
        return ret;
 }
 
-int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result)
+int mp4_open(const struct mp4_callback *cb, struct mp4 **result)
 {
        struct mp4 *f;
        int ret;
@@ -629,6 +629,9 @@ int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result)
        ret = -E_MP4_BAD_SAMPLE_COUNT;
        if (f->track.stsz_sample_count == 0)
                goto fail;
+       ret = -E_MP4_CORRUPT;
+       if (f->track.time_scale == 0)
+               goto fail;
        *result = f;
        return 1;
 fail:
@@ -666,8 +669,6 @@ uint64_t mp4_get_duration(const struct mp4 *f)
 {
        const struct mp4_track *t = &f->track;
 
-       if (t->time_scale == 0)
-               return 0;
        return t->duration * 1000 / t->time_scale;
 }
 
@@ -721,12 +722,7 @@ uint16_t mp4_get_channel_count(const struct mp4 *f)
 
 uint32_t mp4_num_samples(const struct mp4 *f)
 {
-       const struct mp4_track *t = &f->track;
-       uint32_t total = 0;
-
-       for (uint32_t n = 0; n < t->stts_entry_count; n++)
-               total += t->stts_sample_count[n];
-       return total;
+       return f->track.stsz_sample_count;
 }
 
 int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result)
@@ -873,7 +869,7 @@ static int write_data(struct mp4 *f, void *data, size_t size)
        return 1;
 }
 
-int mp4_meta_update(struct mp4 *f)
+int mp4_update_meta(struct mp4 *f)
 {
        void *new_moov_data;
        uint32_t new_moov_size;