Exemple #1
0
        public sealed override void Quant(float[] lsp, float[] qlsp, int order, Bits bits)
        {
            float[] array = new float[20];
            for (int i = 0; i < order; i++)
            {
                qlsp[i] = lsp[i];
            }
            array[0]         = 1f / (qlsp[1] - qlsp[0]);
            array[order - 1] = 1f / (qlsp[order - 1] - qlsp[order - 2]);
            for (int i = 1; i < order - 1; i++)
            {
                float num  = 1f / ((0.15f + qlsp[i] - qlsp[i - 1]) * (0.15f + qlsp[i] - qlsp[i - 1]));
                float num2 = 1f / ((0.15f + qlsp[i + 1] - qlsp[i]) * (0.15f + qlsp[i + 1] - qlsp[i]));
                array[i] = ((num > num2) ? num : num2);
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] -= new float?((float)(0.25 * (double)i + 0.25)).Value;
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= 256f;
            }
            int data = LspQuant.Lsp_quant(qlsp, 0, Codebook_Constants.cdbk_nb, 64, order);

            bits.Pack(data, 6);
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= 2f;
            }
            data = LspQuant.Lsp_weight_quant(qlsp, 0, array, 0, Codebook_Constants.cdbk_nb_low1, 64, 5);
            bits.Pack(data, 6);
            for (int i = 0; i < 5; i++)
            {
                qlsp[i] *= 2f;
            }
            data = LspQuant.Lsp_weight_quant(qlsp, 0, array, 0, Codebook_Constants.cdbk_nb_low2, 64, 5);
            bits.Pack(data, 6);
            data = LspQuant.Lsp_weight_quant(qlsp, 5, array, 5, Codebook_Constants.cdbk_nb_high1, 64, 5);
            bits.Pack(data, 6);
            for (int i = 5; i < 10; i++)
            {
                qlsp[i] *= 2f;
            }
            data = LspQuant.Lsp_weight_quant(qlsp, 5, array, 5, Codebook_Constants.cdbk_nb_high2, 64, 5);
            bits.Pack(data, 6);
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= new float?(0.00097656f).Value;
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] = lsp[i] - qlsp[i];
            }
        }
Exemple #2
0
 public SubMode(int lbrPitch, int forcedPitchGain, int haveSubframeGain, int doubleCodebook, LspQuant lspQuant, Ltp ltp, CodebookSearch innovation, float lpcEnhK1, float lpcEnhK2, float combGain, int bitsPerFrame)
 {
     this.lbrPitch         = lbrPitch;
     this.forcedPitchGain  = forcedPitchGain;
     this.haveSubframeGain = haveSubframeGain;
     this.doubleCodebook   = doubleCodebook;
     this.lsqQuant         = lspQuant;
     this.ltp          = ltp;
     this.innovation   = innovation;
     this.lpcEnhK1     = lpcEnhK1;
     this.lpcEnhK2     = lpcEnhK2;
     this.combGain     = combGain;
     this.bitsPerFrame = bitsPerFrame;
 }
Exemple #3
0
        public sealed override void Quant(float[] lsp, float[] qlsp, int order, Bits bits)
        {
            float[] array = new float[20];
            for (int i = 0; i < order; i++)
            {
                qlsp[i] = lsp[i];
            }
            array[0]         = 1f / (qlsp[1] - qlsp[0]);
            array[order - 1] = 1f / (qlsp[order - 1] - qlsp[order - 2]);
            for (int i = 1; i < order - 1; i++)
            {
                array[i] = Math.Max(1f / (qlsp[i] - qlsp[i - 1]), 1f / (qlsp[i + 1] - qlsp[i]));
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] -= 0.3125f * (float)i + 0.75f;
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= 256f;
            }
            int data = LspQuant.Lsp_quant(qlsp, 0, Codebook_Constants.high_lsp_cdbk, 64, order);

            bits.Pack(data, 6);
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= 2f;
            }
            data = LspQuant.Lsp_weight_quant(qlsp, 0, array, 0, Codebook_Constants.high_lsp_cdbk2, 64, order);
            bits.Pack(data, 6);
            for (int i = 0; i < order; i++)
            {
                qlsp[i] *= 0.0019531f;
            }
            for (int i = 0; i < order; i++)
            {
                qlsp[i] = lsp[i] - qlsp[i];
            }
        }