More pruning. Rename class ready for integration.
git-svn-id: http://op25.osmocom.org/svn/trunk@163 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
e01775be01
commit
3d2ad91012
185
imbe/imbe.cc
185
imbe/imbe.cc
|
@ -1026,7 +1026,7 @@ static const float Uq[129] = {
|
||||||
0.000000
|
0.000000
|
||||||
};
|
};
|
||||||
|
|
||||||
op25_imbe::op25_imbe() :
|
software_imbe_decoder::software_imbe_decoder() :
|
||||||
out(fopen("audio.pcm", "w"))
|
out(fopen("audio.pcm", "w"))
|
||||||
{
|
{
|
||||||
int i,j;
|
int i,j;
|
||||||
|
@ -1048,7 +1048,7 @@ op25_imbe::op25_imbe() :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
op25_imbe::~op25_imbe()
|
software_imbe_decoder::~software_imbe_decoder()
|
||||||
{
|
{
|
||||||
if(out) {
|
if(out) {
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
@ -1056,7 +1056,7 @@ op25_imbe::~op25_imbe()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::decode(uint8_t *buf)
|
software_imbe_decoder::decode(uint8_t *buf)
|
||||||
{
|
{
|
||||||
// process input 144-bit IMBE frame - converts to 88-bit frame
|
// process input 144-bit IMBE frame - converts to 88-bit frame
|
||||||
int i;
|
int i;
|
||||||
|
@ -1105,7 +1105,7 @@ op25_imbe::decode(uint8_t *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::adaptive_smoothing(float SE, float ER, float ET)
|
software_imbe_decoder::adaptive_smoothing(float SE, float ER, float ET)
|
||||||
{
|
{
|
||||||
float VM;
|
float VM;
|
||||||
float AM;
|
float AM;
|
||||||
|
@ -1141,7 +1141,7 @@ op25_imbe::adaptive_smoothing(float SE, float ER, float ET)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::fft(float REX[], float IMX[])
|
software_imbe_decoder::fft(float REX[], float IMX[])
|
||||||
{
|
{
|
||||||
int I;
|
int I;
|
||||||
int J;
|
int J;
|
||||||
|
@ -1186,7 +1186,7 @@ op25_imbe::fft(float REX[], float IMX[])
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::decode_audio(uint8_t *A)
|
software_imbe_decoder::decode_audio(uint8_t *A)
|
||||||
{
|
{
|
||||||
uint32_t u0, u1, u2, u3, u4, u5, u6, u7, E0, ET;
|
uint32_t u0, u1, u2, u3, u4, u5, u6, u7, E0, ET;
|
||||||
int K;
|
int K;
|
||||||
|
@ -1245,7 +1245,7 @@ op25_imbe::decode_audio(uint8_t *A)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::decode_spectral_amplitudes(int Start3, int Start8)
|
software_imbe_decoder::decode_spectral_amplitudes(int Start3, int Start8)
|
||||||
{
|
{
|
||||||
float G[7]; //Can we use C(1 to 6,1) for this?
|
float G[7]; //Can we use C(1 to 6,1) for this?
|
||||||
int J[7];
|
int J[7];
|
||||||
|
@ -1335,7 +1335,7 @@ op25_imbe::decode_spectral_amplitudes(int Start3, int Start8)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::decode_vuv(int K)
|
software_imbe_decoder::decode_vuv(int K)
|
||||||
{
|
{
|
||||||
int bee1, ell, kay;
|
int bee1, ell, kay;
|
||||||
bee1 = bee[1];
|
bee1 = bee[1];
|
||||||
|
@ -1351,7 +1351,7 @@ op25_imbe::decode_vuv(int K)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::enhance_spectral_amplitudes(float& SE)
|
software_imbe_decoder::enhance_spectral_amplitudes(float& SE)
|
||||||
{
|
{
|
||||||
float RM0;
|
float RM0;
|
||||||
float RM1;
|
float RM1;
|
||||||
|
@ -1399,7 +1399,7 @@ op25_imbe::enhance_spectral_amplitudes(float& SE)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::ifft(float FDi[], float FDq[], float TD[]) // ToDo: replace "real IFFT" with fftw3 IFFT proc!
|
software_imbe_decoder::ifft(float FDi[], float FDq[], float TD[]) // ToDo: replace "real IFFT" with fftw3 IFFT proc!
|
||||||
{
|
{
|
||||||
//Inverse FFT:
|
//Inverse FFT:
|
||||||
// transform 129-point freq domain(FDx) to 256-point time domain(TD)
|
// transform 129-point freq domain(FDx) to 256-point time domain(TD)
|
||||||
|
@ -1470,7 +1470,7 @@ op25_imbe::ifft(float FDi[], float FDq[], float TD[]) // ToDo: replace "real IFF
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t
|
uint16_t
|
||||||
op25_imbe::rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7)
|
software_imbe_decoder::rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7)
|
||||||
{
|
{
|
||||||
int K;
|
int K;
|
||||||
int I, ubit, Seq, col;
|
int I, ubit, Seq, col;
|
||||||
|
@ -1572,7 +1572,7 @@ op25_imbe::rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::synth_unvoiced()
|
software_imbe_decoder::synth_unvoiced()
|
||||||
{
|
{
|
||||||
float Uwi[256] ;
|
float Uwi[256] ;
|
||||||
float Uwq[256] ;
|
float Uwq[256] ;
|
||||||
|
@ -1639,7 +1639,7 @@ op25_imbe::synth_unvoiced()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::synth_voiced()
|
software_imbe_decoder::synth_voiced()
|
||||||
{
|
{
|
||||||
float MaxL;
|
float MaxL;
|
||||||
float Tmp;
|
float Tmp;
|
||||||
|
@ -1723,7 +1723,7 @@ op25_imbe::synth_voiced()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::unpack(uint8_t *A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET)
|
software_imbe_decoder::unpack(uint8_t *A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET)
|
||||||
{
|
{
|
||||||
E0 = A[0];
|
E0 = A[0];
|
||||||
ET = A[1];
|
ET = A[1];
|
||||||
|
@ -1744,7 +1744,7 @@ op25_imbe::unpack(uint8_t *A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
op25_imbe::extract(const uint8_t* buf, size_t begin, size_t end)
|
software_imbe_decoder::extract(const uint8_t* buf, size_t begin, size_t end)
|
||||||
{
|
{
|
||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
for(size_t i = begin; i < end; ++i) {
|
for(size_t i = begin; i < end; ++i) {
|
||||||
|
@ -1754,66 +1754,10 @@ op25_imbe::extract(const uint8_t* buf, size_t begin, size_t end)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
// ToDo: swap hamming and golay for external implementations
|
||||||
op25_imbe::vfPickBits0(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 0, 23);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits1(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 23, 23 + 23);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits2(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 46, 46 + 23);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits3(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 69, 69 + 23);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits4(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 92, 92 + 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits5(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 107, 107 + 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits6(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 122, 122 + 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
|
||||||
op25_imbe::vfPickBits7(uint8_t* buf)
|
|
||||||
{
|
|
||||||
return extract(buf, 137, 135 + 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
op25_imbe::gly23127Dec(unsigned int& CW, unsigned int& ET)
|
gly23127GetSyn(unsigned int pattern)
|
||||||
{
|
|
||||||
unsigned int correction;
|
|
||||||
correction = gly23127DecTbl[gly23127GetSyn(CW)];
|
|
||||||
ET = ET +(correction & 3);
|
|
||||||
CW = (CW ^ correction) / 2048;
|
|
||||||
return CW;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
op25_imbe::gly23127GetSyn(unsigned int pattern)
|
|
||||||
{
|
{
|
||||||
unsigned int aux;
|
unsigned int aux;
|
||||||
aux = 0x400000;
|
aux = 0x400000;
|
||||||
|
@ -1827,7 +1771,34 @@ op25_imbe::gly23127GetSyn(unsigned int pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
op25_imbe::vfPrGen15(unsigned int& Pr)
|
gly23127Dec(unsigned int& CW, unsigned int& ET)
|
||||||
|
{
|
||||||
|
unsigned int correction;
|
||||||
|
correction = gly23127DecTbl[gly23127GetSyn(CW)];
|
||||||
|
ET = ET +(correction & 3);
|
||||||
|
CW = (CW ^ correction) / 2048;
|
||||||
|
return CW;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define golay_23_decode gly23127Dec
|
||||||
|
|
||||||
|
int
|
||||||
|
vfHmg15113Dec(int RX, int ET) // should be int& ET!
|
||||||
|
{
|
||||||
|
int Dat, Par, correction;
|
||||||
|
Dat = RX / 16; Par = RX & 15;
|
||||||
|
correction = hmg15113DecTbl[hmg15113EncTbl[Dat] ^ Par];
|
||||||
|
if( correction) {
|
||||||
|
ET = ET + 1;
|
||||||
|
Dat = Dat ^ correction;
|
||||||
|
}
|
||||||
|
return Dat;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define hamming_15_decode vfHmg15113Dec
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
software_imbe_decoder::vfPrGen15(unsigned int& Pr)
|
||||||
{
|
{
|
||||||
int i,n;
|
int i,n;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -1841,7 +1812,7 @@ op25_imbe::vfPrGen15(unsigned int& Pr)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
op25_imbe::vfPrGen23(unsigned int& Pr)
|
software_imbe_decoder::vfPrGen23(unsigned int& Pr)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for(int i = 22; i >= 0; i--) {
|
for(int i = 22; i >= 0; i--) {
|
||||||
|
@ -1854,48 +1825,38 @@ op25_imbe::vfPrGen23(unsigned int& Pr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
op25_imbe::correct(uint8_t* A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET)
|
software_imbe_decoder::correct(uint8_t* A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET)
|
||||||
{
|
{
|
||||||
unsigned int RX = 0;
|
|
||||||
|
|
||||||
ET = 0;
|
ET = 0;
|
||||||
|
|
||||||
RX = vfPickBits0(A);
|
uint32_t RX = extract(A, 0, 23);
|
||||||
u0 = gly23127Dec(RX, ET);
|
u0 = golay_23_decode(RX, ET);
|
||||||
E0 = ET;
|
E0 = ET;
|
||||||
|
|
||||||
unsigned int Pr = 16 * u0;
|
uint32_t pn = u0 << 4;
|
||||||
unsigned int m1 = vfPrGen23(Pr);
|
uint32_t m1 = vfPrGen23(pn);
|
||||||
unsigned int m2 = vfPrGen23(Pr);
|
RX = extract(A, 23, 46) ^ m1;
|
||||||
unsigned int m3 = vfPrGen23(Pr);
|
u1 = golay_23_decode(RX, ET);
|
||||||
unsigned int m4 = vfPrGen15(Pr);
|
|
||||||
unsigned int m5 = vfPrGen15(Pr);
|
|
||||||
unsigned int m6 = vfPrGen15(Pr);
|
|
||||||
|
|
||||||
RX = vfPickBits1(A) ^ m1;
|
uint32_t m2 = vfPrGen23(pn);
|
||||||
u1 = gly23127Dec(RX, ET);
|
RX = extract(A, 46, 69) ^ m2;
|
||||||
RX = vfPickBits2(A) ^ m2;
|
u2 = golay_23_decode(RX, ET);
|
||||||
u2 = gly23127Dec(RX, ET);
|
|
||||||
RX = vfPickBits3(A) ^ m3;
|
|
||||||
u3 = gly23127Dec(RX, ET);
|
|
||||||
RX = vfPickBits4(A) ^ m4;
|
|
||||||
u4 = vfHmg15113Dec(RX, ET);
|
|
||||||
RX = vfPickBits5(A) ^ m5;
|
|
||||||
u5 = vfHmg15113Dec(RX, ET);
|
|
||||||
RX = vfPickBits6(A) ^ m6;
|
|
||||||
u6 = vfHmg15113Dec(RX, ET);
|
|
||||||
u7 = vfPickBits7(A);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
uint32_t m3 = vfPrGen23(pn);
|
||||||
op25_imbe::vfHmg15113Dec(int RX, int ET) // should be int& ET!
|
RX = extract(A, 69, 92) ^ m3;
|
||||||
{
|
u3 = golay_23_decode(RX, ET);
|
||||||
int Dat, Par, correction;
|
|
||||||
Dat = RX / 16; Par = RX & 15;
|
uint32_t m4 = vfPrGen15(pn);
|
||||||
correction = hmg15113DecTbl[hmg15113EncTbl[Dat] ^ Par];
|
RX = extract(A, 92, 107) ^ m4;
|
||||||
if( correction) {
|
u4 = hamming_15_decode(RX, ET);
|
||||||
ET = ET + 1;
|
|
||||||
Dat = Dat ^ correction;
|
uint32_t m5 = vfPrGen15(pn);
|
||||||
}
|
RX = extract(A, 107, 122) ^ m5;
|
||||||
return Dat;
|
u5 = hamming_15_decode(RX, ET);
|
||||||
|
|
||||||
|
uint32_t m6 = vfPrGen15(pn);
|
||||||
|
RX = extract(A, 122, 137) ^ m6;
|
||||||
|
u6 = hamming_15_decode(RX, ET);
|
||||||
|
|
||||||
|
u7 = extract(A, 137, 144);
|
||||||
}
|
}
|
||||||
|
|
48
imbe/imbe.h
48
imbe/imbe.h
|
@ -21,16 +21,16 @@
|
||||||
* 02110-1301, USA.
|
* 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INCLUDED_IMBE_H
|
#ifndef INCLUDED_SOFTWARE_IMBE_DECODER_H
|
||||||
#define INCLUDED_IMBE_H
|
#define INCLUDED_SOFTWARE_IMBE_DECODER_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
class op25_imbe {
|
class software_imbe_decoder {
|
||||||
public:
|
public:
|
||||||
op25_imbe();
|
software_imbe_decoder();
|
||||||
~op25_imbe();
|
virtual ~software_imbe_decoder();
|
||||||
void decode(uint8_t *buf);
|
virtual void decode(uint8_t *buf);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//NOTE: Single-letter variable names are upper case only;
|
//NOTE: Single-letter variable names are upper case only;
|
||||||
|
@ -38,12 +38,12 @@ private:
|
||||||
|
|
||||||
// global Seq ER ?
|
// global Seq ER ?
|
||||||
|
|
||||||
int bee[58]; //Encoded Spectral Amplitudes
|
int bee[58]; //Encoded Spectral Amplitudes
|
||||||
float M[57][2]; //Enhanced Spectral Amplitudes
|
float M[57][2]; //Enhanced Spectral Amplitudes
|
||||||
float Mu[57][2]; //Unenhanced Spectral Amplitudes
|
float Mu[57][2]; //Unenhanced Spectral Amplitudes
|
||||||
int vee[57][2]; //V/UV decisions
|
int vee[57][2]; //V/UV decisions
|
||||||
float suv[160]; //Unvoiced samples
|
float suv[160]; //Unvoiced samples
|
||||||
float sv[160]; //Voiced samples
|
float sv[160]; //Voiced samples
|
||||||
float log2Mu[58][2];
|
float log2Mu[58][2];
|
||||||
float Olduw[256];
|
float Olduw[256];
|
||||||
float psi1;
|
float psi1;
|
||||||
|
@ -55,7 +55,7 @@ private:
|
||||||
int OldL;
|
int OldL;
|
||||||
float w0;
|
float w0;
|
||||||
float Oldw0;
|
float Oldw0;
|
||||||
float Luv; //number of unvoiced spectral amplitudes
|
float Luv; //number of unvoiced spectral amplitudes
|
||||||
int BOT;
|
int BOT;
|
||||||
|
|
||||||
char sym_b[4096];
|
char sym_b[4096];
|
||||||
|
@ -65,24 +65,9 @@ private:
|
||||||
|
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
// member functions
|
|
||||||
uint32_t extract(const uint8_t* buf, size_t begin, size_t end);
|
uint32_t extract(const uint8_t* buf, size_t begin, size_t end);
|
||||||
|
uint32_t vfPrGen15(uint32_t& pn);
|
||||||
unsigned int vfPickBits0(unsigned char *);
|
uint32_t vfPrGen23(uint32_t& pn);
|
||||||
unsigned int vfPickBits1(unsigned char *);
|
|
||||||
unsigned int vfPickBits2(unsigned char *);
|
|
||||||
unsigned int vfPickBits3(unsigned char *);
|
|
||||||
unsigned int vfPickBits4(unsigned char *);
|
|
||||||
unsigned int vfPickBits5(unsigned char *);
|
|
||||||
unsigned int vfPickBits6(unsigned char *);
|
|
||||||
unsigned int vfPickBits7(unsigned char *);
|
|
||||||
|
|
||||||
int vfHmg15113Dec(int , int );
|
|
||||||
unsigned int gly23127Dec(unsigned int& , unsigned int& );
|
|
||||||
unsigned int gly23127GetSyn(unsigned int );
|
|
||||||
|
|
||||||
unsigned int vfPrGen15(unsigned int& );
|
|
||||||
unsigned int vfPrGen23(unsigned int& );
|
|
||||||
|
|
||||||
void correct(uint8_t* A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET);
|
void correct(uint8_t* A, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET);
|
||||||
|
|
||||||
|
@ -92,6 +77,7 @@ private:
|
||||||
void adaptive_smoothing(float, float, float );
|
void adaptive_smoothing(float, float, float );
|
||||||
void fft(float i[], float q[]);
|
void fft(float i[], float q[]);
|
||||||
void enhance_spectral_amplitudes(float&);
|
void enhance_spectral_amplitudes(float&);
|
||||||
|
|
||||||
void ifft(float i[], float q[], float[]);
|
void ifft(float i[], float q[], float[]);
|
||||||
uint16_t rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7);
|
uint16_t rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7);
|
||||||
void synth_unvoiced();
|
void synth_unvoiced();
|
||||||
|
@ -100,4 +86,4 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* INCLUDED_IMBE_H */
|
#endif /* INCLUDED_SOFTWARE_IMBE_DECODER_H */
|
||||||
|
|
Reference in New Issue