tsmux: Refactor get_current_pcr

No functional change.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1431>
This commit is contained in:
Jan Alexander Steffens (heftig) 2020-07-15 16:25:07 +02:00 committed by GStreamer Merge Bot
parent d4caa1b3ae
commit 5a358b7687

View file

@ -1236,18 +1236,25 @@ tsmux_write_null_ts_header (guint8 * buf)
*buf++ = 0x10; *buf++ = 0x10;
} }
static gint64
ts_to_pcr (gint64 ts)
{
if (ts == G_MININT64) {
return 0;
}
return (ts - TSMUX_PCR_OFFSET) * (TSMUX_SYS_CLOCK_FREQ / TSMUX_CLOCK_FREQ);
}
static gint64 static gint64
get_current_pcr (TsMux * mux, gint64 cur_ts) get_current_pcr (TsMux * mux, gint64 cur_ts)
{ {
if (mux->bitrate) if (!mux->bitrate)
return (CLOCK_BASE - TSMUX_PCR_OFFSET) * 300 + return ts_to_pcr (cur_ts);
gst_util_uint64_scale (mux->n_bytes * 8, TSMUX_SYS_CLOCK_FREQ,
mux->bitrate); return ts_to_pcr (CLOCK_BASE) +
else if (cur_ts != G_MININT64) gst_util_uint64_scale (mux->n_bytes * 8, TSMUX_SYS_CLOCK_FREQ,
return (cur_ts - mux->bitrate);
TSMUX_PCR_OFFSET) * (TSMUX_SYS_CLOCK_FREQ / TSMUX_CLOCK_FREQ);
else
return 0;
} }
static gint64 static gint64