1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_dct4_init_f32.c
4  * Description:  Initialization function of DCT-4 & IDCT4 F32
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the License); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 
29 #include "dsp/transform_functions.h"
30 #include "arm_common_tables.h"
31 
32 /**
33  * @defgroup DCT4F32 DCT4 F32
34  */
35 
36 /**
37   @ingroup DCT4_IDCT4
38  */
39 
40  /**
41   @addtogroup DCT4F32
42   @{
43  */
44 
45 /**
46   @brief         Initialization function for the floating-point DCT4/IDCT4.
47   @deprecated    Do not use this function. It is using a deprecated version of the RFFT.
48   @param[in,out] S          points to an instance of floating-point DCT4/IDCT4 structure
49   @param[in]     S_RFFT     points to an instance of floating-point RFFT/RIFFT structure
50   @param[in]     S_CFFT     points to an instance of floating-point CFFT/CIFFT structure
51   @param[in]     N			length of the DCT4
52   @param[in]     Nby2       half of the length of the DCT4
53   @param[in]     normalize  normalizing factor.
54   @return        execution status
55                    - \ref ARM_MATH_SUCCESS        : Operation successful
56                    - \ref ARM_MATH_ARGUMENT_ERROR : <code>N</code> is not a supported transform length
57 
58   @par           Normalizing factor
59                    The normalizing factor is <code>sqrt(2/N)</code>, which depends on the size of transform <code>N</code>.
60                    Floating-point normalizing factors are mentioned in the table below for different DCT sizes:
61 
62 
63 | DCT Size  | Normalizing factor value  |
64 | --------: | ------------------------: |
65 | 2048      | 0.03125                   |
66 | 512       | 0.0625                    |
67 | 128       | 0.125                     |
68 
69  */
70 
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)71 arm_status arm_dct4_init_f32(
72   arm_dct4_instance_f32 * S,
73   arm_rfft_instance_f32 * S_RFFT,
74   arm_cfft_radix4_instance_f32 * S_CFFT,
75   uint16_t N,
76   uint16_t Nby2,
77   float32_t normalize)
78 {
79   /* Initialize the default arm status */
80   arm_status status = ARM_MATH_SUCCESS;
81 
82 
83   /* Initialize the DCT4 length */
84   S->N = N;
85 
86   /* Initialize the half of DCT4 length */
87   S->Nby2 = Nby2;
88 
89   /* Initialize the DCT4 Normalizing factor */
90   S->normalize = normalize;
91 
92   /* Initialize Real FFT Instance */
93   S->pRfft = S_RFFT;
94 
95   /* Initialize Complex FFT Instance */
96   S->pCfft = S_CFFT;
97 
98   switch (N)
99   {
100     /* Initialize the table modifier values */
101   case 8192U:
102     S->pTwiddle = Weights_8192;
103     S->pCosFactor = cos_factors_8192;
104     break;
105 
106   case 2048U:
107     S->pTwiddle = Weights_2048;
108     S->pCosFactor = cos_factors_2048;
109     break;
110 
111   case 512U:
112     S->pTwiddle = Weights_512;
113     S->pCosFactor = cos_factors_512;
114     break;
115 
116   case 128U:
117     S->pTwiddle = Weights_128;
118     S->pCosFactor = cos_factors_128;
119     break;
120   default:
121     status = ARM_MATH_ARGUMENT_ERROR;
122   }
123 
124   /* Initialize the RFFT/RIFFT Function */
125   arm_rfft_init_f32(S->pRfft, S->pCfft, S->N, 0U, 1U);
126 
127   /* return the status of DCT4 Init function */
128   return (status);
129 }
130 
131 /**
132   @} end of DCT4F32 group
133  */
134