andrewm@379: /* andrewm@379: * Copyright 2011-15 ARM Limited and Contributors. andrewm@379: * All rights reserved. andrewm@379: * andrewm@379: * Redistribution and use in source and binary forms, with or without andrewm@379: * modification, are permitted provided that the following conditions are met: andrewm@379: * * Redistributions of source code must retain the above copyright andrewm@379: * notice, this list of conditions and the following disclaimer. andrewm@379: * * Redistributions in binary form must reproduce the above copyright andrewm@379: * notice, this list of conditions and the following disclaimer in the andrewm@379: * documentation and/or other materials provided with the distribution. andrewm@379: * * Neither the name of ARM Limited nor the andrewm@379: * names of its contributors may be used to endorse or promote products andrewm@379: * derived from this software without specific prior written permission. andrewm@379: * andrewm@379: * THIS SOFTWARE IS PROVIDED BY ARM LIMITED AND CONTRIBUTORS "AS IS" AND andrewm@379: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED andrewm@379: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE andrewm@379: * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED AND CONTRIBUTORS BE LIABLE FOR ANY andrewm@379: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES andrewm@379: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; andrewm@379: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND andrewm@379: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT andrewm@379: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS andrewm@379: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. andrewm@379: */ andrewm@379: andrewm@379: /* andrewm@379: * NE10 Library : inc/NE10_types.h andrewm@379: */ andrewm@379: andrewm@379: /** NE10 defines a number of types for use in its function signatures. andrewm@379: * The types are defined within this header file. andrewm@379: */ andrewm@379: andrewm@379: #ifndef NE10_TYPES_H andrewm@379: #define NE10_TYPES_H andrewm@379: andrewm@379: #include andrewm@379: #include andrewm@379: #include andrewm@379: #include andrewm@379: #include andrewm@379: #include andrewm@379: andrewm@379: /** andrewm@379: * @TODO Move the definition of NE10_UNROLL_LEVEL to cmake configuration files. andrewm@379: * Macro NE10_UNROLL_LEVEL controls algorithm of FFT funtions. andrewm@379: * When NE10_UNROLL_LEVEL == 0, complex FFT performs radix-4 x2 per loop. andrewm@379: * When NE10_UNROLL_LEVEL == 1, complex FFT performs radix-4 x4 per loop. andrewm@379: */ andrewm@379: #if !defined(NE10_UNROLL_LEVEL) andrewm@379: #if defined(__arm__) andrewm@379: #define NE10_UNROLL_LEVEL 0 andrewm@379: #elif defined(__aarch64__) andrewm@379: #define NE10_UNROLL_LEVEL 1 andrewm@379: #else andrewm@379: #define NE10_UNROLL_LEVEL 0 andrewm@379: #endif andrewm@379: #endif andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // constant values that are used across the library andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: #define NE10_OK 0 andrewm@379: #define NE10_ERR -1 andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // some external definitions to be exposed to the users andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: andrewm@379: typedef signed char ne10_int8_t; andrewm@379: typedef unsigned char ne10_uint8_t; andrewm@379: typedef signed short ne10_int16_t; andrewm@379: typedef unsigned short ne10_uint16_t; andrewm@379: typedef signed int ne10_int32_t; andrewm@379: typedef unsigned int ne10_uint32_t; andrewm@379: typedef signed long long int ne10_int64_t; andrewm@379: typedef unsigned long long int ne10_uint64_t; andrewm@379: typedef float ne10_float32_t; andrewm@379: typedef double ne10_float64_t; andrewm@379: typedef int ne10_result_t; // resulting [error-]code andrewm@379: andrewm@379: /** andrewm@379: * @brief a 2-tuple of ne10_float32_t values. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t x; andrewm@379: ne10_float32_t y; andrewm@379: } ne10_vec2f_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief a 3-tuple of ne10_float32_t values. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t x; andrewm@379: ne10_float32_t y; andrewm@379: ne10_float32_t z; andrewm@379: } ne10_vec3f_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief a 4-tuple of ne10_float32_t values. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t x; andrewm@379: ne10_float32_t y; andrewm@379: ne10_float32_t z; andrewm@379: ne10_float32_t w; andrewm@379: } ne10_vec4f_t; andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // definitions for matrix andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t r1; andrewm@379: ne10_float32_t r2; andrewm@379: } __attribute__ ( (packed)) ne10_mat_row2f; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_mat_row2f c1; andrewm@379: ne10_mat_row2f c2; andrewm@379: andrewm@379: } __attribute__ ( (packed)) ne10_mat2x2f_t; // a 2x2 matrix andrewm@379: andrewm@379: static inline void createColumnMajorMatrix2x2 (ne10_mat2x2f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m12, ne10_float32_t m22) andrewm@379: { andrewm@379: assert (NULL != outMat); andrewm@379: andrewm@379: outMat->c1.r1 = m11; andrewm@379: outMat->c1.r2 = m21; andrewm@379: outMat->c2.r1 = m12; andrewm@379: outMat->c2.r2 = m22; andrewm@379: } andrewm@379: andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t r1; andrewm@379: ne10_float32_t r2; andrewm@379: ne10_float32_t r3; andrewm@379: } __attribute__ ( (packed)) ne10_mat_row3f; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_mat_row3f c1; andrewm@379: ne10_mat_row3f c2; andrewm@379: ne10_mat_row3f c3; andrewm@379: andrewm@379: } __attribute__ ( (packed)) ne10_mat3x3f_t; // a 3x3 matrix andrewm@379: andrewm@379: static inline void createColumnMajorMatrix3x3 (ne10_mat3x3f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31, andrewm@379: ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32, andrewm@379: ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33) andrewm@379: { andrewm@379: assert (NULL != outMat); andrewm@379: andrewm@379: outMat->c1.r1 = m11; andrewm@379: outMat->c1.r2 = m21; andrewm@379: outMat->c1.r3 = m31; andrewm@379: andrewm@379: outMat->c2.r1 = m12; andrewm@379: outMat->c2.r2 = m22; andrewm@379: outMat->c2.r3 = m32; andrewm@379: andrewm@379: outMat->c3.r1 = m13; andrewm@379: outMat->c3.r2 = m23; andrewm@379: outMat->c3.r3 = m33; andrewm@379: } andrewm@379: andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t r1; andrewm@379: ne10_float32_t r2; andrewm@379: ne10_float32_t r3; andrewm@379: ne10_float32_t r4; andrewm@379: } __attribute__ ( (packed)) ne10_mat_row4f; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_mat_row4f c1; andrewm@379: ne10_mat_row4f c2; andrewm@379: ne10_mat_row4f c3; andrewm@379: ne10_mat_row4f c4; andrewm@379: andrewm@379: } __attribute__ ( (packed)) ne10_mat4x4f_t; // a 4x4 matrix andrewm@379: andrewm@379: static inline void createColumnMajorMatrix4x4 (ne10_mat4x4f_t * outMat, ne10_float32_t m11, ne10_float32_t m21, ne10_float32_t m31, ne10_float32_t m41, andrewm@379: ne10_float32_t m12, ne10_float32_t m22, ne10_float32_t m32, ne10_float32_t m42, andrewm@379: ne10_float32_t m13, ne10_float32_t m23, ne10_float32_t m33, ne10_float32_t m43, andrewm@379: ne10_float32_t m14, ne10_float32_t m24, ne10_float32_t m34, ne10_float32_t m44) andrewm@379: { andrewm@379: assert (NULL != outMat); andrewm@379: andrewm@379: outMat->c1.r1 = m11; andrewm@379: outMat->c1.r2 = m21; andrewm@379: outMat->c1.r3 = m31; andrewm@379: outMat->c1.r4 = m41; andrewm@379: andrewm@379: outMat->c2.r1 = m12; andrewm@379: outMat->c2.r2 = m22; andrewm@379: outMat->c2.r3 = m32; andrewm@379: outMat->c2.r4 = m42; andrewm@379: andrewm@379: outMat->c3.r1 = m13; andrewm@379: outMat->c3.r2 = m23; andrewm@379: outMat->c3.r3 = m33; andrewm@379: outMat->c3.r4 = m43; andrewm@379: andrewm@379: outMat->c4.r1 = m14; andrewm@379: outMat->c4.r2 = m24; andrewm@379: outMat->c4.r3 = m34; andrewm@379: outMat->c4.r4 = m44; andrewm@379: } andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // definitions for fft andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: andrewm@379: /** andrewm@379: * @brief structure for the floating point FFT function. andrewm@379: */ andrewm@379: #define NE10_MAXFACTORS 32 andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_float32_t r; andrewm@379: ne10_float32_t i; andrewm@379: } ne10_fft_cpx_float32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief structure for the floating point FFT state andrewm@379: * andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_float32_t *twiddles; andrewm@379: ne10_fft_cpx_float32_t *buffer; andrewm@379: ne10_fft_cpx_float32_t *last_twiddles; andrewm@379: /** andrewm@379: * @biref Flag to control scaling behaviour in forward floating point complex FFT. andrewm@379: * @note If is_forward_scaled is set 0, Ne10 will not scale output of forward floating andrewm@379: * point complex FFT. Otherwise, Ne10 will scale output of forward floating andrewm@379: * point complex FFT. andrewm@379: * @warning andrewm@379: * Only non-power-of-2 FFT is affected by this flag. andrewm@379: */ andrewm@379: ne10_int32_t is_forward_scaled; andrewm@379: /** andrewm@379: * @biref Flag to control scaling behaviour in backward floating point complex FFT. andrewm@379: * @note If is_backward_scaled is set 0, Ne10 will not scale output of backward floating andrewm@379: * point complex FFT. Otherwise, Ne10 will scale output of backward floating andrewm@379: * point complex FFT. andrewm@379: * @warning andrewm@379: * Only non-power-of-2 FFT is affected by this flag. andrewm@379: */ andrewm@379: ne10_int32_t is_backward_scaled; andrewm@379: } ne10_fft_state_float32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Configure for floating point FFT. andrewm@379: */ andrewm@379: typedef ne10_fft_state_float32_t* ne10_fft_cfg_float32_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_fft_cpx_float32_t *buffer; andrewm@379: #if (NE10_UNROLL_LEVEL == 0) andrewm@379: ne10_int32_t ncfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_float32_t *twiddles; andrewm@379: ne10_fft_cpx_float32_t *super_twiddles; andrewm@379: #elif (NE10_UNROLL_LEVEL > 0) andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_fft_cpx_float32_t *r_twiddles; andrewm@379: ne10_int32_t *r_factors; andrewm@379: ne10_fft_cpx_float32_t *r_twiddles_backward; andrewm@379: ne10_fft_cpx_float32_t *r_twiddles_neon; andrewm@379: ne10_fft_cpx_float32_t *r_twiddles_neon_backward; andrewm@379: ne10_int32_t *r_factors_neon; andrewm@379: ne10_fft_cpx_float32_t *r_super_twiddles_neon; andrewm@379: #endif andrewm@379: } ne10_fft_r2c_state_float32_t; andrewm@379: andrewm@379: typedef ne10_fft_r2c_state_float32_t* ne10_fft_r2c_cfg_float32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief structure for the 16 bits fixed point FFT function. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int16_t r; andrewm@379: ne10_int16_t i; andrewm@379: } ne10_fft_cpx_int16_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_int16_t *twiddles; andrewm@379: ne10_fft_cpx_int16_t *buffer; andrewm@379: } ne10_fft_state_int16_t; andrewm@379: andrewm@379: typedef ne10_fft_state_int16_t* ne10_fft_cfg_int16_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_int32_t ncfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_int16_t *twiddles; andrewm@379: ne10_fft_cpx_int16_t *super_twiddles; andrewm@379: ne10_fft_cpx_int16_t *buffer; andrewm@379: } ne10_fft_r2c_state_int16_t; andrewm@379: andrewm@379: typedef ne10_fft_r2c_state_int16_t* ne10_fft_r2c_cfg_int16_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief structure for the 32 bits fixed point FFT function. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t r; andrewm@379: ne10_int32_t i; andrewm@379: } ne10_fft_cpx_int32_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_int32_t *twiddles; andrewm@379: ne10_fft_cpx_int32_t *buffer; andrewm@379: ne10_fft_cpx_int32_t *last_twiddles; andrewm@379: } ne10_fft_state_int32_t; andrewm@379: andrewm@379: typedef ne10_fft_state_int32_t* ne10_fft_cfg_int32_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_int32_t nfft; andrewm@379: ne10_int32_t ncfft; andrewm@379: ne10_int32_t *factors; andrewm@379: ne10_fft_cpx_int32_t *twiddles; andrewm@379: ne10_fft_cpx_int32_t *super_twiddles; andrewm@379: ne10_fft_cpx_int32_t *buffer; andrewm@379: } ne10_fft_r2c_state_int32_t; andrewm@379: andrewm@379: typedef ne10_fft_r2c_state_int32_t* ne10_fft_r2c_cfg_int32_t; andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // definitions for fir andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating-point FIR filter. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint16_t numTaps; /**< Length of the filter. */ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ andrewm@379: ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps. */ andrewm@379: } ne10_fir_instance_f32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating point FIR Lattice filter. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint16_t numStages; /**< numStages of the of lattice filter. */ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numStages. */ andrewm@379: ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numStages. */ andrewm@379: } ne10_fir_lattice_instance_f32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating-point FIR Decimation. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint8_t M; /**< Decimation Factor. */ andrewm@379: ne10_uint16_t numTaps; /**< Length of the filter. */ andrewm@379: ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ andrewm@379: } ne10_fir_decimate_instance_f32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating-point FIR Interpolation. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint8_t L; /**< Interpolation Factor. */ andrewm@379: ne10_uint16_t phaseLength; /**< Length of each polyphase filter component. */ andrewm@379: ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ andrewm@379: } ne10_fir_interpolate_instance_f32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating-point FIR Sparse filter. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint16_t numTaps; /**< Length of the filter. */ andrewm@379: ne10_uint16_t stateIndex; /**< Index pointer for the state buffer .*/ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numTaps+maxBlockSize-1. */ andrewm@379: ne10_float32_t *pCoeffs; /**< Points to the coefficient array. The array is of length numTaps.*/ andrewm@379: ne10_uint16_t maxDelay; /**< the largest number of delay line values .*/ andrewm@379: ne10_int32_t *pTapDelay; /**< Pointer to the array containing positions of the non-zero tap values. */ andrewm@379: } ne10_fir_sparse_instance_f32_t; andrewm@379: andrewm@379: /** andrewm@379: * @brief Instance structure for the floating point IIR Lattice filter. andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint16_t numStages; /**< numStages of the of lattice filter. */ andrewm@379: ne10_float32_t *pState; /**< Points to the state variable array. The array is of length numStages + blockSize -1. */ andrewm@379: ne10_float32_t *pkCoeffs; /**< Points to the reflection coefficient array. The array is of length numStages. */ andrewm@379: ne10_float32_t *pvCoeffs; /**< Points to the ladder coefficient array. The array is of length numStages+1. */ andrewm@379: } ne10_iir_lattice_instance_f32_t; andrewm@379: andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: // definitions for imgproc module andrewm@379: ///////////////////////////////////////////////////////// andrewm@379: andrewm@379: /** andrewm@379: * @brief Structure for point in image andrewm@379: */ andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint32_t x; andrewm@379: ne10_uint32_t y; andrewm@379: } ne10_point_t; andrewm@379: andrewm@379: typedef struct andrewm@379: { andrewm@379: ne10_uint32_t x; andrewm@379: ne10_uint32_t y; andrewm@379: } ne10_size_t; andrewm@379: andrewm@379: typedef enum andrewm@379: { andrewm@379: UBUNTU_COMMAND_LINE, andrewm@379: ANDROID_DEMO, andrewm@379: IOS_DEMO andrewm@379: } ne10_print_target_t; andrewm@379: andrewm@379: #endif