diff --git a/gst/mpegtsdemux/gstmpegdefs.h b/gst/mpegtsdemux/gstmpegdefs.h index 4f636d900e..6f8ebfdf3d 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), \