Documentation
¶
Overview ¶
Package fixedpoint is the gopus FIXED_POINT CELT codec: a pure-integer port of libopus' CELT encoder and decoder for the static 48000/960 mode. Everything runs in the integer domain with no floating-point and reproduces the libopus integer arithmetic bit-for-bit. The package is not part of the default float build; it is compiled only behind the gopus_fixed_point build tag, so its consumers select the integer codec at build time.
The port covers the whole FIXED_POINT CELT pipeline, each file naming the libopus translation unit it mirrors:
- integer math kernels (celt/mathops.h, celt/mathops.c): log2/exp2, sqrt, rcp, cos, ilog2 — see celt_math.go and celt_mathops.go;
- the MDCT and KISS-FFT (celt/mdct.c, celt/kiss_fft.c) plus the precomputed 48000/960 twiddle/window tables;
- band energy, normalisation, PVQ pulse search and the entropy-coupled band quantiser (celt/bands.c, celt/vq.c, celt/quant_bands.c);
- the encoder and decoder drivers, prefilter/comb filter, transient and dynalloc analysis, anti-collapse, de-emphasis and PLC (celt/celt_encoder.c, celt/celt_decoder.c, celt/celt.c).
Why the integer widths matter: in libopus' FIXED_POINT build celt_norm and opus_val32 are int32, opus_val16 is int16 and opus_val64/accumulators are int64. The macros that truncate an operand to int16 before a 16x16 or 16x32 multiply (MULT16_16, MULT16_16_Q15, MAC16_16, MULT16_32_Q15, ...) and the rounded/arithmetic shifts (PSHR32, VSHR32, ROUND16) are reproduced with those exact Go integer types. Using a wider type anywhere would skip the truncation or overflow wraparound the reference depends on and break bit-exactness, so the operand widths in this package are load-bearing, not incidental.
Q-notation used throughout matches libopus (1.0 represented as 1<<n):
Q10: 1.0 = 1<<10 = 1024 Q14: 1.0 = 1<<14 = 16384 Q15: 1.0 = 1<<15 = 32768 Q16: 1.0 = 1<<16 = 65536
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CeltExp2 ¶
CeltExp2 computes 2^x in fixed-point. Input x is Q10 (1.0 = 1024). Output is Q16 (1.0 = 65536). Matches libopus celt/mathops.h celt_exp2() (FIXED_POINT path).
func CeltExp2Frac ¶
CeltExp2Frac returns the fractional part of 2^x where x is in Q10. Only the fractional bits of x are used (x & 0x3FF in Q10 == x mod 1.0). Output is approximately Q14 (range ≈ [1.0, 2.0)). Matches libopus celt/mathops.h celt_exp2_frac() (FIXED_POINT path).
Constants:
D0=16383, D1=22804, D2=14819, D3=10204
func CeltLog2 ¶
CeltLog2 approximates log2(x) in fixed-point. Input x is Q14 (1.0 = 16384), must be > 0. Output is Q10 (1.0 = 1024). Matches libopus celt/mathops.h celt_log2() (FIXED_POINT path).
func CeltRsqrtNorm ¶
CeltRsqrtNorm computes 1/sqrt(x) for x in [0.25, 1.0) represented in Q16. Output is Q14. Matches libopus celt/mathops.c celt_rsqrt_norm() (FIXED_POINT path).
Types ¶
This section is empty.