Split out vocoder from gr block
git-svn-id: http://op25.osmocom.org/svn/trunk@220 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
b2e4d4dd9d
commit
1d28b8c044
|
@ -70,6 +70,7 @@ _op25_imbe_la_SOURCES = \
|
|||
encode.cc \
|
||||
math_sub.cc \
|
||||
op25_imbe_vocoder.cc \
|
||||
imbe_vocoder.cc \
|
||||
pe_lpf.cc \
|
||||
pitch_est.cc \
|
||||
pitch_ref.cc \
|
||||
|
|
|
@ -31,13 +31,13 @@
|
|||
#include "aux_sub.h"
|
||||
#include "encode.h"
|
||||
#include "dsp_sub.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::decode_init(IMBE_PARAM *imbe_param)
|
||||
void imbe_vocoder::decode_init(IMBE_PARAM *imbe_param)
|
||||
{
|
||||
v_synt_init();
|
||||
uv_synt_init();
|
||||
|
@ -52,7 +52,7 @@ void op25_imbe_vocoder::decode_init(IMBE_PARAM *imbe_param)
|
|||
}
|
||||
|
||||
|
||||
void op25_imbe_vocoder::decode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd)
|
||||
void imbe_vocoder::decode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd)
|
||||
{
|
||||
Word16 snd_tmp[FRAME];
|
||||
Word16 j;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "dsp_sub.h"
|
||||
#include "math_sub.h"
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// PURPOSE:
|
||||
|
@ -46,7 +46,7 @@
|
|||
// Saved in out result of conversion
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void op25_imbe_vocoder::idct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out)
|
||||
void imbe_vocoder::idct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out)
|
||||
{
|
||||
UWord16 angl_step, angl_intl, angl_intl_2;
|
||||
UWord16 angl_acc;
|
||||
|
@ -98,7 +98,7 @@ void op25_imbe_vocoder::idct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out
|
|||
// Saved in out result of conversion
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void op25_imbe_vocoder::dct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out)
|
||||
void imbe_vocoder::dct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out)
|
||||
{
|
||||
UWord16 angl_step, angl_intl, angl_intl_2, angl_begin;
|
||||
UWord16 angl_acc;
|
||||
|
@ -144,7 +144,7 @@ void op25_imbe_vocoder::dct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out)
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::fft_init(void)
|
||||
void imbe_vocoder::fft_init(void)
|
||||
{
|
||||
Word16 i, fft_len2, shift, step, theta;
|
||||
|
||||
|
@ -190,7 +190,7 @@ void op25_imbe_vocoder::fft_init(void)
|
|||
|
||||
#define SWAP(a,b) temp1 = (a);(a) = (b); (b) = temp1
|
||||
|
||||
void op25_imbe_vocoder::fft(Word16 *datam1, Word16 nn, Word16 isign)
|
||||
void imbe_vocoder::fft(Word16 *datam1, Word16 nn, Word16 isign)
|
||||
{
|
||||
Word16 n, mmax, m, j, istep, i;
|
||||
Word16 wr, wi, temp1;
|
||||
|
|
|
@ -35,12 +35,12 @@
|
|||
#include "v_uv_det.h"
|
||||
#include "sa_encode.h"
|
||||
#include "ch_encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::encode_init(void)
|
||||
void imbe_vocoder::encode_init(void)
|
||||
{
|
||||
v_zap(pitch_est_buf, PITCH_EST_BUF_SIZE);
|
||||
v_zap(pitch_ref_buf, PITCH_EST_BUF_SIZE);
|
||||
|
@ -51,7 +51,7 @@ void op25_imbe_vocoder::encode_init(void)
|
|||
}
|
||||
|
||||
|
||||
void op25_imbe_vocoder::encode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd)
|
||||
void imbe_vocoder::encode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd)
|
||||
{
|
||||
Word16 i;
|
||||
Word16 *wr_ptr, *sig_ptr;
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Project 25 IMBE Encoder/Decoder Fixed-Point implementation
|
||||
* Developed by Pavel Yazev E-mail: pyazev@gmail.com
|
||||
* Version 1.0 (c) Copyright 2009
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <imbe_vocoder.h>
|
||||
|
||||
static bool already_printed = false;
|
||||
|
||||
imbe_vocoder::imbe_vocoder (void) :
|
||||
prev_pitch(0),
|
||||
prev_prev_pitch(0),
|
||||
prev_e_p(0),
|
||||
prev_prev_e_p(0),
|
||||
seed(1),
|
||||
num_harms_prev1(0),
|
||||
num_harms_prev2(0),
|
||||
num_harms_prev3(0),
|
||||
fund_freq_prev(0),
|
||||
th_max(0),
|
||||
dc_rmv_mem(0)
|
||||
{
|
||||
memset(wr_array, 0, sizeof(wr_array));
|
||||
memset(wi_array, 0, sizeof(wi_array));
|
||||
memset(pitch_est_buf, 0, sizeof(pitch_est_buf));
|
||||
memset(pitch_ref_buf, 0, sizeof(pitch_ref_buf));
|
||||
memset(pe_lpf_mem, 0, sizeof(pe_lpf_mem));
|
||||
memset(fft_buf, 0, sizeof(fft_buf));
|
||||
memset(sa_prev1, 0, sizeof(sa_prev1));
|
||||
memset(sa_prev2, 0, sizeof(sa_prev2));
|
||||
memset(uv_mem, 0, sizeof(uv_mem));
|
||||
memset(ph_mem, 0, sizeof(ph_mem));
|
||||
memset(vu_dsn_prev, 0, sizeof(vu_dsn_prev));
|
||||
memset(sa_prev3, 0, sizeof(sa_prev3));
|
||||
memset(v_uv_dsn, 0, sizeof(v_uv_dsn));
|
||||
|
||||
memset(&my_imbe_param, 0, sizeof(IMBE_PARAM));
|
||||
|
||||
decode_init(&my_imbe_param);
|
||||
encode_init();
|
||||
|
||||
if (!already_printed) {
|
||||
already_printed = 1;
|
||||
fprintf(stderr,"Project 25 IMBE Encoder/Decoder Fixed-Point implementation\n");
|
||||
fprintf(stderr,"Developed by Pavel Yazev E-mail: pyazev@gmail.com\n");
|
||||
fprintf(stderr,"Version 1.0 (c) Copyright 2009\n");
|
||||
fprintf(stderr,"This program comes with ABSOLUTELY NO WARRANTY.\n");
|
||||
fprintf(stderr,"This is free software, and you are welcome to redistribute it\n");
|
||||
fprintf(stderr,"under certain conditions; see the file ``LICENSE'' for details.\n");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Project 25 IMBE Encoder/Decoder Fixed-Point implementation
|
||||
* Developed by Pavel Yazev E-mail: pyazev@gmail.com
|
||||
* Version 1.0 (c) Copyright 2009
|
||||
*/
|
||||
/* -*- c++ -*- */
|
||||
#ifndef INCLUDED_IMBE_VOCODER_H
|
||||
#define INCLUDED_IMBE_VOCODER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "imbe.h"
|
||||
#include "dsp_sub.h"
|
||||
#include "basic_op.h"
|
||||
#include "math_sub.h"
|
||||
#include "encode.h"
|
||||
#include "decode.h"
|
||||
|
||||
class imbe_vocoder
|
||||
{
|
||||
public:
|
||||
imbe_vocoder(void); // constructor
|
||||
~imbe_vocoder() {} // destructor
|
||||
// imbe_encode compresses 160 samples (in unsigned int format)
|
||||
// outputs u[] vectors as frame_vector[]
|
||||
void imbe_encode(int16_t *frame_vector, int16_t *snd) {
|
||||
encode(&my_imbe_param, frame_vector, snd);
|
||||
}
|
||||
// imbe_decode decodes IMBE codewords (frame_vector),
|
||||
// outputs the resulting 160 audio samples (snd)
|
||||
void imbe_decode(int16_t *frame_vector, int16_t *snd) {
|
||||
decode(&my_imbe_param, frame_vector, snd);
|
||||
}
|
||||
private:
|
||||
IMBE_PARAM my_imbe_param;
|
||||
|
||||
/* data items originally static (moved from individual c++ sources) */
|
||||
Word16 prev_pitch, prev_prev_pitch, prev_e_p, prev_prev_e_p;
|
||||
UWord32 seed ;
|
||||
Word16 num_harms_prev1;
|
||||
Word32 sa_prev1[NUM_HARMS_MAX + 2];
|
||||
Word16 num_harms_prev2;
|
||||
Word32 sa_prev2[NUM_HARMS_MAX + 2];
|
||||
Word16 uv_mem[105];
|
||||
UWord32 ph_mem[NUM_HARMS_MAX];
|
||||
Word16 num_harms_prev3;
|
||||
Word32 fund_freq_prev;
|
||||
Word16 vu_dsn_prev[NUM_HARMS_MAX];
|
||||
Word16 sa_prev3[NUM_HARMS_MAX];
|
||||
Word32 th_max;
|
||||
Word16 v_uv_dsn[NUM_BANDS_MAX];
|
||||
Word16 wr_array[FFTLENGTH / 2 + 1];
|
||||
Word16 wi_array[FFTLENGTH / 2 + 1];
|
||||
Word16 pitch_est_buf[PITCH_EST_BUF_SIZE];
|
||||
Word16 pitch_ref_buf[PITCH_EST_BUF_SIZE];
|
||||
Word32 dc_rmv_mem;
|
||||
Cmplx16 fft_buf[FFTLENGTH];
|
||||
Word16 pe_lpf_mem[PE_LPF_ORD];
|
||||
|
||||
/* member functions */
|
||||
void idct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out);
|
||||
void dct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out);
|
||||
void fft_init(void);
|
||||
void fft(Word16 *datam1, Word16 nn, Word16 isign);
|
||||
void encode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd);
|
||||
void parse(int argc, char **argv);
|
||||
void pitch_est_init(void);
|
||||
Word32 autocorr(Word16 *sigin, Word16 shift, Word16 scale_shift);
|
||||
void e_p(Word16 *sigin, Word16 *res_buf);
|
||||
void pitch_est(IMBE_PARAM *imbe_param, Word16 *frames_buf);
|
||||
void sa_decode_init(void);
|
||||
void sa_decode(IMBE_PARAM *imbe_param);
|
||||
void sa_encode_init(void);
|
||||
void sa_encode(IMBE_PARAM *imbe_param);
|
||||
void uv_synt_init(void);
|
||||
void uv_synt(IMBE_PARAM *imbe_param, Word16 *snd);
|
||||
void v_synt_init(void);
|
||||
void v_synt(IMBE_PARAM *imbe_param, Word16 *snd);
|
||||
void pitch_ref_init(void);
|
||||
Word16 voiced_sa_calc(Word32 num, Word16 den);
|
||||
Word16 unvoiced_sa_calc(Word32 num, Word16 den);
|
||||
void v_uv_det(IMBE_PARAM *imbe_param, Cmplx16 *fft_buf);
|
||||
void decode_init(IMBE_PARAM *imbe_param);
|
||||
void decode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd);
|
||||
void encode_init(void);
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_IMBE_VOCODER_H */
|
|
@ -54,6 +54,8 @@
|
|||
#include <op25_imbe_frame.h>
|
||||
#include <gr_io_signature.h>
|
||||
|
||||
#include <imbe_vocoder.h>
|
||||
|
||||
/*
|
||||
* Create a new instance of op25_imbe_vocoder and return
|
||||
* a boost shared_ptr. This is effectively the public constructor.
|
||||
|
@ -73,8 +75,8 @@ op25_imbe_make_vocoder (bool encode_flag, bool verbose_flag, int stretch_amt, ch
|
|||
|
||||
#define M_IN(encode_flag, udp_port) (1)
|
||||
#define M_OUT(encode_flag, udp_port) ((udp_port) ? 0 : 1)
|
||||
#define S_IN(encode_flag, udp_port) ((encode_flag) ? sizeof(uint16_t) : sizeof(uint8_t))
|
||||
#define S_OUT(encode_flag, udp_port) ((udp_port) ? 0 : ((encode_flag) ? sizeof(uint8_t) : sizeof(uint16_t)))
|
||||
#define S_IN(encode_flag, udp_port) ((encode_flag) ? sizeof(int16_t) : sizeof(uint8_t))
|
||||
#define S_OUT(encode_flag, udp_port) ((udp_port) ? 0 : ((encode_flag) ? sizeof(uint8_t) : sizeof(int16_t)))
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
|
@ -94,44 +96,8 @@ op25_imbe_vocoder::op25_imbe_vocoder (bool encode_flag, bool verbose_flag, int s
|
|||
sampbuf_ct(0),
|
||||
stretch_count(0),
|
||||
save_l(0),
|
||||
f_body(P25_VOICE_FRAME_SIZE),
|
||||
prev_prev_e_p(0),
|
||||
seed(1),
|
||||
num_harms_prev1(0),
|
||||
num_harms_prev2(0),
|
||||
num_harms_prev3(0),
|
||||
fund_freq_prev(0),
|
||||
th_max(0),
|
||||
dc_rmv_mem(0)
|
||||
f_body(P25_VOICE_FRAME_SIZE)
|
||||
{
|
||||
memset(wr_array, 0, sizeof(wr_array));
|
||||
memset(wi_array, 0, sizeof(wi_array));
|
||||
memset(pitch_est_buf, 0, sizeof(pitch_est_buf));
|
||||
memset(pitch_ref_buf, 0, sizeof(pitch_ref_buf));
|
||||
memset(pe_lpf_mem, 0, sizeof(pe_lpf_mem));
|
||||
memset(fft_buf, 0, sizeof(fft_buf));
|
||||
memset(write_buf, 0, sizeof(write_buf));
|
||||
memset(rxbuf, 0, sizeof(rxbuf));
|
||||
memset(sampbuf, 0, sizeof(sampbuf));
|
||||
memset(sa_prev1, 0, sizeof(sa_prev1));
|
||||
memset(sa_prev2, 0, sizeof(sa_prev2));
|
||||
memset(uv_mem, 0, sizeof(uv_mem));
|
||||
memset(ph_mem, 0, sizeof(ph_mem));
|
||||
memset(vu_dsn_prev, 0, sizeof(vu_dsn_prev));
|
||||
memset(sa_prev3, 0, sizeof(sa_prev3));
|
||||
memset(v_uv_dsn, 0, sizeof(v_uv_dsn));
|
||||
memset(&my_imbe_param, 0, sizeof(IMBE_PARAM));
|
||||
|
||||
fprintf(stderr,"Project 25 IMBE Encoder/Decoder Fixed-Point implementation\n");
|
||||
fprintf(stderr,"Developed by Pavel Yazev E-mail: pyazev@gmail.com\n");
|
||||
fprintf(stderr,"Version 1.0 (c) Copyright 2009\n");
|
||||
fprintf(stderr,"This program comes with ABSOLUTELY NO WARRANTY.\n");
|
||||
fprintf(stderr,"This is free software, and you are welcome to redistribute it\n");
|
||||
fprintf(stderr,"under certain conditions; see the file ``LICENSE'' for details.\n");
|
||||
|
||||
decode_init(&my_imbe_param);
|
||||
encode_init();
|
||||
|
||||
opt_encode_flag = encode_flag;
|
||||
opt_dump_raw_vectors = raw_vectors_flag;
|
||||
opt_verbose = verbose_flag;
|
||||
|
@ -170,7 +136,7 @@ op25_imbe_vocoder::~op25_imbe_vocoder ()
|
|||
static const int STATS_INTERVAL = 20;
|
||||
static const int SAMP_INTERVAL = 8192;
|
||||
|
||||
void op25_imbe_vocoder::append_imbe_codeword(bit_vector& frame_body, Word16 frame_vector[], unsigned int& codeword_ct)
|
||||
void op25_imbe_vocoder::append_imbe_codeword(bit_vector& frame_body, int16_t frame_vector[], unsigned int& codeword_ct)
|
||||
{
|
||||
voice_codeword cw(voice_codeword_sz);
|
||||
uint8_t obuf[P25_VOICE_FRAME_SIZE/2];
|
||||
|
@ -233,8 +199,8 @@ void op25_imbe_vocoder::append_imbe_codeword(bit_vector& frame_body, Word16 fram
|
|||
|
||||
void op25_imbe_vocoder::rxchar(char c)
|
||||
{
|
||||
Word16 snd[FRAME];
|
||||
Word16 frame_vector[8];
|
||||
int16_t snd[FRAME];
|
||||
int16_t frame_vector[8];
|
||||
int u[8];
|
||||
|
||||
if (c < ' ') {
|
||||
|
@ -247,7 +213,7 @@ void op25_imbe_vocoder::rxchar(char c)
|
|||
}
|
||||
/* TEST*/ frame_vector[7] >>= 1;
|
||||
// decode 88 bits, outputs 160 sound samples (8000 rate)
|
||||
decode(&my_imbe_param, frame_vector, snd);
|
||||
vocoder.imbe_decode(frame_vector, snd);
|
||||
if (opt_udp_port > 0) {
|
||||
sendto(write_sock, snd, FRAME * sizeof(uint16_t), 0, (struct sockaddr*)&write_sock_addr, sizeof(write_sock_addr));
|
||||
} else {
|
||||
|
@ -265,12 +231,12 @@ void op25_imbe_vocoder::rxchar(char c)
|
|||
}
|
||||
}
|
||||
|
||||
void op25_imbe_vocoder::compress_frame(Word16 snd[])
|
||||
void op25_imbe_vocoder::compress_frame(int16_t snd[])
|
||||
{
|
||||
Word16 frame_vector[8];
|
||||
int16_t frame_vector[8];
|
||||
|
||||
// encode 160 audio samples into 88 bits (u0-u7)
|
||||
encode(&my_imbe_param, frame_vector, (Word16*) snd);
|
||||
vocoder.imbe_encode(frame_vector, snd);
|
||||
|
||||
// if dump option, dump u0-u7 to output
|
||||
if (opt_dump_raw_vectors) {
|
||||
|
@ -287,7 +253,7 @@ void op25_imbe_vocoder::compress_frame(Word16 snd[])
|
|||
append_imbe_codeword(f_body, frame_vector, codeword_ct);
|
||||
}
|
||||
|
||||
void op25_imbe_vocoder::add_sample(Word16 samp)
|
||||
void op25_imbe_vocoder::add_sample(int16_t samp)
|
||||
{
|
||||
// add one sample to 160-sample frame buffer and process if filled
|
||||
sampbuf[sampbuf_ct++] = samp;
|
||||
|
@ -297,7 +263,7 @@ void op25_imbe_vocoder::add_sample(Word16 samp)
|
|||
}
|
||||
|
||||
// track signal amplitudes
|
||||
Word16 asamp = (samp < 0) ? 0 - samp : samp;
|
||||
int16_t asamp = (samp < 0) ? 0 - samp : samp;
|
||||
peak = (asamp > peak) ? asamp : peak;
|
||||
if (++samp_ct >= SAMP_INTERVAL) {
|
||||
peak_amplitude = peak;
|
||||
|
@ -306,7 +272,7 @@ void op25_imbe_vocoder::add_sample(Word16 samp)
|
|||
}
|
||||
}
|
||||
|
||||
void op25_imbe_vocoder::compress_samp(Word16 samp)
|
||||
void op25_imbe_vocoder::compress_samp(int16_t samp)
|
||||
{
|
||||
// Apply sample rate slew to accomodate sound card rate discrepancy -
|
||||
// workaround for USRP underrun problem occurring when sound card
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <deque>
|
||||
typedef std::vector<bool> bit_vector;
|
||||
|
||||
#include <imbe_vocoder.h>
|
||||
|
||||
class op25_imbe_vocoder;
|
||||
|
||||
/*
|
||||
|
@ -94,7 +96,6 @@ private:
|
|||
|
||||
/* data items */
|
||||
int frame_cnt ;
|
||||
IMBE_PARAM my_imbe_param;
|
||||
int write_sock;
|
||||
struct sockaddr_in write_sock_addr;
|
||||
int write_bufp;
|
||||
|
@ -108,13 +109,14 @@ private:
|
|||
char rxbuf[RXBUF_MAX];
|
||||
int rxbufp ;
|
||||
unsigned int codeword_ct ;
|
||||
Word16 sampbuf[FRAME];
|
||||
int16_t sampbuf[FRAME];
|
||||
size_t sampbuf_ct ;
|
||||
int stretch_count ;
|
||||
uint8_t save_l;
|
||||
bit_vector f_body;
|
||||
imbe_vocoder vocoder;
|
||||
|
||||
std::deque<UWord8> output_queue;
|
||||
std::deque<uint8_t> output_queue;
|
||||
std::deque<uint16_t> output_queue_decode;
|
||||
|
||||
bool opt_encode_flag;
|
||||
|
@ -123,62 +125,13 @@ private:
|
|||
int opt_stretch_amt;
|
||||
int opt_stretch_sign;
|
||||
int opt_udp_port;
|
||||
|
||||
/* data items originally static (moved from individual c++ sources) */
|
||||
Word16 prev_pitch, prev_prev_pitch, prev_e_p, prev_prev_e_p;
|
||||
UWord32 seed ;
|
||||
Word16 num_harms_prev1;
|
||||
Word32 sa_prev1[NUM_HARMS_MAX + 2];
|
||||
Word16 num_harms_prev2;
|
||||
Word32 sa_prev2[NUM_HARMS_MAX + 2];
|
||||
Word16 uv_mem[105];
|
||||
UWord32 ph_mem[NUM_HARMS_MAX];
|
||||
Word16 num_harms_prev3;
|
||||
Word32 fund_freq_prev;
|
||||
Word16 vu_dsn_prev[NUM_HARMS_MAX];
|
||||
Word16 sa_prev3[NUM_HARMS_MAX];
|
||||
Word32 th_max;
|
||||
Word16 v_uv_dsn[NUM_BANDS_MAX];
|
||||
Word16 wr_array[FFTLENGTH / 2 + 1];
|
||||
Word16 wi_array[FFTLENGTH / 2 + 1];
|
||||
Word16 pitch_est_buf[PITCH_EST_BUF_SIZE];
|
||||
Word16 pitch_ref_buf[PITCH_EST_BUF_SIZE];
|
||||
Word32 dc_rmv_mem;
|
||||
Cmplx16 fft_buf[FFTLENGTH];
|
||||
Word16 pe_lpf_mem[PE_LPF_ORD];
|
||||
|
||||
/* member functions */
|
||||
void idct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out);
|
||||
void dct(Word16 *in, Word16 m_lim, Word16 i_lim, Word16 *out);
|
||||
void fft_init(void);
|
||||
void fft(Word16 *datam1, Word16 nn, Word16 isign);
|
||||
void encode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd);
|
||||
void parse(int argc, char **argv);
|
||||
void pitch_est_init(void);
|
||||
Word32 autocorr(Word16 *sigin, Word16 shift, Word16 scale_shift);
|
||||
void e_p(Word16 *sigin, Word16 *res_buf);
|
||||
void pitch_est(IMBE_PARAM *imbe_param, Word16 *frames_buf);
|
||||
void sa_decode_init(void);
|
||||
void sa_decode(IMBE_PARAM *imbe_param);
|
||||
void sa_encode_init(void);
|
||||
void sa_encode(IMBE_PARAM *imbe_param);
|
||||
void uv_synt_init(void);
|
||||
void uv_synt(IMBE_PARAM *imbe_param, Word16 *snd);
|
||||
void v_synt_init(void);
|
||||
void v_synt(IMBE_PARAM *imbe_param, Word16 *snd);
|
||||
void pitch_ref_init(void);
|
||||
Word16 voiced_sa_calc(Word32 num, Word16 den);
|
||||
Word16 unvoiced_sa_calc(Word32 num, Word16 den);
|
||||
void v_uv_det(IMBE_PARAM *imbe_param, Cmplx16 *fft_buf);
|
||||
void append_imbe_codeword(bit_vector& frame_body, Word16 frame_vector[], unsigned int& codeword_ct);
|
||||
/* local methods */
|
||||
void append_imbe_codeword(bit_vector& frame_body, int16_t frame_vector[], unsigned int& codeword_ct);
|
||||
void rxchar(char c);
|
||||
void compress_frame(Word16 snd[]);
|
||||
void add_sample(Word16 samp);
|
||||
void compress_samp(Word16 samp);
|
||||
void compress_frame(int16_t snd[]);
|
||||
void add_sample(int16_t samp);
|
||||
void compress_samp(int16_t samp);
|
||||
void init_sock(char* udp_host, int udp_port);
|
||||
void decode_init(IMBE_PARAM *imbe_param);
|
||||
void decode(IMBE_PARAM *imbe_param, Word16 *frame_vector, Word16 *snd);
|
||||
void encode_init(void);
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_OP25_IMBE_VOCODER_H */
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "pitch_est.h"
|
||||
#include "encode.h"
|
||||
#include "dsp_sub.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ static const Word16 min_max_tbl[203] =
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::pitch_est_init(void)
|
||||
void imbe_vocoder::pitch_est_init(void)
|
||||
{
|
||||
prev_pitch = prev_prev_pitch = 158; // 100
|
||||
prev_e_p = prev_prev_e_p = 0;
|
||||
|
@ -71,7 +71,7 @@ void op25_imbe_vocoder::pitch_est_init(void)
|
|||
|
||||
|
||||
|
||||
Word32 op25_imbe_vocoder::autocorr(Word16 *sigin, Word16 shift, Word16 scale_shift)
|
||||
Word32 imbe_vocoder::autocorr(Word16 *sigin, Word16 shift, Word16 scale_shift)
|
||||
{
|
||||
Word32 L_sum;
|
||||
Word16 i;
|
||||
|
@ -85,7 +85,7 @@ Word32 op25_imbe_vocoder::autocorr(Word16 *sigin, Word16 shift, Word16 scale_shi
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::e_p(Word16 *sigin, Word16 *res_buf)
|
||||
void imbe_vocoder::e_p(Word16 *sigin, Word16 *res_buf)
|
||||
{
|
||||
Word16 i, j, den_part_acc, tmp;
|
||||
Word32 L_sum, L_num, L_den, L_e0, L_tmp;
|
||||
|
@ -185,7 +185,7 @@ void op25_imbe_vocoder::e_p(Word16 *sigin, Word16 *res_buf)
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::pitch_est(IMBE_PARAM *imbe_param, Word16 *frames_buf)
|
||||
void imbe_vocoder::pitch_est(IMBE_PARAM *imbe_param, Word16 *frames_buf)
|
||||
{
|
||||
Word16 e_p_arr0[203], e_p_arr1[203], e_p_arr2[203], e1p1_e2p2_est_save[203];
|
||||
Word16 min_index, max_index, p, i, p_index;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "dsp_sub.h"
|
||||
#include "math_sub.h"
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
|||
// None
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void op25_imbe_vocoder::sa_decode_init(void)
|
||||
void imbe_vocoder::sa_decode_init(void)
|
||||
{
|
||||
num_harms_prev1 = 30;
|
||||
v_zap((Word16 *)sa_prev1, 2 * (NUM_HARMS_MAX + 2));
|
||||
|
@ -74,7 +74,7 @@ void op25_imbe_vocoder::sa_decode_init(void)
|
|||
// Decoded Spectral Amplitudes
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void op25_imbe_vocoder::sa_decode(IMBE_PARAM *imbe_param)
|
||||
void imbe_vocoder::sa_decode(IMBE_PARAM *imbe_param)
|
||||
{
|
||||
Word16 gain_vec[6], gain_r[6];
|
||||
UWord16 index, index_1, num_harms;
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
void op25_imbe_vocoder::sa_encode_init(void)
|
||||
void imbe_vocoder::sa_encode_init(void)
|
||||
{
|
||||
Word16 i;
|
||||
num_harms_prev2 = 30;
|
||||
|
@ -44,7 +44,7 @@ void op25_imbe_vocoder::sa_encode_init(void)
|
|||
sa_prev2[i] = 0;
|
||||
}
|
||||
|
||||
void op25_imbe_vocoder::sa_encode(IMBE_PARAM *imbe_param)
|
||||
void imbe_vocoder::sa_encode(IMBE_PARAM *imbe_param)
|
||||
{
|
||||
Word16 gain_vec[6], gain_r[6];
|
||||
UWord16 index, i, j, num_harms;
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
#include "rand_gen.h"
|
||||
#include "tbls.h"
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::uv_synt_init(void)
|
||||
void imbe_vocoder::uv_synt_init(void)
|
||||
{
|
||||
fft_init();
|
||||
v_zap(uv_mem, 105);
|
||||
|
@ -45,7 +45,7 @@ void op25_imbe_vocoder::uv_synt_init(void)
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::uv_synt(IMBE_PARAM *imbe_param, Word16 *snd)
|
||||
void imbe_vocoder::uv_synt(IMBE_PARAM *imbe_param, Word16 *snd)
|
||||
{
|
||||
Cmplx16 Uw[FFTLENGTH];
|
||||
Word16 i, index_a, index_b, index_aux, ha, hb, *v_uv_dsn_ptr, *sa_ptr, sa;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "rand_gen.h"
|
||||
#include "tbls.h"
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
|
||||
void op25_imbe_vocoder::v_synt_init(void)
|
||||
void imbe_vocoder::v_synt_init(void)
|
||||
{
|
||||
Word16 i;
|
||||
|
||||
|
@ -56,7 +56,7 @@ void op25_imbe_vocoder::v_synt_init(void)
|
|||
}
|
||||
|
||||
|
||||
void op25_imbe_vocoder::v_synt(IMBE_PARAM *imbe_param, Word16 *snd)
|
||||
void imbe_vocoder::v_synt(IMBE_PARAM *imbe_param, Word16 *snd)
|
||||
{
|
||||
Word32 L_tmp, L_tmp1, fund_freq, L_snd[FRAME], L_ph_acc, L_ph_step;
|
||||
Word32 L_ph_acc_aux, L_ph_step_prev, L_amp_acc, L_amp_step, L_ph_step_aux;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "encode.h"
|
||||
#include "op25_imbe_vocoder.h"
|
||||
#include "imbe_vocoder.h"
|
||||
|
||||
|
||||
#define CNST_0_5625_Q1_15 0x4800
|
||||
|
@ -58,13 +58,13 @@ extern FILE *fp_in, *fp_out;
|
|||
extern int frame_cnt;
|
||||
|
||||
|
||||
void op25_imbe_vocoder::pitch_ref_init(void)
|
||||
void imbe_vocoder::pitch_ref_init(void)
|
||||
{
|
||||
v_zap(v_uv_dsn, NUM_BANDS_MAX);
|
||||
th_max = 0;
|
||||
}
|
||||
|
||||
Word16 op25_imbe_vocoder::voiced_sa_calc(Word32 num, Word16 den)
|
||||
Word16 imbe_vocoder::voiced_sa_calc(Word32 num, Word16 den)
|
||||
{
|
||||
Word16 tmp;
|
||||
Word32 L_tmp;
|
||||
|
@ -78,7 +78,7 @@ Word16 op25_imbe_vocoder::voiced_sa_calc(Word32 num, Word16 den)
|
|||
return extract_h(L_tmp);
|
||||
}
|
||||
|
||||
Word16 op25_imbe_vocoder::unvoiced_sa_calc(Word32 num, Word16 den)
|
||||
Word16 imbe_vocoder::unvoiced_sa_calc(Word32 num, Word16 den)
|
||||
{
|
||||
Word16 shift, tmp;
|
||||
Word32 L_tmp;
|
||||
|
@ -100,7 +100,7 @@ Word16 op25_imbe_vocoder::unvoiced_sa_calc(Word32 num, Word16 den)
|
|||
// Voiced/Unvoiced Determination & Spectral Amplitudes Estimation
|
||||
//
|
||||
//=============================================================================
|
||||
void op25_imbe_vocoder::v_uv_det(IMBE_PARAM *imbe_param, Cmplx16 *fft_buf)
|
||||
void imbe_vocoder::v_uv_det(IMBE_PARAM *imbe_param, Cmplx16 *fft_buf)
|
||||
{
|
||||
Word16 i, j, index_a_save, tmp, index_wr;
|
||||
Word32 fund_freq, fund_freq_2, fund_freq_acc_a, fund_freq_acc_b, fund_freq_acc, fund_fr_acc, L_tmp, amp_re_acc, amp_im_acc;
|
||||
|
|
Reference in New Issue