summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-11-13 22:55:34 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2016-11-13 22:57:02 +0100
commit8fad4b4e251bb21f8871fa829b593454528aff24 (patch)
treebda5790e6959ca5d64963800e06c4fb2de6accb3 /libavformat/mux.c
parentfb40daa7f3b86b66b15973d33f4269461b1e1ffd (diff)
parent785c25443b56adb6dbbb78d68cccbd9bd4a42e05 (diff)
Merge commit '785c25443b56adb6dbbb78d68cccbd9bd4a42e05'
* commit '785c25443b56adb6dbbb78d68cccbd9bd4a42e05': movenc: Apply offsets on timestamps when peeking into interleaving queues Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 77823a4e75..4d47ddcbde 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -692,6 +692,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
pts_backup = pkt->pts;
dts_backup = pkt->dts;
+ // If the timestamp offsetting below is adjusted, adjust
+ // ff_interleaved_peek similarly.
if (s->output_ts_offset) {
AVStream *st = s->streams[pkt->stream_index];
int64_t offset = av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
@@ -1180,23 +1182,30 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
}
}
-const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream, int64_t *ts_offset)
+int ff_interleaved_peek(AVFormatContext *s, int stream,
+ AVPacket *pkt, int add_offset)
{
AVPacketList *pktl = s->internal->packet_buffer;
while (pktl) {
if (pktl->pkt.stream_index == stream) {
- AVPacket *pkt = &pktl->pkt;
- AVStream *st = s->streams[pkt->stream_index];
- *ts_offset = st->mux_ts_offset;
-
- if (s->output_ts_offset)
- *ts_offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
-
- return pkt;
+ *pkt = pktl->pkt;
+ if (add_offset) {
+ AVStream *st = s->streams[pkt->stream_index];
+ int64_t offset = st->mux_ts_offset;
+
+ if (s->output_ts_offset)
+ offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base);
+
+ if (pkt->dts != AV_NOPTS_VALUE)
+ pkt->dts += offset;
+ if (pkt->pts != AV_NOPTS_VALUE)
+ pkt->pts += offset;
+ }
+ return 0;
}
pktl = pktl->next;
}
- return NULL;
+ return AVERROR(ENOENT);
}
/**