Exemple #1
0
tmv_t mave_accumulate(struct mave *m, tmv_t val)
{
	m->sum = tmv_sub(m->sum, m->val[m->index]);
	m->val[m->index] = val;
	m->index = (1 + m->index) % m->len;
	m->sum = tmv_add(m->sum, val);
	if (m->cnt < m->len) {
		m->cnt++;
	}
	return tmv_div(m->sum, m->cnt);
}
Exemple #2
0
tmv_t get_raw_delay(struct tsproc *tsp)
{
	tmv_t t23, t41, delay;

	/* delay = ((t2 - t3) * rr + (t4 - t1)) / 2 */

	t23 = tmv_sub(tsp->t2, tsp->t3);
	if (tsp->clock_rate_ratio != 1.0)
		t23 = dbl_tmv(tmv_dbl(t23) * tsp->clock_rate_ratio);
	t41 = tmv_sub(tsp->t4, tsp->t1);
	delay = tmv_div(tmv_add(t23, t41), 2);

	if (delay < 0) {
		pr_debug("negative delay %10" PRId64, delay);
		pr_debug("delay = (t2 - t3) * rr + (t4 - t1)");
		pr_debug("t2 - t3 = %+10" PRId64, t23);
		pr_debug("t4 - t1 = %+10" PRId64, t41);
		pr_debug("rr = %.9f", tsp->clock_rate_ratio);
	}

	return delay;
}