Loading Workspace_msvc/lib_com.vcxproj.filters +1 −1 Original line number Diff line number Diff line Loading @@ -619,7 +619,7 @@ <Filter>common_h</Filter> </ClInclude> <ClInclude Include="..\lib_com\prot_fx.h"> <Filter>common_all_c</Filter> <Filter>common_h</Filter> </ClInclude> </ItemGroup> <ItemGroup> Loading lib_com/bitstream.c +118 −78 Original line number Diff line number Diff line Loading @@ -1318,33 +1318,6 @@ UWord16 get_indice_st( } #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* * reset_indices_enc() * * Reset the buffer of encoder indices *-------------------------------------------------------------------*/ void reset_indices_enc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 max_num_indices /* i : max number of indices */ ) { Word16 i; hBstr->nb_bits_tot = 0; move16(); hBstr->nb_ind_tot = 0; move16(); FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; move16(); } return; } /*-------------------------------------------------------------------* * reset_indices_dec() * Loading Loading @@ -1533,21 +1506,21 @@ static ivas_error write_indices_element_fx( { IF( st_ivas->hSCE[element_id]->hMetaData != NULL ) { reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } ELSE { IF( st_ivas->hCPE[element_id]->hMetaData != NULL ) { reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); } FOR( n = 0; n < n_channels; n++ ) { reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } Loading Loading @@ -2059,67 +2032,84 @@ void ivas_set_bitstream_pointers( *-------------------------------------------------------------------*/ /*! r: 1 = reading OK, 0 = problem */ ivas_error read_indices( ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t bit_stream[], /* i : bitstream buffer */ UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ int16_t *prev_ft_speech, int16_t *CNG, int16_t bfi /* i : bad frame indicator */ Word16 *prev_ft_speech, Word16 *CNG, Word16 bfi /* i : bad frame indicator */ ) { int16_t k; Word16 k; Decoder_State **sts; int32_t total_brate = 0; int16_t curr_ft_good_sp, curr_ft_bad_sp; int16_t g192_sid_first, sid_upd_bad, sid_update; int16_t speech_bad, speech_lost; int16_t n; Word32 total_brate = 0; move32(); Word16 curr_ft_good_sp, curr_ft_bad_sp; Word16 g192_sid_first, sid_upd_bad, sid_update; Word16 speech_bad, speech_lost; Word16 n; ivas_error error; error = IVAS_ERR_OK; move32(); st_ivas->BER_detect = 0; move16(); st_ivas->num_bits = num_bits; move16(); sts = reset_elements( st_ivas ); st_ivas->bfi = bfi; move16(); /* convert the frame length to total bitrate */ total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); total_brate = imult3216( num_bits, FRAMES_PER_SEC ); move32(); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ if ( st_ivas->ivas_format != MONO_FORMAT ) IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { k = 0; while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] ) move16(); test(); WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) ) { k++; k = add( k, 1 ); } if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) ) test(); test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) ) { st_ivas->element_mode_init = IVAS_SCE; move16(); } else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) ) ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) ) { st_ivas->element_mode_init = IVAS_SCE; move16(); } else if ( k == SIZE_IVAS_BRATE_TBL ) ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } else ELSE { st_ivas->element_mode_init = -1; move16(); } } else /* AMRWB or EVS */ ELSE /* AMRWB or EVS */ { st_ivas->element_mode_init = EVS_MONO; move16(); if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } Loading @@ -2129,47 +2119,58 @@ ivas_error read_indices( /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ curr_ft_good_sp = 0; move16(); curr_ft_bad_sp = 0; move16(); if ( is_DTXrate( total_brate ) == 0 ) IF( is_DTXrate( total_brate ) == 0 ) { if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { curr_ft_good_sp = 1; move16(); } else ELSE { curr_ft_bad_sp = 1; move16(); } } sid_update = 0; move16(); sid_upd_bad = 0; if ( is_SIDrate( total_brate ) == 1 ) move16(); IF( EQ_16( is_SIDrate( total_brate ), 1 ) ) { if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { sid_update = 1; move16(); } else ELSE { sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */ move16(); } } /* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero indices/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ if ( total_brate == SID_1k75 && sid_update == 1 ) test(); IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) { /* valid sid_update received, check for very risky but formally valid content */ int16_t sum = 0; for ( k = 0; k < num_bits; ++k ) Word16 sum = 0; move16(); FOR( k = 0; k < num_bits; ++k ) { sum += ( bit_stream[k] == 1 ); /* check of 35 zeroes */ sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /* check of 35 zeroes */ } if ( sum == 0 ) { /* all zeros */ sid_upd_bad = 1; /* initial signal as corrupt (BER likely) */ move16(); } } Loading @@ -2180,14 +2181,22 @@ ivas_error read_indices( Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . */ if ( sid_upd_bad ) IF( sid_upd_bad ) { sid_upd_bad = 0; move16(); total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ move32(); } g192_sid_first = 0; if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) move16(); test(); test(); test(); test(); if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ /* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: Loading @@ -2195,104 +2204,135 @@ ivas_error read_indices( and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding */ move16(); } speech_bad = 0; move16(); test(); if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) ) { speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */ move16(); } speech_lost = 0; move16(); test(); if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ move16(); } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ if ( *CNG != 0 ) IF( *CNG != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes you leave CNG synthesis */ *CNG = 0; move16(); } } else ELSE { /* We were in SPEECH synthesis */ /* only a received/detected SID frame can make the decoder enter into CNG synthsis */ test(); test(); if ( g192_sid_first || sid_update || sid_upd_bad ) { *CNG = 1; move16(); } } /* set bfi, total_brate pair for proper decoding */ /* handle the G.192 _simulated_ untransmitted NO_DATA frame, setting for decoder SPEECH synthesis */ test(); test(); if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { st_ivas->bfi = 1; /* SPEECH PLC code will now become active as in a real system */ /* total_brate= 0 */ move16(); } /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( bfi != FRAMEMODE_FUTURE && test(); test(); test(); test(); IF( ( NE_16( bfi, FRAMEMODE_FUTURE ) && ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ move16(); total_brate = FRAME_NO_DATA; move32(); } /* update for next frame's G.192 file format's odd SID_FIRST detection (primarily for AMRWBIO) */ test(); *prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); move16(); /* st->total brate= total_brate; updated in a good frame below */ for ( k = 0; k < st_ivas->nCPE; k++ ) FOR( k = 0; k < st_ivas->nCPE; k++ ) { sts = st_ivas->hCPE[k]->hCoreCoder; for ( n = 0; n < CPE_CHANNELS; n++ ) FOR( n = 0; n < CPE_CHANNELS; n++ ) { sts[n]->bfi = st_ivas->bfi; move16(); } } for ( k = 0; k < st_ivas->nSCE; k++ ) FOR( k = 0; k < st_ivas->nSCE; k++ ) { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bfi = st_ivas->bfi; move16(); } if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { /* select Mode 1 or Mode 2 */ if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */ { decoder_selectCodec( sts[0], total_brate, bit_stream[0] ); st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB; move16(); } else /* IVAS */ ELSE /* IVAS */ { st_ivas->codec_mode = MODE1; move16(); st_ivas->hDecoderConfig->Opt_AMR_WB = 0; move16(); } } /* GOOD frame */ if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE ) test(); if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) ) { /* GOOD frame - convert ITU-T G.192 words to short values */ st_ivas->hDecoderConfig->ivas_total_brate = total_brate; move32(); } st_ivas->bit_stream = bit_stream; if ( st_ivas->ivas_format == MONO_FORMAT ) IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { ivas_set_bitstream_pointers( st_ivas ); } Loading lib_com/bitstream_fx.c +3 −354 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_com/ivas_prot_fx.h +1 −5 Original line number Diff line number Diff line Loading @@ -669,11 +669,6 @@ Word16 read_flag_EC_DFT( Word16 *flag /* o : flag value */ ); /*file : ivas_mc_param_dec_fx.c*/ Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( Decoder_Struct *st_ivas /* i : Parametric MC handle */ ); void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ Word16 *numCldfbAnalyses, /* o : number of CLDFB analysis instances */ Loading Loading @@ -1974,6 +1969,7 @@ void ivas_DetectTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Loading lib_com/prot_fx.h +22 −39 Original line number Diff line number Diff line Loading @@ -1323,7 +1323,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ); void reset_indices_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ const Word16 max_num_indices /* i : max number of indices */ ); void reset_indices_dec_fx( Loading Loading @@ -1367,12 +1368,6 @@ Word16 BRATE2IDX16k_fx( Word32 brate ); Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */ Decoder_State *st_fx, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ Word16 rew_flag /* i : rewind flag (rewind file after reading) */ ); Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ Decoder_State *st, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ Loading Loading @@ -6461,6 +6456,7 @@ void ivas_RefineTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Loading Loading @@ -6649,12 +6645,7 @@ void hf_synth_fx( Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2, /* i : synthesis scaling */ Word16 *delay_syn_hf, /*i/o: HF synthesis memory Q_syn2*/ Word16 *memExp1, /* o : HF excitation exponent */ Word16 *mem_hp_interp, /* i/o: interpol. memory Qx*/ const Word16 extl, /* i : flag indicating BWE Q0*/ const Word16 CNG_mode /* i : CNG_mode Q0*/ const Word16 Q_syn2 /* i : synthesis scaling */ ); void hf_synth_amr_wb_init_fx( Loading Loading @@ -9626,13 +9617,6 @@ void set32_fx( const Word16 N /* i : Lenght of the vector */ ); void delay_signal_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word32 mem[], /* i/o: synchronization memory */ const Word16 delay /* i : delay in samples */ ); void delay_signal_q_adj_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Loading Loading @@ -9770,7 +9754,8 @@ void addBassPostFilter_ivas_fx( Word32 **iAnalysis_fx, HANDLE_CLDFB_FILTER_BANK cldfb ); Word32 ism_dequant_meta_fx( /* o : Q22*/ /* o : Q22*/ Word32 ism_dequant_meta_fx( const Word16 idx, /* i : quantizer index */ const Word32 borders_fx[], /* i : level borders Q22*/ const Word32 q_step_fx, /* i : quantization step Q22 */ Loading @@ -9780,10 +9765,13 @@ Word32 ism_dequant_meta_fx( /* o : Q22*/ void save_synthesis_hq_fec_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ const Word32 output_fx[], /* i : decoded synthesis */ const Word16 output_frame, /* i : decoded synthesis */ const Word16 Qpostd, /* i : Q value of delayed signal */ CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ ); void calculate_nbits_meta_fx( const Word16 nchan_ism, Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 Loading Loading @@ -10548,15 +10536,15 @@ void floating_point_add( const Word32 my, /* i: mantissa of the adder Q31 */ const Word16 ey /* i: exponent of the adder Q0 */ ); /*delay_signal_fx is also present*/ void delay_signal( void delay_signal_fx( Word16 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word16 mem[], /* i/o: synchronization memory */ const Word16 delay /* i : delay in samples */ ); void delay_signal32( void delay_signal32_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word32 mem[], /* i/o: synchronization memory */ Loading Loading @@ -11544,11 +11532,6 @@ uint16_t get_indice( int16_t nb_bits /* i : number of bits that were used to quantize the indice */ ); void reset_indices_enc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const int16_t max_num_indices /* i : max number of indices */ ); void reset_indices_dec( Decoder_State *st /* i/o: decoder state structure */ ); Loading @@ -11560,13 +11543,13 @@ Word16 rate2EVSmode_float( /*! r: 1 = OK, 0 = something wrong */ ivas_error read_indices( ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t bit_stream[], /* i : bitstream buffer */ UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ int16_t *prev_ft_speech, int16_t *CNG, int16_t bfi /* i : bad frame indicator */ Word16 *prev_ft_speech, Word16 *CNG, Word16 bfi /* i : bad frame indicator */ ); Loading
Workspace_msvc/lib_com.vcxproj.filters +1 −1 Original line number Diff line number Diff line Loading @@ -619,7 +619,7 @@ <Filter>common_h</Filter> </ClInclude> <ClInclude Include="..\lib_com\prot_fx.h"> <Filter>common_all_c</Filter> <Filter>common_h</Filter> </ClInclude> </ItemGroup> <ItemGroup> Loading
lib_com/bitstream.c +118 −78 Original line number Diff line number Diff line Loading @@ -1318,33 +1318,6 @@ UWord16 get_indice_st( } #define WMC_TOOL_SKIP /*-------------------------------------------------------------------* * reset_indices_enc() * * Reset the buffer of encoder indices *-------------------------------------------------------------------*/ void reset_indices_enc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const Word16 max_num_indices /* i : max number of indices */ ) { Word16 i; hBstr->nb_bits_tot = 0; move16(); hBstr->nb_ind_tot = 0; move16(); FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; move16(); } return; } /*-------------------------------------------------------------------* * reset_indices_dec() * Loading Loading @@ -1533,21 +1506,21 @@ static ivas_error write_indices_element_fx( { IF( st_ivas->hSCE[element_id]->hMetaData != NULL ) { reset_indices_enc( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); reset_indices_enc_fx( st_ivas->hSCE[element_id]->hMetaData, st_ivas->hSCE[element_id]->hMetaData->nb_ind_tot ); } reset_indices_enc( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); reset_indices_enc_fx( sts[0]->hBstr, sts[0]->hBstr->nb_ind_tot ); } ELSE { IF( st_ivas->hCPE[element_id]->hMetaData != NULL ) { reset_indices_enc( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); reset_indices_enc_fx( st_ivas->hCPE[element_id]->hMetaData, st_ivas->hCPE[element_id]->hMetaData->nb_ind_tot ); } FOR( n = 0; n < n_channels; n++ ) { reset_indices_enc( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); reset_indices_enc_fx( sts[n]->hBstr, sts[n]->hBstr->nb_ind_tot ); } } Loading Loading @@ -2059,67 +2032,84 @@ void ivas_set_bitstream_pointers( *-------------------------------------------------------------------*/ /*! r: 1 = reading OK, 0 = problem */ ivas_error read_indices( ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t bit_stream[], /* i : bitstream buffer */ UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ int16_t *prev_ft_speech, int16_t *CNG, int16_t bfi /* i : bad frame indicator */ Word16 *prev_ft_speech, Word16 *CNG, Word16 bfi /* i : bad frame indicator */ ) { int16_t k; Word16 k; Decoder_State **sts; int32_t total_brate = 0; int16_t curr_ft_good_sp, curr_ft_bad_sp; int16_t g192_sid_first, sid_upd_bad, sid_update; int16_t speech_bad, speech_lost; int16_t n; Word32 total_brate = 0; move32(); Word16 curr_ft_good_sp, curr_ft_bad_sp; Word16 g192_sid_first, sid_upd_bad, sid_update; Word16 speech_bad, speech_lost; Word16 n; ivas_error error; error = IVAS_ERR_OK; move32(); st_ivas->BER_detect = 0; move16(); st_ivas->num_bits = num_bits; move16(); sts = reset_elements( st_ivas ); st_ivas->bfi = bfi; move16(); /* convert the frame length to total bitrate */ total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC ); total_brate = imult3216( num_bits, FRAMES_PER_SEC ); move32(); /* verify that a valid num bits value is present in the G.192 file */ /* only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are allowed in G.192 file frame reading */ if ( st_ivas->ivas_format != MONO_FORMAT ) IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { k = 0; while ( k < SIZE_IVAS_BRATE_TBL && total_brate != ivas_brate_tbl[k] ) move16(); test(); WHILE( LT_16( k, SIZE_IVAS_BRATE_TBL ) && NE_32( total_brate, ivas_brate_tbl[k] ) ) { k++; k = add( k, 1 ); } if ( st_ivas->ivas_format == ISM_FORMAT && ( k < SIZE_IVAS_BRATE_TBL || total_brate <= SID_2k40 ) ) test(); test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && ( LT_16( k, SIZE_IVAS_BRATE_TBL ) || LE_32( total_brate, SID_2k40 ) ) ) { st_ivas->element_mode_init = IVAS_SCE; move16(); } else if ( ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) && ( total_brate <= SID_2k40 ) ) ELSE IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) && LE_32( total_brate, SID_2k40 ) ) { st_ivas->element_mode_init = IVAS_SCE; move16(); } else if ( k == SIZE_IVAS_BRATE_TBL ) ELSE IF( EQ_16( k, SIZE_IVAS_BRATE_TBL ) ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } else ELSE { st_ivas->element_mode_init = -1; move16(); } } else /* AMRWB or EVS */ ELSE /* AMRWB or EVS */ { st_ivas->element_mode_init = EVS_MONO; move16(); if ( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ IF( rate2EVSmode_float( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */ { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate ); } Loading @@ -2129,47 +2119,58 @@ ivas_error read_indices( /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */ curr_ft_good_sp = 0; move16(); curr_ft_bad_sp = 0; move16(); if ( is_DTXrate( total_brate ) == 0 ) IF( is_DTXrate( total_brate ) == 0 ) { if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { curr_ft_good_sp = 1; move16(); } else ELSE { curr_ft_bad_sp = 1; move16(); } } sid_update = 0; move16(); sid_upd_bad = 0; if ( is_SIDrate( total_brate ) == 1 ) move16(); IF( EQ_16( is_SIDrate( total_brate ), 1 ) ) { if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { sid_update = 1; move16(); } else ELSE { sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */ move16(); } } /* all zero indices/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */ /* all zero indices/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */ if ( total_brate == SID_1k75 && sid_update == 1 ) test(); IF( EQ_32( total_brate, SID_1k75 ) && EQ_16( sid_update, 1 ) ) { /* valid sid_update received, check for very risky but formally valid content */ int16_t sum = 0; for ( k = 0; k < num_bits; ++k ) Word16 sum = 0; move16(); FOR( k = 0; k < num_bits; ++k ) { sum += ( bit_stream[k] == 1 ); /* check of 35 zeroes */ sum = add( sum, extract_l( EQ_32( bit_stream[k], 1 ) ) ); /* check of 35 zeroes */ } if ( sum == 0 ) { /* all zeros */ sid_upd_bad = 1; /* initial signal as corrupt (BER likely) */ move16(); } } Loading @@ -2180,14 +2181,22 @@ ivas_error read_indices( Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR . */ if ( sid_upd_bad ) IF( sid_upd_bad ) { sid_upd_bad = 0; move16(); total_brate = FRAME_NO_DATA; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */ move32(); } g192_sid_first = 0; if ( st_ivas->ivas_format == MONO_FORMAT && sts[0]->core == AMR_WB_CORE && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) move16(); test(); test(); test(); test(); if ( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) && EQ_16( sts[0]->core, AMR_WB_CORE ) && *prev_ft_speech && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */ /* It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where: Loading @@ -2195,104 +2204,135 @@ ivas_error read_indices( and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO, due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding */ move16(); } speech_bad = 0; move16(); test(); if ( st_ivas->bfi != 0 && ( is_DTXrate( total_brate ) == 0 ) ) { speech_bad = 1; /* initial ft assumption, CNG_state decides what to do */ move16(); } speech_lost = 0; move16(); test(); if ( total_brate == FRAME_NO_DATA && st_ivas->bfi != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */ { speech_lost = 1; /* initial ft assumption, CNG_state decides what to do */ move16(); } /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame as this frame was never transmitted, one can not know it is good and has a a length of zero ) */ if ( *CNG != 0 ) IF( *CNG != 0 ) { /* We were in CNG synthesis */ if ( curr_ft_good_sp != 0 ) { /* only a good speech frame makes you leave CNG synthesis */ *CNG = 0; move16(); } } else ELSE { /* We were in SPEECH synthesis */ /* only a received/detected SID frame can make the decoder enter into CNG synthsis */ test(); test(); if ( g192_sid_first || sid_update || sid_upd_bad ) { *CNG = 1; move16(); } } /* set bfi, total_brate pair for proper decoding */ /* handle the G.192 _simulated_ untransmitted NO_DATA frame, setting for decoder SPEECH synthesis */ test(); test(); if ( *CNG == 0 && total_brate == FRAME_NO_DATA && st_ivas->bfi == 0 ) { st_ivas->bfi = 1; /* SPEECH PLC code will now become active as in a real system */ /* total_brate= 0 */ move16(); } /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( bfi != FRAMEMODE_FUTURE && test(); test(); test(); test(); IF( ( NE_16( bfi, FRAMEMODE_FUTURE ) && ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { st_ivas->bfi = 0; /* bfi=0 needed to activate CNG code */ move16(); total_brate = FRAME_NO_DATA; move32(); } /* update for next frame's G.192 file format's odd SID_FIRST detection (primarily for AMRWBIO) */ test(); *prev_ft_speech = ( ( curr_ft_good_sp != 0 ) || ( curr_ft_bad_sp != 0 ) ); move16(); /* st->total brate= total_brate; updated in a good frame below */ for ( k = 0; k < st_ivas->nCPE; k++ ) FOR( k = 0; k < st_ivas->nCPE; k++ ) { sts = st_ivas->hCPE[k]->hCoreCoder; for ( n = 0; n < CPE_CHANNELS; n++ ) FOR( n = 0; n < CPE_CHANNELS; n++ ) { sts[n]->bfi = st_ivas->bfi; move16(); } } for ( k = 0; k < st_ivas->nSCE; k++ ) FOR( k = 0; k < st_ivas->nSCE; k++ ) { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bfi = st_ivas->bfi; move16(); } if ( st_ivas->bfi == 0 ) IF( st_ivas->bfi == 0 ) { /* select Mode 1 or Mode 2 */ if ( st_ivas->ivas_format == MONO_FORMAT ) /* EVS mono */ IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) /* EVS mono */ { decoder_selectCodec( sts[0], total_brate, bit_stream[0] ); st_ivas->hDecoderConfig->Opt_AMR_WB = sts[0]->Opt_AMR_WB; move16(); } else /* IVAS */ ELSE /* IVAS */ { st_ivas->codec_mode = MODE1; move16(); st_ivas->hDecoderConfig->Opt_AMR_WB = 0; move16(); } } /* GOOD frame */ if ( st_ivas->bfi == 0 || st_ivas->bfi == FRAMEMODE_FUTURE ) test(); if ( st_ivas->bfi == 0 || EQ_16( st_ivas->bfi, FRAMEMODE_FUTURE ) ) { /* GOOD frame - convert ITU-T G.192 words to short values */ st_ivas->hDecoderConfig->ivas_total_brate = total_brate; move32(); } st_ivas->bit_stream = bit_stream; if ( st_ivas->ivas_format == MONO_FORMAT ) IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) { ivas_set_bitstream_pointers( st_ivas ); } Loading
lib_com/bitstream_fx.c +3 −354 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib_com/ivas_prot_fx.h +1 −5 Original line number Diff line number Diff line Loading @@ -669,11 +669,6 @@ Word16 read_flag_EC_DFT( Word16 *flag /* o : flag value */ ); /*file : ivas_mc_param_dec_fx.c*/ Word16 param_mc_get_num_cldfb_syntheses_ivas_fx( Decoder_Struct *st_ivas /* i : Parametric MC handle */ ); void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ Word16 *numCldfbAnalyses, /* o : number of CLDFB analysis instances */ Loading Loading @@ -1974,6 +1969,7 @@ void ivas_DetectTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Loading
lib_com/prot_fx.h +22 −39 Original line number Diff line number Diff line Loading @@ -1323,7 +1323,8 @@ UWord16 get_indice_1_fx( /* o : value of the indice */ ); void reset_indices_enc_fx( BSTR_ENC_HANDLE hBstr /* i/o: encoder state structure */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ const Word16 max_num_indices /* i : max number of indices */ ); void reset_indices_dec_fx( Loading Loading @@ -1367,12 +1368,6 @@ Word16 BRATE2IDX16k_fx( Word32 brate ); Word32 BIT_ALLOC_IDX_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word32 BIT_ALLOC_IDX_16KHZ_fx( Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc ); Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */ Decoder_State *st_fx, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ Word16 rew_flag /* i : rewind flag (rewind file after reading) */ ); Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */ Decoder_State *st, /* i/o: decoder state structure */ FILE *file, /* i : bitstream file */ Loading Loading @@ -6461,6 +6456,7 @@ void ivas_RefineTonalComponents_fx( const Word16 scaleFactors_exp[], const Word16 scaleFactors_max_e, const Word32 secondLastPowerSpectrum[], const Word16 secondLastPowerSpectrum_e, const Word16 nSamples, const Word16 nSamplesCore, const Word16 floorPowerSpectrum, /* i: lower limit for power spectrum bins */ Loading Loading @@ -6649,12 +6645,7 @@ void hf_synth_fx( Word16 *synth, /* i : 12.8kHz synthesis signal Q_syn2*/ Word16 *synth16k, /* o : 16kHz synthesis signal Q_syn2*/ const Word16 Q_exc, /* i : excitation scaling */ const Word16 Q_syn2, /* i : synthesis scaling */ Word16 *delay_syn_hf, /*i/o: HF synthesis memory Q_syn2*/ Word16 *memExp1, /* o : HF excitation exponent */ Word16 *mem_hp_interp, /* i/o: interpol. memory Qx*/ const Word16 extl, /* i : flag indicating BWE Q0*/ const Word16 CNG_mode /* i : CNG_mode Q0*/ const Word16 Q_syn2 /* i : synthesis scaling */ ); void hf_synth_amr_wb_init_fx( Loading Loading @@ -9626,13 +9617,6 @@ void set32_fx( const Word16 N /* i : Lenght of the vector */ ); void delay_signal_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word32 mem[], /* i/o: synchronization memory */ const Word16 delay /* i : delay in samples */ ); void delay_signal_q_adj_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Loading Loading @@ -9770,7 +9754,8 @@ void addBassPostFilter_ivas_fx( Word32 **iAnalysis_fx, HANDLE_CLDFB_FILTER_BANK cldfb ); Word32 ism_dequant_meta_fx( /* o : Q22*/ /* o : Q22*/ Word32 ism_dequant_meta_fx( const Word16 idx, /* i : quantizer index */ const Word32 borders_fx[], /* i : level borders Q22*/ const Word32 q_step_fx, /* i : quantization step Q22 */ Loading @@ -9780,10 +9765,13 @@ Word32 ism_dequant_meta_fx( /* o : Q22*/ void save_synthesis_hq_fec_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 synth_fx[], /* i : decoded synthesis (EVS) */ const Word32 output_fx[], /* i : decoded synthesis */ const Word16 output_frame, /* i : decoded synthesis */ const Word16 Qpostd, /* i : Q value of delayed signal */ CPE_DEC_HANDLE hCPE /* i : CPE decoder structure */ ); void calculate_nbits_meta_fx( const Word16 nchan_ism, Word32 q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], // Q30 Loading Loading @@ -10548,15 +10536,15 @@ void floating_point_add( const Word32 my, /* i: mantissa of the adder Q31 */ const Word16 ey /* i: exponent of the adder Q0 */ ); /*delay_signal_fx is also present*/ void delay_signal( void delay_signal_fx( Word16 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word16 mem[], /* i/o: synchronization memory */ const Word16 delay /* i : delay in samples */ ); void delay_signal32( void delay_signal32_fx( Word32 x[], /* i/o: signal to be delayed */ const Word16 len, /* i : length of the input signal */ Word32 mem[], /* i/o: synchronization memory */ Loading Loading @@ -11544,11 +11532,6 @@ uint16_t get_indice( int16_t nb_bits /* i : number of bits that were used to quantize the indice */ ); void reset_indices_enc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const int16_t max_num_indices /* i : max number of indices */ ); void reset_indices_dec( Decoder_State *st /* i/o: decoder state structure */ ); Loading @@ -11560,13 +11543,13 @@ Word16 rate2EVSmode_float( /*! r: 1 = OK, 0 = something wrong */ ivas_error read_indices( ivas_error read_indices_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ uint16_t bit_stream[], /* i : bitstream buffer */ UWord16 bit_stream[], /* i : bitstream buffer */ UWord16 num_bits, /* i : number of bits in bitstream */ int16_t *prev_ft_speech, int16_t *CNG, int16_t bfi /* i : bad frame indicator */ Word16 *prev_ft_speech, Word16 *CNG, Word16 bfi /* i : bad frame indicator */ );