Skip to main content

Module decode_pump

Module decode_pump 

Source
Expand description

Shared source decode pump.

One pump per job (not per rung): demux + decode the source once, run the rung-agnostic per-frame work (4:4:4 → 4:2:0 downsample + HDR tonemap), and fan the normalized frame out to N per-rung mpsc channels via cheap VideoFrame::clone() (the inner Bytes is Arc-backed).

Per-rung scaling + encoding consume from those channels. Eliminating the redundant per-rung decode is the whole point — a 5-rung ladder decodes the source once, not five times. The cost: the slowest rung backpressures the pump (usually the largest rung, whose encoder is slowest).

Structs§

ClipSource
One clip of a splice: a decode config, its source bytes, and the source frame range to keep. The first start_frame decoded frames are dropped (the trim in-point); decoding stops once the source index reaches end_frame (exclusive — the trim out-point). end_frame = None keeps the clip to its end. A single full-range clip (start_frame = 0, end_frame = None) is a plain, un-spliced transcode.
DecodePumpConfig
Configuration for one decode pump.

Constants§

DECODE_BENCH_FRAMES
Number of frames timed per candidate when benchmarking decoders. Chosen so the measurement amortises driver init yet stays well under a second per candidate even on a modest GPU.

Functions§

fastest_decode_gpu
Benchmark each candidate GPU by decoding a short prefix of input on it and return the fastest gpu_index (what --decode-with-fastest pins the pump to). Construction + first-frame latency is excluded — the clock starts after a small warmup — so the number reflects steady-state decode throughput, not driver init. Candidates that fail to construct or decode are skipped; returns None if no candidate produced frames or fewer than two candidates were given (nothing to choose).
run_shared_decode_pump_blocking
Single-input decode pump (no trim, no concat) — the common case. A thin wrapper over run_spliced_decode_pump_blocking with one whole clip.
run_spliced_decode_pump_blocking
Spliced decode pump, designed for tokio::task::spawn_blocking. Decodes each clip in order, drops frames outside the clip’s [start_frame, end_frame) source range (trim), and fans the kept frames out to all senders continuously across clips (concat). Because the muxer numbers output frames by count — not by source PTS — the join is automatically gap-free and the timeline is zero-based, with no PTS rewriting.