1 #ifndef LPCNET_PRIVATE_H 2 #define LPCNET_PRIVATE_H 3 4 #include <stdio.h> 5 #include "freq.h" 6 #include "lpcnet.h" 7 #include "plc_data.h" 8 #include "pitchdnn.h" 9 #include "fargan.h" 10 11 12 #define PITCH_FRAME_SIZE 320 13 #define PITCH_BUF_SIZE (PITCH_MAX_PERIOD+PITCH_FRAME_SIZE) 14 15 #define PLC_MAX_FEC 100 16 #define MAX_FEATURE_BUFFER_SIZE 4 17 18 #define PITCH_IF_MAX_FREQ 30 19 #define PITCH_IF_FEATURES (3*PITCH_IF_MAX_FREQ - 2) 20 21 #define CONT_VECTORS 5 22 23 #define FEATURES_DELAY 1 24 25 struct LPCNetEncState{ 26 PitchDNNState pitchdnn; 27 float analysis_mem[OVERLAP_SIZE]; 28 float mem_preemph; 29 kiss_fft_cpx prev_if[PITCH_IF_MAX_FREQ]; 30 float if_features[PITCH_IF_FEATURES]; 31 float xcorr_features[PITCH_MAX_PERIOD - PITCH_MIN_PERIOD]; 32 float dnn_pitch; 33 float pitch_mem[LPC_ORDER]; 34 float pitch_filt; 35 float exc_buf[PITCH_BUF_SIZE]; 36 float lp_buf[PITCH_BUF_SIZE]; 37 float lp_mem[4]; 38 float lpc[LPC_ORDER]; 39 float features[NB_TOTAL_FEATURES]; 40 float sig_mem[LPC_ORDER]; 41 float burg_cepstrum[2*NB_BANDS]; 42 }; 43 44 typedef struct { 45 float gru1_state[PLC_GRU1_STATE_SIZE]; 46 float gru2_state[PLC_GRU2_STATE_SIZE]; 47 } PLCNetState; 48 49 #define PLC_BUF_SIZE ((CONT_VECTORS+5)*FRAME_SIZE) 50 struct LPCNetPLCState { 51 PLCModel model; 52 FARGANState fargan; 53 LPCNetEncState enc; 54 int loaded; 55 int arch; 56 57 #define LPCNET_PLC_RESET_START fec 58 float fec[PLC_MAX_FEC][NB_FEATURES]; 59 int analysis_gap; 60 int fec_read_pos; 61 int fec_fill_pos; 62 int fec_skip; 63 int analysis_pos; 64 int predict_pos; 65 float pcm[PLC_BUF_SIZE]; 66 int blend; 67 float features[NB_TOTAL_FEATURES]; 68 float cont_features[CONT_VECTORS*NB_FEATURES]; 69 int loss_count; 70 PLCNetState plc_net; 71 PLCNetState plc_bak[2]; 72 }; 73 74 void preemphasis(float *y, float *mem, const float *x, float coef, int N); 75 76 void compute_frame_features(LPCNetEncState *st, const float *in, int arch); 77 78 void lpcnet_reset_signal(LPCNetState *lpcnet); 79 void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, const float *features); 80 void run_frame_network_deferred(LPCNetState *lpcnet, const float *features); 81 void run_frame_network_flush(LPCNetState *lpcnet); 82 83 84 void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload); 85 void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N, int preload); 86 void lpcnet_synthesize_blend_impl(LPCNetState *lpcnet, const opus_int16 *pcm_in, opus_int16 *output, int N); 87 88 void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, const float *features); 89 90 #endif 91