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
//! ITU-T / 3GPP fixed-point basic operators — the ETSI "basicop" library.
//!
//! Every fixed-point speech codec in this crate specifies its arithmetic in
//! terms of these exact saturating operations. G.729 and AMR both do, so a
//! single implementation is the only way both can be bit-exact against the same
//! definitions; two copies would be two things to keep in agreement with the
//! spec and with each other.
//!
//! # Provenance
//!
//! Written for the G.729A port, where it was validated by that codec reaching
//! bit-exactness, and promoted out of `codecs::g729::impls::dsp` when AMR
//! needed the same foundation. G.729 continues to reach it under the old name
//! via a re-export, so its ~318 call sites were untouched by the move.
//!
//! # Scope
//!
//! Basic operators only — the table-free saturating arithmetic. Table-driven
//! transcendentals (`pow2`, `log2`, `inv_sqrt`) live with their codec, because
//! each supplies its own lookup tables and sharing the code before proving the
//! tables identical would be an assumption dressed as reuse. G.729's are in
//! [`crate::codecs::g729::impls::math`].
//!
//! # Overflow flags
//!
//! The reference C carries `Overflow` and `Carry` as globals that operators set
//! and a few algorithms read. [`DspContext`] threads them explicitly instead,
//! preserving the observable behaviour without global mutable state.
// This subtree is a transcription of reference fixed-point arithmetic. The
// narrowly enumerated lints below conflict with its deliberate wrapping casts,
// reference-style names and layout — the same exemption, and the same
// reasoning, as the G.729 implementation subtree it came from. Everything else
// in codec-core stays under the full strict lint policy.
// A complete operator library: not every operator has a caller yet, and the
// ones AMR needs but G.729 does not must still be present and correct. The
// same applies to the re-export shims that keep reference-style names
// available alongside the snake_case ones.
/// 16-bit saturating arithmetic.
/// 32-bit saturating arithmetic.
/// Fractional division.
/// Extended-precision 32-bit helpers.
/// The reference pseudo-random generator.
/// Saturating shifts and normalisation.
/// Fixed-point value types and the operator status flags.
/// Public re-export.
pub use ;