1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2026 Christoph Gaffga
// SPDX-License-Identifier: GPL-3.0-only
// https://github.com/cgaffga/phasmcore
//! Phase 6 — pure-Rust H.264 encoder.
//!
//! Module skeleton (Phase 6.0a). Most types are empty placeholders that
//! get filled in as the per-module sessions land — see
//! `docs/design/h264-encoder-algorithms/README.md` for the per-module
//! note + implementation tracking, and
//! `docs/design/h264-video-steganography.md` § Phase 6 for the full
//! sub-phase plan.
//!
//! ## Module structure
//!
//! - [`bitstream_writer`] — NAL / SPS / PPS / slice header / MB layer
//! bit-level writer. Reuses Exp-Golomb helpers from the existing
//! parser side.
//! - [`transform`] — forward 4×4 + 8×8 integer DCT, forward Hadamard
//! 4×4 DC, plus the inverses needed by the reconstruction loop.
//! Forward direction is new; inverse is shared with Phase 1b.
//! - [`quantization`] — forward quantization with trellis-quant
//! refinement.
//! - [`intra_predictor`] — all 9 Intra_4x4 modes, 4 Intra_16x16,
//! chroma intra, plus SATD-based mode decision with psy-RD bias.
//! - [`cavlc_writer`] — CAVLC encoder (luma 4×4, chroma DC + AC,
//! I_16x16 DC + AC). Reverses the existing Phase 1a decoder.
//! - [`reconstruction`] — inverse quant + IDCT + add prediction +
//! neighbor pixel buffer for next-block intra-pred lookup.
//! - [`deblocking_filter`] — boundary strength + alpha/beta tables +
//! Filter4 / Filter2 + cross-MB filtering per ITU-T H.264 § 8.7.
//! - [`rate_control`] — per-MB variance + AQ-mode 1 + CRF-style frame
//! QP target + the `quality: u8` public API + source-quality
//! estimator.
//! - [`motion_estimation`] — Phase 6B: hexagonal + UMH + sub-pel
//! refinement.
//! - [`motion_compensation`] — Phase 6B: 6-tap quarter-pel luma +
//! bilinear chroma.
//! - [`reference_buffer`] — Phase 6B: DPB + reference list + GOP
//! structure.
//! - [`encoder`] — top-level encoder driver: pixel input → MB loop →
//! bytes out. Holds the encoder state machine.
//!
//! ## Status
//!
//! Skeleton only. Every public function in this module currently
//! returns a `EncoderError::NotImplemented` or panics with `todo!()`.
//! Real implementations land in Phase 6A through 6E.
// Phase 6F.1 — `stego` was relocated to `h264::stego`
// (peer of encoder/) so the bin-decoder doesn't need to import
// from encoder::*. Module declaration moved to
// `core/src/codec/h264/mod.rs`. This empty marker line preserves
// commit history readability.
// CAVLC writer lives next door at `core/src/codec/h264/cavlc_writer.rs`
// once Phase 6A.4 lands — keeping it one level up keeps it sibling to
// the existing Phase 1a `cavlc.rs` decoder.
/// Top-level error type for the H.264 encoder.