少年修仙传客户端代码仓库
xingchen Qiu
2019-04-10 b45f84d1a84cb768d0b136fe37ad18364d74af1f
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
namespace NSpeex
{
    using System;
 
    internal class HighLspQuant : 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++)
            {
                weight[num] = Math.Max((float)(1f / (qlsp[num] - qlsp[num - 1])), (float)(1f / (qlsp[num + 1] - qlsp[num])));
            }
            for (num = 0; num < order; num++)
            {
                qlsp[num] -= (0.3125f * num) + 0.75f;
            }
            for (num = 0; num < order; num++)
            {
                qlsp[num] *= 256f;
            }
            int data = LspQuant.Lsp_quant(qlsp, 0, Codebook_Constants.high_lsp_cdbk, 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.high_lsp_cdbk2, 0x40, order);
            bits.Pack(data, 6);
            for (num = 0; num < order; num++)
            {
                qlsp[num] *= 0.0019531f;
            }
            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.3125f * i) + 0.75f;
            }
            base.UnpackPlus(lsp, Codebook_Constants.high_lsp_cdbk, bits, 0.0039062f, order, 0);
            base.UnpackPlus(lsp, Codebook_Constants.high_lsp_cdbk2, bits, 0.0019531f, order, 0);
        }
    }
}