Introduce cadence based VideoRendererAlgorithm.
This is the engine which will power the new video
rendering pipeline! VideoRendererImpl will use this
to manage frame selection (as audio uses a similarly
named AudioRendererAlgorithm).
It attempts to first find a cadence match for a set
of frames (i.e. 30fps in 60Hz would have each frame
displayed for two render intervals). If it can not
find a cadence match, it attempts to find the frame
which covers the vsync interval the most. If no frame
covers the interval it then chooses the frame which
is closest to the deadline.
Cadence fitting is based on a calculation of how long
it would take for a frame to be repeated or dropped
if the cadence is forced from say X.# to just X.0.
It handles both integer (30fps in 60Hz) and fractional
cadences (120fps in 60Hz). It uses a hysteresis of
100ms to avoid oscillation of the cadence.
Clients may use have a secondary pumping mechanism
which can expire frames which fall too far behind
the current media time; this is to handle cases where
the compositor has stopped providing callbacks.
Testing shows it's significantly smoother than the
existing rendering pipeline! \o/
Profiling notes over 45 minutes of simulated time:
- 83ms, UpdateFrameStatistics() most expensive.
- 73ms, for removal of frames from the deque.
- 20ms, for CalculateCadence().
Overall nothing is much of a hot spot, 45 minutes of
simulated time takes ~400ms to run.
BUG=439548
TEST=new unittest.
Review URL: https://codereview.chromium.org/1021943002
Cr-Commit-Position: refs/heads/master@{#327864}
12 files changed