]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Open-code pointless truncate_stream().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index e7dbcc7953164fd4f5b81d8ed993caef6f89f912..da904aa8a7fcb03c99d3c827fcae1f9ef82f039a 100644 (file)
--- a/mp4.c
+++ b/mp4.c
 struct mp4_track {
        bool is_audio;
        int32_t channelCount;
-       int32_t sampleSize;
        uint16_t sampleRate;
 
-       /* stsd */
-       int32_t stsd_entry_count;
-
        /* stsz */
        int32_t stsz_sample_size;
        int32_t stsz_sample_count;
@@ -41,9 +37,6 @@ struct mp4_track {
        int32_t stco_entry_count;
        int32_t *stco_chunk_offset;
 
-       uint32_t maxBitrate;
-       uint32_t avgBitrate;
-
        uint32_t timeScale;
        uint64_t duration;
 };
@@ -558,7 +551,7 @@ static int32_t read_mp4a(struct mp4 *f)
        read_int32(f);  /* reserved */
 
        t->channelCount = read_int16(f);
-       t->sampleSize = read_int16(f);
+       read_int16(f);
 
        read_int16(f);
        read_int16(f);
@@ -573,7 +566,7 @@ static int32_t read_mp4a(struct mp4 *f)
 
 static int32_t read_stsd(struct mp4 *f)
 {
-       int32_t i;
+       int32_t i, entry_count;
        uint8_t header_size = 0;
        struct mp4_track *t;
 
@@ -585,10 +578,10 @@ static int32_t read_stsd(struct mp4 *f)
        read_char(f);   /* version */
        read_int24(f);  /* flags */
 
-       t->stsd_entry_count = read_int32(f);
+       entry_count = read_int32(f);
 
        /* CVE-2017-9253 */
-       for (i = 0; i < t->stsd_entry_count && !f->stream->read_error; i++) {
+       for (i = 0; i < entry_count && !f->stream->read_error; i++) {
                uint64_t skip = get_position(f);
                uint64_t size;
                uint8_t atom_type = 0;
@@ -1908,11 +1901,6 @@ static int32_t write_int32(struct mp4 *f, uint32_t data)
        return write_data(f, temp, sizeof(temp));
 }
 
-static int32_t truncate_stream(struct mp4 *f)
-{
-       return f->stream->truncate(f->stream->user_data);
-}
-
 int32_t mp4_meta_update(struct mp4_callback *f, const struct mp4_metadata *data)
 {
        void *new_moov_data;
@@ -1947,9 +1935,7 @@ int32_t mp4_meta_update(struct mp4_callback *f, const struct mp4_metadata *data)
                write_data(ff, "moov", 4);
                write_data(ff, new_moov_data, new_moov_size);
        }
-
-       truncate_stream(ff);
-
+       f->truncate(f->user_data);
        mp4_close(ff);
        return 1;
 }