Only three members of struct mp4 are in camel case while all others
follow the underscore convention, which is the standard coding style
of the paraslash code base. Let's be consistent here.
Add comments which indicate the origin of the values stored while
at it.
#include "mp4.h"
struct mp4_track {
#include "mp4.h"
struct mp4_track {
- uint16_t channelCount;
- uint16_t sampleRate;
+ /* mp4a */
+ uint16_t channel_count;
+ uint16_t sample_rate;
/* stsz */
uint32_t stsz_sample_size;
/* stsz */
uint32_t stsz_sample_size;
uint32_t stco_entry_count;
uint32_t *stco_chunk_offset;
uint32_t stco_entry_count;
uint32_t *stco_chunk_offset;
+ /* mdhd */
+ uint32_t time_scale;
ret = read_int32(f, NULL); /* reserved */
if (ret <= 0)
return ret;
ret = read_int32(f, NULL); /* reserved */
if (ret <= 0)
return ret;
- ret = read_int16(f, &t->channelCount);
+ ret = read_int16(f, &t->channel_count);
if (ret <= 0)
return ret;
ret = read_int16(f, NULL);
if (ret <= 0)
return ret;
ret = read_int16(f, NULL);
ret = read_int16(f, NULL);
if (ret <= 0)
return ret;
ret = read_int16(f, NULL);
if (ret <= 0)
return ret;
- return read_int16(f, &t->sampleRate);
+ return read_int16(f, &t->sample_rate);
}
static int read_stsd(struct mp4 *f)
}
static int read_stsd(struct mp4 *f)
ret = read_int64(f, NULL); /* modification-time */
if (ret <= 0)
return ret;
ret = read_int64(f, NULL); /* modification-time */
if (ret <= 0)
return ret;
- ret = read_int32(f, &t->timeScale);
+ ret = read_int32(f, &t->time_scale);
if (ret <= 0)
return ret;
ret = read_int64(f, &t->duration);
if (ret <= 0)
return ret;
ret = read_int64(f, &t->duration);
ret = read_int32(f, NULL); /* modification-time */
if (ret <= 0)
return ret;
ret = read_int32(f, NULL); /* modification-time */
if (ret <= 0)
return ret;
- ret = read_int32(f, &t->timeScale);
+ ret = read_int32(f, &t->time_scale);
if (ret <= 0)
return ret;
ret = read_int32(f, &temp);
if (ret <= 0)
return ret;
ret = read_int32(f, &temp);
{
const struct mp4_track *t = f->audio_track;
{
const struct mp4_track *t = f->audio_track;
+ if (t->time_scale == 0)
- return t->duration * 1000 / t->timeScale;
+ return t->duration * 1000 / t->time_scale;
}
int mp4_set_sample_position(struct mp4 *f, int32_t sample)
}
int mp4_set_sample_position(struct mp4 *f, int32_t sample)
uint32_t mp4_get_sample_rate(const struct mp4 *f)
{
uint32_t mp4_get_sample_rate(const struct mp4 *f)
{
- return f->audio_track->sampleRate;
+ return f->audio_track->sample_rate;
}
uint32_t mp4_get_channel_count(const struct mp4 *f)
{
}
uint32_t mp4_get_channel_count(const struct mp4 *f)
{
- return f->audio_track->channelCount ;
+ return f->audio_track->channel_count;
}
int32_t mp4_num_samples(const struct mp4 *f)
}
int32_t mp4_num_samples(const struct mp4 *f)