Representation of signals by minimum number of values is important for storage and transmission. The possibility of large discontinuity between the beginning and end of a period of a signal in DFT can be avoided by extending the signal so that it is even-symmetric. Discrete Cosine Transform (DCT) is constructed such that its energy is heavily concentrated in the lower part of the spectrum and is very widely used in signal and image coding applications. The family of DCTs (DCT type- 1,2,3,4) is the outcome of different combinations of homogeneous boundary conditions. DCT has an excellent energy-packing capability, hence has many applications and in data compression in particular.
DCT is essentially the Discrete Fourier Transform(DFT) of an even-extended real signal. Reordering of the input data makes the computation of DCT just a problem of computing the DFT of a real signal with a few additional operations. This approach provides regular, simple, and very efficient DCT algorithms for practical hardware and software implementations.
DCT type-II can be implemented using Fast fourier transform (FFT) internally, as the transform is applied on real values, Real FFT can be used. DCT4 is implemented using DCT2 as their implementations are similar except with some added pre-processing and post-processing. DCT2 implementation can be described in the following steps:
This process is explained by the block diagram below:
Discrete Cosine Transform - type-IV
k = 0,1,2,.....N-1
n = 0,1,2,.....N-1
arm_dct4_instance_f32 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft}; arm_dct4_instance_q31 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft}; arm_dct4_instance_q15 S = {N, Nby2, normalize, pTwiddle, pCosFactor, pRfft, pCfft};where
N
is the length of the DCT4; Nby2
is half of the length of the DCT4; normalize
is normalizing factor used and is equal to sqrt(2/N)
; pTwiddle
points to the twiddle factor table; pCosFactor
points to the cosFactor table; pRfft
points to the real FFT instance; pCfft
points to the complex FFT instance; The CFFT and RFFT structures also needs to be initialized, refer to arm_cfft_radix4_f32() and arm_rfft_f32() respectively for details regarding static initialization.arm_status arm_dct4_init_f32 | ( | arm_dct4_instance_f32 * | S, |
arm_rfft_instance_f32 * | S_RFFT, | ||
arm_cfft_radix4_instance_f32 * | S_CFFT, | ||
uint16_t | N, | ||
uint16_t | Nby2, | ||
float32_t | normalize | ||
) |
Initialization function for the floating-point DCT4/IDCT4.
[in,out] | *S | points to an instance of floating-point DCT4/IDCT4 structure. |
[in] | *S_RFFT | points to an instance of floating-point RFFT/RIFFT structure. |
[in] | *S_CFFT | points to an instance of floating-point CFFT/CIFFT structure. |
[in] | N | length of the DCT4. |
[in] | Nby2 | half of the length of the DCT4. |
[in] | normalize | normalizing factor. |
fftLenReal
is not a supported transform length. sqrt(2/N)
, which depends on the size of transform N
. Floating-point normalizing factors are mentioned in the table below for different DCT sizes: Definition at line 4142 of file arm_dct4_init_f32.c.
void arm_dct4_f32 | ( | const arm_dct4_instance_f32 * | S, |
float32_t * | pState, | ||
float32_t * | pInlineBuffer | ||
) |
Processing function for the floating-point DCT4/IDCT4.
[in] | *S | points to an instance of the floating-point DCT4/IDCT4 structure. |
[in] | *pState | points to state buffer. |
[in,out] | *pInlineBuffer | points to the in-place input and output buffer. |
Definition at line 126 of file arm_dct4_f32.c.
arm_status arm_dct4_init_q31 | ( | arm_dct4_instance_q31 * | S, |
arm_rfft_instance_q31 * | S_RFFT, | ||
arm_cfft_radix4_instance_q31 * | S_CFFT, | ||
uint16_t | N, | ||
uint16_t | Nby2, | ||
q31_t | normalize | ||
) |
Initialization function for the Q31 DCT4/IDCT4.
[in,out] | *S | points to an instance of Q31 DCT4/IDCT4 structure. |
[in] | *S_RFFT | points to an instance of Q31 RFFT/RIFFT structure |
[in] | *S_CFFT | points to an instance of Q31 CFFT/CIFFT structure |
[in] | N | length of the DCT4. |
[in] | Nby2 | half of the length of the DCT4. |
[in] | normalize | normalizing factor. |
N
is not a supported transform length. sqrt(2/N)
, which depends on the size of transform N
. Normalizing factors in 1.31 format are mentioned in the table below for different DCT sizes: Definition at line 2133 of file arm_dct4_init_q31.c.
void arm_dct4_q31 | ( | const arm_dct4_instance_q31 * | S, |
q31_t * | pState, | ||
q31_t * | pInlineBuffer | ||
) |
Processing function for the Q31 DCT4/IDCT4.
[in] | *S | points to an instance of the Q31 DCT4 structure. |
[in] | *pState | points to state buffer. |
[in,out] | *pInlineBuffer | points to the in-place input and output buffer. |
Definition at line 53 of file arm_dct4_q31.c.
arm_status arm_dct4_init_q15 | ( | arm_dct4_instance_q15 * | S, |
arm_rfft_instance_q15 * | S_RFFT, | ||
arm_cfft_radix4_instance_q15 * | S_CFFT, | ||
uint16_t | N, | ||
uint16_t | Nby2, | ||
q15_t | normalize | ||
) |
Initialization function for the Q15 DCT4/IDCT4.
[in,out] | *S | points to an instance of Q15 DCT4/IDCT4 structure. |
[in] | *S_RFFT | points to an instance of Q15 RFFT/RIFFT structure. |
[in] | *S_CFFT | points to an instance of Q15 CFFT/CIFFT structure. |
[in] | N | length of the DCT4. |
[in] | Nby2 | half of the length of the DCT4. |
[in] | normalize | normalizing factor. |
N
is not a supported transform length. sqrt(2/N)
, which depends on the size of transform N
. Normalizing factors in 1.15 format are mentioned in the table below for different DCT sizes: Definition at line 1125 of file arm_dct4_init_q15.c.
void arm_dct4_q15 | ( | const arm_dct4_instance_q15 * | S, |
q15_t * | pState, | ||
q15_t * | pInlineBuffer | ||
) |
Processing function for the Q15 DCT4/IDCT4.
[in] | *S | points to an instance of the Q15 DCT4 structure. |
[in] | *pState | points to state buffer. |
[in,out] | *pInlineBuffer | points to the in-place input and output buffer. |
Definition at line 52 of file arm_dct4_q15.c.
const float32_t Weights_128[256] [static] |
weights[n] = e^(-j*n*pi/(2*N))
for(i = 0; i< N; i++) { weights[2*i]= cos(i*c); weights[(2*i)+1]= -sin(i * c); }
N
is the Number of weights to be calculated and c
is pi/(2*N)
2*N
. Definition at line 64 of file arm_dct4_init_f32.c.
const float32_t Weights_512[1024] [static] |
Definition at line 195 of file arm_dct4_init_f32.c.
const float32_t Weights_2048[4096] [static] |
Definition at line 710 of file arm_dct4_init_f32.c.
const float32_t cos_factors_128[128] [static] |
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
for(i = 0; i< N; i++) { cos_factors[i]= 2 * cos((2*i+1)*c/2); }
N
is the number of factors to generate and c
is pi/(2*N)
Definition at line 2774 of file arm_dct4_init_f32.c.
const float32_t cos_factors_512[512] [static] |
Definition at line 2841 of file arm_dct4_init_f32.c.
const float32_t cos_factors_2048[2048] [static] |
Definition at line 3100 of file arm_dct4_init_f32.c.
const q31_t WeightsQ31_128[256] [static] |
weights[n] = e^(-j*n*pi/(2*N))
for(i = 0; i< N; i++) { weights[2*i]= cos(i*c); weights[(2*i)+1]= -sin(i * c); }
N
is the Number of weights to be calculated and c
is pi/(2*N)
2*N
. Definition at line 66 of file arm_dct4_init_q31.c.
const q31_t WeightsQ31_512[1024] [static] |
Definition at line 133 of file arm_dct4_init_q31.c.
const q31_t WeightsQ31_2048[4096] [static] |
Definition at line 392 of file arm_dct4_init_q31.c.
const q31_t cos_factorsQ31_128[128] [static] |
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
for(i = 0; i< N; i++) { cos_factors[i]= 2 * cos((2*i+1)*c/2); }
N
is the number of factors to generate and c
is pi/(2*N)
Definition at line 1436 of file arm_dct4_init_q31.c.
const q31_t cos_factorsQ31_512[512] [static] |
Definition at line 1471 of file arm_dct4_init_q31.c.
const q31_t cos_factorsQ31_2048[2048] [static] |
Definition at line 1602 of file arm_dct4_init_q31.c.
const q15_t WeightsQ15_128[256] [static] |
weights[n] = e^(-j*n*pi/(2*N))
for(i = 0; i< N; i++) { weights[2*i]= cos(i*c); weights[(2*i)+1]= -sin(i * c); }
N
is the Number of weights to be calculated and c
is pi/(2*N)
2*N
. Definition at line 66 of file arm_dct4_init_q15.c.
const q15_t WeightsQ15_512[1024] [static] |
Definition at line 101 of file arm_dct4_init_q15.c.
const q15_t WeightsQ15_2048[4096] [static] |
Definition at line 232 of file arm_dct4_init_q15.c.
const q15_t cos_factorsQ15_128[128] [static] |
{ 0x7fff, 0x7ffa, 0x7ff0, 0x7fe1, 0x7fce, 0x7fb5, 0x7f97, 0x7f75, 0x7f4d, 0x7f21, 0x7ef0, 0x7eba, 0x7e7f, 0x7e3f, 0x7dfa, 0x7db0, 0x7d62, 0x7d0f, 0x7cb7, 0x7c5a, 0x7bf8, 0x7b92, 0x7b26, 0x7ab6, 0x7a42, 0x79c8, 0x794a, 0x78c7, 0x7840, 0x77b4, 0x7723, 0x768e, 0x75f4, 0x7555, 0x74b2, 0x740b, 0x735f, 0x72af, 0x71fa, 0x7141, 0x7083, 0x6fc1, 0x6efb, 0x6e30, 0x6d62, 0x6c8f, 0x6bb8, 0x6adc, 0x69fd, 0x6919, 0x6832, 0x6746, 0x6657, 0x6563, 0x646c, 0x6371, 0x6271, 0x616f, 0x6068, 0x5f5e, 0x5e50, 0x5d3e, 0x5c29, 0x5b10, 0x59f3, 0x58d4, 0x57b0, 0x568a, 0x5560, 0x5433, 0x5302, 0x51ce, 0x5097, 0x4f5e, 0x4e21, 0x4ce1, 0x4b9e, 0x4a58, 0x490f, 0x47c3, 0x4675, 0x4524, 0x43d0, 0x427a, 0x4121, 0x3fc5, 0x3e68, 0x3d07, 0x3ba5, 0x3a40, 0x38d8, 0x376f, 0x3604, 0x3496, 0x3326, 0x31b5, 0x3041, 0x2ecc, 0x2d55, 0x2bdc, 0x2a61, 0x28e5, 0x2767, 0x25e8, 0x2467, 0x22e5, 0x2161, 0x1fdc, 0x1e56, 0x1ccf, 0x1b47, 0x19bd, 0x1833, 0x16a8, 0x151b, 0x138e, 0x1201, 0x1072, 0xee3, 0xd53, 0xbc3, 0xa33, 0x8a2, 0x710, 0x57f, 0x3ed, 0x25b, 0xc9 }
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
for(i = 0; i< N; i++) { cos_factors[i]= 2 * cos((2*i+1)*c/2); }
N
is the number of factors to generate and c
is pi/(2*N)
Definition at line 764 of file arm_dct4_init_q15.c.
const q15_t cos_factorsQ15_512[512] [static] |
Definition at line 783 of file arm_dct4_init_q15.c.
const q15_t cos_factorsQ15_2048[2048] [static] |
Definition at line 850 of file arm_dct4_init_q15.c.