1 /****************************************************************************** 2 * @file csky_common_tables.h 3 * @brief This file has extern declaration for common tables like 4 * Bitreverse, reciprocal etc which are used across different functions. 5 * @version V1.0 6 * @date 20. Dec 2016 7 ******************************************************************************/ 8 /* --------------------------------------------------------------------------- 9 * Copyright (C) 2016 CSKY Limited. All rights reserved. 10 * 11 * Redistribution and use of this software in source and binary forms, 12 * with or without modification, are permitted provided that the following 13 * conditions are met: 14 * * Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * * Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * * Neither the name of CSKY Ltd. nor the names of CSKY's contributors may 20 * be used to endorse or promote products derived from this software without 21 * specific prior written permission of CSKY Ltd. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 25 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 27 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 28 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 33 * THE POSSIBILITY OF SUCH DAMAGE. 34 * -------------------------------------------------------------------------- */ 35 36 #ifndef _CSKY_COMMON_TABLES_H 37 #define _CSKY_COMMON_TABLES_H 38 39 #include "csky_math.h" 40 41 extern const uint16_t cskyBitRevTable[1024]; 42 extern const q15_t cskyRecipTableQ15[64]; 43 extern const q31_t cskyRecipTableQ31[64]; 44 extern const uint32_t twiddleCoef_16[32]; 45 extern const uint32_t twiddleCoef_32[64]; 46 extern const uint32_t twiddleCoef_64[128]; 47 extern const uint32_t twiddleCoef_128[256]; 48 extern const uint32_t twiddleCoef_256[512]; 49 extern const uint32_t twiddleCoef_512[1024]; 50 extern const uint32_t twiddleCoef_1024[2048]; 51 extern const uint32_t twiddleCoef_2048[4096]; 52 extern const uint32_t twiddleCoef_4096[8192]; 53 extern const q31_t twiddleCoef_16_q31[24]; 54 extern const q31_t twiddleCoef_32_q31[48]; 55 extern const q31_t twiddleCoef_64_q31[96]; 56 extern const q31_t twiddleCoef_128_q31[192]; 57 extern const q31_t twiddleCoef_256_q31[384]; 58 extern const q31_t twiddleCoef_512_q31[768]; 59 extern const q31_t twiddleCoef_1024_q31[1536]; 60 extern const q31_t twiddleCoef_2048_q31[3072]; 61 extern const q31_t twiddleCoef_4096_q31[6144]; 62 extern const q15_t twiddleCoef_16_q15[24]; 63 extern const q15_t twiddleCoef_32_q15[48]; 64 extern const q15_t twiddleCoef_64_q15[96]; 65 extern const q15_t twiddleCoef_128_q15[192]; 66 extern const q15_t twiddleCoef_256_q15[384]; 67 extern const q15_t twiddleCoef_512_q15[768]; 68 extern const q15_t twiddleCoef_1024_q15[1536]; 69 extern const q15_t twiddleCoef_2048_q15[3072]; 70 extern const q15_t twiddleCoef_4096_q15[6144]; 71 extern const float32_t twiddleCoef_rfft_32[32]; 72 extern const float32_t twiddleCoef_rfft_64[64]; 73 extern const float32_t twiddleCoef_rfft_128[128]; 74 extern const float32_t twiddleCoef_rfft_256[256]; 75 extern const float32_t twiddleCoef_rfft_512[512]; 76 extern const float32_t twiddleCoef_rfft_1024[1024]; 77 extern const float32_t twiddleCoef_rfft_2048[2048]; 78 extern const float32_t twiddleCoef_rfft_4096[4096]; 79 extern const float32_t twiddleCoef_rfft_8192[8192]; 80 81 extern const q15_t twiddleCoef_fast_16_q15[24]; 82 extern const q15_t twiddleCoef_fast_32_q15[56]; 83 extern const q15_t twiddleCoef_fast_64_q15[120]; 84 extern const q15_t twiddleCoef_fast_128_q15[248]; 85 extern const q15_t twiddleCoef_fast_256_q15[504]; 86 extern const q15_t twiddleCoef_fast_512_q15[1016]; 87 extern const q15_t twiddleCoef_fast_1024_q15[2040]; 88 extern const q15_t twiddleCoef_fast_2048_q15[4088]; 89 extern const q15_t twiddleCoef_fast_4096_q15[8184]; 90 91 extern const q31_t twiddleCoef_fast_16_q31[24]; 92 extern const q31_t twiddleCoef_fast_32_q31[56]; 93 extern const q31_t twiddleCoef_fast_64_q31[120]; 94 extern const q31_t twiddleCoef_fast_128_q31[248]; 95 extern const q31_t twiddleCoef_fast_256_q31[504]; 96 extern const q31_t twiddleCoef_fast_512_q31[1016]; 97 extern const q31_t twiddleCoef_fast_1024_q31[2040]; 98 extern const q31_t twiddleCoef_fast_2048_q31[4088]; 99 extern const q31_t twiddleCoef_fast_4096_q31[8184]; 100 101 extern const uint32_t twiddleCoef_fast_16[24]; 102 extern const uint32_t twiddleCoef_fast_32[56]; 103 extern const uint32_t twiddleCoef_fast_64[120]; 104 extern const uint32_t twiddleCoef_fast_128[248]; 105 extern const uint32_t twiddleCoef_fast_256[504]; 106 extern const uint32_t twiddleCoef_fast_512[1016]; 107 extern const uint32_t twiddleCoef_fast_1024[2040]; 108 extern const uint32_t twiddleCoef_fast_2048[4088]; 109 extern const uint32_t twiddleCoef_fast_4096[8184]; 110 111 extern const q15_t realCoefAQ15_8192[8192]; 112 extern const q31_t realCoefAQ31_8192[8192]; 113 extern const q15_t realCoefBQ15_8192[8192]; 114 extern const q31_t realCoefBQ31_8192[8192]; 115 116 /*Tables for RFFT.*/ 117 extern const q15_t ALIGN4 realCoefAQ15_32[32]; 118 extern const q15_t ALIGN4 realCoefAQ15_64[64]; 119 extern const q15_t ALIGN4 realCoefAQ15_128[128]; 120 extern const q15_t ALIGN4 realCoefAQ15_256[256]; 121 extern const q15_t ALIGN4 realCoefAQ15_512[512]; 122 extern const q15_t ALIGN4 realCoefAQ15_1024[1024]; 123 extern const q15_t ALIGN4 realCoefAQ15_2048[2048]; 124 extern const q15_t ALIGN4 realCoefAQ15_4096[4096]; 125 126 extern const q15_t ALIGN4 realCoefBQ15_32[32]; 127 extern const q15_t ALIGN4 realCoefBQ15_64[64]; 128 extern const q15_t ALIGN4 realCoefBQ15_128[128]; 129 extern const q15_t ALIGN4 realCoefBQ15_256[256]; 130 extern const q15_t ALIGN4 realCoefBQ15_512[512]; 131 extern const q15_t ALIGN4 realCoefBQ15_1024[1024]; 132 extern const q15_t ALIGN4 realCoefBQ15_2048[2048]; 133 extern const q15_t ALIGN4 realCoefBQ15_4096[4096]; 134 135 extern const q31_t realCoefAQ31_32[32]; 136 extern const q31_t realCoefAQ31_64[64]; 137 extern const q31_t realCoefAQ31_128[128]; 138 extern const q31_t realCoefAQ31_256[256]; 139 extern const q31_t realCoefAQ31_512[512]; 140 extern const q31_t realCoefAQ31_1024[1024]; 141 extern const q31_t realCoefAQ31_2048[2048]; 142 extern const q31_t realCoefAQ31_4096[4096]; 143 144 extern const q31_t realCoefBQ31_32[32]; 145 extern const q31_t realCoefBQ31_64[64]; 146 extern const q31_t realCoefBQ31_128[128]; 147 extern const q31_t realCoefBQ31_256[256]; 148 extern const q31_t realCoefBQ31_512[512]; 149 extern const q31_t realCoefBQ31_1024[1024]; 150 extern const q31_t realCoefBQ31_2048[2048]; 151 extern const q31_t realCoefBQ31_4096[4096]; 152 153 154 extern const float32_t realCoefA[8192]; 155 extern const float32_t realCoefB[8192]; 156 157 158 /*Tables for DCT4*/ 159 extern const q15_t ALIGN4 WeightsQ15_128[128+2]; 160 extern const q15_t ALIGN4 WeightsQ15_512[512+2]; 161 extern const q15_t ALIGN4 WeightsQ15_2048[2048+2]; 162 extern const q15_t ALIGN4 WeightsQ15_8192[8192+2]; 163 164 extern const q15_t ALIGN4 cos_factorsQ15_128[128]; 165 extern const q15_t ALIGN4 cos_factorsQ15_512[512]; 166 extern const q15_t ALIGN4 cos_factorsQ15_2048[2048]; 167 extern const q15_t ALIGN4 cos_factorsQ15_8192[8192]; 168 169 170 extern const q31_t WeightsQ31_128[128+2]; 171 extern const q31_t WeightsQ31_512[512+2]; 172 extern const q31_t WeightsQ31_2048[2048+2]; 173 extern const q31_t WeightsQ31_8192[8192+2]; 174 175 extern const q31_t cos_factorsQ31_128[128]; 176 extern const q31_t cos_factorsQ31_512[512]; 177 extern const q31_t cos_factorsQ31_2048[2048]; 178 extern const q31_t cos_factorsQ31_8192[8192]; 179 180 181 extern const float32_t Weights_128[128+2]; 182 extern const float32_t Weights_512[512+2]; 183 extern const float32_t Weights_2048[2048+2]; 184 extern const float32_t Weights_8192[8192+2]; 185 186 extern const float32_t cos_factors_128[128]; 187 extern const float32_t cos_factors_512[512]; 188 extern const float32_t cos_factors_2048[2048]; 189 extern const float32_t cos_factors_8192[8192]; 190 191 /* floating-point bit reversal tables */ 192 #define CSKYBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) 193 #define CSKYBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) 194 #define CSKYBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) 195 #define CSKYBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) 196 #define CSKYBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) 197 #define CSKYBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) 198 #define CSKYBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) 199 #define CSKYBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) 200 #define CSKYBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) 201 202 extern const uint16_t cskyBitRevIndexTable16[CSKYBITREVINDEXTABLE__16_TABLE_LENGTH]; 203 extern const uint16_t cskyBitRevIndexTable32[CSKYBITREVINDEXTABLE__32_TABLE_LENGTH]; 204 extern const uint16_t cskyBitRevIndexTable64[CSKYBITREVINDEXTABLE__64_TABLE_LENGTH]; 205 extern const uint16_t cskyBitRevIndexTable128[CSKYBITREVINDEXTABLE_128_TABLE_LENGTH]; 206 extern const uint16_t cskyBitRevIndexTable256[CSKYBITREVINDEXTABLE_256_TABLE_LENGTH]; 207 extern const uint16_t cskyBitRevIndexTable512[CSKYBITREVINDEXTABLE_512_TABLE_LENGTH]; 208 extern const uint16_t cskyBitRevIndexTable1024[CSKYBITREVINDEXTABLE1024_TABLE_LENGTH]; 209 extern const uint16_t cskyBitRevIndexTable2048[CSKYBITREVINDEXTABLE2048_TABLE_LENGTH]; 210 extern const uint16_t cskyBitRevIndexTable4096[CSKYBITREVINDEXTABLE4096_TABLE_LENGTH]; 211 212 /* fixed-point bit reversal tables */ 213 #define CSKYBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) 214 #define CSKYBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) 215 #define CSKYBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) 216 #define CSKYBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) 217 #define CSKYBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) 218 #define CSKYBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) 219 #define CSKYBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) 220 #define CSKYBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) 221 #define CSKYBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) 222 223 extern const uint16_t cskyBitRevIndexTable_fixed_16[CSKYBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; 224 extern const uint16_t cskyBitRevIndexTable_fixed_32[CSKYBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; 225 extern const uint16_t cskyBitRevIndexTable_fixed_64[CSKYBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; 226 extern const uint16_t cskyBitRevIndexTable_fixed_128[CSKYBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; 227 extern const uint16_t cskyBitRevIndexTable_fixed_256[CSKYBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; 228 extern const uint16_t cskyBitRevIndexTable_fixed_512[CSKYBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; 229 extern const uint16_t cskyBitRevIndexTable_fixed_1024[CSKYBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; 230 extern const uint16_t cskyBitRevIndexTable_fixed_2048[CSKYBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; 231 extern const uint16_t cskyBitRevIndexTable_fixed_4096[CSKYBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; 232 233 /* Tables for Fast Math Sine and Cosine */ 234 extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; 235 extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; 236 extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; 237 238 #endif /* CSKY_COMMON_TABLES_H */ 239