Commit Graph
12 Commits
Author SHA1 Message Date
Brandon ThomasandClaude Opus 5.5 a47b90e7bf M2 perf: skip internal deblocking edges of uniform-motion macroblocks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:57:35 -04:00
Brandon ThomasandClaude Opus 5.5 3903d2909a M2 tests: Apple VideoToolbox encoded fixtures (bit-exact)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:55:44 -04:00
Brandon ThomasandClaude Opus 5.5 8da290c1bd M2 tests: POC type 1 reordering synthetic stream
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:54:54 -04:00
Brandon ThomasandClaude Opus 5.5 aa8ee4fcf6 M2 perf/docs: faster CABAC engine and residual parsing, README
- CABAC engine keeps codIOffset scaled in a 64-bit register with 32-bit
  refills instead of re-reading the bitstream on every renormalisation
- significance map collected as a position list; context increments from
  per-category tables
- fixed-size row copies for motion-compensation windows and block copies
- explicit weighted prediction (P_Skip and B_Skip bi-prediction) synthetic
  test, cross-checked with ffmpeg
- crates/h264/README.md: features, API, threading model, fixture matrix,
  performance, known gaps and the plan for High 10 / 4:2:2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:53:55 -04:00
Brandon ThomasandClaude Opus 5.5 20f0d08311 M2 tests: synthetic I_PCM/long-term/MMCO/gap streams, avcC, robustness, stats
- hand-built CAVLC and CABAC bitstreams (test-only CABAC encoder) with I_PCM
  and P_Skip macroblocks exercising long-term references, MMCO 1-6,
  frame_num gaps and reference list modification (idc 0 and 2); expected
  output is known exactly and cross-checked with ffmpeg when available
- avcC configuration + length-prefixed samples with pts round trip
- corrupted / truncated / garbage input never panics or deadlocks
  (single- and multi-threaded)
- Decoder::stats() coverage counters and an ignored coverage report test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:44:39 -04:00
Brandon ThomasandClaude Opus 5.5 374569e65e M2 perf: frame-threaded H.264 decoding and hot-path optimisation
- frame-level parallelism: the calling thread handles headers, POC, DPB and
  reference lists; each picture decodes as a job on a rayon pool (feature
  'threads') and publishes deblocked macroblock rows into a shared Frame;
  motion compensation and co-located lookups block per row on references
  still being decoded (safe Rust, OnceLock per MB row); outputs are handed
  out once their job has finished
- row-pipelined deblocking inside a picture (row r filtered after row r+1 is
  reconstructed), picture buffer recycling, panic/error isolation per job
- faster luma/chroma interpolation (row-wise filters, window fetch), direct
  interpolation into the picture for unweighted single-list blocks, merged
  motion compensation for uniform direct macroblocks, 8x8 direct derivation
  with direct_8x8_inference, vectorisable weighted prediction, deblocking
  with per-edge parameters and cached reference identities
- conformance tests now decode every fixture single- and multi-threaded and
  check pts/POC output order; ignored perf test (1080p High CRF20, 120 frames)

1080p: ~100 fps single-threaded, ~600 fps with 14 threads (M4 Pro, heavily
loaded machine).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:38:40 -04:00
Brandon ThomasandClaude Opus 5.5 aefe1ae08f M2.4: H.264 CABAC entropy decoding
- arithmetic decoding engine (DecodeDecision / Bypass / Terminate, 9-bit
  register semantics incl. I_PCM re-initialisation), combined state
  transition table, round-trip tested against a reference encoder model
- context initialisation for cabac_init_idc 0..2 and I slices, all 1024
  (m, n) pairs extracted from Tables 9-12..9-33 of the spec
- binarisations + ctxIdxInc derivations: mb_skip_flag, mb_type (I/P/B incl.
  intra suffixes and I_PCM), sub_mb_type, ref_idx, mvd (UEG3), prev/rem intra
  modes, intra_chroma_pred_mode, coded_block_pattern, mb_qp_delta,
  transform_size_8x8_flag, coded_block_flag (all block categories incl.
  inferred 8x8 flags), significant/last (frame, 4x4 and 8x8 tables),
  coeff_abs_level_minus1 (UEG0), end_of_slice_flag

The full fixture matrix (32 libx264 configurations: Baseline/Main/High,
CABAC+B-pyramid, weightp/weightb, direct temporal/spatial, ref=4, deblock
variants, cqm=jvt, 4 slices, open GOP, constrained intra, 8x8dct=0, QP 1/50,
720p/1080p/1918x1078 crop) decodes bit-exact against ffmpeg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:19:54 -04:00
Brandon ThomasandClaude Opus 5.5 c6a7075de7 M2.5: H.264 deblocking loop filter
- bS derivation: intra MB edges (4) / internal (3), non-zero coefficients per
  4x4 or 8x8 transform block (2), reference picture identity + mv distance
  rules incl. bi-predicted partitions (1)
- alpha/beta/tC0 tables, luma normal and strong filters, chroma filters with
  chroma bS mapped from luma, I_PCM qP handling, per-component chroma QP
- disable_deblocking_filter_idc 0/1/2 incl. slice boundary rule, slice
  alpha/beta offsets, 8x8 transform internal edges

All CAVLC fixtures (Baseline, High CAVLC with B-frames, temporal direct,
weighted prediction, multi-slice, QP 1) are bit-exact against ffmpeg.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:14:35 -04:00
Brandon ThomasandClaude Opus 5.5 9c8de5468b M2.2/M2.3: CAVLC macroblock decoding, intra and inter prediction, DPB
- CAVLC residual parsing (coeff_token / total_zeros / run_before tables taken
  from the spec text, level decoding with escape codes), macroblock layer for
  I/P/B slices (mb_type, sub_mb_type, mb_pred, sub_mb_pred, me(v) cbp,
  mb_qp_delta), I_PCM
- intra prediction: Intra4x4 (9 modes), Intra8x8 with reference filtering,
  Intra16x16, chroma; constrained_intra_pred
- dequantisation with flat/custom scaling matrices; 4x4, 8x8, luma DC
  Hadamard and 2x2 chroma DC inverse transforms
- inter prediction: median / directional mv prediction, P_Skip, B spatial and
  temporal direct (direct_8x8_inference), B_Skip, 6-tap luma and bilinear
  chroma interpolation, explicit and implicit weighted prediction
- reference lists (init + modification), DPB with sliding window, all MMCOs,
  frame_num gaps, bumping / max_num_reorder_frames output order, IDR and
  no_output_of_prior_pics
- public Decoder/Picture API (Annex-B and avcC input, pts passes through
  reordering)

Deblocking (M2.5) follows in the next commit, so the bit-exact fixtures in
this commit are the no-deblock ones. CABAC slices return Unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:14:18 -04:00
Brandon ThomasandClaude Opus 5.5 a2ac32916b M2.1: H.264 NAL/SPS/PPS/slice header parsing
New crate filmcraft-h264 (L0, depends only on filmcraft-bitstream):
- SPS incl. VUI/HRD, scaling lists with fall-back rules A/B, frame cropping,
  high-profile chroma_format_idc / bit depth fields, DPB size from level
- PPS incl. transform_8x8_mode, scaling lists, slice groups (parse only)
- slice header: all fields incl. ref_pic_list_modification, pred_weight_table,
  dec_ref_pic_marking
- POC types 0/1/2 (incl. MMCO5 handling and frame_num gap hooks)
- default scaling / QPc / deblocking tables from the public ITU-T spec
- ffmpeg/libx264 fixture generator for tests (skips when ffmpeg is absent)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 06:12:38 -04:00
Brandon ThomasandClaude Opus 5.5 936b28e4c4 M0.1/M0.2: workspace skeleton, time and bitstream crates
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 05:33:20 -04:00
Brandon Thomas 16489cea4a first commit 2026-09-30 05:22:00 -04:00