/* stats */
int64_t i_dts_start; /* applies to current segment only */
int64_t i_duration;
+ uint32_t i_timescale;
mtime_t i_starttime; /* the really first packet */
bool b_hasbframes;
calloc(p_stream->i_entry_max, sizeof(mp4_entry_t));
p_stream->i_dts_start = 0;
p_stream->i_duration = 0;
+ if (p_stream->fmt.i_cat == AUDIO_ES)
+ p_stream->i_timescale = p_stream->fmt.audio.i_rate;
+ else
+ p_stream->i_timescale = CLOCK_FREQ;
p_stream->i_starttime = p_sys->i_duration;
p_stream->b_hasbframes = false;
bo_t *stts = box_full_new("stts", 0, 0);
bo_add_32be(stts, 0); // entry-count (fixed latter)
- uint32_t i_timescale;
- if (p_stream->fmt.i_cat == AUDIO_ES)
- i_timescale = p_stream->fmt.audio.i_rate;
- else
- i_timescale = CLOCK_FREQ;
-
unsigned i_index = 0;
for (unsigned i = 0; i < p_stream->i_entry_count; i_index++) {
int i_first = i;
break;
bo_add_32be(stts, i - i_first); // sample-count
- bo_add_32be(stts, i_delta * i_timescale / CLOCK_FREQ ); // sample-delta
+ bo_add_32be(stts, i_delta * p_stream->i_timescale / CLOCK_FREQ ); // sample-delta
}
bo_fix_32be(stts, 12, i_index);
break;
bo_add_32be(ctts, i - i_first); // sample-count
- bo_add_32be(ctts, i_offset * i_timescale / CLOCK_FREQ ); // sample-offset
+ bo_add_32be(ctts, i_offset * p_stream->i_timescale / CLOCK_FREQ ); // sample-offset
}
bo_fix_32be(ctts, 12, i_index);
}
for (unsigned int i_trak = 0; i_trak < p_sys->i_nb_streams; i_trak++) {
mp4_stream_t *p_stream = p_sys->pp_streams[i_trak];
- uint32_t i_timescale;
- if (p_stream->fmt.i_cat == AUDIO_ES)
- i_timescale = p_stream->fmt.audio.i_rate;
- else
- i_timescale = CLOCK_FREQ;
-
/* *** add /moov/trak *** */
bo_t *trak = box_new("trak");
mdhd = box_full_new("mdhd", 0, 0);
bo_add_32be(mdhd, i_timestamp); // creation time
bo_add_32be(mdhd, i_timestamp); // modification time
- bo_add_32be(mdhd, i_timescale); // timescale
- bo_add_32be(mdhd, p_stream->i_duration * (int64_t)i_timescale /
+ bo_add_32be(mdhd, p_stream->i_timescale); // timescale
+ bo_add_32be(mdhd, p_stream->i_duration * (int64_t)p_stream->i_timescale /
CLOCK_FREQ); // duration
} else {
mdhd = box_full_new("mdhd", 1, 0);
bo_add_64be(mdhd, i_timestamp); // creation time
bo_add_64be(mdhd, i_timestamp); // modification time
- bo_add_32be(mdhd, i_timescale); // timescale
- bo_add_64be(mdhd, p_stream->i_duration * (int64_t)i_timescale /
+ bo_add_32be(mdhd, p_stream->i_timescale); // timescale
+ bo_add_64be(mdhd, p_stream->i_duration * (int64_t)p_stream->i_timescale /
CLOCK_FREQ); // duration
}