aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-20 16:40:04 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-20 16:40:04 +0200
commit4a993335812f7e9b2088145c7d043c01019c5d04 (patch)
tree90fa4e0b4419c61d34111694e8ea64afd722ac8f
parente93028790087e632569e94f193b333073a67cf14 (diff)
parent874390e163427c1fe7682ab27924a7843780dbb3 (diff)
downloadffmpeg-4a993335812f7e9b2088145c7d043c01019c5d04.tar.gz
Merge commit '874390e163427c1fe7682ab27924a7843780dbb3'
* commit '874390e163427c1fe7682ab27924a7843780dbb3': lavc: add a convenience function for rescaling timestamps in a packet Conflicts: libavcodec/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--doc/APIchanges3
-rw-r--r--libavcodec/avcodec.h13
-rw-r--r--libavcodec/avpacket.c13
-rw-r--r--libavcodec/version.h2
4 files changed, 30 insertions, 1 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index ed9d560bfd..ed9820b55c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2012-10-22
API changes, most recent first:
+2014-06-xx - xxxxxxx - lavc 55.55.0 - avcodec.h
+ Add av_packet_rescale_ts() to simplify timestamp conversion.
+
2014-xx-xx - xxxxxxx - lavf 55.20.0 - avformat.h
The proper way for providing a hint about the desired timebase to the muxers
is now setting AVStream.time_base, instead of AVStream.codec.time_base as was
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2579ccc971..f25636e610 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3806,6 +3806,19 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src);
int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
/**
+ * Convert valid timing fields (timestamps / durations) in a packet from one
+ * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
+ * ignored.
+ *
+ * @param pkt packet on which the conversion will be performed
+ * @param tb_src source timebase, in which the timing fields in pkt are
+ * expressed
+ * @param tb_dst destination timebase, to which the timing fields will be
+ * converted
+ */
+void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
+
+/**
* @}
*/
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 959d95963a..a87e8e3ead 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"
#include "bytestream.h"
@@ -562,3 +563,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);
+}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index af19be280a..f2c4e4856b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 67
+#define LIBAVCODEC_VERSION_MINOR 68
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \