Selkies

lib/decode-pace

The frame rate a decoder that cannot keep up asks the server for.

A decoder slower than the stream keeps a backlog, which the decode gate (lib/decode-gate.js) answers by letting frames go: each backlog frame is latency on the screen, and each drop a repair on the wire. Asking the server for fewer frames removes both. Once the decoder has stood behind for ENGAGE_S seconds in a row, the pace is CAP_SHARE of the frames it turned out over them, never under CAP_FLOOR, and falls again the same way while it stays behind. After a wait of LIFT_S seconds keeping up the pace rises by LIFT_STEP, and falling behind within REGRET_S of a rise takes the rise back and doubles the wait before the next. A pace rising to CAP_CEILING asks for nothing. A second without frames, a still screen's, counts neither way.

Classes

DecodePace

Defined in: lib/decode-pace.js:40

Constructors

Constructor
new DecodePace(): DecodePace;

Defined in: lib/decode-pace.js:41

Returns

DecodePace

Properties

cap
cap: number;

Defined in: lib/decode-pace.js:48

Methods

reset()
reset(): void;

Defined in: lib/decode-pace.js:46

A new decoder or stream, or a rate the user chose: the pace asks for nothing.

Returns

void

decided()
decided(backlog, dropped): void;

Defined in: lib/decode-pace.js:67

A frame the gate decided on.

Parameters
ParameterTypeDescription
backlognumberFrames the decoder had yet to decode then.
droppedbooleanWhether the gate let it, or the backlog, go.
Returns

void

decoded()
decoded(): void;

Defined in: lib/decode-pace.js:74

A frame the decoder turned out.

Returns

void

second()
second(): number;

Defined in: lib/decode-pace.js:83

Closes a second of the stream.

Returns

number

The new pace where it changed (null: ask for nothing), undefined where it stayed.

Variables

BEHIND_QUEUE

const BEHIND_QUEUE: 4 = 4;

Defined in: lib/decode-pace.js:24

Mean frames of decode backlog over a second that count as behind.


ENGAGE_S

const ENGAGE_S: 3 = 3;

Defined in: lib/decode-pace.js:26

Seconds behind in a row before the pace falls.


CAP_SHARE

const CAP_SHARE: 0.93 = 0.93;

Defined in: lib/decode-pace.js:28

Share of the frames the decoder turned out that the pace asks for.


CAP_FLOOR

const CAP_FLOOR: 10 = 10;

Defined in: lib/decode-pace.js:30

The lowest pace, in frames per second.


LIFT_S

const LIFT_S: 20 = 20;

Defined in: lib/decode-pace.js:32

Seconds keeping up before the pace rises, doubled at each regret.


LIFT_STEP

const LIFT_STEP: 1.1 = 1.1;

Defined in: lib/decode-pace.js:34

How far each rise goes.


REGRET_S

const REGRET_S: 10 = 10;

Defined in: lib/decode-pace.js:36

How soon after a rise falling behind takes it back, in seconds.


CAP_CEILING

const CAP_CEILING: 240 = 240;

Defined in: lib/decode-pace.js:38

A pace rising this high asks for nothing: no display the page follows runs faster.