Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Module idct

Module idct 

Source
Expand description

The MDEC’s IDCT matrix, generated from the DCT basis.

MDEC command 3 takes 64 signed 16-bit coefficients, sent as 32 words with the even-numbered coefficient in each word’s low halfword (psx-spx, “MDEC Decompression”, command 3). Coefficient 8k + n is the 8-point DCT-II basis function of frequency k sampled at n, scaled to 1.15 fixed point and truncated toward zero:

M[0][n] = 32768 / sqrt(2)                      (= 16384 * sqrt(2))
M[k][n] = 32768 * cos((2n + 1) * k * pi / 16)   for k = 1..7

Everything below runs at compile time, in integers: pi from Machin’s formula, cosines from their Taylor series in 2.62 fixed point, and the DC term from an integer square root. Nothing here exists at run time except the finished table.

Constants§

MATRIX
The 64 coefficients, frequency-major: MATRIX[8 * k + n].
MATRIX_WORDS
MATRIX packed for the MDEC: word w holds coefficient 2w in its low halfword and 2w + 1 in its high halfword.