diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index b1857db14a628abed083afe6d38a62d5caa97ec7..d5223e2b3876cc19db79a3f4bc29346deef2ccc4 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -13,158 +13,184 @@ common_evs_c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_ivas_c + + + common_all_c + + + common_all_c + + + common_all_c + - - - - - - - - - - - - - - - - - - - + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_evs_c + + + common_all_c + common_evs_c @@ -205,175 +231,262 @@ common_all_c - - common_ivas_c + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - - common_evs_c + + common_all_c - + common_all_c - + common_all_c - + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + + common_all_c + + common_all_c - + common_all_c - + common_all_c - + common_all_c - - common_ivas_c + + common_all_c + + + common_all_c - - - - - - - - - - - - - - - - + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + - + + common_h + + + + common_h + + + common_h + - - - - - - + + + + {890c2f45-9385-4fce-859b-6a65469e8dc0} + + + {201ea764-9626-4dca-9cc4-5b4106f8b8b2} + + + {fbb860e2-79d0-45b1-ada1-c3a0a369ce2c} + + + {b95b7bed-a666-4a00-9332-2b528638503e} + \ No newline at end of file diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c index 7304b15455c0a9c5e2a2a77f15807d8cc13ad2ac..e0496ab3338528668b2d9f6432de0f57110afcc1 100644 --- a/lib_com/codec_tcx_common.c +++ b/lib_com/codec_tcx_common.c @@ -604,3 +604,131 @@ void tcx5TnsUngrouping( } #endif + + +/*-------------------------------------------------------------------* + * tcx5SpectrumInterleaving() + * + * + *-------------------------------------------------------------------*/ + + +void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ) +{ + Word16 i; + Word32 interleaveBuf[N_TCX10_MAX]; + + set32_fx( interleaveBuf, 0, N_TCX10_MAX ); + + /* group sub-windows: interleave bins according to their frequencies */ + FOR( i = 0; i < tcx5Size; i++ ) + { + interleaveBuf[2 * i] = spectrum[i]; + interleaveBuf[2 * i + 1] = spectrum[tcx5Size + i]; + } + + Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); + + return; +} + +/*-------------------------------------------------------------------* + * tcx5SpectrumDeinterleaving() + * + * + *-------------------------------------------------------------------*/ + +void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ) +{ + Word16 i; + Word32 interleaveBuf[N_TCX10_MAX]; + + set32_fx( interleaveBuf, 0, N_TCX10_MAX ); + + /* ungroup sub-windows: interleave bins according to their frequencies */ + FOR( i = 0; i < tcx5Size; i++ ) + { + interleaveBuf[i] = spectrum[2 * i]; + interleaveBuf[tcx5Size + i] = spectrum[2 * i + 1]; + } + + Copy32( interleaveBuf, spectrum, shl( tcx5Size, 1 ) ); + + return; +} + +/*-------------------------------------------------------------------* + * tcx5TnsGrouping() + * + * + *-------------------------------------------------------------------*/ + +void tcx5TnsGrouping_fx( + const Word16 L_frame, /* i : frame length (TCX5) */ + const Word16 L_spec, /* i : coded spec length (TCX5, derived from filter borders*/ + Word32 *spectrum ) +{ + /* rearrange LF sub-window lines prior to TNS synthesis filtering */ + IF( LT_16( L_spec, L_frame ) ) + { + Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) ); + Copy32( spectrum + L_frame, spectrum + 8, 8 ); + Copy32( spectrum + L_frame + 8, spectrum + L_spec + 8, sub( L_spec, 8 ) ); + } + ELSE + { + Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */ + Copy32( spectrum + L_spec, buff, 8 ); + Copy32( spectrum + 8, spectrum + 16, sub( L_spec, 8 ) ); + Copy32( buff, spectrum + 8, 8 ); + } + + return; +} + +/*-------------------------------------------------------------------* + * tcx5TnsUngrouping() + * + * + *-------------------------------------------------------------------*/ + +void tcx5TnsUngrouping_fx( + const Word16 L_frame, /* i : frame length (TCX5) */ + const Word16 L_spec, /* i : coded spec length (TCX5, derived from filter borders*/ + Word32 *spectrum, + const Word16 enc_dec /* i : 0: encoder, else decoder */ +) +{ + /* undo rearrangement of LF sub-window lines prior to TNS analysis */ + IF( LT_16( L_spec, L_frame ) ) + { + Copy32( spectrum + L_spec + 8, spectrum + L_frame + 8, sub( L_spec, 8 ) ); + Copy32( spectrum + 8, spectrum + L_frame, 8 ); + Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) ); + set32_fx( spectrum + L_spec, 0, sub( L_frame, L_spec ) ); + set32_fx( spectrum + L_frame + L_spec, 0, sub( L_frame, L_spec ) ); + } + ELSE + { + Word32 buff[8]; /* Buffer for the rearrangement of LF TCX5 */ + + Copy32( spectrum + 8, buff, 8 ); + + IF( enc_dec == ENC ) + { + Copy32( spectrum + 16, spectrum + 8, sub( L_frame, 8 ) ); + Copy32( buff, spectrum + L_frame, 8 ); + } + ELSE + { + Copy32( spectrum + 16, spectrum + 8, sub( L_spec, 8 ) ); + Copy32( buff, spectrum + L_spec, 8 ); + } + } + + return; +} \ No newline at end of file diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index 71f5be36bd561e1291480bdede00b42520181b04..d906fcb3edf464967b5ba2bcd6b3a53172b065b0 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -981,6 +981,16 @@ void push_next_bits_fx( Word16 nb_bits /* i : number of bits to pack */ ); +UWord16 get_indice_fx( /* o : value of the indice */ + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ +); + +UWord16 get_next_indice_1_fx( /* o : value of the indice */ + Decoder_State *st_fx /* i/o: decoder state structure */ +); + //UWord16 get_next_indice( /* o : value of the indice */ // Decoder_State *st_fx, /* i/o: decoder state structure */ // Word16 nb_bits /* i : number of bits that were used to quantize the indice */ @@ -7965,4 +7975,37 @@ void cldfbAnalysis_ts_fx( const Word16 samplesToProcess, /* i : samples to process */ HANDLE_CLDFB_FILTER_BANK h_cldfb ); -#endif +// dec4t64.c +void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const int16_t cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const int16_t L_subfr /* i : subframe length */ +); + +// codec_tcx_common.c +void tcx5SpectrumInterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5SpectrumDeinterleaving_fx( + const Word16 tcx5Size, + Word32 *spectrum ); + +void tcx5TnsGrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum ); + +void tcx5TnsUngrouping_fx( + const Word16 L_frame, + const Word16 L_spec, + Word32 *spectrum, + const Word16 enc_dec ); + +// bass_psfilter.c +void bpf_pitch_coherence_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ +); +#endif \ No newline at end of file diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index fcc3fbb0f516e83659fd77102e12cea94f54d0c8..415d81bb1e8ae0574fb679ebdd5703006be190d1 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -40,6 +40,7 @@ #include "cnst.h" #include "rom_com.h" #include "prot.h" +#include "prot_fx2.h" #include "ivas_cnst.h" #include "ivas_prot.h" #include "ivas_rom_com.h" @@ -1237,7 +1238,25 @@ ivas_error acelp_core_dec( } /* analyze pitch coherence for bass post-filter */ + +#ifdef IVAS_FLOAT_FIXED + + Word32 pitch_buf_fx[12]; + + FOR( Word16 lp = 0; lp < 12; lp++ ) + { + st->old_pitch_buf_fx[lp] = (Word32) ( st->old_pitch_buf[lp] * ( 1u << 20 ) ); + } + Word16 lim = st->L_frame / 64; + for ( Word16 lp = 0; lp < lim; lp++ ) + { + pitch_buf_fx[lp] = (Word32) ( pitch_buf[lp] * ( 1u << 20 ) ); + } + bpf_pitch_coherence_fx( st, pitch_buf_fx ); + +#else bpf_pitch_coherence( st, pitch_buf ); +#endif if ( !( st->element_mode == IVAS_CPE_MDCT && st->bpf_off ) ) { diff --git a/lib_dec/bass_psfilter.c b/lib_dec/bass_psfilter.c index 72bebb691a812976149e43fe60f4caf859cebbe0..97894841a35bcdef9eb2be8afc7aaf143361fdde 100644 --- a/lib_dec/bass_psfilter.c +++ b/lib_dec/bass_psfilter.c @@ -38,6 +38,7 @@ #include "options.h" #include #include "prot.h" +#include "prot_fx2.h" #include "ivas_prot.h" #include "cnst.h" #include "stat_dec.h" @@ -57,6 +58,9 @@ #define K_PC_DEC -0.0357f /* <45, 17> */ #define C_PC_DEC 1.6071f +#define K_PC_DEC_FX -1170 /* -0.0357f in Q15 */ +#define K_PC_DEC_FX32 -76665166 /* -0.0357f in Q31 */ +#define C_PC_DEC_FX 6583 /*in Q8*/ /*---------------------------------------------------------------------* * Local function prototypes @@ -695,3 +699,70 @@ void bpf_pitch_coherence( return; } + +void bpf_pitch_coherence_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 pitch_buf[] /* i : pitch for every subfr [0,1,2,3] */ +) +{ + Word16 nb_subfr; + Word32 pc, pcn1, pcn2, pcn3; + + Word32 scaled_inv_L_frame; // Q8 + Q23 + + SWITCH( st->L_frame ) + { + case 80: + scaled_inv_L_frame = 26843545; + BREAK; + case 160: + scaled_inv_L_frame = 13421773; + BREAK; + case 256: + scaled_inv_L_frame = 8388608; + BREAK; + case 320: + scaled_inv_L_frame = 6710886; + BREAK; + case 512: + scaled_inv_L_frame = 4194304; + BREAK; + case 640: + scaled_inv_L_frame = 3355443; + BREAK; + case 960: + scaled_inv_L_frame = 2236962; + BREAK; + default: + scaled_inv_L_frame = 0; + } + + nb_subfr = shr( st->L_frame, 6 ); + + IF( GT_16( st->clas_dec, UNVOICED_CLAS ) && NE_16( st->element_mode, EVS_MONO ) ) + { + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( st->old_pitch_buf_fx[nb_subfr], st->old_pitch_buf_fx[nb_subfr + 1] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn1 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn1 = max( min( pcn1, 4096 ), 0 ); + + pc = L_abs( L_sub( L_add( pitch_buf[nb_subfr - 1], pitch_buf[nb_subfr - 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn2 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn2 = max( min( pcn2, 4096 ), 0 ); + + pc = L_abs( L_sub( L_add( st->old_pitch_buf_fx[nb_subfr + 3], st->old_pitch_buf_fx[nb_subfr + 2] ), L_add( pitch_buf[1], pitch_buf[0] ) ) ); + pc = Mpy_32_32( pc, scaled_inv_L_frame ); + pcn3 = L_add( Mpy_32_32( pc, K_PC_DEC_FX32 ), C_PC_DEC_FX ); + pcn3 = max( min( pcn3, 4096 ), 0 ); + + IF( LT_32( L_add( pcn1, L_add( pcn2, pcn3 ) ), 10240 ) ) + { + st->hBPF->psf_att_fx = 13107; /*Q15*/ + st->hBPF->psf_att = 0.4f; + set16_fx( &st->hBPF->Track_on_hist[L_TRACK_HIST - nb_subfr], 1, nb_subfr ); + } + } + + return; +} diff --git a/lib_dec/dec4t64_fx.c b/lib_dec/dec4t64_fx.c index 9b25d08ffebd2d21958b031ca2c53f026f907698..85c6b315741b4414e2a236cad1e26d9cf0d232fc 100644 --- a/lib_dec/dec4t64_fx.c +++ b/lib_dec/dec4t64_fx.c @@ -1032,4 +1032,232 @@ void dec_acelp_fast( return; } -#endif \ No newline at end of file +#endif + +/*-------------------------------------------------------* + * dec_1p_N1() + * + * Decode 1 pulse with N+1 bits + *-------------------------------------------------------*/ + +static void dec_1p_N1_L_subfr_fx( + const Word32 index, /* i : quantization index */ + const Word16 nb_pos, /* i : number of positions */ + const Word16 N, /* i : nb. of bits */ + Word16 pos[] /* o : pulse position */ +) +{ + Word16 pos1; + Word32 mask, i; + + mask = L_deposit_l( sub( shl( 1, N ), 1 ) ); + pos1 = extract_l( index & mask ); + i = L_shr( index, N ) & 1L; + + IF( EQ_32( i, 1 ) ) + { + pos1 = add( pos1, nb_pos ); + } + + pos[0] = pos1; + + return; +} + +static void add_pulses_L_subfr_fx( + const Word16 nb_pos, /* i : number of positions */ + const Word16 pos[], /* i : pulse position */ + const Word16 nb_pulse, /* i : nb. of pulses */ + const Word16 track, /* i : no. of the tracks */ + Word16 code[] /* i/o: decoded codevector */ +) +{ + Word16 i, k; + Word16 *ptr; + ptr = code + track; + + FOR( k = 0; k < nb_pulse; k++ ) + { + i = shl( ( pos[k] & ( nb_pos - 1 ) ), 2 ); + IF( EQ_16( ( pos[k] & nb_pos ), 0 ) ) + { + + ptr[i] = add( ptr[i], 512 ); + } + ELSE + { + ptr[i] = sub( ptr[i], 512 ); + } + } + + return; +} + +void dec_acelp_fast_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ +) +{ + Word16 k, pos[7], skip_track; + Word32 L_index; + PulseConfig config; + + skip_track = -1; + set16_fx( code, 0, L_subfr ); + + st->total_num_bits = extract_l( st->total_brate / FRAMES_PER_SEC ); + + IF( EQ_16( L_subfr, L_SUBFR ) ) + { + config = PulseConfTable[cdk_index]; + + IF( EQ_16( cdk_index, 2 ) ) + { + dec_acelp_2t32_fx( st, code ); // needs to be imported + } + ELSE IF( EQ_16( config.nb_pulse, 2 ) ) + { + /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks) */ + FOR( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) + { + L_index = get_next_indice_fx( st, 5 ); // already fixed + dec_1p_N1_fx( L_index, 4, 0, pos ); // already fixed + add_pulses_fx( pos, 1, k, code ); // needs to be imported + } + } + ELSE IF( EQ_16( config.nb_pulse, 3 ) ) + { + IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FIXED_FIRST ) ) + { + /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */ + FOR( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) + { + L_index = get_next_indice_fx( st, 5 ); + dec_1p_N1_fx( L_index, 4, 0, pos ); + add_pulses_fx( pos, 1, k, code ); + } + } + ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FREE_THREE ) ) + { + /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */ + skip_track = get_next_indice_fx( st, 2 ); + FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) + { + IF( NE_16( k, skip_track ) ) + { + L_index = get_next_indice_fx( st, 5 ); + dec_1p_N1_fx( L_index, 4, 0, pos ); + add_pulses_fx( pos, 1, k, code ); + } + } + } + } + ELSE + { + IF( EQ_16( config.bits, 20 ) ) + { + skip_track = -1; + } + ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FIXED_FIRST ) ) + { + skip_track = 0; + } + ELSE IF( EQ_16( (Word16) config.codetrackpos, (Word16) TRACKPOS_FREE_ONE ) ) + { + skip_track = get_next_indice_fx( st, 2 ); + } + + FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) + { + IF( EQ_16( k, skip_track ) ) + { + L_index = get_next_indice_fx( st, 9 ); + dec_2p_2N1_fx( L_index, 4, 0, pos ); + add_pulses_fx( pos, 2, k, code ); + } + ELSE + { + L_index = get_next_indice_fx( st, 5 ); + dec_1p_N1_fx( L_index, 4, 0, pos ); + add_pulses_fx( pos, 1, k, code ); + } + } + } + } + ELSE /* L_subfr == 2*L_SUBFR */ + { + config.bits = cdk_index; + + IF( EQ_16( cdk_index, 14 ) ) + { + /* 14 bits, 2 pulses, 2 tracks: 11 (used all tracks) */ + Word16 index, i0, i1; + + index = get_next_indice_fx( st, 14 ); + + + i0 = shl( shr( index, 7 ) & ( NB_POS_FCB_2T_128 - 1 ), 1 ); + i1 = add( shl( index & ( NB_POS_FCB_2T_128 - 1 ), 1 ), 1 ); + + code[i0] = -512; + IF( EQ_16( ( index & 0x2000 ), 0 ) ) + { + code[i0] = 512; + } + + code[i1] = -512; + IF( EQ_16( ( index & 0x40 ), 0 ) ) + { + code[i1] = 512; + } + } + ELSE IF( EQ_16( cdk_index, 12 ) ) + { + /* 12 bits, 2 pulses, 4 tracks: 1010 (used only even tracks) */ + FOR( k = 0; k < NB_TRACK_FCB_4T - 1; k += 2 ) + { + L_index = get_next_indice_fx( st, 6 ); + dec_1p_N1_L_subfr_fx( L_index, NB_POS_FCB_4T_128, 5, pos ); + add_pulses_L_subfr_fx( NB_POS_FCB_4T_128, pos, 1, k, code ); + } + } + ELSE IF( EQ_16( cdk_index, 18 ) ) + { + /* 18 bits, 3 pulses, 4 tracks: 1110 (used first three tracks) */ + FOR( k = 0; k < NB_TRACK_FCB_4T - 1; k++ ) + { + L_index = get_next_indice_fx( st, 6 ); + dec_1p_N1_L_subfr_fx( L_index, NB_POS_FCB_4T_128, 5, pos ); + add_pulses_L_subfr_fx( NB_POS_FCB_4T_128, pos, 1, k, code ); + } + } + ELSE IF( EQ_16( cdk_index, 20 ) ) + { + /* 20 bits, 3 pulses, 4 tracks (used all tracks): 1110, 1101, 1011, 0111 */ + skip_track = get_next_indice_fx( st, 2 ); + FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) + { + IF( NE_16( k, skip_track ) ) + { + L_index = get_next_indice_fx( st, 6 ); + dec_1p_N1_L_subfr_fx( L_index, NB_POS_FCB_4T_128, 5, pos ); + add_pulses_L_subfr_fx( NB_POS_FCB_4T_128, pos, 1, k, code ); + } + } + } + ELSE IF( EQ_16( cdk_index, 24 ) ) + { + /* 24 bits, 4 pulses, 4 tracks: 1111 */ + FOR( k = 0; k < NB_TRACK_FCB_4T; k++ ) + { + L_index = get_next_indice_fx( st, 6 ); + dec_1p_N1_L_subfr_fx( L_index, NB_POS_FCB_4T_128, 5, pos ); + add_pulses_L_subfr_fx( NB_POS_FCB_4T_128, pos, 1, k, code ); + } + } + } + + return; +} \ No newline at end of file diff --git a/lib_dec/inov_dec.c b/lib_dec/inov_dec.c index f281b6f4008b9af76bf524abba883ab3fbbca65d..c3f370e61d6f688fc062679fb8475b40171863a8 100644 --- a/lib_dec/inov_dec.c +++ b/lib_dec/inov_dec.c @@ -38,6 +38,7 @@ #include "options.h" #include "cnst.h" #include "prot.h" +#include "prot_fx2.h" #include "ivas_prot.h" #include "rom_com.h" #include "wmc_auto.h" @@ -96,7 +97,17 @@ void inov_decode( } else { +#ifdef IVAS_FLOAT_FIXED + Word16 code_fx[256] = { 0 }; + dec_acelp_fast_fx( st, nBits, code_fx, L_subfr ); + FOR( Word16 lp = 0; lp < L_subfr; lp++ ) + { + code[lp] = (float) code_fx[lp] / 512; + } + +#else dec_acelp_fast( st, nBits, code, L_subfr ); +#endif } } else if ( ( st->idchan == 1 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 7 ) || ( st->idchan == 0 && st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR] <= 3 ) ) @@ -107,7 +118,16 @@ void inov_decode( } else { +#ifdef IVAS_FLOAT_FIXED + Word16 code_fx[L_SUBFR] = { 0 }; + dec_acelp_fast_fx( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code_fx, L_SUBFR ); + FOR( Word16 lp = 0; lp < L_SUBFR; lp++ ) + { + code[lp] = (float) code_fx[lp] / 512; + } +#else dec_acelp_fast( st, st->acelp_cfg.fixed_cdk_index[i_subfr / L_SUBFR], code, L_SUBFR ); +#endif } } else diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c deleted file mode 100644 index 00f7991d757ac927b9283e5ba3ad281bdc9face1..0000000000000000000000000000000000000000 --- a/lib_enc/enc_ppp_fx.c +++ /dev/null @@ -1,235 +0,0 @@ -///*==================================================================================== -// EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 -// ====================================================================================*/ -//#include -//#include "options.h" /* Compilation switches */ -//#include "cnst.h" /* Common constants */ -//#include "prot_fx2.h" /* Function prototypes */ -// -// /*Temporary location to be move in prot* when merge is done */ -//void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m); -// -///*=======================================================================================*/ -///* FUNCTION : encod_ppp_fx() */ -///*---------------------------------------------------------------------------------------*/ -///* PURPOSE : */ -///*---------------------------------------------------------------------------------------*/ -///* INPUT ARGUMENTS : */ -///* _ (Word16) speech_fx[], i : input speech Q_new */ -///* _ (Word16) Aq_fx[], i : 12k8 Lp coefficient Q12 */ -///* _ (Word16) A_fx[], i : unquantized A(z) filter with bandwidth expansion Q12*/ -///* _ (Word16) coder_type_fx, i : coding type */ -///* _ (Word16) T_op_fx[], i : open loop pitch */ -///* _ (Word16) voicing_fx[], i : voicing Q15 */ -///* _ (Word16) *res_fx, i : residual signal Q_new */ -///* _ (Word16) Q_new i : Q factor for res */ -///* _ (Word16) vadsnr_fx i : SNR for current frame Q7 */ -///*---------------------------------------------------------------------------------------*/ -///* OUTPUT ARGUMENTS : */ -///* _ (Word16) *exc2_fx, o : current enhanced excitation Q0 */ -///* _ (Word16) *pitch_buf_fx, o : floating pitch values for each subframe Q6 */ -///* _ (Word16) *synth_fx, o : core synthesis Q-1 */ -///* _ Encoder_State_fx *st_fx: */ -///* _ lastLgainE_fx - Q11 */ -///* _ lastHgainE_fx - Q11 */ -///* _ lasterbE_fx - Q13 */ -///*---------------------------------------------------------------------------------------*/ -///* INPUT/OUTPUT ARGUMENTS : */ -///* _ Encoder_State_fx *st_fx: */ -///* _ st_fx->dtfs_enc_xxxx */ -///* _ a nd b in st_fx->dtfs_enc_Q */ -///* rest all in Q0 */ -///* - bump_up_fx - Q0 */ -///* _ (Word16) *exc_fx, o : current enhanced excitation Q0 */ -///*---------------------------------------------------------------------------------------*/ -///* RETURN ARGUMENTS : */ -///* _ None. */ -///*---------------------------------------------------------------------------------------*/ -///* CALLED FROM : TX */ -///*=======================================================================================*/ -//ivas_error encod_ppp_fx( -// Encoder_State* st_fx, /* i/o: state structure */ -// const Word16 speech_fx[], /* i : input speech Q_new*/ -// const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */ -// const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ -// Word16 *res_fx, /* i : residual signal Q_new*/ -// Word16 *synth_fx, /* o : core synthesis Q-1*/ -// Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/ -// Word16 *exc2_fx, /* o : current enhanced excitation Q0*/ -// Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6*/ -// Word16 *voice_factors, /* o : voicing factors */ -// Word16 *bwe_exc, /* o : excitation for SWB TBE */ -// Word16 Q_new, -// Word16 shift -//) -//{ -// Word16 xn_fx[L_SUBFR]; /* Target vector for pitch search */ -// Word16 h1_fx[L_SUBFR + (M + 1)]; /* Impulse response vector */ -// Word16 i_subfr; /* tmp variables */ -// const Word16 *p_Aw_fx, *p_Aq_fx; /* pointer to LP filter coeff. vector*/ -// -// Word16 k; -// Word16 p_Aq_old_fx[M + 1], excQ_ppp_fx[L_FRAME], p_Aq_curr_fx[M], pitch_fx[NB_SUBFR]; -// Word16 LPC_de_old_fx[M + 1], LPC_de_curr_fx[M + 1]; -// Word16 shift_wsp = add(Q_new, shift); -// Word16 rate_ctrl_fx; -// Word16 saved_Q_new = Q_new; -// LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; -// SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR; -// BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -// ivas_error error; -// -// error = IVAS_ERR_OK; -// move16(); -// rate_ctrl_fx = hSC_VBR->rate_control; -// move16(); -// -// /*------------------------------------------------------------------* -// * ACELP subframe loop -// *------------------------------------------------------------------*/ -// p_Aw_fx = Aw_fx; -// p_Aq_fx = Aq_fx; -// FOR(i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR) -// { -// /*----------------------------------------------------------------* -// * Bandwidth expansion of A(z) filter coefficients -// * Find the the excitation search target "xn" and innovation -// * target in residual domain "cn" -// * Compute impulse response, h1[], of weighted synthesis filter -// *----------------------------------------------------------------*/ -// -// Copy(&res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR); -// -// find_targets_fx(speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq_fx, -// res_fx, L_SUBFR, p_Aw_fx, TILT_FAC_FX, xn_fx, NULL, h1_fx); -// -// /* scale xn[] and h1[] to avoid overflow in dot_product12() */ -// Scale_sig(xn_fx, L_SUBFR, shift); /* scaling of xn[] to limit dynamic at 12 bits */ -// -// /* call voiced encoder at this point */ -// IF(i_subfr == 0) /* generate the L_FRAME exc */ -// { -// FOR(k = 0; k < M; k++) -// { -// p_Aq_curr_fx[k] = p_Aq_fx[k + (3 * (M + 1)) + 1]; -// move16(); -// } -// -// E_LPC_f_lsp_a_conversion(st_fx->lsp_old_fx, p_Aq_old_fx, M); -// deemph_lpc_fx(p_Aq_curr_fx, p_Aq_old_fx, LPC_de_curr_fx, LPC_de_old_fx, 1); -// /* both outputs LPC_de_curr_fx and LPC_de_old_fx are in Q12 */ -// -// -// /* last frame-end lpc and curr frame-end lpc */ -// IF((error = ppp_voiced_encoder_fx(hBstr, hSC_VBR, st_fx->bwidth, st_fx->last_coder_type_raw, st_fx->old_pitch_buf_fx, res_fx, -// excQ_ppp_fx, st_fx->pitch_fx[1], LPC_de_old_fx, LPC_de_curr_fx, exc_fx, pitch_fx, Q_new)) != IVAS_ERR_OK) -// { -// return error; -// } -// -// Scale_sig(exc_fx, L_FRAME, (saved_Q_new - Q_new)); -// if (EQ_16(hSC_VBR->bump_up, 1)) -// { -// i_subfr = L_FRAME; -// move16(); -// } -// } -// -// IF(NE_16(hSC_VBR->bump_up, 1)) -// { -// /*-----------------------------------------------------------------* -// * Gain clipping test to avoid unstable synthesis on frame erasure -// * or in case of floating point encoder & fixed p. decoder -// *-----------------------------------------------------------------*/ -// gp_clip_fx(st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, st_fx->coder_type, xn_fx, st_fx->clip_var_fx, sub(shift_wsp, 1)); -// -// -// /* run the above to maintain gain clipping memories */ -// gp_clip_test_gain_pit_fx(st_fx->element_mode, st_fx->core_brate, hSC_VBR->prev_ppp_gain_pit_fx, st_fx->clip_var_fx); -// -// -// /*-----------------------------------------------------------------* -// * Synthesize speech to update mem_syn[]. -// * Update A(z) filters -// *-----------------------------------------------------------------*/ -// -// Syn_filt_s(1, p_Aq_fx, M, &excQ_ppp_fx[i_subfr], &synth_fx[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1); -// -// -// p_Aw_fx += (M + 1); -// p_Aq_fx += (M + 1); -// } -// -// } /* end of subframe loop */ -// -// IF(hSC_VBR->bump_up) -// { -// /* PPP failed, bump up */ -// hSC_VBR->ppp_mode = 0; -// move16(); -// st_fx->core_brate = ACELP_7k20; -// move16(); -// hSC_VBR->pppcountE = 0; -// move16(); -// -// IF(hSC_VBR->set_ppp_generic) -// { -// st_fx->coder_type = GENERIC; -// move16(); -// } -// ELSE -// { -// st_fx->coder_type = VOICED; -// move16(); -// } -// -// /* We write signalling indices again only in case of bump_up */ -// /* delete previous indices */ -//#ifndef IVAS_CODE_BITSTREAM -// reset_indices_enc_fx(hBstr); -//#else -// reset_indices_enc_fx(hBstr, hBstr->nb_ind_tot); -//#endif -// -// /* signalling matrix (writing of signalling bits) */ -// signalling_enc_fx(st_fx); -// } -// ELSE -// { -// Copy(excQ_ppp_fx, exc_fx, L_FRAME); -// -// /*-----------------------------------------------------------------* -// * Updates: last value of new target is stored in mem_w0 -// *-----------------------------------------------------------------*/ -// -// hLPDmem->mem_w0 = sub(shr(xn_fx[L_SUBFR - 1],shift), shr(exc_fx[L_FRAME - 1],1)); /*Q_new-1 */ -// -// Copy(exc_fx, exc2_fx, L_FRAME); -// -// hLPDmem->dm_fx.prev_state = 2; -// move16();/*Q0 dispMem index 0 */ -// hLPDmem->dm_fx.prev_gain_pit[0] = hSC_VBR->prev_ppp_gain_pit_fx; -// move16();/*Q14 dispMem index 2 */ -// -// FOR(k = 1; k < 5; k++) -// { -// hLPDmem->dm_fx.prev_gain_pit[k] = hLPDmem->dm_fx.prev_gain_pit[k - 1]; -// move16(); -// } -// -// hLPDmem->tilt_code = hSC_VBR->prev_tilt_code_fx; -// move16(); -// Copy(pitch_fx, pitch_buf_fx, NB_SUBFR); -// pitch_buf_fx[NB_SUBFR16k - 1] = pitch_fx[NB_SUBFR - 1]; -// -// interp_code_5over2_fx(exc2_fx, bwe_exc, L_FRAME); -// set16_fx(voice_factors, 0, NB_SUBFR16k); -// } -// -// hSC_VBR->rate_control = rate_ctrl_fx; -// move16(); -// -// set16_fx(hSC_VBR->nelp_lp_fit_mem, 0, NELP_LP_ORDER * 2); -// -// return error; -//}