]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Make most members of struct mp4_track unsigned.
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index c0efc4fa77d53013e8445fb9b261ea3e9677ac9b..61feafdf2ce744aa593b4eaeb4c16d06aa60250a 100644 (file)
--- a/mp4.c
+++ b/mp4.c
 
 struct mp4_track {
        bool is_audio;
-       int32_t channelCount;
+       uint32_t channelCount;
        uint16_t sampleRate;
 
        /* stsz */
-       int32_t stsz_sample_size;
-       int32_t stsz_sample_count;
-       int32_t *stsz_table;
+       uint32_t stsz_sample_size;
+       uint32_t stsz_sample_count;
+       uint32_t *stsz_table;
 
        /* stts */
-       int32_t stts_entry_count;
-       int32_t *stts_sample_count;
-       int32_t *stts_sample_delta;
+       uint32_t stts_entry_count;
+       uint32_t *stts_sample_count;
+       uint32_t *stts_sample_delta;
 
        /* stsc */
-       int32_t stsc_entry_count;
-       int32_t *stsc_first_chunk;
-       int32_t *stsc_samples_per_chunk;
-       int32_t *stsc_sample_desc_index;
+       uint32_t stsc_entry_count;
+       uint32_t *stsc_first_chunk;
+       uint32_t *stsc_samples_per_chunk;
+       uint32_t *stsc_sample_desc_index;
 
        /* stsc */
-       int32_t stco_entry_count;
-       int32_t *stco_chunk_offset;
+       uint32_t stco_entry_count;
+       uint32_t *stco_chunk_offset;
 
        uint32_t timeScale;
        uint64_t duration;
@@ -1201,12 +1201,6 @@ static void membuffer_write_std_tag(struct membuffer *buf, const char *name,
        membuffer_write(buf, value, len);
 }
 
-static void membuffer_free(struct membuffer *buf)
-{
-       free(buf->data);
-       free(buf);
-}
-
 static unsigned membuffer_get_size(const struct membuffer *buf)
 {
        return buf->written;
@@ -1275,18 +1269,14 @@ static void *membuffer_get_ptr(const struct membuffer *buf)
 static bool membuffer_transfer_from_file(struct membuffer *buf, struct mp4 *src,
                unsigned bytes)
 {
-       unsigned oldsize;
-       void *bufptr;
+       unsigned oldsize = membuffer_get_size(buf);
+       char *bufptr;
 
-       oldsize = membuffer_get_size(buf);
        membuffer_write(buf, 0, bytes);
        bufptr = membuffer_get_ptr(buf);
-       if (bufptr == 0)
-               return false;
-
-       if ((unsigned)read_data(src, (char *) bufptr + oldsize, bytes) !=
-               bytes) {
-               membuffer_free(buf);
+       if (read_data(src, bufptr + oldsize, bytes) != bytes) {
+               free(buf->data);
+               free(buf);
                return false;
        }
        return true;