[vlc-commits] avcodec: add macros to transform lavc timestamps to/from VLC ones

Steve Lhomme git at videolan.org
Wed Sep 19 11:58:34 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri May 11 08:35:59 2018 +0200| [a191f4203eac9ae98a57666a9c1ae1b4649a329b] | committer: Steve Lhomme

avcodec: add macros to transform lavc timestamps to/from VLC ones

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a191f4203eac9ae98a57666a9c1ae1b4649a329b
---

 modules/codec/avcodec/avcommon.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 65ad35f4ad..1bdf05d9d6 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -43,6 +43,20 @@
 # include <libavutil/cpu.h>
 # include <libavutil/log.h>
 
+#if (CLOCK_FREQ == AV_TIME_BASE)
+#define FROM_AV_TS(x)  (x)
+#define TO_AV_TS(x)    (x)
+#elif (CLOCK_FREQ % AV_TIME_BASE) == 0
+#define FROM_AV_TS(x)  ((x) * (CLOCK_FREQ / AV_TIME_BASE))
+#define TO_AV_TS(x)    ((x) / (CLOCK_FREQ / AV_TIME_BASE))
+#elif (AV_TIME_BASE % CLOCK_FREQ) == 0
+#define FROM_AV_TS(x)  ((x) / (AV_TIME_BASE / CLOCK_FREQ))
+#define TO_AV_TS(x)    ((x) * (AV_TIME_BASE / CLOCK_FREQ))
+#else
+#define FROM_AV_TS(x)  ((x) * CLOCK_FREQ / AV_TIME_BASE)
+#define TO_AV_TS(x)    ((x) * AV_TIME_BASE / CLOCK_FREQ)
+#endif
+
 #define AV_OPTIONS_TEXT     N_("Advanced options")
 #define AV_OPTIONS_LONGTEXT N_("Advanced options, in the form {opt=val,opt2=val2}.")
 



More information about the vlc-commits mailing list