|
|
|
@ -16,83 +16,84 @@
|
|
|
|
#include "MBEDecoder.h"
|
|
|
|
#include "MBEDecoder.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace edac;
|
|
|
|
using namespace edac;
|
|
|
|
using namespace vocoder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace vocoder {
|
|
|
|
// Constants
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int MBEDecoder::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, };
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
const int MBEDecoder::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 MBEDecoder::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 MBEDecoder::rW[36] = {
|
|
|
|
const int MBEDecoder::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 MBEDecoder::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, 1,
|
|
|
|
0, 1, 0, 1, 0, 1,
|
|
|
|
0, 1, 0, 1, 0, 1,
|
|
|
|
0, 1, 0, 1, 0, 2,
|
|
|
|
0, 1, 0, 1, 0, 2,
|
|
|
|
0, 2, 0, 2, 0, 2,
|
|
|
|
0, 2, 0, 2, 0, 2,
|
|
|
|
0, 2, 0, 2, 0, 2
|
|
|
|
0, 2, 0, 2, 0, 2
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const int MBEDecoder::rX[36] = {
|
|
|
|
const int MBEDecoder::rX[36] = {
|
|
|
|
23, 10, 22, 9, 21, 8,
|
|
|
|
23, 10, 22, 9, 21, 8,
|
|
|
|
20, 7, 19, 6, 18, 5,
|
|
|
|
20, 7, 19, 6, 18, 5,
|
|
|
|
17, 4, 16, 3, 15, 2,
|
|
|
|
17, 4, 16, 3, 15, 2,
|
|
|
|
14, 1, 13, 0, 12, 10,
|
|
|
|
14, 1, 13, 0, 12, 10,
|
|
|
|
11, 9, 10, 8, 9, 7,
|
|
|
|
11, 9, 10, 8, 9, 7,
|
|
|
|
8, 6, 7, 5, 6, 4
|
|
|
|
8, 6, 7, 5, 6, 4
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// bit 0
|
|
|
|
// bit 0
|
|
|
|
const int MBEDecoder::rY[36] = {
|
|
|
|
const int MBEDecoder::rY[36] = {
|
|
|
|
0, 2, 0, 2, 0, 2,
|
|
|
|
0, 2, 0, 2, 0, 2,
|
|
|
|
0, 2, 0, 3, 0, 3,
|
|
|
|
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,
|
|
|
|
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 MBEDecoder::rZ[36] = {
|
|
|
|
const int MBEDecoder::rZ[36] = {
|
|
|
|
5, 3, 4, 2, 3, 1,
|
|
|
|
5, 3, 4, 2, 3, 1,
|
|
|
|
2, 0, 1, 13, 0, 12,
|
|
|
|
2, 0, 1, 13, 0, 12,
|
|
|
|
22, 11, 21, 10, 20, 9,
|
|
|
|
22, 11, 21, 10, 20, 9,
|
|
|
|
19, 8, 18, 7, 17, 6,
|
|
|
|
19, 8, 18, 7, 17, 6,
|
|
|
|
16, 5, 15, 4, 14, 3,
|
|
|
|
16, 5, 15, 4, 14, 3,
|
|
|
|
13, 2, 12, 1, 11, 0
|
|
|
|
13, 2, 12, 1, 11, 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Public Class Members
|
|
|
|
// Public Class Members
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
/* Initializes a new instance of the MBEDecoder class. */
|
|
|
|
/* Initializes a new instance of the MBEDecoder class. */
|
|
|
|
|
|
|
|
|
|
|
|
MBEDecoder::MBEDecoder(MBE_DECODER_MODE mode) :
|
|
|
|
MBEDecoder::MBEDecoder(MBE_DECODER_MODE mode) :
|
|
|
|
m_mbelibParms(NULL),
|
|
|
|
m_mbelibParms(NULL),
|
|
|
|
m_mbeMode(mode),
|
|
|
|
m_mbeMode(mode),
|
|
|
|
m_gainAdjust(1.0f)
|
|
|
|
m_gainAdjust(1.0f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_mbelibParms = new mbelibParms();
|
|
|
|
m_mbelibParms = new mbelibParms();
|
|
|
|
mbe_initMbeParms(m_mbelibParms->m_cur_mp, m_mbelibParms->m_prev_mp, m_mbelibParms->m_prev_mp_enhanced);
|
|
|
|
mbe_initMbeParms(m_mbelibParms->m_cur_mp, m_mbelibParms->m_prev_mp, m_mbelibParms->m_prev_mp_enhanced);
|
|
|
|
|
|
|
|
|
|
|
|
::memset(gainMaxBuf, 0, sizeof(float) * 200);
|
|
|
|
::memset(gainMaxBuf, 0, sizeof(float) * 200);
|
|
|
|
gainMaxBufPtr = gainMaxBuf;
|
|
|
|
gainMaxBufPtr = gainMaxBuf;
|
|
|
|
gainMaxIdx = 0;
|
|
|
|
gainMaxIdx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Finalizes a instance of the MBEDecoder class. */
|
|
|
|
/* Finalizes a instance of the MBEDecoder class. */
|
|
|
|
|
|
|
|
|
|
|
|
MBEDecoder::~MBEDecoder()
|
|
|
|
MBEDecoder::~MBEDecoder()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete m_mbelibParms;
|
|
|
|
delete m_mbelibParms;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Decodes the given MBE codewords to deinterleaved MBE bits using the decoder mode. */
|
|
|
|
/* Decodes the given MBE codewords to deinterleaved MBE bits using the decoder mode. */
|
|
|
|
|
|
|
|
|
|
|
|
int32_t MBEDecoder::decodeBits(uint8_t* codeword, char* mbeBits)
|
|
|
|
int32_t MBEDecoder::decodeBits(uint8_t* codeword, char* mbeBits)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int32_t errs = 0;
|
|
|
|
int32_t errs = 0;
|
|
|
|
float samples[160U];
|
|
|
|
float samples[160U];
|
|
|
|
::memset(samples, 0x00U, 160U * sizeof(float));
|
|
|
|
::memset(samples, 0x00U, 160U * sizeof(float));
|
|
|
|
@ -150,12 +151,12 @@ int32_t MBEDecoder::decodeBits(uint8_t* codeword, char* mbeBits)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return errs;
|
|
|
|
return errs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Decodes the given MBE codewords to PCM samples using the decoder mode. */
|
|
|
|
/* Decodes the given MBE codewords to PCM samples using the decoder mode. */
|
|
|
|
|
|
|
|
|
|
|
|
int32_t MBEDecoder::decodeF(uint8_t* codeword, float samples[])
|
|
|
|
int32_t MBEDecoder::decodeF(uint8_t* codeword, float samples[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int32_t errs = 0;
|
|
|
|
int32_t errs = 0;
|
|
|
|
switch (m_mbeMode)
|
|
|
|
switch (m_mbeMode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -213,12 +214,12 @@ int32_t MBEDecoder::decodeF(uint8_t* codeword, float samples[])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return errs;
|
|
|
|
return errs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Decodes the given MBE codewords to PCM samples using the decoder mode. */
|
|
|
|
/* Decodes the given MBE codewords to PCM samples using the decoder mode. */
|
|
|
|
|
|
|
|
|
|
|
|
int32_t MBEDecoder::decode(uint8_t* codeword, int16_t samples[])
|
|
|
|
int32_t MBEDecoder::decode(uint8_t* codeword, int16_t samples[])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float samplesF[160U];
|
|
|
|
float samplesF[160U];
|
|
|
|
::memset(samplesF, 0x00U, 160U * sizeof(float));
|
|
|
|
::memset(samplesF, 0x00U, 160U * sizeof(float));
|
|
|
|
int32_t errs = decodeF(codeword, samplesF);
|
|
|
|
int32_t errs = decodeF(codeword, samplesF);
|
|
|
|
@ -313,4 +314,30 @@ int32_t MBEDecoder::decode(uint8_t* codeword, int16_t samples[])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return errs;
|
|
|
|
return errs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extern methods for C#/C++ interop
|
|
|
|
|
|
|
|
MBEDecoder* MBEDecoder_Create(MBE_DECODER_MODE mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new MBEDecoder(mode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t MBEDecoder_Decode(MBEDecoder* pDecoder, uint8_t* codeword, int16_t* samples)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pDecoder != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return pDecoder->decode(codeword, samples);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MBEDecoder_Delete(MBEDecoder* pDecoder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pDecoder != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
delete pDecoder;
|
|
|
|
|
|
|
|
pDecoder = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace vocoder
|