diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-01-04 02:01:18 -0600 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-04-23 14:23:04 +0000 |
commit | 14c6bb798d6bebc80f07e863236adbaf8d156a9c (patch) | |
tree | 551a4b641906c2626af844fa3239c1b2b1ff0ad3 /lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c | |
parent | 75d93937965ec4df70d37df6d4feea04577c996b (diff) | |
download | rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.tar.gz rockbox-14c6bb798d6bebc80f07e863236adbaf8d156a9c.zip |
Sync opus codec to upstream git
Change-Id: I0cfcc0005c4ad7bfbb1aaf454188ce70fb043dc1
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c')
-rw-r--r-- | lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c b/lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c new file mode 100644 index 0000000000..828e7b9fff --- /dev/null +++ b/lib/rbcodec/codecs/libopus/celt/dump_modes/dump_modes_arm_ne10.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /* Copyright (c) 2015 Xiph.Org Foundation | ||
2 | Written by Viswanath Puttagunta */ | ||
3 | /* | ||
4 | Redistribution and use in source and binary forms, with or without | ||
5 | modification, are permitted provided that the following conditions | ||
6 | are met: | ||
7 | |||
8 | - Redistributions of source code must retain the above copyright | ||
9 | notice, this list of conditions and the following disclaimer. | ||
10 | |||
11 | - Redistributions in binary form must reproduce the above copyright | ||
12 | notice, this list of conditions and the following disclaimer in the | ||
13 | documentation and/or other materials provided with the distribution. | ||
14 | |||
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER | ||
19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | #if defined(HAVE_CONFIG_H) | ||
29 | # include "config.h" | ||
30 | #endif | ||
31 | |||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | #include "modes.h" | ||
35 | #include "dump_modes_arch.h" | ||
36 | #include <NE10_dsp.h> | ||
37 | |||
38 | #if !defined(FIXED_POINT) | ||
39 | # define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_float32_t | ||
40 | # define NE10_FFT_CPX_TYPE_T_STR "ne10_fft_cpx_float32_t" | ||
41 | # define NE10_FFT_STATE_TYPE_T_STR "ne10_fft_state_float32_t" | ||
42 | #else | ||
43 | # define NE10_FFT_CFG_TYPE_T ne10_fft_cfg_int32_t | ||
44 | # define NE10_FFT_CPX_TYPE_T_STR "ne10_fft_cpx_int32_t" | ||
45 | # define NE10_FFT_STATE_TYPE_T_STR "ne10_fft_state_int32_t" | ||
46 | #endif | ||
47 | |||
48 | static FILE *file; | ||
49 | |||
50 | void dump_modes_arch_init(CELTMode **modes, int nb_modes) | ||
51 | { | ||
52 | int i; | ||
53 | |||
54 | file = fopen(ARM_NE10_ARCH_FILE_NAME, "w"); | ||
55 | fprintf(file, "/* The contents of this file was automatically generated by\n"); | ||
56 | fprintf(file, " * dump_mode_arm_ne10.c with arguments:"); | ||
57 | for (i=0;i<nb_modes;i++) | ||
58 | { | ||
59 | CELTMode *mode = modes[i]; | ||
60 | fprintf(file, " %d %d",mode->Fs,mode->shortMdctSize*mode->nbShortMdcts); | ||
61 | } | ||
62 | fprintf(file, "\n * It contains static definitions for some pre-defined modes. */\n"); | ||
63 | fprintf(file, "#include <NE10_types.h>\n\n"); | ||
64 | } | ||
65 | |||
66 | void dump_modes_arch_finalize() | ||
67 | { | ||
68 | fclose(file); | ||
69 | } | ||
70 | |||
71 | void dump_mode_arch(CELTMode *mode) | ||
72 | { | ||
73 | int k, j; | ||
74 | int mdctSize; | ||
75 | |||
76 | mdctSize = mode->shortMdctSize*mode->nbShortMdcts; | ||
77 | |||
78 | fprintf(file, "#ifndef NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); | ||
79 | fprintf(file, "#define NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); | ||
80 | /* cfg->factors */ | ||
81 | for(k=0;k<=mode->mdct.maxshift;k++) { | ||
82 | NE10_FFT_CFG_TYPE_T cfg; | ||
83 | cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; | ||
84 | if (!cfg) | ||
85 | continue; | ||
86 | fprintf(file, "static const ne10_int32_t ne10_factors_%d[%d] = {\n", | ||
87 | mode->mdct.kfft[k]->nfft, (NE10_MAXFACTORS * 2)); | ||
88 | for(j=0;j<(NE10_MAXFACTORS * 2);j++) { | ||
89 | fprintf(file, "%d,%c", cfg->factors[j],(j+16)%15==0?'\n':' '); | ||
90 | } | ||
91 | fprintf (file, "};\n"); | ||
92 | } | ||
93 | |||
94 | /* cfg->twiddles */ | ||
95 | for(k=0;k<=mode->mdct.maxshift;k++) { | ||
96 | NE10_FFT_CFG_TYPE_T cfg; | ||
97 | cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; | ||
98 | if (!cfg) | ||
99 | continue; | ||
100 | fprintf(file, "static const %s ne10_twiddles_%d[%d] = {\n", | ||
101 | NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft, | ||
102 | mode->mdct.kfft[k]->nfft); | ||
103 | for(j=0;j<mode->mdct.kfft[k]->nfft;j++) { | ||
104 | #if !defined(FIXED_POINT) | ||
105 | fprintf(file, "{%#0.8gf,%#0.8gf},%c", | ||
106 | cfg->twiddles[j].r, cfg->twiddles[j].i,(j+4)%3==0?'\n':' '); | ||
107 | #else | ||
108 | fprintf(file, "{%d,%d},%c", | ||
109 | cfg->twiddles[j].r, cfg->twiddles[j].i,(j+4)%3==0?'\n':' '); | ||
110 | #endif | ||
111 | } | ||
112 | fprintf (file, "};\n"); | ||
113 | } | ||
114 | |||
115 | for(k=0;k<=mode->mdct.maxshift;k++) { | ||
116 | NE10_FFT_CFG_TYPE_T cfg; | ||
117 | cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; | ||
118 | if (!cfg) { | ||
119 | fprintf(file, "/* Ne10 does not support scaled FFT for length = %d */\n", | ||
120 | mode->mdct.kfft[k]->nfft); | ||
121 | fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", mode->mdct.kfft[k]->nfft); | ||
122 | fprintf(file, "0,\n"); | ||
123 | fprintf(file, "NULL\n"); | ||
124 | fprintf(file, "};\n"); | ||
125 | continue; | ||
126 | } | ||
127 | fprintf(file, "static const %s %s_%d = {\n", NE10_FFT_STATE_TYPE_T_STR, | ||
128 | NE10_FFT_STATE_TYPE_T_STR, mode->mdct.kfft[k]->nfft); | ||
129 | fprintf(file, "%d,\n", cfg->nfft); | ||
130 | fprintf(file, "(ne10_int32_t *)ne10_factors_%d,\n", mode->mdct.kfft[k]->nfft); | ||
131 | fprintf(file, "(%s *)ne10_twiddles_%d,\n", | ||
132 | NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft); | ||
133 | fprintf(file, "NULL,\n"); /* buffer */ | ||
134 | fprintf(file, "(%s *)&ne10_twiddles_%d[%d],\n", | ||
135 | NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft, cfg->nfft); | ||
136 | #if !defined(FIXED_POINT) | ||
137 | fprintf(file, "/* is_forward_scaled = true */\n"); | ||
138 | fprintf(file, "(ne10_int32_t) 1,\n"); | ||
139 | fprintf(file, "/* is_backward_scaled = false */\n"); | ||
140 | fprintf(file, "(ne10_int32_t) 0,\n"); | ||
141 | #endif | ||
142 | fprintf(file, "};\n"); | ||
143 | |||
144 | fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", | ||
145 | mode->mdct.kfft[k]->nfft); | ||
146 | fprintf(file, "1,\n"); | ||
147 | fprintf(file, "(void *)&%s_%d,\n", | ||
148 | NE10_FFT_STATE_TYPE_T_STR, mode->mdct.kfft[k]->nfft); | ||
149 | fprintf(file, "};\n\n"); | ||
150 | } | ||
151 | fprintf(file, "#endif /* end NE10_FFT_PARAMS%d_%d */\n", mode->Fs, mdctSize); | ||
152 | } | ||