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).
This commit is contained in:
Edward Hervey 2013-07-29 08:14:57 +02:00
parent f42176b877
commit cea403eaa5

View file

@ -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), \