initial dstar checkin

This commit is contained in:
Max 2017-03-06 09:17:16 -05:00
parent 8242b8e0fc
commit eb522cf5e5
11 changed files with 1519 additions and 56 deletions

View File

@ -0,0 +1,57 @@
/* -*- c++ -*- */
/*
* DMR Encoder (C) Copyright 2017 Max H. Parke KA1RBI
* This file is part of OP25
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OP25_REPEATER_DSTAR_TX_SB_H
#define INCLUDED_OP25_REPEATER_DSTAR_TX_SB_H
#include <op25_repeater/api.h>
#include <gnuradio/block.h>
namespace gr {
namespace op25_repeater {
/*!
* \brief <+description of block+>
* \ingroup op25_repeater
*
*/
class OP25_REPEATER_API dstar_tx_sb : virtual public gr::block
{
public:
typedef boost::shared_ptr<dstar_tx_sb> sptr;
/*!
* \brief Return a shared_ptr to a new instance of op25_repeater::dstar_tx_sb.
*
* To avoid accidental use of raw pointers, op25_repeater::dstar_tx_sb's
* constructor is in a private implementation
* class. op25_repeater::dstar_tx_sb::make is the public interface for
* creating new instances.
*/
static sptr make(int versbose_flag, const char * conf_file, bool fullrate_mode);
};
} // namespace op25_repeater
} // namespace gr
#endif /* INCLUDED_OP25_REPEATER_DSTAR_TX_SB_H */

View File

@ -28,6 +28,7 @@ list(APPEND op25_repeater_sources
ambe_encoder_sb_impl.cc
dmr_bs_tx_bb_impl.cc
ysf_tx_sb_impl.cc
dstar_tx_sb_impl.cc
vocoder_impl.cc
gardner_costas_cc_impl.cc
p25_frame_assembler_impl.cc

View File

@ -18,9 +18,10 @@
#include <stdlib.h>
#include "mbelib.h"
#include "ambe3600x2250_const.h"
#include "ambe3600x2400_const.h"
int
mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b)
static int
mbe_dequantizeAmbeParms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b, int dstar)
{
int ji, i, j, k, l, L, L9, m, am, ak;
@ -85,8 +86,11 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
if (silence == 0)
{
if (dstar)
f0 = powf(2, (-4.311767578125 - (2.1336e-2 * ((float)b0+0.5))));
else
// w0 from specification document
f0 = AmbeW0table[b0];
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);
@ -102,7 +106,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
{
// L from specification document
// lookup L in tabl3
L = AmbeLtable[b0];
if (dstar)
L = AmbePlusLtable[b0];
else
L = AmbeLtable[b0];
// L formula form patent filings
//L=(int)((float)0.4627 / f0);
cur_mp->L = L;
@ -119,7 +126,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
if (silence == 0)
{
cur_mp->Vl[l] = AmbeVuv[b1][jl];
if (dstar)
cur_mp->Vl[l] = AmbePlusVuv[b1][jl];
else
cur_mp->Vl[l] = AmbeVuv[b1][jl];
}
#ifdef AMBE_DEBUG
printf ("jl[%i]:%i Vl[%i]:%i\n", l, jl, l, cur_mp->Vl[l]);
@ -139,14 +149,25 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
// decode PRBA vectors
Gm[1] = 0;
Gm[2] = AmbePRBA24[b3][0];
Gm[3] = AmbePRBA24[b3][1];
Gm[4] = AmbePRBA24[b3][2];
if (dstar) {
Gm[2] = AmbePlusPRBA24[b3][0];
Gm[3] = AmbePlusPRBA24[b3][1];
Gm[4] = AmbePlusPRBA24[b3][2];
Gm[5] = AmbePRBA58[b4][0];
Gm[6] = AmbePRBA58[b4][1];
Gm[7] = AmbePRBA58[b4][2];
Gm[8] = AmbePRBA58[b4][3];
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
printf ("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]);
@ -191,10 +212,17 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
// decode HOC
// lookup Ji
Ji[1] = AmbeLmprbl[L][0];
Ji[2] = AmbeLmprbl[L][1];
Ji[3] = AmbeLmprbl[L][2];
Ji[4] = AmbeLmprbl[L][3];
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
printf ("Ji[1]: %i Ji[2]: %i Ji[3]: %i Ji[4]: %i\n", Ji[1], Ji[2], Ji[3], Ji[4]);
printf ("b5: %i b6: %i b7: %i b8: %i\n", b5, b6, b7, b8);
@ -211,7 +239,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
}
else
{
Cik[1][k] = AmbeHOCb5[b5][k - 3];
if (dstar)
Cik[1][k] = AmbePlusHOCb5[b5][k - 3];
else
Cik[1][k] = AmbeHOCb5[b5][k - 3];
#ifdef AMBE_DEBUG
printf ("C1,%i: %f ", k, Cik[1][k]);
#endif
@ -225,7 +256,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
}
else
{
Cik[2][k] = AmbeHOCb6[b6][k - 3];
if (dstar)
Cik[2][k] = AmbePlusHOCb6[b6][k - 3];
else
Cik[2][k] = AmbeHOCb6[b6][k - 3];
#ifdef AMBE_DEBUG
printf ("C2,%i: %f ", k, Cik[2][k]);
#endif
@ -239,7 +273,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
}
else
{
Cik[3][k] = AmbeHOCb7[b7][k - 3];
if (dstar)
Cik[3][k] = AmbePlusHOCb7[b7][k - 3];
else
Cik[3][k] = AmbeHOCb7[b7][k - 3];
#ifdef AMBE_DEBUG
printf ("C3,%i: %f ", k, Cik[3][k]);
#endif
@ -253,7 +290,10 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
}
else
{
Cik[4][k] = AmbeHOCb8[b8][k - 3];
if (dstar)
Cik[4][k] = AmbePlusHOCb8[b8][k - 3];
else
Cik[4][k] = AmbeHOCb8[b8][k - 3];
#ifdef AMBE_DEBUG
printf ("C4,%i: %f ", k, Cik[4][k]);
#endif
@ -368,3 +408,15 @@ mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int
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));
}

View File

@ -4,6 +4,7 @@
extern "C" {
#endif
int mbe_dequantizeAmbe2250Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b);
int mbe_dequantizeAmbe2400Parms (mbe_parms * cur_mp, mbe_parms * prev_mp, const int *b);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,884 @@
/*
* 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
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

View File

@ -31,6 +31,7 @@
#include "imbe_vocoder/imbe_vocoder.h"
#include "ambe3600x2250_const.h"
#include "ambe3600x2400_const.h"
#include "op25_imbe_frame.h"
#include "mbelib.h"
#include "ambe.h"
@ -150,7 +151,11 @@ static mbe_parms cur_mp;
static mbe_parms prev_mp;
#endif
static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp, mbe_parms*prev_mp) {
static inline float make_f0(int b0) {
return (powf(2, (-4.311767578125 - (2.1336e-2 * ((float)b0+0.5)))));
}
static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp, mbe_parms*prev_mp, bool dstar) {
static const float SQRT_2 = sqrtf(2.0);
static const int b0_lmax = sizeof(b0_lookup) / sizeof(b0_lookup[0]);
// int b[9];
@ -162,7 +167,11 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
return;
}
b[0] = b0_lookup[b0_i];
int L = (int) AmbeLtable[b[0]];
int L;
if (dstar)
L = (int) AmbePlusLtable[b[0]];
else
L = (int) AmbeLtable[b[0]];
#if 1
// adjust b0 until L agrees
while (L != imbe_param->num_harms) {
@ -175,7 +184,10 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
return;
}
b[0] = b0_lookup[b0_i];
L = (int) AmbeLtable[b[0]];
if (dstar)
L = (int) AmbePlusLtable[b[0]];
else
L = (int) AmbeLtable[b[0]];
}
#endif
float m_float2[NUM_HARMS_MAX];
@ -186,15 +198,25 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
float en_min = 0;
b[1] = 0;
for (int n=0; n < 17; n++) {
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 = (int) ((float) l * (float) 16.0 * AmbeW0table[b[0]]);
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 (imbe_param->v_uv_dsn[(kl-1)*3] != AmbeVuv[n][jl])
En += m_float2[l-1];
if (dstar) {
if (imbe_param->v_uv_dsn[(kl-1)*3] != 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;
@ -207,8 +229,11 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
// log spectral amplitudes
float num_harms_f = (float) imbe_param->num_harms;
float log_l_2 = 0.5 * log2f(num_harms_f); // fixme: table lookup
float log_l_w0 = 0.5 * log2f(num_harms_f * AmbeW0table[b[0]] * 2.0 * M_PI) + 2.289;
// float log_l_w0 = 0.5 * log2f(num_harms_f * AmbeW0table[b[0]]) + 2.289;
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;
@ -228,8 +253,13 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
float error;
int error_index;
for (int i1 = 0; i1 < 32; i1++) {
float diff = fabsf(diff_gain - AmbeDg[i1]);
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]);
if (i1 == 0 || diff < error) {
error = diff;
error_index = i1;
@ -258,7 +288,11 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
}
// DCT
const int * J = AmbeLmprbl[imbe_param->num_harms];
const int * J;
if (dstar)
J = AmbePlusLmprbl[imbe_param->num_harms];
else
J = AmbeLmprbl[imbe_param->num_harms];
float * c[4];
int acc = 0;
for (int i=0; i<4; i++) {
@ -299,12 +333,21 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
for (int i=0; i<512; i++) {
float err=0.0;
float diff;
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 (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;
@ -316,14 +359,25 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
for (int i=0; i<128; i++) {
float err=0.0;
float diff;
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 (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;
@ -336,11 +390,15 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
for (int n=0; n < 32; n++) {
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++) {
diff = AmbeHOCb5[n][j-1] - C[ii-1][j+2-1];
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) {
@ -360,7 +418,10 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
diff = AmbeHOCb6[n][j-1] - C[ii-1][j+2-1];
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) {
@ -380,7 +441,10 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
diff = AmbeHOCb7[n][j-1] - C[ii-1][j+2-1];
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) {
@ -396,11 +460,15 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
if (J[ii-1] <= 2) {
b[4+ii] = 0.0;
} else {
for (int n=0; n < 8; n++) {
int max_8 = (dstar) ? 16 : 8;
for (int n=0; n < max_8; n++) {
float err=0.0;
float diff;
for (int j=1; j <= J[ii-1]-2 && j <= 4; j++) {
diff = AmbeHOCb8[n][j-1] - C[ii-1][j+2-1];
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) {
@ -411,7 +479,11 @@ static void encode_ambe(const IMBE_PARAM *imbe_param, int b[], mbe_parms*cur_mp,
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 = mbe_dequantizeAmbe2250Parms (cur_mp, prev_mp, b);
int rc;
if (dstar)
rc = mbe_dequantizeAmbe2400Parms (cur_mp, prev_mp, b);
else
rc = mbe_dequantizeAmbe2250Parms (cur_mp, prev_mp, b);
mbe_moveMbeParms (cur_mp, prev_mp);
}
@ -468,18 +540,25 @@ static void encode_49bit(uint8_t outp[49], const int b[9]) {
}
ambe_encoder::ambe_encoder(void)
: d_49bit_mode(false)
: d_49bit_mode(false),
d_dstar_mode(false)
{
mbe_parms enh_mp;
mbe_initMbeParms (&cur_mp, &prev_mp, &enh_mp);
}
void ambe_encoder::set_dstar_mode(void)
{
d_dstar_mode = true;
}
void ambe_encoder::set_49bit_mode(void)
{
d_49bit_mode = true;
}
// given a buffer of 160 audio samples (S16_LE),
// generate 72-bit ambe codeword (as 36 dibits in codeword[])
// (as 72 bits in codeword[] if in dstar mode)
// or 49-bit output codeword (if set_49bit_mode() has been called)
void ambe_encoder::encode(int16_t samples[], uint8_t codeword[])
{
@ -493,9 +572,11 @@ void ambe_encoder::encode(int16_t samples[], uint8_t codeword[])
vocoder.imbe_encode(frame_vector, samples);
// halfrate audio encoding - output rate is 2450 (49 bits)
encode_ambe(vocoder.param(), b, &cur_mp, &prev_mp);
encode_ambe(vocoder.param(), b, &cur_mp, &prev_mp, d_dstar_mode);
if (d_49bit_mode) {
if (d_dstar_mode) {
interleaver.encode_dstar(codeword, b);
} else if (d_49bit_mode) {
encode_49bit(codeword, b);
} else {
// add FEC and interleaving - output rate is 3600 (72 bits)

View File

@ -27,12 +27,14 @@ public:
void encode(int16_t samples[], uint8_t codeword[]);
ambe_encoder(void);
void set_49bit_mode(void);
void set_dstar_mode(void);
private:
imbe_vocoder vocoder;
p25p2_vf interleaver;
mbe_parms cur_mp;
mbe_parms prev_mp;
bool d_49bit_mode;
bool d_dstar_mode;
};
#endif /* INCLUDED_AMBE_ENCODER_H */

View File

@ -0,0 +1,162 @@
/* -*- c++ -*- */
/*
* DSTAR Encoder (C) Copyright 2017 Max H. Parke KA1RBI
*
* This file is part of OP25
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "mbelib.h"
#include "p25p2_vf.h"
#include "dstar_tx_sb_impl.h"
// #include "dstar_const.h"
#include <op25_imbe_frame.h>
#include <vector>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <assert.h>
#if 0
static inline void print_result(char title[], const uint8_t r[], int len) {
uint8_t buf[256];
for (int i=0; i<len; i++){
buf[i] = r[i] + '0';
}
buf[len] = 0;
printf("%s: %s\n", title, buf);
}
#endif
namespace gr {
namespace op25_repeater {
dstar_tx_sb::sptr
dstar_tx_sb::make(int verbose_flag, const char * config_file, bool fullrate_mode)
{
return gnuradio::get_initial_sptr
(new dstar_tx_sb_impl(verbose_flag, config_file, fullrate_mode));
}
//////////////////////////////////////////////////////////////////////////
static const int MIN_IN = 1;
static const int MAX_IN = 1;
static const int MIN_OUT = 1;
static const int MAX_OUT = 1;
/*
* The private constructor
*/
dstar_tx_sb_impl::dstar_tx_sb_impl(int verbose_flag, const char * config_file, bool fullrate_mode)
: gr::block("dstar_tx_sb",
gr::io_signature::make (MIN_IN, MAX_IN, sizeof(short)),
gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof(char))),
d_verbose_flag(verbose_flag),
d_config_file(config_file)
{
set_output_multiple(96);
d_encoder.set_dstar_mode();
config();
}
/*
* Our virtual destructor.
*/
dstar_tx_sb_impl::~dstar_tx_sb_impl()
{
}
void
dstar_tx_sb_impl::config()
{
FILE * fp1 = fopen(d_config_file, "r");
char line[256];
char * cp;
if (!fp1) {
fprintf(stderr, "dstar_tx_sb_impl:config: failed to open %s\n", d_config_file);
return;
}
for (;;) {
cp = fgets(line, sizeof(line) - 2, fp1);
if (!cp) break;
if (line[0] == '#') continue;
#if 0
if (memcmp(line, "ft=", 3) == 0)
sscanf(&line[3], "%d", &d_ft);
#endif
}
fclose(fp1);
}
void
dstar_tx_sb_impl::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd)
{
// each 96-bit output frame contains one voice code word=160 samples input
const size_t nof_inputs = nof_input_items_reqd.size();
const int nof_vcw = nof_output_items / 480.0;
const int nof_samples_reqd = nof_vcw * 5 * 160;
std::fill(&nof_input_items_reqd[0], &nof_input_items_reqd[nof_inputs], nof_samples_reqd);
}
int
dstar_tx_sb_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
int nconsumed = 0;
int16_t *in;
in = (int16_t *) input_items[0];
uint8_t *out = reinterpret_cast<uint8_t*>(output_items[0]);
int nframes=0;
for (int n=0;n < (noutput_items/96);n++) {
// need (at least) one voice codeword worth of samples
if (ninput_items[0] - nconsumed < 160)
break;
d_encoder.encode(in, out);
in += 160;
nconsumed += 160;
nframes += 1;
out += 96;
}
// Tell runtime system how many input items we consumed on
// each input stream.
if (nconsumed)
consume_each(nconsumed);
// Tell runtime system how many output items we produced.
return (nframes * 96);
}
} /* namespace op25_repeater */
} /* namespace gr */

View File

@ -0,0 +1,66 @@
/* -*- c++ -*- */
/*
* DSTAR Encoder (C) Copyright 2017 Max H. Parke KA1RBI
*
* This file is part of OP25
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OP25_REPEATER_DSTAR_TX_SB_IMPL_H
#define INCLUDED_OP25_REPEATER_DSTAR_TX_SB_IMPL_H
#include <op25_repeater/dstar_tx_sb.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <stdint.h>
#include <vector>
#include <deque>
#include <algorithm>
#include "imbe_vocoder/imbe_vocoder.h"
#include "ambe_encoder.h"
namespace gr {
namespace op25_repeater {
class dstar_tx_sb_impl : public dstar_tx_sb
{
private:
void config(void);
public:
dstar_tx_sb_impl(int verbose_flag, const char * config_file, bool fullrate_mode);
~dstar_tx_sb_impl();
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
int general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
private:
int d_verbose_flag;
const char * d_config_file;
ambe_encoder d_encoder;
};
} // namespace op25_repeater
} // namespace gr
#endif /* INCLUDED_OP25_REPEATER_DSTAR_TX_SB_IMPL_H */

View File

@ -35,6 +35,20 @@ static void dump_i(uint8_t dest[], int src, int count) {
}
}
static inline void store_reg(int reg, uint8_t val[], int len) {
for (int i=0; i<len; i++){
val[i] = (reg >> (len-1-i)) & 1;
}
}
static inline int load_reg(const uint8_t val[], int len) {
int acc = 0;
for (int i=0; i<len; i++){
acc = (acc << 1) + (val[i] & 1);
}
return acc;
}
static const uint32_t pr_n[4096] = { \
2188835, 846719, 1581972, 3511912, 3170211, 1880711, 3779192, 7694256, \
4247119, 7279335, 7068578, 4613212, 4631701, 8096043, 6180930, 5429652, \
@ -797,3 +811,145 @@ static const uint32_t pr_n[4096] = { \
load_i(c2, _c2, 11);
load_i(c3, _c3, 14);
}
void p25p2_vf::encode_dstar(uint8_t result[72], const int b[9]) {
uint8_t pbuf[49];
pbuf[0] = (b[0] >> 6) & 1;
pbuf[1] = (b[0] >> 5) & 1;
pbuf[2] = (b[0] >> 4) & 1;
pbuf[3] = (b[0] >> 3) & 1;
pbuf[4] = (b[0] >> 2) & 1;
pbuf[5] = (b[0] >> 1) & 1;
pbuf[6] = (b[2] >> 5) & 1;
pbuf[7] = (b[2] >> 4) & 1;
pbuf[8] = (b[2] >> 3) & 1;
pbuf[9] = (b[2] >> 2) & 1;
pbuf[10] = (b[3] >> 8) & 1;
pbuf[11] = (b[3] >> 7) & 1;
pbuf[12] = (b[3] >> 6) & 1;
pbuf[13] = (b[3] >> 5) & 1;
pbuf[14] = (b[3] >> 4) & 1;
pbuf[15] = (b[3] >> 3) & 1;
pbuf[16] = (b[3] >> 2) & 1;
pbuf[17] = (b[4] >> 6) & 1;
pbuf[18] = (b[4] >> 5) & 1;
pbuf[19] = (b[4] >> 4) & 1;
pbuf[20] = (b[4] >> 3) & 1;
pbuf[21] = (b[4] >> 2) & 1;
pbuf[22] = (b[5] >> 3) & 1;
pbuf[23] = (b[5] >> 2) & 1;
pbuf[25] = (b[5] >> 1) & 1;
pbuf[26] = b[5] & 1;
pbuf[27] = (b[6] >> 3) & 1;
pbuf[28] = (b[6] >> 2) & 1;
pbuf[29] = (b[6] >> 1) & 1;
pbuf[30] = b[6] & 1;
pbuf[31] = (b[7] >> 3) & 1;
pbuf[32] = (b[7] >> 2) & 1;
pbuf[33] = (b[7] >> 1) & 1;
pbuf[34] = b[7] & 1;
pbuf[35] = (b[8] >> 3) & 1;
pbuf[36] = (b[8] >> 2) & 1;
pbuf[37] = (b[8] >> 1) & 1;
pbuf[38] = (b[1] >> 3) & 1;
pbuf[39] = (b[1] >> 2) & 1;
pbuf[40] = (b[1] >> 1) & 1;
pbuf[41] = b[1] & 1;
pbuf[42] = (b[2] >> 1) & 1;
pbuf[43] = b[2] & 1;
pbuf[44] = (b[3] >> 1) & 1;
pbuf[45] = b[3] & 1;
pbuf[46] = (b[4] >> 1) & 1;
pbuf[47] = b[4] & 1;
pbuf[48] = b[0] & 1;
int u0 = load_reg(pbuf+0, 12);
int u1 = load_reg(pbuf+12, 12);
int u2 = load_reg(pbuf+24, 11);
int u3 = load_reg(pbuf+35, 14);
int m1 = pr_n[u0];
int c0 = golay_24_encode(u0);
int c1 = golay_23_encode(u1) ^ m1;
int c2 = u2;
int c3 = u3;
uint8_t ambe_fr[4][24];
store_reg(c0, ambe_fr[0], 24);
store_reg(c1, ambe_fr[1], 23);
store_reg(c2, ambe_fr[2], 11);
store_reg(c3, ambe_fr[3], 14);
result[0] = ambe_fr[0][10];
result[1] = ambe_fr[0][22];
result[2] = ambe_fr[3][11];
result[3] = ambe_fr[2][9];
result[4] = ambe_fr[1][10];
result[5] = ambe_fr[1][22];
result[6] = ambe_fr[0][11];
result[7] = ambe_fr[0][23];
result[8] = ambe_fr[1][8];
result[9] = ambe_fr[1][20];
result[10] = ambe_fr[0][9];
result[11] = ambe_fr[0][21];
result[12] = ambe_fr[3][10];
result[13] = ambe_fr[2][8];
result[14] = ambe_fr[1][9];
result[15] = ambe_fr[1][21];
result[16] = ambe_fr[3][8];
result[17] = ambe_fr[2][6];
result[18] = ambe_fr[1][7];
result[19] = ambe_fr[1][19];
result[20] = ambe_fr[0][8];
result[21] = ambe_fr[0][20];
result[22] = ambe_fr[3][9];
result[23] = ambe_fr[2][7];
result[24] = ambe_fr[0][6];
result[25] = ambe_fr[0][18];
result[26] = ambe_fr[3][7];
result[27] = ambe_fr[2][5];
result[28] = ambe_fr[1][6];
result[29] = ambe_fr[1][18];
result[30] = ambe_fr[0][7];
result[31] = ambe_fr[0][19];
result[32] = ambe_fr[1][4];
result[33] = ambe_fr[1][16];
result[34] = ambe_fr[0][5];
result[35] = ambe_fr[0][17];
result[36] = ambe_fr[3][6];
result[37] = ambe_fr[2][4];
result[38] = ambe_fr[1][5];
result[39] = ambe_fr[1][17];
result[40] = ambe_fr[3][4];
result[41] = ambe_fr[2][2];
result[42] = ambe_fr[1][3];
result[43] = ambe_fr[1][15];
result[44] = ambe_fr[0][4];
result[45] = ambe_fr[0][16];
result[46] = ambe_fr[3][5];
result[47] = ambe_fr[2][3];
result[48] = ambe_fr[0][2];
result[49] = ambe_fr[0][14];
result[50] = ambe_fr[3][3];
result[51] = ambe_fr[2][1];
result[52] = ambe_fr[1][2];
result[53] = ambe_fr[1][14];
result[54] = ambe_fr[0][3];
result[55] = ambe_fr[0][15];
result[56] = ambe_fr[1][0];
result[57] = ambe_fr[1][12];
result[58] = ambe_fr[0][1];
result[59] = ambe_fr[0][13];
result[60] = ambe_fr[3][2];
result[61] = ambe_fr[2][0];
result[62] = ambe_fr[1][1];
result[63] = ambe_fr[1][13];
result[64] = ambe_fr[3][0];
result[65] = ambe_fr[3][12];
result[66] = ambe_fr[2][10];
result[67] = ambe_fr[1][11];
result[68] = ambe_fr[0][0];
result[69] = ambe_fr[0][12];
result[70] = ambe_fr[3][1];
result[71] = ambe_fr[3][13];
}

View File

@ -26,6 +26,7 @@ class p25p2_vf {
public:
void process_vcw(const uint8_t vf[], int* b);
void encode_vcw(uint8_t vf[], const int* b);
void encode_dstar(uint8_t result[72], const int b[9]);
private:
void extract_vcw(const uint8_t _vf[], int& _c0, int& _c1, int& _c2, int& _c3);
void interleave_vcw(uint8_t _vf[], int _c0, int _c1, int _c2, int _c3);