# HG changeset patch # User Mychaela Falconia # Date 1669439347 0 # Node ID 58b64224d4acf6f7b1dcb7db112234af8ad53b0c # Parent 824ff833bda9e3117c9d259bfa8008c605b511ea libgsmefr: dtx.c compiles diff -r 824ff833bda9 -r 58b64224d4ac libgsmefr/Makefile --- a/libgsmefr/Makefile Sat Nov 26 03:52:39 2022 +0000 +++ b/libgsmefr/Makefile Sat Nov 26 05:09:07 2022 +0000 @@ -2,7 +2,7 @@ CFLAGS= -O2 OBJS= agc.o autocorr.o az_lsp.o basicop2.o c1035pf.o cod_12k2.o convolve.o \ d1035pf.o d_gains.o d_homing.o d_plsf_5.o dec_12k2.o dec_create.o \ - dec_lag6.o enc_create.o frame2params.o params2frame.o sid_class.o \ + dec_lag6.o dtx.o enc_create.o frame2params.o params2frame.o sid_class.o\ sid_insert.o tls_flags.o HDRS= basic_op.h cnst.h codec.h d_homing.h dec_state.h dtx.h e_homing.h \ enc_state.h gains_tb.h gsm_efr.h memops.h namespace.h no_count.h \ diff -r 824ff833bda9 -r 58b64224d4ac libgsmefr/dtx.c --- a/libgsmefr/dtx.c Sat Nov 26 03:52:39 2022 +0000 +++ b/libgsmefr/dtx.c Sat Nov 26 05:09:07 2022 +0000 @@ -54,12 +54,17 @@ * **************************************************************************/ +#include "gsm_efr.h" #include "typedef.h" +#include "namespace.h" #include "basic_op.h" #include "cnst.h" #include "sig_proc.h" -#include "count.h" +#include "memops.h" +#include "no_count.h" #include "dtx.h" +#include "enc_state.h" +#include "dec_state.h" /* Inverse values of DTX hangover period and DTX hangover period + 1 */ @@ -68,59 +73,12 @@ #define NB_PULSE 10 /* Number of pulses in fixed codebook excitation */ -/* SID frame classification thresholds */ - -#define VALID_SID_THRESH 2 -#define INVALID_SID_THRESH 16 - /* Constant DTX_ELAPSED_THRESHOLD is used as threshold for allowing SID frame updating without hangover period in case when elapsed time measured from previous SID update is below 24 */ #define DTX_ELAPSED_THRESHOLD (24 + DTX_HANGOVER - 1) -/* Index map for encoding and detecting SID codeword */ - -static const Word16 SID_codeword_bit_idx[95] = -{ - 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, - 66, 67, 68, 94, 95, 96, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 148, 149, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, - 171, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 209, 212, 213, 214, 215, 216, - 217, 218, 219, 220, 221 -}; - -Word16 txdtx_ctrl; /* Encoder DTX control word */ -Word16 rxdtx_ctrl; /* Decoder DTX control word */ -Word16 CN_excitation_gain; /* Unquantized fixed codebook gain */ -Word32 L_pn_seed_tx; /* PN generator seed (encoder) */ -Word32 L_pn_seed_rx; /* PN generator seed (decoder) */ -Word16 rx_dtx_state; /* State of comfort noise insertion period */ - -static Word16 txdtx_hangover; /* Length of hangover period (VAD=0, SP=1) */ -static Word16 rxdtx_aver_period;/* Length of hangover period (VAD=0, SP=1) */ -static Word16 txdtx_N_elapsed; /* Measured time from previous SID frame */ -static Word16 rxdtx_N_elapsed; /* Measured time from previous SID frame */ -static Word16 old_CN_mem_tx[6]; /* The most recent CN parameters are stored*/ -static Word16 prev_SID_frames_lost; /* Counter for lost SID frames */ -static Word16 buf_p_tx; /* Circular buffer pointer for gain code - history update in tx */ -static Word16 buf_p_rx; /* Circular buffer pointer for gain code - history update in rx */ - -Word16 lsf_old_tx[DTX_HANGOVER][M]; /* Comfort noise LSF averaging buffer */ -Word16 lsf_old_rx[DTX_HANGOVER][M]; /* Comfort noise LSF averaging buffer */ - -Word16 gain_code_old_tx[4 * DTX_HANGOVER]; /* Comfort noise gain averaging - buffer */ -Word16 gain_code_old_rx[4 * DTX_HANGOVER]; /* Comfort noise gain averaging - buffer */ - /************************************************************************* * * FUNCTION NAME: reset_tx_dtx @@ -130,43 +88,43 @@ * *************************************************************************/ -void reset_tx_dtx () +void reset_tx_dtx (struct EFR_encoder_state *st) { Word16 i; /* suppose infinitely long speech period before start */ - txdtx_hangover = DTX_HANGOVER; - txdtx_N_elapsed = 0x7fff; - txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG; + st->txdtx_hangover = DTX_HANGOVER; + st->txdtx_N_elapsed = 0x7fff; + st->txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG; for (i = 0; i < 6; i++) { - old_CN_mem_tx[i] = 0; + st->old_CN_mem_tx[i] = 0; } for (i = 0; i < DTX_HANGOVER; i++) { - lsf_old_tx[i][0] = 1384; - lsf_old_tx[i][1] = 2077; - lsf_old_tx[i][2] = 3420; - lsf_old_tx[i][3] = 5108; - lsf_old_tx[i][4] = 6742; - lsf_old_tx[i][5] = 8122; - lsf_old_tx[i][6] = 9863; - lsf_old_tx[i][7] = 11092; - lsf_old_tx[i][8] = 12714; - lsf_old_tx[i][9] = 13701; + st->lsf_old_tx[i][0] = 1384; + st->lsf_old_tx[i][1] = 2077; + st->lsf_old_tx[i][2] = 3420; + st->lsf_old_tx[i][3] = 5108; + st->lsf_old_tx[i][4] = 6742; + st->lsf_old_tx[i][5] = 8122; + st->lsf_old_tx[i][6] = 9863; + st->lsf_old_tx[i][7] = 11092; + st->lsf_old_tx[i][8] = 12714; + st->lsf_old_tx[i][9] = 13701; } for (i = 0; i < 4 * DTX_HANGOVER; i++) { - gain_code_old_tx[i] = 0; + st->gain_code_old_tx[i] = 0; } - L_pn_seed_tx = PN_INITIAL_SEED; + st->L_pn_seed_tx = PN_INITIAL_SEED; - buf_p_tx = 0; + st->buf_p_tx = 0; return; } @@ -179,40 +137,40 @@ * *************************************************************************/ -void reset_rx_dtx () +void reset_rx_dtx (struct EFR_decoder_state *st) { Word16 i; /* suppose infinitely long speech period before start */ - rxdtx_aver_period = DTX_HANGOVER; - rxdtx_N_elapsed = 0x7fff; - rxdtx_ctrl = RX_SP_FLAG; + st->rxdtx_aver_period = DTX_HANGOVER; + st->rxdtx_N_elapsed = 0x7fff; + st->rxdtx_ctrl = RX_SP_FLAG; for (i = 0; i < DTX_HANGOVER; i++) { - lsf_old_rx[i][0] = 1384; - lsf_old_rx[i][1] = 2077; - lsf_old_rx[i][2] = 3420; - lsf_old_rx[i][3] = 5108; - lsf_old_rx[i][4] = 6742; - lsf_old_rx[i][5] = 8122; - lsf_old_rx[i][6] = 9863; - lsf_old_rx[i][7] = 11092; - lsf_old_rx[i][8] = 12714; - lsf_old_rx[i][9] = 13701; + st->lsf_old_rx[i][0] = 1384; + st->lsf_old_rx[i][1] = 2077; + st->lsf_old_rx[i][2] = 3420; + st->lsf_old_rx[i][3] = 5108; + st->lsf_old_rx[i][4] = 6742; + st->lsf_old_rx[i][5] = 8122; + st->lsf_old_rx[i][6] = 9863; + st->lsf_old_rx[i][7] = 11092; + st->lsf_old_rx[i][8] = 12714; + st->lsf_old_rx[i][9] = 13701; } for (i = 0; i < 4 * DTX_HANGOVER; i++) { - gain_code_old_rx[i] = 0; + st->gain_code_old_rx[i] = 0; } - L_pn_seed_rx = PN_INITIAL_SEED; - rx_dtx_state = CN_INT_PERIOD - 1; + st->L_pn_seed_rx = PN_INITIAL_SEED; + st->rx_dtx_state = CN_INT_PERIOD - 1; - prev_SID_frames_lost = 0; - buf_p_rx = 0; + st->prev_SID_frames_lost = 0; + st->buf_p_rx = 0; return; } @@ -242,50 +200,46 @@ *************************************************************************/ void tx_dtx ( - Word16 VAD_flag, - Word16 *txdtx_ctrl + struct EFR_encoder_state *st, + Word16 VAD_flag ) { - /* N_elapsed (frames since last SID update) is incremented. If SID is updated N_elapsed is cleared later in this function */ - txdtx_N_elapsed = add (txdtx_N_elapsed, 1); + st->txdtx_N_elapsed = add (st->txdtx_N_elapsed, 1); /* If voice activity was detected, reset hangover counter */ - test (); if (sub (VAD_flag, 1) == 0) { - txdtx_hangover = DTX_HANGOVER; move16 (); - *txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG; move16 (); logic16 (); + st->txdtx_hangover = DTX_HANGOVER; + st->txdtx_ctrl = TX_SP_FLAG | TX_VAD_FLAG; } else { - test (); - if (txdtx_hangover == 0) + if (st->txdtx_hangover == 0) { /* Hangover period is over, SID should be updated */ - txdtx_N_elapsed = 0; move16 (); + st->txdtx_N_elapsed = 0; /* Check if this is the first frame after hangover period */ - test (); logic16 (); - if ((*txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0) + if ((st->txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0) { - *txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE - | TX_SID_UPDATE; move16 (); logic16 (); - L_pn_seed_tx = PN_INITIAL_SEED; move32 (); + st->txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE + | TX_SID_UPDATE; + st->L_pn_seed_tx = PN_INITIAL_SEED; } else { - *txdtx_ctrl = TX_SID_UPDATE; move16 (); + st->txdtx_ctrl = TX_SID_UPDATE; } } else { /* Hangover period is not over, update hangover counter */ - txdtx_hangover = sub (txdtx_hangover, 1); + st->txdtx_hangover = sub (st->txdtx_hangover, 1); /* Check if elapsed time from last SID update is greater than threshold. If not, set SP=0 (although hangover period is not @@ -294,26 +248,24 @@ to avoid erroneus SP=1 decision in case when N_elapsed is grown bigger than threshold and hangover period is still active */ - test (); - if (sub (add (txdtx_N_elapsed, txdtx_hangover), + if (sub (add (st->txdtx_N_elapsed, st->txdtx_hangover), DTX_ELAPSED_THRESHOLD) < 0) { /* old SID frame should be used */ - *txdtx_ctrl = TX_USE_OLD_SID; move16 (); + st->txdtx_ctrl = TX_USE_OLD_SID; } else { - test (); logic16 (); - if ((*txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0) + if ((st->txdtx_ctrl & TX_HANGOVER_ACTIVE) != 0) { - *txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE + st->txdtx_ctrl = TX_PREV_HANGOVER_ACTIVE | TX_HANGOVER_ACTIVE - | TX_SP_FLAG; move16 (); logic16 (); logic16 (); + | TX_SP_FLAG; } else { - *txdtx_ctrl = TX_HANGOVER_ACTIVE - | TX_SP_FLAG; move16 (); logic16 (); + st->txdtx_ctrl = TX_HANGOVER_ACTIVE + | TX_SP_FLAG; } } } @@ -357,7 +309,7 @@ *************************************************************************/ void rx_dtx ( - Word16 *rxdtx_ctrl, + struct EFR_decoder_state *st, Word16 TAF, Word16 bfi, Word16 SID_flag @@ -370,9 +322,6 @@ mitted) are also classified here; they will be discarded later and provided with "NO TRANSMISSION"-flag */ - test (); test (); - test (); test (); - test (); test (); if ((sub (SID_flag, 2) == 0) && (bfi == 0)) { frame_type = VALID_SID_FRAME; move16 (); @@ -392,132 +341,113 @@ /* Update of decoder state */ /* Previous frame was classified as a speech frame */ - test (); logic16 (); - if ((*rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { - test (); test (); test (); test (); if (sub (frame_type, VALID_SID_FRAME) == 0) { - *rxdtx_ctrl = RX_FIRST_SID_UPDATE; move16 (); + st->rxdtx_ctrl = RX_FIRST_SID_UPDATE; } else if (sub (frame_type, INVALID_SID_FRAME) == 0) { - *rxdtx_ctrl = RX_FIRST_SID_UPDATE - | RX_INVALID_SID_FRAME; move16 (); logic16(); + st->rxdtx_ctrl = RX_FIRST_SID_UPDATE + | RX_INVALID_SID_FRAME; } else if (sub (frame_type, UNUSABLE_FRAME) == 0) { - *rxdtx_ctrl = RX_SP_FLAG; move16 (); + st->rxdtx_ctrl = RX_SP_FLAG; } else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0) { - *rxdtx_ctrl = RX_SP_FLAG; move16 (); + st->rxdtx_ctrl = RX_SP_FLAG; } } else { - test (); test (); test (); test (); if (sub (frame_type, VALID_SID_FRAME) == 0) { - *rxdtx_ctrl = RX_CONT_SID_UPDATE; move16 (); + st->rxdtx_ctrl = RX_CONT_SID_UPDATE; } else if (sub (frame_type, INVALID_SID_FRAME) == 0) { - *rxdtx_ctrl = RX_CONT_SID_UPDATE - | RX_INVALID_SID_FRAME; move16 (); logic16 (); + st->rxdtx_ctrl = RX_CONT_SID_UPDATE + | RX_INVALID_SID_FRAME; } else if (sub (frame_type, UNUSABLE_FRAME) == 0) { - *rxdtx_ctrl = RX_CNI_BFI; move16 (); + st->rxdtx_ctrl = RX_CNI_BFI; } else if (sub (frame_type, GOOD_SPEECH_FRAME) == 0) { /* If the previous frame (during CNI period) was muted, raise the RX_PREV_DTX_MUTING flag */ - test (); logic16 (); - if ((*rxdtx_ctrl & RX_DTX_MUTING) != 0) + if ((st->rxdtx_ctrl & RX_DTX_MUTING) != 0) { - *rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG - | RX_PREV_DTX_MUTING; move16 (); logic16 (); - logic16 (); + st->rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG + | RX_PREV_DTX_MUTING; } else { - *rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG; move16 (); - logic16 (); + st->rxdtx_ctrl = RX_SP_FLAG | RX_FIRST_SP_FLAG; } } } - - test (); logic16 (); - if ((*rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { - prev_SID_frames_lost = 0; move16 (); - rx_dtx_state = CN_INT_PERIOD - 1; move16 (); + st->prev_SID_frames_lost = 0; + st->rx_dtx_state = CN_INT_PERIOD - 1; } else { /* First SID frame */ - test (); logic16 (); - if ((*rxdtx_ctrl & RX_FIRST_SID_UPDATE) != 0) + if ((st->rxdtx_ctrl & RX_FIRST_SID_UPDATE) != 0) { - prev_SID_frames_lost = 0; move16 (); - rx_dtx_state = CN_INT_PERIOD - 1; move16 (); + st->prev_SID_frames_lost = 0; + st->rx_dtx_state = CN_INT_PERIOD - 1; } /* SID frame detected, but not the first SID */ - test (); logic16 (); - if ((*rxdtx_ctrl & RX_CONT_SID_UPDATE) != 0) + if ((st->rxdtx_ctrl & RX_CONT_SID_UPDATE) != 0) { - prev_SID_frames_lost = 0; move16 (); + st->prev_SID_frames_lost = 0; - test (); test (); if (sub (frame_type, VALID_SID_FRAME) == 0) { - rx_dtx_state = 0; move16 (); + st->rx_dtx_state = 0; } else if (sub (frame_type, INVALID_SID_FRAME) == 0) { - test (); - if (sub(rx_dtx_state, (CN_INT_PERIOD - 1)) < 0) + if (sub(st->rx_dtx_state, (CN_INT_PERIOD - 1)) < 0) { - rx_dtx_state = add(rx_dtx_state, 1); move16 (); + st->rx_dtx_state = add(st->rx_dtx_state, 1); } } } /* Bad frame received in CNI mode */ - test (); logic16 (); - if ((*rxdtx_ctrl & RX_CNI_BFI) != 0) + if ((st->rxdtx_ctrl & RX_CNI_BFI) != 0) { - test (); - if (sub (rx_dtx_state, (CN_INT_PERIOD - 1)) < 0) + if (sub (st->rx_dtx_state, (CN_INT_PERIOD - 1)) < 0) { - rx_dtx_state = add (rx_dtx_state, 1); move16 (); + st->rx_dtx_state = add (st->rx_dtx_state, 1); } /* If an unusable frame is received during CNI period when TAF == 1, the frame is classified as a lost SID frame */ - test (); if (sub (TAF, 1) == 0) { - *rxdtx_ctrl = *rxdtx_ctrl | RX_LOST_SID_FRAME; - move16 (); logic16 (); - prev_SID_frames_lost = add (prev_SID_frames_lost, 1); + st->rxdtx_ctrl = st->rxdtx_ctrl | RX_LOST_SID_FRAME; + st->prev_SID_frames_lost = add (st->prev_SID_frames_lost, 1); } else /* No transmission occurred */ { - *rxdtx_ctrl = *rxdtx_ctrl | RX_NO_TRANSMISSION; - move16 (); logic16 (); + st->rxdtx_ctrl = st->rxdtx_ctrl | RX_NO_TRANSMISSION; } - test (); - if (sub (prev_SID_frames_lost, 1) > 0) + if (sub (st->prev_SID_frames_lost, 1) > 0) { - *rxdtx_ctrl = *rxdtx_ctrl | RX_DTX_MUTING; - move16 (); logic16 (); + st->rxdtx_ctrl = st->rxdtx_ctrl | RX_DTX_MUTING; } } } @@ -525,30 +455,28 @@ /* N_elapsed (frames since last SID update) is incremented. If SID is updated N_elapsed is cleared later in this function */ - rxdtx_N_elapsed = add (rxdtx_N_elapsed, 1); + st->rxdtx_N_elapsed = add (st->rxdtx_N_elapsed, 1); - test (); logic16 (); - if ((*rxdtx_ctrl & RX_SP_FLAG) != 0) + if ((st->rxdtx_ctrl & RX_SP_FLAG) != 0) { - rxdtx_aver_period = DTX_HANGOVER; move16 (); + st->rxdtx_aver_period = DTX_HANGOVER; } else { - test (); test (); - if (sub (rxdtx_N_elapsed, DTX_ELAPSED_THRESHOLD) > 0) + if (sub (st->rxdtx_N_elapsed, DTX_ELAPSED_THRESHOLD) > 0) { - *rxdtx_ctrl |= RX_UPD_SID_QUANT_MEM; move16 (); logic16 (); - rxdtx_N_elapsed = 0; move16 (); - rxdtx_aver_period = 0; move16 (); - L_pn_seed_rx = PN_INITIAL_SEED; move32 (); + st->rxdtx_ctrl |= RX_UPD_SID_QUANT_MEM; + st->rxdtx_N_elapsed = 0; + st->rxdtx_aver_period = 0; + st->L_pn_seed_rx = PN_INITIAL_SEED; } - else if (rxdtx_aver_period == 0) + else if (st->rxdtx_aver_period == 0) { - rxdtx_N_elapsed = 0; move16 (); + st->rxdtx_N_elapsed = 0; } else { - rxdtx_aver_period = sub (rxdtx_aver_period, 1); + st->rxdtx_aver_period = sub (st->rxdtx_aver_period, 1); } } @@ -574,13 +502,13 @@ *************************************************************************/ void CN_encoding ( + struct EFR_encoder_state *st, Word16 params[], Word16 txdtx_ctrl ) { Word16 i; - test (); logic16 (); if ((txdtx_ctrl & TX_SID_UPDATE) != 0) { /* Store new CN parameters in memory to be used later as old @@ -589,63 +517,31 @@ /* LPC parameter indices */ for (i = 0; i < 5; i++) { - old_CN_mem_tx[i] = params[i]; move16 (); + st->old_CN_mem_tx[i] = params[i]; } /* Codebook index computed in last subframe */ - old_CN_mem_tx[5] = params[56]; move16 (); + st->old_CN_mem_tx[5] = params[56]; } - test (); logic16 (); if ((txdtx_ctrl & TX_USE_OLD_SID) != 0) { /* Use old CN parameters previously stored in memory */ for (i = 0; i < 5; i++) { - params[i] = old_CN_mem_tx[i]; move16 (); + params[i] = st->old_CN_mem_tx[i]; } - params[17] = old_CN_mem_tx[5]; move16 (); - params[30] = old_CN_mem_tx[5]; move16 (); - params[43] = old_CN_mem_tx[5]; move16 (); - params[56] = old_CN_mem_tx[5]; move16 (); + params[17] = st->old_CN_mem_tx[5]; + params[30] = st->old_CN_mem_tx[5]; + params[43] = st->old_CN_mem_tx[5]; + params[56] = st->old_CN_mem_tx[5]; } /* Set all the rest of the parameters to zero (SID codeword will be written later) */ for (i = 0; i < 12; i++) { - params[i + 5] = 0; move16 (); - params[i + 18] = 0; move16 (); - params[i + 31] = 0; move16 (); - params[i + 44] = 0; move16 (); - } - - return; -} - -/************************************************************************* - * - * FUNCTION NAME: sid_codeword_encoding - * - * PURPOSE: Encoding of the SID codeword into the SID frame. The SID - * codeword consists of 95 bits, all set to '1'. - * - * INPUTS: ser2[0..243] Serial-mode speech parameter frame before - * writing SID codeword into it - * - * OUTPUTS: ser2[0..243] Serial-mode speech parameter frame with - * SID codeword written into it - * - * RETURN VALUE: none - * - *************************************************************************/ - -void sid_codeword_encoding ( - Word16 ser2[] -) -{ - Word16 i; - - for (i = 0; i < 95; i++) - { - ser2[SID_codeword_bit_idx[i]] = 1; move16 (); + params[i + 5] = 0; + params[i + 18] = 0; + params[i + 31] = 0; + params[i + 44] = 0; } return; @@ -653,60 +549,6 @@ /************************************************************************* * - * FUNCTION NAME: sid_frame_detection - * - * PURPOSE: Detecting of SID codeword from a received frame. The frames - * are classified into three categories based on how many bit - * errors occur in the SID codeword: - * - VALID SID FRAME - * - INVALID SID FRAME - * - SPEECH FRAME - * - * INPUTS: ser2[0..243] Received serial-mode speech parameter frame - * - * OUTPUTS: none - * - * RETURN VALUE: Ternary-valued SID classification flag - * - *************************************************************************/ - -Word16 sid_frame_detection ( - Word16 ser2[] -) -{ - Word16 i, nbr_errors, sid; - - /* Search for bit errors in SID codeword */ - nbr_errors = 0; move16 (); - for (i = 0; i < 95; i++) - { - test (); - if (ser2[SID_codeword_bit_idx[i]] == 0) - { - nbr_errors = add (nbr_errors, 1); - } - } - - /* Frame classification */ - test (); test (); - if (sub (nbr_errors, VALID_SID_THRESH) < 0) - { /* Valid SID frame */ - sid = 2; move16 (); - } - else if (sub (nbr_errors, INVALID_SID_THRESH) < 0) - { /* Invalid SID frame */ - sid = 1; move16 (); - } - else - { /* Speech frame */ - sid = 0; move16 (); - } - - return sid; -} - -/************************************************************************* - * * FUNCTION NAME: update_lsf_history * * PURPOSE: Update the LSF parameter history. The LSF parameters kept @@ -863,22 +705,20 @@ *************************************************************************/ void update_gain_code_history_tx ( - Word16 new_gain_code, - Word16 gain_code_old_tx[4 * DTX_HANGOVER] + struct EFR_encoder_state *st, + Word16 new_gain_code ) { - /* Circular buffer */ - gain_code_old_tx[buf_p_tx] = new_gain_code; move16 (); + st->gain_code_old_tx[st->buf_p_tx] = new_gain_code; - test (); - if (sub (buf_p_tx, (4 * DTX_HANGOVER - 1)) == 0) + if (sub (st->buf_p_tx, (4 * DTX_HANGOVER - 1)) == 0) { - buf_p_tx = 0; move16 (); + st->buf_p_tx = 0; } else { - buf_p_tx = add (buf_p_tx, 1); + st->buf_p_tx = add (st->buf_p_tx, 1); } return; @@ -906,22 +746,20 @@ *************************************************************************/ void update_gain_code_history_rx ( - Word16 new_gain_code, - Word16 gain_code_old_rx[4 * DTX_HANGOVER] + struct EFR_decoder_state *st, + Word16 new_gain_code ) { - /* Circular buffer */ - gain_code_old_rx[buf_p_rx] = new_gain_code; move16 (); + st->gain_code_old_rx[st->buf_p_rx] = new_gain_code; - test (); - if (sub (buf_p_rx, (4 * DTX_HANGOVER - 1)) == 0) + if (sub (st->buf_p_rx, (4 * DTX_HANGOVER - 1)) == 0) { - buf_p_rx = 0; move16 (); + st->buf_p_rx = 0; } else { - buf_p_rx = add (buf_p_rx, 1); + st->buf_p_rx = add (st->buf_p_rx, 1); } return;