少年修仙传客户端代码仓库
client_Hale
2019-04-13 d4b5806a57e4e88a1fc57dd95f17e185f33e4e43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
namespace NSpeex
{
    using System;
 
    internal class SplitShapeSearch : CodebookSearch
    {
        private float[] e;
        private float[] E;
        private int have_sign;
        private int[] ind;
        private const int MAX_COMPLEXITY = 10;
        private int nb_subvect;
        private int[,] nind;
        private float[][] nt;
        private int[,] oind;
        private float[][] ot;
        private float[] r2;
        private int shape_bits;
        private int[] shape_cb;
        private int shape_cb_size;
        private int[] signs;
        private int subframesize;
        private int subvect_size;
        private float[] t;
 
        public SplitShapeSearch(int subframesize_0, int subvect_size_1, int nb_subvect_2, int[] shape_cb_3, int shape_bits_4, int have_sign_5)
        {
            this.subframesize = subframesize_0;
            this.subvect_size = subvect_size_1;
            this.nb_subvect = nb_subvect_2;
            this.shape_cb = shape_cb_3;
            this.shape_bits = shape_bits_4;
            this.have_sign = have_sign_5;
            this.ind = new int[nb_subvect_2];
            this.signs = new int[nb_subvect_2];
            this.shape_cb_size = ((int)1) << shape_bits_4;
            this.ot = this.CreateJaggedArray<float>(10, subframesize_0);
            this.nt = this.CreateJaggedArray<float>(10, subframesize_0);
            this.oind = new int[10, nb_subvect_2];
            this.nind = new int[10, nb_subvect_2];
            this.t = new float[subframesize_0];
            this.e = new float[subframesize_0];
            this.r2 = new float[subframesize_0];
            this.E = new float[this.shape_cb_size];
        }
 
        private T[][] CreateJaggedArray<T>(int dim1, int dim2)
        {
            T[][] localArray = new T[dim1][];
            for (int i = 0; i < dim1; i++)
            {
                localArray[i] = new T[dim2];
                Array.Clear(localArray[i], 0, dim2);
            }
            return localArray;
        }
 
        public sealed override void Quantify(float[] target, float[] ak, float[] awk1, float[] awk2, int p, int nsf, float[] exc, int es, float[] r, Bits bits, int complexity)
        {
            int num2;
            int num3;
            int n = complexity;
            if (n > 10)
            {
                n = 10;
            }
            float[] codebook = new float[this.shape_cb_size * this.subvect_size];
            int[] nbest = new int[n];
            float[] numArray5 = new float[n];
            float[] numArray2 = new float[n];
            float[] numArray3 = new float[n];
            int[] numArray6 = new int[n];
            int[] numArray7 = new int[n];
            int index = 0;
            while (index < n)
            {
                for (num2 = 0; num2 < this.nb_subvect; num2++)
                {
                    this.nind[index, num2] = this.oind[index, num2] = -1;
                }
                index++;
            }
            num2 = 0;
            while (num2 < n)
            {
                index = 0;
                while (index < nsf)
                {
                    this.ot[num2][index] = target[index];
                    index++;
                }
                num2++;
            }
            for (index = 0; index < this.shape_cb_size; index++)
            {
                int num8 = index * this.subvect_size;
                int num9 = index * this.subvect_size;
                num2 = 0;
                while (num2 < this.subvect_size)
                {
                    codebook[num8 + num2] = 0f;
                    num3 = 0;
                    while (num3 <= num2)
                    {
                        codebook[num8 + num2] += (0.03125f * this.shape_cb[num9 + num3]) * r[num2 - num3];
                        num3++;
                    }
                    num2++;
                }
                this.E[index] = 0f;
                for (num2 = 0; num2 < this.subvect_size; num2++)
                {
                    this.E[index] += codebook[num8 + num2] * codebook[num8 + num2];
                }
            }
            num2 = 0;
            while (num2 < n)
            {
                numArray3[num2] = 0f;
                num2++;
            }
            for (index = 0; index < this.nb_subvect; index++)
            {
                int num4;
                int num5;
                int offset = index * this.subvect_size;
                num2 = 0;
                while (num2 < n)
                {
                    numArray2[num2] = 2.147484E+09f;
                    num2++;
                }
                num2 = 0;
                while (num2 < n)
                {
                    numArray6[num2] = numArray7[num2] = 0;
                    num2++;
                }
                num2 = 0;
                while (num2 < n)
                {
                    float num11 = 0f;
                    num4 = offset;
                    while (num4 < (offset + this.subvect_size))
                    {
                        num11 += this.ot[num2][num4] * this.ot[num2][num4];
                        num4++;
                    }
                    num11 *= 0.5f;
                    if (this.have_sign != 0)
                    {
                        VQ.Nbest_sign(this.ot[num2], offset, codebook, this.subvect_size, this.shape_cb_size, this.E, n, nbest, numArray5);
                    }
                    else
                    {
                        VQ.Nbest(this.ot[num2], offset, codebook, this.subvect_size, this.shape_cb_size, this.E, n, nbest, numArray5);
                    }
                    for (num3 = 0; num3 < n; num3++)
                    {
                        float num12 = (numArray3[num2] + numArray5[num3]) + num11;
                        if (num12 < numArray2[n - 1])
                        {
                            num4 = 0;
                            while (num4 < n)
                            {
                                if (num12 < numArray2[num4])
                                {
                                    num5 = n - 1;
                                    while (num5 > num4)
                                    {
                                        numArray2[num5] = numArray2[num5 - 1];
                                        numArray6[num5] = numArray6[num5 - 1];
                                        numArray7[num5] = numArray7[num5 - 1];
                                        num5--;
                                    }
                                    numArray2[num4] = num12;
                                    numArray6[num5] = nbest[num3];
                                    numArray7[num5] = num2;
                                    break;
                                }
                                num4++;
                            }
                        }
                    }
                    if (index == 0)
                    {
                        break;
                    }
                    num2++;
                }
                num2 = 0;
                while (num2 < n)
                {
                    int num6;
                    num4 = (index + 1) * this.subvect_size;
                    while (num4 < nsf)
                    {
                        this.nt[num2][num4] = this.ot[numArray7[num2]][num4];
                        num4++;
                    }
                    num4 = 0;
                    while (num4 < this.subvect_size)
                    {
                        float num15 = 1f;
                        int num14 = numArray6[num2];
                        if (num14 >= this.shape_cb_size)
                        {
                            num15 = -1f;
                            num14 -= this.shape_cb_size;
                        }
                        num6 = this.subvect_size - num4;
                        float num13 = (num15 * 0.03125f) * this.shape_cb[(num14 * this.subvect_size) + num4];
                        num5 = 0;
                        for (int i = offset + this.subvect_size; num5 < (nsf - (this.subvect_size * (index + 1))); i++)
                        {
                            this.nt[num2][i] -= num13 * r[num5 + num6];
                            num5++;
                        }
                        num4++;
                    }
                    for (num6 = 0; num6 < this.nb_subvect; num6++)
                    {
                        this.nind[num2, num6] = this.oind[numArray7[num2], num6];
                    }
                    this.nind[num2, index] = numArray6[num2];
                    num2++;
                }
                float[][] ot = this.ot;
                this.ot = this.nt;
                this.nt = ot;
                num2 = 0;
                while (num2 < n)
                {
                    for (num4 = 0; num4 < this.nb_subvect; num4++)
                    {
                        this.oind[num2, num4] = this.nind[num2, num4];
                    }
                    num2++;
                }
                num2 = 0;
                while (num2 < n)
                {
                    numArray3[num2] = numArray2[num2];
                    num2++;
                }
            }
            for (index = 0; index < this.nb_subvect; index++)
            {
                this.ind[index] = this.nind[0, index];
                bits.Pack(this.ind[index], this.shape_bits + this.have_sign);
            }
            for (index = 0; index < this.nb_subvect; index++)
            {
                float num18 = 1f;
                int num17 = this.ind[index];
                if (num17 >= this.shape_cb_size)
                {
                    num18 = -1f;
                    num17 -= this.shape_cb_size;
                }
                num2 = 0;
                while (num2 < this.subvect_size)
                {
                    this.e[(this.subvect_size * index) + num2] = (num18 * 0.03125f) * this.shape_cb[(num17 * this.subvect_size) + num2];
                    num2++;
                }
            }
            for (num2 = 0; num2 < nsf; num2++)
            {
                exc[es + num2] += this.e[num2];
            }
            Filters.Syn_percep_zero(this.e, 0, ak, awk1, awk2, this.r2, nsf, p);
            for (num2 = 0; num2 < nsf; num2++)
            {
                target[num2] -= this.r2[num2];
            }
        }
 
        public sealed override void Unquantify(float[] exc, int es, int nsf, Bits bits)
        {
            int num;
            for (num = 0; num < this.nb_subvect; num++)
            {
                if (this.have_sign != 0)
                {
                    this.signs[num] = bits.Unpack(1);
                }
                else
                {
                    this.signs[num] = 0;
                }
                this.ind[num] = bits.Unpack(this.shape_bits);
            }
            for (num = 0; num < this.nb_subvect; num++)
            {
                float num3 = 1f;
                if (this.signs[num] != 0)
                {
                    num3 = -1f;
                }
                for (int i = 0; i < this.subvect_size; i++)
                {
                    exc[(es + (this.subvect_size * num)) + i] += (num3 * 0.03125f) * this.shape_cb[(this.ind[num] * this.subvect_size) + i];
                }
            }
        }
    }
}