Documentation
¶
Overview ¶
Package mdct implements the forward MDCT used by the AAC encoder, numerically equivalent to FFmpeg's AV_TX_FLOAT_MDCT (libavutil/tx @ d09d5afc3a). Internals are float64 for headroom; the API is float32.
SPDX-License-Identifier: LGPL-2.1-or-later
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MDCT ¶
type MDCT struct {
// contains filtered or unexported fields
}
MDCT computes a forward MDCT with n output coefficients from 2n inputs:
X[k] = scale * sum_{j=0}^{2n-1} x[j] * cos(pi/n * (j + 0.5 + n/2) * (k + 0.5))
Mirrors libavutil/tx_template.c:ff_tx_mdct_fwd and ff_tx_mdct_gen_exp @ d09d5afc3a (fold 2n reals into n/2 complex points, n/2-point forward FFT, post-rotation; sqrt(scale) folded into the twiddles twice).
func New ¶
New returns an MDCT producing n coefficients from 2n input samples with output scale factor scale.
n must be a positive power of two divisible by 4: the FFT's bit-reversal assumes a power-of-two length and Transform's second loop steps over n/4 index pairs. An invalid n would not panic, it would quietly produce wrong coefficients, so it is rejected here. AAC uses 1024 and 128.
Transform writes through the per-instance scratch buffers, so an *MDCT must not be shared across goroutines without external synchronization. The encoder gives each channel its own.