rvoip-codec-core 0.3.8

G.711 and optional G.729/Opus/AMR audio codec implementations for RVOIP
Documentation
//! Normative tables for AMR-WB LP analysis.
//!
//! Values come from the 3GPP TS 26.173 fixed-point reference, which is what
//! defines the codec - TS 26.190 section 8.1: "described in a bit-exact
//! arithmetic". They are standard-defined constants, carried because the codec
//! cannot be conformant without exactly these numbers.
//!
//! The analysis window is deliberately *not* computed from the section 5.2.1
//! formula. It is close - `round(w * 32767)` reproduces 377 of the 384 entries -
//! but seven differ by one LSB, and one LSB through `mult_r` changes the output
//! bits. A test checks this table against the analytic formula to within 1 LSB,
//! which documents the definition and catches transcription errors without
//! pretending the formula is the source of truth.

/// Asymmetric LP analysis window, Q15, 384 samples (30 ms at 12.8 kHz).
///
/// Half a Hamming window over the first 256 samples, then a quarter cycle of a
/// Hamming-cosine over the last 128, per TS 26.190 section 5.2.1. Weight is
/// concentrated late so the filter describes the end of the frame, which is
/// where it gets used.
pub const ANALYSIS_WINDOW: [i16; 384] = [
    2621, 2622, 2626, 2632, 2640, 2650, 2662, 2677, 2694, 2714, 2735, 2759, 2785, 2814, 2844, 2877,
    2912, 2949, 2989, 3031, 3075, 3121, 3169, 3220, 3273, 3328, 3385, 3444, 3506, 3569, 3635, 3703,
    3773, 3845, 3919, 3996, 4074, 4155, 4237, 4321, 4408, 4496, 4587, 4680, 4774, 4870, 4969, 5069,
    5171, 5275, 5381, 5489, 5599, 5710, 5824, 5939, 6056, 6174, 6295, 6417, 6541, 6666, 6793, 6922,
    7052, 7185, 7318, 7453, 7590, 7728, 7868, 8009, 8152, 8296, 8442, 8589, 8737, 8887, 9038, 9191,
    9344, 9499, 9655, 9813, 9971, 10131, 10292, 10454, 10617, 10781, 10946, 11113, 11280, 11448,
    11617, 11787, 11958, 12130, 12303, 12476, 12650, 12825, 13001, 13178, 13355, 13533, 13711,
    13890, 14070, 14250, 14431, 14612, 14793, 14975, 15158, 15341, 15524, 15708, 15891, 16076,
    16260, 16445, 16629, 16814, 16999, 17185, 17370, 17555, 17740, 17926, 18111, 18296, 18481,
    18666, 18851, 19036, 19221, 19405, 19589, 19773, 19956, 20139, 20322, 20504, 20686, 20867,
    21048, 21229, 21408, 21588, 21767, 21945, 22122, 22299, 22475, 22651, 22825, 22999, 23172,
    23344, 23516, 23686, 23856, 24025, 24192, 24359, 24525, 24689, 24853, 25016, 25177, 25337,
    25496, 25654, 25811, 25967, 26121, 26274, 26426, 26576, 26725, 26873, 27019, 27164, 27308,
    27450, 27590, 27729, 27867, 28003, 28137, 28270, 28401, 28531, 28659, 28785, 28910, 29033,
    29154, 29274, 29391, 29507, 29622, 29734, 29845, 29953, 30060, 30165, 30268, 30370, 30469,
    30566, 30662, 30755, 30847, 30936, 31024, 31109, 31193, 31274, 31354, 31431, 31506, 31579,
    31651, 31719, 31786, 31851, 31914, 31974, 32032, 32088, 32142, 32194, 32243, 32291, 32336,
    32379, 32419, 32458, 32494, 32528, 32560, 32589, 32617, 32642, 32664, 32685, 32703, 32719,
    32733, 32744, 32753, 32760, 32764, 32767, 32767, 32765, 32757, 32745, 32727, 32705, 32678,
    32646, 32609, 32567, 32520, 32468, 32411, 32349, 32283, 32211, 32135, 32054, 31968, 31877,
    31781, 31681, 31575, 31465, 31351, 31231, 31107, 30978, 30844, 30706, 30563, 30415, 30263,
    30106, 29945, 29779, 29609, 29434, 29255, 29071, 28883, 28691, 28494, 28293, 28087, 27878,
    27664, 27446, 27224, 26997, 26767, 26533, 26294, 26052, 25806, 25555, 25301, 25043, 24782,
    24516, 24247, 23974, 23698, 23418, 23134, 22847, 22557, 22263, 21965, 21665, 21361, 21054,
    20743, 20430, 20113, 19794, 19471, 19146, 18817, 18486, 18152, 17815, 17476, 17134, 16789,
    16442, 16092, 15740, 15385, 15028, 14669, 14308, 13944, 13579, 13211, 12841, 12470, 12096,
    11721, 11344, 10965, 10584, 10202, 9819, 9433, 9047, 8659, 8270, 7879, 7488, 7095, 6701, 6306,
    5910, 5514, 5116, 4718, 4319, 3919, 3519, 3118, 2716, 2315, 1913, 1510, 1108, 705, 302,
];

/// Lag window for the autocorrelations, in the double-precision format the
/// reference uses: 16 `(high, low)` pairs covering lags 1 through 16.
///
/// Lag 0 is not stored, because the reference never scales `r[0]`. This is a
/// 60 Hz bandwidth expansion with the -40 dB noise floor folded in, so the
/// entries are `exp(-0.5 (2 pi 60 i / 12800)^2) * 0.9999`.
pub const LAG_WINDOW_DPF: [i16; 32] = [
    32750, 16896, 32707, 30464, 32637, 2496, 32538, 4480, 32411, 12160, 32257, 3520, 32075, 24320,
    31867, 24192, 31633, 20736, 31374, 576, 31089, 18240, 30780, 31488, 30449, 128, 30094, 16704,
    29718, 11520, 29321, 14784,
];