Skip to main content

Module ofdm_frame

Module ofdm_frame 

Source

Structs§

BlockPlan
Deterministic size accounting for one logical block’s coding chain, so the transmitter and receiver agree on every intermediate length (needed to trim interleaver/fragmentation zero-padding on receive) and on how many OFDM symbols the coded bits occupy.
CodecCache
EncodedStages
The intermediate bit-streams the encode chain passes through, kept so a receiver can measure error rates against them.
Mcs
A modulation-and-coding scheme: the payload’s constellation plus its inner and outer FEC. Selected per-frame by FrameMetadata::mcs_index via an McsTable.
McsTable
Maps an 8-bit mcs_index to an Mcs. The sender and receiver must share the same table.
OfdmFrameMod
The OFDM frame modulator.

Constants§

BCH_INFO_BITS
Fixed information-bit block size for the outer BCH code (per shortened codeword). Chosen so one codeword fits comfortably within GF(2^8)’s length bound (n = k + parity ≤ 255) for the t values used here.
HEADER_CONSTELLATION
The fixed constellation used for header symbols (most robust).
HEADER_FIELD_BYTES
Number of header field bytes before the header CRC: mcs_index (1) + payload_len (4, big-endian) + sequence_num (4) + flags (1) + scrambler_seed (4) = 14 bytes.
HEADER_LDPC
The fixed inner code protecting the header — a rate-1/2 LDPC, independent of the payload MCS.

Functions§

append_crc
Appends the selected CRC (over data) to data, big-endian.
bits_to_bytes
Packs a bit slice (MSB-first per byte) back into bytes. The bit count must be a multiple of 8.
block_plan
Computes the BlockPlan for info_bytes under the given coding chain, reusing constructed code objects from cache (their dimensions are all this needs, but sharing the cache avoids rebuilding them here and in the encode/decode passes).
build_scrambler
Builds a PnScrambler from a ScramblerKind and an explicit seed value (for PerFrameRandom, the caller supplies the drawn seed). Returns None for ScramblerKind::None.
bytes_to_bits
Unpacks bytes into a bit vector, MSB-first per byte.
check_and_strip_crc
Splits data into (payload, crc-ok). Returns None if data is too short to hold the CRC field. With CrcKind::None the check is vacuously true.
encode_chain
Runs the full encode chain for one logical block (header or payload): bytes → CRC → [scramble if before] → outer → outer-interleave → inner → inner-interleave → [scramble if after], returning coded bits ready to map.
encode_chain_stages
encode_chain, keeping the per-stage intermediates instead of only the final coded bits — see EncodedStages.
inner_encode
Encodes info_bits through the inner code, returning coded bits. The info bit stream is fragmented into K-bit blocks, each encoded into one N-bit codeword (final block zero-padded). None passes through.
interleave_bits
Applies a block interleaver to bits in place-by-value: writes bit i of each padded block row-major and reads column-major. Returns the interleaved bits plus the block size used, so the deinterleaver can trim padding.
outer_encode
Encodes message_bytes through the outer code (byte domain), returning the coded bits (MSB-first). The message bit stream is fragmented into BCH_INFO_BITS-bit blocks, each encoded into one shortened BCH codeword; the final block is zero-padded. None outer code passes the bytes through as bits.
pack_header_fields
Serializes the 14 header field bytes (before CRC), big-endian.
plan_of
Convenience: the carrier plan cloned from a config (used by the demodulator).
scramble_bits
Scrambles a bit vector by packing to bytes (zero-padded), XORing the PN sequence, and unpacking — used for the after-inner-FEC bit-domain position.
scramble_bytes
Applies the byte-domain whitener for kind to bytes in place (self-inverse, so the same call scrambles and descrambles). Handles both the generic Additive LFSR and DVB-T energy dispersal; a no-op for None. The after-inner-FEC bit-domain scramble position uses the PnScrambler directly (DVB-T energy dispersal is byte-domain / before-FEC only).
shortened_bch_for
Constructs a BCH code correcting t errors, shortened so its message part holds exactly msg_bits information bits.
symbol_config
Builds a bare per-symbol OfdmConfig (no frame fields) for a given constellation, sharing the base plan/fs/rf/gain. Used to drive OfdmMod for the header (BPSK) and payload (MCS) symbol streams.
symbols_for_coded_bits
Number of OFDM symbols a logical block occupies for a given constellation over the base plan.