Functions | Variables

DCT Type IV Functions
[Transform Functions]

Functions

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)
void arm_dct4_f32 (const arm_dct4_instance_f32 *S, float32_t *pState, float32_t *pInlineBuffer)
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)
void arm_dct4_q31 (const arm_dct4_instance_q31 *S, q31_t *pState, q31_t *pInlineBuffer)
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)
void arm_dct4_q15 (const arm_dct4_instance_q15 *S, q15_t *pState, q15_t *pInlineBuffer)

Variables

static const float32_t Weights_128 [256]
static const float32_t Weights_512 [1024]
static const float32_t Weights_2048 [4096]
static const float32_t cos_factors_128 [128]
static const float32_t cos_factors_512 [512]
static const float32_t cos_factors_2048 [2048]
static const q31_t WeightsQ31_128 [256]
static const q31_t WeightsQ31_512 [1024]
static const q31_t WeightsQ31_2048 [4096]
static const q31_t cos_factorsQ31_128 [128]
static const q31_t cos_factorsQ31_512 [512]
static const q31_t cos_factorsQ31_2048 [2048]
static const q15_t WeightsQ15_128 [256]
static const q15_t WeightsQ15_512 [1024]
static const q15_t WeightsQ15_2048 [4096]
static const q15_t cos_factorsQ15_128 [128]
static const q15_t cos_factorsQ15_512 [512]
static const q15_t cos_factorsQ15_2048 [2048]

Detailed Description

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:

DCT4.gif

Discrete Cosine Transform - type-IV

Algorithm:
The N-point type-IV DCT is defined as a real, linear transformation by the formula:
DCT4Equation.gif
where k = 0,1,2,.....N-1
Its inverse is defined as follows:
IDCT4Equation.gif
where n = 0,1,2,.....N-1
The DCT4 matrices become involutory (i.e. they are self-inverse) by multiplying with an overall scale factor of sqrt(2/N). The symmetry of the transform matrix indicates that the fast algorithms for the forward and inverse transform computation are identical. Note that the implementation of Inverse DCT4 and DCT4 is same, hence same process function can be used for both.
Lengths supported by the transform:
As DCT4 internally uses Real FFT, it supports all the lengths supported by arm_rfft_f32(). The library provides separate functions for Q15, Q31, and floating-point data types.
Instance Structure
The instances for Real FFT and FFT, cosine values table and twiddle factor table are stored in an instance data structure. A separate instance structure must be defined for each transform. There are separate instance structure declarations for each of the 3 supported data types.
Initialization Functions
There is also an associated initialization function for each data type. The initialization function performs the following operations:
  • Sets the values of the internal structure fields.
  • Initializes Real FFT as its process function is used internally in DCT4, by calling arm_rfft_init_f32().
Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Manually initialize the instance structure as follows:
      
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.
Fixed-Point Behavior
Care must be taken when using the fixed-point versions of the DCT4 transform functions. In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. Refer to the function specific documentation below for usage guidelines.

Function Documentation

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.

Parameters:
[in,out]*Spoints to an instance of floating-point DCT4/IDCT4 structure.
[in]*S_RFFTpoints to an instance of floating-point RFFT/RIFFT structure.
[in]*S_CFFTpoints to an instance of floating-point CFFT/CIFFT structure.
[in]Nlength of the DCT4.
[in]Nby2half of the length of the DCT4.
[in]normalizenormalizing factor.
Returns:
arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if fftLenReal is not a supported transform length.
Normalizing factor:
The normalizing factor is 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:
dct4NormalizingF32Table.gif

Definition at line 4136 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.

Parameters:
[in]*Spoints to an instance of the floating-point DCT4/IDCT4 structure.
[in]*pStatepoints to state buffer.
[in,out]*pInlineBufferpoints to the in-place input and output buffer.
Returns:
none.

Definition at line 120 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.

Parameters:
[in,out]*Spoints to an instance of Q31 DCT4/IDCT4 structure.
[in]*S_RFFTpoints to an instance of Q31 RFFT/RIFFT structure
[in]*S_CFFTpoints to an instance of Q31 CFFT/CIFFT structure
[in]Nlength of the DCT4.
[in]Nby2half of the length of the DCT4.
[in]normalizenormalizing factor.
Returns:
arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if N is not a supported transform length.
Normalizing factor:
The normalizing factor is 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:
dct4NormalizingQ31Table.gif

Definition at line 2127 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.

Parameters:
[in]*Spoints to an instance of the Q31 DCT4 structure.
[in]*pStatepoints to state buffer.
[in,out]*pInlineBufferpoints to the in-place input and output buffer.
Returns:
none.
Input an output formats:
Input samples need to be downscaled by 1 bit to avoid saturations in the Q31 DCT process, as the conversion from DCT2 to DCT4 involves one subtraction. 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:
dct4FormatsQ31Table.gif

Definition at line 47 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.

Parameters:
[in,out]*Spoints to an instance of Q15 DCT4/IDCT4 structure.
[in]*S_RFFTpoints to an instance of Q15 RFFT/RIFFT structure.
[in]*S_CFFTpoints to an instance of Q15 CFFT/CIFFT structure.
[in]Nlength of the DCT4.
[in]Nby2half of the length of the DCT4.
[in]normalizenormalizing factor.
Returns:
arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if N is not a supported transform length.
Normalizing factor:
The normalizing factor is 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:
dct4NormalizingQ15Table.gif

Definition at line 1119 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.

Parameters:
[in]*Spoints to an instance of the Q15 DCT4 structure.
[in]*pStatepoints to state buffer.
[in,out]*pInlineBufferpoints to the in-place input and output buffer.
Returns:
none.
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:
dct4FormatsQ15Table.gif

Definition at line 46 of file arm_dct4_q15.c.


Variable Documentation

const float32_t Weights_128[256] [static]
Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
C command to generate the table
      
 for(i = 0; i< N; i++)      
 {      
    weights[2*i]= cos(i*c);      
    weights[(2*i)+1]= -sin(i * c);      
 } 
Where N is the Number of weights to be calculated and c is pi/(2*N)
In the tables below the real and imaginary values are placed alternatively, hence the array length is 2*N.

Definition at line 58 of file arm_dct4_init_f32.c.

const float32_t Weights_512[1024] [static]

Definition at line 189 of file arm_dct4_init_f32.c.

const float32_t Weights_2048[4096] [static]

Definition at line 704 of file arm_dct4_init_f32.c.

const float32_t cos_factors_128[128] [static]
cosFactor tables are generated using the formula :
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
C command to generate the table
 for(i = 0; i< N; i++)      
 {      
    cos_factors[i]= 2 * cos((2*i+1)*c/2);      
 } 
where N is the number of factors to generate and c is pi/(2*N)

Definition at line 2768 of file arm_dct4_init_f32.c.

const float32_t cos_factors_512[512] [static]

Definition at line 2835 of file arm_dct4_init_f32.c.

const float32_t cos_factors_2048[2048] [static]

Definition at line 3094 of file arm_dct4_init_f32.c.

const q31_t WeightsQ31_128[256] [static]
Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
C command to generate the table
      
 for(i = 0; i< N; i++)      
 {      
   weights[2*i]= cos(i*c);      
   weights[(2*i)+1]= -sin(i * c);      
 } 
where N is the Number of weights to be calculated and c is pi/(2*N)
Convert the output to q31 format by multiplying with 2^31 and saturated if required.
In the tables below the real and imaginary values are placed alternatively, hence the array length is 2*N.

Definition at line 60 of file arm_dct4_init_q31.c.

const q31_t WeightsQ31_512[1024] [static]

Definition at line 127 of file arm_dct4_init_q31.c.

const q31_t WeightsQ31_2048[4096] [static]

Definition at line 386 of file arm_dct4_init_q31.c.

const q31_t cos_factorsQ31_128[128] [static]
cosFactor tables are generated using the formula :
cos_factors[n] = 2 * cos((2n+1)*pi/(4*N))
C command to generate the table
      
 for(i = 0; i< N; i++)      
 {      
   cos_factors[i]= 2 * cos((2*i+1)*c/2);      
 } 
where N is the number of factors to generate and c is pi/(2*N)
Then converted to q31 format by multiplying with 2^31 and saturated if required.

Definition at line 1430 of file arm_dct4_init_q31.c.

const q31_t cos_factorsQ31_512[512] [static]

Definition at line 1465 of file arm_dct4_init_q31.c.

const q31_t cos_factorsQ31_2048[2048] [static]

Definition at line 1596 of file arm_dct4_init_q31.c.

const q15_t WeightsQ15_128[256] [static]
Weights tables are generated using the formula :
weights[n] = e^(-j*n*pi/(2*N))
C command to generate the table
      
 for(i = 0; i< N; i++)      
 {      
   weights[2*i]= cos(i*c);      
   weights[(2*i)+1]= -sin(i * c);      
 } 
where N is the Number of weights to be calculated and c is pi/(2*N)
Converted the output to q15 format by multiplying with 2^31 and saturated if required.
In the tables below the real and imaginary values are placed alternatively, hence the array length is 2*N.

Definition at line 60 of file arm_dct4_init_q15.c.

const q15_t WeightsQ15_512[1024] [static]

Definition at line 95 of file arm_dct4_init_q15.c.

const q15_t WeightsQ15_2048[4096] [static]

Definition at line 226 of file arm_dct4_init_q15.c.

const q15_t cos_factorsQ15_128[128] [static]
Initial value:
 {     
  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     
}
cosFactor tables are generated using the formula :
 cos_factors[n] = 2 * cos((2n+1)*pi/(4*N)) 
C command to generate the table
      
 for(i = 0; i< N; i++)      
 {      
   cos_factors[i]= 2 * cos((2*i+1)*c/2);      
 } 
where N is the number of factors to generate and c is pi/(2*N)
Then converted to q15 format by multiplying with 2^31 and saturated if required.

Definition at line 758 of file arm_dct4_init_q15.c.

const q15_t cos_factorsQ15_512[512] [static]

Definition at line 777 of file arm_dct4_init_q15.c.

const q15_t cos_factorsQ15_2048[2048] [static]

Definition at line 844 of file arm_dct4_init_q15.c.

 All Data Structures Files Functions Variables Enumerations Enumerator Defines