All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- MBAFF (Macroblock-Adaptive Frame-Field) interlaced support — the decoder
now handles interlaced H.264 content encoded with
mb_adaptive_frame_field_flag. Both frame-coded and field-coded MB pairs are fully supported:- Pair-based MB addressing with
mb_field_decoding_flagdecode (CABAC contexts 70-72 and CAVLC 1-bit) - MBAFF neighbor derivation per spec Tables 6-3/6-4 with y-coordinate remapping for all 4 frame/field mode combinations
- MVy scaling at cross frame/field boundaries (×2 field→frame, /2 frame→field)
- All CABAC/CAVLC context functions updated for MBAFF pair-based addressing
- Field-coded pixel layout with doubled stride and field-line offset
- Field-aware motion compensation via
luma_mc_stridewith per-field reference buffer offset for top/bottom field access - Field reference lists:
num_ref_idxdoubled for field-coded MBs,ref_idxmaps same-parity and opposite-parity fields - Field-coded CABAC significance/last coefficient contexts (ctxIdx 277+/338+ per spec Table 9-34)
- Field-coded CABAC neighbor addressing: bottom field MBs use same-field MB from above pair (not top of current pair)
- MBAFF-aware deblocking filter with pair-based iteration and correct left/above neighbor addressing
- MBAFF-aware POC computation:
min(TopFieldOrderCnt, BottomFieldOrderCnt)for POC types 0 and 1
- Pair-based MB addressing with
- 15 new MBAFF-specific byte-exact tests covering CAVLC/CABAC, I/P/B slices, frame-coded and field-coded pairs, deblocking, High profile 8x8 DCT, and implicit weighted bi-prediction. Total test count: 178.
- POC computation for
pic_order_cnt_type0 and 1 now correctly returnsmin(TopFieldOrderCnt, BottomFieldOrderCnt)instead of justTopFieldOrderCnt. Fixes implicit weighted bi-prediction for MBAFF B-frames with non-zerodelta_pic_order_cnt_bottom. - Above-right MV neighbor for MBAFF bottom MBs no longer reads from
undecoded pairs due to
mb_slice_idinitialization matchingthis_slice_id=0. Falls back to above-left correctly. - Fuzzing robustness: fixed multiple integer overflow panics found by
fuzzing on malformed bitstreams:
- IDCT 4x4 and 8x8 add/sub overflows (use wrapping arithmetic)
- POC type 1 multiplication overflow and MSB computation overflow
- POC shift overflow (clamp shift amount)
- Dequant DC multiply overflow
- SPS scaling list delta add overflow
- Deblocking filter multiply overflow
- SPS width overflow
- Bounds checking: fixed multiple out-of-bounds panics on malformed
bitstreams:
- Chroma MC reference plane boundary checks
- CABAC I_PCM frame buffer index validation
- Bitstream reader position validation
- Empty reference list safe indexing
- CAVLC coefficient position underflow guard
- Missing bounds/range validation on values from malformed bitstreams
OrderedDecoder— wrapsDecoderwith a built-in reorder buffer that emits frames in display order automatically. Handles IDR boundary tracking internally, eliminating a common pitfall where callers would tag the last B-frame of a GOP with the wrong GOP id and produce visible glitches at scene cuts. Recommended for most users.- AVCC (length-prefixed) NAL parser for MP4/MKV containers:
nal::parse_avcc(data, length_size)— parse a length-prefixed samplenal::parse_avcc_config(avcc_box)— parse an MP4avcCconfiguration record and extract SPS/PPS NALsnal::AvccConfigstruct exposinglength_size,sps_nals,pps_nals
- NEON SIMD acceleration on aarch64 for luma half-pel filters
(
half_pel_h,half_pel_v, quarter-pel paths) and chroma bilinear interpolation. Requires no opt-in — enabled automatically on aarch64. - Comprehensive doc comments on the entire public API. Crate-level docs, module-level intros, and runnable examples render on docs.rs.
- Test for
OrderedDecodervalidating display-order output against the manual sort baseline on a real preset_medium stream.
- Performance: 1080p decode improved from ~48 fps to ~67 fps (28% speedup) on Apple Silicon thanks to NEON luma half-pel intrinsics. 1080p @ 60 fps target achieved.
- Performance: 720p P-only improved from ~186 fps to ~278 fps; 720p with B-frames from ~190 fps to ~299 fps.
- README.md restructured to lead with
OrderedDecoderas the recommended entry point. The lower-levelDecoderis documented as an advanced option for callers who need raw decode order. parse_annex_band AVCC parsers now share a commonparse_nal_byteshelper for NAL header parsing and emulation-prevention removal.
- Build clean on stable Rust with no clippy warnings.
- Initial release on crates.io. Pure Rust H.264 decoder supporting Baseline, Main, and High profile (8-bit 4:2:0 progressive) with both CAVLC and CABAC entropy coding.
- Full support for I/P/B-frame decoding, multi-reference prediction with
ref_pic_list_modification, multi-slice frames, weighted prediction (explicit and implicit), long-term references, MMCO ops 1-6, deblocking filter, intra prediction (I4x4/I8x8/I16x16, all 9 modes for 4x4 and 8x8), spatial and temporal direct mode for B-slices. - Annex B bitstream parser (
nal::parse_annex_b) with zero-copy emulation prevention removal. - 119 unit tests, including 73 byte-exact stream tests against FFmpeg, with coverage up to 1080p (CABAC, CABAC+deblock, CAVLC) using SHA-256 hash comparison to keep test data small.
- License: dual MIT / Apache-2.0.
- ~48 fps at 1080p (mandelbrot content, x264
--preset mediumbframes=3 ref=2) - ~186 fps at 720p P-only / ~190 fps at 720p with B-frames
- See
BENCHMARK.mdfor detailed profile breakdown and methodology.
- Interlaced coding (MBAFF, field pictures)
- High 10 / 4:2:2 / 4:4:4 profiles
- SP/SI slice types
- Slice groups / FMO