LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
DCT Type II Functions
Collaboration diagram for DCT Type II Functions:

Functions

tpt_status tpt_dct2_f32 (f32_t *aOutData, f32_t *aInData, f32_t *aScratch, size_t aLogN, bool aIdctFlag)
 Processing function for the floating-point DCT2. More...
 
tpt_status tpt_dct2_f64 (f64_t *aOutData, f64_t *aInData, f64_t *aScratch, size_t aLogN, bool aIdctFlag)
 Processing function for the floating-point DCT2. More...
 
tpt_status tpt_dct2_q15 (q15_t *aOutData, q15_t *aInData, q15_t *aScratch, size_t aLogN, bool aIdctFlag)
 Processing function for the Q15 DCT2. More...
 
tpt_status tpt_dct2_q31 (q31_t *aOutData, q31_t *aInData, q31_t *aScratch, size_t aLogN, bool aIdctFlag)
 Processing function for the Q31 DCT2. More...
 

Detailed Description

A discrete cosine transform (DCT) expresses a finite sequence of data points in terms of a sum of cosine functions oscillating at different frequencies. In particular, a DCT is a Fourier-related transform similar to the discrete Fourier transform (DFT), but using only real numbers.

Algorithm
This function implements DCT Type II Function:
           N-1
    y[k] = sum { x[n] * cos(PI * (2 * n + 1) * k / (2 * N)) }
           n=0
  
The N-point DCT2 internally uses N-point RFFT implementation. It supports lengths of [32, 64, 128, ..., 1024] and the corresponding aLogN value is [5, 6, 7, ..., 10].
Normalizing factor
The normalizing factor is 1.0. If necessary, the caller should calculate the normalizing factor separately.

Function Documentation

◆ tpt_dct2_f32()

tpt_status tpt_dct2_f32 ( f32_t aOutData,
f32_t aInData,
f32_t aScratch,
size_t  aLogN,
bool  aIdctFlag 
)

Processing function for the floating-point DCT2.

Source buffer is modified by this function.

Parameters
[out]aOutDatapoints to output buffer.
[in]aInDatapoints to input buffer (Source buffer is modified by this function.)
[in]aScratchpoints to a temporary buffer of size 2^(aLogN+1).
[in]aLogNThe length is 2^aLogN.
Returns
execution status

◆ tpt_dct2_f64()

tpt_status tpt_dct2_f64 ( f64_t aOutData,
f64_t aInData,
f64_t aScratch,
size_t  aLogN,
bool  aIdctFlag 
)

Processing function for the floating-point DCT2.

Source buffer is modified by this function.

Parameters
[out]aOutDatapoints to output buffer.
[in]aInDatapoints to input buffer (Source buffer is modified by this function.)
[in]aScratchpoints to a temporary buffer of size 2^(aLogN+1).
[in]aLogNThe length is 2^aLogN.
Returns
execution status

◆ tpt_dct2_q15()

tpt_status tpt_dct2_q15 ( q15_t aOutData,
q15_t aInData,
q15_t aScratch,
size_t  aLogN,
bool  aIdctFlag 
)

Processing function for the Q15 DCT2.

Source buffer is modified by this function.

Parameters
[out]aOutDatapoints to output buffer.
[in]aInDatapoints to input buffer (Source buffer is modified by this function.)
[in]aScratchpoints to a temporary buffer of size 2^(aLogN+1).
[in]aLogNThe length is 2^aLogN.
Returns
execution status
Input an output formats
Internally inputs are downscaled in the RFFT process function to avoid overflows. Number of bits downscaled, depends on the size of the transform. The input and output formats for different DCT sizes and number of bits to upscale are mentioned in the table below:
Input and Output Formats for Q15 DCT2
aLogNDCT2 SizeInput formatOutput formatNumber of bits to upscale
5 32 1.15 6.10 5
6 64 1.15 7.9 6
7 128 1.15 8.8 7
8 256 1.15 9.7 8
9 512 1.15 10.6 9
10 1024 1.15 11.5 10
......

◆ tpt_dct2_q31()

tpt_status tpt_dct2_q31 ( q31_t aOutData,
q31_t aInData,
q31_t aScratch,
size_t  aLogN,
bool  aIdctFlag 
)

Processing function for the Q31 DCT2.

Source buffer is modified by this function.

Parameters
[out]aOutDatapoints to output buffer.
[in]aInDatapoints to input buffer (Source buffer is modified by this function.)
[in]aScratchpoints to a temporary buffer of size 2^(aLogN+1).
[in]aLogNThe length is 2^aLogN.
Returns
execution status
Input an output formats
Internally inputs are downscaled in the RFFT process function to avoid overflows. Number of bits downscaled, depends on the size of the transform. The input and output formats for different DCT sizes and number of bits to upscale are mentioned in the table below:
Input and Output Formats for Q31 DCT2
aLogNDCT2 SizeInput formatOutput formatNumber of bits to upscale
5 32 1.31 6.26 5
6 64 1.31 7.25 6
7 128 1.31 8.24 7
8 256 1.31 9.23 8
9 512 1.31 10.22 9
10 1024 1.31 11.21 10
......