diff options
author | Anton Khirnov <anton@khirnov.net> | 2014-06-18 09:39:32 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-06-20 14:14:11 +0200 |
commit | 874390e163427c1fe7682ab27924a7843780dbb3 (patch) | |
tree | f178ddee50533875a3f572a450b3bb714496919c /libavcodec/avpacket.c | |
parent | 440842c4eb1d7709654ec97cd687663d11ef499c (diff) | |
download | ffmpeg-874390e163427c1fe7682ab27924a7843780dbb3.tar.gz |
lavc: add a convenience function for rescaling timestamps in a packet
Diffstat (limited to 'libavcodec/avpacket.c')
-rw-r--r-- | libavcodec/avpacket.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 052aaf8638..25eabdb215 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -24,6 +24,7 @@ #include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/internal.h" +#include "libavutil/mathematics.h" #include "libavutil/mem.h" #include "avcodec.h" #if FF_API_DESTRUCT_PACKET @@ -380,3 +381,15 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src) *dst = *src; av_init_packet(src); } + +void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb) +{ + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts = av_rescale_q(pkt->pts, src_tb, dst_tb); + if (pkt->dts != AV_NOPTS_VALUE) + pkt->dts = av_rescale_q(pkt->dts, src_tb, dst_tb); + if (pkt->duration > 0) + pkt->duration = av_rescale_q(pkt->duration, src_tb, dst_tb); + if (pkt->convergence_duration > 0) + pkt->convergence_duration = av_rescale_q(pkt->convergence_duration, src_tb, dst_tb); +} |