//calculate dts from pts
if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
- st->pts_buffer[0] = pkt->pts;
- for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
- st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
- for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
- FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
+ st->internal->pts_buffer[0] = pkt->pts;
+ for (i = 1; i < delay + 1 && st->internal->pts_buffer[i] == AV_NOPTS_VALUE; i++)
+ st->internal->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
+ for (i = 0; i<delay && st->internal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++)
+ FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]);
- pkt->dts = st->pts_buffer[0];
+ pkt->dts = st->internal->pts_buffer[0];
}
if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
if (s->avoid_negative_ts > 0) {
AVStream *st = s->streams[pkt->stream_index];
- int64_t offset = st->mux_ts_offset;
+ int64_t offset = st->internal->mux_ts_offset;
int64_t ts = s->internal->avoid_negative_ts_use_pts ? pkt->pts : pkt->dts;
if (s->internal->offset == AV_NOPTS_VALUE && ts != AV_NOPTS_VALUE &&
}
if (s->internal->offset != AV_NOPTS_VALUE && !offset) {
- offset = st->mux_ts_offset =
+ offset = st->internal->mux_ts_offset =
av_rescale_q_rnd(s->internal->offset,
s->internal->offset_timebase,
st->time_base,
return 0;
}
-static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt)
+static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
{
- AVStream *st;
- int ret;
-
- ret = check_packet(s, pkt);
- if (ret < 0)
- return ret;
- st = s->streams[pkt->stream_index];
-
#if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX
/* sanitize the timestamps */
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
- st->interleaver_chunk_size += pkt->size;
- st->interleaver_chunk_duration += pkt->duration;
- if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
- || (max && st->interleaver_chunk_duration > max)) {
- st->interleaver_chunk_size = 0;
+ st->internal->interleaver_chunk_size += pkt->size;
+ st->internal->interleaver_chunk_duration += pkt->duration;
+ if ( (s->max_chunk_size && st->internal->interleaver_chunk_size > s->max_chunk_size)
+ || (max && st->internal->interleaver_chunk_duration > max)) {
+ st->internal->interleaver_chunk_size = 0;
pkt->flags |= CHUNK_START;
- if (max && st->interleaver_chunk_duration > max) {
+ if (max && st->internal->interleaver_chunk_duration > max) {
int64_t syncoffset = (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
- st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
+ st->internal->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
} else
- st->interleaver_chunk_duration = 0;
+ st->internal->interleaver_chunk_duration = 0;
}
}
if (*next_point) {
*pkt = pktl->pkt;
if (add_offset) {
AVStream *st = s->streams[pkt->stream_index];
- int64_t offset = st->mux_ts_offset;
+ int64_t offset = st->internal->mux_ts_offset;
if (s->output_ts_offset)
offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
{
if (s->oformat->interleave_packet) {
- int ret = s->oformat->interleave_packet(s, out, in, flush);
- if (in)
- av_packet_unref(in);
- return ret;
+ return s->oformat->interleave_packet(s, out, in, flush);
} else
return ff_interleave_packet_per_dts(s, out, in, flush);
}
static int write_packets_common(AVFormatContext *s, AVPacket *pkt, int interleaved)
{
AVStream *st;
- int ret = prepare_input_packet(s, pkt);
+ int ret = check_packet(s, pkt);
if (ret < 0)
return ret;
st = s->streams[pkt->stream_index];
+ ret = prepare_input_packet(s, st, pkt);
+ if (ret < 0)
+ return ret;
+
ret = check_bitstream(s, st, pkt);
if (ret < 0)
return ret;
ret = s->pb ? s->pb->error : 0;
for (i = 0; i < s->nb_streams; i++) {
av_freep(&s->streams[i]->priv_data);
- av_freep(&s->streams[i]->index_entries);
+ av_freep(&s->streams[i]->internal->index_entries);
}
if (s->oformat->priv_class)
av_opt_free(s->priv_data);