Skip to main content

Module toy

Module toy 

Source
Expand description

Reference implementations: a toy container (TIVF: a 20-byte header and length-prefixed timed packets) and a toy codec (a packet holds 0..3 grey pictures and may re-present the previous one).

They exercise every rule of the media contracts: output later than input and 0..N frames per packet, shared pictures, backpressure, drain, reset, configuration epochs, seeking with an index scan, and pulled muxer output with or without patches. The conformance checks are validated against them, as zencodec-testkit’s checks are against its reference codec.

TIVF header: b"TIVF", width u16, height u16, time base numerator u32, denominator u32, packet count u32 (0 = unknown), all little endian. Packet: payload length u32, pts i64, flags u8 (bit 0: random access), payload. Toy payload: picture count u8 (0..=3), show-existing u8, then the grey planes.

Structs§

ToyDecoder
Toy decoder. Pictures come out one packet late (a one-packet reorder), so output trails input; a show-existing flag re-presents the previous picture. Holds at most max_queued_frames before pushing back.
ToyDemuxer
Sans-I/O TIVF demuxer. Sequential by default; seek builds a bounded index by scanning packet headers with Range requests.
ToyEncoder
Toy encoder: one gray picture per packet, lookahead frames held back, a random-access point every keyint packets.
ToyMuxer
TIVF muxer. write_count means the header’s packet count is patched at finish, which a forward-only destination cannot accept.

Enums§

ToyError
Errors of the toy container and codec.

Constants§

HEADER_LEN
TIVF header length.
MAGIC
The TIVF file signature.
PACKET_HEADER_LEN
TIVF packet header length.

Functions§

toy_payload
Build a toy packet payload.