Pure-Rust EVC — MPEG-5 Essential Video Coding (ISO/IEC 23094-1)
video decoder. Baseline + Main profiles. Zero C dependencies, zero FFI,
zero *-sys.
Part of the oxideav framework but usable standalone.
Working Baseline-profile decoder for IDR + P + B slices with full
residual coding, luma + chroma deblocking, and the 64-point IDCT, plus
the Main-profile CABAC initialization tables (Tables 40-90) and
the §9.3.4.2 ctxInc derivation helpers. Decode of the Main-profile
syntax elements themselves remains parked behind Error::Unsupported
— the round-7 deliverable lands the CABAC infrastructure so subsequent
rounds can implement individual tools without revisiting initValue
churn.
The remaining Baseline constraints (future rounds will lift them):
- 8-bit luma + chroma (4:2:0).
sps_addb_flag = 0(deblocking uses the §8.8.2 baseline filter; the Main-profile advanced deblocking §8.8.3 is parked).- Single reference picture per list (
num_ref_idx_active_minus1_l? = 0). - Sub-pel MV phases restricted to the Baseline 1/4-pel grid for luma (Table 25 phases 4, 8, 12) and 1/8-pel grid for chroma (Table 27 phases 4, 8, 12, 16, 20, 24, 28).
Anything outside the Baseline toolset (BTT, SUCO, ADMVP, EIPD, IBC, ATS,
ADCC, ALF, DRA, AMVR, MMVD, affine, DMVR, HMVP, …) bubbles up as
Error::Unsupported — but the CABAC contexts are now ready.
- Main-profile CABAC init tables: every initValue from
ISO/IEC 23094-1 §9.3.5 Tables 40-90 (BTT split, SUCO, cu_skip,
AMVR, MMVD, affine, ALF, DRA, ATS, ADCC, IBC, mvp_idx, merge_idx,
ref_idx, abs_mvd, intra_pred_mode + MPM, inter_pred_idc,
cbf_all/luma/cb/cr, cu_qp_delta_abs, sig_coeff_flag,
coeff_abs_level_greaterA/B, last_sig_coeff_x/y_prefix, …) lives in
the new
cabac_initmodule aspub constarrays keyed by the [MainCtxTable] enum (discriminant = spec table number). - §9.3.2.2 init pipeline (eq. 1425/1426) wired through
init_main_profile_contexts, which walks every Main-profile table and installs the per-(table, ctxIdx)(valState, valMps)derived from the slice QP. Table 39's initType=0 (I) vs initType=1 (P/B) split is encoded in [MainCtxTable::init_type_range]. - §9.3.4.2.2-12 ctxInc helpers: pure-function ports of the
per-syntax-element ctxInc derivations for
coeff_zero_run/coeff_abs_level_minus1,split_unit_coding_order_flag, the neighbour-block sum used byaffine_flag/cu_skip_flag/pred_mode_flag/ibc_flag,btt_split_flag(with Table 97ctxSetIdx),last_sig_coeff_{x,y}_prefix,sig_coeff_flag,coeff_abs_level_greaterA/B_flag,coeff_abs_level_remainingRice-parameter (Table 98),ats_cu_inter_flag, andats_cu_inter_horizontal_flag.
- Chroma deblocking: §8.8.2 chroma path per eq. 1167-1213. The
2-tap stencil (only
sBandsCmutate — eq. 1208/1209/1212/1213) runs against both Cb and Cr planes after the luma pass. Table 33 is keyed byqp_c = Clip3(0, 51, slice_qp + slice_cb_qp_offset)for Cb (withslice_cr_qp_offsetfor Cr — eq. 1194). Edge spacing scales via Table 2 sub-sampling factors (4:2:0 → every 2 chroma samples).
- Residual coding:
residual_coding_rle()per §7.3.8.7 now drives per-positionTransCoeffLevelreconstruction. Each non-zero CBF triggers the dequant + inverse-transform + add-to-predictor pipeline (intra and inter both supported). - 64×64 IDCT: the spec's eq. 1071-1076 has m/n indexing typos that
blocked transcription in round 3. Round 5 builds the matrix from
the closed form
M[m][n] = round(64·√2·cos(π·m·(2n+1)/128))for m≥1 (M[0][n] = 64), verified against every printed entry of eq. 1072 / eq. 1074. - Deblocking: §8.8.2 luma path with the BS table from Table 33, the 4-tap edge filter from eq. 1148-1158, and per-4×4-grid side-info tracking (PredMode + CBF + MV + RefIdx) populated as CUs decode.
167 unit tests cover the CABAC engine, NAL / parameter-set parsing, the
slice_data() walker, the IDR pixel pipeline, the inter-prediction
primitives, the residual / dequant / IDCT chain, the 64-point IDCT
construction, the deblocking filter math for both luma (4-tap) and
chroma (2-tap) — Table 33 spot checks, BS rules, edge smoothing
fixtures, the chroma_qp_offset switch, the end-to-end no-op pass on
a uniform-grey IDR — and the round-7 Main-profile CABAC infrastructure
(Tables 40-90 spot checks, Table 39 init-type ranges, the §9.3.4.2.x
ctxInc helpers, and end-to-end init_main_profile_contexts derivation
at QP 22 / 32).