[vlc-commits] vlc_tick: add helper functions to convert vlc_tick to/from samples

Steve Lhomme git at videolan.org
Thu Sep 20 16:16:05 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Sep 20 13:26:24 2018 +0200| [90c53e85d37f1b0e0d2e8ef97bc94ccbe37ae872] | committer: Steve Lhomme

vlc_tick: add helper functions to convert vlc_tick to/from samples

Based on a sampling rate.

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

 include/vlc_tick.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/vlc_tick.h b/include/vlc_tick.h
index f7ab9a2265..0e54bd5408 100644
--- a/include/vlc_tick.h
+++ b/include/vlc_tick.h
@@ -95,6 +95,17 @@ static inline vlc_tick_t vlc_tick_rate_duration(float frame_rate)
     return CLOCK_FREQ / frame_rate;
 }
 
+/*
+ * samples<>vlc_tick_t
+ */
+static inline vlc_tick_t vlc_tick_from_samples(int64_t samples, int samp_rate)
+{
+    return CLOCK_FREQ * samples / samp_rate;
+}
+static inline int64_t samples_from_vlc_tick(vlc_tick_t t, int samp_rate)
+{
+    return t * samp_rate / CLOCK_FREQ;
+}
 
 /*
  * vlc_tick_t <> milliseconds (ms) conversions



More information about the vlc-commits mailing list