Cleanup mbevocoder code

This commit is contained in:
Doug McLain committed 2026-10-12 14:55:03 -04:00
1 parent 97189204db
commit 498a93beaa
16 files changed
+2191 -4265

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@
#include "PacketQueue.h"
#include "codec2.h"
#include "TCSocket.h"
#include "mbe/mbevocoder_api.h"
#include "mbe/mbevocoder.h"
class CController
{
+4 -5
View File
@@ -19,9 +19,8 @@
#include <stdio.h>
#include <math.h>
#include "mbelib.h"
#include "ambe3600x2400_const.h"
#include "dstar_pitch.h"
#include "mbevocoder.h"
#include "vocoder_tables.h"
void
mbe_dumpAmbe2400Data (char *ambe_d)
@@ -286,7 +285,7 @@ mbe_decodeAmbe2400Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp)
{
// L from specification document
// lookup L in tabl3
L = DSTAR_L(b0); // QSO One: the chip-measured harmonic count (dstar_pitch.h 3); was AmbePlusLtable[b0]
L = DSTAR_L(b0);
// L formula from patent filings
//L=(int)((float)0.4627 / f0);
cur_mp->L = L;
@@ -576,7 +575,7 @@ mbe_decodeAmbe2400Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp)
// eq 43
Sum43 = Sum43 + ((((float) 1 - deltal[l]) * prev_mp->log2Ml[intkl[l]]) + (deltal[l] * prev_mp->log2Ml[intkl[l] + 1]));
}
Sum43 = ((DSTAR_SPEC_PRED / (float) cur_mp->L) * Sum43); // QSO One: 0.8, measured on a real chip (dstar_pitch.h)
Sum43 = ((DSTAR_SPEC_PRED / (float) cur_mp->L) * Sum43);
#ifdef AMBE_DEBUG
printf ("\n");
printf ("Sum43: %f\n", Sum43);
-884
View File
@@ -1,884 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _AMBE3600x2400_CONST_H
#define _AMBE3600x2400_CONST_H
extern "C" {
const float AmbePlusLtable[126] = {
9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 13,
13, 13, 13, 13, 14, 14,
14, 14, 15, 15, 15, 15,
16, 16, 16, 16, 17, 17,
17, 17, 18, 18, 18, 18,
19, 19, 19, 20, 20, 20,
21, 21, 21, 22, 22, 22,
23, 23, 23, 24, 24, 24,
25, 25, 26, 26, 26, 27,
27, 28, 28, 29, 29, 30,
30, 30, 31, 31, 32, 32,
33, 33, 34, 34, 35, 36,
36, 37, 37, 38, 38, 39,
40, 40, 41, 42, 42, 43,
43, 44, 45, 46, 46, 47,
48, 48, 49, 50, 51, 52,
52, 53, 54, 55, 56, 56,
56, 56, 56, 56, 56, 56 // last line is padded
};
/*
* V/UV Quantization Vectors
*/
const int AmbePlusVuv[16][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 1},
{0, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1},
{0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 1, 1},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 1, 1, 0, 0},
{1, 1, 0, 0, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 0, 0, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1}
};
/*
* Log Magnitude Prediction Residual Block Lengths
*/
const int AmbePlusLmprbl[57][4] = {
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{2, 2, 2, 3,},
{2, 2, 3, 3,},
{2, 3, 3, 3,},
{2, 3, 3, 4,},
{3, 3, 3, 4,},
{3, 3, 4, 4,},
{3, 3, 4, 5,},
{3, 4, 4, 5,},
{3, 4, 5, 5,},
{4, 4, 5, 5,},
{4, 4, 5, 6,},
{4, 4, 6, 6,},
{4, 5, 6, 6,},
{4, 5, 6, 7,},
{5, 5, 6, 7,},
{5, 5, 7, 7,},
{5, 6, 7, 7,},
{5, 6, 7, 8,},
{5, 6, 8, 8,},
{6, 6, 8, 8,},
{6, 6, 8, 9,},
{6, 7, 8, 9,},
{6, 7, 9, 9,},
{6, 7, 9, 10,},
{7, 7, 9, 10,},
{7, 8, 9, 10,},
{7, 8, 10, 10,},
{7, 8, 10, 11,},
{8, 8, 10, 11,},
{8, 9, 10, 11,},
{8, 9, 11, 11,},
{8, 9, 11, 12,},
{8, 9, 11, 13,},
{8, 9, 12, 13,},
{8, 10, 12, 13,},
{9, 10, 12, 13,},
{9, 10, 12, 14,},
{9, 10, 13, 14,},
{9, 11, 13, 14,},
{10, 11, 13, 14,},
{10, 11, 13, 15,},
{10, 11, 14, 15,},
{10, 12, 14, 15,},
{10, 12, 14, 16,},
{11, 12, 14, 16,},
{11, 12, 15, 16,},
{11, 12, 15, 17,},
{11, 13, 15, 17}
};
/*
* Gain Quantizer Levels
*/
const float AmbePlusDg[64] = {
0.000000, 0.118200, 0.215088, 0.421167, 0.590088, 0.749075, 0.879395, 0.996388,
1.092285, 1.171577, 1.236572, 1.313450, 1.376465, 1.453342, 1.516357, 1.600346,
1.669189, 1.742847, 1.803223, 1.880234, 1.943359, 2.025067, 2.092041, 2.178042,
2.248535, 2.331718, 2.399902, 2.492343, 2.568115, 2.658677, 2.732910, 2.816496,
2.885010, 2.956386, 3.014893, 3.078890, 3.131348, 3.206615, 3.268311, 3.344785,
3.407471, 3.484885, 3.548340, 3.623339, 3.684814, 3.764509, 3.829834, 3.915298,
3.985352, 4.072560, 4.144043, 4.231251, 4.302734, 4.399066, 4.478027, 4.572883,
4.650635, 4.760785, 4.851074, 4.972361, 5.071777, 5.226203, 5.352783, 5.352783};
/*
* PRBA24 Vector Quantizer Levels
*/
const float AmbePlusPRBA24[512][3] = {
{-1.250000, -0.312500, -0.625000},
{-0.750000, -0.437500, -0.437500},
{-0.437500, -0.375000, -0.312500},
{-0.437500, -0.625000, -0.500000},
{-1.000000, -0.187500, -0.187500},
{-0.625000, -0.625000, -0.125000},
{-0.500000, -0.187500, -0.187500},
{-0.375000, -0.437500, -0.187500},
{-1.062500, -0.750000, -0.125000},
{-0.625000, -0.312500, -0.062500},
{-0.500000, -1.000000, -0.062500},
{-0.375000, -0.312500, -0.062500},
{-0.687500, -0.250000, 0.187500},
{-0.437500, -0.500000, 0.375000},
{-0.375000, -0.375000, 0.062500},
{-0.312500, -0.187500, 0.000000},
{-0.625000, -0.187500, -0.187500},
{-0.500000, -0.062500, -0.250000},
{-0.500000, -0.125000, -0.437500},
{-0.312500, -0.062500, -0.312500},
{-0.562500, -0.187500, -0.062500},
{-0.375000, -0.187500, -0.062500},
{-0.375000, -0.125000, -0.187500},
{-0.312500, -0.187500, -0.125000},
{-0.562500, 0.000000, 0.125000},
{-0.437500, 0.000000, 0.062500},
{-0.312500, -0.125000, 0.125000},
{-0.312500, -0.062500, 0.000000},
{-0.937500, -0.062500, 0.125000},
{-0.750000, -0.125000, 0.375000},
{-0.437500, -0.062500, 0.250000},
{-0.375000, -0.062500, 0.625000},
{-0.875000, 0.062500, -0.312500},
{-0.500000, 0.125000, -0.375000},
{-0.312500, 0.062500, -0.250000},
{-0.312500, 0.000000, -0.312500},
{-0.687500, 0.125000, -0.187500},
{-0.437500, 0.062500, -0.062500},
{-0.375000, 0.125000, -0.125000},
{-0.312500, 0.062500, -0.125000},
{-0.687500, 0.062500, -0.062500},
{-0.437500, 0.187500, 0.062500},
{-0.312500, 0.062500, 0.000000},
{-0.250000, 0.000000, 0.125000},
{-1.312500, 0.062500, 0.312500},
{-0.562500, 0.125000, 0.250000},
{-0.375000, 0.062500, 0.375000},
{-0.312500, 0.125000, 0.125000},
{-1.250000, 0.187500, -0.250000},
{-0.687500, 0.437500, -0.375000},
{-0.562500, 0.250000, -0.250000},
{-0.312500, 0.375000, -0.562500},
{-0.812500, 0.437500, -0.062500},
{-0.625000, 0.187500, -0.062500},
{-0.500000, 0.375000, -0.062500},
{-0.375000, 0.375000, -0.250000},
{-0.812500, 0.187500, 0.187500},
{-0.562500, 0.625000, 0.062500},
{-0.500000, 0.312500, 0.125000},
{-0.312500, 0.312500, 0.062500},
{-0.500000, 0.250000, 0.625000},
{-0.375000, 0.250000, 0.312500},
{-0.312500, 0.500000, 0.500000},
{-0.312500, 0.500000, 0.250000},
{-0.250000, -0.437500, -0.375000},
{-0.250000, -0.250000, -0.312500},
{-0.250000, -0.687500, -0.312500},
{-0.125000, -0.500000, -0.250000},
{-0.250000, -0.375000, -0.125000},
{-0.125000, -0.312500, -0.187500},
{-0.125000, -0.250000, -0.250000},
{-0.062500, -0.187500, -0.125000},
{-0.187500, -0.187500, -0.062500},
{-0.187500, -0.500000, 0.000000},
{-0.125000, -0.375000, -0.062500},
{-0.062500, -0.250000, 0.000000},
{-0.250000, -0.312500, 0.250000},
{-0.187500, -0.250000, 0.125000},
{-0.187500, -0.250000, 0.000000},
{-0.125000, -0.625000, 0.187500},
{-0.187500, -0.062500, -0.250000},
{-0.125000, -0.062500, -0.187500},
{-0.062500, 0.000000, -0.312500},
{-0.062500, 0.000000, -0.812500},
{-0.250000, -0.125000, -0.062500},
{-0.250000, -0.062500, -0.125000},
{-0.187500, 0.000000, -0.062500},
{-0.125000, -0.062500, -0.062500},
{-0.187500, 0.000000, 0.125000},
{-0.187500, -0.062500, 0.062500},
{-0.125000, -0.125000, 0.125000},
{-0.125000, -0.187500, 0.062500},
{-0.187500, -0.062500, 0.437500},
{-0.187500, -0.125000, 0.187500},
{-0.125000, 0.000000, 0.187500},
{-0.062500, 0.000000, 0.375000},
{-0.187500, 0.000000, -0.187500},
{-0.187500, 0.125000, -0.125000},
{-0.187500, 0.125000, -0.187500},
{-0.125000, 0.125000, -0.375000},
{-0.250000, 0.187500, 0.000000},
{-0.125000, 0.000000, -0.125000},
{-0.062500, 0.000000, -0.062500},
{-0.062500, 0.125000, -0.062500},
{-0.187500, 0.125000, 0.125000},
{-0.187500, 0.062500, 0.000000},
{-0.125000, 0.125000, 0.062500},
{-0.062500, 0.000000, 0.000000},
{-0.250000, 0.062500, 0.250000},
{-0.125000, 0.125000, 0.312500},
{-0.125000, 0.125000, 0.125000},
{-0.062500, 0.000000, 0.125000},
{-0.250000, 0.250000, -0.187500},
{-0.187500, 0.687500, -0.187500},
{-0.125000, 0.250000, -0.125000},
{-0.062500, 0.375000, -0.312500},
{-0.187500, 0.187500, -0.062500},
{-0.187500, 0.437500, -0.062500},
{-0.125000, 0.375000, 0.062500},
{-0.062500, 0.500000, 0.000000},
{-0.250000, 0.250000, 0.187500},
{-0.125000, 0.562500, 0.250000},
{-0.125000, 0.437500, 0.125000},
{-0.062500, 0.312500, 0.125000},
{-0.250000, 0.187500, 0.437500},
{-0.187500, 0.250000, 0.312500},
{-0.062500, 0.312500, 0.250000},
{-0.062500, 0.437500, 0.562500},
{-0.062500, -0.375000, -0.250000},
{0.000000, -0.250000, -0.375000},
{0.062500, -0.250000, -0.312500},
{0.062500, -0.375000, -0.312500},
{0.000000, -0.312500, -0.125000},
{0.000000, -0.250000, -0.062500},
{0.062500, -0.500000, -0.125000},
{0.062500, -0.250000, -0.187500},
{0.000000, -0.437500, 0.000000},
{0.000000, -0.250000, 0.000000},
{0.000000, -0.187500, 0.062500},
{0.062500, -0.375000, 0.000000},
{-0.062500, -0.187500, 0.125000},
{-0.062500, -0.375000, 0.062500},
{0.000000, -0.250000, 0.187500},
{0.000000, -0.312500, 0.125000},
{-0.062500, -0.125000, -0.250000},
{0.000000, -0.125000, -0.500000},
{0.000000, -0.062500, -0.250000},
{0.062500, -0.187500, -0.187500},
{-0.062500, -0.125000, -0.062500},
{-0.062500, -0.187500, 0.000000},
{0.000000, -0.125000, -0.125000},
{0.000000, -0.187500, -0.125000},
{-0.062500, -0.062500, 0.125000},
{0.000000, -0.125000, 0.000000},
{0.062500, -0.062500, 0.000000},
{0.062500, -0.125000, 0.000000},
{-0.062500, -0.125000, 0.437500},
{0.000000, -0.062500, 0.250000},
{0.000000, -0.125000, 0.187500},
{0.062500, -0.187500, 0.312500},
{-0.062500, 0.062500, -0.187500},
{-0.062500, 0.000000, -0.125000},
{0.062500, 0.062500, -0.125000},
{0.062500, 0.062500, -0.312500},
{0.000000, 0.062500, -0.062500},
{0.000000, 0.000000, 0.000000},
{0.062500, 0.000000, -0.125000},
{0.062500, 0.125000, -0.125000},
{0.000000, 0.062500, 0.125000},
{0.000000, 0.125000, 0.062500},
{0.062500, 0.000000, 0.125000},
{0.062500, 0.062500, 0.000000},
{-0.062500, 0.062500, 0.187500},
{-0.062500, 0.062500, 0.437500},
{0.000000, 0.062500, 0.250000},
{0.062500, 0.125000, 0.187500},
{0.000000, 0.250000, -0.250000},
{0.000000, 0.375000, -0.062500},
{0.000000, 0.187500, -0.125000},
{0.062500, 0.500000, -0.187500},
{0.000000, 0.250000, 0.000000},
{0.000000, 0.187500, 0.062500},
{0.062500, 0.312500, 0.062500},
{0.062500, 0.187500, 0.000000},
{-0.062500, 0.187500, 0.187500},
{0.000000, 0.250000, 0.125000},
{0.062500, 0.375000, 0.187500},
{0.062500, 0.250000, 0.250000},
{-0.062500, 0.187500, 0.500000},
{0.000000, 0.312500, 0.375000},
{0.000000, 0.125000, 0.312500},
{0.062500, 0.187500, 0.250000},
{0.125000, -0.125000, -0.312500},
{0.125000, -0.312500, -0.187500},
{0.187500, -0.375000, -0.250000},
{0.187500, -0.187500, -0.125000},
{0.125000, -0.187500, -0.062500},
{0.125000, -0.687500, -0.062500},
{0.125000, -0.187500, -0.062500},
{0.187500, -0.375000, -0.062500},
{0.062500, -0.250000, 0.062500},
{0.125000, -0.187500, 0.000000},
{0.125000, -0.187500, 0.125000},
{0.187500, -0.250000, 0.125000},
{0.062500, -0.187500, 0.187500},
{0.125000, -0.312500, 0.250000},
{0.125000, -0.375000, 0.125000},
{0.187500, -0.187500, 0.187500},
{0.062500, -0.125000, -0.125000},
{0.062500, 0.000000, -0.187500},
{0.125000, -0.062500, -0.187500},
{0.125000, -0.125000, -0.062500},
{0.062500, -0.062500, 0.062500},
{0.125000, -0.062500, 0.000000},
{0.125000, -0.125000, 0.000000},
{0.187500, -0.062500, 0.000000},
{0.062500, 0.000000, 0.187500},
{0.125000, -0.125000, 0.125000},
{0.125000, -0.062500, 0.125000},
{0.187500, -0.125000, 0.125000},
{0.062500, -0.062500, 0.250000},
{0.062500, 0.000000, 0.437500},
{0.187500, -0.125000, 0.375000},
{0.187500, -0.125000, 0.250000},
{0.062500, 0.125000, -0.500000},
{0.125000, 0.125000, -0.125000},
{0.125000, 0.000000, -0.125000},
{0.187500, 0.000000, -0.312500},
{0.062500, 0.062500, 0.062500},
{0.062500, 0.125000, 0.000000},
{0.187500, 0.062500, -0.062500},
{0.187500, 0.125000, 0.062500},
{0.125000, 0.125000, 0.125000},
{0.125000, 0.000000, 0.125000},
{0.187500, 0.000000, 0.062500},
{0.187500, 0.125000, 0.125000},
{0.062500, 0.125000, 0.375000},
{0.125000, 0.062500, 0.687500},
{0.125000, 0.062500, 0.187500},
{0.125000, 0.000000, 0.250000},
{0.062500, 0.187500, -0.125000},
{0.125000, 0.187500, -0.250000},
{0.187500, 0.312500, -0.312500},
{0.187500, 0.250000, -0.125000},
{0.062500, 0.437500, 0.000000},
{0.125000, 0.250000, 0.000000},
{0.187500, 0.187500, 0.062500},
{0.187500, 0.187500, -0.062500},
{0.062500, 0.187500, 0.187500},
{0.125000, 0.375000, 0.062500},
{0.187500, 0.250000, 0.125000},
{0.187500, 0.250000, 0.187500},
{0.125000, 0.312500, 0.375000},
{0.187500, 0.687500, 0.312500},
{0.187500, 0.187500, 0.250000},
{0.187500, 0.312500, 0.250000},
{0.187500, -0.562500, -0.250000},
{0.187500, -0.937500, -0.687500},
{0.312500, -0.312500, -0.375000},
{0.312500, -0.500000, -0.625000},
{0.187500, -0.312500, 0.000000},
{0.187500, -0.250000, -0.250000},
{0.250000, -0.312500, -0.125000},
{0.312500, -0.187500, 0.000000},
{0.187500, -0.437500, 0.062500},
{0.250000, -0.250000, 0.000000},
{0.250000, -0.312500, 0.125000},
{0.250000, -1.000000, 0.125000},
{0.187500, -0.312500, 0.437500},
{0.187500, -0.625000, 0.187500},
{0.187500, -0.250000, 0.187500},
{0.312500, -0.312500, 0.250000},
{0.187500, -0.062500, -0.187500},
{0.187500, -0.125000, -0.437500},
{0.250000, -0.187500, -0.125000},
{0.250000, -0.125000, -0.250000},
{0.250000, -0.187500, -0.062500},
{0.250000, -0.062500, -0.062500},
{0.250000, -0.062500, -0.125000},
{0.312500, -0.125000, -0.062500},
{0.187500, -0.187500, 0.062500},
{0.250000, -0.062500, 0.000000},
{0.250000, -0.125000, 0.000000},
{0.250000, -0.125000, 0.125000},
{0.250000, -0.062500, 0.312500},
{0.250000, -0.187500, 0.312500},
{0.250000, -0.062500, 0.250000},
{0.312500, -0.187500, 0.187500},
{0.187500, 0.125000, -0.187500},
{0.187500, 0.062500, -0.125000},
{0.312500, 0.062500, -0.312500},
{0.312500, 0.062500, -0.187500},
{0.250000, -0.062500, 0.062500},
{0.250000, 0.000000, -0.062500},
{0.250000, 0.062500, 0.000000},
{0.312500, 0.000000, 0.000000},
{0.187500, 0.000000, 0.187500},
{0.187500, 0.062500, 0.125000},
{0.312500, 0.000000, 0.125000},
{0.312500, 0.062500, 0.187500},
{0.187500, 0.062500, 0.187500},
{0.250000, 0.062500, 0.312500},
{0.250000, 0.000000, 0.250000},
{0.250000, 0.062500, 0.437500},
{0.250000, 0.250000, -0.187500},
{0.250000, 0.250000, -0.062500},
{0.250000, 0.125000, -0.062500},
{0.312500, 0.625000, -0.062500},
{0.187500, 0.312500, 0.062500},
{0.250000, 0.375000, -0.062500},
{0.250000, 0.125000, 0.062500},
{0.312500, 0.187500, -0.062500},
{0.250000, 0.437500, 0.125000},
{0.250000, 0.187500, 0.187500},
{0.250000, 0.187500, 0.062500},
{0.312500, 0.250000, 0.187500},
{0.187500, 0.187500, 0.375000},
{0.250000, 0.187500, 0.250000},
{0.250000, 0.312500, 0.437500},
{0.250000, 0.375000, 0.625000},
{0.312500, -0.250000, -0.125000},
{0.312500, -0.312500, -0.187500},
{0.312500, -0.187500, -0.062500},
{0.437500, -0.625000, -0.250000},
{0.312500, -0.312500, 0.062500},
{0.312500, -0.312500, 0.000000},
{0.312500, -0.375000, -0.062500},
{0.375000, -0.250000, 0.062500},
{0.312500, -0.437500, 0.187500},
{0.312500, -0.187500, 0.062500},
{0.312500, -0.312500, 0.125000},
{0.375000, -0.250000, 0.125000},
{0.375000, -0.375000, 0.375000},
{0.375000, -0.250000, 0.437500},
{0.375000, -0.250000, 0.250000},
{0.375000, -0.312500, 0.625000},
{0.375000, -0.125000, -0.062500},
{0.375000, -0.125000, -0.125000},
{0.375000, -0.062500, -0.125000},
{0.437500, 0.000000, -0.312500},
{0.312500, -0.125000, 0.062500},
{0.312500, 0.000000, 0.000000},
{0.375000, -0.062500, 0.000000},
{0.375000, -0.187500, 0.000000},
{0.312500, -0.062500, 0.062500},
{0.375000, -0.062500, 0.187500},
{0.375000, -0.125000, 0.125000},
{0.437500, -0.062500, 0.062500},
{0.312500, -0.125000, 0.312500},
{0.375000, -0.062500, 0.562500},
{0.375000, -0.187500, 0.250000},
{0.437500, -0.062500, 0.187500},
{0.312500, 0.000000, -0.187500},
{0.312500, 0.000000, -0.062500},
{0.375000, 0.062500, -0.187500},
{0.375000, 0.125000, -0.250000},
{0.312500, 0.062500, -0.062500},
{0.375000, 0.062500, 0.000000},
{0.375000, 0.125000, 0.000000},
{0.437500, 0.000000, 0.000000},
{0.312500, 0.062500, 0.062500},
{0.312500, 0.125000, 0.125000},
{0.375000, 0.000000, 0.062500},
{0.437500, 0.125000, 0.062500},
{0.312500, 0.062500, 0.250000},
{0.375000, 0.000000, 0.312500},
{0.375000, 0.000000, 0.187500},
{0.375000, 0.125000, 0.187500},
{0.312500, 0.187500, -0.437500},
{0.312500, 0.187500, -0.250000},
{0.437500, 0.500000, -0.375000},
{0.437500, 0.250000, -0.187500},
{0.312500, 0.250000, -0.125000},
{0.312500, 0.187500, 0.062500},
{0.312500, 0.312500, 0.000000},
{0.375000, 0.125000, -0.125000},
{0.312500, 0.250000, 0.062500},
{0.375000, 0.312500, 0.125000},
{0.375000, 0.187500, 0.125000},
{0.437500, 0.312500, 0.250000},
{0.312500, 0.437500, 0.312500},
{0.375000, 0.125000, 0.375000},
{0.375000, 0.750000, 0.687500},
{0.437500, 0.125000, 0.625000},
{0.437500, -0.250000, -0.312500},
{0.437500, -0.250000, -0.187500},
{0.500000, -0.375000, -0.312500},
{0.562500, -0.250000, -0.125000},
{0.437500, -0.250000, 0.000000},
{0.500000, -0.500000, -0.062500},
{0.500000, -0.312500, -0.125000},
{0.562500, -0.375000, 0.000000},
{0.437500, -0.312500, 0.187500},
{0.437500, -0.375000, 0.125000},
{0.500000, -0.187500, 0.062500},
{0.625000, -0.250000, 0.187500},
{0.437500, -0.375000, 0.312500},
{0.500000, -0.250000, 0.375000},
{0.562500, -0.562500, 0.312500},
{0.625000, -0.437500, 0.187500},
{0.437500, -0.187500, -0.250000},
{0.437500, -0.187500, -0.062500},
{0.437500, -0.062500, -0.125000},
{0.625000, -0.187500, -0.125000},
{0.437500, -0.125000, 0.000000},
{0.500000, -0.125000, -0.062500},
{0.562500, -0.125000, 0.000000},
{0.562500, -0.062500, -0.062500},
{0.437500, -0.062500, 0.125000},
{0.500000, -0.187500, 0.125000},
{0.562500, -0.062500, 0.125000},
{0.625000, -0.187500, 0.187500},
{0.437500, -0.062500, 0.375000},
{0.500000, -0.125000, 0.187500},
{0.562500, -0.125000, 0.562500},
{0.562500, -0.125000, 0.250000},
{0.437500, 0.062500, -0.187500},
{0.500000, 0.125000, -0.187500},
{0.562500, 0.000000, -0.187500},
{0.625000, 0.000000, -0.312500},
{0.437500, 0.062500, -0.062500},
{0.500000, 0.062500, 0.000000},
{0.500000, 0.125000, -0.062500},
{0.500000, -0.062500, 0.000000},
{0.437500, 0.062500, 0.187500},
{0.500000, 0.000000, 0.125000},
{0.500000, 0.062500, 0.125000},
{0.562500, 0.125000, 0.000000},
{0.437500, 0.062500, 0.500000},
{0.500000, -0.062500, 0.312500},
{0.562500, 0.000000, 0.250000},
{0.562500, 0.062500, 0.375000},
{0.437500, 0.312500, -0.125000},
{0.437500, 0.187500, -0.125000},
{0.562500, 0.500000, -0.125000},
{0.562500, 0.312500, -0.125000},
{0.437500, 0.250000, -0.062500},
{0.437500, 0.250000, 0.062500},
{0.500000, 0.250000, -0.062500},
{0.625000, 0.125000, -0.125000},
{0.500000, 0.375000, 0.062500},
{0.500000, 0.125000, 0.125000},
{0.500000, 0.562500, 0.125000},
{0.562500, 0.187500, 0.125000},
{0.500000, 0.187500, 0.250000},
{0.500000, 0.625000, 0.375000},
{0.500000, 0.250000, 0.187500},
{0.562500, 0.312500, 0.375000},
{0.625000, -0.312500, -0.187500},
{0.625000, -0.187500, -0.312500},
{0.812500, -0.437500, -0.437500},
{1.375000, -0.187500, -0.375000},
{0.687500, -0.312500, -0.062500},
{0.875000, -0.250000, -0.062500},
{1.062500, -0.187500, 0.062500},
{1.062500, -0.437500, -0.062500},
{0.625000, -0.250000, 0.125000},
{0.750000, -0.125000, 0.062500},
{0.812500, -0.312500, 0.125000},
{1.187500, -0.125000, 0.312500},
{0.625000, -0.312500, 0.562500},
{0.812500, -0.250000, 0.312500},
{0.875000, -0.500000, 0.312500},
{1.000000, -0.312500, 0.500000},
{0.625000, -0.062500, -0.187500},
{0.687500, 0.062500, -0.187500},
{0.812500, -0.062500, -0.187500},
{1.062500, -0.125000, -0.187500},
{0.625000, 0.062500, -0.062500},
{0.687500, -0.125000, -0.062500},
{0.875000, -0.125000, 0.000000},
{1.437500, 0.000000, 0.000000},
{0.625000, 0.000000, 0.062500},
{0.687500, -0.062500, 0.187500},
{0.750000, 0.062500, 0.000000},
{0.812500, 0.000000, 0.125000},
{0.625000, 0.062500, 0.250000},
{0.687500, -0.062500, 0.375000},
{0.687500, 0.000000, 0.500000},
{0.937500, -0.062500, 0.250000},
{0.687500, 0.187500, -0.312500},
{0.750000, 0.187500, -0.500000},
{1.000000, 0.187500, -0.312500},
{1.750000, 0.125000, -0.250000},
{0.750000, 0.187500, -0.125000},
{0.875000, 0.187500, -0.062500},
{0.937500, 0.125000, 0.000000},
{1.187500, 0.187500, -0.187500},
{0.625000, 0.187500, 0.250000},
{0.625000, 0.187500, 0.125000},
{0.687500, 0.187500, 0.000000},
{0.937500, 0.250000, 0.250000},
{0.687500, 0.187500, 0.437500},
{0.750000, 0.062500, 0.312500},
{0.937500, 0.125000, 0.437500},
{1.437500, 0.187500, 0.437500},
{0.625000, 0.250000, -0.062500},
{0.687500, 0.375000, 0.000000},
{1.062500, 0.937500, -0.250000},
{1.375000, 0.375000, -0.250000},
{0.812500, 0.312500, 0.125000},
{0.875000, 0.500000, 0.000000},
{1.062500, 0.375000, 0.062500},
{1.500000, 0.437500, 0.125000},
{0.625000, 0.375000, 0.250000},
{0.875000, 0.375000, 0.312500},
{1.125000, 0.625000, 0.187500},
{1.187500, 0.250000, 0.187500},
{0.687500, 0.437500, 0.437500},
{0.750000, 0.375000, 0.687500},
{0.937500, 0.750000, 0.500000},
{1.312500, 0.687500, 0.625000}
};
/*
* PRBA58 Vector Quantizer Levels
*/
const float AmbePlusPRBA58[128][4] = {
{-0.460938, -0.265625, -0.281250, -0.062500},
{-0.367188, -0.117188, -0.078125, -0.054688},
{-0.250000, -0.312500, -0.164063, -0.101563},
{-0.156250, -0.078125, -0.085938, -0.203125},
{-0.468750, -0.085938, -0.171875, 0.164063},
{-0.210938, -0.039063, -0.117188, 0.085938},
{-0.187500, -0.156250, -0.289063, 0.070313},
{-0.179688, -0.117188, -0.148438, -0.046875},
{-0.320313, -0.031250, 0.140625, -0.132813},
{-0.289063, -0.140625, 0.179688, 0.015625},
{-0.179688, -0.226563, -0.007813, -0.101563},
{-0.156250, -0.031250, 0.015625, -0.093750},
{-0.390625, -0.273438, 0.046875, 0.031250},
{-0.195313, -0.203125, -0.070313, 0.039063},
{-0.171875, -0.156250, -0.039063, 0.171875},
{-0.156250, -0.085938, 0.085938, 0.125000},
{-0.304688, 0.054688, -0.210938, -0.085938},
{-0.265625, 0.140625, -0.031250, -0.132813},
{-0.242188, 0.078125, -0.031250, 0.015625},
{-0.203125, 0.000000, -0.085938, -0.070313},
{-0.453125, 0.171875, -0.062500, 0.031250},
{-0.289063, 0.125000, -0.156250, 0.093750},
{-0.179688, 0.257813, -0.054688, 0.273438},
{-0.171875, 0.226563, -0.109375, 0.015625},
{-0.312500, -0.007813, 0.000000, 0.085938},
{-0.265625, 0.265625, 0.046875, 0.101563},
{-0.234375, 0.109375, 0.125000, -0.046875},
{-0.171875, -0.015625, 0.093750, 0.007813},
{-0.414063, 0.046875, 0.101563, 0.203125},
{-0.179688, 0.093750, 0.210938, 0.125000},
{-0.179688, -0.007813, 0.007813, 0.273438},
{-0.171875, 0.085938, 0.007813, 0.132813},
{-0.062500, -0.117188, -0.257813, -0.156250},
{-0.054688, -0.226563, -0.109375, -0.015625},
{-0.046875, -0.164063, -0.070313, -0.117188},
{-0.039063, -0.031250, -0.093750, -0.085938},
{-0.156250, -0.031250, -0.015625, 0.039063},
{-0.085938, 0.015625, -0.179688, 0.164063},
{-0.078125, -0.078125, -0.070313, 0.046875},
{-0.046875, -0.195313, -0.062500, 0.109375},
{-0.093750, -0.046875, 0.109375, -0.101563},
{-0.054688, -0.007813, 0.007813, -0.007813},
{-0.039063, -0.132813, 0.031250, -0.031250},
{-0.023438, -0.148438, 0.195313, -0.085938},
{-0.148438, -0.109375, 0.023438, 0.000000},
{-0.039063, -0.085938, 0.031250, 0.085938},
{-0.039063, -0.226563, 0.117188, 0.070313},
{-0.015625, -0.015625, 0.156250, 0.156250},
{-0.109375, 0.132813, -0.109375, -0.140625},
{-0.093750, 0.023438, -0.187500, -0.007813},
{-0.093750, 0.382813, -0.062500, -0.101563},
{-0.023438, 0.101563, -0.062500, -0.007813},
{-0.140625, 0.195313, -0.273438, 0.132813},
{-0.109375, 0.125000, -0.117188, 0.062500},
{-0.085938, 0.015625, -0.078125, 0.031250},
{-0.031250, 0.203125, -0.023438, 0.125000},
{-0.125000, 0.156250, 0.078125, -0.140625},
{-0.117188, 0.085938, 0.312500, -0.101563},
{-0.093750, 0.062500, 0.007813, -0.078125},
{-0.046875, 0.046875, 0.148438, -0.023438},
{-0.125000, 0.148438, 0.007813, 0.015625},
{-0.085938, 0.046875, 0.054688, 0.039063},
{-0.054688, 0.140625, 0.117188, 0.101563},
{-0.054688, 0.039063, -0.015625, 0.109375},
{0.046875, -0.062500, -0.054688, -0.226563},
{0.062500, -0.132813, -0.093750, -0.101563},
{0.078125, -0.015625, -0.132813, -0.023438},
{0.085938, -0.421875, -0.140625, -0.062500},
{-0.007813, -0.054688, -0.054688, 0.179688},
{0.015625, -0.078125, -0.203125, 0.054688},
{0.015625, -0.093750, -0.078125, 0.023438},
{0.062500, -0.179688, -0.187500, 0.148438},
{0.007813, -0.039063, 0.046875, -0.093750},
{0.023438, 0.031250, 0.117188, -0.179688},
{0.101563, -0.171875, 0.093750, -0.171875},
{0.101563, -0.023438, -0.023438, -0.125000},
{-0.007813, -0.039063, 0.109375, 0.023438},
{0.046875, -0.015625, 0.015625, 0.078125},
{0.054688, -0.046875, -0.023438, -0.023438},
{0.070313, -0.140625, 0.062500, -0.015625},
{0.007813, 0.070313, -0.031250, -0.210938},
{0.015625, 0.140625, -0.179688, -0.046875},
{0.023438, 0.039063, -0.039063, -0.039063},
{0.054688, 0.117188, -0.007813, -0.101563},
{0.015625, 0.046875, -0.117188, 0.078125},
{0.054688, 0.054688, -0.281250, 0.164063},
{0.062500, 0.273438, -0.125000, 0.085938},
{0.093750, 0.101563, -0.070313, 0.046875},
{-0.015625, 0.125000, 0.046875, -0.031250},
{-0.007813, 0.273438, 0.054688, 0.000000},
{0.070313, 0.039063, 0.070313, -0.023438},
{0.109375, 0.195313, 0.093750, -0.218750},
{0.046875, 0.078125, 0.039063, 0.070313},
{0.054688, 0.101563, 0.023438, 0.265625},
{0.070313, 0.125000, 0.273438, 0.031250},
{0.093750, 0.335938, 0.164063, 0.132813},
{0.195313, -0.101563, 0.015625, -0.046875},
{0.234375, -0.171875, -0.164063, -0.125000},
{0.296875, -0.085938, -0.117188, 0.031250},
{0.507813, -0.179688, -0.117188, 0.015625},
{0.109375, -0.179688, -0.046875, 0.046875},
{0.132813, -0.054688, -0.039063, 0.070313},
{0.171875, 0.007813, -0.117188, 0.179688},
{0.429688, 0.015625, -0.039063, 0.218750},
{0.132813, -0.015625, 0.156250, -0.085938},
{0.140625, -0.125000, 0.218750, 0.000000},
{0.265625, -0.250000, 0.101563, -0.085938},
{0.382813, -0.109375, 0.101563, -0.125000},
{0.117188, -0.078125, 0.085938, 0.195313},
{0.218750, -0.210938, 0.054688, 0.140625},
{0.265625, -0.031250, 0.054688, 0.148438},
{0.304688, 0.007813, 0.250000, 0.023438},
{0.117188, 0.289063, -0.226563, -0.109375},
{0.132813, 0.023438, -0.195313, -0.132813},
{0.164063, 0.187500, -0.070313, -0.078125},
{0.281250, 0.046875, -0.101563, -0.250000},
{0.164063, 0.023438, -0.023438, -0.039063},
{0.171875, 0.148438, -0.265625, 0.046875},
{0.210938, 0.031250, -0.156250, 0.000000},
{0.390625, 0.179688, -0.101563, -0.031250},
{0.234375, 0.085938, 0.031250, -0.148438},
{0.250000, 0.265625, 0.156250, -0.070313},
{0.312500, 0.054688, 0.093750, -0.007813},
{0.531250, 0.210938, 0.085938, -0.015625},
{0.117188, 0.179688, 0.054688, 0.031250},
{0.132813, 0.039063, 0.140625, 0.070313},
{0.218750, 0.070313, 0.007813, 0.039063},
{0.226563, 0.242188, 0.007813, 0.148438}
};
/*
* Higher Order Coefficients
*/
const float AmbePlusHOCb5[16][4] = {
{-0.617188, -0.015625, 0.015625, -0.023438},
{-0.507813, -0.382813, -0.312500, -0.117188},
{-0.328125, 0.046875, 0.007813, -0.015625},
{-0.320313, -0.281250, -0.023438, -0.023438},
{-0.171875, 0.140625, -0.179688, -0.007813},
{-0.148438, 0.226563, 0.039063, -0.039063},
{-0.140625, -0.007813, -0.007813, -0.015625},
{-0.109375, -0.101563, 0.179688, -0.062500},
{-0.109375, -0.109375, -0.031250, 0.187500},
{-0.109375, -0.218750, -0.273438, -0.140625},
{0.007813, -0.007813, -0.015625, -0.015625},
{0.078125, -0.265625, -0.007813, 0.007813},
{0.101563, 0.054688, -0.210938, -0.007813},
{0.164063, 0.242188, 0.093750, 0.039063},
{0.179688, -0.023438, 0.007813, -0.007813},
{0.460938, 0.015625, -0.015625, 0.007813}
};
/*
* Higher Order Coefficients
*/
const float AmbePlusHOCb6[16][4] = {
{-0.429688, -0.046875, 0.039063, 0.000000},
{-0.296875, 0.187500, 0.125000, 0.015625},
{-0.203125, -0.218750, -0.039063, -0.007813},
{-0.179688, 0.007813, -0.007813, 0.000000},
{-0.171875, 0.265625, -0.085938, -0.039063},
{-0.046875, -0.070313, 0.203125, -0.023438},
{-0.023438, 0.125000, 0.031250, -0.023438},
{-0.007813, 0.000000, -0.195313, -0.007813},
{0.007813, -0.046875, -0.007813, -0.015625},
{0.015625, -0.031250, 0.039063, 0.195313},
{0.031250, -0.273438, -0.015625, -0.007813},
{0.140625, 0.257813, 0.015625, 0.007813},
{0.164063, 0.015625, 0.007813, -0.023438},
{0.210938, -0.148438, -0.187500, 0.039063},
{0.273438, -0.179688, 0.054688, -0.007813},
{0.421875, 0.054688, -0.039063, 0.000000}
};
/*
* Higher Order Coefficients
*/
const float AmbePlusHOCb7[16][4] = {
{-0.382813, -0.101563, 0.007813, 0.015625},
{-0.335938, 0.226563, 0.015625, -0.007813},
{-0.156250, 0.031250, -0.039063, -0.054688},
{-0.156250, -0.015625, 0.187500, -0.015625},
{-0.085938, -0.257813, 0.023438, -0.007813},
{-0.070313, -0.148438, -0.203125, -0.023438},
{-0.031250, 0.187500, -0.156250, 0.007813},
{-0.023438, -0.007813, -0.015625, 0.179688},
{-0.015625, 0.203125, 0.070313, -0.023438},
{0.000000, -0.039063, -0.007813, -0.023438},
{0.140625, -0.078125, 0.179688, -0.007813},
{0.164063, 0.023438, -0.007813, -0.015625},
{0.187500, -0.007813, -0.218750, -0.007813},
{0.218750, 0.242188, 0.023438, 0.031250},
{0.234375, -0.234375, -0.039063, 0.007813},
{0.445313, 0.054688, -0.007813, 0.000000}
};
/*
* Higher Order Coefficients
*/
const float AmbePlusHOCb8[16][4] = {
{-0.453125, 0.179688, 0.078125, -0.015625},
{-0.414063, -0.179688, -0.031250, 0.015625},
{-0.281250, 0.187500, -0.203125, 0.046875},
{-0.210938, -0.007813, -0.031250, -0.031250},
{-0.148438, -0.031250, 0.218750, -0.054688},
{-0.140625, -0.085938, 0.039063, 0.187500},
{-0.117188, 0.234375, 0.031250, -0.054688},
{-0.062500, -0.273438, -0.007813, -0.015625},
{-0.054688, 0.093750, -0.078125, 0.078125},
{-0.023438, -0.062500, -0.210938, -0.054688},
{0.023438, 0.000000, 0.023438, -0.046875},
{0.125000, 0.234375, -0.187500, -0.015625},
{0.164063, -0.054688, -0.093750, 0.070313},
{0.187500, 0.179688, 0.093750, 0.015625},
{0.203125, -0.171875, 0.140625, -0.015625},
{0.421875, -0.039063, -0.046875, -0.007813}
};
}
#endif
+2 -2
View File
@@ -19,8 +19,8 @@
#include <stdio.h>
#include <math.h>
#include "mbelib.h"
#include "ambe3600x2450_const.h"
#include "mbevocoder.h"
#include "vocoder_tables.h"
void
mbe_dumpAmbe2450Data (char *ambe_d)
-971
View File
@@ -1,971 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _AMBE3600x2250_CONST_H
#define _AMBE3600x2250_CONST_H
extern "C" {
/*
* Fundamental Frequency Quanitization Table
*/
const float AmbeW0table[120] = {
0.049971, 0.049215, 0.048471, 0.047739, 0.047010, 0.046299,
0.045601, 0.044905, 0.044226, 0.043558, 0.042900, 0.042246,
0.041609, 0.040979, 0.040356, 0.039747, 0.039148, 0.038559,
0.037971, 0.037399, 0.036839, 0.036278, 0.035732, 0.035198,
0.034672, 0.034145, 0.033636, 0.033133, 0.032635, 0.032148,
0.031670, 0.031122, 0.030647, 0.030184, 0.029728, 0.029272,
0.028831, 0.028395, 0.027966, 0.027538,
0.027122, 0.026712, 0.026304, 0.025906, 0.025515, 0.025129,
0.024746, 0.024372, 0.024002, 0.023636, 0.023279, 0.022926,
0.022581, 0.022236, 0.021900, 0.021570, 0.021240, 0.020920,
0.020605, 0.020294, 0.019983, 0.019684, 0.019386, 0.019094,
0.018805, 0.018520, 0.018242, 0.017965, 0.017696, 0.017431,
0.017170, 0.016911, 0.016657, 0.016409, 0.016163, 0.015923,
0.015686, 0.015411, 0.015177, 0.014946,
0.014721, 0.014496, 0.014277, 0.014061, 0.013847, 0.013636,
0.013430, 0.013227, 0.013025, 0.012829, 0.012634, 0.012444,
0.012253, 0.012068, 0.011887, 0.011703, 0.011528, 0.011353,
0.011183, 0.011011, 0.010845, 0.010681, 0.010517, 0.010359,
0.010202, 0.010050, 0.009895, 0.009747, 0.009600, 0.009453,
0.009312, 0.009172, 0.009033, 0.008896, 0.008762, 0.008633,
0.008501, 0.008375, 0.008249, 0.008125
};
const float AmbeLtable[120] = {
9, 9, 9, 9, 9, 9,
10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 13,
13, 13, 13, 13, 14, 14,
14, 14, 15, 15, 15, 15,
16, 16, 16, 16, 17, 17,
17, 17, 18, 18, 18, 18,
19, 19, 19, 20, 20, 20,
21, 21, 21, 22, 22, 22,
23, 23, 23, 24, 24, 24,
25, 25, 26, 26, 26, 27,
27, 28, 28, 29, 29, 30,
30, 30, 31, 31, 32, 32,
33, 33, 34, 34, 35, 36,
36, 37, 37, 38, 38, 39,
40, 40, 41, 42, 42, 43,
43, 44, 45, 46, 46, 47,
48, 48, 49, 50, 51, 52,
52, 53, 54, 55, 56, 56
};
/*
* V/UV Quantization Vectors
*/
const int AmbeVuv[32][8] = {
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 0, 1, 1, 1, 1, 1},
{1, 1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
/*
* V/UV Quantization Vectors
* alternate version
*/
/*
const int AmbeVuv[32][8] = {
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 1, 0, 1, 1, 1, 1, 1},
{1, 1, 1, 0, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 0, 1, 1},
{1, 1, 1, 1, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 0},
{1, 1, 1, 0, 0, 0, 0, 1},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 1, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
*/
/*
* Log Magnitude Prediction Residual Block Lengths
*/
const int AmbeLmprbl[57][4] = {
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{0, 0, 0, 0,},
{2, 2, 2, 3,},
{2, 2, 3, 3,},
{2, 3, 3, 3,},
{2, 3, 3, 4,},
{3, 3, 3, 4,},
{3, 3, 4, 4,},
{3, 3, 4, 5,},
{3, 4, 4, 5,},
{3, 4, 5, 5,},
{4, 4, 5, 5,},
{4, 4, 5, 6,},
{4, 4, 6, 6,},
{4, 5, 6, 6,},
{4, 5, 6, 7,},
{5, 5, 6, 7,},
{5, 5, 7, 7,},
{5, 6, 7, 7,},
{5, 6, 7, 8,},
{5, 6, 8, 8,},
{6, 6, 8, 8,},
{6, 6, 8, 9,},
{6, 7, 8, 9,},
{6, 7, 9, 9,},
{6, 7, 9, 10,},
{7, 7, 9, 10,},
{7, 8, 9, 10,},
{7, 8, 10, 10,},
{7, 8, 10, 11,},
{8, 8, 10, 11,},
{8, 9, 10, 11,},
{8, 9, 11, 11,},
{8, 9, 11, 12,},
{8, 9, 11, 13,},
{8, 9, 12, 13,},
{8, 10, 12, 13,},
{9, 10, 12, 13,},
{9, 10, 12, 14,},
{9, 10, 13, 14,},
{9, 11, 13, 14,},
{10, 11, 13, 14,},
{10, 11, 13, 15,},
{10, 11, 14, 15,},
{10, 12, 14, 15,},
{10, 12, 14, 16,},
{11, 12, 14, 16,},
{11, 12, 15, 16,},
{11, 12, 15, 17,},
{11, 13, 15, 17}
};
/*
* Gain Quantizer Levels
*/
const float AmbeDg[32] = { -2.0, -0.67, 0.297941, 0.663728, 1.036829, 1.438136, 1.890077, 2.227970,
2.478289, 2.667544, 2.793619, 2.893261, 3.020630, 3.138586, 3.237579, 3.322570,
3.432367, 3.571863, 3.696650, 3.814917, 3.920932, 4.022503, 4.123569, 4.228291,
4.370569, 4.543700, 4.707695, 4.848879, 5.056757, 5.326468, 5.777581, 6.874496
};
/*
* PRBA24 Vector Quantizer Levels
*/
const float AmbePRBA24[512][3] = {
{0.526055, -0.328567, -0.304727},
{0.441044, -0.303127, -0.201114},
{1.030896, -0.324730, -0.397204},
{0.839696, -0.351933, -0.224909},
{0.272958, -0.176118, -0.098893},
{0.221466, -0.160045, -0.061026},
{0.496555, -0.211499, 0.047305},
{0.424376, -0.223752, 0.069911},
{0.264531, -0.353355, -0.330505},
{0.273650, -0.253004, -0.250241},
{0.484531, -0.297627, -0.071051},
{0.410814, -0.224961, -0.084998},
{0.039519, -0.252904, -0.115128},
{0.017423, -0.296519, -0.045921},
{0.225113, -0.224371, 0.037882},
{0.183424, -0.260492, 0.050491},
{0.308704, -0.073205, -0.405880},
{0.213125, -0.101632, -0.333208},
{0.617735, -0.137299, -0.213670},
{0.514382, -0.126485, -0.170204},
{0.130009, -0.076955, -0.229303},
{0.061740, -0.108259, -0.203887},
{0.244473, -0.110094, -0.051689},
{0.230452, -0.076147, -0.028190},
{0.059837, -0.254595, -0.562704},
{0.011630, -0.135223, -0.432791},
{0.207077, -0.152248, -0.148391},
{0.158078, -0.128800, -0.122150},
{-0.265982, -0.144742, -0.199894},
{-0.356479, -0.204740, -0.156465},
{0.000324, -0.139549, -0.066471},
{0.001888, -0.170557, -0.025025},
{0.402913, -0.581478, -0.274626},
{0.191289, -0.540335, -0.193040},
{0.632914, -0.401410, -0.006636},
{0.471086, -0.463144, 0.061489},
{0.044829, -0.438487, 0.033433},
{0.015513, -0.539475, -0.006719},
{0.336218, -0.351311, 0.214087},
{0.239967, -0.380836, 0.157681},
{0.347609, -0.901619, -0.688432},
{0.064067, -0.826753, -0.492089},
{0.303089, -0.396757, -0.108446},
{0.235590, -0.446122, 0.006437},
{-0.236964, -0.652532, -0.135520},
{-0.418285, -0.793014, -0.034730},
{-0.038262, -0.516984, 0.273681},
{-0.037419, -0.958198, 0.214749},
{0.061624, -0.238233, -0.237184},
{-0.013944, -0.235704, -0.204811},
{0.286428, -0.210542, -0.029587},
{0.257656, -0.261837, -0.056566},
{-0.235852, -0.310760, -0.165147},
{-0.334949, -0.385870, -0.197362},
{0.094870, -0.241144, 0.059122},
{0.060177, -0.225884, 0.031140},
{-0.301184, -0.306545, -0.446189},
{-0.293528, -0.504146, -0.429844},
{-0.055084, -0.379015, -0.125887},
{-0.115434, -0.375008, -0.059939},
{-0.777425, -0.592163, -0.107585},
{-0.950500, -0.893847, -0.181762},
{-0.259402, -0.396726, 0.010357},
{-0.368905, -0.449026, 0.038299},
{0.279719, -0.063196, -0.184628},
{0.255265, -0.067248, -0.121124},
{0.458433, -0.103777, 0.010074},
{0.437231, -0.092496, -0.031028},
{0.082265, -0.028050, -0.041262},
{0.045920, -0.051719, -0.030155},
{0.271149, -0.043613, 0.112085},
{0.246881, -0.065274, 0.105436},
{0.056590, -0.117773, -0.142283},
{0.058824, -0.104418, -0.099608},
{0.213781, -0.111974, 0.031269},
{0.187554, -0.070340, 0.011834},
{-0.185701, -0.081106, -0.073803},
{-0.266112, -0.074133, -0.085370},
{-0.029368, -0.046490, 0.124679},
{-0.017378, -0.102882, 0.140482},
{0.114700, 0.092738, -0.244271},
{0.072922, 0.007863, -0.231476},
{0.270022, 0.031819, -0.094208},
{0.254403, 0.024805, -0.050389},
{-0.182905, 0.021629, -0.168481},
{-0.225864, -0.010109, -0.130374},
{0.040089, 0.013969, 0.016028},
{0.001442, 0.010551, 0.032942},
{-0.287472, -0.036130, -0.296798},
{-0.332344, -0.108862, -0.342196},
{0.012700, 0.022917, -0.052501},
{-0.040681, -0.001805, -0.050548},
{-0.718522, -0.061234, -0.278820},
{-0.879205, -0.213588, -0.303508},
{-0.234102, -0.065407, 0.013686},
{-0.281223, -0.076139, 0.046830},
{0.141967, -0.193679, -0.055697},
{0.100318, -0.161222, -0.063062},
{0.265859, -0.132747, 0.078209},
{0.244805, -0.139776, 0.122123},
{-0.121802, -0.179976, 0.031732},
{-0.185318, -0.214011, 0.018117},
{0.047014, -0.153961, 0.218068},
{0.047305, -0.187402, 0.282114},
{-0.027533, -0.415868, -0.333841},
{-0.125886, -0.334492, -0.290317},
{-0.030602, -0.190918, 0.097454},
{-0.054936, -0.209948, 0.158977},
{-0.507223, -0.295876, -0.217183},
{-0.581733, -0.403194, -0.208936},
{-0.299719, -0.289679, 0.297101},
{-0.363169, -0.362718, 0.436529},
{-0.124627, -0.042100, -0.157011},
{-0.161571, -0.092846, -0.183636},
{0.084520, -0.100217, -0.000901},
{0.055655, -0.136381, 0.032764},
{-0.545087, -0.197713, -0.026888},
{-0.662772, -0.179815, 0.026419},
{-0.165583, -0.148913, 0.090382},
{-0.240772, -0.182830, 0.105474},
{-0.576315, -0.359473, -0.456844},
{-0.713430, -0.554156, -0.476739},
{-0.275628, -0.223640, -0.051584},
{-0.359501, -0.230758, -0.027006},
{-1.282559, -0.284807, -0.233743},
{-1.060476, -0.399911, -0.562698},
{-0.871952, -0.272197, 0.016126},
{-0.747922, -0.329404, 0.276696},
{0.643086, 0.046175, -0.660078},
{0.738204, -0.127844, -0.433708},
{1.158072, 0.025571, -0.177856},
{0.974840, -0.009417, -0.112337},
{0.418014, 0.032741, -0.124545},
{0.381422, -0.001557, -0.085504},
{0.768280, 0.056085, 0.095375},
{0.680004, 0.052035, 0.152318},
{0.473182, 0.012560, -0.264221},
{0.345153, 0.036627, -0.248756},
{0.746238, -0.025880, -0.106050},
{0.644319, -0.058256, -0.095133},
{0.185924, -0.022230, -0.070540},
{0.146068, -0.009550, -0.057871},
{0.338488, 0.013022, 0.069961},
{0.298969, 0.047403, 0.052598},
{0.346002, 0.256253, -0.380261},
{0.313092, 0.163821, -0.314004},
{0.719154, 0.103108, -0.252648},
{0.621429, 0.172423, -0.265180},
{0.240461, 0.104684, -0.202582},
{0.206946, 0.139642, -0.138016},
{0.359915, 0.101273, -0.052997},
{0.318117, 0.125888, -0.003486},
{0.150452, 0.050219, -0.409155},
{0.188753, 0.091894, -0.325733},
{0.334922, 0.029098, -0.098587},
{0.324508, 0.015809, -0.135408},
{-0.042506, 0.038667, -0.208535},
{-0.083003, 0.094758, -0.174054},
{0.094773, 0.102653, -0.025701},
{0.063284, 0.118703, -0.000071},
{0.355965, -0.139239, -0.191705},
{0.392742, -0.105496, -0.132103},
{0.663678, -0.204627, -0.031242},
{0.609381, -0.146914, 0.079610},
{0.151855, -0.132843, -0.007125},
{0.146404, -0.161917, 0.024842},
{0.400524, -0.135221, 0.232289},
{0.324931, -0.116605, 0.253458},
{0.169066, -0.215132, -0.185604},
{0.128681, -0.189394, -0.160279},
{0.356194, -0.116992, -0.038381},
{0.342866, -0.144687, 0.020265},
{-0.065545, -0.202593, -0.043688},
{-0.124296, -0.260225, -0.035370},
{0.083224, -0.235149, 0.153301},
{0.046256, -0.309608, 0.190944},
{0.187385, -0.008168, -0.198575},
{0.190401, -0.018699, -0.136858},
{0.398009, -0.025700, -0.007458},
{0.346948, -0.022258, -0.020905},
{-0.047064, -0.085629, -0.080677},
{-0.067523, -0.128972, -0.119538},
{0.186086, -0.016828, 0.070014},
{0.187364, 0.017133, 0.075949},
{-0.112669, -0.037433, -0.298944},
{-0.068276, -0.114504, -0.265795},
{0.147510, -0.040616, -0.013687},
{0.133084, -0.062849, -0.032637},
{-0.416571, -0.041544, -0.125088},
{-0.505337, -0.044193, -0.157651},
{-0.154132, -0.075106, 0.050466},
{-0.148036, -0.059719, 0.121516},
{0.490555, 0.157659, -0.222208},
{0.436700, 0.120500, -0.205869},
{0.754525, 0.269323, 0.045810},
{0.645077, 0.271923, 0.013942},
{0.237023, 0.115337, -0.026429},
{0.204895, 0.121020, -0.008541},
{0.383999, 0.153963, 0.171763},
{0.385026, 0.222074, 0.239731},
{0.198232, 0.072972, -0.108179},
{0.147882, 0.074743, -0.123341},
{0.390929, 0.075205, 0.081828},
{0.341623, 0.089405, 0.069389},
{-0.003381, 0.159694, -0.016026},
{-0.043653, 0.206860, -0.040729},
{0.135515, 0.107824, 0.179310},
{0.081086, 0.119673, 0.174282},
{0.192637, 0.400335, -0.341906},
{0.171196, 0.284921, -0.221516},
{0.377807, 0.359087, -0.151523},
{0.411052, 0.297925, -0.099774},
{-0.010060, 0.261887, -0.149567},
{-0.107877, 0.287756, -0.116982},
{0.158003, 0.209727, 0.077988},
{0.109710, 0.232272, 0.088135},
{0.000698, 0.209353, -0.395208},
{-0.094015, 0.230322, -0.279928},
{0.137355, 0.230881, -0.124115},
{0.103058, 0.166855, -0.100386},
{-0.305058, 0.305422, -0.176026},
{-0.422049, 0.337137, -0.293297},
{-0.121744, 0.185124, 0.048115},
{-0.171052, 0.200312, 0.052812},
{0.224091, -0.010673, -0.019727},
{0.200266, -0.020167, 0.001798},
{0.382742, 0.032362, 0.161665},
{0.345631, -0.019705, 0.164451},
{0.029431, 0.045010, 0.071518},
{0.031940, 0.010876, 0.087037},
{0.181935, 0.039112, 0.202316},
{0.181810, 0.033189, 0.253435},
{-0.008677, -0.066679, -0.144737},
{-0.021768, -0.021288, -0.125903},
{0.136766, 0.000100, 0.059449},
{0.135405, -0.020446, 0.103793},
{-0.289115, 0.039747, -0.012256},
{-0.338683, 0.025909, -0.034058},
{-0.016515, 0.048584, 0.197981},
{-0.046790, 0.011816, 0.199964},
{0.094214, 0.127422, -0.169936},
{0.048279, 0.096189, -0.148153},
{0.217391, 0.081732, 0.013677},
{0.179656, 0.084671, 0.031434},
{-0.227367, 0.118176, -0.039803},
{-0.327096, 0.159747, -0.018931},
{0.000834, 0.113118, 0.125325},
{-0.014617, 0.128924, 0.163776},
{-0.254570, 0.154329, -0.232018},
{-0.353068, 0.124341, -0.174409},
{-0.061004, 0.107744, 0.037257},
{-0.100991, 0.080302, 0.062701},
{-0.927022, 0.285660, -0.240549},
{-1.153224, 0.277232, -0.322538},
{-0.569012, 0.108135, 0.172634},
{-0.555273, 0.131461, 0.325930},
{0.518847, 0.065683, -0.132877},
{0.501324, -0.006585, -0.094884},
{1.066190, -0.150380, 0.201791},
{0.858377, -0.166415, 0.081686},
{0.320584, -0.031499, 0.039534},
{0.311442, -0.075120, 0.026013},
{0.625829, -0.019856, 0.346041},
{0.525271, -0.003948, 0.284868},
{0.312594, -0.075673, -0.066642},
{0.295732, -0.057895, -0.042207},
{0.550446, -0.029110, 0.046850},
{0.465467, -0.068987, 0.096167},
{0.122669, -0.051786, 0.044283},
{0.079669, -0.044145, 0.045805},
{0.238778, -0.031835, 0.171694},
{0.200734, -0.072619, 0.178726},
{0.342512, 0.131270, -0.163021},
{0.294028, 0.111759, -0.125793},
{0.589523, 0.121808, -0.049372},
{0.550506, 0.132318, 0.017485},
{0.164280, 0.047560, -0.058383},
{0.120110, 0.049242, -0.052403},
{0.269181, 0.035000, 0.103494},
{0.297466, 0.038517, 0.139289},
{0.094549, -0.030880, -0.153376},
{0.080363, 0.024359, -0.127578},
{0.281351, 0.055178, 0.000155},
{0.234900, 0.039477, 0.013957},
{-0.118161, 0.011976, -0.034270},
{-0.157654, 0.027765, -0.005010},
{0.102631, 0.027283, 0.099723},
{0.077285, 0.052532, 0.115583},
{0.329398, -0.278552, 0.016316},
{0.305993, -0.267896, 0.094952},
{0.775270, -0.394995, 0.290748},
{0.583180, -0.252159, 0.285391},
{0.192226, -0.182242, 0.126859},
{0.185908, -0.245779, 0.159940},
{0.346293, -0.250404, 0.355682},
{0.354160, -0.364521, 0.472337},
{0.134942, -0.313666, -0.115181},
{0.126077, -0.286568, -0.039927},
{0.405618, -0.211792, 0.199095},
{0.312099, -0.213642, 0.190972},
{-0.071392, -0.297366, 0.081426},
{-0.165839, -0.301986, 0.160640},
{0.147808, -0.290712, 0.298198},
{0.063302, -0.310149, 0.396302},
{0.141444, -0.081377, -0.076621},
{0.115936, -0.104440, -0.039885},
{0.367023, -0.087281, 0.096390},
{0.330038, -0.117958, 0.127050},
{0.002897, -0.062454, 0.025151},
{-0.052404, -0.082200, 0.041975},
{0.181553, -0.137004, 0.230489},
{0.140768, -0.094604, 0.265928},
{-0.101763, -0.209566, -0.135964},
{-0.159056, -0.191005, -0.095509},
{0.045016, -0.081562, 0.075942},
{0.016808, -0.112482, 0.068593},
{-0.408578, -0.132377, 0.079163},
{-0.431534, -0.214646, 0.157714},
{-0.096931, -0.101938, 0.200304},
{-0.167867, -0.114851, 0.262964},
{0.393882, 0.086002, 0.008961},
{0.338747, 0.048405, -0.004187},
{0.877844, 0.374373, 0.171008},
{0.740790, 0.324525, 0.242248},
{0.200218, 0.070150, 0.085891},
{0.171760, 0.090531, 0.102579},
{0.314263, 0.126417, 0.322833},
{0.313523, 0.065445, 0.403855},
{0.164261, 0.057745, -0.005490},
{0.122141, 0.024122, 0.009190},
{0.308248, 0.078401, 0.180577},
{0.251222, 0.073868, 0.160457},
{-0.047526, 0.023725, 0.086336},
{-0.091643, 0.005539, 0.093179},
{0.079339, 0.044135, 0.206697},
{0.104213, 0.011277, 0.240060},
{0.226607, 0.186234, -0.056881},
{0.173281, 0.158131, -0.059413},
{0.339400, 0.214501, 0.052905},
{0.309166, 0.188181, 0.058028},
{0.014442, 0.194715, 0.048945},
{-0.028793, 0.194766, 0.089078},
{0.069564, 0.206743, 0.193568},
{0.091532, 0.202786, 0.269680},
{-0.071196, 0.135604, -0.103744},
{-0.118288, 0.152837, -0.060151},
{0.146856, 0.143174, 0.061789},
{0.104379, 0.143672, 0.056797},
{-0.541832, 0.250034, -0.017602},
{-0.641583, 0.278411, -0.111909},
{-0.094447, 0.159393, 0.164848},
{-0.113612, 0.120702, 0.221656},
{0.204918, -0.078894, 0.075524},
{0.161232, -0.090256, 0.088701},
{0.378460, -0.033687, 0.309964},
{0.311701, -0.049984, 0.316881},
{0.019311, -0.050048, 0.212387},
{0.002473, -0.062855, 0.278462},
{0.151448, -0.090652, 0.410031},
{0.162778, -0.071291, 0.531252},
{-0.083704, -0.076839, -0.020798},
{-0.092832, -0.043492, 0.029202},
{0.136844, -0.077791, 0.186493},
{0.089536, -0.086826, 0.184711},
{-0.270255, -0.058858, 0.173048},
{-0.350416, -0.009219, 0.273260},
{-0.105248, -0.205534, 0.425159},
{-0.135030, -0.197464, 0.623550},
{-0.051717, 0.069756, -0.043829},
{-0.081050, 0.056947, -0.000205},
{0.190388, 0.016366, 0.145922},
{0.142662, 0.002575, 0.159182},
{-0.352890, 0.011117, 0.091040},
{-0.367374, 0.056547, 0.147209},
{-0.003179, 0.026570, 0.282541},
{-0.069934, -0.005171, 0.337678},
{-0.496181, 0.026464, 0.019432},
{-0.690384, 0.069313, -0.004175},
{-0.146138, 0.046372, 0.161839},
{-0.197581, 0.034093, 0.241003},
{-0.989567, 0.040993, 0.049384},
{-1.151075, 0.210556, 0.237374},
{-0.335366, -0.058208, 0.480168},
{-0.502419, -0.093761, 0.675240},
{0.862548, 0.264137, -0.294905},
{0.782668, 0.251324, -0.122108},
{1.597797, 0.463818, -0.133153},
{1.615756, 0.060653, 0.084764},
{0.435588, 0.209832, 0.095050},
{0.431013, 0.165328, 0.047909},
{1.248164, 0.265923, 0.488086},
{1.009933, 0.345440, 0.473702},
{0.477017, 0.194237, -0.058012},
{0.401362, 0.186915, -0.054137},
{1.202158, 0.284782, -0.066531},
{1.064907, 0.203766, 0.046383},
{0.255848, 0.133398, 0.046049},
{0.218680, 0.128833, 0.065326},
{0.490817, 0.182041, 0.286583},
{0.440714, 0.106576, 0.301120},
{0.604263, 0.522925, -0.238629},
{0.526329, 0.377577, -0.198100},
{1.038632, 0.606242, -0.121253},
{0.995283, 0.552202, 0.110700},
{0.262232, 0.313664, -0.086909},
{0.230835, 0.273385, -0.054268},
{0.548466, 0.490721, 0.278201},
{0.466984, 0.355859, 0.289160},
{0.367137, 0.236160, -0.228114},
{0.309359, 0.233843, -0.171325},
{0.465268, 0.276569, 0.010951},
{0.378124, 0.250237, 0.011131},
{0.061885, 0.296810, -0.011420},
{0.000125, 0.350029, -0.011277},
{0.163815, 0.261191, 0.175863},
{0.165132, 0.308797, 0.227800},
{0.461418, 0.052075, -0.016543},
{0.472372, 0.046962, 0.045746},
{0.856406, 0.136415, 0.245074},
{0.834616, 0.003254, 0.372643},
{0.337869, 0.036994, 0.232513},
{0.267414, 0.027593, 0.252779},
{0.584983, 0.113046, 0.583119},
{0.475406, -0.024234, 0.655070},
{0.264823, -0.029292, 0.004270},
{0.246071, -0.019109, 0.030048},
{0.477401, 0.021039, 0.155448},
{0.458453, -0.043959, 0.187850},
{0.067059, -0.061227, 0.126904},
{0.044608, -0.034575, 0.150205},
{0.191304, -0.003810, 0.316776},
{0.153078, 0.029915, 0.361303},
{0.320704, 0.178950, -0.088835},
{0.300866, 0.137645, -0.056893},
{0.553442, 0.162339, 0.131987},
{0.490083, 0.123682, 0.146163},
{0.118950, 0.083109, 0.034052},
{0.099344, 0.066212, 0.054329},
{0.228325, 0.122445, 0.309219},
{0.172093, 0.135754, 0.323361},
{0.064213, 0.063405, -0.058243},
{0.011906, 0.088795, -0.069678},
{0.194232, 0.129185, 0.125708},
{0.155182, 0.174013, 0.144099},
{-0.217068, 0.112731, 0.093497},
{-0.307590, 0.171146, 0.110735},
{-0.014897, 0.138094, 0.232455},
{-0.036936, 0.170135, 0.279166},
{0.681886, 0.437121, 0.078458},
{0.548559, 0.376914, 0.092485},
{1.259194, 0.901494, 0.256085},
{1.296139, 0.607949, 0.302184},
{0.319619, 0.307231, 0.099647},
{0.287232, 0.359355, 0.186844},
{0.751306, 0.676688, 0.499386},
{0.479609, 0.553030, 0.560447},
{0.276377, 0.214032, -0.003661},
{0.238146, 0.223595, 0.028806},
{0.542688, 0.266205, 0.171393},
{0.460188, 0.283979, 0.158288},
{0.057385, 0.309853, 0.144517},
{-0.006881, 0.348152, 0.097310},
{0.244434, 0.247298, 0.322601},
{0.253992, 0.335420, 0.402241},
{0.354006, 0.579776, -0.130176},
{0.267043, 0.461976, -0.058178},
{0.534049, 0.626549, 0.046747},
{0.441835, 0.468260, 0.057556},
{0.110477, 0.628795, 0.102950},
{0.031409, 0.489068, 0.090605},
{0.229564, 0.525640, 0.325454},
{0.105570, 0.582151, 0.509738},
{0.005690, 0.521474, -0.157885},
{0.104463, 0.424022, -0.080647},
{0.223784, 0.389860, 0.060904},
{0.159806, 0.340571, 0.062061},
{-0.173976, 0.573425, 0.027383},
{-0.376008, 0.587868, 0.133042},
{-0.051773, 0.348339, 0.231923},
{-0.122571, 0.473049, 0.251159},
{0.324321, 0.148510, 0.116006},
{0.282263, 0.121730, 0.114016},
{0.690108, 0.256346, 0.418128},
{0.542523, 0.294427, 0.461973},
{0.056944, 0.107667, 0.281797},
{0.027844, 0.106858, 0.355071},
{0.160456, 0.177656, 0.528819},
{0.227537, 0.177976, 0.689465},
{0.111585, 0.097896, 0.109244},
{0.083994, 0.133245, 0.115789},
{0.208740, 0.142084, 0.208953},
{0.156072, 0.143303, 0.231368},
{-0.185830, 0.214347, 0.309774},
{-0.311053, 0.240517, 0.328512},
{-0.041749, 0.090901, 0.511373},
{-0.156164, 0.098486, 0.478020},
{0.151543, 0.263073, -0.033471},
{0.126322, 0.213004, -0.007014},
{0.245313, 0.217564, 0.120210},
{0.259136, 0.225542, 0.176601},
{-0.190632, 0.260214, 0.141755},
{-0.189271, 0.331768, 0.170606},
{0.054763, 0.294766, 0.357775},
{-0.033724, 0.257645, 0.365069},
{-0.184971, 0.396532, 0.057728},
{-0.293313, 0.400259, 0.001123},
{-0.015219, 0.232287, 0.177913},
{-0.022524, 0.244724, 0.240753},
{-0.520342, 0.347950, 0.249265},
{-0.671997, 0.410782, 0.153434},
{-0.253089, 0.412356, 0.489854},
{-0.410922, 0.562454, 0.543891}
};
/*
* PRBA58 Vector Quantizer Levels
*/
const float AmbePRBA58[128][4] = {
{-0.103660, 0.094597, -0.013149, 0.081501},
{-0.170709, 0.129958, -0.057316, 0.112324},
{-0.095113, 0.080892, -0.027554, 0.003371},
{-0.154153, 0.113437, -0.074522, 0.003446},
{-0.109553, 0.153519, 0.006858, 0.040930},
{-0.181931, 0.217882, -0.019042, 0.040049},
{-0.096246, 0.144191, -0.024147, -0.035120},
{-0.174811, 0.193357, -0.054261, -0.071700},
{-0.183241, -0.052840, 0.117923, 0.030960},
{-0.242634, 0.009075, 0.098007, 0.091643},
{-0.143847, -0.028529, 0.040171, -0.002812},
{-0.198809, 0.006990, 0.020668, 0.026641},
{-0.233172, -0.028793, 0.140130, -0.071927},
{-0.309313, 0.056873, 0.108262, -0.018930},
{-0.172782, -0.002037, 0.048755, -0.087065},
{-0.242901, 0.036076, 0.015064, -0.064366},
{0.077107, 0.172685, 0.159939, 0.097456},
{0.024820, 0.209676, 0.087347, 0.105204},
{0.085113, 0.151639, 0.084272, 0.022747},
{0.047975, 0.196695, 0.038770, 0.029953},
{0.113925, 0.236813, 0.176121, 0.016635},
{0.009708, 0.267969, 0.127660, 0.015872},
{0.114044, 0.202311, 0.096892, -0.043071},
{0.047219, 0.260395, 0.050952, -0.046996},
{-0.055095, 0.034041, 0.200464, 0.039050},
{-0.061582, 0.069566, 0.113048, 0.027511},
{-0.025469, 0.040440, 0.132777, -0.039098},
{-0.031388, 0.064010, 0.067559, -0.017117},
{-0.074386, 0.086579, 0.228232, -0.055461},
{-0.107352, 0.120874, 0.137364, -0.030252},
{-0.036897, 0.089972, 0.155831, -0.128475},
{-0.059070, 0.097879, 0.084489, -0.075821},
{-0.050865, -0.025167, -0.086636, 0.011256},
{-0.051426, 0.013301, -0.144665, 0.038541},
{-0.073831, -0.028917, -0.142416, -0.025268},
{-0.083910, 0.015004, -0.227113, -0.002808},
{-0.030840, -0.009326, -0.070517, -0.041304},
{-0.022018, 0.029381, -0.124961, -0.031624},
{-0.064222, -0.014640, -0.108798, -0.092342},
{-0.038801, 0.038133, -0.188992, -0.094221},
{-0.154059, -0.183932, -0.019894, 0.082105},
{-0.188022, -0.113072, -0.117380, 0.090911},
{-0.243301, -0.207086, -0.053735, -0.001975},
{-0.275931, -0.121035, -0.161261, 0.004231},
{-0.118142, -0.157537, -0.036594, -0.008679},
{-0.153627, -0.111372, -0.103095, -0.009460},
{-0.173458, -0.180158, -0.057130, -0.103198},
{-0.208509, -0.127679, -0.149336, -0.109289},
{0.096310, 0.047927, -0.024094, -0.057018},
{0.044289, 0.075486, -0.008505, -0.067635},
{0.076751, 0.025560, -0.066428, -0.102991},
{0.025215, 0.090417, -0.058616, -0.114284},
{0.125980, 0.070078, 0.016282, -0.112355},
{0.070859, 0.118988, 0.001180, -0.116359},
{0.097520, 0.059219, -0.026821, -0.172850},
{0.048226, 0.145459, -0.050093, -0.188853},
{0.007242, -0.135796, 0.147832, -0.034080},
{0.012843, -0.069616, 0.077139, -0.047909},
{-0.050911, -0.116323, 0.082521, -0.056362},
{-0.039630, -0.055678, 0.036066, -0.067992},
{0.042694, -0.091527, 0.150940, -0.124225},
{0.029225, -0.039401, 0.071664, -0.113665},
{-0.025085, -0.099013, 0.074622, -0.138674},
{-0.031220, -0.035717, 0.020870, -0.143376},
{0.040638, 0.087903, -0.049500, 0.094607},
{0.026860, 0.125924, -0.103449, 0.140882},
{0.075166, 0.110186, -0.115173, 0.067330},
{0.036642, 0.163193, -0.188762, 0.103724},
{0.028179, 0.095124, -0.053258, 0.028900},
{0.002307, 0.148211, -0.096037, 0.046189},
{0.072227, 0.137595, -0.095629, 0.001339},
{0.033308, 0.221480, -0.152201, 0.012125},
{0.003458, -0.085112, 0.041850, 0.113836},
{-0.040610, -0.044880, 0.029732, 0.177011},
{0.011404, -0.054324, -0.012426, 0.077815},
{-0.042413, -0.030930, -0.034844, 0.122946},
{-0.002206, -0.045698, 0.050651, 0.054886},
{-0.041729, -0.016110, 0.048005, 0.102125},
{0.013963, -0.022204, 0.001613, 0.028997},
{-0.030218, -0.002052, -0.004365, 0.065343},
{0.299049, 0.046260, 0.076320, 0.070784},
{0.250160, 0.098440, 0.012590, 0.137479},
{0.254170, 0.095310, 0.018749, 0.004288},
{0.218892, 0.145554, -0.035161, 0.069784},
{0.303486, 0.101424, 0.135996, -0.013096},
{0.262919, 0.165133, 0.077237, 0.071721},
{0.319358, 0.170283, 0.054554, -0.072210},
{0.272983, 0.231181, -0.014471, 0.011689},
{0.134116, -0.026693, 0.161400, 0.110292},
{0.100379, 0.026517, 0.086236, 0.130478},
{0.144718, -0.000895, 0.093767, 0.044514},
{0.114943, 0.022145, 0.035871, 0.069193},
{0.122051, 0.011043, 0.192803, 0.022796},
{0.079482, 0.026156, 0.117725, 0.056565},
{0.124641, 0.027387, 0.122956, -0.025369},
{0.090708, 0.027357, 0.064450, 0.013058},
{0.159781, -0.055202, -0.090597, 0.151598},
{0.084577, -0.037203, -0.126698, 0.119739},
{0.192484, -0.100195, -0.162066, 0.104148},
{0.114579, -0.046270, -0.219547, 0.100067},
{0.153083, -0.010127, -0.086266, 0.068648},
{0.088202, -0.010515, -0.102196, 0.046281},
{0.164494, -0.057325, -0.132860, 0.024093},
{0.109419, -0.013999, -0.169596, 0.020412},
{0.039180, -0.209168, -0.035872, 0.087949},
{0.012790, -0.177723, -0.129986, 0.073364},
{0.045261, -0.256694, -0.088186, 0.004212},
{-0.005314, -0.231202, -0.191671, -0.002628},
{0.037963, -0.153227, -0.045364, 0.003322},
{0.030800, -0.126452, -0.114266, -0.010414},
{0.044125, -0.184146, -0.081400, -0.077341},
{0.029204, -0.157393, -0.172017, -0.089814},
{0.393519, -0.043228, -0.111365, -0.000740},
{0.289581, 0.018928, -0.123140, 0.000713},
{0.311229, -0.059735, -0.198982, -0.081664},
{0.258659, 0.052505, -0.211913, -0.034928},
{0.300693, 0.011381, -0.083545, -0.086683},
{0.214523, 0.053878, -0.101199, -0.061018},
{0.253422, 0.028496, -0.156752, -0.163342},
{0.199123, 0.113877, -0.166220, -0.102584},
{0.249134, -0.165135, 0.028917, 0.051838},
{0.156434, -0.123708, 0.017053, 0.043043},
{0.214763, -0.101243, -0.005581, -0.020703},
{0.140554, -0.072067, -0.015063, -0.011165},
{0.241791, -0.152048, 0.106403, -0.046857},
{0.142316, -0.131899, 0.054076, -0.026485},
{0.206535, -0.086116, 0.046640, -0.097615},
{0.129759, -0.081874, 0.004693, -0.073169}
};
/*
* Higher Order Coefficients
*/
const float AmbeHOCb5[32][4] = {
{0.264108, 0.045976, -0.200999, -0.122344},
{0.479006, 0.227924, -0.016114, -0.006835},
{0.077297, 0.080775, -0.068936, 0.041733},
{0.185486, 0.231840, 0.182410, 0.101613},
{-0.012442, 0.223718, -0.277803, -0.034370},
{-0.059507, 0.139621, -0.024708, -0.104205},
{-0.248676, 0.255502, -0.134894, -0.058338},
{-0.055122, 0.427253, 0.025059, -0.045051},
{-0.058898, -0.061945, 0.028030, -0.022242},
{0.084153, 0.025327, 0.066780, -0.180839},
{-0.193125, -0.082632, 0.140899, -0.089559},
{0.000000, 0.033758, 0.276623, 0.002493},
{-0.396582, -0.049543, -0.118100, -0.208305},
{-0.287112, 0.096620, 0.049650, -0.079312},
{-0.543760, 0.171107, -0.062173, -0.010483},
{-0.353572, 0.227440, 0.230128, -0.032089},
{0.248579, -0.279824, -0.209589, 0.070903},
{0.377604, -0.119639, 0.008463, -0.005589},
{0.102127, -0.093666, -0.061325, 0.052082},
{0.154134, -0.105724, 0.099317, 0.187972},
{-0.139232, -0.091146, -0.275479, -0.038435},
{-0.144169, 0.034314, -0.030840, 0.022207},
{-0.143985, 0.079414, -0.194701, 0.175312},
{-0.195329, 0.087467, 0.067711, 0.186783},
{-0.123515, -0.377873, -0.209929, -0.212677},
{0.068698, -0.255933, 0.120463, -0.095629},
{-0.106810, -0.319964, -0.089322, 0.106947},
{-0.158605, -0.309606, 0.190900, 0.089340},
{-0.489162, -0.432784, -0.151215, -0.005786},
{-0.370883, -0.154342, -0.022545, 0.114054},
{-0.742866, -0.204364, -0.123865, -0.038888},
{-0.573077, -0.115287, 0.208879, -0.027698}
};
/*
* Higher Order Coefficients
*/
const float AmbeHOCb6[16][4] = {
{-0.143886, 0.235528, -0.116707, 0.025541},
{-0.170182, -0.063822, -0.096934, 0.109704},
{0.232915, 0.269793, 0.047064, -0.032761},
{0.153458, 0.068130, -0.033513, 0.126553},
{-0.440712, 0.132952, 0.081378, -0.013210},
{-0.480433, -0.249687, -0.012280, 0.007112},
{-0.088001, 0.167609, 0.148323, -0.119892},
{-0.104628, 0.102639, 0.183560, 0.121674},
{0.047408, -0.000908, -0.214196, -0.109372},
{0.113418, -0.240340, -0.121420, 0.041117},
{0.385609, 0.042913, -0.184584, -0.017851},
{0.453830, -0.180745, 0.050455, 0.030984},
{-0.155984, -0.144212, 0.018226, -0.146356},
{-0.104028, -0.260377, 0.146472, 0.101389},
{0.012376, -0.000267, 0.006657, -0.013941},
{0.165852, -0.103467, 0.119713, -0.075455}
};
/*
* Higher Order Coefficients
*/
const float AmbeHOCb7[16][4] = {
{0.182478, 0.271794, -0.057639, 0.026115},
{0.110795, 0.092854, 0.078125, -0.082726},
{0.057964, 0.000833, 0.176048, 0.135404},
{-0.027315, 0.098668, -0.065801, 0.116421},
{-0.222796, 0.062967, 0.201740, -0.089975},
{-0.193571, 0.309225, -0.014101, -0.034574},
{-0.389053, -0.181476, 0.107682, 0.050169},
{-0.345604, 0.064900, -0.065014, 0.065642},
{0.319393, -0.055491, -0.220727, -0.067499},
{0.460572, 0.084686, 0.048453, -0.011050},
{0.201623, -0.068994, -0.067101, 0.108320},
{0.227528, -0.173900, 0.092417, -0.066515},
{-0.016927, 0.047757, -0.177686, -0.102163},
{-0.052553, -0.065689, 0.019328, -0.033060},
{-0.144910, -0.238617, -0.195206, -0.063917},
{-0.024159, -0.338822, 0.003581, 0.060995}
};
/*
* Higher Order Coefficients
*/
const float AmbeHOCb8[8][4] = {
{0.323968, 0.008964, -0.063117, 0.027909},
{0.010900, -0.004030, -0.125016, -0.080818},
{0.109969, 0.256272, 0.042470, 0.000749},
{-0.135446, 0.201769, -0.083426, 0.093888},
{-0.441995, 0.038159, 0.022784, 0.003943},
{-0.155951, 0.032467, 0.145309, -0.041725},
{-0.149182, -0.223356, -0.065793, 0.075016},
{0.096949, -0.096400, 0.083194, 0.049306}
};
}
#endif
-29
View File
@@ -1,29 +0,0 @@
#ifndef QSO_DSTAR_PITCH_H
#define QSO_DSTAR_PITCH_H
extern "C" {
#define DSTAR_F0_C0 4.24734f
#define DSTAR_F0_C1 0.021762f
#define DSTAR_SPEC_PRED 0.8f
#define DSTAR_GAIN_ADJUST 1.8f
#define DSTAR_GAIN_SMOOTH 0.55f
#define DSTAR_OUT_GAIN_DB 5.4f
static const unsigned char DSTAR_CHIP_L[120] = {
9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10,
10, 10, 10, 11, 11, 11, 11, 11, 11, 12, 12, 12,
12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15,
15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17,
18, 18, 18, 19, 19, 19, 20, 20, 20, 20, 21, 21,
21, 22, 22, 22, 23, 23, 23, 24, 24, 25, 25, 25,
26, 26, 27, 27, 27, 28, 28, 29, 29, 30, 30, 30,
31, 31, 32, 32, 33, 33, 34, 34, 35, 36, 36, 37,
37, 38, 38, 39, 40, 40, 41, 41, 42, 43, 43, 44,
45, 45, 46, 47, 47, 48, 49, 50, 50, 51, 52, 53
};
#define DSTAR_L(b0) ((int) DSTAR_CHIP_L[((b0) < 0) ? 0 : (((b0) > 119) ? 119 : (b0))])
#define DSTAR_DEC_VOICED_DB 0.0f
#define DSTAR_DEC_UNVOICED_DB (-4.5f)
#define DSTAR_DEC_PITCH_DB_PER_OCT 1.0f
#define DSTAR_DEC_PITCH_REF_HZ 125.0f
#endif
}
-173
View File
@@ -1,173 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <math.h>
#include "ecc_const.h"
extern "C" {
void
mbe_checkGolayBlock (long int *block)
{
static int i, syndrome, eccexpected, eccbits, databits;
long int mask, block_l;
block_l = *block;
mask = 0x400000l;
eccexpected = 0;
for (i = 0; i < 12; i++)
{
if ((block_l & mask) != 0l)
{
eccexpected ^= golayGenerator[i];
}
mask = mask >> 1;
}
eccbits = (int) (block_l & 0x7ffl);
syndrome = eccexpected ^ eccbits;
databits = (int) (block_l >> 11);
databits = databits ^ golayMatrix[syndrome];
*block = (long) databits;
}
int
mbe_golay2312 (char *in, char *out)
{
int i, errs;
long block;
block = 0;
for (i = 22; i >= 0; i--)
{
block = block << 1;
block = block + in[i];
}
mbe_checkGolayBlock (&block);
for (i = 22; i >= 11; i--)
{
out[i] = (block & 2048) >> 11;
block = block << 1;
}
for (i = 10; i >= 0; i--)
{
out[i] = in[i];
}
errs = 0;
for (i = 22; i >= 11; i--)
{
if (out[i] != in[i])
{
errs++;
}
}
return (errs);
}
int
mbe_hamming1511 (char *in, char *out)
{
int i, j, errs, block, syndrome, stmp, stmp2;
errs = 0;
block = 0;
for (i = 14; i >= 0; i--)
{
block <<= 1;
block |= in[i];
}
syndrome = 0;
for (i = 0; i < 4; i++)
{
syndrome <<= 1;
stmp = block;
stmp &= hammingGenerator[i];
stmp2 = (stmp % 2);
for (j = 0; j < 14; j++)
{
stmp >>= 1;
stmp2 ^= (stmp % 2);
}
syndrome |= stmp2;
}
if (syndrome > 0)
{
errs++;
block ^= hammingMatrix[syndrome];
}
for (i = 14; i >= 0; i--)
{
out[i] = (block & 0x4000) >> 14;
block = block << 1;
}
return (errs);
}
int
mbe_7100x4400hamming1511 (char *in, char *out)
{
int i, j, errs, block, syndrome, stmp, stmp2;
errs = 0;
block = 0;
for (i = 14; i >= 0; i--)
{
block <<= 1;
block |= in[i];
}
syndrome = 0;
for (i = 0; i < 4; i++)
{
syndrome <<= 1;
stmp = block;
stmp &= imbe7100x4400hammingGenerator[i];
stmp2 = (stmp % 2);
for (j = 0; j < 14; j++)
{
stmp >>= 1;
stmp2 ^= (stmp % 2);
}
syndrome |= stmp2;
}
if (syndrome > 0)
{
errs++;
block ^= hammingMatrix[syndrome];
}
for (i = 14; i >= 0; i--)
{
out[i] = (block & 0x4000) >> 14;
block = block << 1;
}
return (errs);
}
}
-112
View File
@@ -1,112 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* constants for ecc.c
*/
#ifndef _ECC_H
#define _ECC_H
extern "C" {
const int hammingGenerator[4] = {
0x7f08, 0x78e4, 0x66d2, 0x55b1
};
const int imbe7100x4400hammingGenerator[4] = {
0x7ac8, 0x3d64, 0x1eb2, 0x7591
};
const int hammingMatrix[16] = {
0x0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000
};
const int golayGenerator[12] = {
0x63a, 0x31d, 0x7b4, 0x3da, 0x1ed, 0x6cc, 0x366, 0x1b3, 0x6e3, 0x54b, 0x49f, 0x475
};
const int golayMatrix[2048] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 2084, 0, 0, 0, 769, 0, 1024, 144,
2, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 72, 0, 72, 72, 72, 0, 0, 0, 16, 0, 1, 1538, 384, 0, 134, 2048, 1056, 288,
2576, 5, 72, 0, 0, 0, 0, 0, 0, 0, 1280, 0, 0, 0, 4, 0, 546, 144, 2049, 0, 0, 0, 66, 0, 1, 144, 520, 0, 2056, 144,
1056, 144, 324, 144, 144, 0, 0, 0, 2688, 0, 1, 32, 22, 0, 272, 3, 1056, 3076, 128, 768, 72, 0, 1, 268, 1056, 1, 1, 2112, 1, 576,
1056, 1056, 1056, 10, 1, 144, 1056, 0, 0, 0, 0, 0, 0, 0, 1280, 0, 0, 0, 160, 0, 21, 2560, 2, 0, 0, 0, 16, 0, 704, 9,
2, 0, 2056, 1092, 2, 288, 2, 2, 2, 0, 0, 0, 16, 0, 2050, 132, 545, 0, 1536, 3, 2308, 288, 128, 1040, 72, 0, 16, 16, 16, 288,
1036, 2112, 16, 288, 65, 648, 16, 288, 288, 288, 2, 0, 0, 0, 1280, 0, 1280, 1280, 1280, 0, 2056, 3, 592, 64, 128, 44, 1280, 0, 2056, 544,
133, 6, 48, 2112, 1280, 2056, 2056, 256, 2056, 1537, 2056, 144, 2, 0, 100, 3, 8, 536, 128, 2112, 1280, 3, 128, 3, 3, 128, 128, 3, 128, 1152,
770, 2112, 16, 2112, 1, 2112, 2112, 20, 2056, 3, 1056, 288, 128, 2112, 516, 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, 4, 0, 1024, 2560,
304, 0, 0, 0, 16, 0, 1024, 320, 520, 0, 1024, 42, 2240, 1024, 1024, 5, 1024, 0, 0, 0, 16, 0, 772, 32, 3072, 0, 2081, 1408, 514, 18,
128, 5, 72, 0, 16, 16, 16, 2184, 98, 5, 16, 576, 264, 5, 16, 5, 1024, 5, 5, 0, 0, 0, 4, 0, 2128, 32, 520, 0, 4, 4,
4, 265, 128, 1090, 4, 0, 416, 3073, 520, 6, 520, 520, 520, 576, 19, 256, 4, 2080, 1024, 144, 520, 0, 1034, 32, 321, 32, 128, 32, 32, 576,
128, 2072, 4, 128, 128, 32, 128, 576, 2052, 130, 16, 1296, 1, 32, 520, 576, 576, 576, 1056, 576, 128, 5, 2306, 0, 0, 0, 16, 0, 40, 2560,
68, 0, 322, 2560, 1033, 2560, 128, 2560, 2560, 0, 16, 16, 16, 6, 2305, 1184, 16, 129, 548, 256, 16, 88, 1024, 2560, 2, 0, 16, 16, 16, 1089,
128, 266, 16, 12, 128, 96, 16, 128, 128, 2560, 128, 16, 16, 16, 16, 512, 16, 16, 16, 3074, 16, 16, 16, 288, 128, 5, 16, 0, 513, 200,
2082, 6, 128, 17, 1280, 1072, 128, 256, 4, 128, 128, 2560, 128, 6, 1088, 256, 16, 6, 6, 6, 520, 256, 2056, 256, 256, 6, 128, 256, 97, 2304,
128, 1540, 16, 128, 128, 32, 128, 128, 128, 3, 128, 128, 128, 128, 128, 41, 16, 16, 16, 6, 128, 2112, 16, 576, 128, 256, 16, 128, 128, 1032,
128, 0, 0, 0, 0, 0, 0, 0, 528, 0, 0, 0, 160, 0, 1024, 262, 2049, 0, 0, 0, 66, 0, 1024, 9, 384, 0, 1024, 2048, 28, 1024,
1024, 608, 1024, 0, 0, 0, 1029, 0, 2050, 32, 384, 0, 272, 2048, 514, 641, 36, 1040, 72, 0, 552, 2048, 384, 84, 384, 384, 384, 2048, 65, 2048,
2048, 10, 1024, 2048, 384, 0, 0, 0, 66, 0, 140, 32, 2049, 0, 272, 1544, 2049, 64, 2049, 2049, 2049, 0, 66, 66, 66, 2816, 48, 1028, 66, 37,
640, 256, 66, 10, 1024, 144, 2049, 0, 272, 32, 8, 32, 1600, 32, 32, 272, 272, 196, 272, 10, 272, 32, 2049, 1152, 2052, 529, 66, 10, 1, 32,
384, 10, 272, 2048, 1056, 10, 10, 10, 516, 0, 0, 0, 160, 0, 2050, 9, 68, 0, 160, 160, 160, 64, 776, 1040, 160, 0, 260, 9, 3584, 9,
48, 9, 9, 530, 65, 256, 160, 2180, 1024, 9, 2, 0, 2050, 832, 8, 2050, 2050, 1040, 2050, 12, 65, 1040, 160, 1040, 2050, 1040, 1040, 1152, 65, 38,
16, 512, 2050, 9, 384, 65, 65, 2048, 65, 288, 65, 1040, 516, 0, 513, 2068, 8, 64, 48, 642, 1280, 64, 1030, 256, 160, 64, 64, 64, 2049, 1152,
48, 256, 66, 48, 48, 9, 48, 256, 2056, 256, 256, 64, 48, 256, 516, 1152, 8, 8, 8, 261, 2050, 32, 8, 2592, 272, 3, 8, 64, 128, 1040,
516, 1152, 1152, 1152, 8, 1152, 48, 2112, 516, 1152, 65, 256, 516, 10, 516, 516, 516, 0, 0, 0, 2312, 0, 1024, 32, 68, 0, 1024, 81, 514, 1024,
1024, 136, 1024, 0, 1024, 644, 33, 1024, 1024, 2066, 1024, 1024, 1024, 256, 1024, 1024, 1024, 1024, 1024, 0, 192, 32, 514, 32, 25, 32, 32, 12, 514, 514,
514, 2368, 1024, 32, 514, 259, 2052, 1096, 16, 512, 1024, 32, 384, 176, 1024, 2048, 514, 1024, 1024, 5, 1024, 0, 513, 32, 1168, 32, 258, 32, 32, 2178,
104, 256, 4, 532, 1024, 32, 2049, 24, 2052, 256, 66, 193, 1024, 32, 520, 256, 1024, 256, 256, 1024, 1024, 256, 1024, 32, 2052, 32, 32, 32, 32, 32,
32, 1025, 272, 32, 514, 32, 128, 32, 32, 2052, 2052, 32, 2052, 32, 2052, 32, 32, 576, 2052, 256, 137, 10, 1024, 32, 80, 0, 513, 1026, 68, 400,
68, 68, 68, 12, 2064, 256, 160, 35, 1024, 2560, 68, 2144, 138, 256, 16, 512, 1024, 9, 68, 256, 1024, 256, 256, 1024, 1024, 256, 1024, 12, 1312, 2177,
16, 512, 2050, 32, 68, 12, 12, 12, 514, 12, 128, 1040, 257, 512, 16, 16, 16, 512, 512, 512, 16, 12, 65, 256, 16, 512, 1024, 194, 2088, 513,
513, 256, 513, 3080, 513, 32, 68, 256, 513, 256, 256, 64, 128, 256, 26, 256, 513, 256, 256, 6, 48, 256, 2176, 256, 256, 256, 256, 256, 1024, 256,
256, 82, 513, 32, 8, 32, 128, 32, 32, 12, 128, 256, 3136, 128, 128, 32, 128, 1152, 2052, 256, 16, 512, 328, 32, 1027, 256, 34, 256, 256, 2065,
128, 256, 516, 0, 0, 0, 0, 0, 0, 0, 528, 0, 0, 0, 4, 0, 2432, 1057, 2, 0, 0, 0, 1160, 0, 1, 320, 2, 0, 112, 2048,
2, 524, 2, 2, 2, 0, 0, 0, 290, 0, 1, 132, 3072, 0, 1536, 2048, 145, 18, 36, 768, 72, 0, 1, 2048, 580, 1, 1, 56, 1, 2048,
264, 2048, 2048, 1216, 1, 2048, 2, 0, 0, 0, 4, 0, 1, 2058, 224, 0, 4, 4, 4, 64, 1048, 768, 4, 0, 1, 544, 2320, 1, 1, 1028,
1, 1282, 640, 73, 4, 2080, 1, 144, 2, 0, 1, 1104, 8, 1, 1, 768, 1, 168, 2114, 768, 4, 768, 1, 768, 768, 1, 1, 130, 1, 1,
1, 1, 1, 20, 1, 2048, 1056, 1, 1, 768, 1, 0, 0, 0, 2113, 0, 40, 132, 2, 0, 1536, 280, 2, 64, 2, 2, 2, 0, 260, 544,
2, 3088, 2, 2, 2, 129, 2, 2, 2, 2, 2, 2, 2, 0, 1536, 132, 8, 132, 336, 132, 132, 1536, 1536, 96, 1536, 2057, 1536, 132, 2, 74,
2208, 1281, 16, 512, 1, 132, 2, 20, 1536, 2048, 2, 288, 2, 2, 2, 0, 146, 544, 8, 64, 2564, 17, 1280, 64, 289, 3200, 4, 64, 64, 64,
2, 544, 1088, 544, 544, 392, 1, 544, 2, 20, 2056, 544, 2, 64, 2, 2, 2, 2304, 8, 8, 8, 1058, 1, 132, 8, 20, 1536, 3, 8, 64,
128, 768, 2096, 20, 1, 544, 8, 1, 1, 2112, 1, 20, 20, 20, 448, 20, 1, 1032, 2, 0, 0, 0, 4, 0, 40, 320, 3072, 0, 4, 4,
4, 18, 577, 136, 4, 0, 2562, 320, 33, 320, 148, 320, 320, 129, 264, 1552, 4, 2080, 1024, 320, 2, 0, 192, 521, 3072, 18, 3072, 3072, 3072, 18,
264, 96, 4, 18, 18, 18, 3072, 1060, 264, 130, 16, 512, 1, 320, 3072, 264, 264, 2048, 264, 18, 264, 5, 672, 0, 4, 4, 4, 1664, 258, 17,
4, 4, 4, 4, 4, 2080, 4, 4, 4, 24, 1088, 130, 4, 2080, 1, 320, 520, 2080, 4, 4, 4, 2080, 2080, 2080, 4, 2304, 560, 130, 4, 76,
1, 32, 3072, 1025, 4, 4, 4, 18, 128, 768, 4, 130, 1, 130, 130, 1, 1, 130, 1, 576, 264, 130, 4, 2080, 1, 1032, 80, 0, 40, 1026,
896, 40, 40, 17, 40, 129, 2064, 96, 4, 1284, 40, 2560, 2, 129, 1088, 2060, 16, 512, 40, 320, 2, 129, 129, 129, 2, 129, 2, 2, 2, 2304,
7, 96, 16, 512, 40, 132, 3072, 96, 1536, 96, 96, 18, 128, 96, 257, 512, 16, 16, 16, 512, 512, 512, 16, 129, 264, 96, 16, 512, 2116, 1032,
2, 2304, 1088, 17, 4, 17, 40, 17, 17, 522, 4, 4, 4, 64, 128, 17, 4, 1088, 1088, 544, 1088, 6, 1088, 17, 2176, 129, 1088, 256, 4, 2080,
784, 1032, 2, 2304, 2304, 2304, 8, 2304, 128, 17, 578, 2304, 128, 96, 4, 128, 128, 1032, 128, 2304, 1088, 130, 16, 512, 1, 1032, 292, 20, 34, 1032,
2561, 1032, 128, 1032, 1032, 0, 0, 0, 528, 0, 528, 528, 528, 0, 11, 2048, 1344, 64, 36, 136, 528, 0, 260, 2048, 33, 162, 2120, 1028, 528, 2048,
640, 2048, 2048, 273, 1024, 2048, 2, 0, 192, 2048, 8, 1288, 36, 67, 528, 2048, 36, 2048, 2048, 36, 36, 2048, 36, 2048, 1042, 2048, 2048, 512, 1, 2048,
384, 2048, 2048, 2048, 2048, 2048, 36, 2048, 2048, 0, 3104, 385, 8, 64, 258, 1028, 528, 64, 640, 50, 4, 64, 64, 64, 2049, 24, 640, 1028, 66, 1028,
1, 1028, 1028, 640, 640, 2048, 640, 64, 640, 1028, 296, 518, 8, 8, 8, 2192, 1, 32, 8, 1025, 272, 2048, 8, 64, 36, 768, 1154, 352, 1, 2048,
8, 1, 1, 1028, 1, 2048, 640, 2048, 2048, 10, 1, 2048, 80, 0, 260, 1026, 8, 64, 1153, 2336, 528, 64, 2064, 517, 160, 64, 64, 64, 2, 260,
260, 208, 260, 512, 260, 9, 2, 1064, 260, 2048, 2, 64, 2, 2, 2, 49, 8, 8, 8, 512, 2050, 132, 8, 386, 1536, 2048, 8, 64, 36, 1040,
257, 512, 260, 2048, 8, 512, 512, 512, 1120, 2048, 65, 2048, 2048, 512, 152, 2048, 2, 64, 8, 8, 8, 64, 64, 64, 8, 64, 64, 64, 8, 64,
64, 64, 64, 2051, 260, 544, 8, 64, 48, 1028, 2176, 64, 640, 256, 1041, 64, 64, 64, 2, 8, 8, 8, 8, 64, 8, 8, 8, 64, 8, 8,
8, 64, 64, 64, 8, 1152, 8, 8, 8, 512, 1, 274, 8, 20, 34, 2048, 8, 64, 3328, 161, 516, 0, 192, 1026, 33, 2053, 258, 136, 528, 800,
2064, 136, 4, 136, 1024, 136, 136, 24, 33, 33, 33, 512, 1024, 320, 33, 70, 1024, 2048, 33, 1024, 1024, 136, 1024, 192, 192, 276, 192, 512, 192, 32,
3072, 1025, 192, 2048, 514, 18, 36, 136, 257, 512, 192, 2048, 33, 512, 512, 512, 14, 2048, 264, 2048, 2048, 512, 1024, 2048, 80, 24, 258, 2624, 4, 258,
258, 32, 258, 1025, 4, 4, 4, 64, 258, 136, 4, 24, 24, 24, 33, 24, 258, 1028, 2176, 24, 640, 256, 4, 2080, 1024, 515, 80, 1025, 192, 32,
8, 32, 258, 32, 32, 1025, 1025, 1025, 4, 1025, 2568, 32, 80, 24, 2052, 130, 1792, 512, 1, 32, 80, 1025, 34, 2048, 80, 388, 80, 80, 80, 1026,
2064, 1026, 1026, 512, 40, 1026, 68, 2064, 2064, 1026, 2064, 64, 2064, 136, 257, 512, 260, 1026, 33, 512, 512, 512, 2176, 129, 2064, 256, 584, 512, 1024, 52,
2, 512, 192, 1026, 8, 512, 512, 512, 257, 12, 2064, 96, 257, 512, 257, 257, 257, 512, 512, 512, 16, 512, 512, 512, 512, 512, 34, 2048, 1156, 512,
512, 512, 257, 164, 513, 1026, 8, 64, 258, 17, 2176, 64, 2064, 256, 4, 64, 64, 64, 1568, 24, 1088, 256, 2176, 512, 2176, 2176, 2176, 256, 34, 256,
256, 64, 13, 256, 2176, 2304, 8, 8, 8, 512, 1044, 32, 8, 1025, 34, 656, 8, 64, 128, 2054, 257, 512, 34, 69, 8, 512, 512, 512, 2176, 34,
34, 256, 34, 512, 34, 1032, 80
};
}
#endif
-501
View File
@@ -1,501 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "mbelib.h"
#include "mbelib_const.h"
/**
* \return A pseudo-random float between [0.0, 1.0].
* See http://www.azillionmonkeys.com/qed/random.html for further improvements
*/
static float
mbe_rand()
{
return ((float) rand () / (float) RAND_MAX);
}
/**
* \return A pseudo-random float between [-pi, +pi].
*/
static float
mbe_rand_phase()
{
return mbe_rand() * (((float)M_PI) * 2.0F) - ((float)M_PI);
}
void
mbe_printVersion (char *str)
{
sprintf (str, "%s", MBELIB_VERSION);
}
void
mbe_moveMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp)
{
int l;
prev_mp->w0 = cur_mp->w0;
prev_mp->L = cur_mp->L;
prev_mp->K = cur_mp->K; // necessary?
prev_mp->Ml[0] = (float) 0;
prev_mp->gamma = cur_mp->gamma;
prev_mp->repeat = cur_mp->repeat;
for (l = 0; l <= 56; l++)
{
prev_mp->Ml[l] = cur_mp->Ml[l];
prev_mp->Vl[l] = cur_mp->Vl[l];
prev_mp->log2Ml[l] = cur_mp->log2Ml[l];
prev_mp->PHIl[l] = cur_mp->PHIl[l];
prev_mp->PSIl[l] = cur_mp->PSIl[l];
}
}
void
mbe_useLastMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp)
{
int l;
cur_mp->w0 = prev_mp->w0;
cur_mp->L = prev_mp->L;
cur_mp->K = prev_mp->K; // necessary?
cur_mp->Ml[0] = (float) 0;
cur_mp->gamma = prev_mp->gamma;
cur_mp->repeat = prev_mp->repeat;
for (l = 0; l <= 56; l++)
{
cur_mp->Ml[l] = prev_mp->Ml[l];
cur_mp->Vl[l] = prev_mp->Vl[l];
cur_mp->log2Ml[l] = prev_mp->log2Ml[l];
cur_mp->PHIl[l] = prev_mp->PHIl[l];
cur_mp->PSIl[l] = prev_mp->PSIl[l];
}
}
void
mbe_initMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced)
{
int l;
prev_mp->w0 = 0.09378;
prev_mp->L = 30;
prev_mp->K = 10;
prev_mp->gamma = (float) 0;
for (l = 0; l <= 56; l++)
{
prev_mp->Ml[l] = (float) 0;
prev_mp->Vl[l] = 0;
prev_mp->log2Ml[l] = (float) 0; // log2 of 1 == 0
prev_mp->PHIl[l] = (float) 0;
prev_mp->PSIl[l] = (M_PI / (float) 2);
}
prev_mp->repeat = 0;
mbe_moveMbeParms (prev_mp, cur_mp);
mbe_moveMbeParms (prev_mp, prev_mp_enhanced);
}
void
mbe_spectralAmpEnhance (mbe_parms * cur_mp)
{
float Rm0, Rm1, R2m0, R2m1, Wl[57];
int l;
float sum, gamma, M;
Rm0 = 0;
Rm1 = 0;
for (l = 1; l <= cur_mp->L; l++)
{
Rm0 = Rm0 + (cur_mp->Ml[l] * cur_mp->Ml[l]);
Rm1 = Rm1 + ((cur_mp->Ml[l] * cur_mp->Ml[l]) * cosf (cur_mp->w0 * (float) l));
}
R2m0 = (Rm0*Rm0);
R2m1 = (Rm1*Rm1);
for (l = 1; l <= cur_mp->L; l++)
{
if (cur_mp->Ml[l] != 0)
{
Wl[l] = sqrtf (cur_mp->Ml[l]) * powf ((((float) 0.96 * M_PI * ((R2m0 + R2m1) - ((float) 2 * Rm0 * Rm1 * cosf (cur_mp->w0 * (float) l)))) / (cur_mp->w0 * Rm0 * (R2m0 - R2m1))), (float) 0.25);
if ((8 * l) <= cur_mp->L)
{
}
else if (Wl[l] > 1.2)
{
cur_mp->Ml[l] = 1.2 * cur_mp->Ml[l];
}
else if (Wl[l] < 0.5)
{
cur_mp->Ml[l] = 0.5 * cur_mp->Ml[l];
}
else
{
cur_mp->Ml[l] = Wl[l] * cur_mp->Ml[l];
}
}
}
// generate scaling factor
sum = 0;
for (l = 1; l <= cur_mp->L; l++)
{
M = cur_mp->Ml[l];
if (M < 0)
{
M = -M;
}
sum += (M*M);
}
if (sum == 0)
{
gamma = (float) 1.0;
}
else
{
gamma = sqrtf (Rm0 / sum);
}
// apply scaling factor
for (l = 1; l <= cur_mp->L; l++)
{
cur_mp->Ml[l] = gamma * cur_mp->Ml[l];
}
}
void
mbe_synthesizeSilencef (float *aout_buf)
{
int n;
float *aout_buf_p;
aout_buf_p = aout_buf;
for (n = 0; n < 160; n++)
{
*aout_buf_p = (float) 0;
aout_buf_p++;
}
}
void
mbe_synthesizeSilence (short *aout_buf)
{
int n;
short *aout_buf_p;
aout_buf_p = aout_buf;
for (n = 0; n < 160; n++)
{
*aout_buf_p = (short) 0;
aout_buf_p++;
}
}
void
mbe_synthesizeSpeechf (float *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality)
{
int i, l, n, maxl;
float *Ss, loguvquality;
float C1, C2, C3, C4;
//float deltaphil, deltawl, thetaln, aln;
int numUv;
float cw0, pw0, cw0l, pw0l;
float uvsine, uvrand, uvthreshold, uvthresholdf;
float uvstep, uvoffset;
float qfactor;
float rphase[64], rphase2[64];
const int N = 160;
uvthresholdf = (float) 2700;
uvthreshold = ((uvthresholdf * M_PI) / (float) 4000);
// voiced/unvoiced/gain settings
uvsine = (float) 1.3591409 *M_E;
uvrand = (float) 2.0;
if ((uvquality < 1) || (uvquality > 64))
{
printf ("\nmbelib: Error - uvquality must be within the range 1 - 64, setting to default value of 3\n");
uvquality = 3;
}
// calculate loguvquality
if (uvquality == 1)
{
loguvquality = (float) 1 / M_E;
}
else
{
loguvquality = log ((float) uvquality) / (float) uvquality;
}
// calculate unvoiced step and offset values
uvstep = (float) 1.0 / (float) uvquality;
qfactor = loguvquality;
uvoffset = (uvstep * (float) (uvquality - 1)) / (float) 2;
// count number of unvoiced bands
numUv = 0;
for (l = 1; l <= cur_mp->L; l++)
{
if (cur_mp->Vl[l] == 0)
{
numUv++;
}
}
cw0 = cur_mp->w0;
pw0 = prev_mp->w0;
// init aout_buf
Ss = aout_buf;
for (n = 0; n < N; n++)
{
*Ss = (float) 0;
Ss++;
}
// eq 128 and 129
if (cur_mp->L > prev_mp->L)
{
maxl = cur_mp->L;
for (l = prev_mp->L + 1; l <= maxl; l++)
{
prev_mp->Ml[l] = (float) 0;
prev_mp->Vl[l] = 1;
}
}
else
{
maxl = prev_mp->L;
for (l = cur_mp->L + 1; l <= maxl; l++)
{
cur_mp->Ml[l] = (float) 0;
cur_mp->Vl[l] = 1;
}
}
// update phil from eq 139,140
for (l = 1; l <= 56; l++)
{
cur_mp->PSIl[l] = prev_mp->PSIl[l] + ((pw0 + cw0) * ((float) (l * N) / (float) 2));
if (l <= (int) (cur_mp->L / 4))
{
cur_mp->PHIl[l] = cur_mp->PSIl[l];
}
else
{
cur_mp->PHIl[l] = cur_mp->PSIl[l] + ((numUv * mbe_rand_phase()) / cur_mp->L);
}
}
for (l = 1; l <= maxl; l++)
{
cw0l = (cw0 * (float) l);
pw0l = (pw0 * (float) l);
if ((cur_mp->Vl[l] == 0) && (prev_mp->Vl[l] == 1))
{
Ss = aout_buf;
// init random phase
for (i = 0; i < uvquality; i++)
{
rphase[i] = mbe_rand_phase();
}
for (n = 0; n < N; n++)
{
C1 = 0;
// eq 131
C1 = Ws[n + N] * prev_mp->Ml[l] * cosf ((pw0l * (float) n) + prev_mp->PHIl[l]);
C3 = 0;
// unvoiced multisine mix
for (i = 0; i < uvquality; i++)
{
C3 = C3 + cosf ((cw0 * (float) n * ((float) l + ((float) i * uvstep) - uvoffset)) + rphase[i]);
if (cw0l > uvthreshold)
{
C3 = C3 + ((cw0l - uvthreshold) * uvrand * mbe_rand());
}
}
C3 = C3 * uvsine * Ws[n] * cur_mp->Ml[l] * qfactor;
*Ss = *Ss + C1 + C3;
Ss++;
}
}
else if ((cur_mp->Vl[l] == 1) && (prev_mp->Vl[l] == 0))
{
Ss = aout_buf;
// init random phase
for (i = 0; i < uvquality; i++)
{
rphase[i] = mbe_rand_phase();
}
for (n = 0; n < N; n++)
{
C1 = 0;
// eq 132
C1 = Ws[n] * cur_mp->Ml[l] * cosf ((cw0l * (float) (n - N)) + cur_mp->PHIl[l]);
C3 = 0;
// unvoiced multisine mix
for (i = 0; i < uvquality; i++)
{
C3 = C3 + cosf ((pw0 * (float) n * ((float) l + ((float) i * uvstep) - uvoffset)) + rphase[i]);
if (pw0l > uvthreshold)
{
C3 = C3 + ((pw0l - uvthreshold) * uvrand * mbe_rand());
}
}
C3 = C3 * uvsine * Ws[n + N] * prev_mp->Ml[l] * qfactor;
*Ss = *Ss + C1 + C3;
Ss++;
}
}
// else if (((cur_mp->Vl[l] == 1) || (prev_mp->Vl[l] == 1)) && ((l >= 8) || (fabsf (cw0 - pw0) >= ((float) 0.1 * cw0))))
else if ((cur_mp->Vl[l] == 1) || (prev_mp->Vl[l] == 1))
{
Ss = aout_buf;
for (n = 0; n < N; n++)
{
C1 = 0;
// eq 133-1
C1 = Ws[n + N] * prev_mp->Ml[l] * cosf ((pw0l * (float) n) + prev_mp->PHIl[l]);
C2 = 0;
// eq 133-2
C2 = Ws[n] * cur_mp->Ml[l] * cosf ((cw0l * (float) (n - N)) + cur_mp->PHIl[l]);
*Ss = *Ss + C1 + C2;
Ss++;
}
}
/*
// expensive and unnecessary?
else if ((cur_mp->Vl[l] == 1) || (prev_mp->Vl[l] == 1))
{
Ss = aout_buf;
// eq 137
deltaphil = cur_mp->PHIl[l] - prev_mp->PHIl[l] - (((pw0 + cw0) * (float) (l * N)) / (float) 2);
// eq 138
deltawl = ((float) 1 / (float) N) * (deltaphil - ((float) 2 * M_PI * (int) ((deltaphil + M_PI) / (M_PI * (float) 2))));
for (n = 0; n < N; n++)
{
// eq 136
thetaln = prev_mp->PHIl[l] + ((pw0l + deltawl) * (float) n) + (((cw0 - pw0) * ((float) (l * n * n)) / (float) (2 * N)));
// eq 135
aln = prev_mp->Ml[l] + (((float) n / (float) N) * (cur_mp->Ml[l] - prev_mp->Ml[l]));
// eq 134
*Ss = *Ss + (aln * cosf (thetaln));
Ss++;
}
}
*/
else
{
Ss = aout_buf;
// init random phase
for (i = 0; i < uvquality; i++)
{
rphase[i] = mbe_rand_phase();
}
// init random phase
for (i = 0; i < uvquality; i++)
{
rphase2[i] = mbe_rand_phase();
}
for (n = 0; n < N; n++)
{
C3 = 0;
// unvoiced multisine mix
for (i = 0; i < uvquality; i++)
{
C3 = C3 + cosf ((pw0 * (float) n * ((float) l + ((float) i * uvstep) - uvoffset)) + rphase[i]);
if (pw0l > uvthreshold)
{
C3 = C3 + ((pw0l - uvthreshold) * uvrand * mbe_rand());
}
}
C3 = C3 * uvsine * Ws[n + N] * prev_mp->Ml[l] * qfactor;
C4 = 0;
// unvoiced multisine mix
for (i = 0; i < uvquality; i++)
{
C4 = C4 + cosf ((cw0 * (float) n * ((float) l + ((float) i * uvstep) - uvoffset)) + rphase2[i]);
if (cw0l > uvthreshold)
{
C4 = C4 + ((cw0l - uvthreshold) * uvrand * mbe_rand());
}
}
C4 = C4 * uvsine * Ws[n] * cur_mp->Ml[l] * qfactor;
*Ss = *Ss + C3 + C4;
Ss++;
}
}
}
}
void
mbe_synthesizeSpeech (short *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality)
{
float float_buf[160];
mbe_synthesizeSpeechf (float_buf, cur_mp, prev_mp, uvquality);
mbe_floattoshort (float_buf, aout_buf);
}
void
mbe_floattoshort (float *float_buf, short *aout_buf)
{
short *aout_buf_p;
float *float_buf_p;
int i, again;
float audio;
again = 7;
aout_buf_p = aout_buf;
float_buf_p = float_buf;
for (i = 0; i < 160; i++)
{
audio = again * *float_buf_p;
if (audio > 32760)
{
#ifdef MBE_DEBUG
printf ("audio clip: %f\n", audio);
#endif
audio = 32760;
}
else if (audio < -32760)
{
#ifdef MBE_DEBUG
printf ("audio clip: %f\n", audio);
#endif
audio = -32760;
}
*aout_buf_p = (short) (audio);
aout_buf_p++;
float_buf_p++;
}
}
-114
View File
@@ -1,114 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MBELIB_H
#define _MBELIB_H
#define MBELIB_VERSION "1.3.0"
extern "C" {
struct mbe_parameters
{
float w0;
int L;
int K;
int Vl[57];
float Ml[57];
float log2Ml[57];
float PHIl[57];
float PSIl[57];
float gamma;
int un;
int repeat;
};
typedef struct mbe_parameters mbe_parms;
/*
* Prototypes from ecc.c
*/
void mbe_checkGolayBlock (long int *block);
int mbe_golay2312 (char *in, char *out);
int mbe_hamming1511 (char *in, char *out);
int mbe_7100x4400hamming1511 (char *in, char *out);
/*
* Prototypes from ambe3600x2400.c
*/
int mbe_eccAmbe3600x2400C0 (char ambe_fr[4][24]);
int mbe_eccAmbe3600x2400Data (char ambe_fr[4][24], char *ambe_d);
int mbe_decodeAmbe2400Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_demodulateAmbe3600x2400Data (char ambe_fr[4][24]);
void mbe_processAmbe2400Dataf (float *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe2400Data (short *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2400Framef (float *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2400Frame (short *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from ambe3600x2450.c
*/
int mbe_eccAmbe3600x2450C0 (char ambe_fr[4][24]);
int mbe_eccAmbe3600x2450Data (char ambe_fr[4][24], char *ambe_d);
int mbe_decodeAmbe2450Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_demodulateAmbe3600x2450Data (char ambe_fr[4][24]);
void mbe_processAmbe2450Dataf (float *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe2450Data (short *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2450Framef (float *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2450Frame (short *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from imbe7200x4400.c
*/
void mbe_dumpImbe4400Data (char *imbe_d);
void mbe_dumpImbe7200x4400Data (char *imbe_d);
void mbe_dumpImbe7200x4400Frame (char imbe_fr[8][23]);
int mbe_eccImbe7200x4400C0 (char imbe_fr[8][23]);
int mbe_eccImbe7200x4400Data (char imbe_fr[8][23], char *imbe_d);
int mbe_decodeImbe4400Parms (char *imbe_d, mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_demodulateImbe7200x4400Data (char imbe[8][23]);
void mbe_processImbe4400Dataf (float *aout_buf, int *errs2, char *err_str, char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processImbe4400Data (short *aout_buf, int *errs2, char *err_str, char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processImbe7200x4400Framef (float *aout_buf, int *errs2, char *err_str, char imbe_fr[8][23], char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processImbe7200x4400Frame (short *aout_buf, int *errs2, char *err_str, char imbe_fr[8][23], char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from imbe7100x4400.c
*/
void mbe_dumpImbe7100x4400Data (char *imbe_d);
void mbe_dumpImbe7100x4400Frame (char imbe_fr[7][24]);
int mbe_eccImbe7100x4400C0 (char imbe_fr[7][24]);
int mbe_eccImbe7100x4400Data (char imbe_fr[7][24], char *imbe_d);
void mbe_demodulateImbe7100x4400Data (char imbe[7][24]);
void mbe_convertImbe7100to7200 (char *imbe_d);
void mbe_processImbe7100x4400Framef (float *aout_buf, int *errs, int *errs2, char *err_str, char imbe_fr[7][24], char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processImbe7100x4400Frame (short *aout_buf, int *errs, int *errs2, char *err_str, char imbe_fr[7][24], char imbe_d[88], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from mbelib.c
*/
void mbe_printVersion (char *str);
void mbe_moveMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_useLastMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_initMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced);
void mbe_spectralAmpEnhance (mbe_parms * cur_mp);
void mbe_synthesizeSilencef (float *aout_buf);
void mbe_synthesizeSilence (short *aout_buf);
void mbe_synthesizeSpeechf (float *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality);
void mbe_synthesizeSpeech (short *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality);
void mbe_floattoshort (float *float_buf, short *aout_buf);
}
#endif
-371
View File
@@ -1,371 +0,0 @@
/*
* Copyright (C) 2010 mbelib Author
* GPG Key ID: 0xEA5EFE2C (9E7A 5527 9CDC EBF7 BF1B D772 4F98 E863 EA5E FE2C)
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MBELIB_CONST_H
#define _MBELIB_CONST_H
extern "C" {
/*
* Speech Synthesis Window 8k version
*/
const float Ws[321] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18,
0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.32, 0.34, 0.36, 0.38,
0.4, 0.42, 0.44, 0.46, 0.48, 0.5, 0.52, 0.54, 0.56, 0.58,
0.6, 0.62, 0.64, 0.66, 0.68, 0.7, 0.72, 0.74, 0.76, 0.78,
0.8, 0.82, 0.84, 0.86, 0.88, 0.9, 0.92, 0.94, 0.96, 0.98,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0.98, 0.96, 0.94, 0.92, 0.9, 0.88, 0.86, 0.84, 0.82, 0.8,
0.78, 0.76, 0.74, 0.72, 0.7, 0.68, 0.66, 0.64, 0.62, 0.6,
0.58, 0.56, 0.54, 0.52, 0.5, 0.48, 0.46, 0.44, 0.42, 0.4,
0.38, 0.36, 0.34, 0.32, 0.3, 0.28, 0.26, 0.24, 0.22, 0.2,
0.18, 0.16, 0.14, 0.12, 0.1, 0.08, 0.06, 0.04, 0.02, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
* Speech Synthesis Window, 48k version
*/
/*
const float Ws48k[1926] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0.000, 0.003, 0.007,
0.010, 0.013, 0.017,
0.020, 0.023, 0.027,
0.030, 0.033, 0.037,
0.040, 0.043, 0.047,
0.050, 0.053, 0.057,
0.060, 0.063, 0.067,
0.070, 0.073, 0.077,
0.080, 0.083, 0.087,
0.090, 0.093, 0.097,
0.100, 0.103, 0.107,
0.110, 0.113, 0.117,
0.120, 0.123, 0.127,
0.130, 0.133, 0.137,
0.140, 0.143, 0.147,
0.150, 0.153, 0.157,
0.160, 0.163, 0.167,
0.170, 0.173, 0.177,
0.180, 0.183, 0.187,
0.190, 0.193, 0.197,
0.200, 0.203, 0.207,
0.210, 0.213, 0.217,
0.220, 0.223, 0.227,
0.230, 0.233, 0.237,
0.240, 0.243, 0.247,
0.250, 0.253, 0.257,
0.260, 0.263, 0.267,
0.270, 0.273, 0.277,
0.280, 0.283, 0.287,
0.290, 0.293, 0.297,
0.300, 0.303, 0.307,
0.310, 0.313, 0.317,
0.320, 0.323, 0.327,
0.330, 0.333, 0.337,
0.340, 0.343, 0.347,
0.350, 0.353, 0.357,
0.360, 0.363, 0.367,
0.370, 0.373, 0.377,
0.380, 0.383, 0.387,
0.390, 0.393, 0.397,
0.400, 0.403, 0.407,
0.410, 0.413, 0.417,
0.420, 0.423, 0.427,
0.430, 0.433, 0.437,
0.440, 0.443, 0.447,
0.450, 0.453, 0.457,
0.460, 0.463, 0.467,
0.470, 0.473, 0.477,
0.480, 0.483, 0.487,
0.490, 0.493, 0.497,
0.500, 0.503, 0.507,
0.510, 0.513, 0.517,
0.520, 0.523, 0.527,
0.530, 0.533, 0.537,
0.540, 0.543, 0.547,
0.550, 0.553, 0.557,
0.560, 0.563, 0.567,
0.570, 0.573, 0.577,
0.580, 0.583, 0.587,
0.590, 0.593, 0.597,
0.600, 0.603, 0.607,
0.610, 0.613, 0.617,
0.620, 0.623, 0.627,
0.630, 0.633, 0.637,
0.640, 0.643, 0.647,
0.650, 0.653, 0.657,
0.660, 0.663, 0.667,
0.670, 0.673, 0.677,
0.680, 0.683, 0.687,
0.690, 0.693, 0.697,
0.700, 0.703, 0.707,
0.710, 0.713, 0.717,
0.720, 0.723, 0.727,
0.730, 0.733, 0.737,
0.740, 0.743, 0.747,
0.750, 0.753, 0.757,
0.760, 0.763, 0.767,
0.770, 0.773, 0.777,
0.780, 0.783, 0.787,
0.790, 0.793, 0.797,
0.800, 0.803, 0.807,
0.810, 0.813, 0.817,
0.820, 0.823, 0.827,
0.830, 0.833, 0.837,
0.840, 0.843, 0.847,
0.850, 0.853, 0.857,
0.860, 0.863, 0.867,
0.870, 0.873, 0.877,
0.880, 0.883, 0.887,
0.890, 0.893, 0.897,
0.900, 0.903, 0.907,
0.910, 0.913, 0.917,
0.920, 0.923, 0.927,
0.930, 0.933, 0.937,
0.940, 0.943, 0.947,
0.950, 0.953, 0.957,
0.960, 0.963, 0.967,
0.970, 0.973, 0.977,
0.980, 0.983, 0.987,
0.990, 0.993, 0.997,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0.997, 0.993, 0.990,
0.987, 0.983, 0.980,
0.977, 0.973, 0.970,
0.967, 0.963, 0.960,
0.957, 0.953, 0.950,
0.947, 0.943, 0.940,
0.937, 0.933, 0.930,
0.927, 0.923, 0.920,
0.917, 0.913, 0.910,
0.907, 0.903, 0.900,
0.897, 0.893, 0.890,
0.887, 0.883, 0.880,
0.877, 0.873, 0.870,
0.867, 0.863, 0.860,
0.857, 0.853, 0.850,
0.847, 0.843, 0.840,
0.837, 0.833, 0.830,
0.827, 0.823, 0.820,
0.817, 0.813, 0.810,
0.807, 0.803, 0.800,
0.797, 0.793, 0.790,
0.787, 0.783, 0.780,
0.777, 0.773, 0.770,
0.767, 0.763, 0.760,
0.757, 0.753, 0.750,
0.747, 0.743, 0.740,
0.737, 0.733, 0.730,
0.727, 0.723, 0.720,
0.717, 0.713, 0.710,
0.707, 0.703, 0.700,
0.697, 0.693, 0.690,
0.687, 0.683, 0.680,
0.677, 0.673, 0.670,
0.667, 0.663, 0.660,
0.657, 0.653, 0.650,
0.647, 0.643, 0.640,
0.637, 0.633, 0.630,
0.627, 0.623, 0.620,
0.617, 0.613, 0.610,
0.607, 0.603, 0.600,
0.597, 0.593, 0.590,
0.587, 0.583, 0.580,
0.577, 0.573, 0.570,
0.567, 0.563, 0.560,
0.557, 0.553, 0.550,
0.547, 0.543, 0.540,
0.537, 0.533, 0.530,
0.527, 0.523, 0.520,
0.517, 0.513, 0.510,
0.507, 0.503, 0.500,
0.497, 0.493, 0.490,
0.487, 0.483, 0.480,
0.477, 0.473, 0.470,
0.467, 0.463, 0.460,
0.457, 0.453, 0.450,
0.447, 0.443, 0.440,
0.437, 0.433, 0.430,
0.427, 0.423, 0.420,
0.417, 0.413, 0.410,
0.407, 0.403, 0.400,
0.397, 0.393, 0.390,
0.387, 0.383, 0.380,
0.377, 0.373, 0.370,
0.367, 0.363, 0.360,
0.357, 0.353, 0.350,
0.347, 0.343, 0.340,
0.337, 0.333, 0.330,
0.327, 0.323, 0.320,
0.317, 0.313, 0.310,
0.307, 0.303, 0.300,
0.297, 0.293, 0.290,
0.287, 0.283, 0.280,
0.277, 0.273, 0.270,
0.267, 0.263, 0.260,
0.257, 0.253, 0.250,
0.247, 0.243, 0.240,
0.237, 0.233, 0.230,
0.227, 0.223, 0.220,
0.217, 0.213, 0.210,
0.207, 0.203, 0.200,
0.197, 0.193, 0.190,
0.187, 0.183, 0.180,
0.177, 0.173, 0.170,
0.167, 0.163, 0.160,
0.157, 0.153, 0.150,
0.147, 0.143, 0.140,
0.137, 0.133, 0.130,
0.127, 0.123, 0.120,
0.117, 0.113, 0.110,
0.107, 0.103, 0.100,
0.097, 0.093, 0.090,
0.087, 0.083, 0.080,
0.077, 0.073, 0.070,
0.067, 0.063, 0.060,
0.057, 0.053, 0.050,
0.047, 0.043, 0.040,
0.037, 0.033, 0.030,
0.027, 0.023, 0.020,
0.017, 0.013, 0.010,
0.007, 0.003, 0.000,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
*/
}
#endif
-44
View File
@@ -1,44 +0,0 @@
/*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MBELIB_H_
#define MBELIB_H_
#include <stdlib.h>
extern "C" {
#include "mbelib.h"
struct mbelibParms
{
mbe_parms *m_cur_mp;
mbe_parms *m_prev_mp;
mbe_parms *m_prev_mp_enhanced;
mbelibParms()
{
m_cur_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp_enhanced = (mbe_parms *) malloc(sizeof(mbe_parms));
}
~mbelibParms()
{
free(m_prev_mp_enhanced);
free(m_prev_mp);
free(m_cur_mp);
}
};
}
#endif /* MBELIB_H_ */
+1 -950
View File
@@ -12,169 +12,11 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <cstring>
#include <cmath>
#include "mbevocoder.h"
#include "vocoder_tables.h"
#include "ambe3600x2400_const.h"
#include "ambe3600x2450_const.h"
static const short b0_lookup[] = {
0, 0, 0, 1, 1, 2, 2, 2,
3, 3, 4, 4, 4, 5, 5, 5,
6, 6, 7, 7, 7, 8, 8, 8,
9, 9, 9, 10, 10, 11, 11, 11,
12, 12, 12, 13, 13, 13, 14, 14,
14, 15, 15, 15, 16, 16, 16, 17,
17, 17, 17, 18, 18, 18, 19, 19,
19, 20, 20, 20, 21, 21, 21, 21,
22, 22, 22, 23, 23, 23, 24, 24,
24, 24, 25, 25, 25, 25, 26, 26,
26, 27, 27, 27, 27, 28, 28, 28,
29, 29, 29, 29, 30, 30, 30, 30,
31, 31, 31, 31, 31, 32, 32, 32,
32, 33, 33, 33, 33, 34, 34, 34,
34, 35, 35, 35, 35, 36, 36, 36,
36, 37, 37, 37, 37, 38, 38, 38,
38, 38, 39, 39, 39, 39, 40, 40,
40, 40, 40, 41, 41, 41, 41, 42,
42, 42, 42, 42, 43, 43, 43, 43,
43, 44, 44, 44, 44, 45, 45, 45,
45, 45, 46, 46, 46, 46, 46, 47,
47, 47, 47, 47, 48, 48, 48, 48,
48, 49, 49, 49, 49, 49, 49, 50,
50, 50, 50, 50, 51, 51, 51, 51,
51, 52, 52, 52, 52, 52, 52, 53,
53, 53, 53, 53, 54, 54, 54, 54,
54, 54, 55, 55, 55, 55, 55, 56,
56, 56, 56, 56, 56, 57, 57, 57,
57, 57, 57, 58, 58, 58, 58, 58,
58, 59, 59, 59, 59, 59, 59, 60,
60, 60, 60, 60, 60, 61, 61, 61,
61, 61, 61, 62, 62, 62, 62, 62,
62, 63, 63, 63, 63, 63, 63, 63,
64, 64, 64, 64, 64, 64, 65, 65,
65, 65, 65, 65, 65, 66, 66, 66,
66, 66, 66, 67, 67, 67, 67, 67,
67, 67, 68, 68, 68, 68, 68, 68,
68, 69, 69, 69, 69, 69, 69, 69,
70, 70, 70, 70, 70, 70, 70, 71,
71, 71, 71, 71, 71, 71, 72, 72,
72, 72, 72, 72, 72, 73, 73, 73,
73, 73, 73, 73, 73, 74, 74, 74,
74, 74, 74, 74, 75, 75, 75, 75,
75, 75, 75, 75, 76, 76, 76, 76,
76, 76, 76, 76, 77, 77, 77, 77,
77, 77, 77, 77, 77, 78, 78, 78,
78, 78, 78, 78, 78, 79, 79, 79,
79, 79, 79, 79, 79, 80, 80, 80,
80, 80, 80, 80, 80, 81, 81, 81,
81, 81, 81, 81, 81, 81, 82, 82,
82, 82, 82, 82, 82, 82, 83, 83,
83, 83, 83, 83, 83, 83, 83, 84,
84, 84, 84, 84, 84, 84, 84, 84,
85, 85, 85, 85, 85, 85, 85, 85,
85, 86, 86, 86, 86, 86, 86, 86,
86, 86, 87, 87, 87, 87, 87, 87,
87, 87, 87, 88, 88, 88, 88, 88,
88, 88, 88, 88, 89, 89, 89, 89,
89, 89, 89, 89, 89, 89, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90,
91, 91, 91, 91, 91, 91, 91, 91,
91, 92, 92, 92, 92, 92, 92, 92,
92, 92, 92, 93, 93, 93, 93, 93,
93, 93, 93, 93, 93, 94, 94, 94,
94, 94, 94, 94, 94, 94, 94, 94,
95, 95, 95, 95, 95, 95, 95, 95,
95, 95, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 97, 97, 97,
97, 97, 97, 97, 97, 97, 97, 98,
98, 98, 98, 98, 98, 98, 98, 98,
98, 98, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100,
100, 101, 101, 101, 101, 101, 101, 101,
101, 101, 101, 101, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102,
103, 103, 103, 103, 103, 103, 103, 103,
103, 103, 103, 103, 104, 104, 104, 104,
104, 104, 104, 104, 104, 104, 104, 104,
105, 105, 105, 105, 105, 105, 105, 105,
105, 105, 105, 105, 106, 106, 106, 106,
106, 106, 106, 106, 106, 106, 106, 106,
107, 107, 107, 107, 107, 107, 107, 107,
107, 107, 107, 107, 107, 108, 108, 108,
108, 108, 108, 108, 108, 108, 108, 108,
108, 109, 109, 109, 109, 109, 109, 109,
109, 109, 109, 109, 109, 109, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 111, 111, 111, 111, 111,
111, 111, 111, 111, 111, 111, 111, 111,
112, 112, 112, 112, 112, 112, 112, 112,
112, 112, 112, 112, 112, 112, 113, 113,
113, 113, 113, 113, 113, 113, 113, 113,
113, 113, 113, 113, 114, 114, 114, 114,
114, 114, 114, 114, 114, 114, 114, 114,
114, 115, 115, 115, 115, 115, 115, 115,
115, 115, 115, 115, 115, 115, 115, 116,
116, 116, 116, 116, 116, 116, 116, 116,
116, 116, 116, 116, 116, 116, 117, 117,
117, 117, 117, 117, 117, 117, 117, 117,
117, 117, 117, 117, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 119, 119, 119, 119, 119,
119, 119, 119
};
static const int m_list[] = {0, 1, 2, 3, 4, 5, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 23, 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 7, 8, 9, 10, 15, 16, 24, 25, 31, 32, 6};
static const int d_list[] = {7, 1, 11, 21, 31, 25, 35, 45, 55, 49, 59, 69, 6, 0, 10, 20, 30, 24, 34, 44, 54, 48, 58, 68, 5, 15, 9, 19, 29, 39, 33, 43, 53, 63, 57, 67, 4, 14, 8, 18, 28, 38, 32, 42, 52, 62, 56, 66, 3, 13, 23, 17, 27, 37, 47, 41, 51, 61, 71, 65, 2, 12, 22, 16, 26, 36, 46, 40, 50, 60, 70, 64};
//static const int alt_d_list[] = {0, 12, 24, 36, 48, 60, 1, 13, 25, 37, 49, 61, 2, 14, 26, 38, 50, 62, 3, 15, 27, 39, 51, 63, 4, 16, 28, 40, 52, 64, 5, 17, 29, 41, 53, 65, 6, 18, 30, 42, 54, 66, 7, 19, 31, 43, 55, 67, 8, 20, 32, 44, 56, 68, 9, 21, 33, 45, 57, 69, 10, 22, 34, 46, 58, 70, 11, 23, 35, 47, 59, 71};
static const int b_lengths[] = {7,4,6,9,7,4,4,4,3};
const int dW[72] = {0,0,3,2,1,1,0,0,1,1,0,0,3,2,1,1,3,2,1,1,0,0,3,2,0,0,3,2,1,1,0,0,1,1,0,0,
3,2,1,1,3,2,1,1,0,0,3,2,0,0,3,2,1,1,0,0,1,1,0,0,3,2,1,1,3,3,2,1,0,0,3,3,};
const int dX[72] = {10,22,11,9,10,22,11,23,8,20,9,21,10,8,9,21,8,6,7,19,8,20,9,7,6,18,7,5,6,18,7,19,4,16,5,17,6,
4,5,17,4,2,3,15,4,16,5,3,2,14,3,1,2,14,3,15,0,12,1,13,2,0,1,13,0,12,10,11,0,12,1,13,};
const int rW[36] = {
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 2,
0, 2, 0, 2, 0, 2,
0, 2, 0, 2, 0, 2
};
const int rX[36] = {
23, 10, 22, 9, 21, 8,
20, 7, 19, 6, 18, 5,
17, 4, 16, 3, 15, 2,
14, 1, 13, 0, 12, 10,
11, 9, 10, 8, 9, 7,
8, 6, 7, 5, 6, 4
};
// bit 0
const int rY[36] = {
0, 2, 0, 2, 0, 2,
0, 2, 0, 3, 0, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3,
1, 3, 1, 3, 1, 3
};
const int rZ[36] = {
5, 3, 4, 2, 3, 1,
2, 0, 1, 13, 0, 12,
22, 11, 21, 10, 20, 9,
19, 8, 18, 7, 17, 6,
16, 5, 15, 4, 14, 3,
13, 2, 12, 1, 11, 0
};
static inline uint32_t golay_24_encode(uint32_t code_word_in)
{
@@ -224,797 +66,6 @@ static inline int load_reg(const uint8_t val[], int len)
return acc;
}
#include "dstar_pitch.h"
inline float make_f0(int b0) {
return powf(2, -DSTAR_F0_C0 - DSTAR_F0_C1 * ((float)b0 + 0.5f));
}
int
mbe_dequantizeAmbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b, int dstar)
{
int ji, i, j, k, l, L, m, am, ak;
int intkl[57];
int b0, b1, b2, b3, b4, b5, b6, b7, b8;
float f0, Cik[5][18], flokl[57], deltal[57];
float Sum42, Sum43, Tl[57], Gm[9], Ri[9], sum, c1, c2;
//char tmpstr[13];
int silence;
int Ji[5], jl;
float deltaGamma, BigGamma;
float unvc, rconst;
b0 = b[0];
b1 = b[1];
b2 = b[2];
b3 = b[3];
b4 = b[4];
b5 = b[5];
b6 = b[6];
b7 = b[7];
b8 = b[8];
silence = 0;
#ifdef AMBE_DEBUG
fprintf (stderr, "\n");
#endif
// copy repeat from prev_mp
cur_mp->repeat = prev_mp->repeat;
if ((b0 >= 120) && (b0 <= 123))
{
#ifdef AMBE_DEBUG
fprintf (stderr, "AMBE Erasure Frame\n");
#endif
return (2);
}
else if ((b0 == 124) || (b0 == 125))
{
#ifdef AMBE_DEBUG
fprintf (stderr, "AMBE Silence Frame\n");
#endif
silence = 1;
cur_mp->w0 = ((float) 2 * M_PI) / (float) 32;
f0 = (float) 1 / (float) 32;
L = 14;
cur_mp->L = 14;
for (l = 1; l <= L; l++)
{
cur_mp->Vl[l] = 0;
}
}
else if ((b0 == 126) || (b0 == 127))
{
#ifdef AMBE_DEBUG
fprintf (stderr, "AMBE Tone Frame\n");
#endif
return (3);
}
if (silence == 0)
{
if (dstar)
f0 = make_f0(b0);
else
// w0 from specification document
f0 = AmbeW0table[b0];
cur_mp->w0 = f0 * (float) 2 *M_PI;
// w0 from patent filings
//f0 = powf (2, ((float) b0 + (float) 195.626) / -(float) 45.368);
//cur_mp->w0 = f0 * (float) 2 *M_PI;
}
unvc = (float) 0.2046 / sqrtf (cur_mp->w0);
//unvc = (float) 1;
//unvc = (float) 0.2046 / sqrtf (f0);
// decode L
if (silence == 0)
{
// L from specification document
// lookup L in tabl3
if (dstar)
L = DSTAR_L(b0);
else
L = AmbeLtable[b0];
// L formula form patent filings
//L=(int)((float)0.4627 / f0);
cur_mp->L = L;
}
// decode V/UV parameters
for (l = 1; l <= L; l++)
{
// jl from specification document
jl = (int) ((float) l * (float) 16.0 * f0);
// jl from patent filings?
//jl = (int)(((float)l * (float)16.0 * f0) + 0.25);
if (silence == 0)
{
if (dstar)
cur_mp->Vl[l] = AmbePlusVuv[b1][jl];
else
cur_mp->Vl[l] = AmbeVuv[b1][jl];
}
#ifdef AMBE_DEBUG
fprintf (stderr, "jl[%i]:%i Vl[%i]:%i\n", l, jl, l, cur_mp->Vl[l]);
#endif
}
#ifdef AMBE_DEBUG
fprintf (stderr, "\nb0:%i w0:%f L:%i b1:%i\n", b0, cur_mp->w0, L, b1);
#endif
if (dstar) {
deltaGamma = AmbePlusDg[b2];
cur_mp->gamma = deltaGamma + ((float) 0.5 * prev_mp->gamma);
} else {
deltaGamma = AmbeDg[b2];
cur_mp->gamma = deltaGamma + ((float) 0.5 * prev_mp->gamma);
}
#ifdef AMBE_DEBUG
fprintf (stderr, "b2: %i, deltaGamma: %f gamma: %f gamma-1: %f\n", b2, deltaGamma, cur_mp->gamma, prev_mp->gamma);
#endif
// decode PRBA vectors
Gm[1] = 0;
if (dstar) {
Gm[2] = AmbePlusPRBA24[b3][0];
Gm[3] = AmbePlusPRBA24[b3][1];
Gm[4] = AmbePlusPRBA24[b3][2];
Gm[5] = AmbePlusPRBA58[b4][0];
Gm[6] = AmbePlusPRBA58[b4][1];
Gm[7] = AmbePlusPRBA58[b4][2];
Gm[8] = AmbePlusPRBA58[b4][3];
} else {
Gm[2] = AmbePRBA24[b3][0];
Gm[3] = AmbePRBA24[b3][1];
Gm[4] = AmbePRBA24[b3][2];
Gm[5] = AmbePRBA58[b4][0];
Gm[6] = AmbePRBA58[b4][1];
Gm[7] = AmbePRBA58[b4][2];
Gm[8] = AmbePRBA58[b4][3];
}
#ifdef AMBE_DEBUG
fprintf (stderr, "b3: %i Gm[2]: %f Gm[3]: %f Gm[4]: %f b4: %i Gm[5]: %f Gm[6]: %f Gm[7]: %f Gm[8]: %f\n", b3, Gm[2], Gm[3], Gm[4], b4, Gm[5], Gm[6], Gm[7], Gm[8]);
#endif
// compute Ri
for (i = 1; i <= 8; i++)
{
sum = 0;
for (m = 1; m <= 8; m++)
{
if (m == 1)
{
am = 1;
}
else
{
am = 2;
}
sum = sum + ((float) am * Gm[m] * cosf ((M_PI * (float) (m - 1) * ((float) i - (float) 0.5)) / (float) 8));
}
Ri[i] = sum;
#ifdef AMBE_DEBUG
fprintf (stderr, "R%i: %f ", i, Ri[i]);
#endif
}
#ifdef AMBE_DEBUG
fprintf (stderr, "\n");
#endif
// generate first to elements of each Ci,k block from PRBA vector
rconst = ((float) 1 / ((float) 2 * M_SQRT2));
Cik[1][1] = (float) 0.5 *(Ri[1] + Ri[2]);
Cik[1][2] = rconst * (Ri[1] - Ri[2]);
Cik[2][1] = (float) 0.5 *(Ri[3] + Ri[4]);
Cik[2][2] = rconst * (Ri[3] - Ri[4]);
Cik[3][1] = (float) 0.5 *(Ri[5] + Ri[6]);
Cik[3][2] = rconst * (Ri[5] - Ri[6]);
Cik[4][1] = (float) 0.5 *(Ri[7] + Ri[8]);
Cik[4][2] = rconst * (Ri[7] - Ri[8]);
// decode HOC
// lookup Ji
if (dstar) {
Ji[1] = AmbePlusLmprbl[L][0];
Ji[2] = AmbePlusLmprbl[L][1];
Ji[3] = AmbePlusLmprbl[L][2];
Ji[4] = AmbePlusLmprbl[L][3];
} else {
Ji[1] = AmbeLmprbl[L][0];
Ji[2] = AmbeLmprbl[L][1];
Ji[3] = AmbeLmprbl[L][2];
Ji[4] = AmbeLmprbl[L][3];
}
#ifdef AMBE_DEBUG
fprintf (stderr, "Ji[1]: %i Ji[2]: %i Ji[3]: %i Ji[4]: %i\n", Ji[1], Ji[2], Ji[3], Ji[4]);
fprintf (stderr, "b5: %i b6: %i b7: %i b8: %i\n", b5, b6, b7, b8);
#endif
// Load Ci,k with the values from the HOC tables
// there appear to be a couple typos in eq. 37 so we will just do what makes sense
// (3 <= k <= Ji and k<=6)
for (k = 3; k <= Ji[1]; k++)
{
if (k > 6)
{
Cik[1][k] = 0;
}
else
{
if (dstar)
Cik[1][k] = AmbePlusHOCb5[b5][k - 3];
else
Cik[1][k] = AmbeHOCb5[b5][k - 3];
#ifdef AMBE_DEBUG
fprintf (stderr, "C1,%i: %f ", k, Cik[1][k]);
#endif
}
}
for (k = 3; k <= Ji[2]; k++)
{
if (k > 6)
{
Cik[2][k] = 0;
}
else
{
if (dstar)
Cik[2][k] = AmbePlusHOCb6[b6][k - 3];
else
Cik[2][k] = AmbeHOCb6[b6][k - 3];
#ifdef AMBE_DEBUG
fprintf (stderr, "C2,%i: %f ", k, Cik[2][k]);
#endif
}
}
for (k = 3; k <= Ji[3]; k++)
{
if (k > 6)
{
Cik[3][k] = 0;
}
else
{
if (dstar)
Cik[3][k] = AmbePlusHOCb7[b7][k - 3];
else
Cik[3][k] = AmbeHOCb7[b7][k - 3];
#ifdef AMBE_DEBUG
fprintf (stderr, "C3,%i: %f ", k, Cik[3][k]);
#endif
}
}
for (k = 3; k <= Ji[4]; k++)
{
if (k > 6)
{
Cik[4][k] = 0;
}
else
{
if (dstar)
Cik[4][k] = AmbePlusHOCb8[b8][k - 3];
else
Cik[4][k] = AmbeHOCb8[b8][k - 3];
#ifdef AMBE_DEBUG
fprintf (stderr, "C4,%i: %f ", k, Cik[4][k]);
#endif
}
}
#ifdef AMBE_DEBUG
fprintf (stderr, "\n");
#endif
// inverse DCT each Ci,k to give ci,j (Tl)
l = 1;
for (i = 1; i <= 4; i++)
{
ji = Ji[i];
for (j = 1; j <= ji; j++)
{
sum = 0;
for (k = 1; k <= ji; k++)
{
if (k == 1)
{
ak = 1;
}
else
{
ak = 2;
}
#ifdef AMBE_DEBUG
fprintf (stderr, "j: %i Cik[%i][%i]: %f ", j, i, k, Cik[i][k]);
#endif
sum = sum + ((float) ak * Cik[i][k] * cosf ((M_PI * (float) (k - 1) * ((float) j - (float) 0.5)) / (float) ji));
}
Tl[l] = sum;
#ifdef AMBE_DEBUG
fprintf (stderr, "Tl[%i]: %f\n", l, Tl[l]);
#endif
l++;
}
}
// determine log2Ml by applying ci,j to previous log2Ml
// fix for when L > L(-1)
if (cur_mp->L > prev_mp->L)
{
for (l = (prev_mp->L) + 1; l <= cur_mp->L; l++)
{
prev_mp->Ml[l] = prev_mp->Ml[prev_mp->L];
prev_mp->log2Ml[l] = prev_mp->log2Ml[prev_mp->L];
}
}
prev_mp->log2Ml[0] = prev_mp->log2Ml[1];
prev_mp->Ml[0] = prev_mp->Ml[1];
// Part 1
Sum43 = 0;
for (l = 1; l <= cur_mp->L; l++)
{
// eq. 40
flokl[l] = ((float) prev_mp->L / (float) cur_mp->L) * (float) l;
intkl[l] = (int) (flokl[l]);
#ifdef AMBE_DEBUG
fprintf (stderr, "flok%i: %f, intk%i: %i ", l, flokl[l], l, intkl[l]);
#endif
// eq. 41
deltal[l] = flokl[l] - (float) intkl[l];
#ifdef AMBE_DEBUG
fprintf (stderr, "delta%i: %f ", l, deltal[l]);
#endif
// eq 43
Sum43 = Sum43 + ((((float) 1 - deltal[l]) * prev_mp->log2Ml[intkl[l]]) + (deltal[l] * prev_mp->log2Ml[intkl[l] + 1]));
}
Sum43 = (((dstar ? DSTAR_SPEC_PRED : 0.65f) / (float) cur_mp->L) * Sum43);
#ifdef AMBE_DEBUG
fprintf (stderr, "\n");
fprintf (stderr, "Sum43: %f\n", Sum43);
#endif
// Part 2
Sum42 = 0;
for (l = 1; l <= cur_mp->L; l++)
{
Sum42 += Tl[l];
}
Sum42 = Sum42 / (float) cur_mp->L;
BigGamma = cur_mp->gamma - ((float) 0.5 * (log ((float) cur_mp->L) / log ((float) 2))) - Sum42;
//BigGamma=cur_mp->gamma - ((float)0.5 * log((float)cur_mp->L)) - Sum42;
// Part 3
for (l = 1; l <= cur_mp->L; l++)
{
c1 = ((dstar ? DSTAR_SPEC_PRED : 0.65f) * ((float) 1 - deltal[l]) * prev_mp->log2Ml[intkl[l]]);
c2 = ((dstar ? DSTAR_SPEC_PRED : 0.65f) * deltal[l] * prev_mp->log2Ml[intkl[l] + 1]);
cur_mp->log2Ml[l] = Tl[l] + c1 + c2 - Sum43 + BigGamma;
// inverse log to generate spectral amplitudes
if (cur_mp->Vl[l] == 1)
{
cur_mp->Ml[l] = exp ((float) 0.693 * cur_mp->log2Ml[l]);
}
else
{
cur_mp->Ml[l] = unvc * exp ((float) 0.693 * cur_mp->log2Ml[l]);
}
#ifdef AMBE_DEBUG
fprintf (stderr, "flokl[%i]: %f, intkl[%i]: %i ", l, flokl[l], l, intkl[l]);
fprintf (stderr, "deltal[%i]: %f ", l, deltal[l]);
fprintf (stderr, "prev_mp->log2Ml[%i]: %f\n", l, prev_mp->log2Ml[intkl[l]]);
fprintf (stderr, "BigGamma: %f c1: %f c2: %f Sum43: %f Tl[%i]: %f log2Ml[%i]: %f Ml[%i]: %f\n", BigGamma, c1, c2, Sum43, l, Tl[l], l, cur_mp->log2Ml[l], l, cur_mp->Ml[l]);
#endif
}
return (0);
}
int
mbe_dequantizeAmbe2400Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b){
int dstar = 1;
return (mbe_dequantizeAmbeParms (cur_mp, prev_mp, b, dstar));
}
int
mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b){
int dstar = 0;
return (mbe_dequantizeAmbeParms (cur_mp, prev_mp, b, dstar));
}
void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp, mbe_parms*prev_mp, bool dstar, float gain_adjust, float *gain_state = nullptr) {
static const float SQRT_2 = sqrtf(2.0);
static const int b0_lmax = sizeof(b0_lookup) / sizeof(b0_lookup[0]);
// int b[9];
int L;
// The harmonics the rest of this function codes: their count (nh), their
// amplitudes (sa_w) and voicing (vuv_w). For DMR they are the IMBE
// analysis' own values, unchanged.
int nh = imbe_param->num_harms;
float sa_w[NUM_HARMS_MAX];
short vuv_w[NUM_HARMS_MAX];
if (dstar) {
float f0_in = 256.0f / (float) imbe_param->ref_pitch; // cycles per sample
int b0 = (int) lrintf((-log2f(f0_in) - DSTAR_F0_C0) / DSTAR_F0_C1 - 0.5f); // nearest code on the chip-measured scale
if (b0 < 0) b0 = 0;
if (b0 > 119) b0 = 119; // 120..127 are erasure / silence / tone codes
b[0] = b0;
L = DSTAR_L(b0);
float f0_c = make_f0(b0);
const int n_in = imbe_param->num_harms;
for (int l = 1; l <= L; l++) {
// position of the decoder's harmonic l on the IMBE harmonic axis (1-based)
float k = (float) l * f0_c / f0_in;
float a;
if (k <= 1.0f) {
a = (float) imbe_param->sa[0];
} else if (k >= (float) n_in) {
a = (float) imbe_param->sa[n_in - 1] * exp2f(-1.0f * (k - (float) n_in));
} else {
int k0 = (int) k; // 1-based lower neighbour
float fr = k - (float) k0;
float a0 = (float) imbe_param->sa[k0 - 1];
float a1 = (float) imbe_param->sa[k0];
if (a0 < 1.0f) a0 = 1.0f;
if (a1 < 1.0f) a1 = 1.0f;
a = exp2f((1.0f - fr) * log2f(a0) + fr * log2f(a1));
}
sa_w[l - 1] = a;
int kn = (int) lrintf(k);
if (kn < 1) kn = 1;
if (kn > n_in) kn = n_in;
vuv_w[l - 1] = imbe_param->v_uv_dsn[kn - 1];
}
nh = L;
} else {
// ref_pitch is Q8_8 in range 19.875 - 123.125
int b0_i = (imbe_param->ref_pitch >> 5) - 159;
if (b0_i < 0 || b0_i > b0_lmax) {
fprintf(stderr, "encode error b0_i %d\n", b0_i);
return;
}
b[0] = b0_lookup[b0_i];
L = (int) AmbeLtable[b[0]];
#if 1
// adjust b0 until L agrees
while (L != imbe_param->num_harms) {
if (L < imbe_param->num_harms)
b0_i ++;
else if (L > imbe_param->num_harms)
b0_i --;
if (b0_i < 0 || b0_i > b0_lmax) {
fprintf(stderr, "encode error2 b0_i %d\n", b0_i);
return;
}
b[0] = b0_lookup[b0_i];
L = (int) AmbeLtable[b[0]];
}
#endif
for (int l = 0; l < nh; l++) {
sa_w[l] = (float) imbe_param->sa[l];
vuv_w[l] = imbe_param->v_uv_dsn[l];
}
}
float m_float2[NUM_HARMS_MAX];
for (int l=1; l <= L; l++) {
m_float2[l-1] = sa_w[l-1] ;
m_float2[l-1] = m_float2[l-1] * m_float2[l-1];
}
float en_min = 0;
b[1] = 0;
int vuv_max = (dstar) ? 16 : 17;
for (int n=0; n < vuv_max; n++) {
float En = 0;
for (int l=1; l <= L; l++) {
int jl;
if (dstar)
jl = (int) ((float) l * (float) 16.0 * make_f0(b[0]));
else
jl = (int) ((float) l * (float) 16.0 * AmbeW0table[b[0]]);
int kl = 12;
if (l <= 36)
kl = (l + 2) / 3;
if (dstar) {
if (vuv_w[l-1] != AmbePlusVuv[n][jl])
En += m_float2[l-1];
} else {
if (imbe_param->v_uv_dsn[(kl-1)*3] != AmbeVuv[n][jl])
En += m_float2[l-1];
}
}
if (n == 0)
en_min = En;
else if (En < en_min) {
b[1] = n;
en_min = En;
}
}
// log spectral amplitudes
float num_harms_f = (float) nh;
float log_l_2 = 0.5 * log2f(num_harms_f); // fixme: table lookup
float log_l_w0;
if (dstar)
log_l_w0 = 0.5 * log2f(num_harms_f * make_f0(b[0]) * 2.0 * M_PI) + 2.289;
else
log_l_w0 = 0.5 * log2f(num_harms_f * AmbeW0table[b[0]] * 2.0 * M_PI) + 2.289;
float lsa[NUM_HARMS_MAX];
float lsa_sum=0.0;
for (int i1 = 0; i1 < nh; i1++) {
float sa = sa_w[i1];
if (sa < 1) sa = 1.0;
if (vuv_w[i1])
lsa[i1] = log_l_2 + log2f(sa);
else
lsa[i1] = log_l_w0 + log2f(sa);
lsa_sum += lsa[i1];
}
float gain = lsa_sum / num_harms_f;
if (dstar && gain_state) {
if (*gain_state > -98.0f) gain = DSTAR_GAIN_SMOOTH * (*gain_state) + (1.0f - DSTAR_GAIN_SMOOTH) * gain;
*gain_state = gain;
}
float diff_gain;
(void)dstar;
diff_gain = gain - 0.5 * prev_mp->gamma;
diff_gain -= gain_adjust;
float error;
int error_index;
int max_dg = (dstar) ? 64 : 32;
for (int i1 = 0; i1 < max_dg; i1++) {
float diff;
if (dstar)
diff = fabsf(diff_gain - AmbePlusDg[i1]);
else
diff = fabsf(diff_gain - AmbeDg[i1]);
//fprintf(stderr, "%2.4f:%2.4f ", diff, error);
if ((i1 == 0) || (diff < error)) {
error = diff;
error_index = i1;
}
}
//fprintf(stderr, "\n");
b[2] = error_index;
// prediction residuals
float l_prev_l = (float) (prev_mp->L) / num_harms_f;
//float tmp_s = 0.0;
prev_mp->log2Ml[0] = prev_mp->log2Ml[1];
for (int i1 = 0; i1 < nh; i1++) {
//float kl = l_prev_l * (float)(i1+1);
//int kl_floor = (int) kl;
//float kl_frac = kl - kl_floor;
//tmp_s += (1.0 - kl_frac) * prev_mp->log2Ml[kl_floor +0] + kl_frac * prev_mp->log2Ml[kl_floor+1 +0];
}
float T[NUM_HARMS_MAX];
for (int i1 = 0; i1 < nh; i1++) {
float kl = l_prev_l * (float)(i1+1);
int kl_floor = (int) kl;
float kl_frac = kl - kl_floor;
const float pc = dstar ? DSTAR_SPEC_PRED : 0.65f;
T[i1] = lsa[i1] - pc * (1.0 - kl_frac) * prev_mp->log2Ml[kl_floor +0] \
- pc * kl_frac * prev_mp->log2Ml[kl_floor+1 +0];
}
// DCT
const int * J;
if (dstar)
J = AmbePlusLmprbl[nh];
else
J = AmbeLmprbl[nh];
float * c[4];
int acc = 0;
for (int i=0; i<4; i++) {
c[i] = &T[acc];
acc += J[i];
}
float C[4][17];
for (int i=1; i<=4; i++) {
for (int k=1; k<=J[i-1]; k++) {
float s = 0.0;
for (int j=1; j<=J[i-1]; j++) {
//fixme: lut?
s += (c[i-1][j-1] * cosf((M_PI * (((float)k) - 1.0) * (((float)j) - 0.5)) / (float)J[i-1]));
}
C[i-1][k-1] = s / (float)J[i-1];
}
}
float R[8];
R[0] = C[0][0] + SQRT_2 * C[0][1];
R[1] = C[0][0] - SQRT_2 * C[0][1];
R[2] = C[1][0] + SQRT_2 * C[1][1];
R[3] = C[1][0] - SQRT_2 * C[1][1];
R[4] = C[2][0] + SQRT_2 * C[2][1];
R[5] = C[2][0] - SQRT_2 * C[2][1];
R[6] = C[3][0] + SQRT_2 * C[3][1];
R[7] = C[3][0] - SQRT_2 * C[3][1];
// encode PRBA
float G[8];
for (int m=1; m<=8; m++) {
G[m-1] = 0.0;
for (int i=1; i<=8; i++) {
//fixme: lut?
G[m-1] += (R[i-1] * cosf((M_PI * (((float)m) - 1.0) * (((float)i) - 0.5)) / 8.0));
}
G[m-1] /= 8.0;
}
for (int i=0; i<512; i++) {
float err=0.0;
float diff;
if (dstar) {
diff = G[1] - AmbePlusPRBA24[i][0];
err += (diff * diff);
diff = G[2] - AmbePlusPRBA24[i][1];
err += (diff * diff);
diff = G[3] - AmbePlusPRBA24[i][2];
err += (diff * diff);
} else {
diff = G[1] - AmbePRBA24[i][0];
err += (diff * diff);
diff = G[2] - AmbePRBA24[i][1];
err += (diff * diff);
diff = G[3] - AmbePRBA24[i][2];
err += (diff * diff);
}
if (i == 0 || err < error) {
error = err;
error_index = i;
}
}
b[3] = error_index;
// PRBA58
for (int i=0; i<128; i++) {
float err=0.0;
float diff;
if (dstar) {
diff = G[4] - AmbePlusPRBA58[i][0];
err += (diff * diff);
diff = G[5] - AmbePlusPRBA58[i][1];
err += (diff * diff);
diff = G[6] - AmbePlusPRBA58[i][2];
err += (diff * diff);
diff = G[7] - AmbePlusPRBA58[i][3];
err += (diff * diff);
} else {
diff = G[4] - AmbePRBA58[i][0];
err += (diff * diff);
diff = G[5] - AmbePRBA58[i][1];
err += (diff * diff);
diff = G[6] - AmbePRBA58[i][2];
err += (diff * diff);
diff = G[7] - AmbePRBA58[i][3];
err += (diff * diff);
}
if (i == 0 || err < error) {
error = err;
error_index = i;
}
}
b[4] = error_index;
// higher order coeffs b5
int ii = 1;
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
int max_5 = (dstar) ? 16 : 32;
for (int n=0; n < max_5; n++) {
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
if (dstar)
diff = AmbePlusHOCb5[n][j-1] - C[ii-1][j+2-1];
else
diff = AmbeHOCb5[n][j-1] - C[ii-1][j+2-1];
err += (diff * diff);
}
if (n == 0 || err < error) {
error = err;
error_index = n;
}
}
b[4+ii] = error_index;
}
// higher order coeffs b6
ii = 2;
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
for (int n=0; n < 16; n++) {
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
if (dstar)
diff = AmbePlusHOCb6[n][j-1] - C[ii-1][j+2-1];
else
diff = AmbeHOCb6[n][j-1] - C[ii-1][j+2-1];
err += (diff * diff);
}
if (n == 0 || err < error) {
error = err;
error_index = n;
}
}
b[4+ii] = error_index;
}
// higher order coeffs b7
ii = 3;
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
for (int n=0; n < 16; n++) {
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
if (dstar)
diff = AmbePlusHOCb7[n][j-1] - C[ii-1][j+2-1];
else
diff = AmbeHOCb7[n][j-1] - C[ii-1][j+2-1];
err += (diff * diff);
}
if (n == 0 || err < error) {
error = err;
error_index = n;
}
}
b[4+ii] = error_index;
}
// higher order coeffs b8
ii = 4;
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
int max_8 = (dstar) ? 16 : 8;
const int step_8 = (dstar) ? 2 : 1;
for (int n=0; n < max_8; n += step_8) {
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
if (dstar)
diff = AmbePlusHOCb8[n][j-1] - C[ii-1][j+2-1];
else
diff = AmbeHOCb8[n][j-1] - C[ii-1][j+2-1];
err += (diff * diff);
}
if (n == 0 || err < error) {
error = err;
error_index = n;
}
}
b[4+ii] = error_index;
}
//fprintf (stderr, "B\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]);
//int rc;
if (dstar)
mbe_dequantizeAmbe2400Parms (cur_mp, prev_mp, b);
else
mbe_dequantizeAmbe2250Parms (cur_mp, prev_mp, b);
mbe_moveMbeParms (cur_mp, prev_mp);
}
MBEVocoder::MBEVocoder()
{
m_mbelibParms = new mbelibParms();
@@ -1027,7 +78,7 @@ void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp, mbe_pa
initMbeParms();
memset(ambe_d, 0, 49);
m_dstar_gain_s = -99.0f; // QSO One: D-Star gain smoothing state (none yet)
m_dstar_gain_s = -99.0f;
}
MBEVocoder::~MBEVocoder()
+82 -2
View File
@@ -17,7 +17,88 @@
#include <cinttypes>
#include <imbe_vocoder_api.h>
#include "mbelib_parms.h"
extern "C" {
struct mbe_parameters
{
float w0;
int L;
int K;
int Vl[57];
float Ml[57];
float log2Ml[57];
float PHIl[57];
float PSIl[57];
float gamma;
int un;
int repeat;
};
typedef struct mbe_parameters mbe_parms;
struct mbelibParms
{
mbe_parms *m_cur_mp;
mbe_parms *m_prev_mp;
mbe_parms *m_prev_mp_enhanced;
mbelibParms()
{
m_cur_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp_enhanced = (mbe_parms *) malloc(sizeof(mbe_parms));
}
~mbelibParms()
{
free(m_prev_mp_enhanced);
free(m_prev_mp);
free(m_cur_mp);
}
};
void mbe_checkGolayBlock (long int *block);
int mbe_golay2312 (char *in, char *out);
void encode_ambe(const IMBE_PARAM *, int b[], mbe_parms*cur_mp, mbe_parms*prev_mp, bool dstar, float gain_adjust, float *gain_state = nullptr);
/*
* Prototypes from ambe3600x2400.cpp
*/
int mbe_eccAmbe3600x2400C0 (char ambe_fr[4][24]);
int mbe_eccAmbe3600x2400Data (char ambe_fr[4][24], char *ambe_d);
int mbe_decodeAmbe2400Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_demodulateAmbe3600x2400Data (char ambe_fr[4][24]);
void mbe_processAmbe2400Dataf (float *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe2400Data (short *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2400Framef (float *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2400Frame (short *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from ambe3600x2450.cpp
*/
int mbe_eccAmbe3600x2450C0 (char ambe_fr[4][24]);
int mbe_eccAmbe3600x2450Data (char ambe_fr[4][24], char *ambe_d);
int mbe_decodeAmbe2450Parms (char *ambe_d, mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_demodulateAmbe3600x2450Data (char ambe_fr[4][24]);
void mbe_processAmbe2450Dataf (float *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe2450Data (short *aout_buf, int *errs2, char *err_str, char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2450Framef (float *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
void mbe_processAmbe3600x2450Frame (short *aout_buf, int *errs2, char *err_str, char ambe_fr[4][24], char ambe_d[49], mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced, int uvquality);
/*
* Prototypes from mbelib.c
*/
void mbe_printVersion (char *str);
void mbe_moveMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_useLastMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp);
void mbe_initMbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp, mbe_parms * prev_mp_enhanced);
void mbe_spectralAmpEnhance (mbe_parms * cur_mp);
void mbe_synthesizeSilencef (float *aout_buf);
void mbe_synthesizeSilence (short *aout_buf);
void mbe_synthesizeSpeechf (float *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality);
void mbe_synthesizeSpeech (short *aout_buf, mbe_parms * cur_mp, mbe_parms * prev_mp, int uvquality);
void mbe_floattoshort (float *float_buf, short *aout_buf);
}
class MBEVocoder
{
@@ -59,5 +140,4 @@ private:
void resetAudio();
void processAudio();
};
#endif // MBEVOCODER_H
-104
View File
@@ -1,104 +0,0 @@
/*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MBEVOCODER_API_H
#define MBEVOCODER_API_H
#include <cinttypes>
extern "C" {
struct mbe_parameters
{
float w0;
int L;
int K;
int Vl[57];
float Ml[57];
float log2Ml[57];
float PHIl[57];
float PSIl[57];
float gamma;
int un;
int repeat;
};
typedef struct mbe_parameters mbe_parms;
struct mbelibParms
{
mbe_parms *m_cur_mp;
mbe_parms *m_prev_mp;
mbe_parms *m_prev_mp_enhanced;
mbelibParms()
{
m_cur_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp = (mbe_parms *) malloc(sizeof(mbe_parms));
m_prev_mp_enhanced = (mbe_parms *) malloc(sizeof(mbe_parms));
}
~mbelibParms()
{
free(m_prev_mp_enhanced);
free(m_prev_mp);
free(m_cur_mp);
}
};
}
class MBEVocoder
{
public:
MBEVocoder();
~MBEVocoder();
void decode_2400x1200(int16_t *pcm, uint8_t *codec);
void decode_2450x1150(int16_t *pcm, uint8_t *codec);
void decode_2450(int16_t *pcm, uint8_t *codec);
void encode_2400x1200(int16_t *pcm, uint8_t *codec);
void encode_2450x1150(int16_t *pcm, uint8_t *codec);
void encode_2450(int16_t *pcm, uint8_t *codec);
private:
imbe_vocoder vocoder;
mbe_parms cur_mp;
mbe_parms prev_mp;
mbelibParms *m_mbelibParms;
//int m_errs;
int m_errs2;
char m_err_str[64];
float m_audio_out_temp_buf[160]; //!< output of decoder
float *m_audio_out_temp_buf_p;
float m_aout_max_buf[200];
float *m_aout_max_buf_p;
int m_aout_max_buf_idx;
short m_audio_out_buf[2*48000]; //!< final result - 1s of L+R S16LE samples
short *m_audio_out_buf_p;
int m_audio_out_nb_samples;
int m_audio_out_buf_size;
const int *w, *x, *y, *z;
char ambe_d[49];
void initMbeParms();
void process_2400x1200(unsigned char *d);
void process_2450x1150(unsigned char *d);
void process_2450(unsigned char *d);
void processData(char ambe_data[49]);
short *getAudio(int& nbSamples);
void resetAudio();
void processAudio();
};
#endif // MBEVOCODER_API_H
+2101 -2
View File
File diff suppressed because it is too large. Load diff