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;
return buf;
}
-static unsigned membuffer_write(struct membuffer *buf, const void *ptr, unsigned bytes)
+static void membuffer_write(struct membuffer *buf, const void *ptr,
+ unsigned bytes)
{
unsigned dest_size = buf->written + bytes;
if (ptr)
memcpy((char *) buf->data + buf->written, ptr, bytes);
buf->written += bytes;
- return bytes;
}
-static unsigned membuffer_write_atom_name(struct membuffer *buf, const char *data)
+static void membuffer_write_atom_name(struct membuffer *buf, const char *data)
{
- return membuffer_write(buf, data, 4) == 4 ? 1 : 0;
+ membuffer_write(buf, data, 4);
}
-static unsigned membuffer_write_int32(struct membuffer *buf, uint32_t data)
+static void membuffer_write_int32(struct membuffer *buf, uint32_t data)
{
uint8_t temp[4];
write_u32_be(temp, data);
- return membuffer_write(buf, temp, 4);
+ membuffer_write(buf, temp, 4);
}
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;
static bool membuffer_transfer_from_file(struct membuffer *buf, struct mp4 *src,
unsigned bytes)
{
- unsigned oldsize;
- void *bufptr;
-
- oldsize = membuffer_get_size(buf);
- if (membuffer_write(buf, 0, bytes) != bytes)
- return false;
+ unsigned oldsize = membuffer_get_size(buf);
+ char *bufptr;
+ 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;