summaryrefslogtreecommitdiff
path: root/libavformat/mux.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2016-06-24 23:38:54 +0300
committerMartin Storsjö <martin@martin.st>2016-06-28 14:16:06 +0300
commit785c25443b56adb6dbbb78d68cccbd9bd4a42e05 (patch)
tree91dc6842332b80b09e902ce212c4c608500f3eb7 /libavformat/mux.c
parenteccfb9778ae939764d17457f34338d140832d9e1 (diff)
movenc: Apply offsets on timestamps when peeking into interleaving queues
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r--libavformat/mux.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index c41c477ab4..37c4541ad9 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -357,6 +357,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
static int write_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret;
+ // If the timestamp offsetting below is adjusted, adjust
+ // ff_interleaved_peek similarly.
if (s->avoid_negative_ts > 0) {
AVRational time_base = s->streams[pkt->stream_index]->time_base;
int64_t offset = 0;
@@ -614,15 +616,27 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
}
}
-const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
+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)
- return &pktl->pkt;
+ if (pktl->pkt.stream_index == stream) {
+ *pkt = pktl->pkt;
+ if (add_offset && s->internal->offset != AV_NOPTS_VALUE) {
+ int64_t offset = av_rescale_q(s->internal->offset,
+ s->internal->offset_timebase,
+ s->streams[stream]->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);
}
/**