少年修仙传客户端代码仓库
client_Zxw
2019-03-04 6beea42305d7bae180f5ec6769f3e9daca3d849c
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
namespace NSpeex
{
    using System;
 
    internal class LbrLspQuant : LspQuant
    {
        public sealed override void Quant(float[] lsp, float[] qlsp, int order, Bits bits)
        {
            int num;
            float[] weight = new float[20];
            for (num = 0; num < order; num++)
            {
                qlsp[num] = lsp[num];
            }
            weight[0] = 1f / (qlsp[1] - qlsp[0]);
            weight[order - 1] = 1f / (qlsp[order - 1] - qlsp[order - 2]);
            for (num = 1; num < (order - 1); num++)
            {
                float num2 = 1f / (((0.15f + qlsp[num]) - qlsp[num - 1]) * ((0.15f + qlsp[num]) - qlsp[num - 1]));
                float num3 = 1f / (((0.15f + qlsp[num + 1]) - qlsp[num]) * ((0.15f + qlsp[num + 1]) - qlsp[num]));
                weight[num] = (num2 > num3) ? num2 : num3;
            }
            for (num = 0; num < order; num++)
            {
                float? nullable = new float?((float)((0.25 * num) + 0.25));
                qlsp[num] -= nullable.Value;
            }
            for (num = 0; num < order; num++)
            {
                qlsp[num] *= 256f;
            }
            int data = LspQuant.Lsp_quant(qlsp, 0, Codebook_Constants.cdbk_nb, 0x40, order);
            bits.Pack(data, 6);
            for (num = 0; num < order; num++)
            {
                qlsp[num] *= 2f;
            }
            data = LspQuant.Lsp_weight_quant(qlsp, 0, weight, 0, Codebook_Constants.cdbk_nb_low1, 0x40, 5);
            bits.Pack(data, 6);
            data = LspQuant.Lsp_weight_quant(qlsp, 5, weight, 5, Codebook_Constants.cdbk_nb_high1, 0x40, 5);
            bits.Pack(data, 6);
            for (num = 0; num < order; num++)
            {
                float? nullable2 = 0.0019531f;
                qlsp[num] *= nullable2.Value;
            }
            for (num = 0; num < order; num++)
            {
                qlsp[num] = lsp[num] - qlsp[num];
            }
        }
 
        public sealed override void Unquant(float[] lsp, int order, Bits bits)
        {
            for (int i = 0; i < order; i++)
            {
                lsp[i] = (0.25f * i) + 0.25f;
            }
            base.UnpackPlus(lsp, Codebook_Constants.cdbk_nb, bits, 0.0039062f, 10, 0);
            base.UnpackPlus(lsp, Codebook_Constants.cdbk_nb_low1, bits, 0.0019531f, 5, 0);
            base.UnpackPlus(lsp, Codebook_Constants.cdbk_nb_high1, bits, 0.0019531f, 5, 5);
        }
    }
}