summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2013-07-29 08:14:57 +0200
committerEdward Hervey <edward@collabora.com>2013-07-29 09:42:11 +0200
commitcea403eaa59d707787b89e25b1ba1e79ffb29c71 (patch)
tree94f7ed62f2ecefa8eb10a99b8d5f3e5e4022e8ac
parentf42176b877c420f7261410d2cdf701d7643e7e28 (diff)
downloadgstreamer-plugins-bad-cea403eaa59d707787b89e25b1ba1e79ffb29c71.tar.gz
mpegdefs: Simplify PCR/PTS/DTS => GST conversion macros
We know we will not overflow 64 bits, therefore just use direct multiplication/division instead of the scale method (trims usage from 50 instruction calls to 2/3).
-rw-r--r--gst/mpegtsdemux/gstmpegdefs.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/gst/mpegtsdemux/gstmpegdefs.h b/gst/mpegtsdemux/gstmpegdefs.h
index 4f636d900..6f8ebfdf3 100644
--- a/gst/mpegtsdemux/gstmpegdefs.h
+++ b/gst/mpegtsdemux/gstmpegdefs.h
@@ -83,10 +83,16 @@
#define CLOCK_BASE 9LL
#define CLOCK_FREQ (CLOCK_BASE * 10000)
-#define PCRTIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
- GST_MSECOND/10, 300 * CLOCK_BASE))
-#define MPEGTIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
- GST_MSECOND/10, CLOCK_BASE))
+/* PCR_TO_GST calculation requires at least 10 extra bits.
+ * Since maximum PCR value is coded with 42 bits, we are
+ * safe to use direct calculation (10+42 < 63)*/
+#define PCRTIME_TO_GSTTIME(t) ((t) * 1000 / 27)
+
+/* MPEG_TO_GST calculation requires at least 17 extra bits (100000)
+ * Since maximum PTS/DTS value is coded with 33bits, we are
+ * safe to use direct calculation (17+33 < 63) */
+#define MPEGTIME_TO_GSTTIME(t) ((t) * 100000 / 9)
+
#define GSTTIME_TO_MPEGTIME(time) (gst_util_uint64_scale ((time), \
CLOCK_BASE, GST_MSECOND/10))
#define GSTTIME_TO_PCRTIME(time) (gst_util_uint64_scale ((time), \