/ Drivers / CMSIS / DSP / Include / dsp / filtering_functions_f16.h
filtering_functions_f16.h
  1  /******************************************************************************
  2   * @file     filtering_functions_f16.h
  3   * @brief    Public header file for CMSIS DSP Library
  4   * @version  V1.10.0
  5   * @date     08 July 2021
  6   * Target Processor: Cortex-M and Cortex-A cores
  7   ******************************************************************************/
  8  /*
  9   * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
 10   *
 11   * SPDX-License-Identifier: Apache-2.0
 12   *
 13   * Licensed under the Apache License, Version 2.0 (the License); you may
 14   * not use this file except in compliance with the License.
 15   * You may obtain a copy of the License at
 16   *
 17   * www.apache.org/licenses/LICENSE-2.0
 18   *
 19   * Unless required by applicable law or agreed to in writing, software
 20   * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 21   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 22   * See the License for the specific language governing permissions and
 23   * limitations under the License.
 24   */
 25  
 26   
 27  #ifndef _FILTERING_FUNCTIONS_F16_H_
 28  #define _FILTERING_FUNCTIONS_F16_H_
 29  
 30  #include "arm_math_types_f16.h"
 31  #include "arm_math_memory.h"
 32  
 33  #include "dsp/none.h"
 34  #include "dsp/utils.h"
 35  
 36  
 37  #ifdef   __cplusplus
 38  extern "C"
 39  {
 40  #endif
 41  
 42  #if defined(ARM_FLOAT16_SUPPORTED)
 43  
 44   /**
 45     * @brief Instance structure for the floating-point FIR filter.
 46     */
 47    typedef struct
 48    {
 49            uint16_t numTaps;     /**< number of filter coefficients in the filter. */
 50            float16_t *pState;    /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
 51      const float16_t *pCoeffs;   /**< points to the coefficient array. The array is of length numTaps. */
 52    } arm_fir_instance_f16;
 53  
 54    /**
 55     * @brief  Initialization function for the floating-point FIR filter.
 56     * @param[in,out] S          points to an instance of the floating-point FIR filter structure.
 57     * @param[in]     numTaps    Number of filter coefficients in the filter.
 58     * @param[in]     pCoeffs    points to the filter coefficients.
 59     * @param[in]     pState     points to the state buffer.
 60     * @param[in]     blockSize  number of samples that are processed at a time.
 61     */
 62    void arm_fir_init_f16(
 63          arm_fir_instance_f16 * S,
 64          uint16_t numTaps,
 65    const float16_t * pCoeffs,
 66          float16_t * pState,
 67          uint32_t blockSize);
 68  
 69    /**
 70     * @brief Processing function for the floating-point FIR filter.
 71     * @param[in]  S          points to an instance of the floating-point FIR structure.
 72     * @param[in]  pSrc       points to the block of input data.
 73     * @param[out] pDst       points to the block of output data.
 74     * @param[in]  blockSize  number of samples to process.
 75     */
 76    void arm_fir_f16(
 77    const arm_fir_instance_f16 * S,
 78    const float16_t * pSrc,
 79          float16_t * pDst,
 80          uint32_t blockSize);
 81  
 82  
 83    /**
 84     * @brief Instance structure for the floating-point Biquad cascade filter.
 85     */
 86    typedef struct
 87    {
 88            uint32_t numStages;      /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */
 89            float16_t *pState;       /**< Points to the array of state coefficients.  The array is of length 4*numStages. */
 90      const float16_t *pCoeffs;      /**< Points to the array of coefficients.  The array is of length 5*numStages. */
 91    } arm_biquad_casd_df1_inst_f16;
 92  
 93  #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
 94    /**
 95     * @brief Instance structure for the modified Biquad coefs required by vectorized code.
 96     */
 97    typedef struct
 98    {
 99        float16_t coeffs[12][8]; /**< Points to the array of modified coefficients.  The array is of length 32. There is one per stage */
100    } arm_biquad_mod_coef_f16;
101  #endif 
102  
103    /**
104     * @brief Processing function for the floating-point Biquad cascade filter.
105     * @param[in]  S          points to an instance of the floating-point Biquad cascade structure.
106     * @param[in]  pSrc       points to the block of input data.
107     * @param[out] pDst       points to the block of output data.
108     * @param[in]  blockSize  number of samples to process.
109     */
110    void arm_biquad_cascade_df1_f16(
111    const arm_biquad_casd_df1_inst_f16 * S,
112    const float16_t * pSrc,
113          float16_t * pDst,
114          uint32_t blockSize);
115  
116  #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
117    void arm_biquad_cascade_df1_mve_init_f16(
118        arm_biquad_casd_df1_inst_f16 * S,
119        uint8_t numStages,
120        const float16_t * pCoeffs, 
121        arm_biquad_mod_coef_f16 * pCoeffsMod, 
122        float16_t * pState);
123  #endif
124  
125    void arm_biquad_cascade_df1_init_f16(
126          arm_biquad_casd_df1_inst_f16 * S,
127          uint8_t numStages,
128    const float16_t * pCoeffs,
129          float16_t * pState);
130  
131    /**
132     * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
133     */
134    typedef struct
135    {
136            uint8_t numStages;         /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */
137            float16_t *pState;         /**< points to the array of state coefficients.  The array is of length 2*numStages. */
138      const float16_t *pCoeffs;        /**< points to the array of coefficients.  The array is of length 5*numStages. */
139    } arm_biquad_cascade_df2T_instance_f16;
140  
141    /**
142     * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
143     */
144    typedef struct
145    {
146            uint8_t numStages;         /**< number of 2nd order stages in the filter.  Overall order is 2*numStages. */
147            float16_t *pState;         /**< points to the array of state coefficients.  The array is of length 4*numStages. */
148      const float16_t *pCoeffs;        /**< points to the array of coefficients.  The array is of length 5*numStages. */
149    } arm_biquad_cascade_stereo_df2T_instance_f16;
150  
151    /**
152     * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
153     * @param[in]  S          points to an instance of the filter data structure.
154     * @param[in]  pSrc       points to the block of input data.
155     * @param[out] pDst       points to the block of output data
156     * @param[in]  blockSize  number of samples to process.
157     */
158    void arm_biquad_cascade_df2T_f16(
159    const arm_biquad_cascade_df2T_instance_f16 * S,
160    const float16_t * pSrc,
161          float16_t * pDst,
162          uint32_t blockSize);
163  
164    /**
165     * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
166     * @param[in]  S          points to an instance of the filter data structure.
167     * @param[in]  pSrc       points to the block of input data.
168     * @param[out] pDst       points to the block of output data
169     * @param[in]  blockSize  number of samples to process.
170     */
171    void arm_biquad_cascade_stereo_df2T_f16(
172    const arm_biquad_cascade_stereo_df2T_instance_f16 * S,
173    const float16_t * pSrc,
174          float16_t * pDst,
175          uint32_t blockSize);
176  
177    /**
178     * @brief  Initialization function for the floating-point transposed direct form II Biquad cascade filter.
179     * @param[in,out] S          points to an instance of the filter data structure.
180     * @param[in]     numStages  number of 2nd order stages in the filter.
181     * @param[in]     pCoeffs    points to the filter coefficients.
182     * @param[in]     pState     points to the state buffer.
183     */
184    void arm_biquad_cascade_df2T_init_f16(
185          arm_biquad_cascade_df2T_instance_f16 * S,
186          uint8_t numStages,
187    const float16_t * pCoeffs,
188          float16_t * pState);
189  
190    /**
191     * @brief  Initialization function for the floating-point transposed direct form II Biquad cascade filter.
192     * @param[in,out] S          points to an instance of the filter data structure.
193     * @param[in]     numStages  number of 2nd order stages in the filter.
194     * @param[in]     pCoeffs    points to the filter coefficients.
195     * @param[in]     pState     points to the state buffer.
196     */
197    void arm_biquad_cascade_stereo_df2T_init_f16(
198          arm_biquad_cascade_stereo_df2T_instance_f16 * S,
199          uint8_t numStages,
200    const float16_t * pCoeffs,
201          float16_t * pState);
202  
203    /**
204     * @brief Correlation of floating-point sequences.
205     * @param[in]  pSrcA    points to the first input sequence.
206     * @param[in]  srcALen  length of the first input sequence.
207     * @param[in]  pSrcB    points to the second input sequence.
208     * @param[in]  srcBLen  length of the second input sequence.
209     * @param[out] pDst     points to the block of output data  Length 2 * max(srcALen, srcBLen) - 1.
210     */
211    void arm_correlate_f16(
212    const float16_t * pSrcA,
213          uint32_t srcALen,
214    const float16_t * pSrcB,
215          uint32_t srcBLen,
216          float16_t * pDst);
217  
218  
219  /**
220    @brief         Levinson Durbin
221    @param[in]     phi      autocovariance vector starting with lag 0 (length is nbCoefs + 1)
222    @param[out]    a        autoregressive coefficients
223    @param[out]    err      prediction error (variance)
224    @param[in]     nbCoefs  number of autoregressive coefficients
225    @return        none
226   */
227  void arm_levinson_durbin_f16(const float16_t *phi,
228    float16_t *a, 
229    float16_t *err,
230    int nbCoefs);
231  
232  #endif /*defined(ARM_FLOAT16_SUPPORTED)*/
233  #ifdef   __cplusplus
234  }
235  #endif
236  
237  #endif /* ifndef _FILTERING_FUNCTIONS_F16_H_ */