mirror of https://github.com/Genymobile/scrcpy
Improve delay buffer startup
The delay buffer clock estimates the clock offset between the PTS and the frame decoded date using an "Exponentially Weighted Moving Average" (EWMA). But for the first frames, the clock have less than SC_CLOCK_RANGE points to average. Since the timing for the first frames are typically the worst ones, give more weight to the last point for the estimation. Once SC_CLOCK_RANGE points are available (i.e. when SC_CLOCK_RANGE == clock->range), the new estimation is equivalent to the previous version.
This commit is contained in:
parent
f089ea67e1
commit
a7cae59578
|
@ -21,8 +21,10 @@ sc_clock_update(struct sc_clock *clock, sc_tick system, sc_tick stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_tick offset = system - stream;
|
sc_tick offset = system - stream;
|
||||||
clock->offset = ((clock->range - 1) * clock->offset + offset)
|
unsigned clock_weight = clock->range - 1;
|
||||||
/ clock->range;
|
unsigned value_weight = SC_CLOCK_RANGE - clock->range + 1;
|
||||||
|
clock->offset = (clock->offset * clock_weight + offset * value_weight)
|
||||||
|
/ SC_CLOCK_RANGE;
|
||||||
|
|
||||||
#ifdef SC_CLOCK_DEBUG
|
#ifdef SC_CLOCK_DEBUG
|
||||||
LOGD("Clock estimation: pts + %" PRItick, clock->offset);
|
LOGD("Clock estimation: pts + %" PRItick, clock->offset);
|
||||||
|
|
Loading…
Reference in New Issue