### `wai.video.encode`: AVC and HEVC through the encoders a device already has, and who made the bytes

- **The extension** ([platform-encode](extensions/platform-encode.md)). WAI writes no AVC or HEVC
  encoder. An encode goes through an interface the device has: the operating system's media
  framework and its hardware media engine (`platform`), a GPU's encode engine through the video
  acceleration API (`va`) or through the GPU driver's own encode interface (`gpu-driver`), or a
  software AVC library the user obtains separately and names at run time (`software`). Every
  encoder is loaded at run time; nothing is linked or shipped. The output is held to one shape
  before it is recorded (§4.3): an ISO/IEC 14496-10 or ISO/IEC 23008-2 Annex B byte stream of one
  access unit per picture, an IDR access unit carrying its parameter sets at exactly the planned
  pictures and no other random access point, 8-bit 4:2:0 progressive, one layer, no reordering.
  A rung of another size is resampled first by `wai.resample.two-tap`, a pure function in
  integers.
- **The record** `wai.video.encode` (§6 to §8): a signed statement of the interface, the encoder
  and its version, whether a hardware engine coded the pictures, the device and the driver (and
  for a library the SHA-256 of the file loaded), the source by digest, the settings, the IDR plan,
  the stream by digest, profile, level and tier, and an optional energy figure with
  jwp-receipts §2.4.5's members, its counter, attribution and fabrics. A hardware encode's figure
  that counts no engine is `Partial`. A verifier checks the record, then the stream against its
  digest and §4.3, then the source; it never re-encodes.
- **An encode over a package's pieces** (§9): one floor object per piece, each naming its encoder
  and version in `derived_from.renderer` (packaging §7.5) and binding the device and the driver
  through its render settings; the record binds the package receipt, each piece's base and each
  object. The package itself is unchanged.
- **The reference:** `wai-rs` feature `platform_encode` (the four adapters, the Annex B reader,
  the record, the energy counters); `wai encode avc|hevc`, `wai encoders`, `wai encode-record
  verify`; `wai-pack encode-rung` and `verify-rung`; `wai_encode_measure` for speed, energy and
  quality.
- **The corpus** [`encode-conformance/`](encode-conformance/): small streams made through each
  interface (fixtures, pinned by SHA-256), records and negative controls generated over them from
  a fixed-seed key, every reason refused at least once, and encoded renditions of the base
  packaging golden, accepted and mutated. `encode_verify.py` is the second implementation,
  written from the text; it agrees with `wai-rs` and `wai-pack` on every case.

