- more work on EVS

This commit is contained in:
Dmytro Bogovych 2020-06-15 17:54:28 +03:00
parent 46c355e29a
commit 3bffbb446d
29 changed files with 236 additions and 171 deletions

View File

@ -1,4 +1,4 @@
/* Copyright(C) 2007-2015 VoIP objects (voipobjects.com)
/* Copyright(C) 2007-2020 VoIP objects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -79,6 +79,9 @@
#define MT_GSMEFR_PAYLOADTYPE -1
#define MT_GSMEFR_CODECNAME "GERAN-EFR"
#define MT_EVS_PAYLOADTYPE -1
#define MT_EVS_CODECNAME "EVS"
// OPUS codec defines
// #define USE_OPUS_CODEC
#define MT_OPUS_CODEC_PT -1

View File

@ -1,7 +1,8 @@
/* Copyright(C) 2007-2019 VoIPobjects (voipobjects.com)
/* Copyright(C) 2007-2020 VoIPobjects (voipobjects.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include "../config.h"
#include "MT_CodecList.h"
@ -11,7 +12,7 @@
# include "MT_AmrCodec.h"
#endif
#include <algorithm>
#include "MT_EvsCodec.h"
using namespace MT;
@ -60,6 +61,9 @@ CodecList::CodecList(const Settings& settings)
#ifndef TARGET_ANDROID
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
#endif
if (mSettings.mEvsPayloadType != -1)
mFactoryList.push_back(new EVSCodec::EVSFactory(EVSCodec::StreamParameters()));
}
CodecList::~CodecList()

View File

@ -44,6 +44,7 @@ public:
int mGsmFrPayloadLength = 33; // Expected GSM payload length
int mGsmHrPayloadType = MT_GSMHR_PAYLOADTYPE;
int mGsmEfrPayloadType = MT_GSMEFR_PAYLOADTYPE;
int mEvsPayloadType = MT_EVS_PAYLOADTYPE;
struct OpusSpec
{

View File

@ -1,6 +1,122 @@
#include "MT_EvsCodec.h"
//bool
/*-------------------------------------------------------------------*
* rate2AMRWB_IOmode()
*
* lookup AMRWB IO mode
*-------------------------------------------------------------------*/
static Word16 rate2AMRWB_IOmode(
Word32 rate /* i: bit rate */
);
/*Revers Function*/
extern Word16 AMRWB_IOmode2rate(
Word32 mode
);
/*-------------------------------------------------------------------*
* rate2EVSmode()
*
* lookup EVS mode
*-------------------------------------------------------------------*/
extern Word16 rate2EVSmode(
Word32 rate /* i: bit rate */
);
/*Revers Function*/
extern Word16 EVSmode2rate(
Word32 mode
);
#define CMR_OFF -1
#define CMR_ON 0
#define CMR_ONLY 1
static const std::map<int, std::set<int>> BitrateToBandwidth_Tab{
{5900, {NB, WB}},
{7200, {NB, WB}},
{8000, {NB, WB}},
{9600, {NB, WB, SWB}},
{13200, {NB, WB, SWB}}, //if channel aware mode - WB, SWB
{16400, {NB, WB, SWB, FB}},
{24400, {NB, WB, SWB, FB}},
{32000, {WB, SWB, FB}},
{48000, {WB, SWB, FB}},
{64000, {WB, SWB, FB}},
{96000, {WB, SWB, FB}},
{128000, {WB, SWB, FB}}
};
/* Protected payload size/Fixed bitrate to EVS ()*/
static const std::map<int, int> Bitrate2PayloadSize_EVSAMR_WB{
/*{bitrate, payload size}*/
{ SID_1k75, 56}, //AMR-WB I/O SIB
{ACELP_6k60, 136},
{ACELP_8k85, 184},
{ACELP_12k65, 256},
{ACELP_14k25, 288},
{ACELP_15k85, 320},
{ACELP_18k25, 368},
{ACELP_19k85, 400},
{ACELP_23k05, 464},
{ACELP_23k85, 480}
};
static const std::map<int, int> Bitrate2PayloadSize_EVS{
/*{bitrate, payload size}*/
{FRAME__NO_DATA, 0},
{SID_2k40, 48}, //EVS Primary SID
{PPP_NELP_2k80, 56}, //special for full header
{ACELP_7k20, 144},
{ACELP_8k00, 160},
{ACELP_9k60, 192},
{ACELP_13k20, 264},
{ACELP_16k40, 328},
{ACELP_24k40, 488},
{ACELP_32k, 640},
{ACELP_48k, 960},
{ACELP_64k, 1280},
{HQ_96k, 1920},
{HQ_128k, 2560}
};
/* Protected payload size/Fixed bitrate to EVS ()*/
static const std::map<int, int> FixedPayload_EVSPrimary{
/*{payload size , bitrate}*/
{48, 2400}, //EVS Primary SID
{56, 2800}, //special for full header
{144, 7200},
{160, 8000},
{192, 9600},
{264, 13200},
{328, 16400},
{488, 24400},
{640, 32000},
{960, 48000},
{1280, 64000},
{1920, 96000},
{2560, 128000}
};
static const std::map<int, int> FixedPayload_EVSAMR_WB{
/*{payload size , bitrate}*/
{136, 6600},
{184, 8850},
{256, 12650},
{288, 14250},
{320, 15850},
{368, 18250},
{400, 19850},
{464, 23050},
{480, 23850}
};
namespace MT
{
EVSCodec::EVSFactory::EVSFactory(StreamParameters sp) : _sp(sp)
{}
@ -204,3 +320,5 @@ void EVSCodec::initDecoder(const StreamParameters& sp)
srand(static_cast<unsigned int>(time(nullptr)));
}
} // end of namespace MT

View File

@ -10,172 +10,27 @@
#include <assert.h>
#include <sstream>
extern "C" {
//#include "lib_dec/EvsRXlib.h"
#include "libevs/lib_com/prot.h"
}
#include "config.h"
#include "MT_Codec.h"
/*-------------------------------------------------------------------*
* rate2AMRWB_IOmode()
*
* lookup AMRWB IO mode
*-------------------------------------------------------------------*/
#include "libevs/lib_com/prot.h"
static Word16 rate2AMRWB_IOmode(
Word32 rate /* i: bit rate */
);
namespace MT {
/*Revers Function*/
extern Word16 AMRWB_IOmode2rate(
Word32 mode
);
/*-------------------------------------------------------------------*
* rate2EVSmode()
*
* lookup EVS mode
*-------------------------------------------------------------------*/
extern Word16 rate2EVSmode(
Word32 rate /* i: bit rate */
);
/*Revers Function*/
extern Word16 EVSmode2rate(
Word32 mode
);
class Codec;
typedef std::shared_ptr<Codec> PCodec;
#define CMR_OFF -1
#define CMR_ON 0
#define CMR_ONLY 1
static const std::map<int, std::set<int>> BitrateToBandwidth_Tab{
{5900, {NB, WB}},
{7200, {NB, WB}},
{8000, {NB, WB}},
{9600, {NB, WB, SWB}},
{13200, {NB, WB, SWB}}, //if channel aware mode - WB, SWB
{16400, {NB, WB, SWB, FB}},
{24400, {NB, WB, SWB, FB}},
{32000, {WB, SWB, FB}},
{48000, {WB, SWB, FB}},
{64000, {WB, SWB, FB}},
{96000, {WB, SWB, FB}},
{128000, {WB, SWB, FB}}
};
/* Protected payload size/Fixed bitrate to EVS ()*/
static const std::map<int, int> Bitrate2PayloadSize_EVSAMR_WB{
/*{bitrate, payload size}*/
{ SID_1k75, 56}, //AMR-WB I/O SIB
{ACELP_6k60, 136},
{ACELP_8k85, 184},
{ACELP_12k65, 256},
{ACELP_14k25, 288},
{ACELP_15k85, 320},
{ACELP_18k25, 368},
{ACELP_19k85, 400},
{ACELP_23k05, 464},
{ACELP_23k85, 480}
};
static const std::map<int, int> Bitrate2PayloadSize_EVS{
/*{bitrate, payload size}*/
{FRAME__NO_DATA, 0},
{SID_2k40, 48}, //EVS Primary SID
{PPP_NELP_2k80, 56}, //special for full header
{ACELP_7k20, 144},
{ACELP_8k00, 160},
{ACELP_9k60, 192},
{ACELP_13k20, 264},
{ACELP_16k40, 328},
{ACELP_24k40, 488},
{ACELP_32k, 640},
{ACELP_48k, 960},
{ACELP_64k, 1280},
{HQ_96k, 1920},
{HQ_128k, 2560}
};
/* Protected payload size/Fixed bitrate to EVS ()*/
static const std::map<int, int> FixedPayload_EVSPrimary{
/*{payload size , bitrate}*/
{48, 2400}, //EVS Primary SID
{56, 2800}, //special for full header
{144, 7200},
{160, 8000},
{192, 9600},
{264, 13200},
{328, 16400},
{488, 24400},
{640, 32000},
{960, 48000},
{1280, 64000},
{1920, 96000},
{2560, 128000}
};
static const std::map<int, int> FixedPayload_EVSAMR_WB{
/*{payload size , bitrate}*/
{136, 6600},
{184, 8850},
{256, 12650},
{288, 14250},
{320, 15850},
{368, 18250},
{400, 19850},
{464, 23050},
{480, 23850}
};
struct StreamParameters {
bool mime = false;
bool fh_only = false; /*not use*/
int CRMByte = CMR_OFF;/*not use*/
int br = 0; /*not use*/
int bw = NB;
int ptime = 20;
}; //Emulated SDP config/meadia type parameters
class Codec
{
public:
class Factory
{
public:
virtual ~Factory() {}
virtual const char* name() = 0;
virtual int samplerate() = 0;
virtual int payloadType() = 0;
virtual PCodec create() = 0;
virtual int channels() = 0;
};
virtual ~Codec() {}
virtual const char* name() = 0;
virtual int samplerate() = 0;
virtual float timestampUnit() { return float(1.0 / samplerate()); }
virtual int pcmLength() = 0;
virtual int frameTime() = 0;
virtual int rtpLength() = 0;
virtual int channels() { return 1; }
virtual int encode(const void* input, int inputBytes, void* output, int outputCapacity) = 0;
virtual int decode(const void* input, int inputBytes, void* output, int outputCapacity) = 0;
virtual int plc(int lostFrames, void* output, int outputCapacity) = 0;
// Returns size of codec in memory
virtual int getSize() const { return 0; };
};
class EVSCodec : public Codec
{
private:
Decoder_State* st_dec;
//Encoder_State_fx* st_enc;
StreamParameters sp;
public:
// Emulated SDP config/media type parameters
struct StreamParameters
{
bool mime = false;
bool fh_only = false; /*not use*/
int CRMByte = -1/*CMR_OFF*/; /*not use*/
int br = 0; /*not use*/
int bw = NB;
int ptime = 20;
};
public:
class EVSFactory : public Factory
@ -185,7 +40,7 @@ public:
public:
EVSFactory(StreamParameters sp);
const char* name() { return "EVS"; };
const char* name() { return MT_EVS_CODECNAME; };
int samplerate();
int payloadType();
PCodec create();
@ -196,7 +51,7 @@ public:
EVSCodec(const StreamParameters& sp);
~EVSCodec() override;
const char* name() { return "EVS"; };
const char* name() { return MT_EVS_CODECNAME; };
int samplerate();
int samplerate(int CodecMode); // DEC or ENC defined in cnst.h
int pcmLength();
@ -206,5 +61,12 @@ public:
int encode(const void* input, int inputBytes, void* output, int outputCapacity);
int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostFrames, void* output, int outputCapacity) ;
private:
Decoder_State* st_dec;
//Encoder_State_fx* st_enc;
StreamParameters sp;
void initDecoder(const StreamParameters& sp);
};
} // End of namespace

View File

@ -6,6 +6,8 @@
#include "cnst.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* get_next_coeff_mapped()
@ -71,3 +73,5 @@ int update_mixed_context(
return (ctx & 0xf) * 16 + t + 13;
}
} // end of namespace evs

View File

@ -14,6 +14,7 @@
#define int32 int
#endif
namespace evs {
/*---------------------------------------------------------------
@ -37,3 +38,5 @@ long mul_sbc_14bits(long r,long c)
/*function in line*/
}
} // end of namespace

View File

@ -10,6 +10,8 @@
#include "prot.h"
#include "rom_com.h"
namespace evs {
/*-------------------------------------------------------------------*
* UnmapIndex()
@ -268,3 +270,5 @@ void tcx_hm_modify_envelope(
return;
}
} // end of namespace

View File

@ -10,8 +10,7 @@
#include "basop_util.h"
#include "basop_proto_func.h"
namespace evs {
/*-------------------------------------------------------*
* expfp()
@ -508,3 +507,5 @@ void tcx_arith_render_envelope(
return;
}
} // end of namespace

View File

@ -130,7 +130,9 @@ HISTORY:
#include <stdlib.h>
#include "stl.h"
namespace evs {
}
/*___________________________________________________________________________
| |
| Local Functions |
@ -2535,6 +2537,6 @@ Word32 L_msu0 (Word32 L_var3, Word16 var1, Word16 var2)
return(L_var_out);
}
} // end of namespace evs
/* end of file */

View File

@ -7,6 +7,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* ACcontextMapping_decode2_no_mem_s17_LC()
*
@ -276,3 +278,5 @@ long ACcontextMapping_decode2_no_mem_s17_LC( /* o: resQBits */
return resQBits;
}
} // end of namespace EVS

View File

@ -7,6 +7,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* acelp_core_dec()
*
@ -917,3 +919,5 @@ void acelp_core_dec(
return;
}
} // end of namespace EVS

View File

@ -7,6 +7,7 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*---------------------------------------------------------------------*
* Local functions
@ -558,3 +559,5 @@ static void decod_gen_voic_core_switch(
return;
}
} // end of namespace

View File

@ -8,6 +8,8 @@
#include "prot.h"
namespace evs {
/*------------------------------------------------------------------*
* amr_wb_dec()
*
@ -863,3 +865,5 @@ void amr_wb_dec(
return;
}
} // end of namespace

View File

@ -10,6 +10,7 @@
#include "assert.h"
#include "basop_util.h"
namespace evs {
/*---------------------------------------------------------------
@ -637,3 +638,4 @@ long ari_decode_14bits_sign(const int *ptr, long bp, long bits, int *res, Tastat
return bp;
}
} // end of namespace

View File

@ -10,6 +10,8 @@
#include "prot.h"
#include "rom_com.h"
namespace evs {
/*-------------------------------------------------------------------*
* DecodeIndex()
*
@ -125,3 +127,5 @@ void tcx_hm_decode(
return;
}
} // end of namespace

View File

@ -11,6 +11,7 @@
#include "basop_util.h"
#include "basop_proto_func.h"
namespace evs {
/*-------------------------------------------------------*
* tcx_arith_decode()
@ -180,3 +181,5 @@ void tcx_arith_decode_envelope(
return;
}
} // end of namespace

View File

@ -8,6 +8,8 @@
#include "options.h"
#include "cnst.h"
namespace evs {
/*-----------------------------------------------------------------*
* AVQ_demuxdec()
@ -218,3 +220,5 @@ void AVQ_dec_lpc(
return;
}
} // end of namespace

View File

@ -8,6 +8,7 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* ACcontextMapping_encode2_no_mem_s17_LC()
@ -634,3 +635,5 @@ int ACcontextMapping_encode2_estimate_no_mem_s17_LC(
return nbits_old;
}
} // end of namespace

View File

@ -10,6 +10,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* acelp_core_enc()
*
@ -583,3 +585,5 @@ void acelp_core_enc(
return;
}
} // end of namespace

View File

@ -11,6 +11,8 @@
#include "prot.h"
#include "prot.h"
namespace evs {
/*---------------------------------------------------------------------*
* Local functions
*---------------------------------------------------------------------*/
@ -436,3 +438,5 @@ static void bwe_switch_enc(
return;
}
} // end of namespace

View File

@ -11,6 +11,7 @@
#include "cnst.h"
#include "rom_com.h"
namespace evs {
/*-------------------------------------------------------------------*
* E_ACELP_toeplitz_mul()
@ -45,3 +46,5 @@ void E_ACELP_toeplitz_mul(
return;
}
} // end of namespace evs

View File

@ -10,6 +10,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* amr_wb_enc()
*
@ -537,3 +539,5 @@ void amr_wb_enc(
return;
}
} // end of namespace

View File

@ -7,6 +7,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
/*-------------------------------------------------------------------*
* analy_lp()
*
@ -141,3 +143,4 @@ void analy_lp_AMR_WB(
return;
}
// end of namespace

View File

@ -9,6 +9,8 @@
#include "rom_com.h"
#include "prot.h"
namespace evs {
static void find_enr( const float data[], float band[], float *ptE, float *Etot, const short min_band,
const short max_band, float *Bin_E, const short bin_freq, float *band_ener );
@ -207,3 +209,5 @@ static void find_enr(
return;
}
} // end of namespace

View File

@ -10,8 +10,7 @@
#include "assert.h"
#include "basop_util.h"
namespace evs {
/**
* \brief Copy state
@ -408,3 +407,4 @@ long ari_done_cbr_encoding_14bits(int *ptr, long bp, long bits, Tastat *s)
return bp;
}
} // end of namespace

View File

@ -11,6 +11,7 @@
#include "prot.h"
#include "rom_com.h"
namespace evs {
/*-------------------------------------------------------------------*
* EncodeIndex()
@ -587,3 +588,5 @@ void tcx_hm_analyse(
return;
}
} // end of namespace

View File

@ -14,6 +14,7 @@
#include "basop_util.h"
#include "basop_proto_func.h"
namespace evs {
/*-------------------------------------------------------------------*
* Local constants
@ -623,3 +624,5 @@ void tcx_arith_encode_envelope(
return;
}
} // end of namespace

View File

@ -7,6 +7,8 @@
#include "prot.h"
#include "rom_com.h"
namespace evs {
/*-------------------------------------------------------------------*
* Function AVQ_cod() *
* *
@ -377,3 +379,5 @@ void AVQ_cod_lpc(
return;
}
} // end of namespace