diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9482f081f3da7d52f19cd2215f3b450160951bbe..2b06c2d788b84e1c39393ceec0ae188e82b00d9e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2160,7 +2160,7 @@ renderer-pytest-on-merge-request: - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest -q --log-level ERROR -n auto -rA --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check @@ -2222,7 +2222,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 0c212d3121dfa022cae3f2f98ae5a7f44557a7b4..96ef1f5076cfa2fd17dd770b210f1d75d79f323b 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -46,6 +46,9 @@ variables: FLOAT_REF_COMMIT_FILE: "float-ref-git-sha.txt" CUT_COMMIT_FILE: "CuT-git-sha.txt" MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha.txt" + RUNNER_TAG: "ivas-basop-linux" + LOGS_BACKUP_SOURCE_DIR: "" + LOGS_BACKUP_TARGET_DIR: "" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -63,4 +66,7 @@ variables: - 'complexity' - 'coverage' - 'voip-be-test' + - 'renderer-framesize-be' - 'peaq-enc-passthrough' + - 'long-term-logs' + - 'backup-long-term-logs' diff --git a/apps/decoder.c b/apps/decoder.c index 98673972e5eb3372c3960b096d2d357c36ab1912..0da70053d045c74ebd9a7a9f694adf8a5c7ac360 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2807,7 +2807,14 @@ static ivas_error decodeVoIP( } vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; frame++; +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + if ( vec_pos_update == 0 ) + { + systemTime_ms += vec_pos_len * systemTimeInc_ms; + } +#else systemTime_ms += systemTimeInc_ms; +#endif #ifdef WMOPS update_mem(); @@ -2815,6 +2822,90 @@ static ivas_error decodeVoIP( #endif } + +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + int16_t nSamplesFlushed = 0; + + /* decode and get samples */ + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( nSamplesFlushed ) + { + /* Write current frame */ + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + + /* Write ISm metadata to external file(s) */ + if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) + { + if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + for ( i = 0; i < numObj; ++i ) + { + IVAS_ISM_METADATA IsmMetadata; + + if ( ( error = IVAS_DEC_GetObjectMetadata( hIvasDec, &IsmMetadata, 0, i ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetObjectMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( IsmFileWriter_writeFrame( IsmMetadata, ismWriters[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing ISM metadata to file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); + goto cleanup; + } + } + } + + if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM ) + { + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + int16_t fullDelayNumSamples[3]; + float delayMs; + + /* delayNumSamples is zeroed, and delayNumSamples_orig is updated only on first good frame, so need to re-fetch delay info */ + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + } +#endif + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale ); + if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK ) +#else + if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) ); + goto cleanup; + } + } + } + } +#endif + + /*------------------------------------------------------------------------------------------* * Add zeros at the end to have equal length of synthesized signals *------------------------------------------------------------------------------------------*/ diff --git a/apps/encoder.c b/apps/encoder.c index 8404747dc088e1321e4fa0b9e6e394369123d135..1f871381b9229ddde7e54d57a7005145e3aebddd 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -758,12 +758,7 @@ int main( } /* *** Encode one frame *** */ - if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_com/basop32.c b/lib_com/basop32.c index fbe08a11f74d5a2afd466d351a5652b35d13f275..6a34cff43e570ae4a6a3212891067ca5887bef48 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -3582,13 +3582,13 @@ Word16 i_mult_o( Word16 a, Word16 b, Flag *Overflow ) #ifdef ORIGINAL_G7231 return a * b; #else - register Word32 c = a * b; + register Word32 c = (Word32) a * b; return saturate_o( c, Overflow ); #endif } Word16 i_mult( Word16 a, Word16 b ) { - return i_mult_o( a, b, NULL ); + return i_mult_sat( a, b ); } Word16 i_mult_sat( Word16 a, Word16 b ) { diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 3d6324783201b56b9dcc849ceab2b8dd2ee0b6c3..4c7ebea263c0df9e48ae3b8c5490ebf3b8ae936a 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1062,7 +1062,6 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) return z; } -#ifdef DIV32_OPT_NEWTON Word32 div_w_newton( Word32 num, Word32 den ); /* Table of 256 precalculated estimates to be used by the "div_w_newton" @@ -1462,7 +1461,6 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) return z; } -#endif /* DIV32_OPT_NEWTON */ Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s ) { @@ -1918,6 +1916,26 @@ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len ) return indx; } +Word16 findIndexOfMinWord64( Word64 *x, const Word16 len ) +{ + Word16 i, indx; + + + indx = 0; + move16(); + FOR( i = 1; i < len; i++ ) + { + if ( LT_64( x[i], x[indx] ) ) + { + indx = i; + move16(); + } + } + + + return indx; +} + Word16 imult1616( Word16 x, Word16 y ) { diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index b1d4b5fc18da6e9657c30667fb42609b8b1980e3..c95bf8100c976ed26819a27e1141278398ee098a 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -333,11 +333,9 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ -#ifdef DIV32_OPT_NEWTON Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ -#endif /************************************************************************/ @@ -538,6 +536,7 @@ Word16 findIndexOfMinWord16( Word16 *x, const Word16 len ); \return index of min Word32 */ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len ); +Word16 findIndexOfMinWord64( Word64 *x, const Word16 len ); /****************************************************************************/ /*! diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 8ebfd6fa7059531fe0a087bacc7d5cfbed840e13..ed82754b55692f65b9b293ec667d5c97c1c37f70 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -48,9 +48,12 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" +#ifdef DEBUGGING +#include "debug.h" #ifdef DBG_BITSTREAM_ANALYSIS #include #endif +#endif #define STEP_MAX_NUM_INDICES 100 /* increase the maximum number of allowed indices in the list by this amount */ @@ -201,7 +204,7 @@ ivas_error ind_list_realloc( { new_ind_list[i].id = old_ind_list[i].id; new_ind_list[i].value = old_ind_list[i].value; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif move16(); @@ -215,7 +218,7 @@ ivas_error ind_list_realloc( FOR( ; i < max_num_indices; i++ ) { new_ind_list[i].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( new_ind_list[i].function_name, "RESET in ind_list_realloc" ); #endif move16(); @@ -808,7 +811,7 @@ void move_indices( new_ind_list[i].value = old_ind_list[i].value; new_ind_list[i].nb_bits = old_ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif old_ind_list[i].nb_bits = -1; @@ -821,12 +824,12 @@ void move_indices( new_ind_list[i].id = old_ind_list[i].id; new_ind_list[i].value = old_ind_list[i].value; new_ind_list[i].nb_bits = old_ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif old_ind_list[i].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( old_ind_list[i].function_name, "RESET in move_indices" ); #endif } @@ -897,7 +900,7 @@ ivas_error check_ind_list_limits( return error; } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *named_indices_table[] = { "IND_IVAS_FORMAT", "IND_SMODE_OMASA", @@ -2817,7 +2820,7 @@ ivas_error push_indice( hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id; hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits; hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[j - 1].function_name, 100 ); #endif move16(); @@ -2831,7 +2834,7 @@ ivas_error push_indice( hBstr->ind_list[i].id = id; hBstr->ind_list[i].value = value; hBstr->ind_list[i].nb_bits = nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[i].function_name, named_indices_table[id], 100 ); #endif move16(); @@ -2852,13 +2855,11 @@ ivas_error push_indice( * * Push a new indice into the buffer at the next position *-------------------------------------------------------------------*/ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( -#endif -#ifdef DBG_BITSTREAM_ANALYSIS - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ UWord16 value, /* i : value of the quantized indice */ @@ -2897,7 +2898,7 @@ ivas_error push_next_indice( move16(); move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[hBstr->nb_ind_tot].function_name, caller, 100 ); #endif @@ -2914,13 +2915,11 @@ ivas_error push_next_indice( * push_next_bits() * Push a bit buffer into the buffer at the next position *-------------------------------------------------------------------*/ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( -#endif -#ifdef DBG_BITSTREAM_ANALYSIS - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ @@ -2965,7 +2964,7 @@ ivas_error push_next_bits( ptr->value = code; ptr->nb_bits = 16; ptr->id = prev_id; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( ptr->function_name, caller, 100 ); #endif hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 ); @@ -2989,7 +2988,7 @@ ivas_error push_next_bits( ptr->value = bits[i]; ptr->nb_bits = 1; ptr->id = prev_id; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( ptr->function_name, caller, 100 ); #endif hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 ); @@ -3066,7 +3065,7 @@ UWord16 delete_indice( hBstr->ind_list[j].id = hBstr->ind_list[i].id; hBstr->ind_list[j].value = hBstr->ind_list[i].value; hBstr->ind_list[j].nb_bits = hBstr->ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[i].function_name, 100 ); #endif } @@ -3080,7 +3079,7 @@ UWord16 delete_indice( { /* reset the shifted indices at the end of the list */ hBstr->ind_list[j].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hBstr->ind_list[j].function_name, "RESET in delete_indice" ); #endif } @@ -3319,10 +3318,6 @@ static ivas_error write_indices_element_fx( UWord16 **pt_stream, /* i : pointer to bitstream buffer */ const Word16 is_SCE, /* i : flag to distingusih SCE and CPE */ const Word16 element_id /* i : id of the SCE or CPE */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Word16 ch; @@ -3429,7 +3424,7 @@ static ivas_error write_indices_element_fx( } } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) if ( is_SCE ) /* EVS and SCE */ { static FILE *f1 = 0; @@ -3539,10 +3534,6 @@ ivas_error write_indices_ivas_fx( Encoder_Struct *st_ivas, /* i/o: encoder state structure */ UWord16 *bit_stream, /* i/o: output bitstream */ UWord16 *num_bits /* i : number of indices written to output */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Word16 i, n; @@ -3566,22 +3557,12 @@ ivas_error write_indices_ivas_fx( FOR( n = 0; n < st_ivas->nSCE; n++ ) { - write_indices_element_fx( st_ivas, &pt_stream, 1, n -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); + write_indices_element_fx( st_ivas, &pt_stream, 1, n ); } FOR( n = 0; n < st_ivas->nCPE; n++ ) { - write_indices_element_fx( st_ivas, &pt_stream, 0, n -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); + write_indices_element_fx( st_ivas, &pt_stream, 0, n ); } *num_bits = (UWord16) ( pt_stream - bit_stream ); diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 2b66f92cd7ba3352cf0979ffa6b6a23896ac9199..02b0a8fa15c04ec02bb4b4c1ef7d8ef0e3a1afb7 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -242,130 +242,6 @@ Word16 rate2EVSmode( * * Push a new indice into the buffer *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void push_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -) -{ - Word16 i; - - - IF( EQ_16( hBstr->last_ind_fx, id ) ) - { - /* indice with the same name as the previous one */ - i = hBstr->next_ind_fx; - move16(); - } - ELSE - { - /* new indice - find an empty slot in the list */ - i = id; - move16(); - WHILE( hBstr->ind_list[i].nb_bits != -1 ) - { - i = add( i, 1 ); - } - } - - /* store the values in the list */ - hBstr->ind_list[i].value = value; - move16(); - hBstr->ind_list[i].nb_bits = nb_bits; - move16(); - - /* updates */ - hBstr->next_ind_fx = add( i, 1 ); - move16(); - hBstr->last_ind_fx = id; - move16(); - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); - - return; -} -/*-------------------------------------------------------------------* - * push_next_indice() * - * Push a new indice into the buffer at the next position - *-------------------------------------------------------------------*/ - -void push_next_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -) -{ - - /* store the values in the list */ - hBstr->ind_list[hBstr->next_ind_fx].value = value; - move16(); - hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits; - move16(); - hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 ); - move16(); - - /* update the total number of bits already written */ - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); - - return; -} - - -/*-------------------------------------------------------------------* - * push_next_bits() - * Push a bit buffer into the buffer at the next position - *-------------------------------------------------------------------*/ - -void push_next_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - Word16 bits[], /* i : bit buffer to pack, sequence of single bits */ - Word16 nb_bits /* i : number of bits to pack */ -) -{ - UWord16 code; - Word16 i, nb_bits_m15; - Indice *ptr; - - ptr = &hBstr->ind_list[hBstr->next_ind_fx]; - nb_bits_m15 = sub( nb_bits, 15 ); - i = 0; - move16(); - IF( nb_bits_m15 > 0 ) - { - FOR( ; i < nb_bits_m15; i += 16 ) - { - code = s_or( lshl( bits[i], 15 ), s_or( lshl( bits[i + 1], 14 ), s_or( lshl( bits[i + 2], 13 ), s_or( lshl( bits[i + 3], 12 ), - s_or( lshl( bits[i + 4], 11 ), s_or( lshl( bits[i + 5], 10 ), s_or( lshl( bits[i + 6], 9 ), s_or( lshl( bits[i + 7], 8 ), - s_or( lshl( bits[i + 8], 7 ), s_or( lshl( bits[i + 9], 6 ), s_or( lshl( bits[i + 10], 5 ), s_or( lshl( bits[i + 11], 4 ), - s_or( lshl( bits[i + 12], 3 ), s_or( lshl( bits[i + 13], 2 ), s_or( lshl( bits[i + 14], 1 ), bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); - - ptr->value = code; - move16(); - ptr->nb_bits = 16; - move16(); - ++ptr; - } - } - IF( LT_16( i, nb_bits ) ) - { - FOR( ; i < nb_bits; ++i ) - { - ptr->value = bits[i]; - move16(); - ptr->nb_bits = 1; - move16(); - ++ptr; - } - } - hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list ); - move16(); - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); -} -#endif /*-------------------------------------------------------------------* * get_next_indice_fx( ) @@ -528,12 +404,6 @@ void reset_indices_enc_fx( move16(); hBstr->nb_bits_tot = 0; move16(); -#ifndef HARM_PUSH_BIT - hBstr->next_ind_fx = 0; - move16(); - hBstr->last_ind_fx = -1; - move16(); -#endif FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; @@ -564,215 +434,11 @@ void reset_indices_dec_fx( * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void write_indices_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - FILE *file /* i : output bitstream file */ - , - UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ - Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */ -) -{ - Word16 i, k; - Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream; - Word32 mask; - UWord8 header; - Word16 isAmrWb = 0; - move16(); - - IF( st_fx->bitstreamformat == G192 ) - { - /*-----------------------------------------------------------------* - * Encode Sync Header and Frame Length - *-----------------------------------------------------------------*/ - pt_stream = stream; - FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) - { - stream[i] = 0; - move16(); - } - *pt_stream++ = SYNC_GOOD_FRAME; - move16(); - *pt_stream++ = hBstr->nb_bits_tot; - move16(); - - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - * Writing the serial stream into file - *----------------------------------------------------------------*/ - - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) - { - /* mask from MSB to LSB */ - mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) ); - - /* write bit by bit */ - FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) - { - IF( L_and( hBstr->ind_list[i].value, mask ) ) - { - *pt_stream++ = G192_BIN1; - move16(); - } - ELSE - { - *pt_stream++ = G192_BIN0; - move16(); - } - - mask = L_shr( mask, 1 ); - } - } - } - } - ELSE - { - /* Create and write ToC header */ - /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ - header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) ); - move16(); - fwrite( &header, sizeof( UWord8 ), 1, file ); - /* Write speech bits */ - fwrite( pFrame, sizeof( UWord8 ), shr( add( pFrame_size, 7 ), 3 ), file ); - } - - /* Clearing of indices */ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - - IF( st_fx->bitstreamformat == G192 ) - { - /* write the serial stream into file */ - fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file ); - } - /* reset index pointers */ - hBstr->nb_bits_tot = 0; - move16(); - hBstr->next_ind_fx = 0; - move16(); - hBstr->last_ind_fx = -1; - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * write_indices_buf_fx() * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void write_indices_buf_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord16 *out_buf, /* i : output bitstream buf */ - UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ - Word16 pFrame_size, /* i: size of the binary encoded access unit [bits] */ - UWord16 *num_bits ) -{ - Word16 i, k; - Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream; - Word32 mask; - UWord8 header; - Word16 isAmrWb = 0; - - IF( st_fx->bitstreamformat == G192 ) - { - /*-----------------------------------------------------------------* - * Encode Sync Header and Frame Length - *-----------------------------------------------------------------*/ - pt_stream = stream; - FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) - { - stream[i] = 0; - move16(); - } - //*pt_stream++ = (Word16) SYNC_GOOD_FRAME; - //*pt_stream++ = hBstr->nb_bits_tot; - *num_bits = hBstr->nb_bits_tot; - move16(); - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - * Writing the serial stream into file - *----------------------------------------------------------------*/ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) - { - /* mask from MSB to LSB */ - mask = L_shl( 1, ( sub( hBstr->ind_list[i].nb_bits, 1 ) ) ); - - /* write bit by bit */ - FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) - { - IF( L_and( hBstr->ind_list[i].value, mask ) ) - { - //*pt_stream++ = G192_BIN1; - *pt_stream++ = 1; - move16(); - } - ELSE - { - //*pt_stream++ = G192_BIN0; - *pt_stream++ = 0; - move16(); - } - - mask = L_shr( mask, 1 ); - } - } - } - } - ELSE - { - /* Create and write ToC header */ - /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ - header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( i_mult( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) ); - // fwrite(&header, sizeof(UWord8), 1, file); - memcpy( out_buf, &header, sizeof( UWord8 ) ); - *num_bits += sizeof( UWord8 ); - /* Write speech bits */ - // fwrite(pFrame, sizeof(UWord8), (pFrame_size + 7) >> 3, file); - memcpy( out_buf, pFrame, sizeof( UWord8 ) * ( shr( add( pFrame_size, 7 ), 3 ) ) ); - *num_bits += sizeof( UWord8 ) * ( shr( ( add( pFrame_size, 7 ) ), 3 ) ); - } - - /* Clearing of indices */ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - - IF( st_fx->bitstreamformat == G192 ) - { - /* write the serial stream into file */ - // fwrite(stream, sizeof(unsigned short), 2 + stream[1], file); - // FILE *ftemp = fopen( "./output/bitstreams/out.COD", "ab" ); - // fwrite( stream, sizeof( unsigned short ), 2 + stream[1], ftemp ); - // fclose( ftemp ); - memcpy( out_buf, stream, sizeof( unsigned short ) * ( *num_bits ) ); - //*num_bits += sizeof( unsigned short ) * ( 2 + stream[1] ); - } - /* reset index pointers */ - hBstr->nb_bits_tot = 0; - hBstr->next_ind_fx = 0; - hBstr->last_ind_fx = -1; - move16(); - move16(); - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * indices_to_serial() * diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index ede4be78bde0a8a0c27bb13f83e1e246613c8057..30b8d57d02d7f69e142269930be0af4c2016ac85 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -104,8 +104,12 @@ void cldfbAnalysis_ivas_fx( Word32 iBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX]; const Word32 *rot_vctr_re_fx; const Word32 *rot_vctr_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -147,8 +151,12 @@ void cldfbAnalysis_ivas_fx( rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; rot_vctr_im_fx = h_cldfb->rot_vec_ana_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -156,6 +164,32 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx @@ -180,10 +214,11 @@ void cldfbAnalysis_ivas_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1 @@ -207,6 +242,31 @@ void cldfbAnalysis_ivas_fx( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx @@ -235,6 +295,7 @@ void cldfbAnalysis_ivas_fx( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // Qx - 1 @@ -323,8 +384,12 @@ void cldfbAnalysis_ts_fx( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -371,8 +436,12 @@ void cldfbAnalysis_ts_fx( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -380,6 +449,31 @@ void cldfbAnalysis_ts_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -404,36 +498,27 @@ void cldfbAnalysis_ts_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ - rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 - ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE + rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 + ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); ///* folding + pre modulation of DCT IV */ - ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 - ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE + ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 + ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -441,6 +526,31 @@ void cldfbAnalysis_ts_fx( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -469,32 +579,23 @@ void cldfbAnalysis_ts_fx( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ - rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 - ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE + rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 + ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); /* folding + pre modulation of DCT IV */ - ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 - ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE + ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 + ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -519,22 +620,6 @@ void cldfbAnalysis_ts_fx( } fft_cldfb_fx( rBuffer_fx, M2 ); -#ifndef FIX_1733_CLDFB_BUG - /* post modulation of DST IV */ - FOR( k = 0; k < M2; k++ ) - { - /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 - realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - move32(); - move32(); - } -#endif *q_cldfb = sub( *q_cldfb, 2 ); move16(); @@ -555,35 +640,23 @@ void cldfbAnalysis_ts_fx( move32(); } -#ifdef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } -#endif /* post modulation of DCT IV */ FOR( k = 0; k < M2; k++ ) { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -604,13 +677,8 @@ void cldfbAnalysis_ts_fx( /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/ /*realBuffer[k] = rBuffer[k]; imagBuffer[k] = iBuffer[k];*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5 imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 - imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[k] = cplx_aux_fx; move32(); move32(); @@ -659,8 +727,12 @@ void cldfbAnalysis_ts_fx_var_q( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -724,8 +796,12 @@ void cldfbAnalysis_ts_fx_var_q( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -733,6 +809,31 @@ void cldfbAnalysis_ts_fx_var_q( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -757,10 +858,11 @@ void cldfbAnalysis_ts_fx_var_q( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 @@ -784,6 +886,32 @@ void cldfbAnalysis_ts_fx_var_q( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -812,6 +940,7 @@ void cldfbAnalysis_ts_fx_var_q( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 @@ -930,8 +1059,12 @@ void cldfbAnalysis_ts_fx_fixed_q( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize, gb, hr, shift; @@ -977,8 +1110,12 @@ void cldfbAnalysis_ts_fx_fixed_q( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -986,6 +1123,31 @@ void cldfbAnalysis_ts_fx_fixed_q( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -1010,10 +1172,11 @@ void cldfbAnalysis_ts_fx_fixed_q( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 @@ -1037,6 +1200,31 @@ void cldfbAnalysis_ts_fx_fixed_q( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -1065,6 +1253,7 @@ void cldfbAnalysis_ts_fx_fixed_q( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 @@ -1189,14 +1378,12 @@ void cldfbAnalysis_ts_fx_fixed_q( * Conduct inverse multple overlap cmplex low delay MDCT *--------------------------------------------------------------------*/ void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ const Word16 out_shift, /* i : scale for output buffer */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ) { @@ -1222,8 +1409,12 @@ void cldfbSynthesis_ivas_fx( Word32 new_samples_fx[2 * CLDFB_NO_CHANNELS_MAX]; Word32 *ptr_time_out_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *p_filter; Word16 p_filter_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 accu0, accu1, accu2, accu3, accu4; Word16 no_col = h_cldfb->no_col; @@ -1253,9 +1444,12 @@ void cldfbSynthesis_ivas_fx( synthesisBuffer_fx = buffer_fx; Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + i_mult( M1, no_col ), h_cldfb->p_filter_length ); +#ifdef OPT_IVAS_FILTER_ROM + p_filter_32 = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ p_filter = h_cldfb->p_filter; - p_filter_sf = h_cldfb->p_filter_sf; // Q14 - move16(); + p_filter_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ ptr_time_out_fx = timeOut_fx; /*synthesisBuffer += M1 * h_cldfb->no_col;*/ @@ -1366,11 +1560,19 @@ void cldfbSynthesis_ivas_fx( { FOR( i = 0; i < L2; i++ ) { +#ifdef OPT_IVAS_FILTER_ROM + accu0 = Madd_32_32( synthesisBuffer_fx[i], new_samples_fx[L2 - 1 - i], p_filter_32[i] ); // Qx - 1 + accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 1 * L2 + i )] ); // Qx - 1 + accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 2 * L2 + i )] ); // Qx - 1 + accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 3 * L2 + i )] ); // Qx - 1 + accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 4 * L2 + i )] ); // Qx - 1 +#else /* OPT_IVAS_FILTER_ROM */ accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[i] ), p_filter_sf ); // Qx - 1 accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ synthesisBuffer_fx[i] = accu0; move32(); @@ -1389,12 +1591,21 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < L2; i++ ) { +#ifdef OPT_IVAS_FILTER_ROM + Word32 prod = L_shl_sat( ( new_samples_fx[L2 - 1 - i] ), shift ); + accu0 = Madd_32_32( synthesisBuffer_fx[i], prod, p_filter_32[i] ); // Qx -1 + shift + accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], prod, p_filter_32[( 1 * L2 + i )] ); // Qx -1 + shift + accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], prod, p_filter_32[( 2 * L2 + i )] ); // Qx -1 + shift + accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], prod, p_filter_32[( 3 * L2 + i )] ); // Qx -1 + shift + accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], prod, p_filter_32[( 4 * L2 + i )] ); // Qx -1 + shift +#else /* OPT_IVAS_FILTER_ROM */ Word32 prod = L_shl_sat( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter_sf ), shift ); accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx -1 + shift accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx -1 + shift accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx -1 + shift accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx -1 + shift accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx -1 + shift +#endif /* OPT_IVAS_FILTER_ROM */ synthesisBuffer_fx[i] = accu0; move32(); @@ -1409,16 +1620,13 @@ void cldfbSynthesis_ivas_fx( } } -#ifdef OPT_AVOID_STATE_BUF_RESCALE IF( 0 == out_shift ) { -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( i = 0; i < M1; i++ ) { ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i]; move32(); } -#ifdef OPT_AVOID_STATE_BUF_RESCALE } ELSE { @@ -1428,7 +1636,6 @@ void cldfbSynthesis_ivas_fx( move32(); } } -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ ptr_time_out_fx += M1; @@ -1867,8 +2074,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; - hs->p_filter_sf = (Word16) 17036; // Q14 +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_10_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1879,8 +2090,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_10_SCALE_FX_Q8; } BREAK; @@ -1898,8 +2113,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_16_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1910,8 +2129,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_16_SCALE_FX_Q8; } BREAK; @@ -1929,8 +2152,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_20_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1941,8 +2168,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15390; // Q14 hs->p_filter = LDQMF_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_20_SCALE_FX_Q8; } BREAK; @@ -1960,8 +2191,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_30_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_30_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1972,8 +2207,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_30_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_30_SCALE_FX_Q8; } BREAK; @@ -1991,8 +2230,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_32_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -2003,8 +2246,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15392; // Q14 hs->p_filter = LDQMF_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_32_SCALE_FX_Q8; } BREAK; @@ -2022,8 +2269,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_40_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -2034,8 +2285,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_40_SCALE_FX_Q8; } BREAK; @@ -2053,8 +2308,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_60_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -2065,8 +2324,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_60_SCALE_FX_Q8; } BREAK; @@ -2113,11 +2376,15 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17036; // Q14 hs->scale = cldfb_scale_2_5ms[0]; move16(); move16(); +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ } ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { @@ -2129,8 +2396,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[0]; move16(); move16(); @@ -2158,8 +2429,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[1]; move16(); move16(); @@ -2174,8 +2449,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[1]; move16(); move16(); @@ -2210,8 +2489,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[2]; move16(); move16(); @@ -2226,8 +2509,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15390; // Q14 hs->p_filter = LDQMF_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[2]; move16(); move16(); @@ -2261,9 +2548,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17051; // Q14 hs->scale = cldfb_scale_2_5ms[6]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = CLDFB80_30_fx; + hs->p_filter_sf = (Word16) 17051; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ } ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { @@ -2275,9 +2566,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_sf = (Word16) 15388; // Q14 hs->scale = cldfb_scale_5_0ms[6]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = LDQMF_30_fx; + hs->p_filter_sf = (Word16) 15388; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2304,8 +2599,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[3]; move16(); move16(); @@ -2320,9 +2619,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_sf = (Word16) 15392; // Q14 hs->scale = cldfb_scale_5_0ms[3]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = LDQMF_32_fx; + hs->p_filter_sf = (Word16) 15392; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2355,9 +2658,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17051; // Q14 hs->scale = cldfb_scale_2_5ms[4]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = CLDFB80_40_fx; + hs->p_filter_sf = (Word16) 17051; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2371,8 +2678,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[4]; move16(); move16(); @@ -2406,8 +2717,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[5]; move16(); move16(); @@ -2422,8 +2737,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[5]; move16(); move16(); diff --git a/lib_com/cnst.h b/lib_com/cnst.h index d648a4280b01819741eb0277344d8bfc8d17e6dc..a8eeb1d890485698eb34c8d6fe0a8c97dd9e836b 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -134,7 +134,7 @@ #define ONE_IN_Q29 536870912 #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 -2147483648 +#define MINUS_ONE_IN_Q31 (-2147483647 - 1) #define TWO_IN_Q29 1073741824 #define FOUR_IN_Q28 1073741824 @@ -227,6 +227,7 @@ enum{ #define ONE_BY_L_FRAME32k_Q31 3355443 #define ONE_BY_L_FRAME25_6k_Q31 4194304 #define ONE_BY_L_FRAME16k_Q31 6710886 +#define ONE_BY_L_FRAME16k_Q15 102 #define ONE_BY_L_FRAME_Q31 8388608 #define ONE_BY_240_Q31 8947849 #define ONE_BY_L_FRAME8k_Q31 13421772 @@ -535,15 +536,7 @@ enum IND_STEREO_ICBWE_MSFLAG, IND_SHB_ENER_SF, IND_SHB_RES_GS, -#ifndef FIX_1486_IND_SHB_RES - IND_SHB_RES_GS1, - IND_SHB_RES_GS2, - IND_SHB_RES_GS3, - IND_SHB_RES_GS4, - IND_SHB_VF, -#else IND_SHB_VF = IND_SHB_RES_GS + 5, -#endif IND_SHB_LSF, IND_SHB_MIRROR = IND_SHB_LSF + 5, IND_SHB_GRID, @@ -690,6 +683,7 @@ enum #define NUM_DCT_LENGTH 24 #define NB_DIV 2 /* number of division (subframes) per 20ms frame */ +#define NB_DIV_LOG2 1 /* To be used for shift operation instead of division */ #define L_MDCT_HALF_OVLP_MAX L_MDCT_OVLP_MAX - 48000 / 200 /* Size of HALF overlap window slope @ 48 kHz */ #define L_MDCT_MIN_OVLP_MAX 60 /* Size of the MDCT minimal overlap @ 48 kHz - 1.25ms */ #define L_MDCT_TRANS_OVLP_MAX NS2SA( 48000, ACELP_TCX_TRANS_NS ) /* Size of the ACELP->MDCT transition overlap - 1.25ms */ @@ -718,6 +712,7 @@ enum #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ +#define L_SUBFR_LOG2 6 /* To be used for shift operation instead of division */ #define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ #define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ @@ -798,6 +793,7 @@ enum #endif #define CLDFB_NO_CHANNELS_MAX_FX 30720 /*Q9*/ #define CLDFB_NO_COL_MAX 16 /* CLDFB resampling - max number of CLDFB col., == IVAS_CLDFB_NO_COL_MAX */ +#define CLDFB_NO_COL_MAX_LOG2 4 /* To be used for shift operation instead of division */ #define ONE_BY_CLDFB_NO_COL_MAX_Q31 134217728 #define CLDFB_NO_COL_MAX_SWITCH 6 /* CLDFB resampling - max number of CLDFB col. for switching */ #define CLDFB_NO_COL_MAX_SWITCH_BFI 10 /* CLDFB resampling - max number of CLDFB col. for switching, BFI */ @@ -1544,6 +1540,7 @@ enum #define INTERP_3_2_MEM_LEN 15 #define L_SHB_LAHEAD 20 /* Size of lookahead for SHB */ #define NUM_SHB_SUBFR 16 +#define NUM_SHB_SUBFR_LOG2 4 /* To be used for shift operation instead of division */ #define LPC_SHB_ORDER 10 #define LPC_WHTN_ORDER 4 /* Order of whitening filter for SHB excitation */ #define SHB_OVERLAP_LEN ( L_FRAME16k - L_SHB_LAHEAD ) / ( NUM_SHB_SUBFR - 1 ) @@ -3105,7 +3102,8 @@ extern const Word16 Idx2Freq_Tbl[]; #define FS_32K_IN_NS_Q31 68719 #define FS_16K_IN_NS_Q31 34360 -#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ #define THREE_Q21 6291456 #define SIX_Q21 12582912 diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index 9bc20cb6f6892b86fe023ff163fa8272ec9cc7bb..523061b9808f6bf61038b4c909884fa39f64f9a5 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -197,8 +197,12 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W { FOR( i = 0; i < L; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ +#else L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ - x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ +#endif + x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ move16(); } } diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 40c9780148ac85d1a202be1a623309ed24095c1b..b1323e1561fb770e3c82f94bda56b3ee5f696fba 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -4725,7 +4725,6 @@ static void fft_len16( cmplx t[4]; cmplx y[16]; -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[0]; // Qx move64(); s[1] = x[4]; // Qx @@ -4734,16 +4733,6 @@ static void fft_len16( move64(); s[3] = x[12]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[0], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[4], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[8], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[12], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4763,7 +4752,6 @@ static void fft_len16( y[3] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[1]; // Qx move64(); s[1] = x[5]; // Qx @@ -4772,16 +4760,6 @@ static void fft_len16( move64(); s[3] = x[13]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[1], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[5], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[9], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[13], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4801,7 +4779,6 @@ static void fft_len16( y[7] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[2]; // Qx move64(); s[1] = x[6]; // Qx @@ -4810,16 +4787,6 @@ static void fft_len16( move64(); s[3] = x[14]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[2], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[6], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[10], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[14], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4841,7 +4808,6 @@ static void fft_len16( y[11] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[3]; // Qx move64(); s[1] = x[7]; // Qx @@ -4850,16 +4816,6 @@ static void fft_len16( move64(); s[3] = x[15]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[3], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[7], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[11], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[15], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -5020,7 +4976,6 @@ static void fft_len20_fx( cmplx tt[4]; cmplx y[20]; -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[0]; // Qx move64(); xx[1] = x[16]; // Qx @@ -5031,18 +4986,6 @@ static void fft_len20_fx( move64(); xx[4] = x[4]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[0], SCALEFACTOR20 ); // Qx - move64(); - xx[1] = CL_shr( x[16], SCALEFACTOR20 ); // Qx - move64(); - xx[2] = CL_shr( x[12], SCALEFACTOR20 ); // Qx - move64(); - xx[3] = CL_shr( x[8], SCALEFACTOR20 ); // Qx - move64(); - xx[4] = CL_shr( x[4], SCALEFACTOR20 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5078,7 +5021,6 @@ static void fft_len20_fx( y[12] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[5]; move64(); xx[1] = x[1]; @@ -5089,18 +5031,6 @@ static void fft_len20_fx( move64(); xx[4] = x[9]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[5], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[1], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[17], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[13], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[9], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5136,7 +5066,6 @@ static void fft_len20_fx( y[13] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[10]; move64(); xx[1] = x[6]; @@ -5147,18 +5076,6 @@ static void fft_len20_fx( move64(); xx[4] = x[14]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[10], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[6], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[2], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[18], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[14], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5194,7 +5111,6 @@ static void fft_len20_fx( y[14] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[15]; move64(); xx[1] = x[11]; @@ -5205,18 +5121,6 @@ static void fft_len20_fx( move64(); xx[4] = x[19]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[15], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[11], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[7], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[3], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[19], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -6595,7 +6499,6 @@ static void fft_lenN( cmplx s[8]; cmplx y[8]; -#ifdef OPT_STEREO_32KBPS_V1 y[1] = xx[1 * dim1]; move64(); y[2] = xx[2 * dim1]; @@ -6827,288 +6730,6 @@ static void fft_lenN( move64(); } } -#else /* OPT_STEREO_32KBPS_V1 */ - test(); - test(); - test(); - test(); - IF( EQ_16( dim1, 30 ) || EQ_16( dim1, 20 ) || EQ_16( dim1, 15 ) || EQ_16( dim1, 10 ) || EQ_16( dim1, 5 ) ) - { - FOR( i = 0; i < dim1; i++ ) - { - { - y[0] = xx[i]; // y[0] = xx[i + 0 * dim1] - move64(); - }; - IF( i == 0 ) - { - { - y[1] = xx[( i + ( 1 * dim1 ) )]; - move64(); - }; - { - y[2] = xx[( i + ( 2 * dim1 ) )]; - move64(); - }; - { - y[3] = xx[( i + ( 3 * dim1 ) )]; - move64(); - }; - { - y[4] = xx[( i + ( 4 * dim1 ) )]; - move64(); - }; - { - y[5] = xx[( i + ( 5 * dim1 ) )]; - move64(); - }; - { - y[6] = xx[( i + ( 6 * dim1 ) )]; - move64(); - }; - { - y[7] = xx[( i + ( 7 * dim1 ) )]; - move64(); - }; - } - ELSE - { - { - y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - } - - t[0] = CL_add( y[0], y[4] ); - move64(); - t[1] = CL_sub( y[0], y[4] ); - move64(); - t[2] = CL_add( y[1], y[5] ); - move64(); - t[3] = CL_sub( y[1], y[5] ); - move64(); - t[4] = CL_add( y[2], y[6] ); - move64(); - t[5] = CL_sub( y[2], y[6] ); - move64(); - t[6] = CL_add( y[3], y[7] ); - move64(); - t[7] = CL_sub( y[3], y[7] ); - move64(); - - s[0] = CL_add( t[0], t[4] ); - move64(); - s[2] = CL_sub( t[0], t[4] ); - move64(); - s[4] = CL_mac_j( t[1], t[5] ); - move64(); - s[5] = CL_msu_j( t[1], t[5] ); - move64(); - s[1] = CL_add( t[2], t[6] ); - move64(); - s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); - move64(); - - t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); - move64(); - t[1] = CL_sub( t[3], t[7] ); - move64(); - - s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx - move64(); - s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx - move64(); - s[7] = CL_conjugate( s[7] ); - move64(); - - x[i] = CL_add( s[0], s[1] ); /*x[add(i + i_mult(0 , dim1)] = CL_add( s[0], s[1] )*/ - move64(); - x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); - move64(); - x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); - move64(); - x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); - move64(); - x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); - move64(); - x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); - move64(); - x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); - move64(); - x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); - move64(); - } - } - ELSE - { - FOR( i = 0; i < dim1; i++ ) - { - { - y[0] = xx[i]; /* y[0] = xx[i + 0 * dim1] */ - move64(); - }; - IF( i == 0 ) - { - { - y[1] = xx[( i + ( 1 * dim1 ) )]; - move64(); - }; - { - y[2] = xx[( i + ( 2 * dim1 ) )]; - move64(); - }; - { - y[3] = xx[( i + ( 3 * dim1 ) )]; - move64(); - }; - { - y[4] = xx[( i + ( 4 * dim1 ) )]; - move64(); - }; - { - y[5] = xx[( i + ( 5 * dim1 ) )]; - move64(); - }; - { - y[6] = xx[( i + ( 6 * dim1 ) )]; - move64(); - }; - { - y[7] = xx[( i + ( 7 * dim1 ) )]; - move64(); - }; - } - ELSE - { - { - y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - } - - t[0] = CL_add( y[0], y[4] ); - move64(); - t[1] = CL_sub( y[0], y[4] ); - move64(); - t[2] = CL_add( y[1], y[5] ); - move64(); - t[3] = CL_sub( y[1], y[5] ); - move64(); - t[4] = CL_add( y[2], y[6] ); - move64(); - t[5] = CL_sub( y[2], y[6] ); - move64(); - t[6] = CL_add( y[3], y[7] ); - move64(); - t[7] = CL_sub( y[3], y[7] ); - move64(); - - s[0] = CL_add( t[0], t[4] ); - move64(); - s[2] = CL_sub( t[0], t[4] ); - move64(); - s[4] = CL_mac_j( t[1], t[5] ); - move64(); - s[5] = CL_msu_j( t[1], t[5] ); - move64(); - s[1] = CL_add( t[2], t[6] ); - move64(); - s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); - move64(); - - t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); - move64(); - t[1] = CL_sub( t[3], t[7] ); - move64(); - - s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx - move64(); - s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx - move64(); - s[7] = CL_conjugate( s[7] ); - move64(); - - x[i] = CL_add( s[0], s[1] ); /*x[i + 0 * dim1] = CL_add( s[0], s[1] )*/ - move64(); - x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); - move64(); - x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); - move64(); - x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); - move64(); - x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); - move64(); - x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); - move64(); - x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); - move64(); - x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); - move64(); - } - } -#endif /* OPT_STEREO_32KBPS_V1 */ BREAK; } @@ -7501,11 +7122,7 @@ void rfft_fx( move32(); x[( length - ( i << 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 /*0.5.Q15*/ ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_add( t2, t4 ), -16384 /*0.5.Q15*/ ); -#else /* OPT_STEREO_32KBPS_V1 */ - x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 /*0.5.Q15*/ ); -#endif /* OPT_STEREO_32KBPS_V1 */ move32(); } diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index f1864d7a792a27526a97321276cde5df053c8bb0..4a055e0733df912583fd38b86930508aa0187031 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -532,11 +532,7 @@ void hp20_fx_32( move16(); } Qy1 = sub( Qy1, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R1 = W_mult0_32_32( W_shl_sat_l( y1_fx64, Qy1 ), a1_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qy1 = add( Qy1, Qprev_y1 ); Qy2 = W_norm( y2_fx64 ); @@ -546,11 +542,7 @@ void hp20_fx_32( move16(); } Qy2 = sub( Qy2, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R2 = W_mult0_32_32( W_shl_sat_l( y2_fx64, Qy2 ), a2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qy2 = add( Qy2, Qprev_y2 ); Qx0 = W_norm( x0_fx64 ); @@ -560,11 +552,7 @@ void hp20_fx_32( move16(); } Qx0 = sub( Qx0, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R3 = W_mult0_32_32( W_shl_sat_l( x0_fx64, Qx0 ), b2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qx1 = W_norm( x1_fx64 ); if ( x1_fx64 == 0 ) @@ -573,11 +561,7 @@ void hp20_fx_32( move16(); } Qx1 = sub( Qx1, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R4 = W_mult0_32_32( W_shl_sat_l( x1_fx64, Qx1 ), b1_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qx2 = W_norm( x2_fx64 ); if ( x2_fx64 == 0 ) @@ -586,11 +570,7 @@ void hp20_fx_32( move16(); } Qx2 = sub( Qx2, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R5 = W_mult0_32_32( W_shl_sat_l( x2_fx64, Qx2 ), b2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qmin = s_min( Qy1, Qy2 ); diff --git a/lib_com/interpol_fx.c b/lib_com/interpol_fx.c index a490a755269c9fa7d3f9bdeb440b60bf7f483253..030d417359a34f3d61c7948d4cbde3c2fad9b949 100644 --- a/lib_com/interpol_fx.c +++ b/lib_com/interpol_fx.c @@ -70,9 +70,14 @@ Word32 Interpol_lc_fx( /* o : interpolated value c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */ c1 += up_samp; } +#ifdef OPT_SBA_ENC_V2_BE + L_sum = W_shl_sat_l( L_sum64, 1 ); /*Q15*/ + } +#else L_sum = W_sat_l( L_sum64 ); /*Q14*/ } L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/ +#endif return L_sum; } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index e719008c4e2406eb9656d5fc356bef86092ba975..5b1d54265c66aac7c75a5d8a85cb0712387044fc 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -166,6 +166,7 @@ typedef enum #define BINAURAL_CHANNELS 2 /* number of channels for binaural output configuration */ #define CPE_CHANNELS 2 /* number of CPE (stereo) channels */ +#define CPE_CHANNELS_LOG2 1 /* To be used for the shift operation instead of division */ #define FOA_CHANNELS 4 /* number of FOA channels */ #define HOA2_CHANNELS 9 #define HOA3_CHANNELS 16 @@ -198,6 +199,7 @@ typedef enum #define MAX_JBM_SUBFRAMES_5MS 8 #define DEFAULT_JBM_SUBFRAMES_5MS 4 #define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 +#define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 2 /* To be used for shift operation instead of division */ #define MAX_JBM_CLDFB_TIMESLOTS 32 #define DEFAULT_JBM_CLDFB_TIMESLOTS 16 #define MAX_JBM_L_FRAME48k 1920 @@ -936,12 +938,14 @@ typedef enum { #define MDFT_FB_BANDS_240 240 #define CLDFB_TO_MDFT_FAC 4 #define MDFT_NO_COL_MAX 4 +#define MDFT_NO_COL_MAX_LOG2 2 /* To be used for shift operation instead of division */ /*----------------------------------------------------------------------------------* * General Parametric Coding Constants *----------------------------------------------------------------------------------*/ #define MAX_PARAM_SPATIAL_SUBFRAMES 4 /* Maximum number of subframes for parameteric spatial coding */ +#define MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 2 /* To be used for shift operation instead of division */ #define L_SPATIAL_SUBFR_48k (L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES) #define CLDFB_SLOTS_PER_SUBFRAME ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) /* Number of CLDFB slots per subframe */ @@ -972,6 +976,7 @@ typedef enum { #define DIRAC_MAX_NBANDS 12 /* Maximum number of frequency bands for the DirAC Side Parameter decoding */ #define DIRAC_LOW_BANDRES_STEP 2 /* always combine two bands for low band resolution in the DirAC parameter coding */ #define DIRAC_NO_COL_AVG_DIFF 32 /* Number of slots for averaging intensity vector for diffuseness computation */ +#define DIRAC_NO_COL_AVG_DIFF_LOG2 5 /* To be used for shift operation instead of division */ #define DIRAC_DIFFUSE_LEVELS 8 /* Size of the diffuseness alphabet (constant value) */ #define INV_DIRAC_DIFFUSE_LEVELS_Q13 1170 /* 1/(DIRAC_DIFFUSE_LEVELS - 1) in Q13 */ #define DIRAC_DITH_SEED 29680 @@ -1689,6 +1694,7 @@ typedef enum #define DEG_180_IN_Q22 ( 180 << Q22 ) // Q22 #define DEG_90_IN_Q22 ( 90 << Q22 ) // Q22 #define ONE_BY_360_Q31 ( 5965232 ) // Q31 +#define ONE_BY_360_Q15 ( 91 ) // Q15 #define ONE_BY_180_Q31 ( 11930465 ) // Q31 /* ----- Enums - TD Renderer ----- */ @@ -1865,6 +1871,7 @@ typedef enum #define SPAR_DIRAC_SPLIT_START_BAND 8 #define DIRAC_TO_SPAR_HBR_PRED_CHS (FOA_CHANNELS - 1) #define SPAR_DTX_BANDS 2 +#define SPAR_DTX_BANDS_LOG2 1 /* To be used for shift operation instead of division */ #define DIRAC_DTX_BANDS 2 #define SPAR_DIRAC_DTX_BANDS ( SPAR_DTX_BANDS + DIRAC_DTX_BANDS ) #define CLDFB_PAR_WEIGHT_START_BAND 7 diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 858f4798e265d10e61554e2dace2f24ddda3563f..59735c9c564cfbcdd2faeebc8f259d23c9120711 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -1114,6 +1114,17 @@ void calculate_hodirac_sector_parameters_fx( Word16 i_sec, i_bin, i_band; Word32 p_real_fx, p_imag_fx, normI_fx, energy_fx, tmp_diff_fx; Word16 energy_exp, normI_exp, tmp_diff_exp; +#ifdef OPT_SBA_ENC_V2_NBE + Word16 tmp_exp_1 = sub( 33, shl( Qfac, 1 ) ); // 31 - (2 *Qfac - 2 ) + Word16 tmp_exp_2 = sub( 35, shl( Qfac, 1 ) ); // 31 - (2 *Qfac - 4 ) + Word32 tmp32_1, tmp32_2; + Word64 temp_x64 = 0, temp_y64 = 0, temp_z64 = 0; + Word16 tmp_scale = 0; + move64(); + move64(); + move64(); + move16(); +#endif Word32 sec_I_vec_x_fx[NUM_ANA_SECTORS]; Word32 sec_I_vec_y_fx[NUM_ANA_SECTORS]; @@ -1187,7 +1198,16 @@ void calculate_hodirac_sector_parameters_fx( move32(); energy_exp = 0; move16(); - +#ifdef OPT_SBA_ENC_V2_NBE + Word64 sec_I_vec_x_64_fx = 0; + Word64 sec_I_vec_y_64_fx = 0; + Word64 sec_I_vec_z_64_fx = 0; + Word64 energy_64_fx = 0; + move64(); + move64(); + move64(); + move64(); +#endif IF( i_sec == 0 ) { FOR( i_bin = band_grouping[i_band]; i_bin < band_grouping[i_band + 1]; i_bin++ ) @@ -1196,7 +1216,18 @@ void calculate_hodirac_sector_parameters_fx( move32(); Word32 sec_w_imag_fx, sec_x_imag_fx, sec_y_imag_fx, sec_z_imag_fx; Word32 sec_w_real_fx, sec_x_real_fx, sec_y_real_fx, sec_z_real_fx; - +#ifdef OPT_SBA_ENC_V2_NBE + sec_w_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ); // Qfac - 2 + sec_x_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_imag_fx = Msub_32_32( ( Msub_32_32( ( Madd_32_32( Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_5_fx++ ) ); // Qfac - 2 + + sec_w_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_0_fx ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx ) ); // Qfac - 2 + sec_x_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_real_fx = Msub_32_32( ( Msub_32_32( Madd_32_32( Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ), HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ); // Qfac - 2 + +#else sec_w_imag_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ) ); // Qfac - 2 sec_x_imag_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_imag_fx = L_sub( L_sub( L_add( Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ) ); // Qfac - 2 @@ -1206,14 +1237,17 @@ void calculate_hodirac_sector_parameters_fx( sec_x_real_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_real_fx = L_sub( L_sub( L_add( Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ) ); // Qfac - 2 sec_z_real_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ) ); // Qfac - 2 +#endif +#ifndef OPT_SBA_ENC_V2_NBE Word16 p_q; Word32 tmp_x, tmp_y, tmp_z; Word16 n, n1, n2; - +#endif p_real_fx = Mpy_32_32( sec_w_real_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 p_imag_fx = Mpy_32_32( sec_w_imag_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 +#ifndef OPT_SBA_ENC_V2_NBE n1 = norm_l( p_real_fx ); n2 = norm_l( p_imag_fx ); @@ -1236,13 +1270,35 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_sec_I_vec_z_fx = BASOP_Util_Add_Mant32Exp( *p_sec_I_vec_z_fx, *p_sec_I_vec_z_exp, tmp_z, tmp_exp, p_sec_I_vec_z_exp ); move32(); - - Word32 tmp1; +#else + temp_x64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_x_real_fx ), p_imag_fx, sec_x_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_y64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_y_real_fx ), p_imag_fx, sec_y_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_z64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_z_real_fx ), p_imag_fx, sec_z_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + sec_I_vec_x_64_fx = W_add( sec_I_vec_x_64_fx, temp_x64 ); + sec_I_vec_y_64_fx = W_add( sec_I_vec_y_64_fx, temp_y64 ); + sec_I_vec_z_64_fx = W_add( sec_I_vec_z_64_fx, temp_z64 ); + + Word64 tmp1; +#endif Word64 tmp2, tmp3, tmp4, sec_sum64; +#ifndef OPT_SBA_ENC_V2_NBE + Word32 tmp1; Word32 tmp5, sec_sum; tmp_exp = sub( 62, add( p_q, p_q ) ); tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( p_real_fx, p_real_fx ), tmp_exp, Mpy_32_32( p_imag_fx, p_imag_fx ), tmp_exp, &tmp_exp ); +#endif +#ifdef OPT_SBA_ENC_V2_NBE + tmp1 = W_mac_32_32( W_mult_32_32( p_real_fx, p_real_fx ), p_imag_fx, p_imag_fx ); // 2 * (Qfac - 3) + 1 + tmp1 = W_shl( tmp1, 2 ); // 2 * (Qfac - 2) + 1 + tmp2 = W_mac_32_32( W_mult_32_32( sec_x_real_fx, sec_x_real_fx ), sec_x_imag_fx, sec_x_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp3 = W_mac_32_32( W_mult_32_32( sec_y_real_fx, sec_y_real_fx ), sec_y_imag_fx, sec_y_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp4 = W_mac_32_32( W_mult_32_32( sec_z_real_fx, sec_z_real_fx ), sec_z_imag_fx, sec_z_imag_fx ); // 2 * (Qfac - 2) + 1 + sec_sum64 = W_add( tmp1, W_add( W_add( tmp2, tmp3 ), tmp4 ) ); // 2 * (Qfac - 2) + 1 + + // instead dividing changed Q// + energy_64_fx = W_add( energy_64_fx, sec_sum64 ); // 2 * (Qfac - 2) + 1 + 1 +#else tmp2 = W_add( W_mult0_32_32( sec_x_real_fx, sec_x_real_fx ), W_mult0_32_32( sec_x_imag_fx, sec_x_imag_fx ) ); // 2 * (Qfac - 2) tmp3 = W_add( W_mult0_32_32( sec_y_real_fx, sec_y_real_fx ), W_mult0_32_32( sec_y_imag_fx, sec_y_imag_fx ) ); // 2 * (Qfac - 2) tmp4 = W_add( W_mult0_32_32( sec_z_real_fx, sec_z_real_fx ), W_mult0_32_32( sec_z_imag_fx, sec_z_imag_fx ) ); // 2 * (Qfac - 2) @@ -1258,7 +1314,51 @@ void calculate_hodirac_sector_parameters_fx( tmp5 = BASOP_Util_Add_Mant32Exp( tmp1, tmp_exp, sec_sum, sec_sum_exp, &tmp_exp ); energy_fx = BASOP_Util_Add_Mant32Exp( energy_fx, energy_exp, tmp5, tmp_exp, &energy_exp ); +#endif + } +#ifdef OPT_SBA_ENC_V2_NBE + tmp_scale = sub( W_norm( energy_64_fx ), 32 ); + energy_fx = W_shl_sat_l( energy_64_fx, tmp_scale ); + energy_exp = sub( tmp_exp_1, tmp_scale ); + if ( energy_fx == 0 ) + { + energy_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_x_64_fx ), 32 ); + *p_sec_I_vec_x_fx = W_shl_sat_l( sec_I_vec_x_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_x_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_x_fx == 0 ) + { + *p_sec_I_vec_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_y_64_fx ), 32 ); + *p_sec_I_vec_y_fx = W_shl_sat_l( sec_I_vec_y_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_y_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_y_fx == 0 ) + { + *p_sec_I_vec_y_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_z_64_fx ), 32 ); + *p_sec_I_vec_z_fx = W_shl_sat_l( sec_I_vec_z_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_z_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_z_fx == 0 ) + { + *p_sec_I_vec_z_exp = 0; + move16(); } +#endif } ELSE { @@ -1269,6 +1369,18 @@ void calculate_hodirac_sector_parameters_fx( Word32 sec_w_imag_fx, sec_x_imag_fx, sec_y_imag_fx, sec_z_imag_fx; Word32 sec_w_real_fx, sec_x_real_fx, sec_y_real_fx, sec_z_real_fx; +#ifdef OPT_SBA_ENC_V2_NBE + sec_w_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ); // Qfac - 2 + sec_x_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_imag_fx = Madd_32_32( ( Madd_32_32( ( Madd_32_32( Mpy_32_32( -HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_5_fx++ ) ); // Qfac - 2 + + sec_w_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_0_fx ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx ) ); // Qfac - 2 + sec_x_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_real_fx = Madd_32_32( ( Madd_32_32( ( Madd_32_32( Mpy_32_32( -HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ); // Qfac - 2 + +#else sec_w_imag_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ) ); // Qfac - 2 sec_x_imag_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_imag_fx = L_add( L_add( L_add( Mpy_32_32( -HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ) ); // Qfac - 2 @@ -1278,20 +1390,21 @@ void calculate_hodirac_sector_parameters_fx( sec_x_real_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_real_fx = L_add( L_add( L_add( Mpy_32_32( -HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ) ); // Qfac - 2 sec_z_real_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ) ); // Qfac - 2 - +#endif +#ifndef OPT_SBA_ENC_V2_NBE Word16 p_q; + Word32 tmp_x, tmp_y, tmp_z; + Word16 n, n1, n2; +#endif p_real_fx = Mpy_32_32( sec_w_real_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 p_imag_fx = Mpy_32_32( sec_w_imag_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 - Word32 tmp_x, tmp_y, tmp_z; - Word16 n, n1, n2; - +#ifndef OPT_SBA_ENC_V2_NBE n1 = norm_l( p_real_fx ); n2 = norm_l( p_imag_fx ); n = s_min( n1, n2 ); - p_real_fx = L_shl( p_real_fx, n ); p_imag_fx = L_shl( p_imag_fx, n ); @@ -1309,13 +1422,35 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_sec_I_vec_z_fx = BASOP_Util_Add_Mant32Exp( *p_sec_I_vec_z_fx, *p_sec_I_vec_z_exp, tmp_z, tmp_exp, p_sec_I_vec_z_exp ); move32(); - - Word32 tmp1; +#else + temp_x64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_x_real_fx ), p_imag_fx, sec_x_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_y64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_y_real_fx ), p_imag_fx, sec_y_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_z64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_z_real_fx ), p_imag_fx, sec_z_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + sec_I_vec_x_64_fx = W_add( sec_I_vec_x_64_fx, temp_x64 ); + sec_I_vec_y_64_fx = W_add( sec_I_vec_y_64_fx, temp_y64 ); + sec_I_vec_z_64_fx = W_add( sec_I_vec_z_64_fx, temp_z64 ); + + Word64 tmp1; +#endif Word64 tmp2, tmp3, tmp4, sec_sum64; +#ifndef OPT_SBA_ENC_V2_NBE + Word32 tmp1; Word32 tmp5, sec_sum; tmp_exp = sub( 62, add( p_q, p_q ) ); tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( p_real_fx, p_real_fx ), tmp_exp, Mpy_32_32( p_imag_fx, p_imag_fx ), tmp_exp, &tmp_exp ); +#endif +#ifdef OPT_SBA_ENC_V2_NBE + tmp1 = W_mac_32_32( W_mult_32_32( p_real_fx, p_real_fx ), p_imag_fx, p_imag_fx ); // 2 * (Qfac - 3) + 1 + tmp1 = W_shl( tmp1, 2 ); // 2 * (Qfac - 2) + 1 + tmp2 = W_mac_32_32( W_mult_32_32( sec_x_real_fx, sec_x_real_fx ), sec_x_imag_fx, sec_x_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp3 = W_mac_32_32( W_mult_32_32( sec_y_real_fx, sec_y_real_fx ), sec_y_imag_fx, sec_y_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp4 = W_mac_32_32( W_mult_32_32( sec_z_real_fx, sec_z_real_fx ), sec_z_imag_fx, sec_z_imag_fx ); // 2 * (Qfac - 2) + 1 + sec_sum64 = W_add( tmp1, W_add( W_add( tmp2, tmp3 ), tmp4 ) ); // 2 * (Qfac - 2) + 1 + + // instead dividing changed Q// + energy_64_fx = W_add( energy_64_fx, sec_sum64 ); // 2 * (Qfac - 2) + 1 + 1 +#else tmp2 = W_add( W_mult0_32_32( sec_x_real_fx, sec_x_real_fx ), W_mult0_32_32( sec_x_imag_fx, sec_x_imag_fx ) ); // 2 * (Qfac - 2) tmp3 = W_add( W_mult0_32_32( sec_y_real_fx, sec_y_real_fx ), W_mult0_32_32( sec_y_imag_fx, sec_y_imag_fx ) ); // 2 * (Qfac - 2) tmp4 = W_add( W_mult0_32_32( sec_z_real_fx, sec_z_real_fx ), W_mult0_32_32( sec_z_imag_fx, sec_z_imag_fx ) ); // 2 * (Qfac - 2) @@ -1324,14 +1459,56 @@ void calculate_hodirac_sector_parameters_fx( sec_sum64 = W_shl( sec_sum64, n ); // 2 * (Qfac - 2) + n sec_sum = W_extract_h( sec_sum64 ); // 2 * (Qfac - 2) + n - 32 = 2 * Qfac + n - 36 sec_sum_exp = sub( 67, add( shl( Qfac, 1 ), n ) ); - // divide by 2: tmp1 = L_shr( tmp1, 1 ); sec_sum = L_shr( sec_sum, 1 ); - tmp5 = BASOP_Util_Add_Mant32Exp( tmp1, tmp_exp, sec_sum, sec_sum_exp, &tmp_exp ); energy_fx = BASOP_Util_Add_Mant32Exp( energy_fx, energy_exp, tmp5, tmp_exp, &energy_exp ); +#endif + } +#ifdef OPT_SBA_ENC_V2_NBE + tmp_scale = sub( W_norm( energy_64_fx ), 32 ); + energy_fx = W_shl_sat_l( energy_64_fx, tmp_scale ); + energy_exp = sub( tmp_exp_1, tmp_scale ); + if ( energy_fx == 0 ) + { + energy_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_x_64_fx ), 32 ); + *p_sec_I_vec_x_fx = W_shl_sat_l( sec_I_vec_x_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_x_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_x_fx == 0 ) + { + *p_sec_I_vec_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_y_64_fx ), 32 ); + *p_sec_I_vec_y_fx = W_shl_sat_l( sec_I_vec_y_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_y_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_y_fx == 0 ) + { + *p_sec_I_vec_y_exp = 0; + move16(); } + + tmp_scale = sub( W_norm( sec_I_vec_z_64_fx ), 32 ); + *p_sec_I_vec_z_fx = W_shl_sat_l( sec_I_vec_z_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_z_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_z_fx == 0 ) + { + *p_sec_I_vec_z_exp = 0; + move16(); + } +#endif } IF( hDirAC->firstrun_sector_params ) @@ -1356,7 +1533,62 @@ void calculate_hodirac_sector_parameters_fx( ELSE { Word32 w_fx = L_sub( ONE_IN_Q30, beta_fx ); // Q30 +#ifdef OPT_SBA_ENC_V2_NBE + Word32 tmp_1, tmp_2, tmp_3, tmp_sec_1, tmp_sec_2, tmp_sec_3; + Word16 e_x, e_y, e_z; + move16(); + + e_x = s_max( *p_sec_I_vec_x_exp, *p_sec_I_vec_smth_x_exp ); + e_y = s_max( *p_sec_I_vec_y_exp, *p_sec_I_vec_smth_y_exp ); + e_z = s_max( *p_sec_I_vec_z_exp, *p_sec_I_vec_smth_z_exp ); + + tmp_1 = L_shr( *p_sec_I_vec_x_fx, sub( e_x, *p_sec_I_vec_x_exp ) ); // e_x + tmp_2 = L_shr( *p_sec_I_vec_y_fx, sub( e_y, *p_sec_I_vec_y_exp ) ); // e_y + tmp_3 = L_shr( *p_sec_I_vec_z_fx, sub( e_z, *p_sec_I_vec_z_exp ) ); // e_z + tmp_sec_1 = L_shr( *p_sec_I_vec_smth_x_fx, sub( e_x, *p_sec_I_vec_smth_x_exp ) ); // e_x + tmp_sec_2 = L_shr( *p_sec_I_vec_smth_y_fx, sub( e_y, *p_sec_I_vec_smth_y_exp ) ); // e_y + tmp_sec_3 = L_shr( *p_sec_I_vec_smth_z_fx, sub( e_z, *p_sec_I_vec_smth_z_exp ) ); // e_z + + + temp_x64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_1 ), beta_fx, tmp_sec_1 ); // 31-e_x+30+1=62-e_x + temp_y64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_2 ), beta_fx, tmp_sec_2 ); // 31-e_y+30+1=62-e_y + temp_z64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_3 ), beta_fx, tmp_sec_3 ); // 31-e_z+30+1=62-e_z + + tmp_scale = sub( W_norm( temp_x64 ), 32 ); + *p_sec_I_vec_smth_x_fx = W_shl_sat_l( temp_x64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_x_exp = sub( sub( e_x, 31 ), tmp_scale ); // 31-(62-e_x+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_x_fx == 0 ) + { + *p_sec_I_vec_smth_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( temp_y64 ), 32 ); + *p_sec_I_vec_smth_y_fx = W_shl_sat_l( temp_y64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_y_exp = sub( sub( e_y, 31 ), tmp_scale ); // 31-(62-e_z+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_y_fx == 0 ) + { + *p_sec_I_vec_smth_y_exp = 0; + move16(); + } + tmp_scale = sub( W_norm( temp_z64 ), 32 ); + *p_sec_I_vec_smth_z_fx = W_shl_sat_l( temp_z64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_z_exp = sub( sub( e_z, 31 ), tmp_scale ); // 31-(62-e_z+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_z_fx == 0 ) + { + *p_sec_I_vec_smth_z_exp = 0; + move16(); + } + + *p_energy_smth_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, energy_fx ), add( energy_exp, 1 ), Mpy_32_32( beta_fx, *p_energy_smth_fx ), add( *p_energy_smth_exp, 1 ), p_energy_smth_exp ); +#else *p_sec_I_vec_smth_x_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_x_fx ), add( *p_sec_I_vec_x_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_x_fx ), add( *p_sec_I_vec_smth_x_exp, 1 ), p_sec_I_vec_smth_x_exp ); move32(); *p_sec_I_vec_smth_y_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_y_fx ), add( *p_sec_I_vec_y_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_y_fx ), add( *p_sec_I_vec_smth_y_exp, 1 ), p_sec_I_vec_smth_y_exp ); @@ -1364,6 +1596,8 @@ void calculate_hodirac_sector_parameters_fx( *p_sec_I_vec_smth_z_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_z_fx ), add( *p_sec_I_vec_z_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_z_fx ), add( *p_sec_I_vec_smth_z_exp, 1 ), p_sec_I_vec_smth_z_exp ); move32(); *p_energy_smth_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, energy_fx ), add( energy_exp, 1 ), Mpy_32_32( beta_fx, *p_energy_smth_fx ), add( *p_energy_smth_exp, 1 ), p_energy_smth_exp ); +#endif + move32(); } IF( LT_32( energy_fx, EPSILON_FX_SMALL ) ) @@ -1406,7 +1640,7 @@ void calculate_hodirac_sector_parameters_fx( *p_ene_exp = *p_energy_smth_exp; move16(); - tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) ); + tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add_sat( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) ); tmp_e = add( tmp_e, sub( normI_exp, *p_energy_smth_exp ) ); tmp32 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( tmp32 ), tmp_e, &tmp_e ); *p_diff_fx = tmp32; @@ -1440,6 +1674,18 @@ void calculate_hodirac_sector_parameters_fx( } ELSE { +#ifdef OPT_SBA_ENC_V2_NBE + tmp32_1 = L_sub( ONE_IN_Q29, tmp_diff_fx ); + tmp32_2 = L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ); + + // *p_azi = 2.f * (1.f - tmp_diff) * *p_azi + (2.f * tmp_diff - 1.f) * *p_azi_prev + *p_azi_fx = L_shl( Madd_32_32( Mpy_32_32( tmp32_1, *p_azi_fx ), tmp32_2, *p_azi_prev_fx ), 3 ); // Q29 + Q23 - 31 + 2 = Q23 + move32(); + + // *p_ele = 2.f * (1.f - tmp_diff) * *p_ele + (2.f * tmp_diff - 1.f) * *p_ele_prev + *p_ele_fx = L_shl( Madd_32_32( Mpy_32_32( tmp32_1, *p_ele_fx ), tmp32_2, *p_ele_prev_fx ), 3 ); // Q29 + Q23 - 31 + 2 = Q23 + move32(); +#else *p_azi_fx = L_shl( L_add( Mpy_32_32( L_sub( ONE_IN_Q29, tmp_diff_fx ), *p_azi_fx ), Mpy_32_32( L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ), *p_azi_prev_fx ) ), 1 ); // Q29 + Q23 - 31 = Q21 move32(); *p_ele_fx = L_shl( L_add( Mpy_32_32( L_sub( ONE_IN_Q29, tmp_diff_fx ), *p_ele_fx ), Mpy_32_32( L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ), *p_ele_prev_fx ) ), 1 ); // Q29 + Q23 - 31 = Q21 @@ -1448,6 +1694,7 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_ele_fx = L_shl( *p_ele_fx, 2 ); // Q21 -> Q23; move32(); +#endif } } ELSE diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 0d8a74514326453362b8dc6ff4c2d0ace00929e0..c40f65ad64e59a00297eddb8372c5212a4df2b61 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -614,13 +614,21 @@ void ivas_fb_mixer_get_windowed_fr_fx( Word16 n_new_samples; Word32 fr_in_block_fx[L_FRAME48k * 2]; const Word16 *win_ptr_fx; - +#ifdef OPT_MCT_ENC_V1_BE + Word16 two_mdft_len = shl( mdft_len, 1 ); + Word16 tmp = sub( shl( mdft_len, 1 ), length ); + Word16 gb_neg = negate( gb ); + + n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), two_mdft_len ); + offset = sub( tmp, hFbMixer->ana_window_offset ); + rev_offset = sub( two_mdft_len, hFbMixer->ana_window_offset ); +#else n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), ( shl( mdft_len, 1 ) ) ); - n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) ); offset = sub( sub( shl( mdft_len, 1 ), length ), hFbMixer->ana_window_offset ); rev_offset = sub( shl( mdft_len, 1 ), hFbMixer->ana_window_offset ); +#endif set32_fx( fr_in_block_fx, 0, offset ); - + n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) ); FOR( ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) { Copy32( &hFbMixer->ppFilterbank_prior_input_fx[ch_idx][offset + hFbMixer->fb_cfg->windowed_fr_offset], &fr_in_block_fx[offset], sub( n_old_samples, offset ) ); // Qx @@ -628,25 +636,41 @@ void ivas_fb_mixer_get_windowed_fr_fx( win_ptr_fx = hFbMixer->pAna_window_fx; /*Q15*/ +#ifdef OPT_MCT_ENC_V1_BE + FOR( j = offset; j < tmp; j++ ) +#else FOR( j = offset; j < sub( shl( mdft_len, 1 ), length ); j++ ) +#endif { fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( win_ptr_fx++ ) ) ); // Qx + 15 - 15 = Qx move32(); } +#ifdef OPT_MCT_ENC_V1_BE + FOR( j = rev_offset; j < two_mdft_len; j++ ) +#else FOR( j = rev_offset; j < shl( mdft_len, 1 ); j++ ) +#endif { fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( --win_ptr_fx ) ) ); // Qx + 15 - 15 = Qx move32(); } +#ifdef OPT_MCT_ENC_V1_BE + scale_sig32( fr_in_block_fx, two_mdft_len, gb_neg ); +#else FOR( Word16 i = 0; i < shl( mdft_len, 1 ); i++ ) { fr_in_block_fx[i] = L_shr( fr_in_block_fx[i], gb ); // Qx - gb move32(); } +#endif +#ifdef OPT_MCT_ENC_V1_BE + ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], two_mdft_len, mdft_len ); +#else ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], shl( mdft_len, 1 ), mdft_len ); +#endif } return; diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index a691fb390380b8f2f12c1510fcf719432fc09d25..f4c8fab10d09d20b5591e2796305ac79a888ea38 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -978,7 +978,7 @@ static Word16 quantize_phi_masa_fx( Word32 tmp32; Word16 tmp_e, delta_phi_e; - delta_phi_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( 360, n, &delta_phi_e ) ); + delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( 360, n, &delta_phi_e ); delta_phi_fx = L_shr( delta_phi_fx, sub( sub( 31, delta_phi_e ), 22 ) ); // Q22 IF( EQ_16( n, 1 ) ) @@ -1000,8 +1000,8 @@ static Word16 quantize_phi_masa_fx( } tmp32 = L_add( L_sub( phi_fx, dd_fx ), L_shr( delta_phi_fx, 1 ) ); - id_phi = BASOP_Util_Divide3232_Scale( tmp32, delta_phi_fx, &tmp_e ); - id_phi = shr( id_phi, sub( 15, tmp_e ) ); // Q0 + tmp32 = BASOP_Util_Divide3232_Scale_newton( tmp32, delta_phi_fx, &tmp_e ); + id_phi = extract_l( L_shr( tmp32, sub( 31, tmp_e ) ) ); // Q0 if ( EQ_16( id_phi, n ) ) { @@ -1014,7 +1014,10 @@ static Word16 quantize_phi_masa_fx( id_phi = sub( n, 1 ); } - *phi_hat_fx = L_add( L_shl( Mpy_32_16_1( delta_phi_fx, id_phi ), 15 ), dd_fx ); // q22 + q0 - 15 = q7 -> q7 + 15 = q22 + delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( L_mult0( 360, id_phi ), n, &delta_phi_e ); + delta_phi_fx = L_shr( delta_phi_fx, sub( sub( 31, delta_phi_e ), 22 ) ); // Q22 + + *phi_hat_fx = L_add( delta_phi_fx, dd_fx ); // Q22 move32(); return id_phi; // Q0 diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 2d5bf9cd6f7564e5973028b39bb1c5c75364af95..510a9067de037845973169a4986c25fb273a14cf 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1095,10 +1095,14 @@ void ivas_mct_dec_mct_fx( ); void apply_MCT_dec_fx( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */ - Word16 q_x[MCT_MAX_CHANNELS] ); + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + Decoder_State **sts, /* i/o: decoder state structure */ + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +); void mctStereoIGF_dec_fx( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ @@ -1132,9 +1136,13 @@ void stereo_decoder_tcx_fx( const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ const Word16 last_core_l, /* i : last core for left channel */ const Word16 last_core_r, /* i : last core for right channel */ - const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision */ + const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision */ +#ifndef OPT_SBA_DEC_PATH + , Word16 *q_x_ch2, - Word16 *q_x_ch1 ); + Word16 *q_x_ch1 +#endif /* OPT_SBA_DEC_PATH */ +); void v_multc_acc_32_16( const Word32 x[], /* i : Input vector */ @@ -1571,7 +1579,12 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - Word16 x_e[CPE_CHANNELS][NB_DIV] ); +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e +#else /* OPT_SBA_DEC_V2_NBE */ + Word16 x_e[CPE_CHANNELS][NB_DIV] +#endif /* OPT_SBA_DEC_V2_NBE */ +); void decoder_tcx_imdct_fx( Decoder_State *st, /* i/o: coder memory state */ @@ -1586,7 +1599,12 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], Word16 q_x, Word16 xn_buf_fx[], +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_win, + Word16 *q_winFB, +#else Word16 q_win, +#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], /* i/o: synth[-M..L_frame] */ @@ -1932,9 +1950,17 @@ void ivas_mdct_core_invQ_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_0_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_0_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV], Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ @@ -5015,14 +5041,12 @@ void ivas_dirac_dec_get_response_fx( const Word16 ambisonics_order, Word16 Q_out ); -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/ void ivas_dirac_dec_get_response_fx_29( const Word16 azimuth, const Word16 elevation, Word32 *response_fx, /*Q_out=29*/ const Word16 ambisonics_order ); -#endif void calculate_hodirac_sector_parameters_fx( DIRAC_ENC_HANDLE hDirAC, /* i : DirAC handle */ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 3d85f546fbacfa27d4a608ae65b25255af0c5b8e..e3ee71ac97c59e6cd2786c312afe64fa53385f6c 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -483,20 +483,8 @@ const Word32 dft_res_gains_q_fx[][2] = { }; -// Q13 -const Word16 McMASA_LFEGain_vectors_fx_q13[64] = { - 3112, 2703, 1556, 1638, -1310, -1802, -2867, -2785, - 4096, 4096, 4096, 4096, -6553, -3276, 8355, 819, - -4096, -4096, -4096, -4096, -4587, -983, -6389, 11141, - -8355, 9666, -4669, 2703, 5898, -9256, 7946, -5079, - -7454, 7618, 8192, -9011, 14172, -1884, -6389, -6881, - 7782, -13107, -2785, 7618, 7127, 3850, -15564, 4259, - 5488, 11632, -7946, -10158, 6799, 4751, 4997, -16711, - -6553, -12943, 6717, 11632, -17530, 2129, 6881, 8355 -}; - // Q25 -const Word32 McMASA_LFEGain_vectors_fx_q25[64] = { +const Word32 McMASA_LFEGain_vectors_fx[64] = { 12750684, 11072963, 6375342, 6710886, /* 1st bit */ -5368709, -7381975, -11744051, -11408507, 16777216, 16777216, 16777216, 16777216, /* 2nd bit*/ @@ -1545,19 +1533,6 @@ const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] = { /* from 1 to 11 bits*/ /*q factor = 8*/ const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = { -#ifndef FIX_1379_MASA_ANGLE_ROUND - { 1073741824 }, - { 536870912 }, - { 536870912, 1073741824 }, - { 268435456, 536870912 }, - { 178956970, 306783378, 1073741824, 2147483647 }, - { 153391689, 165191049, 238609294, 1073741824, 2147483647 }, - { 97612893, 102261126, 126322567, 195225786, 715827882, 2147483647 }, - { 65075262, 67108864, 74051160, 93368854, 126322567, 238609294, 2147483647 }, - { 44739242, 45691141, 47721858, 52377649, 61356675, 76695844, 107374182, 178956970, 1073741824, 2147483647 }, - { 35791394, 35791394, 37025580, 38347922, 39768215, 42949672, 46684427, 52377649, 59652323, 71582788, 93368854, 126322567, 214748364, 2147483647 }, - { 24129029, 24129029, 24403223, 24970740, 25565281, 26512143, 27889398, 29417584, 31580641, 34087042, 37675151, 42107522, 48806446, 56512727, 71582788, 93368854, 143165576, 268435456, 2147483647 } -#else { 1073741824 }, { 536870912 }, { 536870912, 1073741824 }, @@ -1569,7 +1544,6 @@ const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = { { 44739243, 45691141, 47721859, 52377650, 61356676, 76695845, 107374182, 178956971, 1073741824, 2147483647 }, { 35791394, 35791394, 37025580, 38347922, 39768216, 42949673, 46684427, 52377650, 59652324, 71582788, 93368854, 126322568, 214748365, 2147483647 }, { 24129030, 24129030, 24403223, 24970740, 25565282, 26512144, 27889398, 29417584, 31580642, 34087042, 37675152, 42107523, 48806447, 56512728, 71582788, 93368854, 143165577, 268435456, 2147483647 }, -#endif }; diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h index 54a620b154dc0410d69c1bb5ef3befe6dfc97d75..04a86ed5b01418904cd870d1b1701f56e8f59c2c 100644 --- a/lib_com/ivas_rom_com_fx.h +++ b/lib_com/ivas_rom_com_fx.h @@ -56,8 +56,7 @@ extern const Word16 dft_trigo_12k8_fx[STEREO_DFT_N_12k8_ENC / 4 + 1]; extern const Word16 dft_trigo_32k_fx[STEREO_DFT_N_32k_ENC / 4 + 1]; extern const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1]; extern const Word16 gridEq_Table[NO_THETA16_MAX]; -extern const Word16 McMASA_LFEGain_vectors_fx_q13[64]; -extern const Word32 McMASA_LFEGain_vectors_fx_q25[64]; +extern const Word32 McMASA_LFEGain_vectors_fx[64]; /* Q25 */ extern const Word16 ivas_divde_255[256]; diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index f1e44be78bdfea1016e77b24dd00e2433ca3d2cb..1a0219b2523b6ad44888add522e8a7d116343269 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -376,12 +376,14 @@ void sns_shape_spectrum_fx( { L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1 move64(); +#ifndef OPT_MCT_ENC_V3_NBE shift = W_norm( L64_tmp[k] ); if ( LT_16( shift, min_shift ) ) { min_shift = shift; move16(); } +#endif } } tmp_k = k; @@ -391,18 +393,29 @@ void sns_shape_spectrum_fx( *length = k; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + min_shift = W_norm_arr( L64_tmp, k ); +#endif q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 ); if ( GT_16( q_tmp, 30 ) ) { q_tmp = 30; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + shift = sub( q_tmp, add( *q_spectrum, q_scf_int ) ); + FOR( k = 0; k < tmp_k; k++ ) + { + spectrum[k] = W_shl_sat_l( L64_tmp[k], shift ); // q_tmp+1 + move32(); +#else FOR( k = 0; k < tmp_k; k++ ) { L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) ); // Q = q_tmp+1 move64(); spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp+1 move64(); +#endif } *q_spectrum = q_tmp; move16(); @@ -418,6 +431,7 @@ void sns_shape_spectrum_fx( { L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1 move64(); +#ifndef OPT_MCT_ENC_V3_NBE shift = W_norm( L64_tmp[k] ); test(); if ( LT_16( shift, min_shift ) && NE_64( L64_tmp[k], 0 ) ) @@ -425,6 +439,7 @@ void sns_shape_spectrum_fx( min_shift = shift; move16(); } +#endif } } tmp_k = k; @@ -434,18 +449,29 @@ void sns_shape_spectrum_fx( *length = k; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + min_shift = W_norm_arr( L64_tmp, k ); +#endif q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 ); if ( GT_16( q_tmp, 30 ) ) { q_tmp = 30; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + shift = sub( q_tmp, add( *q_spectrum, q_scf_int ) ); + FOR( k = 0; k < tmp_k; k++ ) + { + spectrum[k] = W_shl_sat_l( L64_tmp[k], shift ); // q_tmp+1 + move32(); +#else FOR( k = 0; k < tmp_k; k++ ) { L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) ); // q_tmp+1 move64(); spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp+1 move64(); +#endif } *q_spectrum = q_tmp; move16(); diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index ef549a2ae42ad2dfa3389548201920751d2a74e4..361215e221087eb26272647ecb88781b4ff73081 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -2361,18 +2361,30 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( Word32 re1, re2; W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ pSparMd->band_coeffs[b_ts_idx].q_C_re_fx*/ +#ifdef OPT_SBA_ENC_V2_BE + q_tmp1 = sub( W_norm( W_tmp ), 32 ); + re1 = W_shl_sat_l( W_tmp, q_tmp1 ); /*q_cov_dd_re+ q_C_re+q_tmp1*/ + q_tmp1 = add( add( q_C_re, q_tmp1 ), q_cov_dd_re ); +#else q_tmp1 = W_norm( W_tmp ); re1 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); /*q_cov_dd_re+ q_C_re+q_tmp1-32*/ q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp1 = 31; move16(); } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ q_C_re*/ +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 32 ); + re2 = W_shl_sat_l( W_tmp, q_tmp ); /*q_cov_dd_re+ q_C_re+q_tmp*/ + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = W_norm( W_tmp ); re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); /*q_cov_dd_re+ q_C_re+q_tmp-32*/ q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2380,12 +2392,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1 ); // q_tmp1+q_C_re +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[0][0] = W_shl_sat_l( W_tmp, q_factor ); // q_tmp1+q_C_re+q_recon_uu_re[0][0] + move32(); + q_recon_uu_re[0][0] = add( add( q_C_re, q_factor ), q_tmp1 ); + move16(); +#else q_recon_uu_re[0][0] = W_norm( W_tmp ); move16(); recon_uu_re[0][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][0] ) ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]-32 move32(); q_recon_uu_re[0][0] = sub( add( add( q_C_re, q_recon_uu_re[0][0] ), q_tmp1 ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[0][0] = 31; @@ -2393,12 +2413,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ); // q_C_re+q_tmp1 +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[0][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp1+q_recon_uu_re[0][1] + move32(); + q_recon_uu_re[0][1] = add( add( q_C_re, q_factor ), q_tmp1 ); + move16(); +#else q_recon_uu_re[0][1] = W_norm( W_tmp ); move16(); recon_uu_re[0][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][1] ) ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]-32 move32(); q_recon_uu_re[0][1] = sub( add( add( q_C_re, q_recon_uu_re[0][1] ), q_tmp1 ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[0][1] = 31; @@ -2406,12 +2434,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ); // q_C_re+q_tmp +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[1][0] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][0] + move32(); + q_recon_uu_re[1][0] = add( add( q_C_re, q_factor ), q_tmp ); + move16(); +#else q_recon_uu_re[1][0] = W_norm( W_tmp ); move16(); recon_uu_re[1][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][0] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][0]-32 move32(); q_recon_uu_re[1][0] = sub( add( add( q_C_re, q_recon_uu_re[1][0] ), q_tmp ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[1][0] = 31; @@ -2419,12 +2455,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ); // q_C_re+q_tmp +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[1][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][1] + move32(); + q_recon_uu_re[1][1] = add( add( q_C_re, q_factor ), q_tmp ); + move16(); +#else q_recon_uu_re[1][1] = W_norm( W_tmp ); move16(); recon_uu_re[1][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][1] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][1]-32 move32(); q_recon_uu_re[1][1] = sub( add( add( q_C_re, q_recon_uu_re[1][1] ), q_tmp ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[1][1] = 31; @@ -2441,12 +2485,18 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } } q_tmp = sub( s_min( q_tmp, q_cov_uu_re ), 1 ); - +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( q_cov_uu_re, q_tmp ); +#endif FOR( i = 0; i < 2; i++ ) { FOR( j = 0; j < 2; j++ ) { +#ifdef OPT_SBA_ENC_V2_BE + cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], q_factor ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp +#else cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], sub( q_cov_uu_re, q_tmp ) ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp +#endif move32(); } } @@ -2466,9 +2516,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( { Word32 re; W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ); // q_C_re+q_cov_dd_re +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 33 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = sub( W_norm( W_tmp ), 1 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2492,9 +2548,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ); // q_C_re+q_re1[0] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 33 ); + re2 = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[0]+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_re1[0] ); +#else q_tmp = sub( W_norm( W_tmp ), 1 ); re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[0]+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[0] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2504,9 +2566,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( move32(); W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ); // q_C_re+q_re1[1] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp1 = sub( W_norm( W_tmp ), 33 ); + re2 = W_shl_sat_l( W_tmp, q_tmp1 ); // q_C_re+q_re1[1]+q_tmp1 + q_tmp1 = add( add( q_C_re, q_tmp1 ), q_re1[1] ); +#else q_tmp1 = sub( W_norm( W_tmp ), 1 ); re2 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); // q_C_re+q_re1[1]+q_tmp1-32 q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_re1[1] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp1 = 31; @@ -2585,9 +2653,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( FOR( k = 0; k < num_dmx - 1; k++ ) { W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ); // q_C_re+q_cov_dd_re +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 34 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = sub( W_norm( W_tmp ), 2 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2627,9 +2701,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( FOR( m = 0; m < num_dmx - 1; m++ ) { W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ); // q_C_re+q_re1[m] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 34 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[m]+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_re1[m] ); +#else q_tmp = sub( W_norm( W_tmp ), 2 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[m]+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[m] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2714,9 +2794,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( move16(); IF( trace != 0 ) { +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( trace ), 32 ); + tmp = Mpy_32_32( p_norm_scaling, W_shl_sat_l( trace, q_factor ) ); // q_cov_uu_re+q_factor + q_factor = add( q_cov_uu_re, q_factor ); +#else q_factor = W_norm( trace ); tmp = Mpy_32_32( p_norm_scaling, W_extract_h( W_shl( trace, q_factor ) ) ); // q_cov_uu_re+q_factor-32 q_factor = sub( add( q_cov_uu_re, q_factor ), 32 ); +#endif IF( GT_16( q_factor, q_postpred_cov_re ) ) { tmp = L_shr( tmp, sub( q_factor, q_postpred_cov_re ) ); // q_postpred_cov_re @@ -3931,7 +4017,12 @@ void ivas_compute_spar_params_fx( Word32 diff_norm_order1_table[4] = { 0, 805306368, 402653184, 268435456 }; // q28 Word32 diff_norm_order2_table[6] = { 0, 1342177280, 671088640, 447392416, 335544320, 268435456 }; // q28 Word32 diff_norm_order3_table[8] = { 0, 1879048192, 939524096, 626349376, 469762048, 375809632, 313174688, 268435456 }; // q28 -#define EPSILON_FX_THR 70 +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT +#define EPSILON_FX_SHIFT 6 +#define EPSILON_FX_THR ( 1 << EPSILON_FX_SHIFT ) +#else +#define EPSILON_FX_THR 70 +#endif #define ONE_BY_THREE_Q31 715827882 #define ONE_BY_FIVE_Q31 429496729 #define ONE_BY_SEVEN_Q31 306783378 @@ -4171,10 +4262,20 @@ void ivas_get_spar_md_from_dirac_enc_fx( { Word32 norm_fx; Word16 norm_q; + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + Word16 num_ch_order, norm_t; + Word32 tmp_norm_out; +#else Word16 num_ch_order, hoa2_ch_order; +#endif num_ch_order = ivas_sba_get_nchan_fx( order, 0 ); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 ); +#else + assert( order == 1 ); +#endif FOR( ch = 0; ch < num_ch_order; ch++ ) { @@ -4189,16 +4290,26 @@ void ivas_get_spar_md_from_dirac_enc_fx( } /*normalize 1st order*/ +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); + norm_t = sub( norm_t, 1 ); + scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); +#endif norm_fx = 0; move32(); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT norm_q = 0; move16(); +#endif FOR( ch = 1; ch < foa_ch; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) ); +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q +#else IF( norm_fx ) { norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q @@ -4208,6 +4319,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( norm_fx = EPSILON_FX; move32(); } +#endif IF( norm_q <= 0 ) { norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31 @@ -4215,6 +4327,27 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + IF( LT_32( norm_fx, EPSILON_FX_THR ) ) + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ + response_avg_fx[ch] = L_shl( response_avg_fx[ch], Q30 - EPSILON_FX_SHIFT ); // q30 + move32(); + } + } + ELSE + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + tmp_norm_out = divide3232( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ) ); // q15 + response_avg_fx[ch] = L_shl( tmp_norm_out, 15 ); // q30 + move32(); + } + } +#else FOR( ch = 1; ch < foa_ch; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) @@ -4240,6 +4373,9 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } +#endif + +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT /*normalize 2nd order*/ norm_fx = 0; @@ -4340,6 +4476,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } +#endif } } @@ -4729,10 +4866,19 @@ void ivas_get_spar_md_from_dirac_fx( { Word32 norm_fx; Word16 norm_q; +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + Word16 num_ch_order, norm_t; + Word32 tmp_norm_out; +#else Word16 num_ch_order, hoa2_ch_order; +#endif num_ch_order = ivas_sba_get_nchan_fx( order, 0 ); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 ); +#else + assert( order == 1 ); +#endif FOR( ch = 0; ch < num_ch_order; ch++ ) { @@ -4747,16 +4893,27 @@ void ivas_get_spar_md_from_dirac_fx( } /*normalize 1st order*/ +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); + norm_t = sub( norm_t, 1 ); + scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); +#endif norm_fx = 0; move32(); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT norm_q = 0; move16(); +#endif FOR( ch = 1; ch < foa_ch; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) ); + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q +#else IF( norm_fx ) { norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q @@ -4766,6 +4923,8 @@ void ivas_get_spar_md_from_dirac_fx( norm_fx = EPSILON_FX; move32(); } +#endif + IF( norm_q <= 0 ) { norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31 @@ -4773,6 +4932,27 @@ void ivas_get_spar_md_from_dirac_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + IF( LT_32( norm_fx, EPSILON_FX_THR ) ) + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ + response_avg_fx[ch] = L_shl( response_avg_fx[ch], Q30 - EPSILON_FX_SHIFT ); // q30 + move32(); + } + } + ELSE + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + tmp_norm_out = divide3232( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ) ); // q15 + response_avg_fx[ch] = L_shl( tmp_norm_out, 15 ); // q30 + move32(); + } + } +#else FOR( ch = 1; ch < foa_ch; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) @@ -4798,7 +4978,9 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } +#endif +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT /*normalize 2nd order*/ norm_fx = 0; move32(); @@ -4898,6 +5080,7 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } +#endif } } @@ -7201,7 +7384,6 @@ void ivas_dirac_dec_get_response_fx( return; } -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/ void ivas_dirac_dec_get_response_fx_29( const Word16 azimuth, @@ -7327,7 +7509,6 @@ void ivas_dirac_dec_get_response_fx_29( } return; } -#endif /*FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx*/ /*-----------------------------------------------------------------------------------------* * Function ivas_get_bits_to_encode * diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index ca8dec27615addfd578de77e9464538d8f21d519..a1b484f6db3d0b97aa836ee217f5c7cfeec73d16 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -606,7 +606,9 @@ Word64 dot_product_cholesky_fixed( { Word16 i, j; Word64 suma, tmp_sum; +#ifndef OPT_MCT_ENC_V3_BE Word32 mul; +#endif Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; @@ -621,12 +623,20 @@ Word64 dot_product_cholesky_fixed( FOR( j = 0; j <= i; j++ ) { +#ifdef OPT_MCT_ENC_V3_BE + tmp_sum = W_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); +#else mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); +#endif } +#ifdef OPT_MCT_ENC_V3_BE + tmp = W_shl_sat_l( tmp_sum, -4 ); // to make sure that the tmp_sum will not overflow +#else tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); +#endif suma = W_mac_32_32( suma, tmp, tmp ); } @@ -1955,7 +1965,11 @@ void v_multc_acc_32_16( FOR( i = 0; i < N; i++ ) { +#ifdef OPT_MCT_ENC_V1_BE + y[i] = Madd_32_16( y[i], x[i], c ); +#else y[i] = L_add( y[i], Mpy_32_16_1( x[i], c ) ); +#endif move32(); } @@ -1972,7 +1986,11 @@ void v_multc_acc_32_32( FOR( i = 0; i < N; i++ ) { +#ifdef OPT_MCT_ENC_V1_BE + y[i] = Madd_32_32( y[i], x[i], c ); /*Qx*/ +#else y[i] = L_add( y[i], Mpy_32_32( x[i], c ) ); /*Qx*/ +#endif move32(); } diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index fb8679ebc8e218ddcf1ce12ad0bcc59dcc899a35..39dee9314d95f5acf0175589995418fc9918d52f 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -292,7 +292,7 @@ void ivas_transient_det_process_fx( ) { Word32 in_duck_gain[L_FRAME48k]; - Word16 num_sf, sf, sf_samp, idx; + Word16 num_sf, sf, sf_samp, idx, num_sf_log2; Word32 mem = hTranDet->in_duck_gain; /*Q30*/ move32(); @@ -309,7 +309,9 @@ void ivas_transient_det_process_fx( num_sf = 16; /*Q0*/ move16(); - sf_samp = idiv1616( frame_len, num_sf ); /*Q0*/ + num_sf_log2 = 4; /* To be used for shift operation instead of division */ + move16(); + sf_samp = shr( frame_len, num_sf_log2 ); /*Q0*/ FOR( sf = 1; sf <= num_sf; sf++ ) { idx = sub( imult1616( sf_samp, sf ), 1 ); diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index e51d2807b10162a20e29b17dca29ab55a8e7c13a..1860744457d8d605bd2422dc59753c169e00758b 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -96,8 +96,12 @@ void ivas_fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ +#ifdef ISSUE_1772_replace_shr_o + tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ +#else tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ +#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ @@ -204,8 +208,12 @@ void fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ +#ifdef ISSUE_1772_replace_shr_o + tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ +#else tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ +#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 2e39af523138f176abf849628d6f8ea46e6b6a29..46e24e31af8d899d10a3cd489e1ab217bcd3d7b1 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -1059,7 +1059,6 @@ void Decimate_allpass_steep_fx32( /* upper allpass filter chain */ FOR( k = 0; k < N / 2; k++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx move32(); mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx @@ -1074,118 +1073,51 @@ void Decimate_allpass_steep_fx32( move32(); mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx - move32(); - mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx - move32(); - - temp[1] = L_add( mem[1], Mpy_32_16_1( temp[0], AP1_STEEP_FX[1] ) ); // Qx - move32(); - mem[1] = L_sub( temp[0], Mpy_32_16_1( temp[1], AP1_STEEP_FX[1] ) ); // Qx - move32(); - - out[k] = L_add( mem[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* lower allpass filter chain */ -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx - move32(); - /*if ( fabs( temp[n] ) < 1e-12 ) - { - temp[n] = sign( temp[n] ) * 1e-12f; - }*/ - mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - - mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); FOR( k = 1; k < N / 2; k++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx - move32(); - /*if ( fabs( temp[n] ) < 1e-12 ) - { - temp[n] = sign( temp[n] ) * 1e-12f; - }*/ - mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); } @@ -1487,21 +1419,12 @@ void interpolate_3_over_2_allpass_fx32( FOR( i = 0; i < len; i++ ) { /* Upper branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx move32(); Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx move32(); mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[1] = Vu[0]; // Qx move32(); @@ -1511,21 +1434,12 @@ void interpolate_3_over_2_allpass_fx32( move32(); /* Middle branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx move32(); Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx move32(); mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[4] = Vm[0]; // Qx move32(); @@ -1535,21 +1449,12 @@ void interpolate_3_over_2_allpass_fx32( move32(); /* Lower branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx move32(); Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx move32(); mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[0] = input[i]; // Qx move32(); @@ -1568,17 +1473,10 @@ void interpolate_3_over_2_allpass_fx32( { mem_temp = out1_buff[2 * i]; move32(); -#ifdef OPT_STEREO_32KBPS_V1 out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 ); // 0.614152f in Q15 -> 20125 -#else /* OPT_STEREO_32KBPS_V1 */ - out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx - // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 - out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) ); - // 0.614152f in Q15 -> 20125 -#endif /* OPT_STEREO_32KBPS_V1 */ mem[10] = mem[11]; // Qx move32(); mem[11] = mem[12]; // Qx @@ -1861,8 +1759,8 @@ void interpolate_3_over_1_allpass_fx32( { mem_temp = out[i]; // Qx move32(); - out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2424 ) ); // Qx - // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2424 + out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2425 ) ); // Qx + // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2425 move32(); mem[10] = mem[11]; // Qx move32(); diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 8d5e8adf2c394a7799a75085ccaff97cf9b698e9..bbca861591070cc59549d592ad221314cc7ebfd9 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -126,13 +126,10 @@ void init_lvq_fx( ) { Word16 i, j; -#ifdef OPT_STEREO_32KBPS_V1 Word16 k; -#endif /* OPT_STEREO_32KBPS_V1 */ /* safety-net mode */ FOR( i = 0; i < MAX_NO_MODES; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ ) { if ( no_lead_fx[i][j] > 0 ) @@ -162,31 +159,10 @@ void init_lvq_fx( } no_scales[i][1] = k; move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - j = 0; - move16(); - test(); - WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_fx[i][j] > 0 ) ) - { - j++; - } - no_scales[i][0] = j; - move16(); - j = MAX_NO_SCALES; - move16(); - test(); - WHILE( ( LT_16( j, shl( MAX_NO_SCALES, 1 ) ) ) && ( no_lead_fx[i][j] > 0 ) ) - { - j++; - } - no_scales[i][1] = sub( j, MAX_NO_SCALES ); - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* predictive mode */ FOR( i = 0; i < MAX_NO_MODES_p; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ ) { if ( no_lead_p_fx[i][j] > 0 ) @@ -218,26 +194,6 @@ void init_lvq_fx( no_scales_p[i][1] = k; move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - j = 0; - move16(); - WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_p_fx[i][j] > 0 ) ) - { - test(); - j++; - } - no_scales_p[i][0] = j; - move16(); - j = MAX_NO_SCALES; - move16(); - WHILE( ( LT_16( j, shl( MAX_NO_SCALES, 1 ) ) ) && ( no_lead_p_fx[i][j] > 0 ) ) - { - test(); - j++; - } - no_scales_p[i][1] = sub( j, MAX_NO_SCALES ); - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* index offsets for each truncation */ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p ); diff --git a/lib_com/options.h b/lib_com/options.h index 32c53988aa4942a91bd1aac6f5a72f183a24cbad..929ae2b05d72c8b69d4afd8116cb90f16d6346ae 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -50,6 +50,7 @@ /*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ #define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ +/*#define DEBUG_MODE_JBM */ /* define to output JBM relevant parameters */ #endif #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ @@ -62,58 +63,91 @@ /*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif +/*#define DISABLE_LIMITER*/ + /* #################### End DEBUGGING switches ############################ */ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif +#define FIX_732_MS_PERIODOG_FLOOR /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */ #define FIX_867_CLDFB_NRG_SCALE +#define FIX_1737_FIX_867_CLDFB_NRG_SCALE +#define FIX_1737_proto_fac_overflow -#define FIX_1378_ACELP_OUT_OF_BOUNDS -#define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V3_BE +#define OPT_MCT_ENC_V3_NBE +#define OPT_MCT_ENC_V2_BE +#define OPT_BIN_REND_V2_NBE +#define OPT_MCH_DEC_V1_NBE +#define OPT_MASA_DEC_V1_NBE +#define OPT_MASA_DEC_V2_NBE +#define OPT_MCT_ENC_48KB_NBE +#define OPT_MCH_DEC_V1_BE +#define OPT_MCT_ENC_V2_NBE +#define OPT_SBA_DEC_V2_NBE +#define OPT_MCT_ENC_V1_NBE +#define OPT_MCT_ENC_V1_BE #define OPT_SBA_REND_V1_BE #define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_DEC_V2_BE +#define OPT_SBA_ENC_V2_BE +#define OPT_SBA_ENC_V2_NBE #define OPT_SBA_ENC_V1_BE -#define OPT_BIN_RENDERER_V1 -#define OPT_BIN_RENDERER_V2 -#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ +#define OPT_SBA_DEC_PATH /* Optimization made in SBA decoding path */ +#define OPT_IVAS_FILTER_ROM /* Optimization made in IVAS filter table */ /* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ -#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ //#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define HARM_PUSH_BIT -#define HARM_ENC_INIT //#define HARM_SCE_INIT -#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ -#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ #define MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of dmx calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Requires MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE /* FhG: reduce WMOPS by inlining the matrix multiplications for the smoothing operation. */ -#define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic /*FhG: reduces maintenance complexity & reduces WMOPS & prepares STAGE2 patch*/ -#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/ -#define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ -#define VEC_ARITH_OPT_v1 -#define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ -#define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ - -#define TEST_HR -#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ - -#define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ + + +#define FIX_1348_BIT_PRECISION_IMPROVEMENT +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + +#define FIX_1802 + #define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */ -#define FIX_1733_CLDFB_BUG #define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ +#define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */ +#define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */ +#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ + +#define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ +#define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ +#define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ +#define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ + +#define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ +#define FIX_ISSUE_1792 /* FhG: fix noise bursts in binaural rendering */ + +/* Info for issue 1816: + * Some compilers do not automatically use 32 bit for 16x16bit products. The code "Word32 c = (Word16) a * (Word16) b;" creates then a 16-bit result, sign-extending the + * lower 16-bit of the product, any upper bits are omitted. Example: Product 0x0100 * 0x0100 results in 0x0001.0000, gets truncated to its lower bits and return 0x0000. + * The issue is fixed by simply casting one of the product operands to Word32 in lib_com/basop32.c + */ +#define FIX_ISSUE_1816_USE_W32_FOR_MPY_W16xW16 /* FhG: (QA-FIX) Use doubled data width for 16x16 product, some compilers keep 16-bit format also for products */ +#define FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION /* FhG: (NON-BE) improve precision of multiplications with factor 0.1f, avoids overflow with up-rounded value */ + +#define FIX_ISSUE_1795_Q3_OVERFLOW /* FhG: Q3 overflow in function WB_BWE_gain_pred_fx (EVS legacy code) BE, MR1855 */ +#define NONBE_FIX_1748_SPAR_DIV_OPT /*Dlb: issue 1748: SPAR common div optimizations*/ + +#define FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION /* FhG: Fixed getScalefactor usage */ + +#define FIX_1818_WRONG_PIT_INIT /* VA: Fix wrong pitch initialization */ + +#define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ + +#define FIX_1824 +#define FIX_1822 + /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6784d86870099ab19dd27a929158939c8ad62c6a..12459249b73798862b92d1a89755f617bf5cc742 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3220,11 +3220,8 @@ void interp_code_4over2_fx( void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_lsyn_filt_dwn_shb[], Word16 state_32and48k_WB_upsample[], Word16 state_resamp_HB[] ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic void elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 const Word16 element_mode, -#endif Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ Word16 *Q_input_fx, @@ -3233,16 +3230,6 @@ void elliptic_bpf_48k_generic_fx( Word16 memory_fx_Q[], const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ ); -#else -void elliptic_bpf_48k_generic_fx( - const Word16 input_fx[], /* i : i signal Q_input_fx */ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ -); -#endif void synthesise_fb_high_band_fx( const Word16 excitation_in[], /* i : full band excitation */ @@ -3255,12 +3242,8 @@ void synthesise_fb_high_band_fx( Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], - Word16 Qout -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 - , - Word16 element_mode -#endif -); + Word16 Qout, + Word16 element_mode ); void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ @@ -6026,14 +6009,12 @@ void v_add_fixed( const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ ); -#ifdef VEC_ARITH_OPT_v1 void v_add_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ const Word16 N /* i : Vector length */ ); -#endif /* VEC_ARITH_OPT_v1 */ void v_add_fixed_me( const Word32 x1[], /* i : Input vector 1 */ @@ -6069,14 +6050,12 @@ void v_sub_fixed( const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ ); -#ifdef VEC_ARITH_OPT_v1 void v_sub_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ const Word16 N /* i : Vector length */ ); -#endif /* VEC_ARITH_OPT_v1 */ /*! r: dot product of x[] and y[] */ Word32 dotp_fixed( @@ -6431,9 +6410,13 @@ void TonalMDCTConceal_Apply( ); void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 mdctSpectrum_exp, /*IN */ +#else /* OPT_SBA_DEC_V2_NBE */ Word16 mdctSpectrum_exp[L_FRAME48k], /*IN */ +#endif /* OPT_SBA_DEC_V2_NBE */ const PsychoacousticParameters *psychParamsCurrent ); void TonalMDCTConceal_InsertNoise_ivas_fx( @@ -9378,14 +9361,12 @@ void cldfbAnalysis_ivas_fx( ); void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE - const Word16 out_shift, /* i : scale for output buffer */ -#endif + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ); @@ -9464,9 +9445,19 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T void IMDCT_ivas_fx( Word32 *x_fx, Word16 q_x, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, +#else + Word16 *old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, +#endif Word16 *xn_buf_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_xn_buf_fx, +#endif const Word16 *tcx_aldo_window_1_fx, const PWord16 *tcx_aldo_window_1_trunc_fx, const PWord16 *tcx_aldo_window_2_fx, @@ -9487,11 +9478,19 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Word16 *q_old_out_fx, +#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_acelp_zir_fx, + Word16 *pq_win ); +#else Word16 q_win ); +#endif void v_mult16_fixed( const Word16 x1[], /* i : Input vector 1 */ @@ -10659,31 +10658,27 @@ ivas_error config_acelp1_fx( const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) #define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( -#endif -#ifdef DBG_BITSTREAM_ANALYSIS - const char *caller, #endif BSTR_ENC_HANDLE hBstr, UWord16 value, /* i : value of the quantized indice */ Word16 nb_bits /* i : number of bits used to quantize the indice */ ); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( -#endif -#ifdef DBG_BITSTREAM_ANALYSIS - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ @@ -11001,7 +10996,7 @@ ivas_error push_indice( ); ivas_error push_next_indice_( -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, @@ -11010,7 +11005,7 @@ ivas_error push_next_indice_( ); ivas_error push_next_bits_( -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 32d18d1feb543401666d751fb554240dce4e8e6f..91d0ee30a04a5f639a529a20a93d77453acd8e49 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -156,7 +156,7 @@ void Residu3_fx( move16(); #endif q = add( norm_s( a[0] ), 1 ); - IF( shift != 0 ) + if ( shift != 0 ) { q = add( q, shift ); } diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 5d0a7f303652b706a4272935b7ae5e66adfc8827..b10f5cc52ddec87091b7b41c061229e235af6fb8 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1273,28 +1273,6 @@ const Word16 sin_table256_fx[] = * 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2) *----------------------------------------------------------------------------------*/ - -const Word16 inter4_2_fx_Q15[65] = -{//Q15 - 30801, - 28062, 20718, 11061, 1935, - -4294, -6533, -5195, -1846, - 1559, 3497, 3398, 1705, - -497, -2087, -2413, -1523, - -32, 1252, 1741, 1312, - 305, -710, -1237, -1087, - -426, 350, 848, 862, - 452, -119, -550, -650, - -418, -17, 330, 462, - 349, 85, -175, -306, - -265, -104, 76, 184, - 182, 93, -20, -98, - -110, -66, -3, 43, - 55, 37, 8, -13, - -20, -14, -4, 2, - 3, 1, 0, 0, -}; - const Word16 inter4_2_fx[] = {//evs table , some mismatch in values compared to float is observed 0, 1, 2, 1, @@ -1366,6 +1344,13 @@ const Word16 pitch_inter4_2[PIT_FIR_SIZE2] = 3/*0.000098f Q15*/, 2/*0.000048f Q15*/, 0/*0.000007f Q15*/, 0/*0.000000f Q15*/ }; /* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ +const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = /* Q31 */ +{ + 1932735283, 1758701061, 1298905484, 711630983, 180298432, -162768528, + -280712608, -226956816, -100446400, 9592809, 59676424, 55065776, + 26996016, 4138201, -3373696, -1617055, 0 +}; +/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = { 29491/*0.900000F Q15*/, @@ -5209,6 +5194,7 @@ const Word16 freqTable[2] = {20, 40}; // Q0 /* SNR: 109.44, PHASE: 3.500000000000000 */ /* SNR: 109.44, PHASE: 3.500000000000000 */ +#ifndef OPT_IVAS_FILTER_ROM const Word16 CLDFB80_10_fx[100] = // q = 15 sf = 17036 qsf = 14 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -2, 0, 0, 0, -1, 0, 0, 0, -8, -31, @@ -5444,6 +5430,778 @@ const Word16 LDQMF_60_fx[] = // q = 15 sf = 15391 qsf = 14 -142, -123, -104, -88, -72, -57, -44, -28, }; +#else /* OPT_IVAS_FILTER_ROM */ + +const Word32 CLDFB80_10_fx[100] = // q = 30 +{ + 3584, -2501, -707, 157, -1170, -1038, +-11, -1944, -1380, 1837, 14727, -9096, +-1691, -267, 3897, -4705, 419, 4651, +5275, -6639, -243747, -72521, -17071, 14831, +-23632, -38285, 18452, -20885, -6245, -281515, +-1070487, -153329, -20195, -4338, -209848, 194011, +24972, -5106, -34468, 1151402, -2164680, -832327, +376720, 1686598, 1844777, 1697325, 2356308, 3037447, +3248821, 1779296, -1533240, -1713947, 833816, 2751563, +2421812, 284255, -3540922, -6991555, -10248264, -14642952, +20031906, 26043234, 34417552, 45928496, 60756732, 78698864, +98151832, 116245496, 129823136, 136344976, 134601568, 122059576, +95304000, 53433792, -3371365, -74987256, -160511088, -258343120, +-366360320, -481533344, 599091264, 714631872, 823505600, 920768896, +1001735168, 1062249792, 1100603392, 1116473216, 1114030976, 1091249536, +1031959808, 939413760, 835792512, 727712064, 614651648, 499141824, +382288320, 266885408, 148867680, 44714176 +}; + + +/* SNR: 292.49, PHASE: 2.000000000000000 */ +const Word32 CLDFB80_16_fx[160] = // q = 30 +{ 592, -824, -251, 104, 64, -2, +-19, 2357, 3222, -18, -2, 75, +37, -82, -596, 808, 2242, -3035, +-755, 254, 126, -435, 107, -19350, +26445, -100, 482, -149, -91, 247, +2196, -3062, -344117, -158537, -67240, -47926, +-21715, 16231, 6227, 48320, 46494, 5449, +17932, -33783, -26258, -13467, -97911, -469416, +-1317171, -563405, -199456, -118497, -43264, 11679, +-61886, 64706, -248886, 55869, 3768, 67211, +64791, 39611, 345778, 1796799, -2314105, -1658358, +-815220, -115680, 761413, 1616443, 1931089, 1230669, +1712206, 1949652, 2418775, 2970521, 3179526, 3272216, +2739046, 1383591, -1186345, -2091284, -1594461, -20541, +1561481, 2685864, 2822045, 2243697, 1007270, -1321111, +-3774214, -5979353, -7970747, -10025660, -12576468, -15588057, +19092548, 22464968, 26489252, 31480652, 37681832, 45115060, +53868456, 63884792, 75139712, 87185504, 99355152, 110921760, +121117896, 129158840, 134480400, 136595408, 135565040, 130704096, +120827352, 105296200, 83827480, 56486836, 23319760, -15680647, +-60454808, -110775264, -166285472, -226570624, -291114656, -359358976, +-430528992, -503583200, 577127680, 650096768, 721690560, 790528896, +855345280, 915113088, 968648896, 1014713216, 1052549440, 1081848192, +1102232576, 1113723648, 1117499392, 1114694144, 1104247168, 1084392960, +1047294336, 993703296, 933123072, 868665920, 802559168, 734628416, +664562240, 593135168, 520952544, 448011680, 375024864, 302909728, +230463232, 156264608, 85568040, 29877076 +}; + + +/* SNR: 89.77, PHASE: 1.500000000000000 */ +const Word32 CLDFB80_20_fx[200] = // q = 30 +{ 1767, -5032, -88, -196, 26, 203, +-254, -755, -8, 5224, 7569, 3, +161, -101, 462, -85, -115, 1651, +-2694, 4755, 4946, -22236, -524, -658, +65, 469, -402, -1021, 719, -9362, +12273, -828, -312, 170, -1089, 201, +407, -7058, 12038, -3893, -327043, -222151, +-35479, -70712, -44739, -22286, -4950, 10391, +-6975, 55398, 27635, -7373, 3144, -22481, +-20586, -25326, -30793, 63871, -118589, -531211, +-1262671, -706692, -140675, -191397, -107627, -49946, +-20212, 30609, -145958, 302172, -516943, 139838, +-27637, 62099, 52144, 58317, 81974, -160536, +375017, 1963206, -2140127, -2009648, -925313, -652848, +-36271, 664400, 1339893, 1799274, 1945125, 831665, +1777056, 1828829, 2078398, 2585601, 2993432, 3154609, +3289693, 3034094, 2356141, 1146722, -993260, -1911082, +-2021484, -1182252, 157141, 1427332, 2466905, 2979250, +2692828, 2193128, 1283653, -616499, -2589952, -4472529, +-6187298, -7776617, -9380603, -11192438, -13438549, -15899665, +18725886, 21392202, 24336266, 27874318, 32044188, 37006492, +42749912, 49318540, 56747120, 64938688, 73960840, 83528888, +93302528, 102923904, 112017456, 120184144, 127010856, 132191136, +135478896, 136610544, 135791440, 132663544, 126439184, 116783968, +103416816, 86239880, 65299188, 40633116, 12229525, -19893306, +-55715672, -95119752, -137902624, -183892768, -232841840, -284483936, +-338536576, -394642624, -452297696, -510956224, 569805312, 628294144, +686151296, 742695360, 797209408, 849073920, 897777728, 942743488, +983299712, 1018874944, 1049145600, 1073975296, 1093176448, 1106582656, +1114420736, 1117424512, 1116238848, 1110577792, 1099271424, 1081958528, +1052270720, 1010577920, 964128448, 914037760, 862118336, 809238464, +755241024, 699830528, 643231744, 585949312, 528205504, 469954944, +411440896, 353300032, 295721536, 237791168, 178588864, 119772248, +66882256, 25081918 +}; + + +/* SNR: 89.29, PHASE: 0.833333333333333 */ +const Word32 CLDFB80_30_fx[300] = // q = 30 +{ -298, 3584, 1941, -855, -2501, -18, +108, -707, 31, 15, 157, 303, +46, -1170, 5206, 7621, -1038, 39, +476, -11, -29, -11, -1944, 58, +-3, -1380, -660, 1053, 1837, -2898, +-12992, 14727, 8112, -3476, -9096, -22, +265, -1691, 46, -32, -267, 593, +210, 3897, 9064, -12976, -4705, -177, +-1102, 419, 158, 60, 4651, -142, +-11, 5275, 2753, -4425, -6639, 19639, +-341195, -243747, -157895, -76329, -72521, -65719, +-49275, -17071, -21325, -4817, 14831, 27866, +-1522, -23632, 5019, -51348, -38285, -878, +59536, 18452, -11251, -36822, -20885, -26546, +-28596, -6245, -16613, -92408, -281515, -679650, +-1089989, -1070487, -687312, -252030, -153329, -178007, +-122647, -20195, -41359, -29533, -4338, 53191, +-112253, -209848, 617831, -803951, 194011, 106901, +-106999, 24972, 64775, 70954, -5106, 66493, +77725, -34468, 24005, 399486, 1151402, 2091330, +-1945866, -2164680, -1871142, -1133490, -832327, -560635, +-144700, 376720, 793103, 1258629, 1686598, 1843272, +1942367, 1844777, 286874, 1790714, 1697325, 1882734, +2048236, 2356308, 2670961, 2960784, 3037447, 3187788, +3282834, 3248821, 2972461, 2561469, 1779296, 779690, +-670109, -1533240, -2023874, -2068454, -1713947, -979306, +-79112, 833816, 1606493, 2311180, 2751563, 2948543, +2758276, 2421812, 2144318, 1669907, 284255, -925661, +-2240403, -3540922, -4767759, -5909822, -6991555, -8035796, +-9103931, -10248264, -11549851, -13052389, -14642952, -16334399, +18220558, 20031906, 21872604, 23814234, 26043234, 28516756, +31295850, 34417552, 37909524, 41736344, 45928496, 50500180, +55453996, 60756732, 66352956, 72392624, 78698864, 85151696, +91671536, 98151832, 104484224, 110553528, 116245496, 121424144, +125981624, 129823136, 132872256, 135069696, 136344976, 136548112, +135995744, 134601568, 131846392, 127706624, 122059576, 114818808, +105909512, 95304000, 83010216, 69049472, 53433792, 36159948, +17222988, -3371365, -25594396, -49478012, -74987256, -102019216, +-130543792, -160511088, -191851984, -224489536, -258343120, -293333280, +-329374368, -366360320, -404158112, -442603456, -481533344, -520813312, +560055680, 599091264, 637996480, 676579264, 714631872, 751940864, +788293056, 823505600, 857424640, 889902848, 920768896, 949826944, +976873792, 1001735168, 1024295104, 1044475456, 1062249792, 1077572608, +1090377088, 1100603392, 1108260608, 1113474048, 1116473216, 1117510400, +1116725248, 1114030976, 1109119488, 1101598848, 1091249536, 1078932736, +1059134272, 1031959808, 1003169408, 972174976, 939413760, 905472960, +870845632, 835792512, 800328576, 764335744, 727712064, 690466496, +652724672, 614651648, 576357376, 537862912, 499141824, 460206112, +421184800, 382288320, 343676096, 305305440, 266885408, 228014720, +188521408, 148867680, 110353960, 74971128, 44714176, 18455688 +}; + + +const Word32 CLDFB80_32_fx[320] = // q = 30 +{ + -1093, 2020, -1500, 75, -3259, -200, +2, 86, -307, -6, -372, -406, +686, 39, -1685, 4713, 6814, -1488, +47, 778, -40, -130, 24, -872, +225, -5, -116, -556, -123, -751, +1334, -5815, -17696, 8208, -6989, 239, +-11912, -669, 1, 206, -738, 0, +-579, -811, 1617, 569, 3828, 10109, +-14335, -4601, -628, -1935, 180, 186, +-69, 2086, -538, 14, 408, 1524, +585, 3601, -4502, 26170, -348871, -274413, +-191283, -101650, -55023, -71745, -57839, -39470, +-16489, -17154, -4618, 1542, 27531, -4838, +-24078, -6041, -61576, -45939, -4350, 52992, +-21467, -30551, -47624, -16879, -16327, -28526, +-30774, 45781, -47861, -103961, -321282, -704888, +-1065517, -1123685, -707166, -371532, -86309, -196314, +-147630, -95796, -26567, -30201, -12085, -23646, +30175, -133297, -186726, 644643, -823106, 165914, +127129, -77847, 76139, 59764, 84597, 13696, +44921, 72597, 82827, -180230, 163871, 385660, +1272552, 2097220, -1940583, -2216918, -1963534, -1312195, +-811283, -684818, -332127, 81208, 566324, 995811, +1374732, 1743252, 1885233, 1944746, 1791356, 230889, +1776037, 1693755, 1848743, 2021967, 2237951, 2554532, +2866858, 3010232, 3111818, 3235821, 3289505, 3179984, +2912034, 2438977, 1724392, 733947, -625866, -1486531, +-1958890, -2094028, -1863598, -1255187, -454123, 425746, +1212702, 1901282, 2517750, 2869908, 2908450, 2719155, +2384774, 2140992, 1717492, 398307, -731735, -1939480, +-3196994, -4359654, -5453402, -6492968, -7485701, -8462297, +-9485345, -10586349, -11872517, -13293064, -14799378, -16391634, +18159074, 19878216, 21572990, 23372214, 25384474, 27638258, +30127980, 32911950, 36012916, 39421380, 43135868, 47172528, +51552328, 56259572, 61272356, 66530936, 72196904, 78102488, +84136944, 90243120, 96340328, 102334376, 108124720, 113633800, +118743656, 123354504, 127384760, 130768192, 133428752, 135331936, +136411184, 136532064, 136012736, 134791376, 132367184, 128735088, +123803096, 117494272, 109734136, 100486232, 89749032, 77539936, +63866580, 48743548, 32160198, 14114131, -5387419, -26313940, +-48704924, -72531920, -97696000, -124178280, -151940320, -180929216, +-211078752, -242327632, -274608448, -307853568, -341987136, -376916512, +-412518528, -448658976, -485200704, -522047808, 558838528, 595432000, +631934592, 668176768, 703995904, 739213504, 773652800, 807151808, +839574912, 870801792, 900704320, 929133248, 955922048, 980906240, +1003949120, 1024962240, 1043881152, 1060686784, 1075342592, 1087794688, +1097989248, 1105913344, 1111637504, 1115325568, 1117191552, 1117410816, +1116024960, 1112890624, 1107711872, 1100166016, 1090143104, 1078585600, +1060024128, 1034545088, 1007817280, 979127552, 948772416, 917237312, +884973248, 852271488, 819225472, 785777536, 751820160, 717295872, +682246976, 646793792, 611070144, 575157504, 539069056, 502781984, +466300064, 429718016, 393203360, 356913536, 320878656, 284927936, +248740064, 212036736, 174863904, 137843808, 102263632, 69872776, +42173520, 17586372 +}; + + +/* SNR: 81.55, PHASE: 0.500000000000000 */ +const Word32 CLDFB80_40_fx[400] = // q = 30 +{ +-4459, -419, -3627, 1424, -337, -2077, +303, 18, 81, 159, -711, 9, +12, -289, -782, 599, -26, 261, +-439, 2799, 3758, -185, 230, -43, +682, -21, -75, -29, -55, -1950, +416, 56, 16, 233, 887, -479, +680, -2718, -569, -16448, -33103, -1653, +-16424, 6275, -1401, -7536, 1256, 82, +202, 378, -1703, -5, -27, -665, +-1194, 1295, -18, 118, -11445, 11396, +-15922, 16043, 175, 78, -1655, 102, +374, 132, 161, 4663, -995, -137, +-67, -970, -4393, 2058, -3082, 11739, +-993, 52507, -372470, -339964, -238020, -154668, +-91227, -39704, -68193, -63466, -52270, -36721, +-12972, -20431, -6925, 7426, -2361, 29241, +920, -11369, 13936, -42084, -90219, 4460, +-7456, 295, 60570, -36066, -9836, -23630, +-40550, -22839, -11573, -27317, -28142, -21799, +74247, -37443, -94761, -175261, -418504, -781461, +-995765, -1274142, -822204, -644197, -320592, -79371, +-211045, -170432, -131251, -90676, -8615, -38865, +-25806, 10490, -21115, 43834, -93771, -212052, +-80067, 687824, -841077, -28319, 196054, 89800, +-98757, 81413, 22561, 71310, 76947, -1234, +38817, 69237, 75947, 74313, -220677, 108139, +388007, 614410, 1602908, 2104013, -1945962, -2345233, +-2073811, -1788974, -1237042, -801097, -773094, -511061, +-205272, 126459, 548962, 854332, 1215260, 1516757, +1754373, 1867886, 1938796, 1938332, 1525725, 104199, +1696967, 1687208, 1745905, 1910502, 2033618, 2194668, +2472078, 2712787, 2937869, 3012596, 3095693, 3204093, +3274808, 3283756, 3148592, 2939051, 2641685, 2031332, +1549503, 597843, -490013, -1328870, -1713436, -2059616, +-2084878, -1903964, -1464478, -873102, -195311, 513856, +1135793, 1697317, 2228107, 2629045, 2909611, 2926214, +2785543, 2569874, 2293850, 2134485, 1852516, 752397, +-164140, -1082527, -2067571, -3082101, -4010647, -4913513, +-5770452, -6592737, -7388101, -8166445, -8966356, -9806266, +-10700961, -11733450, -12861255, -14030459, -15273330, -16566203, +17977196, 19420796, 20683474, 22109952, 23560036, 25167814, +26942868, 28845886, 30930688, 33206692, 35686848, 38368864, +41237952, 44313740, 47594052, 51099240, 54815852, 58726668, +62834600, 67067844, 71610536, 76321632, 81103048, 85964624, +90855304, 95735248, 100552568, 105257896, 109812680, 114164760, +118253480, 122029112, 125449296, 128468360, 131068744, 133194984, +134844544, 135983552, 136548480, 136476080, 136056288, 135290432, +133727152, 131405624, 128303264, 124356992, 119537688, 113797504, +107116320, 99479544, 90889712, 81356080, 70886368, 59482072, +47150368, 33884192, 19681098, 4546190, -11521655, -28482206, +-46395036, -65246120, -84945856, -105504280, -126897840, -149107856, +-172107808, -195862240, -220341504, -245510512, -271335616, -297782912, +-324814976, -352387008, -380449280, -408931776, -437767552, -466890752, +-496221408, -525752320, 555187200, 584450368, 613710272, 642840512, +671780800, 700438528, 728721728, 756541312, 783807872, 810444608, +836384512, 861566464, 885927424, 909395008, 931888896, 953321728, +973609216, 992677120, 1010468928, 1026949632, 1042084096, 1055868544, +1068286464, 1079312512, 1088916480, 1097072128, 1103772032, 1109042176, +1112948608, 1115590912, 1117080960, 1117511680, 1116923264, 1115280512, +1112471040, 1108330880, 1102691712, 1095455872, 1086748672, 1077537920, +1062688064, 1042243712, 1021432192, 999408768, 976158720, 951869952, +926793472, 901173760, 875200384, 848982208, 822546624, 795860992, +768868224, 741522368, 713812928, 685772416, 657463808, 628958848, +600314432, 571556608, 542686272, 513690592, 484561600, 455329056, +426060320, 396846880, 367771776, 338869952, 310096864, 281325184, +252379520, 223109248, 193485184, 163693120, 134192648, 105710896, +79151352, 55383672, 34725716, 14899882 +}; + + +/* SNR: 85.15, PHASE: 0.166666666666667 */ +const Word32 CLDFB80_60_fx[600] = // q = 30 +{ -11638, 1767, -122, 1628, -5032, -196, +161, -88, -3545, 137, -196, 21, +36, 26, 132, -1128, 203, 12, +-29, -254, -97, -286, -755, 689, +-55, -8, 215, -1583, 5224, -169, +-595, 7569, -1361, 190, 3, -67, +788, 161, -43, -20, -101, -32, +-10, 462, -3064, 321, -85, 24, +12, -115, 151, -968, 1651, -22, +-258, -2694, -28, 68, 4755, -32803, +-51846, 4946, -596, 6086, -22236, -388, +578, -524, -12974, 673, -658, 65, +91, 65, 314, -2699, 469, 12, +-69, -402, -518, -689, -1021, 1669, +-23, 719, 449, -2322, -9362, 9537, +-13566, 12273, 3730, -157, -828, 61, +-1978, -312, 206, 462, 170, 84, +41, -1089, 7330, -768, 201, -60, +-41, 407, -660, 3231, -7058, 161, +771, 12038, 198, -1291, -3893, 106546, +-387363, -327043, -319712, -213953, -222151, -158504, +-105319, -35479, -59682, -66733, -70712, -61610, +-55171, -44739, -31711, -9900, -22286, -19252, +-9917, -4950, 14172, 3111, 10391, 26566, +4086, -6975, -13332, -9892, 55398, -89244, +-120822, 27635, -30751, -9363, -7373, 2810, +49557, 3144, -15960, 10651, -22481, -39335, +-43081, -20586, -29742, -8098, -25326, -28071, +-28128, -30793, -15878, 36414, 63871, -51035, +-98423, -118589, -196780, -380753, -531211, -867079, +-924260, -1262671, -1211187, -909700, -706692, -590140, +-387713, -140675, -90592, -207147, -191397, -163116, +-139419, -107627, -77449, 8620, -49946, -36329, +-21446, -20212, 13295, -23389, 30609, 24765, +-73159, -145958, -228347, -136170, 302172, 622362, +-742756, -516943, 79533, 208728, 139838, 68780, +-69177, -27637, 72365, 6204, 62099, 78720, +81230, 52144, -15436, 27781, 58317, 71170, +74613, 81974, 55368, -164496, -160536, 180918, +362005, 375017, 795458, 1461875, 1963206, 2095155, +-1983049, -2140127, -2301661, -2078197, -2009648, -1702455, +-1336746, -925313, -815553, -803613, -652848, -461551, +-265137, -36271, 196856, 518314, 664400, 915382, +1166217, 1339893, 1585569, 1738976, 1799274, 1890535, +1933937, 1945125, 1923994, 1665861, 831665, 77564, +1488037, 1777056, 1688417, 1721975, 1828829, 1937199, +2017937, 2078398, 2252451, 2437196, 2585601, 2754365, +2909842, 2993432, 3016599, 3074266, 3154609, 3219375, +3265044, 3289693, 3277126, 3189837, 3034094, 2902602, +2709099, 2356141, 1938986, 1632226, 1146722, 418214, +-305018, -993260, -1403823, -1653092, -1911082, -2083225, +-2096449, -2021484, -1849083, -1552144, -1182252, -764155, +-310625, 157141, 627282, 1032601, 1427332, 1788414, +2142931, 2466905, 2666629, 2856089, 2979250, 2902477, +2810289, 2692828, 2523008, 2330296, 2193128, 2132550, +2001086, 1283653, 592123, -15236, -616499, -1241115, +-1897102, -2589952, -3235046, -3852858, -4472529, -5058432, +-5630304, -6187298, -6725206, -7257095, -7776617, -8297675, +-8829816, -9380603, -9952123, -10548511, -11192438, -11919065, +-12671172, -13438549, -14232061, -15062200, -15899665, -16802572, +17739412, 18725886, 19625418, 20458448, 21392202, 22346532, +23310144, 24336266, 25457146, 26639572, 27874318, 29180440, +30570936, 32044188, 33604364, 35257056, 37006492, 38833420, +40745368, 42749912, 44846596, 47032812, 49318540, 51704112, +54183000, 56747120, 59397304, 62137772, 64938688, 67793344, +70831448, 73960840, 77111768, 80298224, 83528888, 86778376, +90039080, 93302528, 96541856, 99755032, 102923904, 106027616, +109066040, 112017456, 114866184, 117592440, 120184144, 122624224, +124905544, 127010856, 128931552, 130666344, 132191136, 133505016, +134605360, 135478896, 136120576, 136498544, 136610544, 136390896, +136106368, 135791440, 135081680, 134039064, 132663544, 130943336, +128876128, 126439184, 123615464, 120403880, 116783968, 112750168, +108296544, 103416816, 98114136, 92387688, 86239880, 79676032, +72697184, 65299188, 57491652, 49271324, 40633116, 31582262, +22113356, 12229525, 1933215, -8779568, -19893306, -31396530, +-43338216, -55715672, -68469528, -81601800, -95119752, -109012544, +-123274624, -137902624, -152887216, -168220960, -183892768, -199892672, +-216212560, -232841840, -249770272, -266987040, -284483936, -302248800, +-320270592, -338536576, -357031680, -375740448, -394642624, -413715328, +-432939744, -452297696, -471766976, -491319872, -510956224, -530689568, +550314688, 569805312, 589331520, 608841280, 628294144, 647679424, +666974528, 686151296, 705180416, 724037376, 742695360, 761126400, +779305216, 797209408, 814818048, 832112192, 849073920, 865685504, +881927232, 897777728, 913213888, 928211072, 942743488, 956784768, +970310720, 983299712, 995732352, 1007593856, 1018874944, 1029566592, +1039655360, 1049145600, 1058033856, 1066312576, 1073975296, 1081012992, +1087415680, 1093176448, 1098289920, 1102755712, 1106582656, 1109785856, +1112388096, 1114420736, 1115916544, 1116907776, 1117424512, 1117484800, +1117091968, 1116238848, 1114897920, 1113026048, 1110577792, 1107500160, +1103739520, 1099271424, 1094099328, 1088271360, 1081958528, 1076012800, +1066112832, 1052270720, 1038832960, 1024980800, 1010577920, 995613248, +980113280, 964128448, 947737280, 931017344, 914037760, 896864896, +879548544, 862118336, 844591360, 826968768, 809238464, 791384896, +773390848, 755241024, 736928896, 718455680, 699830528, 681070912, +662197568, 643231744, 624193216, 605096768, 585949312, 566752640, +547506176, 528205504, 508844544, 489425088, 469954944, 450450944, +430937408, 411440896, 391989376, 372605984, 353300032, 334067616, +314888448, 295721536, 276517248, 257224080, 237791168, 218193616, +198443888, 178588864, 158737840, 139063920, 119772248, 101121944, +83411368, 66882256, 51724928, 38009000, 25081918, 11097560 +}; + + +/* 5ms delay prototype */ +const Word32 LDQMF_10_fx[] = // q = 30 +{ + 136778, 68195, -70890, -226890, -352352, -420072, +-436802, -444543, -506661, -672815, -980068, -1367880, +-1747442, -2041059, -2171766, -2084001, -1756846, -1205000, +-470033, 391658, -1352314, -2311012, -3225024, -4068760, +-4825637, -5483931, -6033975, -6472204, -6808585, -7075060, +-7325812, -7636335, -8074047, -8676456, -9424478, -10219283, +-10865228, -11073811, -10475044, -8652076, 5180201, -339904, +-8224782, -18673422, -31726070, -47229416, -64809980, -83846512, +-103451368, -122477480, -139540384, -153063904, -161342016, -162639632, +-155309920, -137908720, -109304704, -68777832, -16099735, 48410956, +-123867744, -208812656, -301278944, -398795360, -498505440, -597277184, +-691834048, -778907776, -855407232, -918606592, -966152640, -996390080, +-1008509056, -1002265344, -978191040, -937540800, -882190336, -814525888, +-737309056, -653527872, 566225280, 478344672, 392910464, 312395584, +238918544, 174094816, 118926376, 73749168, 38239292, 11438051, +-6809585, -17473586, -23179288, -24893300, -23497172, -19904868, +-15070633, -9938406, -5364481, -2000462 +}; + + +const Word32 LDQMF_16_fx[] = // q = 30 +{ +135840, 119105, 61025, -23300, -120396, -217572, +-303688, -369787, -411986, -431913, -436960, -439365, +-455121, -500073, -585815, -716339, -910646, -1146410, +-1392576, -1634245, -1852285, -2026746, -2138911, -2173116, +-2118583, -1970211, -1728614, -1399460, -992562, -520340, +3268, 562389, -1169900, -1774888, -2369781, -2945925, +-3497147, -4018445, -4506032, -4956920, -5368526, -5738270, +-6064626, -6347064, -6587229, -6790047, -6964112, -7121373, +-7276728, -7449880, -7659373, -7920485, -8244154, -8633965, +-9083566, -9574508, -10074442, -10534940, -10894573, -11076715, +-10992408, -10543848, -9627864, -8139161, 5976364, 3037887, +-760649, -5491840, -11209240, -17943616, -25700144, -34454400, +-44150032, -54695840, -65964980, -77789648, -89960896, -102229872, +-114308392, -125871952, -136561440, -145990880, -153753088, -159424128, +-162577504, -162794960, -159676832, -152853360, -141995744, -126825840, +-107126032, -82747424, -53617472, -19744928, 18775524, 61761592, +-108947912, -159965984, -214394832, -271716064, -331337920, -392605120, +-454808224, -517194272, -578978880, -639359104, -697528768, -752693376, +-804086912, -850989824, -892747136, -928791232, -958536704, -981563328, +-997684800, -1006698432, -1008520640, -1003187328, -990852800, -971782976, +-946346880, -915003328, -878295040, -836832960, -791284544, -742359104, +-690793664, -637338560, 582754624, 527645440, 472906400, 419190784, +367113152, 317241312, 270082016, 226065808, 185534960, 148735312, +115810224, 86800312, 61646000, 40190228, 22181636, 7245162, +-4169367, -12156084, -17964338, -21866804, -24101958, -24886370, +-24433336, -22962478, -20701850, -17885954, -14749119, -11519968, +-8412224, -5619924, -3298610, -1524161 +}; + + +const Word32 LDQMF_20_fx[] = // q = 30 +{ +132095, 130054, 94118, 37811, -32619, -110471, +-188997, -262715, -325880, -375095, -408842, -427924, +-435582, -437285, -440062, -452482, -482692, -537287, +-620381, -731564, -887814, -1074239, -1268925, -1466394, +-1657422, -1832122, -1980124, -2091724, -2157946, -2171782, +-2128230, -2024638, -1860817, -1638685, -1362085, -1036418, +-668022, -263994, 167952, 619489, -1109006, -1594302, +-2074063, -2544892, -3002259, -3443307, -3865450, -4266665, +-4645248, -4999899, -5329217, -5631869, -5906959, -6153951, +-6372928, -6565001, -6732690, -6880012, -7012401, -7136777, +-7260809, -7394870, -7549043, -7731644, -7949919, -8208793, +-8510223, -8852171, -9227619, -9624792, -10025312, -10404401, +-10731825, -10971712, -11081824, -11015548, -10722771, -10150872, +-9246198, -7954792, 6226194, 4006049, 1251053, -2079213, +-6018496, -10592059, -15815707, -21694928, -28223572, -35382820, +-43140436, -51449560, -60249600, -69462792, -78994976, -88734976, +-98555328, -108312432, -117847120, -126986608, -135542896, -143318016, +-150106768, -155693424, -159859744, -162387488, -163062224, -161676800, +-158034768, -151954128, -143271408, -131843832, -117553208, -100308496, +-80048728, -56744644, -30400730, -1056328, 31212950, 66296312, +-104051416, -144280880, -186784688, -231313168, -277585056, -325290400, +-374093504, -423635840, -473540064, -523412928, -572850304, -621440576, +-668770368, -714429248, -758014656, -799138176, -837430848, -872549376, +-904183040, -932063424, -955866112, -975368256, -990502784, -1001141248, +-1007204608, -1008661952, -1005531712, -997881088, -985824192, -969518976, +-949164608, -924995776, -897283008, -866326016, -832450624, -796003264, +-757347840, -716859456, -674920448, -631918336, 588261568, 544170240, +500187776, 456655456, 413899520, 372230592, 331939808, 293293792, +256529792, 221851008, 189423392, 159373024, 131783696, 106697088, +84113256, 63991576, 46252108, 30775584, 17400960, 5897692, +-3242832, -10003035, -15315395, -19324048, -22161874, -23947232, +-24790774, -24801182, -24088950, -22768174, -20956786, -18774960, +-16343248, -13780261, -11200397, -8711802, -6413878, -4393110, +-2713518, -1364255 +}; + + +const Word32 LDQMF_30_fx[] = // q = 30 +{ + 121571, 136778, 125655, 101704, 68195, 26875, +-20212, -70890, -123705, -176138, -226890, -274106, +-316253, -352352, -381787, -404297, -420072, -429892, +-434876, -436802, -437431, -439163, -444543, -456066, +-476087, -506661, -549091, -604538, -672815, -752814, +-858037, -980068, -1106184, -1235998, -1367880, -1498945, +-1626464, -1747442, -1858910, -1957741, -2041059, -2106142, +-2150372, -2171766, -2168618, -2139643, -2084001, -2001495, +-1892255, -1756846, -1596236, -1411745, -1205000, -977797, +-732072, -470033, -193708, 94399, 391658, 694989, +-1028102, -1352314, -1674661, -1994503, -2311012, -2622127, +-2927093, -3225024, -3515027, -3796480, -4068760, -4331384, +-4583784, -4825637, -5056603, -5276176, -5483931, -5679645, +-5863044, -6033975, -6192384, -6338348, -6472204, -6594554, +-6706284, -6808585, -6902959, -6991107, -7075060, -7157331, +-7239857, -7325812, -7418951, -7521577, -7636335, -7765375, +-7910813, -8074047, -8256089, -8457071, -8676456, -8912695, +-9163169, -9424478, -9691922, -9959316, -10219283, -10463412, +-10682245, -10865228, -11000298, -11074417, -11073811, -10983892, +-10789539, -10475044, -10024687, -9422374, -8652076, -7698111, +6547450, 5180201, 3585185, 1749124, -339904, -2692689, +-5318487, -8224782, -11417230, -14899579, -18673422, -22738288, +-27091010, -31726070, -36635292, -41807760, -47229416, -52884028, +-58751904, -64809980, -71032152, -77388632, -83846512, -90369776, +-96918936, -103451368, -109921528, -116280640, -122477480, -128458624, +-134165992, -139540384, -144523760, -149052944, -153063904, -156492352, +-159273296, -161342016, -162634320, -163087360, -162639632, -161231616, +-158806368, -155309920, -150691824, -144905568, -137908720, -129663752, +-120138088, -109304704, -97142448, -83636416, -68777832, -52564528, +-35001268, -16099735, 4121304, 25635912, 48410956, 72407360, +-97584200, -123867744, -151213264, -179552912, -208812656, -238912112, +-269764832, -301278944, -333357440, -365898336, -398795360, -431938528, +-465214080, -498505440, -531693760, -564658432, -597277184, -629427584, +-660987072, -691834048, -721848128, -750911168, -778907776, -805726528, +-831260224, -855407232, -878071616, -899164800, -918606592, -936328128, +-952202112, -966152640, -978197888, -988289792, -996390080, -1002471040, +-1006513664, -1008509056, -1008457600, -1006369728, -1002265344, -996173888, +-988133504, -978191040, -966401920, -952828672, -937540800, -920615360, +-902135488, -882190336, -860873664, -838284672, -814525888, -789704064, +-763927872, -737309056, -709960000, -681994880, -653527872, -624673024, +595607552, 566225280, 536822976, 507495872, 478344672, 449466912, +420958208, 392910464, 365412224, 338547584, 312395584, 287029856, +262517344, 238918544, 216286160, 194665808, 174094816, 154602160, +136208672, 118926376, 102759984, 87704592, 73749168, 60872400, +49048000, 38239292, 28404982, 19492542, 11438051, 4150853, +-1959299, -6809585, -10983833, -14524688, -17473586, -19875174, +-21764768, -23179288, -24150308, -24711158, -24893300, -24729546, +-24252922, -23497172, -22497182, -21287720, -19904868, -18383770, +-16760795, -15070633, -13348427, -11626766, -9938406, -8313092, +-6779951, -5364481, -4088471, -2966834, -2000462, -1134160 +}; + + +const Word32 LDQMF_32_fx[] = // q = 30 +{ +119697, 137151, 128520, 107723, 78400, 41836, +-442, -46740, -95597, -145201, -193804, -240598, +-283800, -322316, -355411, -382593, -403699, -418862, +-428699, -434120, -436480, -437237, -438149, -441391, +-449045, -463039, -485346, -517326, -560092, -614348, +-679872, -755580, -854379, -968457, -1086190, -1207329, +-1330799, -1454135, -1575271, -1691704, -1801098, -1900763, +-1988263, -2061316, -2117677, -2155275, -2172543, -2168111, +-2140952, -2090356, -2016155, -1918414, -1797519, -1654212, +-1489464, -1304576, -1100939, -880095, -643755, -393648, +-131597, 140303, 419876, 704520, -1017921, -1322020, +-1624457, -1924758, -2222508, -2515835, -2804014, -3086295, +-3361992, -3630425, -3891163, -4143616, -4387487, -4622276, +-4847761, -5063642, -5269495, -5464963, -5649876, -5823971, +-5987172, -6139337, -6280537, -6410931, -6530943, -6641149, +-6742439, -6835855, -6922708, -7004445, -7082802, -7159902, +-7237256, -7317480, -7403834, -7498178, -7602711, -7719257, +-7849652, -7995245, -8157013, -8335469, -8530447, -8741283, +-8966383, -9203373, -9449370, -9700315, -9951033, -10195449, +-10426707, -10637019, -10818085, -10960053, -11052529, -11084311, +-11043675, -10918394, -10695736, -10362793, -9906464, -9313511, +-8570674, -7665161, 6586647, 5317833, 3849979, 2171972, +273875, -1853535, -4218327, -6827112, -9685347, -12796811, +-16163952, -19787344, -23665996, -27796800, -32174812, -36793016, +-41642268, -46710992, -51985904, -57451192, -63088408, -68876552, +-74792144, -80808992, -86898528, -93029584, -99168576, -105279432, +-111323816, -117260928, -123048216, -128641440, -133992400, -139052160, +-143773440, -148104208, -151991888, -155383600, -158225792, -160465072, +-162048320, -162923104, -163038096, -162343200, -160789920, -158332016, +-154925376, -150528912, -145104496, -138617152, -131035664, -122332640, +-112485024, -101474136, -89286032, -75911456, -61346324, -45591780, +-28653996, -10544916, 8718141, 29112362, 50609392, 73176464, +-96780680, -121357544, -146873168, -173272304, -200494976, -228475968, +-257145792, -286430368, -316251616, -346527296, -377172096, -408096800, +-439210240, -470417824, -501623072, -532727936, -563632832, -594237184, +-624439872, -654140096, -683237312, -711632192, -739226496, -765924288, +-791632320, -816260416, -839722176, -861935360, -882823040, -902313408, +-920341952, -936853184, -951735680, -964924736, -976443584, -986251200, +-994314944, -1000609792, -1005117952, -1007828864, -1008739392, -1007854080, +-1005185024, -1000751488, -994580096, -986704064, -977163328, -966004416, +-953279168, -939044864, -923364608, -906306368, -887942656, -868349888, +-847608448, -825801792, -803016512, -779341120, -754867072, -729686080, +-703891520, -677576896, -650837184, -623766656, 596524928, 568982144, +541414592, 513899552, 486520032, 459356832, 432489472, 405994688, +379947008, 354417408, 329473600, 305178976, 281592608, 258768368, +236754960, 215594992, 195325728, 175977920, 157575920, 140137536, +123674336, 108191456, 93687496, 80154992, 67580128, 55943780, +45219876, 35377480, 26377892, 18179138, 10724362, 3937154, +-1793747, -6383129, -10375463, -13802420, -16701194, -19108980, +-21056298, -22573612, -23687536, -24425978, -24814642, -24880884, +-24650790, -24152456, -23413234, -22462376, -21328340, -20040900, +-18629038, -17122794, -15550818, -13942058, -12323783, -10723672, +-9166937, -7678115, -6278687, -4990172, -3829056, -2807491, +-1918388, -1103400 +}; + + +const Word32 LDQMF_40_fx[] = // q = 30 +{ +113206, 137254, 134425, 123146, 105211, 81666, +53560, 21302, -14069, -51499, -90644, -130324, +-169687, -208133, -245093, -279677, -311296, -339564, +-364227, -384972, -401866, -414904, -424383, -430758, +-434462, -436342, -437086, -437526, -438798, -441921, +-448029, -458055, -473038, -493889, -521096, -555299, +-596905, -645667, -701531, -764070, -843495, -933719, +-1026835, -1122239, -1219597, -1318430, -1417239, -1515133, +-1610824, -1702996, -1790556, -1872015, -1946188, -2011806, +-2067738, -2112859, -2146050, -2166539, -2173557, -2166437, +-2144725, -2108000, -2056211, -1989295, -1907357, -1810628, +-1699503, -1574446, -1436054, -1285028, -1122103, -948052, +-763730, -570121, -367947, -158284, 57837, 279329, +505114, 733496, -987128, -1230885, -1473412, -1714779, +-1954662, -2192913, -2428356, -2660607, -2889345, -3114179, +-3334742, -3550687, -3761781, -3967793, -4168400, -4363503, +-4552806, -4736194, -4913551, -5084693, -5249383, -5407420, +-5558753, -5703241, -5840790, -5971350, -6094838, -6211308, +-6320774, -6423390, -6519396, -6609079, -6692852, -6771222, +-6844809, -6914280, -6980363, -7043921, -7105964, -7167616, +-7229469, -7292854, -7359781, -7431209, -7508135, -7591745, +-7682927, -7782628, -7891680, -8010673, -8140087, -8280182, +-8430924, -8592083, -8763179, -8943293, -9131195, -9325472, +-9524332, -9725493, -9926142, -10123188, -10313198, -10492333, +-10656603, -10801577, -10922158, -11013175, -11068951, -11083709, +-11051345, -10965628, -10820070, -10607987, -10322919, -9958035, +-9506509, -8961670, -8316717, -7565184, 6702942, 5718827, +4609517, 3369113, 1992225, 473872, -1190731, -3005819, +-4975066, -7101637, -9388180, -11836610, -14448347, -17224060, +-20163764, -23266722, -26531342, -29955288, -33535422, -37267720, +-41147260, -45168140, -49323552, -53606284, -58007508, -62517548, +-67125584, -71820016, -76587808, -81415152, -86287160, -91187832, +-96100320, -101006496, -105887512, -110723520, -115493552, -120176040, +-124748632, -129188288, -133469680, -137567456, -141458352, -145116032, +-148513808, -151624560, -154421360, -156876704, -158963328, -160653808, +-161921024, -162738128, -163078752, -162916896, -162227280, -160985216, +-159167008, -156749920, -153712208, -150033328, -145694224, -140676912, +-134964928, -128543672, -121399776, -113521832, -104900488, -95527920, +-85398544, -74508560, -62856444, -50442808, -37270156, -23343566, +-8670189, 6740502, 22876916, 39724980, 57268860, 75490816, +-94376496, -113883272, -134001320, -154702832, -175958544, -197737504, +-220006032, -242729312, -265870144, -289389664, -313247648, -337401888, +-361809024, -386424256, -411201216, -436093120, -461051360, -486026816, +-510969600, -535829088, -560554240, -585093440, -609395008, -633407296, +-657078592, -680357568, -703193408, -725535424, -747334272, -768541184, +-789108672, -808990656, -828142272, -846520832, -864084928, -880795968, +-896616960, -911514304, -925457216, -938417536, -950324992, -961141376, +-970896128, -979566976, -987136576, -993587776, -998908288, -1003088128, +-1006120192, -1008000960, -1008729280, -1008307648, -1006741504, -1004039168, +-1000212096, -995274560, -989243584, -982139008, -973983296, -964801472, +-954620608, -943470016, -931381312, -918388608, -904527488, -889835648, +-874352128, -858117568, -841174400, -823565824, -805336512, -786531904, +-767198144, -747382720, -727132672, -706495808, -685520512, -664254656, +-642746560, -621047616, 599273536, 577248256, 555196416, 533150944, +511154144, 489249568, 467478368, 445881248, 424498464, 403368608, +382529632, 362017792, 341868224, 322114240, 302787552, 283917824, +265532592, 247657504, 230315568, 213527440, 197311648, 181683920, +166657488, 152242496, 138447232, 125276624, 112733328, 100817520, +89526080, 78854768, 68795096, 59337532, 50469688, 42175888, +34440516, 27241264, 20558124, 14361678, 8619497, 3303077, +-1288525, -5070930, -8454926, -11459781, -14115485, -16433949, +-18436136, -20138626, -21555150, -22702724, -23593500, -24242222, +-24662498, -24867088, -24870766, -24686354, -24328404, -23811232, +-23148884, -22356736, -21449164, -20441404, -19348716, -18185774, +-16968062, -15710186, -14426756, -13132428, -11840736, -10565599, +-9320040, -8115962, -6965903, -5879984, -4867950, -3939393, +-3097321, -2346408, -1680052, -1007771 +}; + + +const Word32 LDQMF_60_fx[] = // q = 30 +{ + 102336, 132095, 137435, 135349, 130054, 120487, +108540, 94118, 77297, 58570, 37811, 15643, +-7974, -32619, -57897, -84046, -110471, -136942, +-163210, -188997, -214438, -239091, -262715, -285164, +-306247, -325880, -343923, -360378, -375095, -388054, +-399325, -408842, -416725, -423037, -427924, -431547, +-434000, -435582, -436522, -437005, -437285, -437644, +-438481, -440062, -442703, -446767, -452482, -460182, +-470154, -482692, -497967, -516093, -537287, -561715, +-589463, -620381, -654511, -691825, -731564, -775911, +-829205, -887814, -949148, -1011179, -1074239, -1138341, +-1203246, -1268925, -1334921, -1400802, -1466394, -1531260, +-1595082, -1657422, -1717943, -1776350, -1832122, -1884921, +-1934396, -1980124, -2021834, -2059138, -2091724, -2119241, +-2141378, -2157946, -2168655, -2173353, -2171782, -2163852, +-2149388, -2128230, -2100421, -2065896, -2024638, -1976676, +-1922048, -1860817, -1793099, -1719008, -1638685, -1552286, +-1460012, -1362085, -1258676, -1150050, -1036418, -918024, +-795131, -668022, -536993, -402188, -263994, -122679, +21420, 167952, 316690, 467104, 619489, 773430, +-945239, -1109006, -1271451, -1433050, -1594302, -1754861, +-1914784, -2074063, -2232363, -2389328, -2544892, -2698989, +-2851488, -3002259, -3151251, -3298296, -3443307, -3586211, +-3726943, -3865450, -4001599, -4135335, -4266665, -4395461, +-4521664, -4645248, -4766175, -4884420, -4999899, -5112604, +-5222404, -5329217, -5433113, -5533999, -5631869, -5726641, +-5818340, -5906959, -5992421, -6074745, -6153951, -6230036, +-6303010, -6372928, -6439843, -6503845, -6565001, -6623435, +-6679269, -6732690, -6783804, -6832855, -6880012, -6925506, +-6969547, -7012401, -7054336, -7095680, -7136777, -7177903, +-7219120, -7260809, -7303731, -7348340, -7394870, -7443617, +-7494881, -7549043, -7606393, -7667166, -7731644, -7800142, +-7872827, -7949919, -8031501, -8117779, -8208793, -8304570, +-8405066, -8510223, -8619935, -8734017, -8852171, -8974106, +-9099397, -9227619, -9358364, -9490965, -9624792, -9759051, +-9892867, -10025312, -10155439, -10282162, -10404401, -10520844, +-10630426, -10731825, -10823502, -10903968, -10971712, -11025073, +-11062346, -11081824, -11081759, -11060277, -11015548, -10945697, +-10848751, -10722771, -10565739, -10375810, -10150872, -9888970, +-9588053, -9246198, -8861297, -8431401, -7954792, -7429283, +6854949, 6226194, 5542800, 4803353, 4006049, 3149248, +2231398, 1251053, 206700, -902968, -2079213, -3323232, +-4636016, -6018496, -7471561, -8995894, -10592059, -12260527, +-14001671, -15815707, -17702624, -19662438, -21694928, -23799650, +-25976100, -28223572, -30541232, -32928052, -35382820, -37904240, +-40490688, -43140436, -45851544, -48621904, -51449560, -54331840, +-57266136, -60249600, -63279032, -66351236, -69462792, -72609920, +-75788648, -78994976, -82224448, -85472704, -88734976, -92006232, +-95281520, -98555328, -101822272, -105076584, -108312432, -111523680, +-114704032, -117847120, -120946376, -123995120, -126986608, -129913560, +-132768248, -135542896, -138230992, -140825344, -143318016, -145701104, +-147966688, -150106768, -152113232, -153978192, -155693424, -157250816, +-158642336, -159859744, -160895152, -161740352, -162387488, -162828688, +-163056176, -163062224, -162839296, -162379936, -161676800, -160722816, +-159511024, -158034768, -156287280, -154262480, -151954128, -149356496, +-146464032, -143271408, -139773568, -135965808, -131843832, -127403488, +-122641048, -117553208, -112136840, -106389392, -100308496, -93892368, +-87139520, -80048728, -72619504, -64851416, -56744644, -48299972, +-39518100, -30400730, -20949652, -11167261, -1056328, 9379870, +20137698, 31212950, 42601076, 54297248, 66296312, 78593112, +-91185600, -104051416, -117194704, -130607064, -144280880, -158207776, +-172378736, -186784688, -201415824, -216262032, -231313168, -246558128, +-261985952, -277585056, -293343616, -309249600, -325290400, -341453376, +-357725472, -374093504, -390543744, -407062432, -423635840, -440249504, +-456889088, -473540064, -490187584, -506816896, -523412928, -539960640, +-556444864, -572850304, -589161600, -605363456, -621440576, -637377600, +-653159232, -668770368, -684195712, -699420352, -714429248, -729207616, +-743740992, -758014656, -772014784, -785727168, -799138176, -812234496, +-825002880, -837430848, -849505856, -861215872, -872549376, -883495616, +-894043456, -904183040, -913905152, -923200640, -932063424, -940477696, +-948417216, -955866112, -962841216, -969345024, -975368256, -980905536, +-985952256, -990502784, -994553344, -998100544, -1001141248, -1003673344, +-1005694720, -1007204608, -1008202304, -1008687808, -1008661952, -1008125952, +-1007081664, -1005531712, -1003479040, -1000927424, -997881088, -994344832, +-990323904, -985824192, -980852096, -975414528, -969518976, -963173312, +-956385600, -949164608, -941519424, -933459776, -924995776, -916137728, +-906896448, -897283008, -887308928, -876985984, -866326016, -855341824, +-844045696, -832450624, -820569472, -808415936, -796003264, -783345088, +-770455104, -757347840, -744036608, -730535808, -716859456, -703022272, +-689038016, -674920448, -660685696, -646345600, -631918336, -617424704, +602927232, 588261568, 573575488, 558872576, 544170240, 529480224, +514815008, 500187776, 485610624, 471095904, 456655456, 442301536, +428045760, 413899520, 399874240, 385981024, 372230592, 358633472, +345199872, 331939808, 318862624, 305977728, 293293792, 280819232, +268562016, 256529792, 244729552, 233167968, 221851008, 210784624, +199973840, 189423392, 179137440, 169119664, 159373024, 149900064, +140703152, 131783696, 123142424, 114780232, 106697088, 98892400, +91364808, 84113256, 77135992, 70429688, 63991576, 57819020, +51907328, 46252108, 40848248, 35691672, 30775584, 26091894, +21637068, 17400960, 13374445, 9548629, 5897692, 2475272, +-592184, -3242832, -5659970, -7917455, -10003035, -11926348, +-13696880, -15315395, -16789184, -18123694, -19324048, -20394110, +-21338122, -22161874, -22868630, -23462238, -23947232, -24327810, +-24607834, -24790774, -24881324, -24883598, -24801182, -24638338, +-24399474, -24088950, -23710470, -23268668, -22768174, -22213084, +-21607820, -20956786, -20264828, -19536176, -18774960, -17986262, +-17174228, -16343248, -15497611, -14641749, -13780261, -12916498, +-12055168, -11200397, -10355588, -9525147, -8711802, -7920384, +-7153632, -6413878, -5706099, -5031208, -4393110, -3792571, +-3230785, -2713518, -2227977, -1784736, -1364255, -871387 +}; +#endif /* OPT_IVAS_FILTER_ROM */ + const Word32 rot_vec_delay_re_LDQMF_fx[60] = // q = 31 { -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, @@ -14896,6 +15654,33 @@ const Word16 wac_swb_l[LPC_SHB_ORDER] = 30328 }; +const Word16 wac_swb_ivas_h[LPC_SHB_ORDER] = +{//Q15 + 32749, + 32731, + 32686, + 32622, + 32541, + 32442, + 32325, + 32191, + 32039, + 31870 +}; + +const Word16 wac_swb_ivas_l[LPC_SHB_ORDER] = +{//Q15 + 2624, + 20874, + 7850, + 25873, + 12831, + 5927, + 10541, + 239, + 15037, + 30328 +}; const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[4 * 4] = { diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index a87ee8d0d3fdad11bf7d0cd323aa0abce3b4eaee..8a8ff7dd03e7d60d834f94ab6d6054f0f247d6f2 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -172,16 +172,16 @@ extern const Word32 crit_bands_fx[]; extern const float sincos_t_ext[]; // fft_rel dep extern const Word16 sincos_t_rad3_fx[]; // Q15 extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ -extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx[]; -extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ -extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ -extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/ -extern const Word16 Assym_window_W16fx[]; // Q15 -extern const Word16 assym_window_16k_fx[]; // Q15 -extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ +extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ +extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ +extern const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*Q31*/ +extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/ +extern const Word16 Assym_window_W16fx[]; // Q15 +extern const Word16 assym_window_16k_fx[]; // Q15 +extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 +extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 +extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/ extern const Word16 filter5_39s320_120_fx[]; // Q15 @@ -616,8 +616,10 @@ extern const Word16 window_wb_fx[]; // extern const Word16 subwin_wb_fx[]; // Q15 extern const Word16 Hilbert_coeffs_fx[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1]; // Q14 -extern const Word16 wac_swb_h[]; // Q15 -extern const Word16 wac_swb_l[]; // Q15 +extern const Word16 wac_swb_h[]; // Q15 +extern const Word16 wac_swb_l[]; // Q15 +extern const Word16 wac_swb_ivas_h[]; // Q15 +extern const Word16 wac_swb_ivas_l[]; // Q15 extern const Word16 wb_bwe_lsfvq_cbook_8bit_fx[]; // Q15 extern const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[]; // Q15 diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h index 29e7637574ac2d2085f44ff635a71493440b7444..9bf335aac1b8bac51a45ccafc1cc847a0dba6500 100644 --- a/lib_com/rom_com_fx.h +++ b/lib_com/rom_com_fx.h @@ -70,7 +70,7 @@ extern const Word16 sin_twiddle_table_25_5_5[25]; // Q15 extern const Word16 cos_twiddle_table_16_8_2[16]; // Q15 extern const Word16 sin_twiddle_table_16_8_2[16]; // Q15 - +#ifndef OPT_IVAS_FILTER_ROM extern const Word16 CLDFB80_10_fx[100]; // Q15 extern const Word16 CLDFB80_16_fx[160]; // Q15 extern const Word16 CLDFB80_20_fx[200]; // Q15 @@ -87,6 +87,25 @@ extern const Word16 LDQMF_30_fx[300]; // Q15 extern const Word16 LDQMF_32_fx[320]; // Q15 extern const Word16 LDQMF_40_fx[400]; // Q15 extern const Word16 LDQMF_60_fx[600]; // Q15 +#else /* OPT_IVAS_FILTER_ROM */ + +extern const Word32 CLDFB80_10_fx[100]; // Q30 +extern const Word32 CLDFB80_16_fx[160]; // Q30 +extern const Word32 CLDFB80_20_fx[200]; // Q30 +extern const Word32 CLDFB80_30_fx[300]; // Q30 +extern const Word32 CLDFB80_32_fx[320]; // Q30 +extern const Word32 CLDFB80_40_fx[400]; // Q30 +extern const Word32 CLDFB80_60_fx[600]; // Q30 + +/*5ms delay*/ +extern const Word32 LDQMF_10_fx[100]; // Q30 +extern const Word32 LDQMF_16_fx[160]; // Q30 +extern const Word32 LDQMF_20_fx[200]; // Q30 +extern const Word32 LDQMF_30_fx[300]; // Q30 +extern const Word32 LDQMF_32_fx[320]; // Q30 +extern const Word32 LDQMF_40_fx[400]; // Q30 +extern const Word32 LDQMF_60_fx[600]; // Q30 +#endif /* OPT_IVAS_FILTER_ROM */ /* Not used anywhere extern const Word16 LDQMF_10_enc_fx[100]; extern const Word16 LDQMF_16_enc_fx[160]; diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 2ce2ffd12b8aad3cf41c48a53bfb7c253b1ee80b..168a96011ce4b8e8affb9cc6a16d3b900b946526 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -307,12 +307,10 @@ void scale_sig32( /* saturation can occur here */ x[i] = L_shl( x[i], exp0 ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 if ( 0 == exp0 ) { i = lg; } -#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -329,12 +327,10 @@ void scale_sig32_r( /* saturation can occur here */ x[i] = L_shl_r( x[i], exp0 ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 if ( 0 == exp0 ) { i = lg; } -#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index e5081d2be6bc7d1650a88dbc1b23ab2394a9840a..506d2d1cd7b828ecfbe8d863db3973f0646d87b9 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -619,8 +619,11 @@ typedef struct cldfb_filter_bank_struct Word16 da; /* delay analysis */ CLDFB_PROTOTYPE prototype; const Word16 *p_filter; /*!< Pointer to filter coefficients */ // Q15 - Word16 p_filter_sf; // Q0 - +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *p_filter_32; /*!< Pointer to filter coefficients */ // Q15 +#else /* OPT_IVAS_FILTER_ROM */ + Word16 p_filter_sf; // Q0 +#endif /* OPT_IVAS_FILTER_ROM */ /* rotation vectors */ const Word32 *rot_vec_syn_re_fx; // Q29 diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 11da78c46f06cf04a6895050c706e53824225711..8b134e5d63591a710ca01b80c2999e722c276c0d 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -241,14 +241,26 @@ Word16 WB_BWE_gain_pred_fx( tmp = extract_l( L_tmp ); enerL = L_deposit_l( enerL_16 ); - enerL = L_shl( enerL, 6 ); /*Q6 */ + enerL = L_shl( enerL, 6 ); /*Q6 */ +#ifdef FIX_ISSUE_1795_Q3_OVERFLOW + /* Here, we do not multiply L_tmp by 3 to avoid overflow */ + L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ +#else + /* Here, we have not enough headroom for mult with 3, so we get some overflow */ tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ L_tmp = L_mult0( tmp1, WB_fenv[0] ); /*Q6 */ +#endif test(); test(); test(); +#ifdef FIX_ISSUE_1795_Q3_OVERFLOW +#define ONE_DIV_3 ( (Word32) 0x2AAAAAAA ) + /* Here, L_tmp is not pre-multiplied with 3, we multiply enerL with 1/3 */ + IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( Mpy_32_32( ONE_DIV_3, enerL ), L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) +#else IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( enerL, L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) +#endif { env_var_flag = 1; move16(); diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e4d84ef23c38a6584b694485cb3082d43667ff37..2ca52b8e4f673b1f486b85d3b052a3793736131a 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6368,15 +6368,9 @@ void wb_tbe_extras_reset_synth_fx( *-------------------------------------------------------------------*/ void elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 const int16_t element_mode, -#endif -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ -#else - const Word16 input_fx[], /* i : input signal Q_input_fx*/ -#endif Word16 *Q_input_fx, Word16 output_fx[], /* o : output signal memory_fx_Q */ Word32 memory_fx2[][4], /* i/o: 4 arrays of 4 for memory */ @@ -6385,27 +6379,18 @@ void elliptic_bpf_48k_generic_fx( ) { Word16 i, j; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 memory_fx0, Q_temp, Q_temp2; Word32 L_tmp_buffer[L_FRAME48k + 4], L_tmp2_buffer[L_FRAME48k + 4], L_output_buffer[L_FRAME48k + 4], L_tmpX; Word32 L_tmpMax; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 Word64 W_tmpX; Word64 W_tmpY; -#endif Word32 *L_tmp = &L_tmp_buffer[4]; Word32 *L_tmp2 = &L_tmp2_buffer[4]; Word32 *L_output = &L_output_buffer[4]; -#else - Word16 memory_fx0[4][4], memory_fx[4][4], Q_temp, Q_temp2; - Word32 L_tmp[L_FRAME48k], L_tmp2[L_FRAME48k], L_output[L_FRAME48k], L_tmpX, memory2_fx[4][4], L_tmpMax; - Word32 memory2_fx_2[4], memory2_fx_3[4]; -#endif FOR( i = 0; i < 4; i++ ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic memory_fx0 = extract_l( memory_fx2[0][i] ); input_fx[i - 4] = shl_sat( memory_fx0, sub( *Q_input_fx, memory_fx_Q[0] ) ); L_tmp[i - 4] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); @@ -6416,24 +6401,11 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); -#else - memory_fx0[0][i] = extract_l( memory_fx2[0][i] ); - memory_fx[0][i] = shl_sat( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) ); - memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); - memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) ); - move32(); - move32(); - move32(); - move32(); - move32(); -#endif } -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); IF( !IsUpsampled3 ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6453,7 +6425,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6472,7 +6443,6 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ ELSE { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; ) @@ -6508,7 +6478,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; ) { @@ -6542,63 +6511,6 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( L_mult( memory_fx[0][0], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - - L_tmpX = L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - - L_tmpX = L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - L_tmpX = L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[3], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[2], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( L_mult( input_fx[i - 4], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - } -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ memory_fx2[0][0] = input_fx[L_FRAME48k - 4]; memory_fx2[0][1] = input_fx[L_FRAME48k - 3]; @@ -6610,9 +6522,7 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6632,7 +6542,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6649,66 +6558,6 @@ void elliptic_bpf_48k_generic_fx( L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) ); } } -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmp2[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][0], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - move32(); - L_tmpMax = L_abs( L_tmp2[0] ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[1] ) ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[2] ) ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[3], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[2], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ /*14 + Q_input_fx - shift_flag*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[3] ) ); - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmp2[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) ); - } -#endif Q_temp = norm_l( L_tmpMax ); @@ -6724,7 +6573,6 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic FOR( j = 0; j < 4; j++ ) { L_tmp2[j - 4] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); @@ -6733,19 +6581,7 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); } -#else - FOR( j = 0; j < 4; j++ ) - { - memory2_fx_2[j] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); - memory2_fx_3[j] = L_shl_sat( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) ); - move32(); - move32(); - move32(); - } -#endif -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6765,7 +6601,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6786,73 +6621,6 @@ void elliptic_bpf_48k_generic_fx( } } -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_output[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[0], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - move32(); - L_tmpMax = L_abs( L_output[0] ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx+Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_output[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[1] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1+Q_temp +13 -15 + 2*/ - L_output[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[2] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[3], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[2], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_output[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[3] ) ); - - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_output[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 4], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) ); - } -#endif memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4]; memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3]; @@ -6917,20 +6685,12 @@ void synthesise_fb_high_band_fx( Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], - Word16 Qout -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 - , - int16_t element_mode -#endif -) + Word16 Qout, + int16_t element_mode ) { Word16 i, j; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 excitation_in_interp3_buffer[L_FRAME48k + 4]; Word16 *excitation_in_interp3 = &excitation_in_interp3_buffer[0] + 4; -#else - Word16 excitation_in_interp3[L_FRAME48k]; -#endif Word16 tmp[L_FRAME48k]; Word32 temp1; Word32 ratio2; @@ -6955,33 +6715,22 @@ void synthesise_fb_high_band_fx( IF( EQ_16( L_frame, L_FRAME16k ) ) { /* for 16kHz ACELP core */ -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 element_mode, -#endif 1, // IsUpsampled3 excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx ); -#else - elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx ); -#endif } ELSE { /* for 12.8kHz ACELP core */ -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 element_mode, -#endif 1, // IsUpsampled3 excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); -#else - elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); -#endif } + /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/ @@ -6990,9 +6739,33 @@ void synthesise_fb_high_band_fx( tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/ exp = sub( sub( 31, tmp1 ), exp ); - exp2 = norm_l( temp1 ); - tmp2 = extract_h( L_shl( temp1, exp2 ) ); - exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + IF( element_mode != EVS_MONO ) + { + Word16 sft, t_Q; + Word64 P_ONE = 33; /* 0.001f in Q15 */ + move64(); + Word64 W_temp; + + t_Q = sub( shl( exp_tmp, 1 ), 8 ); + P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); + + W_temp = W_add( P_ONE, temp1 ); + + sft = W_norm( W_temp ); + W_temp = W_shl( W_temp, sft ); + + temp1 = W_extract_h( W_temp ); + t_Q = sub( add( t_Q, sft ), 32 ); + + tmp2 = extract_h( temp1 ); + exp2 = sub( 31, t_Q ); + } + ELSE + { + exp2 = norm_l( temp1 ); + tmp2 = extract_h( L_shl( temp1, exp2 ) ); + exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + } exp = sub( exp2, exp ); /* Denormalize and substract */ IF( GT_16( tmp2, tmp3 ) ) @@ -7304,7 +7077,7 @@ void prep_tbe_exc_fx( FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ ) { L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ - L_tmp = L_shl( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ + L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q9 + Q_exc + Q6*/ L_tmp = L_mac_o( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC], &Overflow ); /*Q15+Q_exc */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index ada0d243ea88b7c08fdb6ac8bd5d8720f9eb7f8f..1216c4533f0955530ca6612e47f70007bf0d6dd4 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -188,14 +188,20 @@ void syn_filt_fx( Word16 *yy; Word32 s; Word16 q; +#ifndef ISSUE_1772_replace_shr_o Flag Overflow = 0; move16(); +#endif Word16 a0; yy = &buf[0]; q = add( norm_s( a[0] ), 1 ); +#ifdef ISSUE_1772_replace_shr_o + a0 = shr_sat( a[0], shift ); /* input / 2^shift */ +#else a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ +#endif /*------------------------------------------------------------------* * copy initial filter states into synthesis buffer and do synthesis @@ -373,7 +379,11 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W *-----------------------------------------------------------------------*/ mem += m; /*move16();*/ +#ifdef ISSUE_1772_replace_shr_o + a0 = shr_sat( a[0], shift ); /* input / 2^shift */ +#else a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ +#endif /*-----------------------------------------------------------------------* * Do the filtering *-----------------------------------------------------------------------*/ diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 5e18430be5631649c80cbd2524996ee7f008a419..376e2813d42810a86cec254f518d4812573c85a6 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1207,17 +1207,26 @@ static Word32 FIRLattice( move32(); FOR( i = 0; i < order - 1; i++ ) { - tmp = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) ); /*Q0*/ - x = L_add( x, Mpy_32_16_1( state[i], parCoeff[i] ) ); /* exponent: 31+0 */ - state[i] = tmpSave; /*Q0*/ +#ifdef OPT_MCT_ENC_V1_BE + tmp = Madd_32_16( state[i], x, parCoeff[i] ); /*Q0*/ + x = Madd_32_16( x, state[i], parCoeff[i] ); /* exponent: 31+0 */ +#else + tmp = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) ); /*Q0*/ + x = L_add( x, Mpy_32_16_1( state[i], parCoeff[i] ) ); /* exponent: 31+0 */ +#endif + state[i] = tmpSave; /*Q0*/ move32(); tmpSave = tmp; /*Q0*/ move32(); } /* last stage: only need half operations */ +#ifdef OPT_MCT_ENC_V1_BE + x = Madd_32_16( x, state[order - 1], parCoeff[order - 1] ); /*Q0*/ +#else x = L_add( x, Mpy_32_16_1( state[order - 1], parCoeff[order - 1] ) ); /*Q0*/ - state[order - 1] = tmpSave; /*Q0*/ +#endif + state[order - 1] = tmpSave; /*Q0*/ move32(); return x; /*Q0*/ diff --git a/lib_com/tools.c b/lib_com/tools.c index 69f26350393e9eaf022c151c3009f8fb069ad663..61c489157bec7dcee3b108220b23b6b134ad0c57 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -687,7 +687,11 @@ Word32 dotp_fixed_o( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); @@ -717,7 +721,11 @@ Word32 dotp_fixed_32( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); @@ -776,7 +784,6 @@ void v_sub_fixed( return; } -#ifdef VEC_ARITH_OPT_v1 void v_sub_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -794,7 +801,6 @@ void v_sub_fixed_no_hdrm( return; } -#endif /* VEC_ARITH_OPT_v1 */ /*-------------------------------------------------------------------* * v_multc_fixed() diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 8e803051d8dc674f0158098f03859a44a581ae72..5b9cc52d773fec6cfe31a432e5192eb7b08874be 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -798,7 +798,6 @@ void Copy_Scale_sig_16_32_no_sat( } return; } -#ifdef FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); IF( L_tmp >= 0x7FFF ) @@ -820,15 +819,6 @@ void Copy_Scale_sig_16_32_no_sat( move32(); } } -#else - L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); - FOR( i = 0; i < lg; i++ ) - { - // y[i] = L_mult0(x[i], L_tmp); - y[i] = W_extract_l( W_mult_32_16( L_tmp, x[i] ) ); - move32(); /* Overflow can occur here */ - } -#endif } void Copy_Scale_sig_32_16( @@ -3134,7 +3124,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( x1[i], shr_r_sat( x2[i], Qyx2 ), &Overflow ); +#else y[i] = add_o( x1[i], shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } @@ -3142,7 +3136,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_r_sat( x2[i], Qyx2 ), &Overflow ); +#else y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } @@ -4580,7 +4578,6 @@ void v_add_fixed( return; } -#ifdef VEC_ARITH_OPT_v1 void v_add_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -4598,7 +4595,6 @@ void v_add_fixed_no_hdrm( return; } -#endif /* VEC_ARITH_OPT_v1 */ void v_add_fixed_me( const Word32 x1[], /* i : Input vector 1 */ diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 0683e266ce67faea01f2768f6b51a98bd56f3ab4..36678487a263a9b9737b86959583bc4456ec0a83 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -84,9 +84,7 @@ void preecho_sb_fx( UWord16 tmp_u16; Word32 mean_prev_hb_fx_loc, mean_prev_nc_fx_loc, mean_prev_fx_loc; /* */ Word16 q16p1, qmemp1, qtmp; -#ifdef OPT_STEREO_32KBPS_V1 Word16 shift_q = sub( 15, q_sig32 ); -#endif /* OPT_STEREO_32KBPS_V1 */ q16p1 = add( q_sig16, 1 ); qmemp1 = q16p1; @@ -139,7 +137,6 @@ void preecho_sb_fx( /* len3xLp20 = framelength/2-(short)((float)framelength*N_ZERO_MDCT/FRAME_SIZE_MS); in float*/ fxptr1 = imdct_mem_fx; -#ifdef OPT_STEREO_32KBPS_V1 FOR( i = 0; i < len3xLp20; i++ ) { *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[len3xLp20 - 1 - i], shift_q ) ) ); /*Q-1*/ @@ -150,19 +147,6 @@ void preecho_sb_fx( *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], shift_q ) ) ); /*Q-1*/ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } -#else /* OPT_STEREO_32KBPS_V1 */ - fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/ - FOR( i = 0; i < len3xLp20; i++ ) - { - *fxptr1++ = negate( extract_h( L_shl_sat( *fx32ptr1--, sub( 15, q_sig32 ) ) ) ); /*Q-1*/ - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ - } - FOR( i = 0; i < L_shr( framelength, 1 ); i++ ) - { - *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/ - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ - } -#endif /* OPT_STEREO_32KBPS_V1 */ qmemp1 = 0; /*already in q-1*/ move16(); @@ -408,7 +392,6 @@ void preecho_sb_fx( move16(); FOR( i = 1; i <= NUMSF; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 max_es_hb_fx = L_max( max_es_hb_fx, es_mdct_hb_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ max_es_fx = L_max( max_es_fx, es_mdct_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ @@ -418,19 +401,6 @@ void preecho_sb_fx( maxind = i; move16(); } -#else /* OPT_STEREO_32KBPS_V1 */ - IF( GE_32( es_mdct_hb_fx[i], max_es_hb_fx ) ) /* '=' to handle the first window*/ - { - max_es_hb_fx = L_add( es_mdct_hb_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ - } - - IF( GE_32( es_mdct_fx[i], max_es_fx ) ) /* '=' to handle the first window*/ - { - max_es_fx = L_add( es_mdct_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ - maxind = i; - move16(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ } cnt2 = cnt5 = 0; diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index cc03dcf525f424e500118ee9f8d2362c74ebedd3..40e26df9c1d6c2348031ad11bbb9133df9cda173 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -638,7 +638,11 @@ void ivas_HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1772_replace_shr_o + *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -924,7 +928,11 @@ void HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1772_replace_shr_o + *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index ad2f8607311a94fdc8a81ec9955dd2e16e97bb04..4be003ecb8a24d8e5101fe4450e65a6729237a76 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1164,9 +1164,11 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 y1, y2, y3, man, expo, edge; const Word16 *pY; Word32 numer, denom, sign, acc, y3_y1; +#ifndef ISSUE_1772_replace_shr_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Seek the extremum of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */ @@ -1200,9 +1202,13 @@ static Word16 imax_fx( /* o: The location, relative to the } /* Although the output of ratio() is in Q14, adding the missing factor of 2 (See above) * in the denominator, the output is now considered to be in Q15. */ - man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ + man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ +#ifdef ISSUE_1772_replace_shr_o + posi = shr_sat( man, expo ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ +#else posi = shr_o( man, expo, &Overflow ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ - if ( sign < 0 ) /* Restore the sign. */ +#endif + if ( sign < 0 ) /* Restore the sign. */ { posi = negate( posi ); } @@ -1434,7 +1440,7 @@ static void ivas_spec_ana_fx( man = mult_r( man, FEC_HQ_ECU_ROOT2 ); /* FEC_HQ_ECU_ROOT2 is sqrt(2) in Q14 */ expoBy2 = sub( expoBy2, 1 ); } - *pXfp++ = shr( man, expoBy2 ); + *pXfp++ = shr_sat( man, expoBy2 ); move16(); /* Denormalize the mantissa back to Q0. */ } } @@ -2132,7 +2138,7 @@ static void ivas_subst_spec_fx( move16(); im = *pImX; move16(); - tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) ); + tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) ); IF( LT_16( alpha[k], 32766 ) ) { diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 847e165948ea8d866449541728ebb0f39ddbdd81..a05304d8a7e19d71dea45252b3488f44a7a87970 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -62,18 +62,18 @@ ivas_error acelp_core_dec_fx( Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/ const Word16 sharpFlag, /* i : formant sharpening flag */ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ + Word16 *unbits, /* o : number of unused bits */ + Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/ const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/ const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ + const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ + const Word16 last_element_mode, /* i : last element mode */ + const Word32 last_element_brate, /* i : last element bitrate */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 nchan_out, /* i : number of output channels */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const Word16 read_sid_info /* i : read SID info flag */ ) { Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; @@ -2042,15 +2042,6 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) -#endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2070,18 +2061,8 @@ ivas_error acelp_core_dec_fx( } } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2093,21 +2074,8 @@ ivas_error acelp_core_dec_fx( move32(); } } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -2131,19 +2099,11 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; @@ -2224,26 +2184,9 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + IF( st->p_bpf_noise_buf_32 ) { Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index b126823858db562e01e384e307083c48888e3d2d..109f360cb63a30f8544bb6b14b33c2db62f14380 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -832,25 +832,10 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, 1 ); // Q_cldfb_state+1 - st_fx->cldfbSyn->Q_cldfb_state = add( st_fx->cldfbSyn->Q_cldfb_state, 1 ); - move16(); - Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ - - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), 0, st_fx->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1 - st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); - move16(); - Copy_Scale_sig_32_16( synth32, synth_out, L_FRAME48k, -5 ); // 11-5-1 -> 11 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index eb34e1bc1e4ad06bdf2fa06d34dfe06806550b3e..d5a1dfeb067483b3dcb6849dd94d8453386bad3e 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -396,8 +396,15 @@ void open_decoder_LPD_fx( move16(); Copy( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ) ); /* hHQ_core->Q_fer_samples*/ - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_OverlFB = hHQ_core->Q_fer_samples; + move16(); +#endif lerp( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( hTcxDec->L_frameTCX, 1 ) ); /*Q0: ACELP(bfi)->TCX(rect)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hHQ_core->Q_fer_samples; + move16(); +#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ hHQ_core->Q_old_wtda = -1; @@ -1069,8 +1076,16 @@ void acelp_plc_mdct_transition_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); move16(); /*CLDFB delay*/ - Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ + Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_OverlFB = st->hHQ_core->Q_fer_samples; + move16(); +#endif lerp( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( st->hTcxDec->L_frameTCX, 1 ) ); /*ACELP(bfi)->TCX(rect)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_Overl = st->hHQ_core->Q_fer_samples; + move16(); +#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ st->hHQ_core->Q_old_wtda = -1; move16(); @@ -2090,6 +2105,11 @@ void reset_tcx_overl_buf_fx( set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#endif set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl_TDACFB = 0; move16(); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ba7c73741751664b8b8545bcdb85a0d66fc6f557..106cb0e607d8e70d73cb89197d08eef43658344c 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2056,11 +2056,7 @@ static void core_switch_lb_upsamp_fx( } /* synthesis of the combined signal */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ /*rescaling whole buffer to a common Q*/ no_col = st->cldfbSyn->no_col; @@ -2368,11 +2364,7 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ cldfb_restore_memory_ivas_fx( st->cldfbSyn ); Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 9c366e3f3190c2138e9940a69e30a447609a0d1f..edc429459e1a613dacdfefa6a0bf8b55c16b276f 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -690,6 +690,10 @@ void decoder_acelp_fx( E_UTIL_deemph2( st->Q_syn, syn, st->preemph_fac, st->L_frame, &tmp_deemph ); /* tmp_deemph and syn in Q0 starting from here*/ bufferCopyFx( syn + shr( st->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); + move16(); +#endif Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /*Q0*/ diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 51cbef624c6ea7d74e2a0b70cd7c4e6727ef2ba8..e7f8c98ce7332dc3283ce290c5851eca31e78850 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -169,20 +169,9 @@ void D_ACELP_indexing_fx( pulses = pulsestrack[0]; move16(); -#ifndef FIX_1378_ACELP_OUT_OF_BOUNDS - /* safety check in case of bit errors */ - IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) - { - set16_fx( code, 0, L_SUBFR ); - *BER_detect = 1; - move16(); - return; - } -#endif IF( pulses ) { -#ifdef FIX_1378_ACELP_OUT_OF_BOUNDS /* safety check in case of bit errors */ IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) { @@ -191,7 +180,6 @@ void D_ACELP_indexing_fx( move16(); return; } -#endif D_ACELP_decode_arithtrack_fx( code, s, pulses, num_tracks, 16 ); } ELSE diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 14d9d1772700242840bc8cbfb1bc39769d9d08bf..a58cd19c9c7e75572e5fbb6bd30a988817d7204d 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -106,10 +106,6 @@ ivas_error decod_gen_voic_fx( gain_inov_fx = 0; error_fx = 0; gain_preQ_fx = 0; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif move16(); move32(); move32(); @@ -467,11 +463,20 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); +#ifdef ISSUE_1751_replace_shl_ro + IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#else + Flag Overflow; IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 8e8a2b34368a34a551c8940955044ae3d9813674..8009c69e011123ec9161741f2c1d18379e427e18 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2572,12 +2572,394 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + +static Word16 IMDCT_ivas_fx_calc_qwin( + Decoder_State *st, + Word16 *syn_Overl_TDAC, + Word16 Q_syn_Overl_TDAC, + Word16 *syn_Overl, + Word16 Q_syn_Overl, + Word16 *old_syn_Overl, + Word16 Q_old_syn_Overl, + Word16 *old_out_fx, + Word16 Q_old_out_fx, + Word16 q_win, + const Word16 FB_flag ) +{ + Word16 t, old_syn_Overl_len, syn_Overl_TDAC_len; + + t = L_FRAME32k; + move16(); + if ( FB_flag ) + { + t = L_FRAME48k; + move16(); + } + + old_syn_Overl_len = st->hTcxCfg->tcx_mdct_window_length; + syn_Overl_TDAC_len = s_max( st->hTcxCfg->tcx_mdct_window_length_old, 0 ); + + IF( ( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) ) || EQ_16( st->last_core, ACELP_CORE ) ) + { + old_syn_Overl_len = shr( st->L_frame, 1 ); + syn_Overl_TDAC_len = shr( st->last_L_frame, 1 ); + } + + IF( st->prev_bfi && ( st->last_core_bfi == ACELP_CORE ) ) + { + syn_Overl_TDAC_len = old_syn_Overl_len; + } + + q_win = 6; + move16(); + + // q_win == norm + Q_syn_Overl_TDAC + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ) + Q_syn_Overl_TDAC ); + + // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, old_syn_Overl_len ) + Q_syn_Overl ); + + q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); + + // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); + q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); + +#if 0 + set16_zero_fx(syn_Overl_TDAC + oldLength / 2, (t-oldLength)/2 ); + //set16_zero_fx(syn_Overl + oldLength / 2, (t-oldLength)/2 ); + set16_zero_fx(old_syn_Overl + oldLength / 2, (t-oldLength)/2 ); + //set16_zero_fx(old_out_fx + oldLength, (t-oldLength) ); +#endif + q_win = s_max( -3, sub( q_win, 2 ) ); + + return q_win; +} + +static void IMDCT_ivas_fx_rescale( + Word16 *xn_buf_fx, + Word16 *q_xn_buf_fx, + Word16 *syn_Overl_TDAC, + Word16 *Q_syn_Overl_TDAC, + Word16 *syn_Overl, + Word16 *Q_syn_Overl, + Word16 *old_syn_Overl, + Word16 *Q_old_syn_Overl, + Word16 *old_out_fx, + Word16 *Q_old_out_fx, + Word16 q_win, + const Word16 FB_flag ) +{ + Word16 oldLength; + + oldLength = L_FRAME32k; + move16(); + if ( FB_flag ) + { + oldLength = L_FRAME48k; + move16(); + } + +#if 1 + IF( xn_buf_fx != NULL ) + { + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( q_win, *q_xn_buf_fx ) ); + *q_xn_buf_fx = q_win; + move16(); + } + Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + *Q_syn_Overl_TDAC = q_win; + move16(); + Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win + *Q_syn_Overl = q_win; + move16(); + if ( FB_flag == 0 ) + { + Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + *Q_old_syn_Overl = q_win; + move16(); + } + Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_out_fx ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + *Q_old_out_fx = q_win; + move16(); +#endif +} + +static Word16 TCX_MDCT_Inverse_GetScaleFactor( + const Word16 L, /* Q0 */ + Word16 *factor_e /* Q0 */ +) +{ + + Word16 factor; + + IF( EQ_16( L, NORM_MDCT_FACTOR ) ) + { + factor = 32767; + move16(); + *factor_e = 0; + move16(); + } + ELSE IF( EQ_16( L, 2 * NORM_MDCT_FACTOR ) ) + { + factor = 23170; + move16(); + *factor_e = 1; + move16(); + } + ELSE IF( EQ_16( L, 4 * NORM_MDCT_FACTOR ) ) + { + factor = 32767; + move16(); + *factor_e = 1; + move16(); + } + ELSE + { + factor = mult_r( shl( L, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR*/ ); /* 4Q11 */ + *factor_e = 4; + move16(); + + factor = Sqrt16( factor, factor_e ); + } + + return factor; +} + +static void TCX_MDCT_Inverse_qwin_fx( + Word32 *x, // Q( 31 - x_e ) + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode, /* Q0 */ + Word16 *q_win, + Word16 allow_qwin_change ) +{ + + Word16 i, fac, negfac, s; + Word16 L2 = l, R2 = r; + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 fac_e; + (void) element_mode; + L2 = shr( l, 1 ); + R2 = shr( r, 1 ); + + x_e = sub( 15, x_e ); + edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); + x_e = sub( 15, x_e ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); /* exp(fac_e) */ + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + + IF( allow_qwin_change ) + { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); + *q_win = s_min( sub( s, x_e ), *q_win ); + } + + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + + move16(); + } + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + Word16 f; + + f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + y[l + m + R2 - 1 - i] = f; + move16(); + } +} + +static void TCX_MDST_Inverse_qwin_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + Word16 *q_win, + Word16 allow_qwin_change ) +{ + + Word16 i, fac, negfac, s; + Word16 L2 = l, R2 = r; + move16(); + move16(); + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 fac_e; + + L2 = shr( l, 1 ); + R2 = shr( r, 1 ); + + x_e = sub( 15, x_e ); + edst_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); + x_e = sub( 15, x_e ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + + IF( allow_qwin_change ) + { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); + *q_win = s_min( sub( s, x_e ), *q_win ); + } + + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + Word16 f; + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + + y[l + m + R2 - 1 - i] = negate( f ); + move16(); + } +} + +/*-------------------------------------------------------------------* + * TCX_MDXT_Inverse_fx() + * + * + *-------------------------------------------------------------------*/ +static void TCX_MDXT_Inverse_qwin_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type, /* Q0 */ + Word16 *q_win, + Word16 allow_qwin_change ) +{ + Word16 signLeft; + Word16 signRight; + Word16 i, fac, negfac, s, fac_e; + const Word16 L2 = shr( l, 1 ), R2 = shr( r, 1 ); + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 f; + + set32_fx( tmp_buf, 0, N_MAX + L_MDCT_OVLP_MAX / 2 ); + + edxt_fx( x, tmp_buf + L2, add( add( L2, m ), R2 ), kernel_type, TRUE ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + IF( GE_16( kernel_type, MDCT_II ) ) + { + signLeft = negfac; + } + ELSE + { + signLeft = fac; + } + // signRight = ( kernel_type & 1 ? fac : negfac ); + IF( L_and( kernel_type, 1 ) ) + { + signRight = fac; + } + ELSE + { + signRight = negfac; + } + + IF( allow_qwin_change ) + { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); + *q_win = s_min( sub( s, x_e ), *q_win ); + } + + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ + } + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + + y[l + m + R2 - 1 - i] = f; + move16(); + } + + return; +} +#endif + void IMDCT_ivas_fx( Word32 *x_fx, // Q(q_x) Word16 q_x, - Word16 *old_syn_overl_fx, // Q(-2) - Word16 *syn_Overl_TDAC_fx, // Q(-2) - Word16 *xn_buf_fx, // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *old_syn_overl_fx, // *Q_old_syn_overl_fx + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, // *Q_syn_Overl_TDAC_fx + Word16 *Q_syn_Overl_TDAC_fx, +#else + Word16 *old_syn_overl_fx, // Q(-2) + Word16 *syn_Overl_TDAC_fx, // Q(-2) +#endif + Word16 *xn_buf_fx, // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_xn_buf_fx, +#endif const Word16 *tcx_aldo_window_1_fx, // Q(15) const PWord16 *tcx_aldo_window_1_trunc_fx, // Q(15) const PWord16 *tcx_aldo_window_2_fx, // Q(15) @@ -2598,11 +2980,19 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Word16 *q_old_out_fx, +#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, - Word16 q_win ) // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_acelp_zir_fx, + Word16 *pq_win ) +#else + Word16 q_win ) // Q(-2) +#endif { Word16 i, nz, aldo, w, L_win, L_ola; Word16 win_fx[( L_FRAME_PLUS + L_MDCT_OVLP_MAX ) / 2]; @@ -2611,7 +3001,27 @@ void IMDCT_ivas_fx( Word16 x_e_hdrm; Word32 c; Word16 exp; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win = *pq_win; + Word16 allow_qwin_change = 1; + move16(); + move16(); + x_e_hdrm = sub( Q16, q_x ); +#if 0 + IF( *pq_win == 0 ) + { + allow_qwin_change = 0; + } +#endif + IF( allow_qwin_change ) + { + // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); + q_win = IMDCT_ivas_fx_calc_qwin( st, syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, + hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, FB_flag ); + } +#else x_e_hdrm = add( q_win, sub( Q16, q_x ) ); +#endif aldo = 0; move16(); @@ -2692,11 +3102,41 @@ void IMDCT_ivas_fx( Word16 L_spec_TCX5_tmp = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change ) + { + /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ + q_win = -2; + move16(); + allow_qwin_change = 0; + move16(); + } +#endif + FOR( w = 0; w < 2; w++ ) { test(); test(); L_spec_TCX5_tmp = imult1616( w, L_spec_TCX5 ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + // Assume that xn_buf_fx has no headroom. + q_win = s_min( q_xn_buf_fx, q_win ); + + IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); + } + ELSE IF( ( kernel_type != 0 ) && ( w == 0 ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, kernel_type, &q_win, allow_qwin_change ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); + } + + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); @@ -2709,6 +3149,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); } +#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); @@ -2747,6 +3188,38 @@ void IMDCT_ivas_fx( set16_fx( win_fx, 0, shr( add( L_FRAME_PLUS, L_MDCT_OVLP_MAX ), 1 ) ); /* 1st TCX-5 window, special MDCT with minimum overlap on right side */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win_prev; + +#if 0 + // Assume that xn_buf_fx has no headroom. + q_win = s_min( q_xn_buf_fx, q_win ); +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change ) + { + /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ + q_win = -2; + move16(); + allow_qwin_change = 0; + move16(); + } +#endif + + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, &q_win, allow_qwin_change ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, kernel_type, &q_win, allow_qwin_change ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode, &q_win, allow_qwin_change ); + } + q_win_prev = q_win; +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola ); @@ -2759,12 +3232,31 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode ); } +#endif set16_fx( xn_buf_fx, 0, shr( overlap, 1 ) ); /* copy new sub-window region not overlapping with previous window */ Copy( win_fx + L_win, xn_buf_fx + shr( overlap, 1 ), add( L_win, shr( L_ola, 1 ) ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + q_xn_buf_fx = q_win; + move16(); + + /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ + IF( s_and( kernel_type, 1 ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); + } + + assert( q_win_prev == q_win ); + + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ IF( s_and( kernel_type, 1 ) ) { @@ -2774,6 +3266,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); } +#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, 0, /* left_rect */ MIN_OVERLAP, /* left_mode */ acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, ( tcx_offset < 0 ) ? -tcx_offset : 0, 1, /* st->last_mode_bfi */ 0, /* st->last_is_cng */ fullbandScale ); @@ -2808,6 +3301,30 @@ void IMDCT_ivas_fx( ELSE { /* default, i.e. maximum overlap, single transform, no grouping */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change && fullbandScale ) + { + q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); + } + + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, &q_win, allow_qwin_change ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, kernel_type, &q_win, allow_qwin_change ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win, allow_qwin_change ); + } + // Because xn_buf_fx is overwritten above. + q_xn_buf_fx = q_win; + move16(); + + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap ); @@ -2820,7 +3337,18 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); } +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( !fullbandScale ) + { + *q_acelp_zir_fx = q_xn_buf_fx; + } + ELSE + { + scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); + } +#endif tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && NE_16( st->last_core, ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), ( tcx_offset < 0 ) ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); } /* tcx_last_overlap_mode != FULL_OVERLAP */ @@ -2865,10 +3393,30 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = q_xn_buf_fx_32; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + // q_win < norm + q_tmp_fx_32 - 16 + q_win = s_min( q_win, L_norm_arr( tmp_fx_32, L_frame ) + q_tmp_fx_32 - 16 ); + IMDCT_ivas_fx_rescale( NULL, NULL, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#endif + Word16 diff = sub( q_tmp_fx_32, q_win ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); + IF( q_old_out_diff < 0 ) + { + Scale_sig( old_out_fx, L_frame, q_old_out_diff ); + *q_old_out_fx = add( *q_old_out_fx, q_old_out_diff ); + q_old_out_diff = 0; + } +#endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + assert( L_shr( L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); + old_out_fx_32[ind] = L_shl( L_deposit_l( old_out_fx[ind] ), q_old_out_diff ); +#else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); +#endif move32(); } @@ -2876,7 +3424,14 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == -1 ); + old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); +#else + assert( extract_h( L_shr( old_out_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], diff ) ) == -1 ); old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); +#endif + assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == -1 ); xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); move16(); move16(); @@ -2884,9 +3439,11 @@ void IMDCT_ivas_fx( } ELSE { +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out = q_win; move16(); - edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); +#endif + edct_ivas_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); Word16 res_m, res_e; res_e = 0; move16(); @@ -2901,22 +3458,53 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e ); // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + if ( allow_qwin_change ) + { + // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) + // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) + // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 +#ifdef FIX_1802 + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), sub( L_norm_arr( xn_buf_fx_32 + ( overlap / 2 ) + nz, L_frame ), 2 ) ) ); +#else + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); +#endif + } + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#endif + Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { + assert( extract_h( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ) == -1 ); xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = extract_l( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ); move16(); } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, q_old_out_fx, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); +#else window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, &q_old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); q_diff = sub( q_old_out, q_win ); - +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + if ( allow_qwin_change ) + { + // sub( q_tmp_fx_32, q_win ) == -norm_arr( xn_buf_fx, L_frame ) + // q_tmp_fx_32 - q_win == -norm_arr( xn_buf_fx, L_frame ) + // q_win == q_tmp_fx_32 + norm_arr( xn_buf_fx, L_frame ) + q_win = s_min( q_win, add( q_tmp_fx_32, norm_arr( xn_buf_fx, L_frame ) ) ); + } +#endif Word16 diff = sub( q_tmp_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); move16(); +#endif xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); move16(); } @@ -2939,6 +3527,40 @@ void IMDCT_ivas_fx( move16(); } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change && fullbandScale ) + { + q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); + } + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || st->last_core == ACELP_CORE ) && ( fullbandScale == 0 ) ) + { + /* Increase headroom because if the ACELP ZIR is used below, the synthesis filter gain is unknown. */ + IF( allow_qwin_change ) + { + allow_qwin_change = 0; + move16(); + q_win = s_max( -2, sub( q_win, 1 ) ); + } + } + + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, &q_win, allow_qwin_change ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, kernel_type, &q_win, allow_qwin_change ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win, allow_qwin_change ); + } + // Because xn_buf_fx is overwritten above. + q_xn_buf_fx = q_win; + move16(); + + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap ); @@ -2951,7 +3573,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode ); } - +#endif /*-----------------------------------------------------------* * Windowing, overlap and add * *-----------------------------------------------------------*/ @@ -2983,7 +3605,16 @@ void IMDCT_ivas_fx( move16(); } } - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( !fullbandScale ) + { + *q_acelp_zir_fx = q_xn_buf_fx; + } + ELSE + { + scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); + } +#endif /* Window current frame */ tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), acelp_mem_len, st->last_core_bfi, (Word8) st->last_is_cng, fullbandScale ); } @@ -3008,9 +3639,18 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + Word16 tmp_old_out; + Word16 q_diff = sub( *q_old_out_fx, q_win ); +#endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // q_win +#else + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) +#endif move16(); } @@ -3023,17 +3663,32 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // q_win +#else + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // q_win +#endif move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win +#else + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win +#endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win +#else + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win +#endif move16(); } } @@ -3041,12 +3696,22 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) +#else + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) +#endif move16(); } FOR( ; i < overlap; i++ ) { - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) +#else + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) +#endif move16(); } } @@ -3095,7 +3760,9 @@ void IMDCT_ivas_fx( /* Compute windowed synthesis in case of switching to ALDO windows in next frame */ Copy( xn_buf_fx + sub( L_frame, nz ), old_out_fx, add( nz, overlap ) ); set16_fx( old_out_fx + add( nz, overlap ), 0, nz ); - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + *q_old_out_fx = q_win; +#endif tcx_windowing_synthesis_past_frame( old_out_fx + nz, tcx_aldo_window_1_trunc_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, hTcxCfg->tcx_curr_overlap_mode ); /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ @@ -3169,6 +3836,10 @@ void IMDCT_ivas_fx( } } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + *pq_win = q_win; + move16(); +#endif return; } @@ -3588,6 +4259,7 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn x_e = sub( 31, 11 ); @@ -3599,6 +4271,43 @@ void decoder_tcx_ivas_fx( move16(); } + Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); + + Word16 q_win, q_winFB; + + q_win = st->Q_syn; + move16(); + q_winFB = st->Q_syn; + move16(); + + assert( q_win == 0 ); + + Scale_sig( synth_fx, L_frame_glob, sub( q_win, st->Q_syn ) ); // Scaling to Q_syn + Scale_sig( synthFB_fx, L_frameTCX_glob, sub( q_winFB, st->Q_syn ) ); // Scaling to Q_syn + + decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, &q_winFB, MDCT_IV, + fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); + + /* Scaling up again */ + Scale_sig( synth_fx, L_frame_glob, sub( st->Q_syn, q_win ) ); + Scale_sig( synthFB_fx, L_frameTCX_glob, sub( st->Q_syn, q_winFB ) ); + // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); + + Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 + st->hTcxDec->Q_old_syn_Overl = -2; + +#else + Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn + x_e = sub( 31, 11 ); + + IF( st->igf != 0 ) + { + Scale_sig32( st->hIGFDec->virtualSpec, ( N_MAX_TCX - IGF_START_MN ), ( sub( st->hIGFDec->virtualSpec_e, x_e ) ) ); + st->hIGFDec->virtualSpec_e = x_e; + move16(); + } + /* Scaling down buffers for decoder_tcx_imdct_fx*/ Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // Scaling to Q_syn st->hTcxDec->Q_syn_Overl_TDACFB = st->Q_syn; @@ -3606,12 +4315,14 @@ void decoder_tcx_ivas_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDAC ) ); // Scaling to Q_syn st->hTcxDec->Q_syn_Overl_TDAC = st->Q_syn; move16(); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) ); // Scaling to Q_syn - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q_syn +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) ); // Scaling to Q0 + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q0 st->hHQ_core->Q_old_wtda = 0; move16(); st->hHQ_core->Q_old_wtda_LB = 0; move16(); +#endif Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn st->hTcxDec->Q_old_syn_Overl = st->Q_syn; @@ -3627,12 +4338,15 @@ void decoder_tcx_ivas_fx( Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD st->hHQ_core->Q_old_wtda = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); +#endif Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 st->hTcxDec->Q_old_syn_Overl = -2; +#endif } /*-------------------------------------------------------------------* @@ -4761,14 +5475,19 @@ void decoder_tcx_noiseshaping_igf_fx( test(); IF( bfi && st->tonal_mdct_plc_active && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifndef OPT_SBA_DEC_V2_NBE Word16 tmp_x_fx_exp[L_FRAME48k], temp; temp = -MAX_16; move16(); set16_fx( tmp_x_fx_exp, *x_e, L_frameTCX ); TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx, tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent ); +#else /* OPT_SBA_DEC_V2_NBE */ + TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx, *x_e, st->hTcxCfg->psychParamsCurrent ); +#endif /* OPT_SBA_DEC_V2_NBE */ /* If exponent has been updated after TonalMDCTConceal_Apply, then shift the spectrum to common exponent. */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < L_frameTCX; i++ ) { temp = s_max( temp, tmp_x_fx_exp[i] ); @@ -4783,6 +5502,7 @@ void decoder_tcx_noiseshaping_igf_fx( move32(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ } test(); @@ -4926,7 +5646,12 @@ void decoder_tcx_tns_fx( test(); test(); test(); +#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT + test(); + IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && whitenedDomain ) || GT_16( L_spec, L_frameTCX ) ) +#else IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) +#endif { L = L_spec; move16(); @@ -4980,7 +5705,12 @@ void decoder_tcx_tns_fx( IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { test(); +#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT + test(); + IF( st->element_mode == EVS_MONO || ( LT_16( L_spec, L_frameTCX ) && !whitenedDomain ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ +#else IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ +#endif { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); tmp = L_frameTCX; @@ -5033,7 +5763,12 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], // Q(11) Word16 q_x, Word16 xn_buf_fx[], // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_win, + Word16 *q_winFB, +#else Word16 q_win, +#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ @@ -5059,7 +5794,12 @@ void decoder_tcx_imdct_fx( Word16 q_a_itf = 15; Word16 x_e = sub( 31, q_x ); move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_acelp_zir_fx = 0; + set16_fx( acelp_zir_fx, 0, L_FRAME_MAX / 2 ); +#else Word16 shift_q = sub( q_x, q_win ); +#endif /*-----------------------------------------------------------------* * Initializations @@ -5212,9 +5952,17 @@ void decoder_tcx_imdct_fx( IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, +#else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, +#endif hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#endif } /* Generate additional comfort noise to mask potential coding artefacts */ @@ -5234,14 +5982,32 @@ void decoder_tcx_imdct_fx( IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) { Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#endif } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 shift_q, q_x16; + + shift_q = L_norm_arr( xn_bufFB_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); + shift_q = sub( 16, shift_q ); + q_x16 = sub( q_x, shift_q ); +#endif + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + assert( extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == -1 ); +#endif + xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x16 move16(); } @@ -5251,19 +6017,40 @@ void decoder_tcx_imdct_fx( IF( st->element_mode != EVS_MONO ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, +#else IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, +#endif hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); +#else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#endif } ELSE { - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#else IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); +#else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#endif } + +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + shift_q = 16; + move16(); +#endif + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x + xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // q_winFB } IF( ( bfi == 0 ) ) @@ -5305,18 +6092,21 @@ void decoder_tcx_imdct_fx( /* Update old_syn_overl */ IF( hTcxCfg->last_aldo == 0 ) { - Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) + Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // q_win FOR( Word16 ind = 0; ind < overlapFB; ind++ ) { - hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x + assert( extract_h( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ) == -1 ); + hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_winFB } } /* Output */ - Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) + Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // q_win FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) { - synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x + assert( extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == 0 || + extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == -1 ); + synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_winFB } diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index e30553d388e32c0a53b2b903aa763b120af22ab0..470053c6a063550c32b07461961700494f8c4f44 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -557,7 +557,7 @@ void con_acelp_fx( tmp_32 = Mpy_32_16_1( st->Mode2_lp_gainc /*Q16*/, alpha /*Q14*/ ); /*Q31-16 = Q15*/ s_32 = norm_l( tmp_32 ); tmp_32 = L_shl( tmp_32, s_32 ); - tmp_16 = round_fx( tmp_32 ); + tmp_16 = round_fx_sat( tmp_32 ); s_16 = negate( s_32 ); s_16 = sub( s_16, -1 - 15 ); /*->Q15*/ @@ -1018,6 +1018,10 @@ void con_acelp_fx( Copy( syn, synth, st->L_frame ); bufferCopyFx( syn + sub( st->L_frame, shr( st->L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( Qf_syn, 1 ); + move16(); +#endif /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); @@ -1057,11 +1061,9 @@ void con_acelp_fx( move16(); } set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); - hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); - FOR( i = 0; i < W2; i++ ) { buf[i] = mult_r( hTcxDec->syn_Overl_TDAC[i], w[i].v.re ); /*hTcxDec->Q_syn_Overl_TDAC*/ @@ -1104,7 +1106,15 @@ void con_acelp_fx( st->hTcxDec->Q_syn_Overl_TDACFB = st->hTcxDec->Q_syn_Overl_TDAC; move16(); lerp( hTcxDec->syn_Overl, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ), shr( st->L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_OverlFB = hTcxDec->Q_syn_Overl; + move16(); +#endif lerp( hHQ_core->old_out_LB_fx, hHQ_core->old_out_fx, hTcxDec->L_frameTCX, st->L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; + move16(); +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 3d0eab8153845c06cda2e6562038b4da91a1b2c2..37465bc294ad33a91ad7a5f3ced6dfbe86d80d57 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -843,6 +843,10 @@ void con_tcx_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = Q_syn; + move16(); +#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) @@ -867,7 +871,13 @@ void con_tcx_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#else Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -929,11 +939,23 @@ void con_tcx_fx( /* update memory for low band */ Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_old_syn_Overl = -1; + move16(); +#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; + move16(); +#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_NO + hHQ_core->Q_old_wtda_LB = hHQ_core->Q_old_wtda; + move16(); +#endif st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); @@ -1789,6 +1811,10 @@ void con_tcx_ivas_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_old_syn_Overl = Q_syn; + move16(); +#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) @@ -1813,7 +1839,13 @@ void con_tcx_ivas_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#else Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -1828,9 +1860,14 @@ void con_tcx_ivas_fx( move16(); /* create aliasing and windowing need for transition to TCX10/5 */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ) ); + hTcxDec->Q_syn_Overl_TDACFB = Q_syn; +#else // bufferCopyFx( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), Q_syn, 0, -1, 0 ); Copy_Scale_sig( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), sub( Q_syn, 1 ) ); hTcxDec->Q_syn_Overl_TDACFB = sub( Q_syn, 1 ); +#endif move16(); FOR( i = 0; i < W12; i++ ) @@ -1877,14 +1914,20 @@ void con_tcx_ivas_fx( /* update memory for low band */ st->Q_syn = Q_syn; move16(); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ st->hTcxDec->Q_old_syn_Overl = -1; +#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; + move16(); +#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); - st->hHQ_core->Q_old_wtda_LB = Q_syn; + st->hHQ_core->Q_old_wtda_LB = Q_syn; // st->hHQ_core->Q_old_wtda st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 9c81fddf347529f42c78a49bbaae321ffc589306..6411eb477cb3508a4570f8b64a6a850e7a172d6e 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -167,7 +167,7 @@ ivas_error evs_dec_fx( tmp1 = extract_l( L_shr_r( f, s ) ); /*Q14 - s*/ FOR( i = 0; i < st_fx->hTcxCfg->tcx_mdct_window_lengthFB; i++ ) { - hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); /*hTcxDec->Q_syn_Overl*/ + hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); /*hTcxDec->Q_syn_OverlFB*/ move16(); } s = norm_l( f ); diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 364d10ed1d52d4ec3a18c4b4b7fa10fd0c2400c7..8302f68b95fdc37e0e50ede3ab7bea2c3196a7e2 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1500,6 +1500,9 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; +#ifdef FIX_732_MS_PERIODOG_FLOOR + Word32 msPeriodog_floor; +#endif Word32 *msNoiseEst; Word32 *reIter; Word32 rescale_fac = 0; @@ -1508,6 +1511,10 @@ void perform_noise_estimation_dec_ivas_fx( Word16 q_shift; Word32 max_l; Word16 norm_shift; +#ifdef FIX_732_MS_PERIODOG_FLOOR + Word16 check = 0; + move16(); +#endif /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ @@ -1706,12 +1713,38 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); +#ifdef FIX_732_MS_PERIODOG_FLOOR + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/ + IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) +#else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) +#endif { +#ifdef FIX_732_MS_PERIODOG_FLOOR + msPeriodog[p] = msPeriodog_floor; + move32(); +#else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); +#endif } } +#ifdef FIX_732_MS_PERIODOG_FLOOR + FOR( p = 0; p < npart; p++ ) + { + IF( GT_32( msPeriodog[p], 1 ) ) + { + check = 1; + move16(); + BREAK; + } + } + IF( check == 0 ) + { + hFdCngDec->msPeriodog_exp = 14; /* msPeriodog buffer will have minimum value as 1e-5f */ + move16(); + } +#endif } /* calculate total energy (short-term and long-term) */ @@ -4725,11 +4758,7 @@ void generate_masking_noise_ivas_fx( } ELSE { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ } return; diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 3c2cd5a8092c7c385a6916eae760689d1996e8b8..0161cbac0e1ad5b6f95c233ca22f1ba665229c56 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1094,6 +1094,10 @@ void HQ_core_dec_init_fx( move16(); move16(); move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif hHQ_core->last_hq_core_type = -1; /* Q0 */ move16(); diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 11c108380ec274e2d901fddf50bf2890f9a5fef8..7ee1b8c34b76293480a2944f54b3290b5b6c5ac2 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1558,6 +1558,8 @@ ivas_error init_decoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } + st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; + move16(); } ELSE { diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index d2573c4d7af6cc5a69ba82e2e3a611c27642bb90..68886c1baac85e6bed86c46fd0b0df026c325b63 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -54,7 +54,6 @@ * * *-------------------------------------------------------------------------*/ -#ifdef OPT_BIN_RENDERER_V2 static void ivas_binRenderer_filterModule_fx( Word32 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q6 */ Word32 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q6 */ @@ -74,12 +73,17 @@ static void ivas_binRenderer_filterModule_fx( Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; move16(); - // to be checked: feasibility with 32 bit buffers +#ifdef OPT_BIN_REND_V2_NBE + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); + hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; +#else /* OPT_BIN_REND_V2_NBE */ Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif /* OPT_BIN_REND_V2_NBE */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { +#ifndef OPT_BIN_REND_V2_NBE set64_fx( &Cldfb_RealBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); set64_fx( &Cldfb_ImagBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -93,6 +97,7 @@ static void ivas_binRenderer_filterModule_fx( filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 +#endif /* OPT_BIN_REND_V2_NBE */ FOR( k = 0; k < numTimeSlots; k++ ) { Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; @@ -100,633 +105,559 @@ static void ivas_binRenderer_filterModule_fx( move64(); move64(); move64(); - - FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) - { - filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; - move32(); - filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; - move32(); - Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - } - - shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); - - IF( shift_q != 0 ) - { - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 - hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; - move16(); - } - - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); - - - /* Left Real and Imag */ - - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 - Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr +#ifdef OPT_BIN_REND_V2_NBE + Word64 outRealLeft = 0, outRealRight = 0, outImagLeft = 0, outImagRight = 0; move64(); - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr move64(); - - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr move64(); - - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr move64(); - } - } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 - move32(); - out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 - move32(); - } - } - } + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); + filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); - return; -} -#else /* OPT_BIN_RENDERER_V2 */ -static void ivas_binRenderer_filterModule_fx( - Word64 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q29 */ - Word64 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q29 */ - Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals Q_curr*/ - Word32 CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals Q_curr*/ - const Word16 numTimeSlots, /* i : number of time slots to process */ - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - const Word16 pos_idx, /* i : pose index */ - Word16 Q_curr ) -{ - Word16 bandIdx, k, chIdx, tapIdx; - Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; - Word16 Q_filterStates; - const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; - Word16 shift_q; - Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; - move16(); + filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 + filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 + filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 + filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 +#endif /* OPT_BIN_REND_V2_NBE */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); - filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); + FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) + { + filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; + move32(); + filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; + move32(); + Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); - filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 - filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 - filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 - filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 - FOR( k = 0; k < numTimeSlots; k++ ) - { - Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; - move64(); - move64(); - move64(); - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) - { - filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; - move32(); - filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; - move32(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + } - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates +#ifndef OPT_BIN_REND_V2_NBE + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + IF( shift_q != 0 ) + { + outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 + outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 + outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 + outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 + hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; + move16(); + } +#endif /* OPT_BIN_REND_V2_NBE */ + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - } +#ifdef OPT_BIN_REND_V2_NBE + /* Left Real and Imag */ + Word32 neg_temp2 = L_negate( filterStatesLeftImagPtr_fx[0] ); // Q_curr - shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); + outRealLeft = W_mac_32_32( W_mac_32_32( outRealLeft, filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), neg_temp2, filterTapsLeftImagPtr_fx[0] ); + outImagLeft = W_mac_32_32( W_mac_32_32( outImagLeft, filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ); - IF( shift_q != 0 ) - { - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr - hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; - move16(); + /* Right Real and Imag */ + outRealRight = W_mac_32_32( W_mac_32_32( outRealRight, neg_temp2, filterTapsRightImagPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ); + outImagRight = W_mac_32_32( W_mac_32_32( outImagRight, filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ); } - - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + out_Conv_CLDFB_real[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealLeft_fx, shift_q ), W_shr( outRealLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealRight_fx, shift_q ), W_shr( outRealRight, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagLeft_fx, shift_q ), W_shr( outImagLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagRight_fx, shift_q ), W_shr( outImagRight, 1 ) ), shift_q6 ); move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; move32(); + move32(); + move32(); + } +#else /* OPT_BIN_REND_V2_NBE */ + /* Left Real and Imag */ - - /* Left Real and Imag */ - // Q29 + Q_curr - - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 + Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr + move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr + move64(); - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr + move64(); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); - } + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr + move64(); } } - - return; -} -#endif /* OPT_BIN_RENDERER_V2 */ - -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses ) -{ - Word16 bandIdx, chIdx; - Word16 pos_idx; - - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) + { + out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + } } +#endif /* OPT_BIN_REND_V2_NBE */ + } - IF( !isLoudspeaker ) - { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); - move16(); - } - ELSE - { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); - move16(); + + return; } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, + const HRTFS_FASTCONV_HANDLE hHrtf, + const Word16 num_poses ) { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; - move16(); + Word16 bandIdx, chIdx; + Word16 pos_idx; - /* Use variable order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( ; bandIdx < 20; bandIdx++ ) + + IF( !isLoudspeaker ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + hBinRenderer->nInChannels = audioCfg2channels( input_config ); move16(); } - FOR( ; bandIdx < 30; bandIdx++ ) + ELSE { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); move16(); } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; move16(); - } - } - ELSE - { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + + /* Use variable order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < 5; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } + FOR( ; bandIdx < 10; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; + move16(); + } + FOR( ; bandIdx < 20; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + move16(); + } + FOR( ; bandIdx < 30; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + move16(); + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } } ELSE { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + move16(); + } + ELSE + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS; + move16(); + } - /* Use fixed order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + /* Use fixed order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } } - } - - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } - if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } + + IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } + IF( ( hBinRenConvModule->Q_filterStates = (Word16 *) malloc( num_poses * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx] = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - if ( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - if ( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } - } - } - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word16 tmp = 0; - move16(); - IF( isLoudspeaker ) - { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - tmp = channelIndex_CICP19[chIdx]; - move16(); + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } } } + } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - /* set the memories to zero */ + Word16 tmp = 0; + move16(); + IF( isLoudspeaker ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) + { + tmp = channelIndex_CICP6[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) + { + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + { + tmp = channelIndex_CICP19[chIdx]; + move16(); + } } - } - ELSE - { - IF( isLoudspeaker ) + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; + /* set the memories to zero */ + IF( isLoudspeaker ) + { + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + } } ELSE { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) - { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + /* set the memories to zero */ + IF( isLoudspeaker ) { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } } } - } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + } } } } - } - ELSE - { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + ELSE { - hBinRenConvModule->Q_filterStates[pos_idx] = 31; - move16(); - for ( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { - for ( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + hBinRenConvModule->Q_filterStates[pos_idx] = 31; + move16(); + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + } } } } - } - - hBinRenderer->hBinRenConvModule = hBinRenConvModule; - - return IVAS_ERR_OK; -} - -/*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ -) -{ - Word16 i; - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; - move32(); + hBinRenderer->hBinRenConvModule = hBinRenConvModule; - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; - move32(); + return IVAS_ERR_OK; + } - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); + /*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ + ) + { + Word16 i; - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + move32(); - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + move32(); - HrtfFastConv->allocate_init_flag = 0; - move16(); + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; move32(); - } - return; -} + HrtfFastConv->allocate_init_flag = 0; + move16(); -/*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ -static ivas_error ivas_alloc_pppMem_fx( - Word32 ****pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) -{ - Word16 i, j; - Word32 ***localMem = NULL; + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + move32(); + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + move32(); + } - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + return; } - for ( i = 0; i < dim1; i++ ) + /*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ + static ivas_error ivas_alloc_pppMem_fx( + Word32 * ***pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) { - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ) + Word16 i, j; + Word32 ***localMem = NULL; + + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } - IF( allocate_init_flag == 0 ) + + FOR( i = 0; i < dim1; i++ ){ + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + IF( allocate_init_flag == 0 ) + { + FOR( j = 0; j < dim2; j++ ) { - FOR( j = 0; j < dim2; j++ ) + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); - } + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } } } +} - *pppMem = localMem; +*pppMem = localMem; - return IVAS_ERR_OK; +return IVAS_ERR_OK; } /*-------------------------------------------------------------------------* @@ -1148,7 +1079,7 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); /*Ambisonics input requires different processing*/ - if ( EQ_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) + IF( EQ_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) { Word32 *inRealPtr_W, *inImagPtr_W; Word32 *inRealPtr_Y, *inImagPtr_Y; @@ -1168,7 +1099,7 @@ static void ivas_binaural_obtain_DMX_fx( outImagRightPtr_fx[bandIdx] = L_sub( inImagPtr_W[bandIdx], inImagPtr_Y[bandIdx] ); } } - else + ELSE { FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -1225,12 +1156,12 @@ ivas_error ivas_rend_openCldfbRend( * prepare library opening *-----------------------------------------------------------------*/ - if ( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) + IF( ( hBinRenderer = (BINAURAL_RENDERER_HANDLE) malloc( sizeof( BINAURAL_RENDERER ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Renderer\n" ) ); } - if ( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) + IF( ( hBinRenderer->hInputSetup = (IVAS_OUTPUT_SETUP_HANDLE) malloc( sizeof( IVAS_OUTPUT_SETUP ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output setup Binaural Renderer\n" ) ); } @@ -1840,17 +1771,13 @@ void ivas_binRenderer_fx( Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#ifndef OPT_BIN_RENDERER_V2 - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif /* OPT_BIN_RENDERER_V2 */ push_wmops( "fastconv_binaural_rendering" ); num_poses = hBinRenderer->numPoses; /* Compute Convolution */ /* memory reset for the binaural output */ +#ifndef OPT_SBA_DEC_V2_BE FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -1862,17 +1789,7 @@ void ivas_binRenderer_fx( } } } - -#ifndef OPT_BIN_RENDERER_V2 - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif /* OPT_BIN_RENDERER_V2 */ +#endif /* OPT_SBA_DEC_V2_BE */ /* Note: on main, this nested for loop was removed under a "bit-exact optimization" under switch OPT_SBA_DEC_V2_BE */ /* this was found to clash with split rendering, so kept here. WMOPS impact should be assessed */ @@ -1922,25 +1839,7 @@ void ivas_binRenderer_fx( hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } -#ifdef OPT_BIN_RENDERER_V2 ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx[0], Cldfb_ImagBuffer_Binaural_fx[0], RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); -#else /* OPT_BIN_RENDERER_V2 */ - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); - - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - } - } - } -#endif /* OPT_BIN_RENDERER_V2 */ IF( pMultiBinPoseData != NULL ) { @@ -1949,9 +1848,6 @@ void ivas_binRenderer_fx( IVAS_QUATERNION Quaternions_abs, Quaternions_ref, Quaternions_ref2; Word32 Rmat_local[3][3]; Word16 q_fact_orig; -#ifndef OPT_BIN_RENDERER_V2 - Word16 extra_shift = 0; -#endif IF( hCombinedOrientationData && hBinRenderer->rotInCldfb ) { @@ -1967,11 +1863,7 @@ void ivas_binRenderer_fx( Quaternions_ref2.x_fx = 0; Quaternions_ref2.y_fx = 0; Quaternions_ref2.z_fx = 0; -#ifndef OPT_BIN_RENDERER_V2 - extra_shift = 1; -#else *Q_in = sub( *Q_in, 1 ); -#endif } ELSE { @@ -2003,43 +1895,15 @@ void ivas_binRenderer_fx( modify_Rmat_q_fx( Rmat_local, Rmat_local, sub( shl( q_fact_orig, 1 ), 32 ), Q30 ); - if ( hBinRenderer->hInputSetup->is_loudspeaker_setup ) + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup ) { rotateFrame_sd_cldfb_fixed( Rmat_local, RealBuffer_fx, ImagBuffer_fx, hBinRenderer->hInputSetup, hBinRenderer->hEFAPdata, numTimeSlots, hBinRenderer->conv_band ); } - else + ELSE { rotateFrame_shd_cldfb( RealBuffer_fx, ImagBuffer_fx, Rmat_local, hBinRenderer->hInputSetup->nchan_out_woLFE, numTimeSlots, 3 ); } -#ifndef OPT_BIN_RENDERER_V2 - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif -#ifdef OPT_BIN_RENDERER_V2 ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx], Cldfb_ImagBuffer_Binaural_fx[pos_idx], RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); -#else - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, pos_idx, *Q_in ); - - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[pos_idx][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 - extra_shift ) ); //(*Q_in + 29) - 29 - move32(); - } - } - } -#endif } } } @@ -2052,9 +1916,8 @@ void ivas_binRenderer_fx( Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 inRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 inIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#ifdef OPT_BIN_RENDERER_V2 Word16 shift_q; -#endif + ivas_binaural_obtain_DMX_fx( numTimeSlots, hBinRenderer, RealBuffer_fx, ImagBuffer_fx, inRe_fx, inIm_fx ); FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -2068,26 +1931,17 @@ void ivas_binRenderer_fx( ivas_binaural_reverb_processSubframe_fx( hBinRenderer->hReverb, BINAURAL_CHANNELS, numTimeSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); -#ifdef OPT_BIN_RENDERER_V2 shift_q = sub( Q6, sub( *Q_in, 1 ) ); -#endif FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < numTimeSlots; j++ ) { FOR( k = 0; k < hBinRenderer->hReverb->numBins; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], shift_q ); // Q6 move32(); reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], shift_q ); // Q6 move32(); -#else - reverbRe_fx[i][j][k] = L_shl( reverbRe_fx[i][j][k], 1 ); //*Q_in - move32(); - reverbIm_fx[i][j][k] = L_shl( reverbIm_fx[i][j][k], 1 ); //*Q_in - move32(); -#endif } } } @@ -2097,7 +1951,7 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q6 @@ -2197,13 +2051,9 @@ void ivas_rend_CldfbMultiBinRendProcess( { Copy32( &Cldfb_RealBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); Copy32( &Cldfb_ImagBuffer_Binaural[pose_idx][ch_idx][slot_idx][0], &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band ); -#ifndef OPT_BIN_RENDERER_V2 - Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig - Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q_in_orig ) ); // Q_in_orig -#else + Scale_sig32( &Cldfb_Out_Real[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q6 ) ); // Q_in Scale_sig32( &Cldfb_Out_Imag[( pose_idx * BINAURAL_CHANNELS ) + ch_idx][idx][0], hCldfbRend->max_band, sub( Q_in, Q6 ) ); // Q_in -#endif } } } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 40012175640da7963da6eb8fbda62bc83507ad23..4def2242a8154a77d5f207239121970b24973354 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -337,6 +337,10 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 L_lerp_fx_q11( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( sts[0]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + sts[0]->hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif } IF( NE_16( sts[0]->L_frame, L_FRAME16k ) ) { @@ -576,14 +580,16 @@ ivas_error ivas_core_dec_fx( move32(); /* TCX decoder */ - Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 - Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 + Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 + Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, -st->hHQ_core->Q_old_wtda_LB ); // Q0 Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, -st->hHQ_core->Q_old_wtda ); // Q0 st->hHQ_core->Q_old_wtda_LB = 0; move16(); st->hHQ_core->Q_old_wtda = 0; move16(); +#endif IF( st_ivas == NULL ) { @@ -598,8 +604,10 @@ ivas_error ivas_core_dec_fx( stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda; move16(); +#endif Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, Q11 ); // Q11 IF( st->hTcxDec ) @@ -701,6 +709,7 @@ ivas_error ivas_core_dec_fx( st->hHQ_core->Q_fer_samples = 0; move16(); } +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT IF( NE_16( st->core, st->last_core ) ) { IF( st->hTcxDec ) @@ -710,7 +719,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn = 0; move16(); } - +#endif st->prev_Q_syn = st->Q_syn; move16(); @@ -1401,6 +1410,10 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, st->hHQ_core->Q_old_wtda_LB ) ); // Q11 Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, st->hHQ_core->Q_old_wtda ) ); // Q11 +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif } IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index e26a56c1bb44b72f62e6c4bd06cc37c0619618f3..6e29c2ac9197a3da833cfd15ef01f45e0a58be53 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -132,7 +132,11 @@ ivas_error ivas_cpe_dec_fx( IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_out_fx32 = Q11; +#else hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; +#endif move16(); } } @@ -155,7 +159,7 @@ ivas_error ivas_cpe_dec_fx( test(); IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda + Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB } } @@ -648,7 +652,7 @@ ivas_error ivas_cpe_dec_fx( IF( NE_16( shift, 31 ) ) { - shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q15 ); /* Q15 for guard bits */ + shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q16 ); /* Q16 for guard bits */ IF( GT_16( shift, hCPE->hStereoDft->q_dft ) ) { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 3ffcde3063d4cb5ee93813ff4750d8d9099ae71c..69c841dac34ad395ba7c11e258cde2fb3311fa42 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1779,31 +1779,68 @@ void ivas_qmetadata_to_dirac_fx( } ELSE { +#ifndef OPT_SBA_DEC_PATH Word16 tmp1, tmp4; +#endif /* OPT_SBA_DEC_PATH */ Word16 a, b_tmp; Word16 exp_factor = 0; move16(); a = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor +#ifndef OPT_SBA_DEC_PATH tmp1 = mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5 Word32 tmp1_32 = L_deposit_h( tmp1 ); +#else /* OPT_SBA_DEC_PATH */ + Word32 tmp1_32 = L_mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5 +#endif /* OPT_SBA_DEC_PATH */ Word16 final_1_exp; - Word32 final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, exp_factor + 5, &final_1_exp ); - b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor + Word32 final_1_32; +#ifndef OPT_SBA_DEC_PATH + final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, add( exp_factor, 5 ), &final_1_exp ); +#else /* OPT_SBA_DEC_PATH */ + Word16 norm_op1 = norm_l( azimuth_fx ); + Word16 norm_op2 = norm_l( tmp1_32 ); + Word16 op2_e = add( exp_factor, 5 ); + final_1_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom + final_1_32 = L_add( L_shr( azimuth_fx, sub( final_1_exp, 9 ) ), L_shr( tmp1_32, sub( final_1_exp, op2_e ) ) ); + +#endif /* OPT_SBA_DEC_PATH */ + b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor +#ifndef OPT_SBA_DEC_PATH tmp4 = mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4 Word32 tmp4_32 = L_deposit_h( tmp4 ); - Word16 final_2_exp; - Word32 final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, exp_factor + 4, &final_2_exp ); - +#else /* OPT_SBA_DEC_PATH */ + Word32 tmp4_32 = L_mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4 +#endif /* OPT_SBA_DEC_PATH */ + Word16 final_2_exp; + Word32 final_2_32; +#ifndef OPT_SBA_DEC_PATH + final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, add( exp_factor, 4 ), &final_2_exp ); +#else /* OPT_SBA_DEC_PATH */ + norm_op1 = norm_l( elevation_fx ); + norm_op2 = norm_l( tmp4_32 ); + op2_e = add( exp_factor, 4 ); + final_2_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom + final_2_32 = L_add( L_shr( elevation_fx, sub( final_2_exp, 9 ) ), L_shr( tmp4_32, sub( final_2_exp, op2_e ) ) ); +#endif /* OPT_SBA_DEC_PATH */ + +#ifndef OPT_SBA_DEC_PATH final_1_32 = BASOP_Util_Add_Mant32Exp( final_1_32, final_1_exp, ONE_IN_Q30, 0, &final_1_exp ); /*0.5 in q31*/ final_2_32 = BASOP_Util_Add_Mant32Exp( final_2_32, final_2_exp, ONE_IN_Q30, 0, &final_2_exp ); azi = extract_h( L_shr( final_1_32, sub( sub( 31, final_1_exp ), 16 ) ) ); ele = extract_h( L_shr( final_2_32, sub( sub( 31, final_2_exp ), 16 ) ) ); +#else /* OPT_SBA_DEC_PATH */ + final_1_32 = L_add( final_1_32, L_shl( 1, sub( 30, final_1_exp ) ) ); /*0.5 in q31*/ + final_2_32 = L_add( final_2_32, L_shl( 1, sub( 30, final_2_exp ) ) ); + azi = extract_h( L_shr( final_1_32, sub( 15, final_1_exp ) ) ); + ele = extract_h( L_shr( final_2_32, sub( 15, final_2_exp ) ) ); +#endif /* OPT_SBA_DEC_PATH */ + /*addition of one to compensate precision loss*/ if ( azi < 0 ) @@ -2001,7 +2038,11 @@ void ivas_dirac_dec_set_md_map( tmp_fx = W_add_nosat( tmp_fx, W_deposit32_l( L_deposit_l( hSpatParamRendCom->render_to_md_map[slot_idx_abs] ) ) ); slot_idx_abs = add( slot_idx_abs, 1 ); } +#ifdef FIX_1735_W_SHL_SAT_L + iDiv_and_mod_32( W_shl_sat_l( tmp_fx, 16 ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); +#else iDiv_and_mod_32( W_extract_l( W_shl_nosat( tmp_fx, 16 ) ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); +#endif hSpatParamRendCom->render_to_md_map[sf_idx] = add( round_fx( quo ), hSpatParamRendCom->dirac_read_idx ) % hSpatParamRendCom->dirac_md_buffer_length; move16(); } @@ -2256,23 +2297,6 @@ void ivas_dirac_dec_render_sf_fx( } } -#ifndef OPT_BIN_RENDERER_V2 - FOR( Word16 p = 0; p < MAX_HEAD_ROT_POSES; p++ ) - { - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - set32_fx( Cldfb_RealBuffer_Binaural_fx[p][i][j], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_RealBuffer_Binaural_fx[p][i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } - } - } -#endif /* OPT_BIN_RENDERER_V2 */ - /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; Word16 elevation[CLDFB_NO_CHANNELS_MAX]; @@ -2333,16 +2357,6 @@ void ivas_dirac_dec_render_sf_fx( } } -#ifndef OPT_BIN_RENDERER_V2 - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif /* OPT_BIN_RENDERER_V2 */ hDirAC = st_ivas->hDirAC; hDirACRend = st_ivas->hDirACRend; @@ -3108,7 +3122,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( idiv1616( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ + hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( shr( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF_LOG2 ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ move16(); } @@ -3167,11 +3181,7 @@ void ivas_dirac_dec_render_sf_fx( v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ -#endif /* VEC_ARITH_OPT_v1 */ p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -3893,9 +3903,6 @@ void ivas_dirac_dec_render_sf_fx( { Word16 j, k, j2, l; Word16 num_objects, nchan_out_woLFE, lfe_index; -#ifndef FIX_1379_MASA_ANGLE_ROUND - Word16 az1, el1; -#endif Word16 n_slots_to_render; Word16 n_samples_to_render; Word16 interp_offset; @@ -3929,20 +3936,11 @@ void ivas_dirac_dec_render_sf_fx( Word16 el_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ) ); Word32 az1_32, el1_32; rotateAziEle_fixed( az_q0, el_q0, &az1_32, &el1_32, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup ); -#ifndef FIX_1379_MASA_ANGLE_ROUND - az1 = extract_h( az1_32 ); - el1 = extract_h( el1_32 ); -#endif IF( st_ivas->hEFAPdata != NULL ) { -#ifdef FIX_1379_MASA_ANGLE_ROUND const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22 const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22 -#else - const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 - const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 -#endif efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); } } @@ -3982,27 +3980,13 @@ void ivas_dirac_dec_render_sf_fx( { Word32 g_fx; w2_fx = sub( MAX16B, *w1_fx ); -#ifdef OPT_BIN_RENDERER_V2 g_fx = Madd_32_16( Mpy_32_16_1( gain_fx, *w1_fx ), prev_gain_fx, w2_fx ); // Q15 -#else /* OPT_BIN_RENDERER_V2 */ - g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); // Q15 -#endif /* OPT_BIN_RENDERER_V2 */ FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { -#ifdef OPT_BIN_RENDERER_V2 Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_re_fx ); move32(); tc_re_fx++; Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_im_fx ); -#else /* OPT_BIN_RENDERER_V2 */ - Word32 tmp; - tmp = Mpy_32_32( g_fx, *tc_re_fx ); - Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); - move32(); - tc_re_fx++; - tmp = Mpy_32_32( g_fx, *tc_im_fx ); - Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); -#endif /* OPT_BIN_RENDERER_V2 */ move32(); tc_re_fx++; } @@ -4052,13 +4036,6 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); Word16 pos_idx; -#ifndef OPT_BIN_RENDERER_V2 - FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) - { - Scale_sig32( &Cldfb_RealBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 - Scale_sig32( &Cldfb_ImagBuffer_Binaural_fx[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 - } -#endif IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -4093,11 +4070,7 @@ void ivas_dirac_dec_render_sf_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col; move16(); @@ -4200,11 +4173,7 @@ void ivas_dirac_dec_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; move32(); } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ IF( !st_ivas->hLsSetupCustom->separate_ch_found ) { @@ -4244,11 +4213,7 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q6-1 st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ // Calculating length of output Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col; @@ -4316,11 +4281,7 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scaling output from Q6-1 to Q11 Scale_sig32( p_out, out_len, ( Q11 - ( Q6 - 1 ) ) ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 598f9082945fd0eb2385355d5460e71e4611cd79..238ca3704ffbe7d3c5056a9c8bb13fd7afd2e6cc 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE #include #include @@ -518,14 +517,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word16 mixing_matrix_buffer_e; Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 input_f_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE - -#else - Word32 output_f_real_fx[MAX_CICP_CHANNELS]; - Word32 output_f_imag_fx[MAX_CICP_CHANNELS]; - Word16 output_f_real_e; - Word16 output_f_imag_e; -#endif + Word32 diff_f_real_fx[MAX_CICP_CHANNELS]; Word32 diff_f_imag_fx[MAX_CICP_CHANNELS]; @@ -533,12 +525,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( set_zero_fx( input_f_real_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero_fx( input_f_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE -#else - set_zero_fx( output_f_real_fx, MAX_CICP_CHANNELS ); - set_zero_fx( output_f_imag_fx, MAX_CICP_CHANNELS ); -#endif set_zero_fx( diff_f_real_fx, MAX_CICP_CHANNELS ); set_zero_fx( diff_f_imag_fx, MAX_CICP_CHANNELS ); @@ -602,13 +589,16 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( } /* apply residual mixing */ -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE { Word16 shifter; +#ifdef OPT_SBA_DEC_V2_NBE + shifter = sub( mixing_matrix_res_smooth_e, 32 ); +#else /* OPT_SBA_DEC_V2_NBE */ #ifdef OPT_SBA_DEC_V2_BE shifter = sub( mixing_matrix_res_smooth_e, 31 ); #else /* OPT_SBA_DEC_V2_BE */ shifter = 31 - mixing_matrix_res_smooth_e; +#endif /* OPT_SBA_DEC_V2_NBE */ #endif /* OPT_SBA_DEC_V2_BE */ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) { @@ -624,8 +614,13 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move64(); for ( i = 0; i < nY; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + temp_real = W_mac_32_32( temp_real, mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ); + temp_imag = W_mac_32_32( temp_imag, mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ); +#else /* OPT_SBA_DEC_V2_NBE */ temp_real = W_add( temp_real, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ) ); temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ idx += nY; } #ifdef OPT_SBA_DEC_V2_BE @@ -637,25 +632,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( #endif /* OPT_SBA_DEC_V2_BE */ } } - - -#else - - matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_real_fx, 25, nY, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, nY, sub( Q6, sub( Q31, output_f_real_e ) ) ); // Q6 - - - matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_imag_fx, 25, nY, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, nY, sub( Q6, sub( Q31, output_f_imag_e ) ) ); // Q6 - - FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) - { - Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_real_fx[ch_idx]; // Q6 - move32(); - Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_imag_fx[ch_idx]; // Q6 - move32(); - } -#endif } ELSE { @@ -679,7 +655,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( } /* apply mixing matrix */ -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE { Word16 shifter; shifter = 31 - mixing_matrix_smooth_e; @@ -708,24 +683,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move32(); } } -#else - - matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_real_fx, 25, nX, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); // Q6 - - - matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_imag_fx, 25, nX, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_imag_e ) ) ); // Q6 - - /* collect output */ - FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) - { - Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band], output_f_real_fx[ch_idx] ); - move32(); - Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band], output_f_imag_fx[ch_idx] ); - move32(); - } -#endif } } @@ -929,7 +886,11 @@ Word16 computeMixingMatrices_fx( move16(); FOR( i = 1; i < lengthCx; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( svd_s_buffer_fx[i], L_shl_sat( limit_fx, sub( limit_e, svd_s_buffer_e[i] ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = svd_s_buffer_fx[i]; move32(); @@ -938,13 +899,22 @@ Word16 computeMixingMatrices_fx( } } - L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); limit_e = add( limit_e, reg_Sx_e ); + +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_Sx_fx ); +#else /* OPT_MCH_DEC_V1_BE */ + L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( i = 0; i < lengthCx; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( LT_32( L_shl_sat( svd_s_buffer_fx[i], sub( svd_s_buffer_e[i], limit_e ) ), limit_fx ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) < 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { svd_s_buffer_fx[i] = limit_fx; move32(); @@ -989,9 +959,16 @@ Word16 computeMixingMatrices_fx( matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e ); +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = sub( limit_e, Cy_hat_diag_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = Cy_hat_diag_fx[i]; move32(); @@ -999,15 +976,27 @@ Word16 computeMixingMatrices_fx( move16(); } } +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ limit_e = add( limit_e, reg_ghat_e ); +#ifdef OPT_MCH_DEC_V1_NBE + com_e = sub( Cy_hat_diag_e, limit_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { Cy_hat_diag_buff_e[i] = Cy_hat_diag_e; move16(); + +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_buff_e[i] ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#endif /* OPT_MCH_DEC_V1_NBE */ { Cy_hat_diag_fx[i] = limit_fx; move32(); @@ -1427,7 +1416,11 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < lengthCx; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Kx_fx[i], L_shl_sat( limit_fx, sub( limit_e, Kx_fx_e[i] ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { div_tmp = Kx_fx[i]; move32(); @@ -1468,9 +1461,16 @@ Word16 computeMixingMatricesResidual_fx( Cy_hat_diag_e = Cx_e; move16(); +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = sub( limit_e, Cy_hat_diag_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = Cy_hat_diag_fx[i]; move32(); @@ -1479,16 +1479,28 @@ Word16 computeMixingMatricesResidual_fx( } } +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e) +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e) limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ limit_e = add( limit_e, reg_ghat_e ); /* Computing G_hat */ + +#ifdef OPT_MCH_DEC_V1_NBE + com_e = sub( Cy_hat_diag_e, limit_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { Cy_hat_diag_fx_e[i] = Cy_hat_diag_e; move16(); +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_e ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#endif /* OPT_MCH_DEC_V1_NBE */ { Cy_hat_diag_fx[i] = limit_fx; move32(); @@ -1511,8 +1523,12 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs; i++ ) { - L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) +#ifdef OPT_MCH_DEC_V1_BE + Kx_fx[i] = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) +#else /* OPT_MCH_DEC_V1_BE */ + L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) Kx_fx[i] = L_tmp; +#endif /* OPT_MCH_DEC_V1_BE */ move32(); Kx_fx_e[i] = add( Kx_fx_e[i], G_hat_e[i] ); move16(); @@ -1526,11 +1542,18 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { +#ifdef OPT_MCH_DEC_V1_BE + mat_mult_buffer1_fx[i + j * num_outputs] = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e)); + move32(); + mat_mult_buffer1_buff_e[i + j * num_outputs] = add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ); + move16(); +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e)) mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp; move32(); mat_mult_buffer1_buff_e[i + j * num_outputs] = extract_l( L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ) ); move16(); +#endif /* OPT_MCH_DEC_V1_BE */ } } @@ -1586,9 +1609,14 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { +#ifdef OPT_MCH_DEC_V1_BE + mixing_matrix_fx[j + i * num_outputs] = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e); + move32(); +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e) mixing_matrix_fx[j + i * num_outputs] = L_tmp; move32(); +#endif /* OPT_MCH_DEC_V1_BE */ mixing_matrix_fx_e[j + i * num_outputs] = add( mat_mult_buffer1_buff_e[j + i * num_outputs], Kx_reg_inv_e[i] ); move16(); } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 09e3c0e6ced9f1ae5c3b4e10d3cd1a679cacc762..aa778fd2da0373b23f96dbc92030b9987b27a783 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1337,14 +1337,14 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( { gain_fx = 0; move16(); - tmp_e1 = 31; + tmp_e1 = 0; move16(); } - ELSE - { /*handling denominator equals to zero*/ - gain_fx = 1; + ELSE /*handling denominator equals to zero*/ + { + gain_fx = 32767; //(max value of Word16 in Q0) move16(); - tmp_e1 = -32767; //(-1.0f in Q15) + 1 + tmp_e1 = 15; move16(); } } @@ -1531,11 +1531,7 @@ static void ivas_ism_param_dec_render_sf_fx( Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 4bdc3cd742fec7d2d1beb7bfb6616a6deab93411..bcca2a71d79ea7ed669bd7ca8d66522aeb4eeb62 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -417,7 +417,11 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; +#endif move16(); } IF( hCPE->hStereoDft != NULL ) @@ -613,7 +617,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( ch = 0; ch < nchan_transport; ch++ ) { +#ifdef FIX_ISSUE_1792 + temp_min = L_norm_arr( p_output_fx[ch], output_frame ); +#else temp_min = getScaleFactor32( p_output_fx[ch], output_frame ); +#endif Q_p_output = s_min( Q_p_output, temp_min ); } Q_p_output = sub( Q_p_output, 2 ); @@ -933,7 +941,11 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; +#endif move16(); } IF( hCPE->hStereoDft != NULL ) @@ -979,7 +991,6 @@ ivas_error ivas_jbm_dec_tc_fx( IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda } @@ -1014,18 +1025,30 @@ ivas_error ivas_jbm_dec_tc_fx( { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 Q_p_output = 14; - move16(); Word16 nchan_transport; // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; move16(); nchan_out = nchan_transport; move16(); + Word16 Q_p_output; + Word16 min_norm = 31; + move16(); + + FOR( ch = 0; ch < nchan_transport; ++ch ) + { + Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel + min_norm = s_min( norm, min_norm ); + } + + Q_p_output = s_max( 3, sub( min_norm, 1 ) ); + + Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 FOR( ch = 0; ch < nchan_transport; ch++ ) { - Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); // Q_p_output + Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 } + Q_p_output = add( Q11, Q_p_output ); hSpar->hMdDec->Q_mixer_mat = 31; move16(); @@ -1369,7 +1392,11 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; +#endif move16(); } IF( hCPE->hStereoDft != NULL ) @@ -2145,11 +2172,7 @@ ivas_error ivas_jbm_dec_render_fx( /* add already rendered SBA part */ FOR( n = 0; n < nchan_out; n++ ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -2255,10 +2278,10 @@ ivas_error ivas_jbm_dec_render_fx( FOR( i = 0; i < nchan_in; i++ ) { - scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor IF( st_ivas->hDecoderConfig->Opt_tsm ) { - scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } } @@ -2279,6 +2302,18 @@ ivas_error ivas_jbm_dec_render_fx( return error; } + // Todo main-pc update: This might be needed also in the split rendering path + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) + { + FOR( i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); + } + } + } + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); } @@ -2654,7 +2689,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); - FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } @@ -4045,15 +4080,15 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( &cldfb_real_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &Q_tc ); - IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) - { - st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = sub( 31, Q_tc ); - st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = sub( 31, Q_tc ); - move16(); - move16(); - } } } + IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) + { + st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + move16(); + move16(); + } } hTcBuffer->n_samples_rendered = 0; move16(); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index d05cf0afd1b712aff4bd0ef0ead36301ef9fe23a..3133c8c57752b90884c94727cab98a97abffa2b7 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1541,11 +1541,11 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( } ELSE { - tmp16 = shr( McMASA_LFEGain_vectors_fx_q13[4 * lfeToTotalEnergyRatioIndices[2] + i], 1 ); /* Q12 */ - tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ - tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ - tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ - hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ + tmp16 = shr( extract_l( L_shr_r( McMASA_LFEGain_vectors_fx[4 * lfeToTotalEnergyRatioIndices[2] + i], Q12 ) ), 1 ); /* Q12 */ + tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ + tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ + tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ + hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ move16(); } @@ -2054,7 +2054,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( } ELSE { - sf = idiv1616( hSpar->render_to_md_map[slot_idx + slot_idx_start], JBM_CLDFB_SLOTS_IN_SUBFRAME ); + sf = shr( hSpar->render_to_md_map[slot_idx + slot_idx_start], JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 ); } IF( LT_16( sf, SPAR_META_DELAY_SUBFRAMES ) ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index d8a3d67c44212e3fe8f40da8314f3231da5c97ad..c8cfe7af21a71508dbad9b110da85af6a830e8e1 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -528,12 +528,15 @@ ivas_error ivas_param_mc_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size ); + hParamMC->Cldfb_RealBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, cldfb_buf_size ); - + hParamMC->Cldfb_ImagBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); hParamMC->sz = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); move16(); @@ -2084,13 +2087,8 @@ void ivas_param_mc_dec_render_fx( { IF( hLsSetup.index_lfe[idx_lfe] != ch ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1 ); v_add_fixed_no_hdrm( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1, 0 ); - v_add_fixed( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } } @@ -2172,22 +2170,6 @@ void ivas_param_mc_dec_render_fx( } Word16 pos_idx; -#ifndef OPT_BIN_RENDERER_V2 - FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) - { - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) - { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 - } - } - } - } -#endif /* OPT_BIN_RENDERER_V2 */ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -2237,13 +2219,8 @@ void ivas_param_mc_dec_render_fx( Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); scale_sig32( output_f_fx[ch], len, 5 - 11 ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11 } @@ -2397,13 +2374,21 @@ static void param_mc_protoSignalComputation_fx( FOR( band = 0; band < num_freq_bands; band++ ) { - Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#ifdef FIX_1737_proto_fac_overflow + Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 +#else + Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); move32(); p_proto_frame_fx++; - tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#ifdef FIX_1737_proto_fac_overflow + tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 +#else + tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); move32(); @@ -3629,7 +3614,11 @@ static ivas_error param_mc_get_diff_proto_info_fx( { p_diff_proto_info->source_chan_idx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = cur_transport_ch; move16(); +#ifdef FIX_1737_proto_fac_overflow + p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; // (proto_fac_fx)Q26 = Q26 +#else p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = L_shl( *proto_fac_ptr, 4 ); // (proto_fac_fx)Q26 + 4 = Q30 +#endif move16(); p_diff_proto_info->num_source_chan_diff[cur_diff_proto] = add( p_diff_proto_info->num_source_chan_diff[cur_diff_proto], 1 ); move16(); diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index b6da5c01b8549716fcac20659f228a4a81017bd3..af2506b95ac60dfef43416d6f04bb6bdba817303 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -887,23 +887,6 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_ImagBuffer_subfr_fx, &input_q ); Word16 pos_idx; -#ifndef OPT_BIN_RENDERER_V2 - FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) - { - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) - { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 - } - } - } - } -#endif /* OPT_BIN_RENDERER_V2 */ - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -931,28 +914,8 @@ static void ivas_mc_paramupmix_dec_sf( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; - move16(); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); // Q5 -> Q11 - } -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -978,13 +941,8 @@ static void ivas_mc_paramupmix_dec_sf( ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; // Q6 ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; // Q6 -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), hMCParamUpmix->num_freq_bands, 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), - hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index b42eb534b34af52b78b359306728ea7fd919f4a3..bc2471e24106f0ee994e29feb71f019fc7316524 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -198,7 +198,10 @@ void ivas_mct_core_dec( Word16 tcx_offset; Word16 tcx_offsetFB; Word16 left_rect; - Word16 L_spec, scale, tmp1, tmp2; + Word16 L_spec; +#ifndef OPT_SBA_DEC_PATH + Word16 scale, tmp1, tmp2; +#endif /* OPT_SBA_DEC_PATH */ #ifdef DEBUG_MCT float nrg[MCT_MAX_CHANNELS]; #endif @@ -218,11 +221,18 @@ void ivas_mct_core_dec( move16(); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { +#ifndef OPT_SBA_DEC_PATH FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; i = add( i, 1 ); } +#else /* OPT_SBA_DEC_PATH */ + FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) ) + { + sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; + } +#endif /* OPT_SBA_DEC_PATH */ } i = 0; @@ -246,7 +256,11 @@ void ivas_mct_core_dec( move16(); x_fx[ch][0] = signal_out_fx[ch]; x_fx[ch][1] = signal_out_fx[ch] + ( L_FRAME48k / 2 ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } @@ -268,7 +282,77 @@ void ivas_mct_core_dec( { CONTINUE; } +#ifdef OPT_SBA_DEC_PATH + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + Word16 L_frame_2 = shr( st->L_frame, 1 ); + Word16 L_frameTCX_2 = shr( st->hTcxDec->L_frameTCX, 1 ); + nSubframes = NB_DIV; // assuming NB_DIV is 2. Below logic needs to be modified if NB_DIV changes. + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + L_spec = shr( st->hTcxCfg->tcx_coded_lines, 1 ); + move32(); + init_tcx_info_fx( st, L_frame_2, L_frameTCX_2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); + + Word16 x_e, x_len; + /* mono or dual mono IGF decoding */ + x_e = sub( 31, q_x[ch] ); + decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12 +#else /* OPT_SBA_DEC_V2_NBE */ + q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ + move16(); + FOR( i = 0; i < x_len; i++ ) + { + x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] ); + move32(); + } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ + q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ + move16(); + } + } + ELSE + { + nSubframes = 1; + move16(); + { + L_spec = st->hTcxCfg->tcx_coded_lines; + move32(); + + init_tcx_info_fx( st, st->L_frame, st->hTcxDec->L_frameTCX, 0, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); + + Word16 x_e, x_len; + /* mono or dual mono IGF decoding */ + x_e = sub( 31, q_x[ch] ); + decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12 +#else /* OPT_SBA_DEC_V2_NBE */ + q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ + move16(); + FOR( i = 0; i < x_len; i++ ) + { + x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] ); + move32(); + } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ + q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ + move16(); + } + } +#else /* OPT_SBA_DEC_PATH */ IF( EQ_16( st->core, TCX_10_CORE ) ) { nSubframes = NB_DIV; @@ -298,12 +382,21 @@ void ivas_mct_core_dec( move16(); FOR( i = 0; i < x_len; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q11 ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q12 ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } +#endif /* OPT_SBA_DEC_PATH */ } } ELSE @@ -318,19 +411,32 @@ void ivas_mct_core_dec( * MCT processing *--------------------------------------------------------------------------------*/ +#ifdef OPT_SBA_DEC_PATH + apply_MCT_dec_fx( hMCT, sts, x_fx ); +#else /* OPT_SBA_DEC_PATH */ apply_MCT_dec_fx( hMCT, sts, x_fx, q_x ); FOR( ch = 0; ch < nChannels; ch++ ) { FOR( i = 0; i < L_FRAME48k / 2; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q11 ) ); + x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q11 ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q12 ) ); x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q12 ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } +#endif /* OPT_SBA_DEC_PATH */ } pop_wmops(); diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index cee3a81b21d2a6e858dcb3a9060eb7bfdfc87d70..9b622bdcd5f7432bd0c67fb00b4fa1933158dfae 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -64,7 +64,7 @@ ivas_error ivas_mct_dec_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ) { - Word16 ch, nCPE, cpe_id; + Word16 nCPE, cpe_id; MCT_DEC_HANDLE hMCT; CPE_DEC_HANDLE hCPE; Word16 param[MCT_MAX_BLOCKS][CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV]; @@ -76,10 +76,13 @@ ivas_error ivas_mct_dec_fx( Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; // Q12 Word32 output_lfe_ch_fx[L_FRAME48k]; Word16 q_output = 11; - Word16 n, k, i; + Word16 n, i; Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e) +#ifndef OPT_SBA_DEC_V2_NBE Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]; + Word16 ch, k; +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV]; set16_fx( x_len[0], 0, NB_DIV ); set16_fx( x_len[1], 0, NB_DIV ); @@ -182,21 +185,31 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][0] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][1] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 ); set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 ); } +#ifndef OPT_SBA_DEC_V2_NBE ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], fUseTns[cpe_id], tnsData[cpe_id], x_fx, x_e, x_fx, x_e, x_len, Aq_fx[cpe_id], NULL, 1 ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], + fUseTns[cpe_id], tnsData[cpe_id], x_fx, 20, x_fx, 20, x_len, Aq_fx[cpe_id], NULL, 1 ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { Word16 subFrames; @@ -214,6 +227,7 @@ ivas_error ivas_mct_dec_fx( Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); // Scaling back to Q11 } } +#endif /* OPT_SBA_DEC_V2_NBE */ st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect ); move16(); @@ -224,18 +238,22 @@ ivas_error ivas_mct_dec_fx( /* MCT core decoder */ Word16 q_x[MAX_TRANSPORT_CHANNELS]; +#ifndef OPT_SBA_DEC_V2_NBE set16_fx( q_x, Q12, MAX_TRANSPORT_CHANNELS ); // Scaling output buffer to q_x FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); // Q11 -> Q12 } +#endif /* OPT_SBA_DEC_V2_NBE */ ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x ); // Scaling output buffer back to Q11 +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); // Q12 -> Q11 } +#endif /* OPT_SBA_DEC_V2_NBE */ /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ @@ -263,16 +281,25 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][0] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][1] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } +#ifndef OPT_SBA_DEC_V2_NBE ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, x_e ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( Word16 ind = 0; ind < 2; ind++ ) { Word16 nSubFrames; @@ -291,6 +318,7 @@ ivas_error ivas_mct_dec_fx( Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); // Q11 } } +#endif /* OPT_SBA_DEC_V2_NBE */ } @@ -347,22 +375,37 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); - +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + Word16 hdrm; +#else Word16 hdrm, sh; +#endif hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); IF( hdrm != 0 ) { +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + hdrm = sub( hdrm, 1 ); + Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm ); + e_sig[0] = sub( e_sig[0], hdrm ); +#else sh = s_min( sub( e_sig[0], 16 ), hdrm ); Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sh ); e_sig[0] = sub( e_sig[0], sh ); +#endif move16(); } hdrm = getScaleFactor16( synth_fx[1], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); IF( hdrm != 0 ) { +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + hdrm = sub( hdrm, 1 ); + Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm ); + e_sig[1] = sub( e_sig[1], hdrm ); +#else sh = s_min( sub( e_sig[1], 16 ), hdrm ); Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sh ); e_sig[1] = sub( e_sig[1], sh ); +#endif move16(); } diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 0f20c1ec0fbdd12dc61b9d97a6d8bf256733fbb5..f470ac9cd41e16ef3c8ca323f94aad8ce8a0bd39 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -165,8 +165,12 @@ void ivas_mct_dec_mct_fx( static void applyGlobalILD_fx( Decoder_State **sts, MCT_DEC_HANDLE hMCT, - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], - Word16 q_x[MCT_MAX_CHANNELS] ) + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 ch, k; Word16 nSubframes, L_subframeTCX; @@ -207,9 +211,14 @@ static void applyGlobalILD_fx( FOR( k = 0; k < nSubframes; k++ ) { v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio +#ifdef OPT_SBA_DEC_PATH + scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) ); +#endif /* OPT_SBA_DEC_PATH */ } +#ifndef OPT_SBA_DEC_PATH q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio ); move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE { @@ -228,10 +237,14 @@ static void applyGlobalILD_fx( *----------------------------------------------------------*/ void apply_MCT_dec_fx( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */ - Word16 q_x[MCT_MAX_CHANNELS] ) + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + Decoder_State **sts, /* i/o: decoder state structure */ + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 pair; MCT_DEC_BLOCK_DATA_HANDLE hBlock; @@ -240,10 +253,18 @@ void apply_MCT_dec_fx( { hBlock = hMCT->hBlockData[pair]; +#ifndef OPT_SBA_DEC_PATH stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0, &q_x[hBlock->ch2], &q_x[hBlock->ch1] ); +#else /* OPT_SBA_DEC_PATH */ + stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 ); +#endif /* OPT_SBA_DEC_PATH */ } +#ifndef OPT_SBA_DEC_PATH applyGlobalILD_fx( sts, hMCT, x, q_x ); +#else /* OPT_SBA_DEC_PATH */ + applyGlobalILD_fx( sts, hMCT, x ); +#endif /* OPT_SBA_DEC_PATH */ return; } @@ -302,8 +323,13 @@ void mctStereoIGF_dec_fx( move16(); // Using input Q-factor as 12 +#ifdef OPT_SBA_DEC_V2_NBE + set16_fx( p_x_e[0], 31 - Q11, CPE_CHANNELS ); // Q12 + set16_fx( p_x_e[1], 31 - Q11, CPE_CHANNELS ); // Q12 +#else /* OPT_SBA_DEC_V2_NBE */ set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); // Q12 set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); // Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( k = 0; k < nSubframes; k++ ) { @@ -332,13 +358,21 @@ void mctStereoIGF_dec_fx( decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ ); // Shifting output with variable exponent back to Q12 +#ifdef OPT_SBA_DEC_V2_NBE + shr_k = sub( 31 - Q11, p_x_e[0][k] ); +#else /* OPT_SBA_DEC_V2_NBE */ shr_k = sub( 31 - Q12, p_x_e[0][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( Word16 i = 0; i < p_x_len[0][k]; i++ ) { p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k ); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + shr_k = sub( 31 - Q11, p_x_e[1][k] ); +#else /* OPT_SBA_DEC_V2_NBE */ shr_k = sub( 31 - Q12, p_x_e[1][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( Word16 i = 0; i < p_x_len[1][k]; i++ ) { p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k ); @@ -371,7 +405,11 @@ void mctStereoIGF_dec_fx( /* mono or dual mono IGF decoding */ +#ifdef OPT_SBA_DEC_V2_NBE + x_e = 31 - Q11; // input q-factor of x[p_ch[ch]][k] is Q12 +#else /* OPT_SBA_DEC_V2_NBE */ x_e = 31 - Q12; // input q-factor of x[p_ch[ch]][k] is Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); decoder_tcx_IGF_mono_fx( st, x[p_ch[ch]][k], &x_e, &x_len, L_frame[ch], left_rect[ch], bfi, k ); @@ -379,7 +417,11 @@ void mctStereoIGF_dec_fx( FOR( Word16 i = 0; i < x_len; i++ ) { // Converting from variable exponent to Fixed q-factor (Q12) +#ifdef OPT_SBA_DEC_V2_NBE + x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q11, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q12, x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } } @@ -431,7 +473,11 @@ void mctStereoIGF_dec_fx( init_tcx_info_fx( st, L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] ); /* mono or dual mono IGF decoding */ +#ifdef OPT_SBA_DEC_V2_NBE + x_e = 31 - Q11; // Input Q-factor is Q12. +#else /* OPT_SBA_DEC_V2_NBE */ x_e = 31 - Q12; // Input Q-factor is Q12. +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); decoder_tcx_IGF_mono_fx( st, x[ch][k], &x_e, &x_len, L_frame[0], left_rect[0], bfi, k ); @@ -439,7 +485,11 @@ void mctStereoIGF_dec_fx( FOR( Word16 i = 0; i < x_len; i++ ) { // Converting from variable exponent to Fixed q-factor (Q12) +#ifdef OPT_SBA_DEC_V2_NBE + x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q11, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q12, x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index fabebede4e6e468526331188d065f9086d1715c9..2baa31d22db37abfd1f956256654a4c820577083 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -630,9 +630,17 @@ void ivas_mdct_core_invQ_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_0_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_0_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV], Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients Q12*/ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ @@ -737,7 +745,11 @@ void ivas_mdct_core_invQ_fx( q_r = sub( 30, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ); /* both input in same Q */ +#ifndef OPT_SBA_DEC_PATH stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l ); +#else /* OPT_SBA_DEC_PATH */ + stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 ); +#endif /* OPT_SBA_DEC_PATH */ Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15 Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15 @@ -959,9 +971,11 @@ void ivas_mdct_core_invQ_fx( IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { +#ifndef OPT_SBA_DEC_V2_NBE set32_fx( x[ch][0], 0, st->hTcxCfg->tcx_coded_lines ); x_e[ch][0] = 31; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ /* usually set in decoder_tcx_invQ(), needed for concealment */ st->hTcxDec->damping = 0; move16(); @@ -993,6 +1007,10 @@ void ivas_mdct_core_invQ_fx( FOR( k = 0; k < nSubframes[ch]; k++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e_local = x_e; + Word16 j, diff; +#endif /* OPT_SBA_DEC_V2_NBE */ /* Stability Factor */ IF( !bfi ) { @@ -1027,17 +1045,38 @@ void ivas_mdct_core_invQ_fx( nf_seed = 0; move16(); - decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); + diff = sub( x_e_local, x_0_e ); + IF( diff != 0 ) + { + FOR( j = 0; j < L_frameTCX[ch]; j++ ) + { + x_0[ch][k][j] = L_shl_sat( x[ch][k][j], diff ); + move32(); + } + } + ELSE + { + Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); + } +#else /* OPT_SBA_DEC_V2_NBE */ + decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); +#endif /* OPT_SBA_DEC_V2_NBE */ shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] ); move16(); Scale_sig32( x[ch][k], L_frameTCX[ch], shift ); +#ifdef OPT_SBA_DEC_V2_NBE + x_e_local = sub( x_e_local, shift ); +#else /* OPT_SBA_DEC_V2_NBE */ x_e[ch][k] = sub( x_e[ch][k], shift ); move16(); Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); x_0_e[ch][k] = x_e[ch][k]; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ // PLC to be done test(); @@ -1046,15 +1085,29 @@ void ivas_mdct_core_invQ_fx( TonalMdctConceal_create_concealment_noise_ivas_fx( concealment_noise_fx[ch], &concealment_noise_e[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi ); } +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k ); +#else /* OPT_SBA_DEC_V2_NBE */ decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k ); +#endif /* OPT_SBA_DEC_V2_NBE */ shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] ); move16(); Scale_sig32( x[ch][k], L_frameTCX[ch], shift ); +#ifdef OPT_SBA_DEC_V2_NBE + x_e_local = sub( x_e_local, shift ); +#else /* OPT_SBA_DEC_V2_NBE */ x_e[ch][k] = sub( x_e[ch][k], shift ); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e_local, &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi ); + + Scale_sig32( x[ch][k], L_frameTCX[ch], sub( x_e_local, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e[ch][k], &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi ); +#endif /* OPT_SBA_DEC_V2_NBE */ } } } @@ -1098,8 +1151,17 @@ void ivas_mdct_core_reconstruct_fx( Word16 *synthFB_fx; Word16 q_syn = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win = 0; + Word16 q_winFB = 0; +#else +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 q_win = -1; +#else Word16 q_win = -2; +#endif move16(); +#endif /* TCX */ Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2) Word16 tcx_offset[CPE_CHANNELS]; @@ -1160,32 +1222,79 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->q_old_synth = 0; move16(); } +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth +#endif q_syn = st->hTcxDec->q_old_synth; move16(); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win0 = Q15; + move16(); + Word16 q_winFB0 = Q15; + move16(); +#else Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + st->hTcxDec->Q_syn_Overl_TDACFB = q_win; + move16(); + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + st->hTcxDec->Q_syn_Overl_TDAC = q_win; + move16(); + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + move16(); + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + st->hHQ_core->Q_old_wtda = q_win; + move16(); + st->hHQ_core->Q_old_wtda_LB = q_win; + move16(); +#endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win +#endif + FOR( k = 0; k < nSubframes[ch]; k++ ) { init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + assert( nSubframes[ch] <= 2 ); + q_win0 = q_win; + move16(); + q_winFB0 = q_winFB; + move16(); + q_win = -2; + move16(); + q_winFB = -2; + move16(); +#endif + IF( !skip_decoding ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + test(); + test(); + IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) + { + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, + MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); + } + ELSE + { + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, + st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); + } +#else test(); test(); IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) @@ -1198,21 +1307,86 @@ void ivas_mdct_core_reconstruct_fx( decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } +#endif } ELSE { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + q_win = Q15; + move16(); + q_winFB = Q15; + move16(); +#endif set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] ); /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + st->hHQ_core->Q_old_wtda = Q15; + st->hHQ_core->Q_old_wtda_LB = Q15; +#endif set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_OverlFB[0], 0, shr( L_frameTCX[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_Overl_TDAC[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_Overl_TDACFB[0], 0, shr( L_frameTCX[ch], 1 ) ); } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + + IF( nSubframes[ch] > 1 ) + { + Word16 q_winN, q_winFBN; + + q_winN = s_min( q_win, q_win0 ); + q_winFBN = s_min( q_winFB, q_winFB0 ); + // Need to rescale for each subframe, because q_win/q_winFB might had changed for the next subframe. Other OLA buffers are rescaled each time. + Scale_sig( synth_fx, L_frame[ch], sub( q_winN, q_win0 ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synthFB_fx, L_frameTCX[ch], sub( q_winFBN, q_winFB0 ) ); // q_winFB -> st->hTcxDec->q_old_synth + Scale_sig( synth_fx + L_frame[ch], add( L_frame[ch], M ), sub( q_winN, q_win ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synthFB_fx + L_frameTCX[ch], add( L_frameTCX[ch], M ), sub( q_winFBN, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth + q_win = q_winN; + move16(); + q_winFB = q_winFBN; + move16(); + } + + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // q_win + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); // q_winFB + + test(); + IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) + { + TonalMDCTConceal_SaveTimeSignal_ivas_fx( st->hTonalMDCTConc, synthFB_fx, q_winFB, L_frameTCX[ch] ); + } + decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_winFB, NULL, bfi, MCT_flag ); + + // norm(synth_buf) >= q_syn - q_win + // norm(synth_buf) + q_win >= q_syn + sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) ); + q_syn = add( sub( sf, 1 ), s_min( q_win, q_winFB ) ); + st->Q_syn = q_syn; + move16(); + + // norm(old_out) >= st->Q_syn - q_win + // norm(old_out) + q_win >= st->Q_syn + sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); + st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); + + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn + // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); + Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, st->prev_Q_syn ) ); // st->Q_syn gets a new value, but st->mem_syn2_fx got its value from E_UTIL_f_preemph3 with st->Q_syn = st->prev_Q_syn + } + ELSE + { + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, add( q_win, 2 ) ) ); // q_win+2 -> st->Q_syn: in this case, E_UTIL_f_preemph2 shifts st->mem_syn2_fx by 2 bits + } +#else test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) { @@ -1245,16 +1419,33 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + st->hTcxDec->Q_syn_OverlFB = st->Q_syn; + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + st->hTcxDec->Q_syn_Overl = st->Q_syn; +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); +#endif +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn +#endif } ELSE /*ACELP core for ACELP-PLC */ { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth + + // Temporary workaround: con_tcx_ivas_fx() should be analyzed for potential issues. + // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); + // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); + /////////////////////////////////////////////////////////////////////////////////// +#endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) @@ -1283,6 +1474,13 @@ void ivas_mdct_core_reconstruct_fx( st->Q_syn = q_syn; move16(); st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn ); + move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); + move16(); + // st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions. + // move16(); +#endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { @@ -1454,7 +1652,11 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS Q(31 - x_e)*/ Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients Q16*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e ) +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV] ) +#endif /* OPT_SBA_DEC_V2_NBE */ { Word16 ch, k, bfi; Decoder_State **sts, *st; @@ -1528,7 +1730,11 @@ void ivas_mdct_core_tns_ns_fx( &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); Word16 q_x; +#ifdef OPT_SBA_DEC_V2_NBE + q_x = sub( 31, x_e ); +#else /* OPT_SBA_DEC_V2_NBE */ q_x = sub( 31, x_e[ch][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ IF( bfi == 0 ) { sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); // Q16 @@ -1547,7 +1753,11 @@ void ivas_mdct_core_tns_ns_fx( scf_e[ind] = sub( 15, q_shift ); move16(); } +#ifdef OPT_SBA_DEC_V2_NBE + TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); +#else /* OPT_SBA_DEC_V2_NBE */ TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ } } ELSE @@ -1609,8 +1819,10 @@ void ivas_mdct_core_tns_ns_fx( norm_x = getScaleFactor32( &x_fx[ch][k][0], length ); Scale_sig32( &x_fx[ch][k][0], length, norm_x ); q_x = add( q_x, norm_x ); +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 q_sns_int_scf; Word16 q_2; @@ -1637,8 +1849,10 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0] + length, sub( length2, length ), sub( add( q_x, 1 ), q_2 ) ); q_x = add( q_x, 1 ); } +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) ); @@ -1646,8 +1860,10 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) ); q_x = q_2; move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ q_x = sub( q_x, 5 ); length = L_frameTCX[ch]; @@ -1664,25 +1880,37 @@ void ivas_mdct_core_tns_ns_fx( } Scale_sig32( &x_fx[ch][k][0], length, -5 ); decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0, &length ); +#ifndef OPT_SBA_DEC_V2_NBE norm_x = getScaleFactor32( &x_fx[ch][k][0], length ); Scale_sig32( &x_fx[ch][k][0], length, norm_x ); q_x = add( q_x, norm_x ); x_e[ch][k] = sub( 31, q_x ); move16(); +#else /* OPT_SBA_DEC_V2_NBE */ + Scale_sig32( &x_fx[ch][k][0], length, sub( sub( 31, q_x ), x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ } IF( ( bfi != 0 ) && ( st->tonal_mdct_plc_active != 0 ) ) { - Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16, i; +#ifndef OPT_SBA_DEC_V2_NBE + Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ + Word16 i; FOR( i = 0; i < FDNS_NPTS; i++ ) { st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); } +#ifndef OPT_SBA_DEC_V2_NBE set16_fx( tmp_x_fx_exp, x_e[ch][0], L_FRAME48k ); TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent ); +#else /* OPT_SBA_DEC_V2_NBE */ + TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], x_e, st->hTcxCfg->psychParamsCurrent ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < L_FRAME48k; i++ ) { temp = s_max( temp, tmp_x_fx_exp[i] ); @@ -1697,6 +1925,7 @@ void ivas_mdct_core_tns_ns_fx( move32(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ } test(); diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 59611527830058104fc767b67c4d0bfe9faff4a6..bc96bf46c537fdf2b13e514c86046b8ebb7c4d52 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -695,6 +695,11 @@ void ivas_ls_setup_conversion_process_mdct_fx( Word16 guard_1 = shr( add( find_guarded_bits_fx( tmp_sub ), 1 ), 1 ); Word16 guard_2 = find_guarded_bits_fx( L_mult0( outChannels, inChannels ) ); q_output = sub( q_output, s_max( guard_1, guard_2 ) ); + /* Increase the guard bit by 1 to avoid overflow only if q_output is positive */ + if ( q_output > 0 ) + { + q_output = sub( q_output, 1 ); + } FOR( i = 0; i < inChannels; ++i ) { @@ -1028,6 +1033,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( Word16 start, stop, start_tcx5, stop_tcx5; Word16 mct_chan_mode[MAX_CICP_CHANNELS]; + Word16 all_ch_ignored; // Flag for checking if all channels are ignored /* Declare all handles */ LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; @@ -1130,13 +1136,22 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); Word16 max_e = 0; move16(); + all_ch_ignored = 1; + move16(); FOR( idx = 0; idx < nchan_transport; idx++ ) { IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) ) { max_e = s_max( max_e, x_e[idx][0] ); + all_ch_ignored = 0; + move16(); } } + if ( all_ch_ignored ) + { + max_e = 31; + move16(); + } FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { set_zero_fx( real_in_buffer_fx, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS ); @@ -1164,22 +1179,32 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } } } - Word16 shift = 1; + input_exp = max_e; move16(); - FOR( i = 0; i < num_bands * nchan_transport; ++i ) + IF( all_ch_ignored == 0 ) { - real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); - move32(); - imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); - move32(); + Word16 shift = 1; + move16(); + FOR( i = 0; i < num_bands * nchan_transport; ++i ) + { + real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); + move32(); + imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); + move32(); + } + input_exp = add( input_exp, shift ); } - input_exp = max_e; - move16(); - input_exp = add( input_exp, shift ); + cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp ); v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ } + if ( all_ch_ignored ) + { + output_exp = 29; + move16(); + } + Word16 exp_in = 10, exp_out = 0; move16(); move16(); diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index c0e69b91663e2275b0398e4dec3439df3baf5c1b..1b02b2b17fa81322d0581b49a56ebe28bc1532af 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -112,6 +112,9 @@ void ivas_post_proc_fx( { Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/ move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + assert( sts[n]->hHQ_core->Q_old_out_fx32 == Q11 ); +#endif Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/ } @@ -588,7 +591,11 @@ void stereo_dft_dec_core_switching_fx( Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32; +#else hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx; +#endif move16(); test(); diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index ba8c529d71c83365484a127b9f30b36a60e37d1e..7a96185b9c7a8838e8cfd40e4502a9ad1a610b60 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -77,11 +77,7 @@ void ivas_sba2mc_cldfb_fixed( FOR( m = 0; m < nb_channels_in; m++ ) { -#ifdef OPT_BIN_RENDERER_V2 g_fx = L_shl_sat( hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )], Q2 ); -#else /* OPT_BIN_RENDERER_V2 */ - g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 -#endif /* OPT_BIN_RENDERER_V2 */ p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; @@ -91,15 +87,9 @@ void ivas_sba2mc_cldfb_fixed( p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/ FOR( iBand = 0; iBand < nb_bands; iBand++ ) { -#ifdef OPT_BIN_RENDERER_V2 *p_realOut_fx = Madd_32_32( *p_realOut_fx, g_fx, *( p_real_fx++ ) ); // Q_real move32(); *p_imagOut_fx = Madd_32_32( *p_imagOut_fx, g_fx, *( p_imag_fx++ ) ); // Q_imag -#else /* OPT_BIN_RENDERER_V2 */ - *p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real - move32(); - *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag -#endif /* OPT_BIN_RENDERER_V2 */ move32(); p_realOut_fx++; p_imagOut_fx++; @@ -177,11 +167,7 @@ void ivas_mc2sba_fx( /* Add LFE to omni W with gain*/ FOR( k = 0; k < output_frame; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 buffer_tmp_fx[0][k] = Madd_32_16( buffer_tmp_fx[0][k], L_shl( in_buffer_td_fx[i][k], 1 ), gain_lfe_fx ); /*Q+14-15+1==Q*/ -#else /* OPT_BIN_RENDERER_V2 */ - buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/ -#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } @@ -210,11 +196,7 @@ void ivas_mc2sba_fx( { FOR( k = 0; k < output_frame; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 buffer_tmp_fx[j][k] = Madd_32_32( buffer_tmp_fx[j][k], L_shl_sat( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/ -#else /* OPT_BIN_RENDERER_V2 */ - buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/ -#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } @@ -523,7 +505,7 @@ void ivas_sba_mix_matrix_determiner_fx( temp_fx = MAX16B; /*Q0*/ move32(); } - ELSE IF( LT_32( temp_fx, L_negate( PCM16_TO_FLT_FAC_FX ) ) ) + ELSE IF( LT_32( temp_fx, -( PCM16_TO_FLT_FAC_FX ) ) ) { temp_fx = -( PCM16_TO_FLT_FAC_FX ); /*Q0*/ move32(); diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index da7e1c0994c859259348f36badfa86e553dc157a..4a95f4d35d7e586f204f94c6783937e167aac82d 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -787,11 +787,7 @@ void ivas_spar_get_cldfb_gains_fx( cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb ); cldfb_reset_memory_fx( cldfbSynDec0 ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, 0, cldfbSynDec0 ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, cldfbSynDec0 ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( sample = 0; sample < stride; sample++ ) { T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/ @@ -2104,11 +2100,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } @@ -2123,11 +2115,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[out_ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[out_ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } } diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 36b77732ae7e3eb7e66d842147d5a9830d7bae39..fdb29e842026e4ea644c553cd636c0d094130545 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -44,6 +44,9 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC +#define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */ +#endif #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) @@ -1715,7 +1718,7 @@ static void ivas_spar_dec_parse_md_bs_fx( { *nB = SPAR_DTX_BANDS; move16(); - *bands_bw = idiv1616( num_bands, *nB ); /*Q0*/ + *bands_bw = shr( num_bands, SPAR_DTX_BANDS_LOG2 ); /*Q0*/ move16(); FOR( i = 0; i < *nB; i++ ) @@ -2959,8 +2962,13 @@ void ivas_spar_to_dirac_fx( radius_fx = Sqrt32( temp, &q_temp ); Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/ - Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 azi_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_azi_fx ); +#else Word16 check_azi_fx_res; + Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + IF( check_azi_fx_32 < 0 ) { check_azi_fx_res = negate( divide3232( L_negate( check_azi_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ @@ -2970,7 +2978,9 @@ void ivas_spar_to_dirac_fx( check_azi_fx_res = divide3232( check_azi_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/ - azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ +#endif + + azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 azi_res; IF( azi_intermediate < 0 ) @@ -2983,9 +2993,14 @@ void ivas_spar_to_dirac_fx( } Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/ - Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 ele_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_ele_fx ); +#else + Word16 check_ele_fx_res; - IF( check_azi_fx_32 < 0 ) + Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ + + IF( check_ele_fx_32 < 0 ) { check_ele_fx_res = negate( divide3232( L_negate( check_ele_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ } @@ -2994,7 +3009,8 @@ void ivas_spar_to_dirac_fx( check_ele_fx_res = divide3232( check_ele_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/ - ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ +#endif + ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 ele_res; IF( ele_intermediate < 0 ) diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 8ec147ff7edf274f9e776c99924c186ac0e6a6c3..463032467ed8b90f0d9c942ea1e135f50617ea8a 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1446,11 +1446,7 @@ void stereo_cna_update_params_fx( { IF( EQ_16( hCPE->nchan_out, 1 ) ) { -#ifdef OPT_STEREO_32KBPS_V1 c_LR_fx = MAX_32; -#else /* OPT_STEREO_32KBPS_V1 */ - c_LR_fx = MAX_WORD16; -#endif /* OPT_STEREO_32KBPS_V1 */ move32(); c_ILD_fx = 0; move32(); @@ -1513,11 +1509,7 @@ void stereo_cna_update_params_fx( dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) ); dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */ /* estimate L/R correlation factor and ILD in time domain */ -#ifdef OPT_STEREO_32KBPS_V1 - c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ -#else /* OPT_STEREO_32KBPS_V1 */ - c_LR_fx = extract_h( W_extract_l( dotLR_fx ) ); /* Q15 */ -#endif /* OPT_STEREO_32KBPS_V1 */ + c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ temp_res_q = 0; move16(); @@ -1556,24 +1548,15 @@ void stereo_cna_update_params_fx( /* update of long-term ILD and LR correlation factors for stereo CNA */ IF( !hFdCngDec->first_cna_noise_updated ) { -#ifdef OPT_STEREO_32KBPS_V1 hFdCngDec->cna_LR_LT_fx = extract_h( c_LR_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx ); move16(); } ELSE { -#ifdef OPT_STEREO_32KBPS_V1 hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), Mpy_32_32( ONE_IN_Q31 - STEREO_CNA_LR_CORR_LT_FILT_FX, c_LR_fx ) ) ); /* Q31 */ -#else /* OPT_STEREO_32KBPS_V1 */ - hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), - Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) ); /* Q31 */ -#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ), diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 914c7fad17b255839f68fe1cfd598a15caef587a..7d3bec07d2135d922a19fc6527c9cc8f8fe0b92f 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1881,10 +1881,6 @@ void stereo_dft_dec_fx( HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; Word16 *cna_seed = &( hFdCngCom->seed ); Word32 DFT_W, DFT_Y; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 q_samp_ratio = Q15; - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 len; output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1893,12 +1889,7 @@ void stereo_dft_dec_fx( * Initialization *-----------------------------------------------------------------*/ -#ifdef OPT_STEREO_32KBPS_V1 samp_ratio = divide3232( st0->sr_core, st0->output_Fs ); // Q15 -#else /* OPT_STEREO_32KBPS_V1 */ - samp_ratio = (Word16) BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); - samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ stop = shr( STEREO_DFT32MS_N_32k, 1 ); @@ -2473,17 +2464,10 @@ void stereo_dft_dec_fx( /*Nyquist Freq.*/ IF( EQ_16( hStereoDft->band_limits[b], shr( hStereoDft->NFFT, 1 ) ) ) { -#ifdef OPT_STEREO_32KBPS_V1 DFT_L[1] = Madd_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ move32(); DFT_R[1] = Msub_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - DFT_L[1] = L_add( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ - move32(); - DFT_R[1] = L_sub( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = Mpy_32_16_1( DFT_L[1], INV_SQRT2_FX_Q15 ); /* qDFT */ move32(); DFT_R[1] = Mpy_32_16_1( DFT_R[1], INV_SQRT2_FX_Q15 ); /* qDFT */ @@ -2608,7 +2592,7 @@ void stereo_dft_dec_fx( q_cna_level = hFdCngDec->smoothed_psd_exp; move16(); l_tmp = Sqrt32( cna_level, &q_cna_level ); - scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* q_cna_level */ + scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* Q = (31-q_cna_level) + Q15 - 31 */ /* scale_fact0 will be in Q15 by the time the above operation is performed so the q of scale_fact represented now by q_cna_level has to be updated @@ -2616,52 +2600,28 @@ void stereo_dft_dec_fx( q_cna_level = sub( Q31, add( q_cna_level, Q16 ) ); /* generate comfort noise from gaussian noise and add to the decoded DFT spectrum */ -#ifdef OPT_STEREO_32KBPS_V1 Word16 shift = sub( q_cna_level, hStereoDft->q_dft ); -#endif /* OPT_STEREO_32KBPS_V1 */ N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ -#ifdef OPT_STEREO_32KBPS_V1 - l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, shift ); /* q_dft */ -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ - DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); -#ifdef OPT_STEREO_32KBPS_V1 l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ + DFT_R[2 * i] = L_add_sat( DFT_R[2 * i], l_tmp ); /* q_dft */ move32(); N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ -#ifdef OPT_STEREO_32KBPS_V1 - l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ move32(); l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ - move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ - move32(); - l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ + DFT_R[2 * i + 1] = L_add_sat( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -2749,12 +2709,7 @@ static void stereo_dft_compute_td_stefi_params_fx( return; } -#ifdef OPT_STEREO_32KBPS_V1 bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - bin0 = extract_l( L_shr_r( Mpy_32_16_1( (Word32) hStereoDft->NFFT, samp_ratio ), 1 ) ); /* Q0 */ - bin0 = shl( bin0, Q3 ); -#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; /* Q0 */ move16(); @@ -2919,18 +2874,14 @@ static void stereo_dft_dequantize_ipd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ -#ifdef OPT_STEREO_32KBPS_V1 - const Word16 samp_ratio, /* i : sampling ratio Q15*/ -#else /* OPT_STEREO_32KBPS_V1 */ - const Word16 samp_ratio, /* i : sampling ratio Q13*/ -#endif /* OPT_STEREO_32KBPS_V1 */ - Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ - Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ - Word32 *pPredGain, /* i : residual prediction gains Q31*/ - const Word16 k, /* i : subframe index Q0*/ - Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ - Word16 *stop, /* o : last FD stereo filling bin Q0*/ - const Word16 bfi /* i : BFI flag Q0*/ + const Word16 samp_ratio, /* i : sampling ratio Q15*/ + Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ + Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ + Word32 *pPredGain, /* i : residual prediction gains Q31*/ + const Word16 k, /* i : subframe index Q0*/ + Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ + Word16 *stop, /* o : last FD stereo filling bin Q0*/ + const Word16 bfi /* i : BFI flag Q0*/ ) { /* general variables */ @@ -2941,9 +2892,6 @@ void stereo_dft_generate_res_pred_fx( /* variables for enhanced stereo filling */ Word16 norm_fac, q_norm_fac; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 lim_norm_fac; -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 q_sqrt; Word16 alpha; // gain_limit; @@ -2957,12 +2905,7 @@ void stereo_dft_generate_res_pred_fx( Word32 pred_gain_avg; Word32 g2; Word16 nbands_respred; -#ifdef OPT_STEREO_32KBPS_V1 Word16 q_new, diff; -#else /* OPT_STEREO_32KBPS_V1 */ - q_norm_fac = 0; - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 len; push_wmops( "gen_respred" ); @@ -2985,12 +2928,7 @@ void stereo_dft_generate_res_pred_fx( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ -#ifdef OPT_STEREO_32KBPS_V1 bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - bin0 = (Word16) ( L_shr( L_add( L_mult0( hStereoDft->NFFT, samp_ratio ), ONE_IN_Q12 ), Q12 + 1 ) ); /* Q0 */ - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; move16(); @@ -3035,22 +2973,12 @@ void stereo_dft_generate_res_pred_fx( len = s_min( hStereoDft->band_limits[b + 1], bin0 ); FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ rev_nrg_64bit = W_mac_32_32( W_mac_32_32( rev_nrg_64bit, ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ -#else /* OPT_STEREO_32KBPS_V1 */ - dmx_nrg_64bit = W_add( dmx_nrg_64bit, - W_add( W_mult0_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), - W_mult0_32_32( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ - rev_nrg_64bit = W_add( rev_nrg_64bit, - W_add( W_mult0_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), - W_mult0_32_32( ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 q_new = add( shl( hStereoDft->q_dft, 1 ), 1 ); q_shift = W_norm( dmx_nrg_64bit ); dmx_nrg = W_shl_sat_l( dmx_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) @@ -3059,54 +2987,26 @@ void stereo_dft_generate_res_pred_fx( rev_nrg = W_shl_sat_l( rev_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) rev_nrg_q = add( q_new, sub( q_shift, 32 ) ); move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - q_shift = W_norm( dmx_nrg_64bit ); - dmx_nrg = W_extract_l( W_shl( dmx_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) - dmx_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); - q_shift = W_norm( rev_nrg_64bit ); - rev_nrg = W_extract_l( W_shl( rev_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) - rev_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ /* Reach a common Q for dmx_nrg and rev_nrg */ q_com = s_min( dmx_nrg_q, rev_nrg_q ); dmx_nrg = L_shl( dmx_nrg, sub( q_com, dmx_nrg_q ) ); /* q_com */ rev_nrg = L_shl( rev_nrg, sub( q_com, rev_nrg_q ) ); /* q_com */ -#ifdef OPT_STEREO_32KBPS_V1 diff = sub( hStereoDft->q_smoothed_nrg, q_com ); IF( diff < 0 ) -#else /* OPT_STEREO_32KBPS_V1 */ - IF( LT_16( hStereoDft->q_smoothed_nrg, q_com ) ) -#endif /* OPT_STEREO_32KBPS_V1 */ { -#ifdef OPT_STEREO_32KBPS_V1 rev_nrg = L_shl( rev_nrg, shl( diff, 1 ) ); dmx_nrg = L_shl( dmx_nrg, shl( diff, 1 ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - rev_nrg = L_shr( rev_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); - dmx_nrg = L_shr( dmx_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ q_com = hStereoDft->q_smoothed_nrg; move16(); } -#ifdef OPT_STEREO_32KBPS_V1 ELSE -#else /* OPT_STEREO_32KBPS_V1 */ - ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, q_com ) ) -#endif /* OPT_STEREO_32KBPS_V1 */ { -#ifdef OPT_STEREO_32KBPS_V1 hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ - move32(); - hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ q_smoothed_nrg_local[b] = q_com; move16(); } @@ -3116,15 +3016,12 @@ void stereo_dft_generate_res_pred_fx( hStereoDft->smooth_dmx_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_dmx_nrg_fx[b], alpha ), dmx_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); /* hStereoDft->q_smoothed_nrg */ move32(); -#ifdef OPT_STEREO_32KBPS_V1 // Compute norm_fac in Q14 norm_fac = MAX_16; move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* normalization factor */ IF( hStereoDft->smooth_res_nrg_fx[b] != 0 ) { -#ifdef OPT_STEREO_32KBPS_V1 norm_fac = 0; move16(); IF( hStereoDft->smooth_dmx_nrg_fx[b] != 0 ) @@ -3147,88 +3044,15 @@ void stereo_dft_generate_res_pred_fx( norm_fac = extract_h( prod ); } -#else /* OPT_STEREO_32KBPS_V1 */ - norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ - norm_fac = Sqrt16( norm_fac, &q_norm_fac ); - IF( norm_fac != 0 ) - { - /* gain compressor */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( LE_16( q_norm_fac, -Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && GT_16( (Word16) 0x3333, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) ) - { - lim_norm_fac = (Word16) 0x5000; - move16(); - } - ELSE IF( GT_16( q_norm_fac, Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && LT_16( (Word16) 0x5000, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) ) - { - lim_norm_fac = (Word16) 0x3333; - move16(); - } - ELSE - { - lim_norm_fac = norm_fac; - move16(); - } - IF( EQ_16( lim_norm_fac, norm_fac ) ) - { - norm_fac = ONE_IN_Q14; - move16(); - q_norm_fac = Q1; - move16(); - } - ELSE - { - norm_fac = extract_l( L_shr( L_mult0( norm_fac, lim_norm_fac ), Q15 ) ); /* q_norm_fac */ - q_norm_fac = add( q_norm_fac, 1 ); - test(); - IF( q_norm_fac < 0 ) - { - norm_fac = shl( norm_fac, q_norm_fac ); - q_norm_fac = 0; - move16(); - } - ELSE IF( GT_16( q_norm_fac, 2 ) && LT_16( norm_s( norm_fac ), sub( q_norm_fac, Q1 ) ) ) - { - norm_fac = MAX_16; - move16(); - q_norm_fac = Q1; - move16(); - } - } - } -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifndef OPT_STEREO_32KBPS_V1 - ELSE - { - norm_fac = MAX_16; - move16(); - q_norm_fac = Q1; - move16(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ len = s_min( hStereoDft->band_limits[b + 1], bin0 ); FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ move32(); DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), 1 ); /* q_dft */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac ); /* q_dft */ - move32(); - DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac ); /* q_dft */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 772eb2d7d218c7061e3fd9208ac65f818c0ad218..af31aea40ce19df09cd9d9dfba2162c9f9a1a301 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -904,9 +904,7 @@ void stereo_icBWE_dec_fx( winSlope_fx = div_s( 1, winLen_fx ); /* Q15 */ alpha_fx = winSlope_fx; /* Q15 */ move16(); -#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx Word16 winSlope_fx_ = sub( 32767 /* 1.0 in Q15*/, winSlope_fx ); -#endif FOR( i = 0; i < winLen_fx; i++ ) { L_tmp = L_mult0( alpha_fx, icbweM2Ref_fx ); /* Q29 */ @@ -914,17 +912,10 @@ void stereo_icBWE_dec_fx( tmp = shl( round_fx( L_tmp ), 1 ); /* Q14 */ synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn - 1 */ move32(); -#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx if ( LE_16( alpha_fx, winSlope_fx_ ) ) { alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ } -#else - IF( LE_16( alpha_fx, sub( 32767 /* 1.0 in Q15*/, winSlope_fx ) ) ) - { - alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ - } -#endif } FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 89cb92a4d08c1b9f834610892fdd5ce2dc73c68c..b52d0495198e1ebb4b2a910e038326d1c5f8da83 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -178,7 +178,9 @@ void stereo_mdct_core_dec_fx( /*needed to allocate N_MAX to prevent stereo switching crash */ Word32 x_0_buf_fx[CPE_CHANNELS][N_MAX]; Word32 *x_0_fx[CPE_CHANNELS][NB_DIV]; +#ifndef OPT_SBA_DEC_V2_NBE Word16 x_0_e[CPE_CHANNELS][NB_DIV]; +#endif /* OPT_SBA_DEC_V2_NBE */ /* Concealment */ Word16 bfi; @@ -289,15 +291,24 @@ void stereo_mdct_core_dec_fx( { FOR( j = 0; j < NB_DIV; ++j ) { +#ifndef OPT_SBA_DEC_V2_NBE x_e[i][j] = 31; +#else /* OPT_SBA_DEC_V2_NBE */ + x_e[i][j] = 20; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); x_len[i][j] = 0; move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_0_e[i][j] = 31; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } } +#ifdef OPT_SBA_DEC_V2_NBE + ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, 20, x_fx, 20, x_len, Aq_fx, ms_mask, 0 ); +#else /* OPT_SBA_DEC_V2_NBE */ ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, x_0_e, x_fx, x_e, x_len, Aq_fx, ms_mask, 0 ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -323,6 +334,7 @@ void stereo_mdct_core_dec_fx( move16(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( ch = 0; ch < nChannels; ch++ ) { @@ -465,9 +477,13 @@ void stereo_mdct_core_dec_fx( test(); IF( ( !bfi || ( sts[0]->core != ACELP_CORE || sts[1]->core != ACELP_CORE ) ) && !hCPE->hStereoMdct->isSBAStereoMode ) { +#ifndef OPT_SBA_DEC_PATH Word16 q_x_1 = 11, q_x_0 = 11; move16(); move16(); +#endif /* OPT_SBA_DEC_PATH */ + +#ifndef OPT_SBA_DEC_V2_NBE FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -477,9 +493,18 @@ void stereo_mdct_core_dec_fx( move16(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifdef OPT_SBA_DEC_PATH + stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 ); +#else /* OPT_SBA_DEC_PATH */ stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 ); +#endif /* OPT_SBA_DEC_PATH */ } +#ifdef OPT_SBA_DEC_V2_NBE + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, 20 ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, x_e ); FOR( Word16 ind = 0; ind < 2; ind++ ) @@ -505,7 +530,7 @@ void stereo_mdct_core_dec_fx( move16(); } } - +#endif /* OPT_SBA_DEC_V2_NBE */ test(); test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 8842a6792a8c866cbcc17e6b0b0a9f1a32f7392d..492060a67d4a4527180dbf4e195e7b80e68ce567 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -313,9 +313,13 @@ void stereo_decoder_tcx_fx( const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ const Word16 last_core_l, /* i : last core for left channel Q0*/ const Word16 last_core_r, /* i : last core for right channel Q0*/ - const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision Q0*/ + const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/ +#ifndef OPT_SBA_DEC_PATH + , Word16 *q_x_ch2, - Word16 *q_x_ch1 ) + Word16 *q_x_ch1 +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 i, k, sfb, nSubframes; STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL; @@ -361,10 +365,12 @@ void stereo_decoder_tcx_fx( } } inverseMS_fx( sfbConf->sfbOffset[sfbConf->nBandsStereoCore], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( EQ_16( mdct_stereo_mode[k], SMDCT_BW_MS ) ) { @@ -381,10 +387,12 @@ void stereo_decoder_tcx_fx( } } inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } @@ -402,10 +410,12 @@ void stereo_decoder_tcx_fx( } } inverseMS_fx( sub( sfbConf->sfbOffset[sfbConf->sfbCnt], sfbConf->sfbOffset[sfbConf->nBandsStereoCore] ), &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) ) { @@ -422,10 +432,12 @@ void stereo_decoder_tcx_fx( } } inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } @@ -483,8 +495,10 @@ void stereo_decoder_tcx_fx( nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */ v_multc_fixed( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */ Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */ +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) ) { @@ -492,8 +506,10 @@ void stereo_decoder_tcx_fx( shift = sub( 5, tmp_e ); v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */ Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */ +#ifndef OPT_SBA_DEC_PATH *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } /* for k */ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 522e741e82b87d6c3b43800adab58f3b91f170a0..57f631204777984c44b613c1b08fdffed3590fcf 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -68,6 +68,10 @@ static ivas_error allocate_CoreCoder_TCX_fx( reset_tcx_overl_buf_fx( st->hTcxDec ); // st->hTcxDec->CngLevelBackgroundTrace_bfi = 0; //initializing to avoid garbage overflow; set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_OverlFB = 0; + move16(); +#endif set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); st->hTcxDec->q_old_synth = 0; move16(); @@ -418,6 +422,9 @@ ivas_error stereo_memory_dec_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + assert( hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 == hCPE->hCoreCoder[1]->hHQ_core->Q_old_out_fx32 ); +#endif v_add_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[1]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ @@ -2149,6 +2156,10 @@ void stereo_td2dft_update_fx( move16(); /* update buffers used for fading when switching to DFT Stereo */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + assert( sts[0]->hHQ_core->Q_old_out_fx32 == sts[1]->hHQ_core->Q_old_out_fx32 ); +#endif + v_add_fx( sts[0]->hHQ_core->old_out_LB_fx32 + nsLB, sts[1]->hHQ_core->old_out_LB_fx32 + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); FOR( i = 0; i < old_outLB_len; i++ ) @@ -2306,19 +2317,10 @@ static Word32 ncross_corr_self_fx( Word64 c_c_fx; Word32 c_c_fx_return; Word64 energy_x_fx, energy_y_fx; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 c_c_fx_q; - Word64 energy_xy_fx; -#endif /* OPT_STEREO_32KBPS_V1 */ UWord16 j; Word32 *signal_a_fx, *signal_b_fx; Word32 temp_x, temp_y; Word16 headroom_left_x, headroom_left_y; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 x_inv_q, y_inv_q; - Word16 x_q, y_q; - Word16 res_q; -#endif /* OPT_STEREO_32KBPS_V1 */ c_c_fx = 0; move64(); energy_x_fx = 0; @@ -2329,20 +2331,13 @@ static Word32 ncross_corr_self_fx( signal_b_fx = &signal_fx[y]; /* Q11 */ FOR( j = 0; j < corr_len; j += subsampling ) { -#ifdef OPT_STEREO_32KBPS_V1 c_c_fx = W_mac_32_32( c_c_fx, signal_a_fx[j], signal_b_fx[j] ); /* 2 * Q11 + 1*/ energy_x_fx = W_mac_32_32( energy_x_fx, signal_a_fx[j], signal_a_fx[j] ); /* 2 * Q11+ 1 */ energy_y_fx = W_mac_32_32( energy_y_fx, signal_b_fx[j], signal_b_fx[j] ); /* 2 * Q11+ 1 */ -#else /* OPT_STEREO_32KBPS_V1 */ - c_c_fx = W_add( c_c_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ - energy_x_fx = W_add( energy_x_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_a_fx[j] ) ) ); /* 2 * Q11 */ - energy_y_fx = W_add( energy_y_fx, W_mult0_32_32( ( signal_b_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ -#endif /* OPT_STEREO_32KBPS_V1 */ } headroom_left_x = W_norm( energy_x_fx ); headroom_left_y = W_norm( energy_y_fx ); -#ifdef OPT_STEREO_32KBPS_V1 temp_x = W_extract_h( W_shl( energy_x_fx, headroom_left_x ) ); // Q23 + headroom_left_x -32 temp_y = W_extract_h( W_shl( energy_y_fx, headroom_left_y ) ); // Q23 + headroom_left_y -32 Word64 prod = W_mult0_32_32( temp_x, temp_y ); // Q(headroom_left_x + headroom_left_y - 18) @@ -2365,79 +2360,6 @@ static Word32 ncross_corr_self_fx( quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 } -#else /* OPT_STEREO_32KBPS_V1 */ - IF( LT_16( headroom_left_x, 32 ) ) - { - energy_x_fx = W_shr( energy_x_fx, sub( 32, headroom_left_x ) ); /* 2 * Q11 - (32 -headroom_left_x) */ - x_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_x ) ) ) ); - } - ELSE - { - x_q = 31 - ( 2 * OUTPUT_Q ); - } - IF( LT_16( headroom_left_y, 32 ) ) - { - energy_y_fx = W_shr( energy_y_fx, sub( 32, headroom_left_y ) ); /* 2 * Q11 - (32 -headroom_left_y) */ - y_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), ( sub( 32, headroom_left_y ) ) ) ) ); - } - ELSE - { - y_q = 31 - ( 2 * OUTPUT_Q ); - } - - x_inv_q = x_q; - move16(); - y_inv_q = y_q; - move16(); - - temp_x = Sqrt32( W_extract_l( energy_x_fx ), &x_q ); - IF( x_q < 0 ) - { - temp_x = L_shr( temp_x, i_mult( -1, x_q ) ); /* Q0 */ - x_q = 0; - move16(); - } - - temp_y = Sqrt32( W_extract_l( energy_y_fx ), &y_q ); - IF( y_q < 0 ) - { - temp_y = L_shr( temp_y, i_mult( -1, y_q ) ); /* Q0 */ - y_q = 0; - move16(); - } - - energy_xy_fx = Mpy_32_32( temp_x, temp_y ); /* x_q + y_q - 31 */ - res_q = add( y_q, x_q ); - - IF( ( energy_xy_fx < L_shr( ONE_IN_Q31, res_q ) ) || energy_xy_fx == 0 ) - { - energy_xy_fx = ONE_IN_Q31; /* conceal silent frames */ - res_q = 0; - c_c_fx = W_shl( c_c_fx, 31 - ( 2 * OUTPUT_Q ) ); /* Q31 */ - } - ELSE - { - Word32 temp_x_inv = ISqrt32( W_extract_l( energy_x_fx ), &x_inv_q ); - Word32 temp_y_inv = ISqrt32( W_extract_l( energy_y_fx ), &y_inv_q ); - Word16 headroom_left_c_c; - energy_xy_fx = Mpy_32_32( temp_x_inv, temp_y_inv ); /* exp(x_inv_q + y_inv_q) */ - res_q = add( x_inv_q, y_inv_q ); - headroom_left_c_c = W_norm( c_c_fx ); - c_c_fx_q = OUTPUT_Q * 2; - move16(); - IF( LT_16( headroom_left_c_c, 32 ) ) - { - c_c_fx = W_shr( c_c_fx, extract_l( sub( 32, headroom_left_c_c ) ) ); /* c_c_fx_q - (32 - headroom_left_c_c) */ - c_c_fx_q = sub( c_c_fx_q, sub( 32, headroom_left_c_c ) ); - } - c_c_fx = W_deposit32_l( Mpy_32_32( W_extract_l( c_c_fx ), W_extract_l( energy_xy_fx ) ) ); /* c_c_fx_q + (31 - res_q) - 31 */ - c_c_fx_q = add( c_c_fx_q, sub( sub( 31, res_q ), 31 ) ); - c_c_fx = W_extract_l( W_shl_sat_l( c_c_fx, extract_l( sub( 31, c_c_fx_q ) ) ) ); /* Q31 */ - } - - c_c_fx_return = W_extract_l( c_c_fx ); /* Q31 */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ return c_c_fx_return; } diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 023c9a2e5e3a1fc4dd97ded44e0ac846508e84ed..6209d5684e8b991ae9ca45da1530efe632099225 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -355,26 +355,16 @@ void tdm_upmix_plain_fx( { FOR( i = start_index; i < end_index; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 Word32 temp_left = Madd_32_32( SCh_2_R_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx ), -30 ); /* Qx */ move32(); Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx ), -30 ); /* Qx */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Word32 temp_left = L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ - Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - Word32 temp_right = L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ); /* Qx */ - Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } ELSE { -#ifdef OPT_STEREO_32KBPS_V1 Word32 inv_den_LR_ratio_fx_neg = L_negate( inv_den_LR_ratio_fx ); FOR( i = start_index; i < end_index; i++ ) { @@ -385,17 +375,6 @@ void tdm_upmix_plain_fx( Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ move32(); } -#else /* OPT_STEREO_32KBPS_V1 */ - FOR( i = start_index; i < end_index; i++ ) - { - Word32 temp_left = L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ - Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - Word32 temp_right = L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), PCh_2_L_fx[i] ); /* Qx */ - Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ } return; diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 4b052288430d888a2b29857d24ec105999397042..ba65c4b7b466e02bbb8aee0f2f9b90870390ee89 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -322,7 +322,11 @@ Word16 svd_fx( move16(); FOR( iCh = 0; iCh < lengthSingularValues - 1; iCh++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( LT_32( L_shl_sat( singularValues_fx[iCh], sub( singularValues_fx_e[iCh], singularValues_fx_e[iCh + 1] ) ), singularValues_fx[iCh + 1] ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( singularValues_fx[iCh], singularValues_fx_e[iCh], singularValues_fx[iCh + 1], singularValues_fx_e[iCh + 1] ) < 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { condition = 1; move16(); @@ -427,14 +431,24 @@ static Word16 BidagonalDiagonalisation_fx( FOR( jCh = iCh; jCh >= 0; jCh-- ) { - split = sub( jCh, 1 ); /* Q0 */ - IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( secDiag_fx[jCh] ), secDiag_new_e[jCh], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = s_max( secDiag_new_e[jCh], eps_x_e ); + IF( LE_32( L_shr( L_abs( secDiag_fx[jCh] ), sub( com_e, secDiag_new_e[jCh] ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#else + split = sub( jCh, 1 ); /* Q0 */ /* OPT_MCH_DEC_V1_NBE */ + IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( secDiag_fx[jCh] ), secDiag_new_e[jCh], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { found_split = 0; move16(); BREAK; } +#ifdef OPT_MCH_DEC_V1_NBE + com_e = s_max( singularValues_new_e[jCh - 1], eps_x_e ); + IF( LE_32( L_shr( L_abs( singularValues_fx[jCh - 1] ), sub( com_e, singularValues_new_e[jCh - 1] ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) /* is singularValues[jCh - 1] vanishing compared to eps_x */ +#else /* OPT_MCH_DEC_V1_NBE */ IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( singularValues_fx[split] ), singularValues_new_e[split], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { BREAK; } @@ -462,14 +476,21 @@ static Word16 BidagonalDiagonalisation_fx( move32(); c_e = 0; move16(); - +#ifdef OPT_MCH_DEC_V1_NBE + split = sub( jCh, 1 ); /* Q0 */ +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( kCh = jCh; kCh <= iCh; kCh++ ) { g = Mpy_32_32( s, secDiag_fx[kCh] ); /* exp(s_e + secDiag_new_e) */ g_e = add( s_e, secDiag_new_e[kCh] ); secDiag_fx[kCh] = Mpy_32_32( c, secDiag_fx[kCh] ); /* exp(c_e + secDiag_new_e) */ secDiag_new_e[kCh] = add( c_e, secDiag_new_e[kCh] ); - IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( g ), g_e, Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = s_max( g_e, eps_x_e ); + IF( LE_32( L_shr( L_abs( g ), sub( com_e, g_e ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ + IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( g ), g_e, Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { BREAK; } @@ -779,6 +800,9 @@ static void ApplyRotation_fx( move16(); } op_e = add( op_e, 1 ); // 64 bit mac -> +1 +#ifdef OPT_MCH_DEC_V1_BE + op_e = negate( op_e ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch = 0; ch < nChannels; ch++ ) { @@ -788,13 +812,21 @@ static void ApplyRotation_fx( move32(); Word64 temp = W_mac_32_32( W_mult_32_32( op1, x11 ), op2, x12 ); // Q(singularVector) + op_e - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) +#ifdef OPT_MCH_DEC_V1_BE + singularVector[ch][currentIndex2] = W_shl_sat_l( temp, op_e ); // Q(singularVector) +#else /* OPT_MCH_DEC_V1_BE */ + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) +#endif /* OPT_MCH_DEC_V1_BE */ move32(); temp = W_mac_32_32( W_mult_32_32( op1, x12 ), L_negate( op2 ), x11 ); // Q(singularVector) + op_e - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) +#ifdef OPT_MCH_DEC_V1_BE + singularVector[ch][currentIndex1] = W_shl_sat_l( temp, op_e ); // Q(singularVector) +#else /* OPT_MCH_DEC_V1_BE */ + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) +#endif /* OPT_MCH_DEC_V1_BE */ move32(); } @@ -918,9 +950,15 @@ static void biDiagonalReductionLeft_fx( Word16 invVal_e; Word32 invVal; invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); +#ifdef OPT_MCH_DEC_V1_NBE + Word64 temp = 0; + move64(); + Word16 max_e = MIN_16; +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = 0; move32(); norm_x_e = 0; +#endif /* OPT_MCH_DEC_V1_NBE */ move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { @@ -929,8 +967,25 @@ static void biDiagonalReductionLeft_fx( move32(); singularVectors2_e[jCh][currChannel] = sub( add( invVal_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ), temp_e ); move16(); +#ifdef OPT_MCH_DEC_V1_NBE + max_e = s_max( max_e, singularVectors2_e[jCh][currChannel] ); +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( singularVectors2_e[jCh][currChannel], 1 ), &norm_x_e ); /* exp(norm_x_e) */ +#endif /* OPT_MCH_DEC_V1_NBE */ } + +#ifdef OPT_MCH_DEC_V1_NBE + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + temp = W_add( temp, L_shr( Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sub( max_e, singularVectors2_e[jCh][currChannel] ), 1 ) ) ); + } + + Word16 nrm = W_norm( temp ); + nrm = sub( nrm, 32 ); + norm_x = W_shl_sat_l( temp, nrm ); + norm_x_e = sub( add( max_e, max_e ), nrm ); +#endif /* OPT_MCH_DEC_V1_NBE */ + IF( GT_16( norm_x_e, 0 ) ) { norm_x = MAX_32; @@ -958,6 +1013,30 @@ static void biDiagonalReductionLeft_fx( FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word16 max2_e = MIN_16; + max_e = MIN_16; + move16(); + move16(); + temp = 0; + move64(); + + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + max_e = s_max( max_e, singularVectors2_e[jCh][currChannel] ); /* exp(norm_x_e) */ + max2_e = s_max( max2_e, singularVectors2_e[jCh][iCh] ); /* exp(norm_x_e) */ + } + max_e = add( max_e, max2_e ); + + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + temp = W_add( temp, L_shr( Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), sub( max_e, add( singularVectors2_e[jCh][currChannel], singularVectors2_e[jCh][iCh] ) ) ) ); + } + nrm = W_norm( temp ); + nrm = sub( nrm, 32 ); + norm_x = W_shl_sat_l( temp, nrm ); + norm_x_e = sub( max_e, nrm ); +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = 0; move32(); norm_x_e = 0; @@ -966,6 +1045,7 @@ static void biDiagonalReductionLeft_fx( { norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( singularVectors2_e[jCh][currChannel], singularVectors2_e[jCh][iCh] ), &norm_x_e ); /* exp(norm_x_e) */ } +#endif /* OPT_MCH_DEC_V1_NBE */ f = Mpy_32_32( norm_x, invVal ); /* invVal_e + (norm_x_e - r_e) */ f_e = add( invVal_e, sub( norm_x_e, r_e ) ); @@ -1217,8 +1297,16 @@ static void singularVectorsAccumulationLeft_fx( move32(); } } +#ifdef OPT_MCH_DEC_V1_NBE + Word16 exp = s_max( singularVectors_Left_e[nCh][nCh], 1 ); + singularVectors_Left[nCh][nCh] = L_sub( L_shr( singularVectors_Left[nCh][nCh], sub( exp, singularVectors_Left_e[nCh][nCh] ) ), L_shr( MINUS_ONE_IN_Q31, exp ) ); /* exp(sing_exp2) */ + move32(); + singularVectors_Left_e[nCh][nCh] = exp; + move16(); +#else /* OPT_MCH_DEC_V1_NBE */ singularVectors_Left[nCh][nCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[nCh][nCh], singularVectors_Left_e[nCh][nCh], ONE_IN_Q30, 1, &singularVectors_Left_e[nCh][nCh] ); /* exp(sing_exp2) */ move32(); +#endif /* OPT_MCH_DEC_V1_NBE */ } // fclose(fp); FOR( nCh = 0; nCh < nChannelsL; nCh++ ) @@ -1281,21 +1369,56 @@ static void singularVectorsAccumulationRight_fx( FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word64 norm_val = 0; + move64(); + Word16 maxL_e = MIN_16; + Word16 maxR_e = MIN_16; + Word16 maxR2_e = MIN_16; + move16(); + move16(); + move16(); + FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ + { + maxL_e = s_max( maxL_e, singularVectors_Left_e[nCh][k] ); + maxR_e = s_max( maxR_e, sing_right_exp[k][iCh] ); + maxR2_e = s_max( maxR2_e, sing_right_exp[k][nCh] ); + } +#else /* OPT_MCH_DEC_V1_NBE */ norm_y = 0; move32(); norm_y_e = 0; move16(); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ { - norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_Left_e[nCh][k], sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ +#ifdef OPT_MCH_DEC_V1_NBE + norm_val = W_mac_32_32( norm_val, L_shr( singularVectors_Left[nCh][k], sub( maxL_e, singularVectors_Left_e[nCh][k] ) ), L_shr( singularVectors_Right[k][iCh], sub( maxR_e, sing_right_exp[k][iCh] ) ) ); +#else /* OPT_MCH_DEC_V1_NBE */ + norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_Left_e[nCh][k], sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ +#endif /* OPT_MCH_DEC_V1_NBE */ } +#ifdef OPT_MCH_DEC_V1_NBE + norm_y_e = W_norm( norm_val ); + norm_y = W_extract_h( W_shl( norm_val, norm_y_e ) ); + norm_y_e = sub( add( maxL_e, maxR_e ), norm_y_e ); + Word16 max_new = s_max( maxR_e, add( maxR2_e, norm_y_e ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word32 temp = Mpy_32_32( norm_y, singularVectors_Right[k][nCh] ); + Word32 op2 = L_shr( temp, sub( max_new, add( norm_y_e, sing_right_exp[k][nCh] ) ) ); + singularVectors_Right[k][iCh] = L_add_sat( L_shr( singularVectors_Right[k][iCh], sub( max_new, sing_right_exp[k][iCh] ) ), op2 ); /* exp(sing_right_exp) */ + move32(); + singularVectors_Right[k][iCh] = L_shl_sat( singularVectors_Right[k][iCh], max_new ); /* Q31 */ +#else /* OPT_MCH_DEC_V1_NBE */ singularVectors_Right[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Right[k][iCh], sing_right_exp[k][iCh], Mpy_32_32( norm_y, singularVectors_Right[k][nCh] ), add( norm_y_e, sing_right_exp[k][nCh] ), &sing_right_exp[k][iCh] ); /* exp(sing_right_exp) */ move32(); singularVectors_Right[k][iCh] = L_shl_sat( singularVectors_Right[k][iCh], sing_right_exp[k][iCh] ); /* Q31 */ +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); sing_right_exp[k][iCh] = 0; move16(); diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index e2528e619eb9ab631ad0ced53399220cba4a2702..0321a6495e844d29287aad94af717284417e336c 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -964,70 +964,78 @@ UWord8 apa_exec_ivas_fx( { Word16 a_tmp[APA_BUF]; Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); - Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out - move16(); - } Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out - - /* fill input frame */ - /* 1st input frame: previous output samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in[i] = buf_out_ptr[i]; - move16(); - } - /* 2nd input frame: new input samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in_ptr[i] = a_tmp[i]; - move16(); - } - /* no scaling */ IF( EQ_32( ps->scale, 100 ) ) { - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); - } - /* shrink */ - ELSE IF( LT_32( ps->scale, 100 ) ) - { - shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = a_in[i]; // Q11 + move32(); + } + l_frm_out = ps->l_frm; + move16(); } - /* extend */ ELSE { - extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); - } - /* control the amount/frequency of scaling */ - IF( NE_32( l_frm_out, ps->l_frm ) ) - { - test(); - IF( ( maxScaling != 0 ) && - GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) + Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); + + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) { - /* maxScaling exceeded -> discard scaled frame */ - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out + move16(); } - ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + /* fill input frame */ + /* 1st input frame: previous output samples */ + FOR( i = 0; i < ps->l_frm; i++ ) { - dl_copied = L_sub( l_frm_out_target, ps->l_frm ); - dl_scaled = L_sub( l_frm_out_target, l_frm_out ); - /* discard scaled frame if copied frame is closer to target length */ - IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + frm_in[i] = buf_out_ptr[i]; + move16(); + } + /* 2nd input frame: new input samples */ + FOR( i = 0; i < ps->l_frm; i++ ) + { + frm_in_ptr[i] = a_tmp[i]; + move16(); + } + /* shrink */ + IF( LT_32( ps->scale, 100 ) ) + { + shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + } + /* extend */ + ELSE + { + extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); + } + /* control the amount/frequency of scaling */ + IF( NE_32( l_frm_out, ps->l_frm ) ) + { + test(); + IF( ( maxScaling != 0 ) && + GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) { + /* maxScaling exceeded -> discard scaled frame */ copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); } + ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + { + dl_copied = L_sub( l_frm_out_target, ps->l_frm ); + dl_scaled = L_sub( l_frm_out_target, l_frm_out ); + /* discard scaled frame if copied frame is closer to target length */ + IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + { + copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + } + } } - } - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 - move32(); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 + move32(); + } } } @@ -1532,7 +1540,6 @@ static bool copy_frm_fx( return 0; } - /* ******************************************************************************** * diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index cc13c0148d23a45b7a154bb93fc2ce91fa1ccc10..7015022ebec826fff8b4390692f5318eeeae9b7d 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -113,9 +113,15 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, sumXX = L_shl( sumXX, normX ); normY = norm_l( sumYY ); sumYY = L_shl( sumYY, normY ); +#ifdef FIX_1824 + product = L_shr( L_mult0( extract_h( sumXX ), extract_h( sumYY ) ), 1 ); + normXY = add( normX, normY ); + normXY = sub( normXY, 32 + 1 ); +#else product = L_mult0( extract_h( sumXX ), extract_h( sumYY ) ); normXY = add( normX, normY ); normXY = sub( normXY, 32 ); +#endif /* change norm to factor of 2 */ IF( s_and( normXY, 0x1 ) != 0 ) @@ -128,7 +134,6 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, IF( sqrtXY != 0 ) { - Flag Overflow = 0; move32(); normCC = 0; move16(); @@ -136,7 +141,12 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF +#ifdef ISSUE_1751_replace_shl_ro + cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); +#else + Flag Overflow; cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 4c448efc7d7dbca1a1adb3e65402ceb53cccdafd..7c881cce983bd84a83833722e87d9e5d4df5f9d3 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -60,6 +60,9 @@ struct IVAS_DEC_VOIP UWord16 lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ UWord16 *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/ +#endif #ifdef SUPPORT_JBM_TRACEFILE IVAS_JBM_TRACE_DATA JbmTraceData; #endif @@ -81,8 +84,11 @@ struct IVAS_DEC bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ Word16 tsm_scale; /* scale for TSM operation */ Word16 tsm_max_scaling; - Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ +#endif Word16 tsm_quality; /*Q14*/ + Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; @@ -114,6 +120,9 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, cons static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE +static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); +#endif static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); @@ -153,6 +162,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = ONE_IN_Q14; /*1.f Q14*/ +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 0; +#endif hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; @@ -175,6 +187,9 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + move16(); +#endif hIvasDec->mode = mode; move16(); @@ -910,6 +925,10 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->hCurrentDataUnit = NULL; hIvasDec->hVoIP->nSamplesFrame = (UWord16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->hVoIP->nSamplesRendered20ms = 0; + move16(); +#endif #define WMC_TOOL_SKIP /* Bitstream conversion is not counted towards complexity and memory usage */ @@ -1225,18 +1244,29 @@ ivas_error IVAS_DEC_GetSamples( } assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 1; + move16(); +#endif } ELSE { nSamplesTcsScaled = hIvasDec->nSamplesFrame; move16(); } +#ifdef DEBUG_MODE_JBM + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); +#endif /* Feed decoded transport channels samples to the renderer */ IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) { return error; } +#ifdef DEBUG_MODE_JBM + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); +#endif + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { @@ -1936,6 +1966,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( if ( hIvasDec->st_ivas->hTcBuffer != NULL ) { *nSamplesBuffered = sub( hIvasDec->st_ivas->hTcBuffer->n_samples_buffered, hIvasDec->st_ivas->hTcBuffer->n_samples_rendered ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + *nSamplesBuffered = add( *nSamplesBuffered, hIvasDec->hVoIP->nSamplesRendered20ms ); +#endif move16(); } @@ -3135,7 +3168,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( UWord32 extBufferedTime_ms, scale, maxScaling; JB4_DATAUNIT_HANDLE dataUnit; UWord16 extBufferedSamples; +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE Word16 timeScalingDone; +#endif Word16 result; ivas_error error; Word16 nSamplesRendered; @@ -3144,7 +3179,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE timeScalingDone = 0; +#endif nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out; nSamplesRendered = 0; move16(); @@ -3172,7 +3209,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } } +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + extBufferedSamples = nSamplesBuffered; + move16(); +#else extBufferedSamples = add( nSamplesRendered, nSamplesBuffered ); +#endif Word16 exp; extBufferedTime_ms = BASOP_Util_Divide3232_Scale( imult3216( extBufferedSamples, 1000 ), hDecoderConfig->output_Fs, &exp ); extBufferedTime_ms = (UWord32) W_shr( extBufferedTime_ms, sub( 15, exp ) ); // Q0 @@ -3195,19 +3237,33 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } maxScaling = Mult_32_32( imult3216( hDecoderConfig->output_Fs, (Word16) maxScaling ), INV_1000_Q31 ); +#ifdef DEBUG_MODE_JBM + dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); + dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); + dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); + dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); +#endif + /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE { - IF( timeScalingDone ) + IF( hIvasDec->timeScalingDone ) +#else + { + IF( timeScalingDone ) +#endif { scale = 100; move32(); } +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE ELSE { timeScalingDone = 1; move16(); } +#endif } /* limit scale to range supported by time scaler */ @@ -3300,6 +3356,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); move16(); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); +#endif } ELSE { @@ -3314,12 +3373,45 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); +#endif } } return IVAS_ERR_OK; } +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE +/*---------------------------------------------------------------------* + * update_voip_rendered20ms( ) + * + * Function to flush remaining audio in VoIP + *---------------------------------------------------------------------*/ + +static void update_voip_rendered20ms( + IVAS_DEC_HANDLE hIvasDec, + const Word16 nSamplesRendered ) +{ + Word16 nSamplesRenderedTotal; + nSamplesRenderedTotal = add( hIvasDec->hVoIP->nSamplesRendered20ms, nSamplesRendered ); + /* we have crossed a 20ms border, reset the time scaling done flag */ + IF( GE_16( nSamplesRenderedTotal, hIvasDec->hVoIP->nSamplesFrame ) ) + { + hIvasDec->timeScalingDone = 0; + move16(); + } + + /* float code was: hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; */ + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal; + move16(); + WHILE( GE_16( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame ) ) + { + hIvasDec->hVoIP->nSamplesRendered20ms = sub( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame ); + } +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) @@ -3345,7 +3437,22 @@ ivas_error IVAS_DEC_Flush( move16(); /* render IVAS frames */ - error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + error = IVAS_ERR_OK; + + test(); + IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) ) + { +#endif + error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + } + ELSE + { + *nSamplesFlushed = 0; + move16(); + } +#endif return error; } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 28a97f072fa86cd9ea94c4c884a0a0c5740c1459..3015b85e4a9b2386a20501e468a11d2c6597ccc9 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -700,11 +700,15 @@ typedef struct hq_nbfec_structure typedef struct hq_dec_structure { Word32 old_out_fx32[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ - Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ + Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA. Q_old_wtda */ Word16 exp_old_out; - Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ + Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band. Q_old_wtda_LB */ Word32 old_out_LB_fx32[L_FRAME32k]; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 Q_old_out_fx32; /* Q for both old_out_fx32 and old_out_LB_fx32 */ +#else Word16 q_old_outLB_fx; +#endif Word16 Q_old_wtda_LB; Word16 Q_old_wtda; Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 1234e2853225f6db45718a9340925494e8e5554c..3ed08633c76d6e135dda5df6ae2f2b069adddf94 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -613,6 +613,7 @@ void ivas_wb_tbe_dec_fx( Word16 error[L_FRAME16k]; Word16 synth_frac[L_FRAME16k]; Word16 upsampled_synth[L_FRAME48k]; + Word32 tmp_synL[L_FRAME48k], upsampled_synth_32fx[L_FRAME48k]; Word32 prev_pow, curr_pow, curr_frame_pow; Word16 curr_frame_pow_exp; Word16 temp, scale, n; @@ -1181,9 +1182,10 @@ void ivas_wb_tbe_dec_fx( } ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) { - Scale_sig( hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, hBWE_TD->prev_Qx ) ); - ivas_interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, hBWE_TD->mem_resamp_HB_fx ); - Copy( upsampled_synth, synth, L_FRAME48k ); + Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) ); + interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 ); + Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) ); + Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) ); } } ELSE @@ -2721,6 +2723,38 @@ void swb_tbe_dec_fx( exp = 0; move16(); } +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ + temp = sub( 32767 /*1.0f Q15*/, temp ); + Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ + temp = sub( 32767 /*1.0f Q15*/, temp ); + Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } +#else FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ @@ -2731,6 +2765,7 @@ void swb_tbe_dec_fx( shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ move16(); } +#endif /* Update SHB excitation */ Copy( shaped_shb_excitation + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ @@ -4269,7 +4304,7 @@ void ivas_dequantizeSHBparams_fx_9_1( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } Q_subgain[i] = Q_subgain[idx]; move16(); @@ -4597,7 +4632,7 @@ static void dequantizeSHBparams_fx_9_1( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } Q_subgain[i] = Q_subgain[idx]; move16(); @@ -4662,12 +4697,8 @@ void fb_tbe_dec_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ - synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 - , - st->element_mode -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ - ); + synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, + st->element_mode ); /* add the fb_synth component to the hb_synth component */ /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ @@ -4736,12 +4767,8 @@ void fb_tbe_dec_ivas_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ - synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 - , - st->element_mode -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ - ); + synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, + st->element_mode ); test(); IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) ) @@ -6291,6 +6318,38 @@ void ivas_swb_tbe_dec_fx( exp = 0; move16(); } +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } +#else FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ @@ -6301,6 +6360,7 @@ void ivas_swb_tbe_dec_fx( shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ move16(); } +#endif } ELSE { @@ -6652,7 +6712,7 @@ void ivas_swb_tbe_dec_fx( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } GainShape_fx[i] = GainShape_tmp_fx[idx]; move16(); @@ -6696,7 +6756,7 @@ void ivas_swb_tbe_dec_fx( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } GainShape_fx[i] = GainShape_fx[idx]; move16(); @@ -7045,23 +7105,12 @@ void ivas_swb_tbe_dec_fx( tmp1 = 0; move16(); -#ifdef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx Word32 idx32 = L_shr_r( 0x00333333, 10 ); /*NUM_SHB_SUBFR/L_FRAME16k*/ // Q16 -#endif FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifndef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); - } -#else Word16 idx; - idx = extract_h( imult3216( idx32, i ) ); /*Q0*/ -#endif + idx = extract_h( imult3216( idx32, i ) ); /*Q0*/ L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ move16(); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index fd6cf7835e410e763405e49170ac72cb81337ee2..9582463ebaa219524690db8b76250b4c7497aacf 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -2587,9 +2587,13 @@ void TonalMDCTConceal_Apply( } void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ - Word16 mdctSpectrum_exp[L_FRAME_MAX], /*IN */ + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 mdctSpectrum_exp, /*IN */ +#else /* OPT_SBA_DEC_V2_NBE */ + Word16 mdctSpectrum_exp[L_FRAME_MAX], /*IN */ +#endif /* OPT_SBA_DEC_V2_NBE */ const PsychoacousticParameters *psychParamsCurrent ) { @@ -2755,8 +2759,12 @@ void TonalMDCTConceal_Apply_ivas_fx( /* getCosWord16 returns 1Q14*/ mdctSpectrum[l] = Mpy_32_16_1( powerSpectrum[l], getCosWord16( extract_l( currentPhase ) ) ); move32(); +#ifdef OPT_SBA_DEC_V2_NBE + mdctSpectrum[l] = L_shr( mdctSpectrum[l], sub( mdctSpectrum_exp, add( powerSpectrum_exp, 1 ) ) ); +#else /* OPT_SBA_DEC_V2_NBE */ mdctSpectrum_exp[l] = add( powerSpectrum_exp, 1 ); // getCosWord16 returns Q14 (exp is 1)d move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } } } @@ -2886,7 +2894,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( HANDLE_FD_CNG_COM hFdCngCom; Word16 *rnd_c, *rnd; Word16 crossOverFreq, i, save_rnd_c, max_noise_line; - Word16 c, c_inv, inc; + Word16 c, c_inv, inc, inc_log2; Word32 noise_shape_buffer[L_FRAME48k]; Word16 noise_shape_buffer_e[L_FRAME48k]; Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; @@ -2994,14 +3002,21 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( IF( GT_16( st->core, TCX_20_CORE ) ) { inc = 2; + inc_log2 = 1; + move16(); + move16(); + start_idx = shr( hFdCngCom->startBand, inc_log2 ); + stop_idx = shr( hFdCngCom->stopFFTbin, inc_log2 ); } ELSE { inc = 1; + start_idx = hFdCngCom->startBand; + stop_idx = hFdCngCom->stopFFTbin; + move16(); + move16(); + move16(); } - move16(); - start_idx = idiv1616( hFdCngCom->startBand, inc ); - stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); FOR( i = 0; i < start_idx; i++ ) { diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 81046fb19c71b0ceef898d08f1e36163f092644a..d1fe01b4290a9243e01b799fd041880386c4fb30 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1207,6 +1207,10 @@ void update_decoder_LPD_cng( Copy( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, sub( hTcxDec->old_synth_len, st->L_frame ) ); Copy( synth, hTcxDec->old_synth + sub( hTcxDec->old_synth_len, st->L_frame ), st->L_frame ); bufferCopyFx( synth + sub( st->L_frame, ( st->L_frame / 2 ) ), hTcxDec->old_syn_Overl, st->L_frame / 2, 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); + move16(); +#endif hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 5003712b7ceda9821bc022dd7e0275be48282386..a7944410b9f855c85dd7edb3d47b8b20e55e40cc 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1249,6 +1249,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( k = 1; move16(); +#ifdef OPT_SBA_ENC_V2_BE + Word16 round_bit_estimate_fx; + Word32 target_Q15 = L_shl( target, Q15 ); // Q15 +#endif + WHILE( LT_16( k, nt / 2 ) ) { bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) ); @@ -1334,7 +1339,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ctx = &c[L_or( p1, p2 )]; t = (UWord16) L_add( *ctx, rateFlag ); - IF( LT_16( nt_half, idx ) ) + if ( LT_16( nt_half, idx ) ) { t = add( t, ( 1 << NBITS_CONTEXT ) ); } @@ -1351,6 +1356,19 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) + { + pki = lookup[lev1]; /* ESC symbol */ + + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); + a1 = shr( a1, 1 ); + b1 = shr( b1, 1 ); + + lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); + } +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) { pki = lookup[lev1]; /* ESC symbol */ @@ -1364,14 +1382,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ } - +#endif pki = lookup[lev1]; symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); +#ifdef OPT_SBA_ENC_V2_BE + IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15 +#else /* Should we truncate? */ IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) +#endif { stop2 = 1; move16(); @@ -1393,6 +1415,13 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); +#ifdef OPT_SBA_ENC_V2_BE + t = add( 13, lev1 ); + IF( lev1 <= 0 ) + { + t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); + } +#else IF( lev1 <= 0 ) { t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); @@ -1401,6 +1430,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { t = add( 13, lev1 ); } +#endif *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t ); move32(); @@ -1425,15 +1455,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } } /*end of the 2-tuples loop*/ - - total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ - +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else + total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#endif IF( *stop ) { - total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else + total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#endif } - IF( stop2 ) + if ( stop2 ) { stop2 = total_output_bits; /* Q0 */ move16(); @@ -1455,8 +1491,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */ move16(); - +#ifdef OPT_SBA_ENC_V2_BE + return round_fx( L_add( W_shl_sat_l( nbits2_fx, -Q7 ), ONE_IN_Q14 ) ); /* Q0 */ +#else return round_fx( L_add( W_extract_l( W_shr( nbits2_fx, Q7 ) ), ONE_IN_Q14 ) ); /* Q0 */ +#endif } ELSE /* if (!hm_cfg) */ { @@ -1530,6 +1569,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) + { + pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ + + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); + + a1 = shr( a1, 1 ); + b1 = shr( b1, 1 ); + + lev1 = add( lev1, 1 ); + esc_nb = s_min( lev1, 3 ); + } +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) { pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ @@ -1546,15 +1600,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ } - +#endif pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ - move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ +#ifdef OPT_SBA_ENC_V2_BE + IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15 +#else IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) +#endif { overflow_flag = 1; move16(); @@ -1570,6 +1627,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } } +#ifdef OPT_SBA_ENC_V2_BE + /* Update context for next 2-tuple */ + cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */ + if ( GE_16( esc_nb, 2 ) ) + { + cp = add( 12, esc_nb ); /* Q0 */ + } +#else /* Update context for next 2-tuple */ IF( LT_16( esc_nb, 2 ) ) { @@ -1579,59 +1644,94 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { cp = add( 12, esc_nb ); /* Q0 */ } +#endif /*shift old bits and replace last 4 bits*/ s = (UWord16) L_add( L_shl( s, 4 ), cp ); t = s_and( s, 0xFF ); - } /*end of the 2-tuples loop*/ +#ifdef OPT_SBA_ENC_V2_BE + tot_bits2 = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ + round_bit_estimate_fx = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else tot_bits2 = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ - IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ +#endif + if ( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; move16(); } +#ifdef OPT_SBA_ENC_V2_BE + if ( EQ_16( mode, -1 ) ) + { + tot_bits2 = round_bit_estimate_fx; + move16(); + } +#else IF( EQ_16( mode, -1 ) ) { - tot_bits2 = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + tot_bits2 = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ + } +#endif +#ifdef OPT_SBA_ENC_V2_BE + if ( overflow_flag == 0 ) /* No overflow */ + { + *stop = 0; + move16(); } + IF( overflow_flag != 0 ) /* Overflow */ + { + IF( *stop ) + { + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE + { + *stop = round_bit_estimate_fx; + move16(); + } + } +#else IF( overflow_flag == 0 ) /* No overflow */ { *stop = 0; move16(); } ELSE /* Overflow */ + { + IF( *stop ) { - IF( *stop ){ - *stop = tot_bits2; /* Q0 */ + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE + { + *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + move16(); + } + } +#endif + + *lastnz_out = lastnz; /* Q0 */ move16(); - } - ELSE - { - *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + *nEncoded = lastnz2; /* Q0 */ move16(); - } -} + /* Safety mechanism to avoid overflow */ + test(); + IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) + { + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); + } + } -*lastnz_out = lastnz; /* Q0 */ -move16(); -*nEncoded = lastnz2; /* Q0 */ -move16(); -/* Safety mechanism to avoid overflow */ -test(); -IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) -{ - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); + return tot_bits2; } } -return tot_bits2; -} -} - /*-------------------------------------------------------------------* * RCcontextMapping_encode2_estimate_bandWise_start_fx() @@ -1743,6 +1843,15 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* Get context */ t = add( hContextMem->ctx, hContextMem->rateFlag ); /* Q0 */ +#ifdef OPT_SBA_ENC_V2_BE + tmp = ( 1 << NBITS_CONTEXT ); + move16(); + if ( GE_16( hContextMem->nt_half, idx ) ) + { + tmp = 0; + move16(); + } +#else IF( GE_16( hContextMem->nt_half, idx ) ) { tmp = 0; @@ -1751,6 +1860,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( { tmp = ( 1 << NBITS_CONTEXT ); } +#endif t = add( t, tmp ); /* Q0 */ @@ -1771,15 +1881,18 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) +#endif { pki = lookup[lev1]; /* Q0 */ - move16(); hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); - move32(); - move32(); + move64(); + move64(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC]; @@ -1789,20 +1902,27 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( b1 = shr( b1, 1 ); lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */ - /* check while condition */ + /* check while condition */ } pki = lookup[lev1]; /* Q0 */ - move16(); + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); - move32(); + move64(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol]; /* Update context */ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); +#ifdef OPT_SBA_ENC_V2_BE + t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */ + if ( lev1 > 0 ) + { + t = add( 13, lev1 ); /* Q0 */ + } +#else IF( lev1 <= 0 ) { t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */ @@ -1811,12 +1931,16 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( { t = add( 13, lev1 ); /* Q0 */ } - +#endif hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */ move16(); - } /*end of the 2-tuples loop*/ + } /*end of the 2-tuples loop*/ +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( hContextMem->bit_estimate_fx, -Q7 ) ); /* Q0 */ +#else total_output_bits = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */ +#endif // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 76fa6f151d2f431e7062f1a41b00a099016082d7..8db68e089bb2609d217c89746bb14d0cacc60162 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -46,10 +46,8 @@ void acelp_core_switch_enc_fx( Word16 Aq[2 * ( M + 1 )]; LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef HARM_PUSH_BIT UWord16 value; Word16 nb_bits; -#endif hLPDmem = st_fx->hLPDmem; /* initializations */ @@ -140,7 +138,6 @@ void acelp_core_switch_enc_fx( encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); -#ifdef HARM_PUSH_BIT i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); #ifdef DEBUGGING assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); @@ -151,20 +148,6 @@ void acelp_core_switch_enc_fx( i++; } delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); -#else - /*----------------------------------------------------------------* - * bit-stream: modify the layer of sub frame CELP - *----------------------------------------------------------------*/ - FOR( i = 0; i < 20; i++ ) - { - hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */ - move16(); - hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; /* Q0 */ - move16(); - hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */ - move16(); - } -#endif /*----------------------------------------------------------------* * BWE encoding *----------------------------------------------------------------*/ @@ -632,7 +615,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -708,7 +691,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * long term prediction on the 2nd sub frame *-----------------------------------------------------------------*/ - pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) { diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index dbd656dec391af2ae3400c8a949e8a53765054a3..48ed114c714a04829f3e88aaf4d633c9368461d6 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -321,7 +321,11 @@ static void find_enr_dft_ivas_fx( } /* normalization per frequency bin */ - band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#ifdef FIX_1735_W_SHL_SAT_L + band_fx[i] = W_shl_sat_l( band_ener, sub( Q16 - 32, shift ) ); // *q_band +#else + band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); /* per band energy without E_MIN */ @@ -642,7 +646,11 @@ void ivas_analy_sp_fx( move32(); /* PS[i] = ( Bin_E[i] + 1e-5f + Bin_E[i + L_FFT / 2] + 1e-5f ) / 2.0f; */ +#ifndef FIX_1762_COMPILER_ISSUE PS[i] = W_extract_h( W_add( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ), W_shr( W_shl( add_const, 32 ), sub( 31, *q_Bin_E ) ) ) ); // *q_Bin_E +#else + PS[i] = W_extract_h( W_add( W_shl( W_add( W_deposit32_l( Bin_E[i] ), W_deposit32_l( Bin_E[i + L_FFT / 2] ) ), 31 ), W_shr( W_shl( add_const, 32 ), sub( 31, *q_Bin_E ) ) ) ); // *q_Bin_E +#endif move32(); /* Bin_E[i] = (float) ( 10.0f * log( PS[i] ) ); */ @@ -719,6 +727,9 @@ static void ivas_find_enr( Word32 min_ener; Word16 shift = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + Word16 tmp_shift; +#endif ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ @@ -748,13 +759,20 @@ static void ivas_find_enr( freq = BIN_FREQ_FX; move16(); +#ifdef OPT_MCT_ENC_V3_BE + tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 +#endif FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */ { band_ener = 0; move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *ptE = *ptR * *ptR + *ptI * *ptI; @@ -787,7 +805,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band @@ -812,7 +834,11 @@ static void ivas_find_enr( move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *Bin_E = *ptR * *ptR + *ptI * *ptI; @@ -843,7 +869,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 343f1890fd01b79e821a02184d77e8383bc8d3fd..1172bd890a4f8a96883f9fec9b5f10041047b02a 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -458,7 +458,11 @@ Word16 SearchPeriodicityIndex_fx( tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); +#ifdef ISSUE_1772_replace_shr_o + *RelativeScore = shr_sat( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */ +#else *RelativeScore = shr_o( tmp3, add( sub( tmp, tmp2 ), 2 ), &Overflow ); /* -> 2Q13 */ +#endif move16(); } ELSE diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 9dea812a6d01a5f464a9fb622dda064334c62c27..ed3663732c2f4317fcaf436f3094ed71e17c6351 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1261,11 +1261,11 @@ void CNG_enc_ivas_fx( move16(); /* Temp variables for floating point functions */ - lp_ener_thr_scale = 8; /* 4.0f*/ /* Q2 */ + lp_ener_thr_scale = 8; /* 4.0f*/ /* Q1 */ move16(); if ( st_fx->element_mode != EVS_MONO ) { - lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q2 */ + lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q1 */ move16(); } @@ -1634,7 +1634,7 @@ void CNG_enc_ivas_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ - w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q7*/ + w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ test(); test(); @@ -2455,12 +2455,7 @@ static void shb_CNG_encod_fx( push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice( hBstr, IND_SID_BW, 1, 1 ); -#ifdef HARM_PUSH_BIT delete_indice( hBstr, IND_CNG_ENV1 ); -#else - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); - hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; -#endif move16(); move16(); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 27f3d2aa6697f9d88264ca14b3a8452595d9de08..b520d9eeb57e5d478103af673e2b08a571a37695 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -2604,7 +2604,11 @@ void QuantizeSpectrum_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + xn_buf16[i] = shr_sat( xn_buf16[i], Q ); +#else xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); +#endif move16(); } @@ -3199,6 +3203,11 @@ void QuantizeTCXSpectrum_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifdef OPT_MCT_ENC_V3_NBE + Word16 scale = sub( L_norm_arr( spectrum_fx, L_spec ), 2 ); + scale_sig32( spectrum_fx, L_spec, scale ); + *spectrum_e = sub( *spectrum_e, scale ); +#endif sqGain_fx = SQ_gain_estimate_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e ); } ELSE @@ -4523,7 +4532,11 @@ void InternalTCXDecoder_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + xn_buf16[i] = shr_sat( xn_buf16[i], Q ); +#else xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); +#endif move16(); } diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 5290509cd32d8a7909d6c9af75ee51fabda55fdd..4c0b843e93560a38221a6e839b4c7998270495b4 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -282,8 +282,11 @@ void core_switching_pre_enc_fx( tmp16 = shr( st_fx->L_frame, 6 ); Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old TD BWE buffers */ IF( hBWE_TD != NULL ) { @@ -851,8 +854,11 @@ void core_switching_pre_enc_ivas_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old ACELP buffers */ test(); IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) @@ -902,8 +908,11 @@ void core_switching_pre_enc_ivas_fx( tmp16 = shr( st_fx->L_frame, 6 ); Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old TD BWE buffers */ IF( hBWE_TD != NULL ) { diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 7966fc7d890911da1911021957a5603e4a7bf973..247dcbda36417b85610b2bf4a28fd99fe26c9ae8 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -838,11 +838,7 @@ void dtx_fx( /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); -#endif } } diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 240f9859c84f2748e544432bf47a9ff619bfae59..1a17a0f9c2a7b1974c63f5e9aca4204e0dd86c40 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -623,7 +623,7 @@ void E_ACELP_4tsearchx_ivas_fx( /* Init to avoid crash when the search does not find a solution */ FOR( k = 0; k < nb_pulse; k++ ) { - codvec[k] = k; + codvec[k] = s_and( k, 3 ); move16(); } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index a485a1bf39cca3e3b503ba25c80494a3c8d25231..fc1f3e993f0038da6e3e1cf494c325313259461c 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -522,12 +522,10 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef TEST_HR if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { shift_wsp = sub( shift_wsp, 1 ); } -#endif /* set and write harmonicity flag */ harm_flag_acelp = 0; move16(); @@ -578,7 +576,7 @@ void encod_gen_voic_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -630,33 +628,18 @@ void encod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { -#ifdef TEST_HR gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); -#else - gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); -#endif } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { -#ifdef TEST_HR gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); -#else - gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) ); -#endif } ELSE { -#ifdef TEST_HR gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); -#else - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); -#endif } IF( st_fx->Opt_SC_VBR ) { diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index e9c9d87f74bfa057d719079170b1496c85b61887..8d9e1e1a13a1b817dcfb88714741bdd2ca1b59fc 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -449,7 +449,11 @@ void coder_acelp_rf_fx( Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_xn */ hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */ move16(); +#ifdef ISSUE_1772_replace_shr_o + hRF->rf_mem_w0 = shr_sat( hRF->rf_mem_w0, shift ); /*Qnew-1*/ +#else hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ +#endif /*-------------------------------------------------------* diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index bfdf46ea07a7db5a2b3c6db64020d48167b02455..548e3f904125711e63a0fdd5b428049e7cafbb72 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -744,7 +744,7 @@ void enc_pit_exc_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder @@ -814,7 +814,7 @@ void enc_pit_exc_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, + gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); @@ -823,7 +823,7 @@ void enc_pit_exc_ivas_fx( gcode16 = round_fx_sat( Lgcode ); IF( use_fcb != 0 ) { - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); // Q15 move16(); } ELSE diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 9d1ffad606de1ad414a8a6249fef35c5763a38b1..fca36f460bc3e53cef1ee84cc7ea8e9ebeb26a97 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -189,11 +189,7 @@ ivas_error encod_ppp_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); -#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } @@ -376,11 +372,7 @@ ivas_error encod_ppp_ivas_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); -#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 9802dc15b82071197c49514f3cfd2167ca4d2698..fb601aebad7dc48ac4fea83e31633876ad84ec0e 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -520,12 +520,10 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef TEST_HR if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { shift_wsp = sub( shift_wsp, 1 ); } -#endif /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -546,11 +544,7 @@ Word16 encod_tran_ivas_fx( q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ -#ifdef TEST_HR Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); -#else - Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) ); -#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); @@ -569,9 +563,6 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { -#ifndef TEST_HR - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ -#endif transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); } @@ -599,37 +590,22 @@ Word16 encod_tran_ivas_fx( IF( Jopt_flag == 0 ) { /* SQ gain_code */ -#ifdef TEST_HR gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); -#else - gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, sub( shift_wsp, 1 ) ); -#endif } ELSE { IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { /* SQ gain_pit and gain_code */ -#ifdef TEST_HR gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); -#else - gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, sub( shift_wsp, 1 ) ); -#endif } ELSE { /* VQ gain_pit and gain_code */ -#ifdef TEST_HR gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); -#else - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); -#endif } } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 5e1c8dfe32dffa97ff711e152ddc3b37b3c89478..ce7f05968128c6c31b9f24f99af344dc9f15c235 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -379,7 +379,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k ); -#ifdef HARM_PUSH_BIT /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) { @@ -387,26 +386,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit } delete_indice( hBstr, IND_ES_PRED ); -#else - /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ - FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) - { - IF( hBstr->ind_list[i].nb_bits != -1 ) - { - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */ - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - } - - IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 ) - { - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */ - move16(); - hBstr->ind_list[IND_ES_PRED].nb_bits = -1; - move16(); - } -#endif } IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 49d757be3054aaa7a7b2b829c14c21553ba46a77..87fa6a451061c07e284666c6bd70cb22ac42ac79 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1031,7 +1031,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { Word16 scale; - L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */ + L_subframe = L_frameTCX; /* Q0 */ /* L_subframe = idiv1616( L_frameTCX, nSubframes ); */ + IF( EQ_16( nSubframes, 2 ) ) + { + L_subframe = shr( L_frameTCX, 1 ); + } test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index dc78719d2b6cbcf57c535a7f86b0fb0e229e00b9..a49955e6ca8e914f16593005091097bd5b9412f9 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -322,10 +322,14 @@ void find_tilt_ivas_fx( { sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 } - lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr - /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ + lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr + /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ +#ifndef FIX_1762_COMPILER_ISSUE hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr - if ( hp_bckr == 0 ) /* Avoid division by zero. */ +#else + hp_bckr = W_extract_h( W_shl( W_add( W_deposit32_l( bckr[max_band - 1] ), W_deposit32_l( bckr[max_band] ) ), 31 ) ); // q_bckr +#endif + if ( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l( 1 ); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 61de9ca7d6d5a41fc5ac31197d075d2d8fde199a..9dcd8386bb4b405c607d3e02acc083e119c75f3b 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -32,9 +32,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum Word16 wtmp0, wtmp1; Word32 maxEnr, minEnr; Word16 dE2, exp0, exp1; +#ifndef ISSUE_1770_replace_shr_ro #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif dE2 = 0; @@ -76,7 +78,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum exp1 = sub( norm_l( maxEnr ), 1 ); wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); +#ifdef ISSUE_1770_replace_shr_ro + dE2 = shr_r_sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ +#else dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ +#endif return dE2; } diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 0ccb31ccfcf7e1eeb00cecab9149fa111b45bc8b..5e2a111693f72c8b8d5964b36708897b451935dd 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -2525,8 +2525,8 @@ void gain_enc_lbr_ivas_fx( /*Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR; *gain_inov = 1.0f / (float)sqrt(Ecode);*/ - L_tmp = Dot_product12( code, code, L_subfr, &exp_code ); - L_inov = L_tmp; /* sets to 'L_tmp' in 1 clock */ + L_tmp = Dot_product12( code, code, L_subfr, &exp_code ); /* Q9 + Q9 + 1 + (30-exp_code)*/ + L_inov = L_tmp; /* sets to 'L_tmp' in 1 clock */ move32(); /* exp_code: -18 (code in Q9), -6 (/L_SUBFR), -31 (L_tmp Q31->Q0) */ /* output gain_inov*/ @@ -2599,12 +2599,15 @@ void gain_enc_lbr_ivas_fx( /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode)); gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */ - - exp_code = sub( exp_code, 18 + 6 + 1 ); + // Ecode = (Ecode / L_subfr) + L_tmp = L_shr( L_tmp, L_subfr_sf ); // Q19 + (Q30-exp_code) + /* Calculation for log10(Ecode) exponent for applying log10 = Q31 - q = Q31 - Q19 - Q30 + exp_code = exp_code - Q18*/ + L_tmp = BASOP_Util_Log10( L_tmp, sub( exp_code, 18 ) ); // new q = Q25 exp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( exp_code, exp ); - L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/ + L_tmp = L_shl( L_tmp, exp ); // Q25 + exp + // 10 in Q27 , ( 10 * log10( Ecode ) ) + L_tmp1 = Mpy_32_32( L_tmp, 1342177280 ); // Q25 + exp + 1 + Q27 - 32 = Q21 + exp + L_tmp1 = L_shr( L_tmp1, add( 7, exp ) ); // Q21 + exp - 7 - exp = Q14 L_tmp = Dot_product( b, aux, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 320 ); /*Q14, 20 in Q4*/ diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 2aa9a5dfff887f9e1fd502971505046bb588201e..1efe1f656cf3ad523a83224221c81bc8cae05718 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -362,8 +362,12 @@ void gauss2v_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); +#ifdef ISSUE_1772_replace_shr_o + delta = shr_sat( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ +#else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ - delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ +#endif + delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -823,8 +827,12 @@ void gauss2v_ivas_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); +#ifdef ISSUE_1772_replace_shr_o + delta = shr_sat( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ +#else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ - delta = i_mult2( delta, m_sign ); /* Apply sign */ +#endif + delta = i_mult2( delta, m_sign ); /* Apply sign */ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 70b5166df6efef91583d4eb1f3df7225988b04b1..0a01dfe6667897772df2872ff2d6089504db72c5 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -135,9 +135,13 @@ static Word16 IGF_getCrest_new_fx( { x = logSpec[i]; move16(); +#ifdef OPT_MCT_ENC_V3_BE + x_eff = L_mac0( x_eff, x, x ); +#else x_eff = L_add( x_eff, L_mult0( x, x ) ); +#endif - IF( GT_16( x, x_max ) ) + if ( GT_16( x, x_max ) ) { x_max = x; move16(); @@ -2367,65 +2371,6 @@ void IGFEncSetMode_ivas_fx( * * IGF bitstream concatenation for TCX10 modes *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT /* Float code */ -void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -) -{ - Word16 i; - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - Indice *ind_list; - UWord8 *pFrame; /* byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size; /* number of bits in the binary encoded access unit [bits] */ - Word16 k, nb_bits_written; - Word32 imask; - UWord8 omask; - - hPrivateData = &hIGFEnc->igfData; - - ind_list = &hBstr->ind_list[sub( hBstr->nb_ind_tot, bsBits )]; /* here, we assume that each bit has been written as a single indice */ - pFrame = hPrivateData->igfBitstream; - pFrame_size = &hPrivateData->igfBitstreamBits; - nb_bits_written = 0; - move16(); - - omask = (UWord8) shr( 0x80, s_and( *pFrame_size, 0x7 ) ); - pFrame += shr( *pFrame_size, 3 ); - - /* bitstream packing (conversion of individual indices into a serial stream) */ - FOR( i = 0; i < bsBits; i++ ){ - IF( ind_list[i].nb_bits > 0 ){ - /* mask from MSB to LSB */ - imask = L_shl( 1, ( sub( ind_list[i].nb_bits, 1 ) ) ); - - /* write bit by bit */ - FOR( k = 0; k < ind_list[i].nb_bits; k++ ) - { - pack_bit( ind_list[i].value & imask, &pFrame, &omask ); - imask = L_shr( imask, 1 ); - } - nb_bits_written = add( nb_bits_written, ind_list[i].nb_bits ); - - /* delete the indice */ - ind_list[i].nb_bits = -1; - move16(); -} -} - -*pFrame_size = add( *pFrame_size, nb_bits_written ); -move16(); - -/* update list of indices */ -hBstr->nb_ind_tot = sub( hBstr->nb_ind_tot, bsBits ); -hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, nb_bits_written ); -move16(); -move16(); - -return; -} -#endif /*-------------------------------------------------------------------* * IGFEncResetTCX10BitCounter_ivas_fx() diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index a7b5eabb3f3701a86f4ab7d6e9859fcb83f37194..e0562467a93c60abef056c29d59cf5a67a193c8c 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -1627,33 +1627,6 @@ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, nb_bits_written ); return; } -#ifndef HARM_PUSH_BIT /* old bitstream */ -/**********************************************************************/ /* - IGF bitsream concatenation for TCX10 modes - **************************************************************************/ -void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word16 bsBits, /**< in: Q0 | number of IGF bits written to list of indices */ - Word16 *next_ind, /**< in/out: | pointer to actual bit indice */ - Word16 *nb_bits, /**< in/out: | total number of bits already written */ - Indice *ind_list_fx /**< in: | pointer to list of indices */ -) -{ - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - - hPrivateData = &hInstance->igfData; - *next_ind = *next_ind - bsBits; - move16(); - indices_to_serial_generic( - &ind_list_fx[*next_ind], - bsBits, - hPrivateData->igfBitstream, - &hPrivateData->igfBitstreamBits ); - - *nb_bits = sub( *nb_bits, bsBits ); - move16(); - return; -} -#endif /**********************************************************************/ /* IGF reset bitsream bit counter for TCX10 modes **************************************************************************/ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index a2f31cdd6c1c0f3f08971003816ec2a55bee4b0b..69cee425591e02ed5e9b17353c01c41b4c26def5 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -2163,13 +2163,9 @@ ivas_error init_encoder_ivas_fx( } ELSE { -#ifndef HARM_ENC_INIT - InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); -#else InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), &st->transientDetection ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index d019bf4747d93ff71f71c6e414e1826c8572237b..02ef250961a34f494fcf68dd187155763948c394 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -370,7 +370,7 @@ Word16 inov_encode_ivas_fx( Word16 shift, Word16 Q_new ) { - Word16 dn[2 * L_SUBFR], Qdn, Qcn; + Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; Word16 stack_pulses; Word16 g1, g2; @@ -586,6 +586,9 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); + Qh2 = sub( 14, norm_s( h2[0] ) ); + Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); + IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) @@ -597,7 +600,7 @@ Word16 inov_encode_ivas_fx( IF( i_subfr != 0 ) { idx = idiv1616( i_subfr, L_subfr ); - idx2 = idiv1616( i_subfr, L_SUBFR ); + idx2 = shr( i_subfr, L_SUBFR_LOG2 ); } IF( LT_16( st_fx->acelp_cfg.fixed_cdk_index[idx], ACELP_FIXED_CDK_NB ) ) @@ -661,7 +664,7 @@ Word16 inov_encode_ivas_fx( { FOR( k = 0; k < L_SUBFR - i; k++ ) { - y2[i + k] = add_sat( y2[i + k], round_fx( L_shl( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked + y2[i + k] = add_sat( y2[i + k], round_fx_sat( L_shl_sat( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked move16(); } } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index fbd207e2613f88aeb731994682a57b9fdacc910c..fff73a248cae6a23d5095adc19466514cf07fbb8 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1199,10 +1199,10 @@ ivas_error pre_proc_front_ivas_fx( IF( LE_32( element_brate, IVAS_32k ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7, element_mode ); } ELSE { @@ -1228,16 +1228,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ - - Word16 scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) ); - scale = sub( scale, 1 ); // guard bits - scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) ); - st->hNoiseEst->q_bckr = q_tmpN = scale; - move16(); - move16(); - - scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); + Word16 scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); scale = sub( scale, 1 ); // guard bits scale_sig32( tmpE_fx, NB_BANDS, sub( scale, q_tmpE ) ); @@ -1256,7 +1247,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); move16(); - noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_fx, q_tmpN, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx, &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, extract_h( st->hNoiseEst->Etot_l_lp_32fx ), st->hNoiseEst->Etot_v_h2_32fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame ); @@ -1265,14 +1256,6 @@ ivas_error pre_proc_front_ivas_fx( { FOR( Word16 j = 0; j < 2; j++ ) { - scale = s_min( add( q_tmpN_LR[j], L_norm_arr( tmpN_LR_fx[j], NB_BANDS ) ), add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS ) ) ); - scale = sub( s_min( Q31, scale ), 1 ); - scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_LR_fx[j], NB_BANDS, sub( scale, q_tmpN_LR[j] ) ); - hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_tmpN_LR[j] = scale; - move16(); - move16(); - scale = add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ); scale = s_min( scale, add( q_tmpE_LR[j], L_norm_arr( tmpE_LR_fx[j], NB_BANDS ) ) ); scale = sub( s_min( Q31, scale ), 1 ); @@ -1297,14 +1280,14 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Run noise_est for Left and Right channel */ - noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], q_tmpN_LR[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, tmpE_LR_fx[0], q_tmpE_LR[0], fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], lf_E_LR_fx_q, &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame ); /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */ - noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], q_tmpN_LR[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, tmpE_LR_fx[1], q_tmpE_LR[1], fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], lf_E_LR_fx_q, &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 6a2748e1c7d1fafb83d1074ca97f07604372112f..40ee8b95bb450e1d7fca1403e2b73242966bb990 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -39,7 +39,7 @@ #include "ivas_prot_fx.h" #include "math.h" #include "wmc_auto.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif /*-------------------------------------------------------------------* @@ -196,7 +196,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( temp_ind_list[i].function_name, hBstr->ind_list[i].function_name, 100 ); #endif hBstr->ind_list[i].nb_bits = -1; /* Q0 */ @@ -552,7 +552,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 ); #endif } @@ -579,7 +579,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 ); #endif } diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index be15b5048e9d7cf46306330025488e7b50d23804..ab48d0f3b849feba671f4ef99a89d61a1af4dad1 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -660,7 +660,18 @@ static Word16 ivas_dirac_get_mono_flag_fx( move32(); move16(); } - +#ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, W_band_power_e, Mpy_32_32( other_ch_band_power, threshold ), other_ch_band_power_e + threshold_e ) == 1 ) + { + any_mono_band = 1; + move16(); + } + ELSE + { + any_mc_band = 1; + move16(); + } +#else IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 0 ) { any_mono_band = 1; @@ -671,6 +682,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( any_mc_band = 1; move16(); } +#endif } } } @@ -998,7 +1010,7 @@ void ivas_dirac_param_est_enc_fx( diffuseness_vector_q = 0; move16(); - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); /* Q0 */ + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); /* Q0 */ IF( useLowerRes ) { q_direction->cfg.nblocks = 1; diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 495e6caa106cdc55a2165c5655ee104814982737..8b4509f49745d4ec4f7a39720b22e0142de70874 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -224,7 +224,11 @@ static Word16 ivas_spar_get_activeW_flag_fx( q_shift = Q31; move16(); q_shift = W_norm( bb_var_64bit[ch] ); +#ifdef FIX_1735_W_SHL_SAT_L + bb_var[ch] = W_shl_sat_l( bb_var_64bit[ch], sub( q_shift, 32 ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */ +#else bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */ +#endif move32(); q_bb_var[ch] = add( q_bb_var[ch], sub( q_shift, 32 ) ); move16(); @@ -564,7 +568,7 @@ static void ivas_band_cov_fx( pV_re[k] = W_shl_sat_l( pV_re_64bit[k], q_shift_tmp ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); #else - pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) + pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); #endif /* perform rounding towards lower value for negative results */ diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 963e363b27579a88cfeb6dab466b096f709a4ac4..1f62b6854b01955de104e106528d5c713a61ec4a 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -203,8 +203,6 @@ ivas_error front_vad_fx( move16(); FOR( n = 0; n < n_chan; n++ ) { - hFrontVads[n]->lp_speech_fx = shr( hFrontVads[n]->lp_speech_fx, 1 ); - move16(); scale_inp = s_min( sts[n]->q_inp, hCPE->hFrontVad[n]->q_mem_decim ); Scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) ); @@ -389,7 +387,7 @@ ivas_error front_vad_create_fx( } wb_vad_init_ivas_fx( hFrontVad->hVAD ); - hFrontVad->lp_speech_fx = 11520; // Q9/* Initialize the long-term active speech level in dB */ + hFrontVad->lp_speech_fx = 11520; // 45.0f in Q8 /* Initialize the long-term active speech level in dB */ move16(); hFrontVad->lp_noise_fx = 0; /* Initialize the long-term noise level in dB */ move16(); @@ -722,13 +720,6 @@ ivas_error front_vad_spar_fx( hFrontVad->hNoiseEst->ave_enr_q = scale; move16(); - scale = s_min( add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ), add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ) ); - scale = sub( s_min( Q31, scale ), 1 ); // guard bits - scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) ); - hFrontVad->hNoiseEst->q_bckr = scale; - move16(); - scale = add( hFrontVad->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) ); scale = s_min( scale, add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ) ); scale = s_min( Q31, scale ); @@ -739,7 +730,7 @@ ivas_error front_vad_spar_fx( move16(); move16(); - noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx, + noise_est_ivas_fx( st, old_pitch, tmpN_fx, q_tmpN, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx, hFrontVad->hNoiseEst->ave_enr_q, fr_bands_fx[0], q_fr_bands[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame ); @@ -767,7 +758,8 @@ ivas_error front_vad_spar_fx( move16(); hSpar->front_vad_dtx_flag = 1; move16(); - if ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) + test(); + if ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) { hSpar->front_vad_dtx_flag = 0; move16(); diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 7d88b12642a10e909e54a259de54435fe0479935..68b7fa7f724e3d8e7fabc7a4dfde8e1d17cb6ac3 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -41,7 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif @@ -272,59 +272,6 @@ Word16 getNumChanAnalysis_fx( return n; } -#ifndef HARM_ENC_INIT -/*-------------------------------------------------------------------* - * copy_encoder_config_ivas_fx() - * - * Copy configuration structrue to the state structrure - *-------------------------------------------------------------------*/ - -void copy_encoder_config_ivas_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -) -{ - IF( flag_all ) - { - st->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */ - move32(); - - st->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */ - move16(); - st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */ - move32(); - - st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */ - move16(); - - st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */ - move16(); - } - - st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */ - st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */ - move16(); - move16(); - - st->codec_mode = st_ivas->codec_mode; /* Q0 */ - st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */ - move16(); - move16(); - - st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */ - st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */ - st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */ - move16(); - move16(); - move16(); - - st->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */ - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * copy_encoder_config_fx() * @@ -467,617 +414,6 @@ void ivas_initialize_handles_enc_fx( * * Initialize IVAS encoder state structure *-------------------------------------------------------------------*/ -#ifndef HARM_ENC_INIT -ivas_error ivas_init_encoder( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -) -{ - Word16 i, n; - Word16 nchan_inp_buff; - Word16 sce_id, cpe_id; - IVAS_FORMAT ivas_format; - Word32 input_Fs, ivas_total_brate; - Word32 element_brate_tmp[MAX_NUM_OBJECTS]; - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - - error = IVAS_ERR_OK; - - hEncoderConfig = st_ivas->hEncoderConfig; - ivas_format = hEncoderConfig->ivas_format; - input_Fs = hEncoderConfig->input_Fs; /* Q0 */ - ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */ - move32(); - move32(); - - hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */ - move32(); - - if ( NE_32( ivas_format, MONO_FORMAT ) ) - { - /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ - move16(); - } - st_ivas->ism_mode = ISM_MODE_NONE; - st_ivas->mc_mode = MC_MODE_NONE; - move32(); - move32(); - - st_ivas->nchan_transport = -1; - move16(); - - /*-----------------------------------------------------------------* - * Allocate floating-point input audio buffers - *-----------------------------------------------------------------*/ - - nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */ - move16(); - - IF( EQ_32( ivas_format, MONO_FORMAT ) ) - { - nchan_inp_buff = 0; - move16(); - } - ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) - { - if ( EQ_32( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */ - { - nchan_inp_buff = add( nchan_inp_buff, 1 ); - } - - nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */ - } - - FOR( n = 0; n < nchan_inp_buff; n++ ) - { - /* note: these are intra-frame heap memories */ - IF( ( st_ivas->p_data_fx[n] = (Word32 *) malloc( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); - } - set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); - } - st_ivas->q_data_fx = Q11; - move16(); - FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - st_ivas->p_data_fx[n] = NULL; - } - /*-----------------------------------------------------------------* - * Allocate and initialize buffer of indices - *-----------------------------------------------------------------*/ - - /* set the maximum allowed number of indices in the list */ - st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */ - move16(); - - /* allocate buffer of indices */ - IF( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) ); - } - - /* reset the list of indices */ - for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) - { - st_ivas->ind_list[i].nb_bits = -1; - move16(); - } - - /* set the maximum allowed number of metadata indices in the list */ - st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */ - move16(); - - /* allocate buffer of metadata indices */ - IF( st_ivas->ivas_max_num_indices_metadata > 0 ) - { - IF( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of metadata indices!\n" ) ); - } - - /* reset the list of metadata indices */ - for ( i = 0; i < st_ivas->ivas_max_num_indices_metadata; i++ ) - { - st_ivas->ind_list_metadata[i].nb_bits = -1; - move16(); - } - } - ELSE - { - st_ivas->ind_list_metadata = NULL; - } - - /*-----------------------------------------------------------------* - * Allocate and initialize SCE/CPE and other handles - *-----------------------------------------------------------------*/ - - IF( EQ_32( ivas_format, MONO_FORMAT ) ) - { - st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ - move16(); - st_ivas->nCPE = 0; - move16(); - st_ivas->nchan_transport = 1; - move16(); - sce_id = 0; - move16(); - - test(); - IF( st_ivas->hEncoderConfig->element_mode_init != EVS_MONO ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - - /* prepare stereo downmix for EVS */ - IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) - { - IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ - st_ivas->nchan_transport = CPE_CHANNELS; - cpe_id = 0; - move16(); - move16(); - move16(); - move16(); - - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) ) - { - st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( st_ivas->hEncoderConfig->Opt_DTX_ON ) - { - IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) ) - { - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( ivas_format, SBA_FORMAT ) ) - { - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */ - move16(); - - IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */ - move16(); - - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( EQ_32( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->dtx_sce_sba = 1; - move16(); - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; - move16(); - } - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) - { - Word32 ism_total_brate; - Word16 k; - - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */ - move32(); - st_ivas->nchan_transport = 2; - move16(); - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - k = 0; - move16(); - while ( k < SIZE_IVAS_BRATE_TBL && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) ) - { - k++; - } - - ism_total_brate = 0; - move32(); - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] ); - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( GE_32( L_sub( ivas_total_brate, ism_total_brate ), MIN_BRATE_MDCT_STEREO ) ) - { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - else - { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - } - - IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ISM_MODE_NONE; - - if ( GE_32( ivas_total_brate, IVAS_256k ) ) - { - st_ivas->ism_mode = ISM_SBA_MODE_DISC; - } - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* allocate and initialize SBA handles */ - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); - move16(); - - IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) - { - /* allocate and initialize SBA core-coders */ - IF( EQ_16( st_ivas->nchan_transport, 1 ) ) - { - IF( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE - { - /* allocate and initialize MCT core coder */ - st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, MC_FORMAT ) ) - { - st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */ - - IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */ - move16(); - move16(); - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */ - move16(); - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2; - st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - move16(); - move16(); - move16(); - - IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) - { - IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) - { - Word32 brate_sce, brate_cpe; - - ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate ); - - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - ivas_mcmasa_split_brate_fx( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - } - - /*-----------------------------------------------------------------* - * Allocate and initialize HP20 filter memories - *-----------------------------------------------------------------*/ - - /* set number of input channels used for analysis/coding */ - n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */ - move16(); - - IF( n > 0 ) - { - IF( ( st_ivas->mem_hp20_in_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - } - } - ELSE - { - st_ivas->mem_hp20_in_fx = NULL; - } - - FOR( i = 0; i < n; i++ ) - { - IF( ( st_ivas->mem_hp20_in_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - } - - set32_fx( st_ivas->mem_hp20_in_fx[i], 0, L_HP20_MEM + 2 ); - } - return error; -} -#endif ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) @@ -1538,7 +874,7 @@ ivas_error ivas_init_encoder_fx( { st_ivas->nSCE = 0; move16(); - st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */ + st_ivas->nCPE = shr( hEncoderConfig->nchan_inp, CPE_CHANNELS_LOG2 ); /* Q0 */ move16(); FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index f7c06d2bd51f094cd278e911584cd3cbfe6e591a..d35327de0cb0aacb322d1e8ab8b21a23eaddc481 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -48,7 +48,8 @@ * Local constants *-----------------------------------------------------------------------*/ -#define ISM_NUM_PARAM 5 /* number of coded metadata parameters */ +#define ISM_NUM_PARAM 5 /* number of coded metadata parameters */ +#define ONE_BY_ISM_NUM_PARAM_Q15 6554 /* To be used for shift operation instead of division */ #define ISM_MAX_AZIMUTH_DIFF_IDX ( ISM_AZIMUTH_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_MAX_ELEVATION_DIFF_IDX ( ISM_ELEVATION_NBITS - 1 /*zero*/ - 1 /*sign*/ ) @@ -612,7 +613,7 @@ ivas_error ivas_ism_metadata_enc_fx( pos_zero = add( pos_zero, 1 ); } - ch = idiv1616( abs_next, ISM_NUM_PARAM ); + ch = mult( abs_next, ONE_BY_ISM_NUM_PARAM_Q15 ); IF( abs_next % ISM_NUM_PARAM == 0 ) { diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 13e4b06ad3ce025ca2f9f575a94936b54e8e6020..616c28ad8912b7c69d52a0b4420d1a34a362d84c 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -786,7 +786,7 @@ void ivas_masa_estimate_energy_fx( move16(); Word16 q_buf; maxBin = extract_l( Mpy_32_32( 134217728 /*CLDFB_NO_CHANNELS_MAX / L_FRAME48k in Q31*/, input_frame ) ); - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { @@ -2846,7 +2846,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx( IF( VQLevels > 0 ) { - lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx_q25, 4, VQLevels ); + lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx, 4, VQLevels ); move16(); } } diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 7f74f78f922ecc40682f6bbe91214d0c9cd0376e..ba2c52073d3f999bbd4962fe1200adf5a85a08a2 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -675,15 +675,10 @@ static void ivas_param_mc_param_est_enc_fx( #endif Word32 a_fx, b_fx, c_fx, d_fx; /* Tmp complex values */ Word16 a_e, b_e, c_e, d_e; /* Tmp complex values */ -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Word64 Cy_sum_real_64[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; Word64 Cy_sum_imag_64[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; Word16 sub62gb; Word16 sub35gb; -#else - Word32 Cy_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; - Word16 Cy_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; -#endif Word32 Cx_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 Cx_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 real_part_fx, imag_part_fx; @@ -712,7 +707,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); band_step = 1; move16(); -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) { FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) @@ -720,18 +714,12 @@ static void ivas_param_mc_param_est_enc_fx( set64_fx( Cy_sum_real_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); } } -#endif FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC; cur_param_band++ ) { FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE set64_fx( Cy_sum_imag_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); -#else - set32_fx( Cy_sum_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); - set16_fx( Cy_sum_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); -#endif } FOR( ch_idx1 = 0; ch_idx1 < PARAM_MC_MAX_TRANSPORT_CHANS; ch_idx1++ ) @@ -760,23 +748,16 @@ static void ivas_param_mc_param_est_enc_fx( } } -#if defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) || defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) Word16 gb = find_guarded_bits_fx( l_ts ); #ifndef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE Word16 add20gb = add( 20, gb ); #endif -#endif -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE sub35gb = sub( 32, sub( 11, find_guarded_bits_fx( l_ts ) ) ); // 31 - (((11 - gb) + 31 + norm) - 32) sub62gb = sub( 63, shl( sub( 11, find_guarded_bits_fx( l_ts ) ), 1 ) ); // 31 - ((2*(11 - gb) + norm) - 32) -#endif FOR( ts = start_ts; ts < num_time_slots; ts++ ) { -#if !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) && !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) - Word16 gb = find_guarded_bits_fx( l_ts ); -#endif ivas_fb_mixer_get_windowed_fr_fx( hParamMC->hFbMixer, pcm_in_fx, p_slot_frame_f_real_fx, p_slot_frame_f_imag_fx, l_ts, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans, gb ); ivas_fb_mixer_update_prior_input_fx( hParamMC->hFbMixer, pcm_in_fx, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans ); @@ -822,26 +803,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); move64(); -#else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - dmx_real_fx[ch_idx1] = 0; - move32(); - dmx_real_e[ch_idx1] = 0; - move16(); - dmx_imag_fx[ch_idx1] = 0; - move32(); - dmx_imag_e[ch_idx1] = 0; - move16(); - FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) - { - L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_real_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_real_fx[ch_idx1], dmx_real_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_real_e[ch_idx1] ); - move32(); - L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_imag_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_imag_fx[ch_idx1], dmx_imag_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_imag_e[ch_idx1] ); - move32(); - p_dmx_fac_fx++; - } #else Word32 real_fx = L_add( 0, 0 ); Word16 real_e = add( 0, 0 ); @@ -863,7 +824,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); move32(); move16(); -#endif #endif } @@ -910,7 +870,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); } } -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; @@ -930,65 +889,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); } } -#else - /* Cy for input channels */ - FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) - { -#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); - a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); - a_e = sub( add20gb, a_e ); - if ( a_fx == 0 ) - { - a_e = 0; - move16(); - } - b_e = norm_l( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band] ); - b_fx = L_shl( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], b_e ); - b_e = sub( add20gb, b_e ); - if ( b_fx == 0 ) - { - b_e = 0; - move16(); - } -#endif - FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) - { -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); - b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); - c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); - d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); -#else - c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); - c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); - c_e = sub( add20gb, c_e ); - if ( c_fx == 0 ) - { - c_e = 0; - move16(); - } - d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); - d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); - d_e = sub( add20gb, d_e ); - if ( d_fx == 0 ) - { - d_e = 0; - move16(); - } -#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - L_tmp, tmp_e, &Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, d_fx ), add( a_e, d_e ), L_negate( Mpy_32_32( b_fx, c_fx ) ), add( b_e, c_e ), &tmp_e ); - Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2], - L_tmp, tmp_e, &Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - } - } -#endif } } @@ -1026,27 +926,6 @@ static void ivas_param_mc_param_est_enc_fx( dmx_imag_64[ch_idx1] = imag_64; move64(); move64(); -#else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - dmx_real_fx[ch_idx1] = 0; - move32(); - dmx_real_e[ch_idx1] = 0; - move16(); - dmx_imag_fx[ch_idx1] = 0; - move32(); - dmx_imag_e[ch_idx1] = 0; - move16(); - - FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) - { - L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_real_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_real_fx[ch_idx1], dmx_real_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_real_e[ch_idx1] ); - move32(); - L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_imag_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_imag_fx[ch_idx1], dmx_imag_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_imag_e[ch_idx1] ); - move32(); - p_dmx_fac_fx++; - } #else Word32 real_fx = L_add( 0, 0 ); Word16 real_e = 0; @@ -1071,7 +950,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); dmx_imag_e[ch_idx1] = imag_e; move16(); -#endif #endif } @@ -1083,7 +961,6 @@ static void ivas_param_mc_param_est_enc_fx( CONVERT_DMX( dmx_real_64[ch_idx1], a_fx, a_e ); CONVERT_DMX( dmx_imag_64[ch_idx1], b_fx, b_e ); #else -#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE a_fx = dmx_real_fx[ch_idx1]; move32(); a_e = dmx_real_e[ch_idx1]; @@ -1092,7 +969,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); b_e = dmx_imag_e[ch_idx1]; move16(); -#endif #endif FOR( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) @@ -1106,34 +982,10 @@ static void ivas_param_mc_param_est_enc_fx( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); #else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - a_fx = dmx_real_fx[ch_idx1]; - move32(); - a_e = dmx_real_e[ch_idx1]; - move16(); - b_fx = dmx_imag_fx[ch_idx1]; - move32(); - b_e = dmx_imag_e[ch_idx1]; - move16(); - c_fx = dmx_real_fx[ch_idx2]; - move32(); - c_e = dmx_real_e[ch_idx2]; - move16(); - d_fx = dmx_imag_fx[ch_idx2]; - move32(); - d_e = dmx_imag_e[ch_idx2]; - move16(); - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, - &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); -#else /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, dmx_real_fx[ch_idx2] ), add( a_e, dmx_real_e[ch_idx2] ), Mpy_32_32( b_fx, dmx_imag_fx[ch_idx2] ), add( b_e, dmx_imag_e[ch_idx2] ), &tmp_e ); Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); -#endif #endif move32(); } @@ -1160,7 +1012,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); } #endif -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; b_fx = slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band]; move32(); @@ -1176,39 +1027,6 @@ static void ivas_param_mc_param_est_enc_fx( W_add( W_mult0_32_32( a_fx, c_fx ), W_mult0_32_32( b_fx, d_fx ) ) ); move64(); } -#else - FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) - { -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); - b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); - c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); - d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); -#else - c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); - c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); - c_e = sub( add20gb, c_e ); - if ( c_fx == 0 ) - { - c_e = 0; - move16(); - } - d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); - d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); - d_e = sub( add20gb, d_e ); - if ( d_fx == 0 ) - { - d_e = 0; - move16(); - } -#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, - &Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - } -#endif } } } @@ -1222,7 +1040,6 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move64(); Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; @@ -1231,24 +1048,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); Cy_sum_imag_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move64(); -#else - Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); - Cy_sum_imag_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_imag_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_imag_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_imag_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); -#endif } } @@ -1256,21 +1055,10 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move64(); Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move64(); -#else - Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); -#endif } } } @@ -1307,16 +1095,9 @@ static void ivas_param_mc_param_est_enc_fx( /* get ICLDs */ FOR( k = 0; k < nchan_input; ++k ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE CONVERT_CY( Cy_sum_real_64[cur_param_band][k][k], Nrg_fx[k], Nrg_e[k] ); move32(); move16(); -#else - Nrg_fx[k] = Cy_sum_fx[cur_param_band][k][k]; - move32(); - Nrg_e[k] = Cy_sum_e[cur_param_band][k][k]; - move16(); -#endif } FOR( k = 0; k < num_ilds_to_code; ++k ) { @@ -1383,22 +1164,10 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); move64(); Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] ); move64(); - -#else - Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); - Cy_sum_imag_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_imag_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_imag_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); -#endif } } } @@ -1422,14 +1191,7 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); -#else - Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); -#endif } } } @@ -1438,7 +1200,6 @@ static void ivas_param_mc_param_est_enc_fx( band_step = 2; move16(); } -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE { // convert the 64 bit fixpoint back into the 48 bit float format FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) @@ -1454,7 +1215,6 @@ static void ivas_param_mc_param_est_enc_fx( } } } -#endif /* map complex covariances to real values */ FOR( cur_param_band = 0; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band += band_step ) @@ -1491,16 +1251,9 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE CONVERT_CY( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], imag_part_fx, imag_part_e ); move32(); move16(); -#else - imag_part_fx = Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2]; - move32(); - imag_part_e = Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2]; - move16(); -#endif real_part_fx = Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2]; move32(); real_part_e = Cy_sum_e[cur_param_band][ch_idx1][ch_idx2]; diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index cad29b1461033258b0bc71d37f575a2d8552c7e1..c1f7357042c0eea950db02102160e179edb20407 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -855,7 +855,7 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx( } // l_ts = input_frame / MAX_PARAM_SPATIAL_SUBFRAMES; - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); move16(); Word16 gb = find_guarded_bits_fx( l_ts ); diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 314424341f4a80b354c9d1aab3f5dceb5ac24536..b246230033d83694c711f70a860288be2cf06fa3 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -957,10 +957,10 @@ void ivas_mcmasa_param_est_enc_fx( set_zero_fx( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); } - num_freq_bins = idiv1616( input_frame, MDFT_NO_COL_MAX ); + num_freq_bins = shr( input_frame, MDFT_NO_COL_MAX_LOG2 ); num_freq_bands = hMcMasa->nbands; move16(); - l_ts = idiv1616( input_frame, MDFT_NO_COL_MAX ); + l_ts = shr( input_frame, MDFT_NO_COL_MAX_LOG2 ); set16_fx( q_vdv, 31, MASA_FREQUENCY_BANDS ); set16_fx( out_exp, 30, MASA_FREQUENCY_BANDS ); @@ -1942,9 +1942,17 @@ static void ivas_mcmasa_dmx_fx( Word32 alpha_fx, L_tmp, L_tmp1; Word16 multiChEne_e, scale, downmixEne_e = 0, prevEQ_e, tmp, currEQ_e, instEQ_e; move16(); +#ifdef OPT_MCT_ENC_48KB_NBE + Word16 max_exp, tmp_exp, separateChannelFlag; + Word64 tmp_64; + Word64 multiChEne_64_fx = 0; + Word64 downmixEne_64_fx = 0; + move64(); + move64(); +#endif numAnalysisChannels = sub( nchan_inp, 1 ); - IF( hMcMasa->separateChannelEnabled ) + if ( hMcMasa->separateChannelEnabled ) { numAnalysisChannels = sub( nchan_inp, 2 ); } @@ -1957,22 +1965,45 @@ static void ivas_mcmasa_dmx_fx( { FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + multiChEne_64_fx = W_mac_32_32( multiChEne_64_fx, data_fx[j][i], data_fx[j][i] ); // exp: 2*data_e +#else L_tmp1 = BASOP_Util_Add_Mant32Exp( data_fx[j][i], data_e, 0, 0, &scale ); L_tmp = Mpy_32_32( L_tmp1, L_tmp1 ); // data_e + data_e multiChEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale + scale, multiChEne_fx, multiChEne_e, &scale ); multiChEne_e = scale; move16(); +#endif } } - +#ifdef OPT_MCT_ENC_48KB_NBE + tmp = shl( data_e, 1 ); +#endif IF( EQ_16( nchan_transport, 2 ) ) { Word16 numSideChannels; /* Channels other than left, right, center */ Word16 leftIndex, rightIndex; +#ifdef OPT_MCT_ENC_48KB_NBE + Word16 tmp_16; + + separateChannelFlag = 1; + move16(); + if ( hMcMasa->separateChannelEnabled ) + { + separateChannelFlag = 0; + move16(); + } +#endif numSideChannels = sub( shr( numAnalysisChannels, 1 ), 1 ); FOR( j = 0; j < numSideChannels; j++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + tmp_16 = add( shl( j, 1 ), 2 ); + + leftIndex = add( tmp_16, separateChannelFlag ); + rightIndex = add( add( tmp_16, 1 ), separateChannelFlag ); +#else IF( hMcMasa->separateChannelEnabled ) { leftIndex = add( shl( j, 1 ), 2 ); @@ -1983,7 +2014,7 @@ static void ivas_mcmasa_dmx_fx( leftIndex = add( shl( j, 1 ), 3 ); rightIndex = add( shl( j, 1 ), 4 ); } - +#endif FOR( i = 0; i < input_frame; i++ ) { data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] ); // data_e @@ -2023,15 +2054,28 @@ static void ivas_mcmasa_dmx_fx( { FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + downmixEne_64_fx = W_mac_32_32( downmixEne_64_fx, data_fx[j][i], data_fx[j][i] ); // exp: 2*data_e +#else L_tmp1 = BASOP_Util_Add_Mant32Exp( data_fx[j][i], data_e, 0, 0, &scale ); L_tmp = Mpy_32_32( L_tmp1, L_tmp1 ); // data_e + data_e downmixEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale + scale, downmixEne_fx, downmixEne_e, &downmixEne_e ); +#endif } } alpha_fx = 214748364; // 0.1 in Q31 move32(); +#ifdef OPT_MCT_ENC_48KB_NBE + scale = W_norm( multiChEne_64_fx ); + multiChEne_fx = W_extract_h( W_shl( multiChEne_64_fx, scale ) ); + multiChEne_e = sub( tmp, scale ); + + scale = W_norm( downmixEne_64_fx ); + downmixEne_fx = W_extract_h( W_shl( downmixEne_64_fx, scale ) ); + downmixEne_e = sub( tmp, scale ); +#endif L_tmp = Mpy_32_32( alpha_fx, multiChEne_fx ); L_tmp1 = Mpy_32_32( 1932735284 /* 0.9f in Q31 */, hMcMasa->prevMultiChEne_fx ); hMcMasa->prevMultiChEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, multiChEne_e, L_tmp1, hMcMasa->prevMultiChEne_e, &hMcMasa->prevMultiChEne_e ); @@ -2056,12 +2100,26 @@ static void ivas_mcmasa_dmx_fx( hMcMasa->prevEQ_e = currEQ_e; move16(); +#ifdef OPT_MCT_ENC_48KB_NBE + max_exp = s_max( prevEQ_e, currEQ_e ); + prevEQ_fx = L_shl( prevEQ_fx, sub( prevEQ_e, max_exp ) ); // exp:max_exp + currEQ_fx = L_shl( currEQ_fx, sub( currEQ_e, max_exp ) ); // exp:max_exp + tmp_exp = add( max_exp, 16 ); +#endif + FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + tmp_64 = W_mac_32_32( W_mult_32_16( currEQ_fx, hMcMasa->interpolator_fx[i] ), prevEQ_fx, L_sub( ONE_IN_Q15, hMcMasa->interpolator_fx[i] ) ); // exp:max_exp +16 + scale = W_norm( tmp_64 ); + instEQ_fx = W_extract_h( W_shl( tmp_64, scale ) ); + instEQ_e = sub( tmp_exp, scale ); +#else L_tmp = Mpy_32_32( L_deposit_h( hMcMasa->interpolator_fx[i] ), currEQ_fx ); L_tmp1 = L_sub( 1073741824 /* 1 in Q30 */, L_lshr( L_deposit_h( hMcMasa->interpolator_fx[i] ), 1 ) ); L_tmp1 = Mpy_32_32( L_tmp1, prevEQ_fx ); instEQ_fx = BASOP_Util_Add_Mant32Exp( L_tmp, currEQ_e, L_tmp1, add( prevEQ_e, 1 ), &instEQ_e ); +#endif FOR( j = 0; j < nchan_transport; j++ ) { @@ -2085,6 +2143,41 @@ static void compute_cov_mtx_fx( ) { Word16 i, j; +#ifdef OPT_MCT_ENC_V1_NBE + Word64 temp64_1, temp64_2; + Word16 tmp_16, max_exp; + Word16 temp_exp = shl( inp_exp, 1 ); + FOR( i = 0; i < N; i++ ) + { + FOR( j = i; j < N; j++ ) + { + temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_2 = W_deposit32_h( COVls->xr_fx[i][j] ); // exp:COVls->xr_e[i][j] + max_exp = s_max( COVls->xr_e[i][j], temp_exp ); + temp64_2 = W_shl( temp64_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp + tmp_16 = W_norm( temp64_1 ); + + COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xr_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + move16(); + + temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp + temp64_2 = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] + max_exp = s_max( COVls->xi_e[i][j], temp_exp ); + temp64_2 = W_shl( temp64_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp + tmp_16 = W_norm( temp64_1 ); + + COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xi_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + } + } +#else Word32 a, b, c, d; Word32 temp; Word16 norm_a, norm_b, norm_c, norm_d; @@ -2117,10 +2210,89 @@ static void compute_cov_mtx_fx( move32(); } } - +#endif return; } +#ifdef OPT_MCT_ENC_V1_BE +static void computeIntensityVector_enc_fx( + const Word16 *band_grouping, + Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ + const Word16 enc_param_start_band, /* i : first band to process */ + const Word16 num_frequency_bands, + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ) +{ + Word16 i, j; + Word32 real, img; + Word16 brange[2]; + Word16 shift_value = add( shl( inp_q, 1 ), 1 ); + Word16 tmp_norm; + FOR( i = 0; i < num_frequency_bands; i++ ) + { + brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */ + move16(); + brange[1] = band_grouping[i + enc_param_start_band + 1]; /* Q0 */ + move16(); + Word16 num_bins = sub( brange[1], brange[0] ); + Word16 gb = find_guarded_bits_fx( num_bins ); + Word16 norm; + + Word64 tmp_1 = 0, tmp_2 = 0, tmp_3 = 0; + move64(); + move64(); + move64(); + + FOR( j = brange[0]; j < brange[1]; j++ ) + { + real = Cldfb_RealBuffer[0][j]; + move32(); + img = Cldfb_ImagBuffer[0][j]; + move32(); + Word64 t1, t2, t3; + t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */ + t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */ + t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */ + t1 = W_shr( t1, gb ); + t2 = W_shr( t2, gb ); + t3 = W_shr( t3, gb ); + /* Intensity is XYZ order, audio is WYZX order. */ + tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */ + tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */ + tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */ + } + norm = 63; + move16(); + tmp_norm = W_norm( tmp_1 ); + if ( tmp_1 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + tmp_norm = W_norm( tmp_2 ); + if ( tmp_2 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + tmp_norm = W_norm( tmp_3 ); + if ( tmp_3 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + norm = sub( norm, 32 ); + intensity_real[0][i] = W_shl_sat_l( tmp_1, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[1][i] = W_shl_sat_l( tmp_2, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[2][i] = W_shl_sat_l( tmp_3, norm ); // shift_value - (gb - norm) + q_intensity_real[i] = sub( shift_value, sub( gb, norm ) ); + move16(); + } + + return; +} +#else static void computeIntensityVector_enc_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ @@ -2205,6 +2377,7 @@ static void computeIntensityVector_enc_fx( return; } +#endif static void computeVerticalDiffuseness_fx( Word32 **buffer_intensity, /* i : Intensity vectors */ diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index e01387c37d7fffdd145b29b55d43de1adbfcdef1..8eb2ee9b26000c9cac8e634a7dbcc603abf705a4 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -285,11 +285,11 @@ ivas_error ivas_mct_enc_fx( Word16 length, ch, nCPE; IF( ( hMCT->nchan_out_woLFE % 2 ) == 0 ) { - nCPE = idiv1616( hMCT->nchan_out_woLFE, 2 ); + nCPE = shr( hMCT->nchan_out_woLFE, 1 ); } ELSE { - nCPE = add( idiv1616( hMCT->nchan_out_woLFE, 2 ), 1 ); + nCPE = add( shr( hMCT->nchan_out_woLFE, 1 ), 1 ); } FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) @@ -311,12 +311,12 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV } IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } IF( hMCT->p_orig_spectrum_long_fx[cpe_id][ch] ) { @@ -357,11 +357,11 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } Word16 norm = L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ); q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); @@ -389,7 +389,7 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) ); // q_spec @@ -402,7 +402,7 @@ ivas_error ivas_mct_enc_fx( IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) @@ -431,7 +431,7 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } Word16 e_spec = sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ) ); IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index d1ca16b9435ce8975d1109075248e268788d6693..4e7bc83283187a4bf1e568a0ca4b2a1d62e02dc4 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -98,7 +98,7 @@ void computeIntensityVector_enc_fx( Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ); -static void computeReferencePower_omasa_ivas_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 *reference_power, const Word16 enc_param_start_band, const Word16 num_freq_bands, Word16 q_Cldfb, Word16 *ref_exp ); +static void computeReferencePower_omasa_ivas_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 *reference_power, const Word16 enc_param_start_band, const Word16 num_freq_bands, Word16 q_Cldfb, Word16 q_reference_power[CLDFB_NO_CHANNELS_MAX] ); /*--------------------------------------------------------------------------* * ivas_omasa_enc_open() * @@ -1073,7 +1073,7 @@ static void ivas_omasa_param_est_enc_fx( dir_v_e = MIN_16; num_freq_bins = hOMasa->cldfbAnaEnc[0]->no_channels; num_freq_bands = hOMasa->nbands; - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); move16(); move16(); move16(); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 9a7c4038b3e4a6a25cac5ab22478160812bca365..c9a8428eb5566cc65ed35a53ab00430f7f264dd9 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -43,7 +43,7 @@ #include "basop_util.h" #include "ivas_rom_com_fx.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif @@ -370,7 +370,7 @@ ivas_error ivas_qmetadata_enc_encode_fx( { no_TF = add( imult1616( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ), imult1616( hQMetaData->q_direction[1].cfg.nbands, hQMetaData->q_direction[1].cfg.nblocks ) ); test(); - IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), idiv1616( imult1616( 43, no_TF ), 10 ) ), sum16_fx( bits_diff, ndirections ) ), MASA_MIN_BITS_SURR_COH ) ) + IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), mult( imult1616( 43, no_TF ), ONE_BY_TEN_Q15 ) ), sum16_fx( bits_diff, ndirections ) ), MASA_MIN_BITS_SURR_COH ) ) { bits_surround_coh = encode_surround_coherence_fx( hQMetaData, hMetaData ); } @@ -396,7 +396,7 @@ ivas_error ivas_qmetadata_enc_encode_fx( { no_TF = imult1616( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ); test(); - IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), idiv1616( imult1616( 43, no_TF ), 10 ) ), bits_diff[0] ), MASA_MIN_BITS_SURR_COH ) ) + IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), mult( imult1616( 43, no_TF ), ONE_BY_TEN_Q15 ) ), bits_diff[0] ), MASA_MIN_BITS_SURR_COH ) ) { bits_surround_coh = encode_surround_coherence_fx( hQMetaData, hMetaData ); } @@ -1072,12 +1072,8 @@ void ivas_qmetadata_enc_sid_encode_fx( { /*compute the average direction */ ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[m], q_direction->band_data[b].elevation_fx[m], direction_vector_fx ); - scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 + scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22 v_add_fixed_no_hdrm( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3 ); // Q22 -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3, 0 ); // Q22 -#endif /* VEC_ARITH_OPT_v1 */ } ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, Q22, &avg_azimuth_fx[b], &avg_elevation_fx[b] ); @@ -1195,7 +1191,7 @@ void reset_metadata_spatial_fx( { hMetaData->ind_list[i].nb_bits = -1; move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" ); #endif } @@ -1204,12 +1200,12 @@ void reset_metadata_spatial_fx( { hMetaData->ind_list[j].value = hMetaData->ind_list[i].value; hMetaData->ind_list[j].nb_bits = hMetaData->ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hMetaData->ind_list[j].function_name, hMetaData->ind_list[i].function_name, 100 ); #endif hMetaData->nb_bits_tot = add( hMetaData->nb_bits_tot, hMetaData->ind_list[j].nb_bits ); hMetaData->ind_list[i].nb_bits = -1; -#ifdef BISTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" ); #endif move16(); @@ -2019,7 +2015,7 @@ void restore_metadata_buffer_fx( { hMetaData->ind_list[i].nb_bits = -1; move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in restore_metadata_buffer" ); #endif } @@ -2421,11 +2417,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( /*compute the average direction */ ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector ); scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } } @@ -2688,11 +2680,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( IF( LT_16( idx, 4 ) ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } /* project the quantized average azimuth angle to the same grid as the current sample */ @@ -2723,11 +2711,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector ); scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector, Q22, &avg_azimuth, &avg_elevation ); avg_azimuth_index_upd = quantize_phi_enc_fx( L_add( avg_azimuth, 180 << Q22 ), 0, &avg_azimuth, avg_azimuth_alphabet ); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index f0811aea67b6c18f2cf62a213d93fe7c12bd36d5..879a982460dc4831cfa83123152fe85e54a2b60d 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -612,7 +612,6 @@ ivas_error create_evs_sce_enc_fx( { return error; } -#ifdef HARM_PUSH_BIT /*-----------------------------------------------------------------* * Bitstream *-----------------------------------------------------------------*/ @@ -626,11 +625,6 @@ ivas_error create_evs_sce_enc_fx( st_fx->hBstr->nb_bits_tot = 0; move16(); st_fx->hBstr->st_ivas = st_ivas; -#else - st_fx->hBstr->ind_list = ind_list; - // st_fx->hBstr->ind_list_fx = st->hBstr->ind_list; - reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); -#endif hSCE->hCoreCoder[0] = st_fx; diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 2eaefb48358859a5c23cb148d781654a24b39a7b..610f39b1b2f0610a24bd4764d3cfd61ee0dfa108 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -258,7 +258,7 @@ static Word16 sns_1st_cod_fx( } /* for second split shift by five bits to store both indices as one 10 bit value */ - IF( EQ_16( split, 1 ) ) + if ( EQ_16( split, 1 ) ) { index_split = shl( index_split, 5 ); } @@ -672,11 +672,7 @@ Word16 quantize_sns_fx( Word32 ener_side_fx; Word16 ener_side_q; -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ Word64 L64_sum; L64_sum = 1; diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 3b380f2ebacda088f27ceaa010823af2bd6199b3..8143a8c33389b5f70e273554410ced1b7ebd2dff 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -788,7 +788,7 @@ static ivas_error ivas_spar_enc_process_fx( shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); } - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); Word16 gb = find_guarded_bits_fx( l_ts ); FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index 2a4953c2148e18d22ab0f6bf18f2b6590d4d5303..8769c748b91b395ff954568e5b766a8278625a1f 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -439,7 +439,7 @@ static void write_metadata_buffer_fx( FOR( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ ) { -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) push_next_indice_( hMetaData_tmp->ind_list[i].function_name, hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits ); #else push_next_indice( hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits ); @@ -479,7 +479,7 @@ ivas_error ivas_spar_md_enc_process_fx( Word32 pred_coeffs_re_local_fx[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; Word16 k, bwidth, num_bands, num_bands_full, num_bands_bw; Word16 active_w, nchan_transport, dmx_switch, strat; - Word16 nB, bands_bw, packed_ok = 0; + Word16 nB, bands_bw, bands_bw_log2, packed_ok = 0; move16(); ivas_strats_t cs[MAX_CODING_STRATS]; Word16 code_strat; @@ -587,7 +587,7 @@ ivas_error ivas_spar_md_enc_process_fx( { nB = SPAR_DTX_BANDS; move16(); - bands_bw = idiv1616( num_bands, nB ); + bands_bw = shr( num_bands, SPAR_DTX_BANDS_LOG2 ); ivas_band_mixer_fx( cov_real_fx, cov_real_q, num_ch, &num_bands, bands_bw ); } @@ -595,7 +595,9 @@ ivas_error ivas_spar_md_enc_process_fx( { bands_bw = 2; move16(); - nB = idiv1616( num_bands, bands_bw ); + bands_bw_log2 = 1; + move16(); + nB = shr( num_bands, bands_bw_log2 ); ivas_band_mixer_fx( cov_real_fx, cov_real_q, num_ch, &num_bands, bands_bw ); } diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 28bac9e8bc5baa416464a2efd783b833fc06d35c..44434f78f6e060b8590e40f47e6f02c4de0ea724 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -1467,7 +1467,7 @@ void stereo_dft_enc_compute_itd_fx( // sfm_L = expf( log_prod_L / ( NFFT_mid ) ) / ( sum_abs_L / ( NFFT_mid ) ); L_temp = BASOP_Util_Divide3232_Scale_newton( log_prod_L, NFFT_mid, &L_temp_e ); L_temp_e = add( L_temp_e, sub( log_prod_L_e, 31 ) ); - L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); + L_temp = BASOP_Util_fPow( 1459215139 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); q_temp = norm_l( NFFT_mid ); L_temp2 = L_shl( NFFT_mid, q_temp ); L_temp2_e = sub( 31, q_temp ); diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 5753c199e7294b3a837c73b3662558989f9ffe65..1739dc1e9e71c13dad2d7bb78305743103756046 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -437,7 +437,6 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -448,7 +447,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -462,7 +460,6 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -473,7 +470,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -496,7 +492,6 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -507,7 +502,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -520,7 +514,6 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -531,7 +524,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -2930,7 +2922,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_g = hStereoDmxEVS->hPHA->fad_g_fx; // fad_r = 1.0f / (float) ( fad_len + 1 ); -#ifdef FIX_1481_HARDCODE_DIV SWITCH( fad_len ) { case STEREO_DMX_EVS_FAD_LEN_16: @@ -2955,9 +2946,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e ); BREAK; } -#else - fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); -#endif fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) @@ -3053,7 +3041,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_g = hStereoDmxEVS->hPHA->fad_g_prc_fx; move32(); // fad_r = 1.0f / (float) ( fad_len + 1 ); -#ifdef FIX_1481_HARDCODE_DIV SWITCH( fad_len ) { case STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 16: @@ -3078,9 +3065,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e ); BREAK; } -#else - fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); -#endif fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 95c49aeae8f13423959a6ec97aa6092144f4f790..67ba071a055792d0c100a798df8fbe58a027160f 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -828,11 +828,7 @@ void stereo_icBWE_enc_ivas_fx( ELSE { -#ifndef FIX_1713_EXP - max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e ); -#else max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e ); -#endif Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e set32_fx( shb_frame_ref_fx, 0, L_LOOK_16k + L_FRAME16k ); @@ -857,12 +853,8 @@ void stereo_icBWE_enc_ivas_fx( move16(); /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */ - Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */ -#ifndef FIX_1713_EXP - Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#else + Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */ Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#endif /* core switching reset */ test(); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 2f1b7d6c8d6a37248247971dece778020c06e8e5..f7735e8df900b766f6d6043bd53e9b5591397c00 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -882,7 +882,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } i = 0; move16(); @@ -901,7 +901,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } /* SQ scale: 4 bits / 6 dB per quadruple */ @@ -911,6 +911,9 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res offset_fx = fac_fx; /* Q25 */ move32(); +#ifdef OPT_MCT_ENC_V2_BE + Word64 target_64_fx = W_shl( target_fx, 7 ); // Q25 +#endif /* find offset (0 to 128 dB with step of 0.125dB) */ FOR( iter = 0; iter < 10; iter++ ) { @@ -923,6 +926,20 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res { tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */ +#ifdef OPT_MCT_ENC_V2_BE + /* avoid SV with 1 bin of amp < 0.5f */ + if ( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) + { + W_tmp = W_add( W_tmp, tmp_32 ); /* Q25 */ + } + /* if ener is above target -> break and increase offset */ + IF( GT_64( W_tmp, target_64_fx ) ) + { + offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */ + BREAK; + } +#else + /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) { @@ -935,6 +952,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res BREAK; } } +#endif } } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index d10527a241855fcf154159a26d233abe764773e3..e2c12076d416a8fb0787181cdb5b6fab2da2841e 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -285,7 +285,7 @@ void encod_gen_2sbfr( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 16fc9fe4b1b6d07c9fd9947b0b9482b3143b23d2..8cf6be1cd0e6ca1385d5c7ec3588583ea115ac20 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -302,10 +302,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME */ UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); /*! r: error code */ @@ -315,10 +311,6 @@ ivas_error IVAS_ENC_EncodeFrameToCompact( const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ UWord16 *numOutBits /* o : number of bits written to output bitstream */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); /* Setter functions - apply changes to encoder configuration */ diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 32c26be28431c5601bdc278f7e48d0c49bdf054d..dece7ba26a5a9b771489163b89aac1d22baeb02f 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -609,53 +609,6 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( return error; } -#ifndef HARM_ENC_INIT -ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const Word32 inputFs, /* i : input sampling frequency */ - const Word32 bitrate, /* i : requested bitrate of the output bitstream */ - const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ - const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ - const bool Opt_PCA_ON /* i : PCA option flag */ -) -{ - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - - IF( ( error = doCommonConfigureChecks( hIvasEnc ) ) != IVAS_ERR_OK ) - { - return error; - } - - hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; - - hEncoderConfig->ivas_format = SBA_FORMAT; - hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ - hEncoderConfig->sba_planar = isPlanar; - hEncoderConfig->sba_order = order; - move16(); - move16(); - move16(); - - /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ - hEncoderConfig->nchan_inp = ivas_sba_get_nchan_fx( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ - move16(); - - - hEncoderConfig->Opt_PCA_ON = (Word16) Opt_PCA_ON; - move16(); - - hIvasEnc->maxBandwidthUser = max_bwidth_user; - - error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); - - - return error; -} -#endif /*---------------------------------------------------------------------* * IVAS_ENC_ConfigureForSBAObjects() * @@ -1213,340 +1166,6 @@ static ivas_error configureEncoder( return error; } -#ifndef HARM_ENC_INIT -static ivas_error configureEncoder_fx( - IVAS_ENC_HANDLE hIvasEnc, - const Word32 inputFs, - const Word32 initBitrate, - const IVAS_ENC_BANDWIDTH initBandwidth, - const IVAS_ENC_DTX_CONFIG dtxConfig, - const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ) -{ - Encoder_Struct *st_ivas; - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - Word32 cpe_brate; - - error = IVAS_ERR_OK; - - st_ivas = hIvasEnc->st_ivas; - hEncoderConfig = st_ivas->hEncoderConfig; - - /*-----------------------------------------------------------------* - * Bandwidth limitation - *-----------------------------------------------------------------*/ - - IF( ( error = setBandwidth_fx( hIvasEnc, initBandwidth ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*-----------------------------------------------------------------* - * DTX/CNG - *-----------------------------------------------------------------*/ - - IF( dtxConfig.enabled ) - { - hEncoderConfig->Opt_DTX_ON = 1; - move16(); - - IF( dtxConfig.variable_SID_rate ) - { - hEncoderConfig->var_SID_rate_flag = 1; - hEncoderConfig->interval_SID = 0; - move16(); - move16(); - } - ELSE - { - hEncoderConfig->var_SID_rate_flag = 0; - move16(); - test(); - IF( GE_16( dtxConfig.SID_interval, 3 ) && LE_16( dtxConfig.SID_interval, 100 ) ) - { - hEncoderConfig->interval_SID = dtxConfig.SID_interval; - move16(); - } - ELSE - { - return IVAS_ERR_INVALID_DTX_UPDATE_RATE; - } - } - } - ELSE - { - hEncoderConfig->Opt_DTX_ON = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Bitrate - *-----------------------------------------------------------------*/ - - hEncoderConfig->ivas_total_brate = initBitrate; - move16(); - - /* SC-VBR at 5.90 kbps */ - IF( EQ_32( hEncoderConfig->ivas_total_brate, ACELP_5k90 ) ) - { - hEncoderConfig->ivas_total_brate = ACELP_7k20; - hEncoderConfig->Opt_SC_VBR = 1; - hEncoderConfig->last_Opt_SC_VBR = hEncoderConfig->Opt_SC_VBR; - move32(); - move16(); - move16(); - - IF( ( hEncoderConfig->max_bwidth != NB ) ) - { - hEncoderConfig->max_bwidth = WB; - move16(); - } - } - - /* check if the entered bitrate is supported */ - test(); - IF( NE_16( hEncoderConfig->ivas_format, UNDEFINED_FORMAT ) && NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) /* IVAS */ - { - IF( !is_IVAS_bitrate_fx( hEncoderConfig->ivas_total_brate ) ) - { - IF( hEncoderConfig->Opt_SC_VBR ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", ACELP_5k90 ); - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", hEncoderConfig->ivas_total_brate ); - } - } - - IF( EQ_16( hEncoderConfig->ivas_format, STEREO_FORMAT ) ) - { - { - hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - IF( GE_32( hEncoderConfig->ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - } - - test(); - test(); - IF( ( EQ_16( hEncoderConfig->element_mode_init, IVAS_CPE_TD ) || EQ_32( hEncoderConfig->element_mode_init, IVAS_CPE_DFT ) ) && GT_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for TD/DFT Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - - test(); - IF( EQ_16( hEncoderConfig->element_mode_init, IVAS_CPE_MDCT ) && LT_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for MDCT Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - - test(); - IF( LT_32( hEncoderConfig->ivas_total_brate, IVAS_256k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, ISM_FORMAT ) ) - { - IF( ( error = sanitizeBitrateISM_fx( hEncoderConfig, hIvasEnc->extMetadataApi ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) ) - { - /* nothing */ - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, MASA_FORMAT ) ) - { - /* adapt element_mode according to the bitrate */ - test(); - IF( EQ_16( hEncoderConfig->nchan_inp, 2 ) && NE_16( hEncoderConfig->element_mode_init, IVAS_SCE ) ) - { - IF( GE_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - ELSE IF( LT_32( hEncoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - } - } - } - ELSE IF( EQ_32( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); - - cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); - - /*adapt element_mode according to the bit-rate*/ - IF( NE_16( hEncoderConfig->element_mode_init, IVAS_SCE ) ) - { - IF( GE_32( cpe_brate, IVAS_48k ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ISM_MODE_NONE; - } - } - ELSE /* EVS mono */ - { - hEncoderConfig->ivas_format = MONO_FORMAT; - hEncoderConfig->element_mode_init = EVS_MONO; - move16(); - - IF( !is_EVS_bitrate( hEncoderConfig->ivas_total_brate, &hEncoderConfig->Opt_AMR_WB ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in EVS mono: %d", hEncoderConfig->ivas_total_brate ); - } - - IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) - { - hEncoderConfig->nchan_inp = 2; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Input sampling frequency - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( NE_32( inputFs, 8000 ) && NE_32( inputFs, 16000 ) && NE_32( inputFs, 32000 ) && NE_32( inputFs, 48000 ) ) - { - return IVAS_ERR_INVALID_SAMPLING_RATE; - } - - hEncoderConfig->input_Fs = inputFs; - move32(); - - /*-----------------------------------------------------------------* - * Channel-aware mode - *-----------------------------------------------------------------*/ - - IF( ( error = setChannelAwareConfig_fx( hIvasEnc, caConfig ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*-----------------------------------------------------------------* - * Set codec mode - *-----------------------------------------------------------------*/ - - st_ivas->codec_mode = MODE1; /* Note: in IVAS, set MODE1 */ - move16(); - - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) - { - IF( hEncoderConfig->Opt_AMR_WB ) - { - st_ivas->codec_mode = MODE1; - move16(); - } - ELSE - { - st_ivas->codec_mode = get_codec_mode( hEncoderConfig->ivas_total_brate ); - move16(); - } - } - - test(); - IF( EQ_32( hEncoderConfig->ivas_total_brate, IVAS_13k2 ) && EQ_16( hEncoderConfig->Opt_RF_ON, 1 ) ) - { - st_ivas->codec_mode = MODE2; - move16(); - } - - st_ivas->last_codec_mode = st_ivas->codec_mode; - move16(); - - /*-----------------------------------------------------------------* - * Sanity checks - *-----------------------------------------------------------------*/ - - assert( hEncoderConfig->ivas_format != UNDEFINED_FORMAT && "\n IVAS format undefined" ); - - test(); - test(); - IF( ( NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) || hEncoderConfig->stereo_dmx_evs ) && EQ_32( hEncoderConfig->input_Fs, 8000 ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz input sampling rate is not supported in IVAS." ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( hEncoderConfig->Opt_DTX_ON && NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && - ( ( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) && GT_32( ivas_get_sba_num_TCs_fx( hEncoderConfig->ivas_total_brate, 1 ), 2 ) ) || - EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) || EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) || EQ_16( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) ) ) - { - return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); - } - - test(); - test(); - test(); - IF( hEncoderConfig->Opt_PCA_ON && !( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) && EQ_32( hEncoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( hEncoderConfig->sba_order, SBA_FOA_ORDER ) ) ) - { - return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); - } - - IF( ( error = sanitizeBandwidth_fx( hIvasEnc ) ) != IVAS_ERR_OK ) - { - return error; - } - - test(); - test(); - test(); - IF( hEncoderConfig->is_binaural && !( ( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && hEncoderConfig->stereo_dmx_evs ) || EQ_16( hEncoderConfig->ivas_format, STEREO_FORMAT ) ) ) - { - return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "'-binaural' option is supported only with '-stereo' or '-stereo_dmx_evs'" ); - } - - /*-----------------------------------------------------------------* - * Finalize initialization - *-----------------------------------------------------------------*/ - - IF( ( error = ivas_init_encoder_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) - { - hIvasEnc->hCoreCoder = st_ivas->hSCE[0]->hCoreCoder[0]; /* Note: this is needed for switching in EVS mono */ - } - ELSE - { - hIvasEnc->hCoreCoder = NULL; - } - - hIvasEnc->Opt_RF_ON_loc = hEncoderConfig->Opt_RF_ON; - hIvasEnc->rf_fec_offset_loc = hEncoderConfig->rf_fec_offset; - move16(); - move16(); - - hIvasEnc->isConfigured = true; - - return error; -} -#endif /*---------------------------------------------------------------------* * IVAS_ENC_GetDelay() * @@ -1660,10 +1279,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() Q0*/ UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME Q0*/ UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value Q0*/ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Encoder_Struct *st_ivas; @@ -1787,7 +1402,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( st_ivas->ind_list[i].nb_bits = -1; move16(); } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) { memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) ); @@ -1826,7 +1441,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /* set pointers to the new buffers of indices in each element */ FOR( n = 0; n < st_ivas->nSCE; n++ ) { -#ifdef HARM_PUSH_BIT st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ind_list = st_ivas->ind_list; st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; @@ -1835,23 +1449,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; } -#else - test(); - IF( !( hIvasEnc->hCoreCoder == NULL && EQ_32( hEncoderConfig->ivas_format, MONO_FORMAT ) ) ) - { - if ( ( hEncoderConfig->element_mode_init != EVS_MONO ) ) - { - st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ind_list = st_ivas->ind_list; - } - st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - } - - IF( st_ivas->hSCE[n]->hMetaData != NULL ) - { - st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; - st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; - } -#endif } FOR( n = 0; n < st_ivas->nCPE; n++ ) @@ -1908,42 +1505,21 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } } ELSE /* IVAS */ - { - IF( NE_32( ( error = ivas_enc_fx( st_ivas, inputBuffer, inputBufferSize ) ), IVAS_ERR_OK ) ) { - return error; - } - } + IF( NE_32( ( error = ivas_enc_fx( st_ivas, inputBuffer, inputBufferSize ) ), IVAS_ERR_OK ) ){ + return error; +} +} - /* write indices into bitstream buffer */ -#ifndef HARM_PUSH_BIT - IF( hEncoderConfig->element_mode_init == EVS_MONO ) - { - test(); - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && ( hCoreCoder->element_mode == EVS_MONO ) ) - { - /* write indices into bitstream file */ - UWord8 pFrame[( MAX_BITS_PER_FRAME + 7 ) >> 3]; - Word16 pFrame_size = 0; - move16(); - write_indices_buf_fx( hCoreCoder, hCoreCoder->hBstr, outputBitStream, pFrame, pFrame_size, numOutBits ); - } - } - ELSE -#endif - { - write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); - } - /* Reset switching flag before next call - can be set to "true" by some setters */ - hIvasEnc->switchingActive = false; - move16(); +/* write indices into bitstream buffer */ +{ + write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits ); +} +/* Reset switching flag before next call - can be set to "true" by some setters */ +hIvasEnc->switchingActive = false; +move16(); - return error; +return error; } diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index cf855bd19d507e4b7f10c661aad3743dc8055757..6056c0c4690b7ad2c518aed8c761b5db0cce0ff5 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -468,6 +468,33 @@ static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 * } +static Word64 depack_mul_values_fx64( Word32 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) +{ + Word16 i, val0, val1, val2, val3; + Word64 en; + + en = 0; + move32(); + FOR( i = 0; i < N; i += 4 ) + { + depack_4_values( cbp + i_mult( shr( i, 2 ), 3 ), val0, val1, val2, val3 ) + Tmp[i + 0] = L_mult0( w[i + 0], val0 ); // Q8 * Q2.56 + move16(); + en = W_mac_32_16( en, Tmp[i + 0], val0 ); // Q8 * Q2.56 * 2.56 * Q1 + Tmp[i + 1] = L_mult0( w[i + 1], val1 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 1], val1 ); + Tmp[i + 2] = L_mult0( w[i + 2], val2 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 2], val2 ); + Tmp[i + 3] = L_mult0( w[i + 3], val3 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 3], val3 ); + } + + return en; // Q8 * Q2.56 * 2.56 * Q1 +} + /*--------------------------------------------------------------------------* * msvq_enc_find_p_max_8() * @@ -522,6 +549,54 @@ static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] ) } +static Word16 msvq_enc_find_p_max_8_fx64( Word64 dist[] ) +{ + Word16 p_max; + + p_max = 0; + move16(); + + BASOP_SATURATE_WARNING_OFF_EVS + if ( GT_64( dist[1], dist[p_max] ) ) + { + p_max = 1; + move16(); + } + if ( GT_64( dist[2], dist[p_max] ) ) + { + p_max = 2; + move16(); + } + if ( GT_64( dist[3], dist[p_max] ) ) + { + p_max = 3; + move16(); + } + if ( GT_64( dist[4], dist[p_max] ) ) + { + p_max = 4; + move16(); + } + if ( GT_64( dist[5], dist[p_max] ) ) + { + p_max = 5; + move16(); + } + if ( GT_64( dist[6], dist[p_max] ) ) + { + p_max = 6; + move16(); + } + if ( GT_64( dist[7], dist[p_max] ) ) + { + p_max = 7; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + return p_max; +} + + /*--------------------------------------------------------------------------* * msvq_enc_find_p_max_6() * @@ -565,6 +640,43 @@ static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] ) return p_max; } +static Word16 msvq_enc_find_p_max_6_fx64( Word64 dist[] ) +{ + Word16 p_max; + + p_max = 0; + move16(); + + BASOP_SATURATE_WARNING_OFF_EVS + if ( GT_64( dist[1], dist[p_max] ) ) + { + p_max = 1; + move16(); + } + if ( GT_64( dist[2], dist[p_max] ) ) + { + p_max = 2; + move16(); + } + if ( GT_64( dist[3], dist[p_max] ) ) + { + p_max = 3; + move16(); + } + if ( GT_64( dist[4], dist[p_max] ) ) + { + p_max = 4; + move16(); + } + if ( GT_64( dist[5], dist[p_max] ) ) + { + p_max = 5; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + return p_max; +} + /*--------------------------------------------------------------------------* * msvq_enc_fx() @@ -787,7 +899,222 @@ void msvq_enc_fx( return; } +void msvq_enc_lsf_fx64( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (10Q5 * 1.28) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 u[], /* i : Vector to be encoded (prediction and mean removed)(Q14Q1*1.28) */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from */ + /* one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8*/ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + Word16 Idx[] /* o : Indices */ +) +{ + Word16 j; + const Word16 *cbp; + Word16 p2i; + Word16 resid_buf[2 * LSFMBEST_MAX * M_MAX], *resid[2]; + Word16 *pTmp, *p1; + Word16 *indices[2], m, s, c, c2, p_max, i; + Word32 Tmp32[M_MAX]; + Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX]; + Word64 *dist_64[2], en64, tmp64; + Word64 dist_buf_64[2 * LSFMBEST_MAX]; + Word16 ( *func_ptr64 )( Word64 * ); + Word16 N34; + Word16 n, maxn, start; + + /*----------------------------------------------------------------* + * Allocate memory for previous (parent) and current nodes. + * Parent node is indexed [0], current node is indexed [1]. + *----------------------------------------------------------------*/ + indices[0] = idx_buf; + indices[1] = idx_buf + maxC * stages; /*move16();*/ + /*vr_iset(0, idx_buf, 2*stages*maxC);*/ + set16_fx( idx_buf, 0, (Word16) ( 2 * stages * maxC ) ); + + resid[0] = resid_buf; + resid[1] = resid_buf + maxC * N; /*move16();*/ + + dist_64[0] = dist_buf_64; + dist_64[1] = dist_buf_64 + maxC; /*move16();*/ + + /*vr_iset(0, parents, maxC);*/ + set16_fx( parents, 0, maxC ); + + + func_ptr64 = msvq_enc_find_p_max_6_fx64; + move16(); + if ( EQ_16( maxC, 8 ) ) + { + func_ptr64 = msvq_enc_find_p_max_8_fx64; + move16(); + } + + /*----------------------------------------------------------------* + * LSF weights are normalized, so it is always better to multiply it first + * Set up inital distance vector + *----------------------------------------------------------------*/ + /* Q0/16 * Qw_norm/16 << 1 >> 16 => Qwnorm-15/16 * Q0/16 << 1 => Qwnorm-14/32 * 6.5536 */ + Word64 ss2_64; + ss2_64 = W_mult_32_16( L_mult0( u[0], w[0] ), u[0] ); + // Q8 * Q2.56 * 2.56 * Q1 + FOR( j = 1; j < N; j++ ) + { + ss2_64 = W_mac_32_16( ss2_64, L_mult0( u[j], w[j] ), u[j] ); + } + + /* Set up inital error (residual) vectors */ + pTmp = resid[1]; /*move16();*/ + FOR( c = 0; c < maxC; c++ ) + { + Copy( u, pTmp + c * N, N ); + dist_64[1][c] = ss2_64; + move64(); + } + + /* Loop over all stages */ + m = 1; + move16(); + FOR( s = 0; s < stages; s++ ) + { + /* codebook pointer is set to point to first stage */ + cbp = cb[s]; /*3Q12*1.28*/ + move16(); + + /* Set up pointers to parent and current nodes */ + swap( indices[0], indices[1], Word16 * ); + move16(); + move16(); + move16(); + move16(); + swap( resid[0], resid[1], Word16 * ); + move16(); + move16(); + move16(); + swap( dist_64[0], dist_64[1], Word64 * ); + move64(); + move64(); + move64(); + + /* p_max points to maximum distortion node (worst of best) */ + p_max = 0; + move16(); + + n = N; + move16(); + maxn = maxN; + move16(); + if ( dims ) + { + n = dims[s]; + move16(); + } + if ( dims ) + { + maxn = n; + move16(); + } + + assert( ( maxn % 4 ) == 0 ); + N34 = mult( maxn, 24576 /*0.75f Q15*/ ); + start = 0; + move16(); + if ( offs ) + { + start = offs[s]; + move16(); + } + + set32_fx( Tmp32, 0, start ); + set32_fx( Tmp32 + start + n, 0, sub( N, add( start, n ) ) ); + + /* Set distortions to a large value */ + FOR( j = 0; j < maxC; j++ ) + { + dist_64[1][j] = LLONG_MAX; + move64(); + } + + FOR( j = 0; j < levels[s]; j++ ) + { + /* Compute weighted codebook element and its energy */ + en64 = depack_mul_values_fx64( Tmp32 + start, w + start, cbp, n ); // Q8 + // en64: Q8 * Q2.56 * Q2.56 * q1 + // Tmp: 2.56 * Q8 + + cbp += N34; /* pointer is incremented */ + + /* Iterate over all parent nodes */ + FOR( c = 0; c < m; c++ ) + { + pTmp = &resid[0][c * N]; // this resid buffer is initial lsf values + /*tmp = (*pTmp++) * Tmp[0];*/ + Word64 t164 = 0; + move64(); + t164 = W_mult_32_16( Tmp32[0], pTmp[0] ); // 2.56 * Q8 * Q2.56 * Q1 + // Tmp32: Q8 * Q2.56 + FOR( i = 1; i < N; i++ ) + { + t164 = W_mac_32_16( t164, Tmp32[i], pTmp[i] ); // 2.56 * Q8 * Q2.56 * Q1 + } + + tmp64 = W_add( dist_64[0][c], W_sub( en64, W_shl( t164, 1 ) ) ); + t164 = W_sub( tmp64, dist_64[1][p_max] ); + IF( t164 <= 0 ) + { + /* Replace worst */ + dist_64[1][p_max] = tmp64; + move64(); + indices[1][p_max * stages + s] = j; + move16(); + parents[p_max] = c; + move16(); + + p_max = ( *func_ptr64 )( dist_64[1] ); + + } /*IF (L_sub(tmp,dist[1][p_max]) < 0) */ + } /* FOR (c=0; cbckr_fx[i] != 0 ) { - Ltmp1 = L_add( hNoiseEst->bckr_fx[i], L_shl( 1, hNoiseEst->q_bckr ) ); // hNoiseEst->q_bckr + diff = 1; + move16(); + IF( GT_16( hNoiseEst->q_bckr, 30 ) ) + { + diff = add( diff, sub( hNoiseEst->q_bckr, 30 ) ); + } + Ltmp1 = L_add( L_shr( hNoiseEst->bckr_fx[i], diff ), L_shl( 1, sub( hNoiseEst->q_bckr, diff ) ) ); // hNoiseEst->q_bckr - diff e_ener = norm_l( Ltmp1 ); f_ener = Log2_norm_lc( L_shl( Ltmp1, e_ener ) ); - e_ener = sub( sub( 30, e_ener ), hNoiseEst->q_bckr ); + e_ener = sub( sub( 30, e_ener ), sub( hNoiseEst->q_bckr, diff ) ); Ltmp1 = L_mac( f_ener, e_ener, ONE_IN_Q14 ); // Q15 Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ @@ -3499,6 +3506,8 @@ void noise_est_ivas_fx( hNoiseEst->bckr_fx[i] = tmpN[i]; move32(); } + hNoiseEst->q_bckr = q_tmpN; + move16(); } /* else if ( ( ( st->act_pred < 0.80f ) && ( aE_bgd || PAU ) && st->lt_haco_ev < 0.10f ) || ( ( st->act_pred < 0.70f ) && ( aE_bgd || non_staB < 17.0f ) && PAU && st->lt_haco_ev < 0.15f ) @@ -3536,14 +3545,34 @@ void noise_est_ivas_fx( hNoiseEst->first_noise_updt = 1; move16(); - FOR( i = 0; i < NB_BANDS; i++ ) + IF( LT_16( q_tmpN, hNoiseEst->q_bckr ) ) { - /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ - /* 32 bit state update */ - Ltmp = L_sub( tmpN[i], hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr - Ltmp = Mult_32_16( Ltmp, updt_step ); - hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr - move32(); + diff = sub( hNoiseEst->q_bckr, q_tmpN ); + FOR( i = 0; i < NB_BANDS; i++ ) + { + /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ + /* 32 bit state update */ + Ltmp1 = L_shr( hNoiseEst->bckr_fx[i], diff ); + Ltmp = L_sub( tmpN[i], Ltmp1 ); // q_tmpN + Ltmp = Mult_32_16( Ltmp, updt_step ); + hNoiseEst->bckr_fx[i] = L_add( Ltmp, Ltmp1 ); // q_tmpN + move32(); + } + hNoiseEst->q_bckr = q_tmpN; + move16(); + } + ELSE + { + diff = sub( q_tmpN, hNoiseEst->q_bckr ); + FOR( i = 0; i < NB_BANDS; i++ ) + { + /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ + /* 32 bit state update */ + Ltmp = L_sub( L_shr( tmpN[i], diff ), hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr + Ltmp = Mult_32_16( Ltmp, updt_step ); + hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr + move32(); + } } } /*else if (aE_bgd || st->harm_cor_cnt > 100 )*/ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 7ca13171ea309caea5710891b929962bcc6914b9..cbeea8f1dd818e825eb8d075f0d61df51ddd9215 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -36,7 +36,8 @@ void pitch_ol2_fx( const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ) { Word16 i, t, step, fraction, t0_min, t0_max, t_min, t_max; @@ -158,7 +159,14 @@ void pitch_ol2_fx( IF( NE_32( t1, 1L ) ) { - pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + IF( element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, L_pitch_inter4_1, 4, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + } R0 = cor_max_fx; move16(); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index fdadcd318be997001ac0ec11996edee7c1423496..79c55821e723e62585ce2df46f29b494b6ddfef0 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -2425,8 +2425,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[0],voicing_fr[1]))>0 */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[0], 8192 ), voicing_fr[1], 8192 ) > 0 ) { @@ -2448,8 +2448,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[2],voicing_fr[3]))>0) */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[2], 8192 ), voicing_fr[3], 8192 ) > 0 ) { diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index f7ebc8298cbff4ec232d23900b37bf55e03dea18..dc3ec020ab1959c1ecaefabc9bea1dcbbb366f43 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -458,10 +458,10 @@ void pre_proc_fx( IF( LE_32( st->total_brate, ACELP_24k40 ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7, EVS_MONO ); } ELSE { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6ef6991d4766c17619aabb1fbe5379867d015874..48af49619a2c184c9cda2c6239c3a7ac3824694b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -385,7 +385,8 @@ void noise_est_fx( void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ - const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */ + const Word32 tmpN[], /* i : temporary noise update q_tmpN */ + const Word16 q_tmpN, /* i : Q-factor of tmpN buffer */ const Word32 epsP[], /* i : msb prediction error energies Qx */ const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */ const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */ @@ -437,13 +438,14 @@ void pitch_ol2_fx( const Word16 pit_min, /* i : minimum pitch value (20 or 29) */ const Word16 pitch_ol, /* i : pitch to be improved */ Word16 *pitch_fr_fx, - /* o : adjusted 1/4 fractional pitch */ /*Q7 */ + /* o : adjusted 1/4 fractional pitch */ /*Q7*/ Word16 *voicing_fr_fx, - /* o : adjusted 1/4 fractional voicing */ /*Q15 */ + /* o : adjusted 1/4 fractional voicing */ /*Q15*/ const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ); void pitch_ol_ivas_fx( @@ -3130,6 +3132,22 @@ void msvq_enc_fx( const Word16 maxN, /* i : Codebook dimension */ Word16 Idx[] /* o : Indices */ ); + +void msvq_enc_lsf_fx64( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (Q10Q5*1.28 ) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 u[], /* i : Vector to be encoded (prediction and mean removed)(14Q1*1.28) */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from */ + /* one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8*/ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + Word16 Idx[] /* o : Indices */ +); + void midlsf_enc_fx( const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */ const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */ @@ -4822,9 +4840,5 @@ ivas_error write_indices_ivas_fx( Encoder_Struct *st_ivas, /* i/o: encoder state structure */ UWord16 *bit_stream, /* i/o: output bitstream */ UWord16 *num_bits /* i : number of indices written to output */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); #endif diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c index d519bc12f9db4e464b977c66e13b329713fb216e..9880084e13ce683d02d5516372bd6deeef7684b0 100644 --- a/lib_enc/rst_enc_fx.c +++ b/lib_enc/rst_enc_fx.c @@ -53,11 +53,19 @@ void CNG_reset_enc_fx( /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( pitch_buf, L_SUBFR << 6, NB_SUBFR ); +#else set16_fx( pitch_buf, L_SUBFR, NB_SUBFR ); +#endif } ELSE /* st->L_frame == L_FRAME16k */ { +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( pitch_buf, L_SUBFR16k << 6, NB_SUBFR16k ); +#else set16_fx( pitch_buf, L_SUBFR16k, NB_SUBFR16k ); +#endif } set16_fx( voice_factors, 1, NB_SUBFR16k ); diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index d4dd73abe8ea2be7536ea15ce15c6270737b279f..364d78f97d57c3cf7a6243b1243a59e44c6a7797 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -201,7 +201,11 @@ void set_impulse_fx( den = extract_h( L_shl( rr_fx[i], exp_den ) ); num = div_s( num, den ); +#ifdef ISSUE_1772_replace_shr_o + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ +#else krit_fx = shr_o( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ +#endif IF( GT_16( krit_fx, krit_max_fx ) ) { diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index fd983741b51cf4319722c01fbbcee140e09a95c5..59f3b35f6da8972a9c05df7cdef5895dee91accc 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2181,11 +2181,7 @@ Word16 ivas_smc_gmm_fx( } /* PCA */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ v_mult_mat_fixed( FV_fx, FV_fx, pca_components_fx, N_SMC_FEATURES, N_PCA_COEF, 0 ); /*------------------------------------------------------------------* * Calculation of posterior probability diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0647b6ebc901636f40ee389cf751a4dccc5d8c02..3839e3ec533848580e954a8e03fcfc1c79ea4dee 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -54,7 +54,7 @@ typedef struct Word16 id; /* id of the indice */ UWord16 value; /* value of the quantized indice */ Word16 nb_bits; /* number of bits used for the quantization of the indice */ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) char function_name[100]; #endif } Indice, *INDICE_HANDLE; @@ -95,10 +95,6 @@ typedef struct bitstream_enc_data_structure void *st_ivas; /* IVAS encoder structure */ // Word16 nb_bits_tot_fx; /* total number of bits already written */ // Indice *ind_list_fx; /* list of indices */ -#ifndef HARM_PUSH_BIT - Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ - Word16 last_ind_fx; /* last written indice */ -#endif } BSTR_ENC_DATA, *BSTR_ENC_HANDLE; /*----------------------------------------------------------------------------------* diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 24932542ce178bea11bb597e42f06d43d7575017..8dfb407383675c291905f6b0d04841b2f294b1d4 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -67,10 +67,14 @@ void stat_noise_uv_enc_fx( expn = sub( norm_l( LepsP[0] ), 1 ); num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ expd = norm_l( LepsP[1] ); - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ +#ifdef ISSUE_1772_replace_shr_o + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ +#else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ +#endif + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -140,10 +144,14 @@ void stat_noise_uv_enc_ivas_fx( expn = sub( norm_l( LepsP[0] ), 1 ); num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ expd = norm_l( LepsP[1] ); - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ +#ifdef ISSUE_1772_replace_shr_o + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ +#else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ - num = sub( num, 1024 ); /*num - 1*/ +#endif + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 0e89e16c17a0d96f74bd352d092809a4086d4a7d..85277e29845940428c92939b2cf585968f32a831 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1275,11 +1275,7 @@ void swb_pre_proc_ivas_fx( thr = icbwe_thr_TDM_fx; regV = icbwe_regressionValuesTDM_fx; -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, st->cldfbSynTd ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); *Q_shb_spch = 0; move16(); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index b001f86936e2b65ac3582c22c0d37839c1f9b790..e1bbd3e19207c57baccfd7570c1cb54340112e0f 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -2535,6 +2535,38 @@ void swb_tbe_enc_fx( exp = 0; move16(); } +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } +#else FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ @@ -2545,6 +2577,7 @@ void swb_tbe_enc_fx( shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } +#endif /* Update SHB excitation */ Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ @@ -3062,7 +3095,7 @@ void swb_tbe_enc_ivas_fx( { FOR( i = 1; i <= LPC_SHB_ORDER; i++ ) { - L_tmp = Mpy_32( R_h[i], R_l[i], wac_swb_h[i - 1], wac_swb_l[i - 1] ); + L_tmp = Mpy_32( R_h[i], R_l[i], wac_swb_ivas_h[i - 1], wac_swb_ivas_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } } @@ -3091,7 +3124,7 @@ void swb_tbe_enc_ivas_fx( } /* this is needed as the E_LPC_lev_dur function outputs lpc in Q14 */ - Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); + scale_sig( lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Expand bandwidth of the LP coeffs */ test(); @@ -3107,6 +3140,14 @@ void swb_tbe_enc_ivas_fx( /* stab_check = a2lsp( lsf_shb, lpc_shb, LPC_SHB_ORDER ); */ + /* LPC to LSP conversion */ + /* LPC: Q12, LSP: Q15 */ + E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); + + /* LSP to LSF conversion */ + /* LSP: Q15, LSF: Q15 */ + E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); + test(); test(); IF( ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || st_fx->ini_frame == 0 ) @@ -3124,14 +3165,6 @@ void swb_tbe_enc_ivas_fx( // mvr2r( hBWE_TD->prev_lsp_shb, lsf_shb, LPC_SHB_ORDER ); // } - /* LPC to LSP conversion */ - /* LPC: Q12, LSP: Q15 */ - E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); - - /* LSP to LSF conversion */ - /* LSP: Q15, LSF: Q15 */ - E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); - Copy( lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); Copy( lsf_shb_fx, lsf_shb_orig_fx, LPC_SHB_ORDER ); @@ -3831,6 +3864,38 @@ void swb_tbe_enc_ivas_fx( exp = 0; move16(); } +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } +#else FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ @@ -3841,6 +3906,7 @@ void swb_tbe_enc_ivas_fx( shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } +#endif } ELSE { @@ -5697,11 +5763,7 @@ static void Quant_shb_res_gshape_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { -#ifdef FIX_1486_IND_SHB_RES push_indice( st_fx->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#else - push_indice( st_fx->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#endif } } } @@ -5737,11 +5799,7 @@ static void Quant_shb_res_gshape_ivas_fx( } ELSE { -#ifdef FIX_1486_IND_SHB_RES push_indice( st->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#else - push_indice( st->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#endif } } } @@ -7321,12 +7379,8 @@ void fb_tbe_enc_fx( Word16 ratio; Word16 tmp_vec[L_FRAME48k]; Word16 idxGain; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 input_fhb_buffer[L_FRAME48k + 4]; Word16 *input_fhb = &input_fhb_buffer[0] + 4; -#else - Word16 input_fhb[L_FRAME48k]; -#endif Word16 Sample_Delay_HP; Word32 fb_exc_energy, temp2; Word32 L_tmp; @@ -7352,16 +7406,10 @@ void fb_tbe_enc_fx( Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) @@ -7459,12 +7507,8 @@ void fb_tbe_enc_ivas_fx( Word16 ratio; Word16 tmp_vec[L_FRAME48k]; Word16 idxGain; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 input_fhb_new_buffer[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) + 4]; Word16 *input_fhb_new = &input_fhb_new_buffer[0] + 4; -#else - Word16 input_fhb_new[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )]; -#endif Word16 input_fhb[L_FRAME48k]; Word16 Sample_Delay_HP; Word64 fb_exc_energy; @@ -7491,29 +7535,17 @@ void fb_tbe_enc_ivas_fx( exp_temp = add( exp_temp, Q_new_input ); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif } ELSE { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif } test(); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index e1b067ac350c4f9416a95f58ee852fbdd110715f..cd4c0729710d1cfbe6e20dc56291699d9f15bbbf 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1053,6 +1053,10 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain Word32 tmp = 0, tmpp = 0; move32(); move32(); +#ifdef OPT_MCT_ENC_V3_NBE + Word64 ener64_fx; + Word16 tmp_exp; +#endif /* tmp = 0.5f * (float) log10( (float) lg / (float) NORM_MDCT_FACTOR ) + + 0.94f; lowest gain + expected value of the quantization noise energy per quadruple (log10(4/12)) in Q16*/ /* tmpp = 0.5f * (float) log10( (float) lg / (float) NORM_MDCT_FACTOR ) * log2(10) in Q16 */ @@ -1166,9 +1170,21 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain lg_4 = shr( lg, 2 ); +#ifdef OPT_MCT_ENC_V3_NBE + tmp_exp = shl( x_e, 1 ); +#endif /* SNR of quadruples for unit step quantizer and lowest possible gain */ FOR( i = 0; i < lg_4; i++ ) { +#ifdef OPT_MCT_ENC_V3_NBE + ener64_fx = W_mac_32_32( 1, x[0], x[0] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[1], x[1] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[2], x[2] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[3], x[3] ); // exp:2*x_e + s = W_norm( ener64_fx ); + ener = W_extract_h( W_shl( ener64_fx, s ) ); + s = sub( tmp_exp, s ); +#else /* normalization */ s = 15; move16(); @@ -1215,7 +1231,7 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain ener = L_mac( ener, tmp16, tmp16 ); s = shl( sub( x_e, s ), 1 ); - +#endif /* log */ tmp32 = L_add_sat( BASOP_Util_Log2( ener ), L_shl_sat( L_deposit_l( s ), 25 ) ); /* log2, 6Q25 */ en[i] = L_add_sat( L_shr( tmp32, 9 ), tmp ); /* 15Q16 */ @@ -1241,8 +1257,13 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain { tmp32 = L_sub( en[i], offset ); +#ifdef OPT_MCT_ENC_V3_NBE + /* avoid SV with 1 bin of amp < 0.5f */ + if ( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ +#else /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ +#endif { ener = L_add( ener, tmp32 ); } @@ -1355,23 +1376,37 @@ void tcx_scalar_quantization_ivas_fx( { Word16 i, tmp16, s; Word32 tmp32, offs32; +#ifdef OPT_MCT_ENC_V2_NBE + Word32 offs32_1; + Word32 offset_Q16 = L_shl( offset, 1 ); // Q16 +#endif /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); +#ifdef OPT_MCT_ENC_V2_NBE + tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e +#else tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); tmp16 = negate( s_max( tmp16, 0 ) ); +#endif i = sub( L_frame, 1 ); IF( memQuantZeros_fx != NULL ) { test(); +#ifdef OPT_MCT_ENC_V2_NBE + FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) +#else WHILE( ( memQuantZeros_fx[i] != 0 ) && ( LT_32( L_abs( L_shl( x[i], tmp16 ) ), tmp32 ) ) ) +#endif { test(); xq[i] = 0; move16(); +#ifndef OPT_MCT_ENC_V2_NBE i = sub( i, 1 ); +#endif } } @@ -1392,25 +1427,50 @@ void tcx_scalar_quantization_ivas_fx( s = sub( add( x_e, gain_e ), 15 ); } - /* substract 0x8000 to affect the mac_r in the following loop - so it acts like extract_h. the 0x4000 will be multiplied by 2 - by the mac_r to get to 0x8000 and disable the round. */ - offset = sub( offset, 0x4000 ); - FOR( ; i >= 0; i-- ) { - offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ +#ifdef OPT_MCT_ENC_V2_NBE + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); IF( x[i] < 0 ) { - tmp16 = negate( tmp16 ); /* restore sign */ + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) + { + tmp16 = add( tmp16, 1 ); + } } - +#else + offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */ + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + IF( x[i] > 0 ) + { + offs32 = L_add_sat( offs32, L_shl( offset, 1 ) ); + tmp16 = extract_h( offs32 ); + IF( GT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = sub( tmp16, 1 ); + } + } + ELSE + { + offs32 = L_add_sat( offs32, L_shl( negate( offset ), 1 ) ); + tmp16 = extract_h( offs32 ); + IF( LT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = add( tmp16, 1 ); + } + } +#endif xq[i] = tmp16; move16(); } + IF( alfe_flag == 0 ) { AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, @@ -2665,15 +2725,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2681,15 +2741,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -2717,7 +2777,7 @@ void tcx_noise_factor_ivas_fx( } ELSE /* current line is zero, so update pointers & segment sum */ { - IF( LT_16( win, nTransWidth ) ) + if ( LT_16( win, nTransWidth ) ) { win = add( win, 1 ); } @@ -2734,15 +2794,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2750,15 +2810,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -3603,7 +3663,10 @@ Word16 tcx_res_Q_spec_ivas_fx( Word16 s, s2, lf_deemph_factor; Word16 c; Word32 thres; - +#ifdef OPT_MCT_ENC_V3_BE + Word16 cmp_1, cmp_2; + Word32 tmp32_1, tmp32_2; +#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3619,16 +3682,28 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); s2 = sub( x_Q_e, 1 ); +#ifdef OPT_MCT_ENC_V3_BE + cmp_1 = sub( sqTargetBits, kMaxEstimatorUndershoot ); + cmp_2 = s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ); +#endif FOR( i = 0; i < L_frame; i++ ) { +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_1 ) ) +#else IF( GE_16( bits, sub( sqTargetBits, kMaxEstimatorUndershoot ) ) ) +#endif { fac_m = 0; move16(); fac_p = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_2 ) ) +#else IF( GE_16( bits, s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ) ) ) +#endif { BREAK; } @@ -3640,11 +3715,11 @@ Word16 tcx_res_Q_spec_ivas_fx( { tmp1 = L_add( x_orig[i], 0 ); tmp2 = Mpy_32_16_1( x_Q[i], sqGain ); - IF( s > 0 ) + if ( s > 0 ) { tmp2 = L_shr( tmp2, s ); } - IF( s < 0 ) + if ( s < 0 ) { tmp1 = L_shl( tmp1, s ); } @@ -3661,11 +3736,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } @@ -3678,11 +3753,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } @@ -3695,12 +3770,17 @@ Word16 tcx_res_Q_spec_ivas_fx( /*Quantize zeroed-line of the spectrum*/ c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) ); +#ifdef OPT_MCT_ENC_V3_BE + FOR( i = 0; ( i < L_frame ) && ( bits < ( sqTargetBits - 2 ) ); i++ ) + { +#else FOR( i = 0; i < L_frame; i++ ) { IF( GE_16( bits, sub( sqTargetBits, 2 ) ) ) { BREAK; } +#endif test(); test(); @@ -3717,8 +3797,15 @@ Word16 tcx_res_Q_spec_ivas_fx( tmp1 = Mpy_32_16_1( thres, sqGain ); +#ifdef OPT_MCT_ENC_V3_BE + tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); + tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); + IF( GT_32( tmp32_1, tmp32_2 ) ) + { +#else IF( GT_32( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) ) { +#endif prm[bits] = 1; move16(); bits = add( bits, 1 ); @@ -3730,7 +3817,11 @@ Word16 tcx_res_Q_spec_ivas_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } +#ifdef OPT_MCT_ENC_V3_BE + ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) +#else ELSE IF( L_add( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) < 0 ) +#endif { prm[bits] = 1; move16(); @@ -3778,11 +3869,7 @@ void ProcessIGF_fx( Word16 igfGridIdx; Word16 isIndepFlag; Word16 bsBits; -#ifndef HARM_PUSH_BIT - Word16 bsStart, pBsStart; -#else Word16 pBsStart; -#endif BSTR_ENC_HANDLE hBstr = st->hBstr; IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; @@ -3859,9 +3946,6 @@ void ProcessIGF_fx( } } -#ifndef HARM_PUSH_BIT - bsStart = hBstr->next_ind_fx; -#endif move16(); hInstance->infoTotalBitsPerFrameWritten = 0; move16(); @@ -3869,18 +3953,6 @@ void ProcessIGF_fx( { IGFEncWriteBitstream_fx( hInstance, NULL, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); } -#ifndef HARM_PUSH_BIT - ELSE - { - IGFEncWriteBitstream_fx( hInstance, st->hBstr, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - } - - bsBits = sub( hBstr->next_ind_fx, bsStart ); - IF( !isTCX20 ) - { - IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot, hBstr->ind_list ); - } -#else ELSE { pBsStart = hBstr->nb_ind_tot; @@ -3891,7 +3963,6 @@ void ProcessIGF_fx( bsBits = sub( hBstr->nb_ind_tot, pBsStart ); IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); } -#endif } void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index d0d62769791a9dfe181c3452d45ef076c2b5167c..c1c032e4ec34f3ac0ac303e097d57380f5d636e3 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1214,7 +1214,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1263,7 +1263,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1327,7 +1327,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1352,7 +1352,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1388,7 +1388,7 @@ void transition_enc_ivas_fx( pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1639,7 +1639,7 @@ void transition_enc_ivas_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = L_deposit_l( 0 ); tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ @@ -2081,11 +2081,7 @@ static void tc_enc_ivas_fx( /*--------------------------------------------------------------* * compute glottal-shape codebook excitation *--------------------------------------------------------------*/ -#ifdef TEST_HR Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) ); -#else - Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 ); -#endif /* create filtered glottal codebook contribution */ conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 1cf7a5de8e6cea58d11cf74ec571e168bc005472..8f1fb6985dc38871880b73479201df4fdaf9fcbb 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2369,10 +2369,10 @@ Word16 wb_vad_ivas_fx( } norm_tmp = norm_l( ftmp1 ); - scaled_tmp = L_shl( ftmp1, norm_tmp ); /*13+norm_tmp*/ + scaled_tmp = L_shl( ftmp1, norm_tmp ); /*16+norm_tmp*/ L_msnr = scaled_tmp; move32(); - L_msnr_e = sub( 18, norm_tmp ); + L_msnr_e = sub( 15, norm_tmp ); FOR( j = 1; j < stmp; j++ ) { L_msnr = Mult_32_32( L_msnr, scaled_tmp ); /*L_msnr_e msnr *= ftmp1;*/ diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index b1cf6659bc467cf2cab943c3e3488f8f747f51b8..632e1cdc531e44ef67149c82f693f97d882295aa 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1846,8 +1846,11 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch_idx][slot_idx]; scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); } - +#ifdef OPT_IVAS_FILTER_ROM + scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits +#else scaleFactor = s_min( sub( scaleFactor, 3 ), Q24 ); // guarded bits +#endif FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); @@ -1859,11 +1862,7 @@ static void isar_rend_CldfbSplitPostRendProcessTdIn( Q_cldfb = add( scaleFactor, Q_in ); #endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); Q_out[ch_idx] = sub( Q_cldfb, 1 ); } @@ -1919,7 +1918,11 @@ void isar_rend_CldfbSplitPostRendProcess( scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); } +#ifdef OPT_IVAS_FILTER_ROM + scaleFactor = s_min( sub( scaleFactor, 6 ), Q24 ); // guarded bits +#else scaleFactor = s_min( sub( scaleFactor, 3 ), Q24 ); // guarded bits +#endif FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { Scale_sig32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX, scaleFactor ); @@ -1927,11 +1930,7 @@ void isar_rend_CldfbSplitPostRendProcess( } Q_cldfb = scaleFactor + Q_cldfb_in; Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch_idx][0] ), num_cldfb_bands * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, 0, hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#endif Scale_sig32( hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); Q_out[ch_idx] = sub( Q_cldfb, 1 ); } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index c784ed1a9aa5d47a4b2e4e07872e558ebe706792..c0a199e95a033f1eda6ce38061923baf06859501 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -1504,7 +1504,11 @@ static ivas_error renderSplitBinauralWithPostRot( scaleFactor = s_min( scaleFactor, s_min( getScaleFactor32( RealBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( ImagBuffer_fx[slot_idx], CLDFB_NO_CHANNELS_MAX ) ) ); } +#ifdef OPT_IVAS_FILTER_ROM + scaleFactor = sub( scaleFactor, 6 ); // guarded bits +#else scaleFactor = sub( scaleFactor, 3 ); // guarded bits +#endif FOR( slot_idx = 0; slot_idx < CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; slot_idx++ ) { @@ -1513,7 +1517,6 @@ static ivas_error renderSplitBinauralWithPostRot( } Q_cldfb = scaleFactor + Q_cldfb_final[sf_idx]; Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( sub( Q_cldfb, 1 ), Q11 ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( tmpCrendBuffer_fx[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), @@ -1521,14 +1524,6 @@ static ivas_error renderSplitBinauralWithPostRot( 0, 0, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( RealBuffer_fx, - ImagBuffer_fx, - &( tmpCrendBuffer_fx[ch_idx][sf_idx * outBufNumSamplesPerChannel] ), - hSplitBin->hBinHrSplitPostRend->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, - 0, - hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx] ); // Q_cldfb - 1 -#endif Scale_sig32( hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->cldfb_state_fx, hSplitBin->hBinHrSplitPostRend->cldfbSyn[ch_idx]->p_filter_length, sub( Q11, sub( Q_cldfb, 1 ) ) ); Q_out[sf_idx][ch_idx] = sub( Q_cldfb, 1 ); } diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 13ae12ac60eeb49a38c2b855acda80f49ed532c5..cecea02aedc3eab2de191f9defadf57e96e467a0 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -444,7 +444,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( q_final = s_min( q1, q2 ); q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); +#ifdef OPT_IVAS_FILTER_ROM + q_final = sub( q_final, 6 ); // guard bits +#else q_final = sub( q_final, 3 ); // guard bits +#endif q_final = s_min( q_final, Q25 ); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -474,11 +478,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 -#endif Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; @@ -512,7 +512,11 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( } q_final = s_min( q1, q2 ); q_final = s_min( add( Q_buff_re, q_final ), add( Q_buff_im, q_final ) ); - q_final = sub( q_final, 3 ); // guard bits +#ifdef OPT_IVAS_FILTER_ROM + q_final = sub( q_final, 6 ); // guard bits +#else + q_final = sub( q_final, 3 ); // guard bits +#endif q_final = s_min( q_final, Q25 ); FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) { @@ -531,11 +535,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Q_cldfb = q_final; move16(); Scale_sig32( hSplitBin->hCldfbHandles->cldfbSyn[ch]->cldfb_state_fx, hSplitBin->hCldfbHandles->cldfbSyn[ch]->p_filter_length, sub( sub( Q_cldfb, 1 ), hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * CLDFB_NO_COL_MAX, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 -#endif Q_out[ch] = sub( Q_cldfb, 1 ); move16(); hSplitBin->hCldfbHandles->cldfbSyn[ch]->Q_cldfb_state = Q_out[ch]; diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index df75d6d0a0cb1386eea1389ad2794449d96b99cb..4e00b96232a515e7f08383a3c9451ac7aa2cadf5 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -43,7 +43,7 @@ /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, Word32 data_f[][L_FRAME48k], Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 input_frame ); +static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, Word32 data_f[][L_FRAME48k], Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 input_frame, const Word16 data_q ); static void ivas_dirac_dmx_fx( Word32 data_in_fx[][L_FRAME48k], const Word16 input_frame, const Word16 nchan_transport ); @@ -247,8 +247,8 @@ void ivas_dirac_ana_fx( DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ Word32 data_fx[][L_FRAME48k], /* i/o: Input / transport audio signals, Q7 */ const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport /* i : Number of transport channels */ -) + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 data_q ) { Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; @@ -256,7 +256,7 @@ void ivas_dirac_ana_fx( Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Estimate MASA parameters from the SBA signals */ - ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame ); + ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q ); /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 ); @@ -281,7 +281,8 @@ static void ivas_dirac_param_est_ana_fx( Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q30 */ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ - const Word16 input_frame ) + const Word16 input_frame, + const Word16 data_q ) { Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 ts, i, d, j; @@ -292,6 +293,7 @@ static void ivas_dirac_param_est_ana_fx( Word32 Foa_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 Foa_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS]; @@ -307,6 +309,10 @@ static void ivas_dirac_param_est_ana_fx( Word16 numAnalysisChannels; Word16 inp_q; Word16 intensity_q, reference_power_q; + Word16 temp_e, sf, scaled_data_q, s, shift = 31; + move16(); + Word32 temp; + Word64 W_temp; num_freq_bands = hDirAC->nbands; /* l_ts = input_frame / CLDFB_NO_COL_MAX; */ l_ts = shr( input_frame, 4 ); @@ -319,6 +325,16 @@ static void ivas_dirac_param_est_ana_fx( move16(); move16(); move16(); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); + } + shift = sub( shift, find_guarded_bits_fx( l_ts ) ); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, shift ); + } + scaled_data_q = add( data_q, shift ); /* do processing over all CLDFB time slots */ FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) @@ -355,27 +371,26 @@ static void ivas_dirac_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { - Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; - inp_q = Q7; // Input Q of data_fx + Word16 cr_q = MAX_16, ci_q = MAX_16; + inp_q = scaled_data_q; // Q of data_fx after scaling move16(); move16(); move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - inp_q = Q7; + inp_q = scaled_data_q; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][l_ts * ts] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, getScaleFactor32( Foa_ImagBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < numAnalysisChannels; i++ ) { - scale_sig32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Foa_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Foa_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); - c_e = sub( 31, inp_q ); /* Compute omni energy for metadata processing */ FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ ) { @@ -385,19 +400,37 @@ static void ivas_dirac_param_est_ana_fx( move16(); FOR( j = brange[0]; j < brange[1]; j++ ) { - Word32 temp = L_add( Mult_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Mult_32_32( Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e - hDirAC->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->energy_fx[block_m_idx][band_m_idx], hDirAC->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hDirAC->energy_e[block_m_idx][band_m_idx] ); + W_temp = W_mac_32_32( W_mult_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ); // Q-> 2*inp_q + 1 + sf = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, sf ) ); // 2*inp_q + 1 + sf - 32 + temp_e = sub( 63 - 1, add( shl( inp_q, 1 ), sf ) ); // 31 - ( 2 * inp_q + 1 + sf - 32 ) + hDirAC->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->energy_fx[block_m_idx][band_m_idx], hDirAC->energy_e[block_m_idx][band_m_idx], temp, temp_e, &hDirAC->energy_e[block_m_idx][band_m_idx] ); move32(); } } /* Direction estimation */ - computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ - intensity_q = sub( 31, shl( c_e, 1 ) ); + computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); + + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), NULL ); /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); //( 2 * ( scale_fact - Q1 ) - 31 - 1 ); // computeReferencePower_ana( hDirAC->band_grouping, Foa_RealBuffer, Foa_ImagBuffer, reference_power[ts], num_freq_bands ); - reference_power_q = sub( shl( inp_q, 1 ), 30 ); + computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); + + /* Aligning intensity_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + } + /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ move16(); @@ -417,18 +450,24 @@ static void ivas_dirac_param_est_ana_fx( FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ - hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] ); move32(); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); + + W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); + s = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, s ) ); + temp_e = sub( 63, add( add( reference_power_q, diffuseness_q ), s ) ); // 31 - ( reference_power_q + diffuseness_q + s - 32 ) + + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); move32(); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); } } @@ -478,6 +517,10 @@ static void ivas_dirac_param_est_ana_fx( } } + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, negate( shift ) ); + } return; } @@ -496,11 +539,7 @@ static void ivas_dirac_dmx_fx( v_add_fx( data_in_fx[0], data_in_fx[1], data_out_fx[0], input_frame ); v_multc_fixed( data_out_fx[0], ONE_IN_Q30, data_out_fx[0], input_frame ); // ONE_IN_Q30 = 0.5* ONE_IN_Q31 -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ v_multc_fixed( data_out_fx[1], ONE_IN_Q30, data_out_fx[1], input_frame ); FOR( i = 0; i < nchan_transport; i++ ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 7a27cf339dc2e03552bd858ac6696c3dce732415..b0077d223c57a96feb56fb3f124b364f9ac8d98b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -659,7 +659,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } - + Word16 q_cldfb_temp = sub( q_input, 1 ); DIRAC_DEC_BIN_HANDLE hDiracDecBin; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; PARAMBIN_REND_CONFIG config_data; @@ -693,7 +693,7 @@ static void ivas_dirac_dec_binaural_internal_fx( nBins = hSpatParamRendCom->num_freq_bands; move16(); offsetSamples = imult1616( hSpatParamRendCom->slots_rendered, nBins ); - + Word32 tmp_arr[CLDFB_NO_CHANNELS_MAX]; /* Setup internal config */ config_data.separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; move16(); @@ -771,9 +771,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); move32(); move32(); -#ifdef OPT_BIN_RENDERER_V1 Word16 ch_len = s_max( 4, numInChannels ); -#endif /* OPT_BIN_RENDERER_V1 */ FOR( i = 0; i < 6; i++ ) { FOR( j = 0; j < 4; j++ ) @@ -790,13 +788,21 @@ static void ivas_dirac_dec_binaural_internal_fx( test(); IF( ch == 0 || EQ_16( nchan_transport, 2 ) ) { - q_cldfb[ch][slot] = q_input; + q_cldfb[ch][slot] = q_cldfb_temp; move16(); + Copy_Scale_sig32( &( st_ivas->hTcBuffer->tc_fx[ch][nBins * slot + offsetSamples] ), tmp_arr, nBins, -1 ); + scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( q_cldfb_temp, st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); cldfbAnalysis_ts_fx_fixed_q( - &( st_ivas->hTcBuffer->tc_fx[ch][add( imult1616( nBins, slot ), offsetSamples )] ), + tmp_arr, Cldfb_RealBuffer_in_fx[ch][slot], Cldfb_ImagBuffer_in_fx[ch][slot], nBins, st_ivas->cldfbAnaDec[ch], &q_cldfb[ch][slot] ); + scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( q_input, st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbAnaDec[ch]->Q_cldfb_state = q_input; + scale_sig32( Cldfb_RealBuffer_in_fx[ch][slot], nBins, 1 ); // Q6 + scale_sig32( Cldfb_ImagBuffer_in_fx[ch][slot], nBins, 1 ); // Q6 + q_cldfb[ch][slot] = add( q_cldfb[ch][slot], 1 ); + move16(); } ELSE IF( EQ_16( config_data.nchan_transport, 2 ) ) /* Stereo signal transmitted as mono with DFT stereo */ { @@ -889,7 +895,6 @@ static void ivas_dirac_dec_binaural_internal_fx( IF( hDiracDecBin->useTdDecorr ) { - Word32 tmp_arr[60]; FOR( ch = BINAURAL_CHANNELS; ch < ( 2 * BINAURAL_CHANNELS ); ch++ ) { q_cldfb[ch][slot] = sub( q_input, 1 ); @@ -931,24 +936,11 @@ static void ivas_dirac_dec_binaural_internal_fx( Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; move16(); -#ifndef OPT_BIN_RENDERER_V1 - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q31 - Q22 ); /*Q31 to Q22*/ - } -#endif /* OPT_BIN_RENDERER_V1 */ ivas_sba_prototype_renderer_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe ); -#ifndef OPT_BIN_RENDERER_V1 - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q22 - Q31 ); /*Q31 to Q22*/ - } -#endif /* OPT_BIN_RENDERER_V1 */ } Word16 q_inp = Q6; move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 cha = 0; cha < ch_len; cha++ ) { FOR( slot = 0; slot < 4; slot++ ) @@ -963,18 +955,6 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 cha = 0; cha < 6; cha++ ) - { - FOR( slot = 0; slot < 4; slot++ ) - { - scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 - scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 - q_cldfb[cha][slot] = 6; - move16(); - } - } -#endif /* OPT_BIN_RENDERER_V1 */ test(); test(); @@ -2165,7 +2145,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( q_CrEne = Q31; move16(); -#ifdef OPT_BIN_RENDERER_V1 Word16 q_diff = sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ); IF( q_diff > 0 ) @@ -2234,67 +2213,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move32(); move16(); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - IF( GT_16( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ) - { - hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ); - hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[0][bin] ); - hDiracDecBin->ChEne_e[1][bin] = hDiracDecBin->ChEne_e[0][bin]; - } - ELSE - { - hDiracDecBin->ChEne_fx[0][bin] = L_shr( hDiracDecBin->ChEne_fx[0][bin], sub( hDiracDecBin->ChEne_e[1][bin], hDiracDecBin->ChEne_e[0][bin] ) ); - hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[1][bin] ); - hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ) ) - { - hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ) ); - hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[0][bin] ); - hDiracDecBin->ChEneOut_e[1][bin] = hDiracDecBin->ChEneOut_e[0][bin]; - } - ELSE - { - hDiracDecBin->ChEneOut_fx[0][bin] = L_shr( hDiracDecBin->ChEneOut_fx[0][bin], sub( hDiracDecBin->ChEneOut_e[1][bin], hDiracDecBin->ChEneOut_e[0][bin] ) ); - hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[1][bin] ); - hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ) ) - { - hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ) ); - hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossRe_e[bin] ); - hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; - } - ELSE - { - hDiracDecBin->ChCrossRe_fx[bin] = L_shr( hDiracDecBin->ChCrossRe_fx[bin], sub( hDiracDecBin->ChCrossIm_e[bin], hDiracDecBin->ChCrossRe_e[bin] ) ); - hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossIm_e[bin] ); - hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ) ) - { - hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ) ); - hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossReOut_e[bin] ); - hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; - } - ELSE - { - hDiracDecBin->ChCrossReOut_fx[bin] = L_shr( hDiracDecBin->ChCrossReOut_fx[bin], sub( hDiracDecBin->ChCrossImOut_e[bin], hDiracDecBin->ChCrossReOut_e[bin] ) ); - hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossImOut_e[bin] ); - hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; - } - move32(); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, @@ -2815,10 +2733,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 *decSlotImPointer_fx; Word16 q_inp_mix, q_reverb = 31; move16(); -#ifdef OPT_BIN_RENDERER_V1 Word16 ch_len = s_max( 4, numInChannels ); Word16 eff_q; -#endif /* OPT_BIN_RENDERER_V1 */ IF( processReverb ) @@ -2837,11 +2753,9 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); q_inp_mix = 31; move16(); -#ifdef OPT_BIN_RENDERER_V1 + FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ + { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2868,13 +2782,11 @@ static void ivas_dirac_dec_binaural_process_output_fx( move16(); } -#ifdef OPT_BIN_RENDERER_V1 + eff_q = sub( add( q_inp_mix, q_mat ), 15 ); FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ + { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2884,13 +2796,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) { -#ifdef OPT_BIN_RENDERER_V1 scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ -#else /* OPT_BIN_RENDERER_V1 */ - scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ - scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ -#endif } } } @@ -3051,11 +2958,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( if ( recompute == 1 ) { /* Inverse filter bank */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, 0, cldfbSynDec[chA] ); -#else - cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); -#endif cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); } @@ -3091,11 +2994,7 @@ static void adaptTransportSignalsHeadtracked_fx( Word16 e_div, is_zero, i; move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -4732,18 +4631,11 @@ static void formulate2x2MixingMatrix_fx( Sx_fx[1] = Sqrt32( Sx_fx[1], &exp1 ); move32(); q_Sx = sub( 31, s_max( exp, exp1 ) ); -#ifdef OPT_BIN_RENDERER_V1 Word16 q_diff = sub( 31, q_Sx ); Sx_fx[0] = L_shr( Sx_fx[0], sub( q_diff, exp ) ); // q_Sx move32(); Sx_fx[1] = L_shr( Sx_fx[1], sub( q_diff, exp1 ) ); // q_Sx move32(); -#else /* OPT_BIN_RENDERER_V1 */ - Sx_fx[0] = L_shr( Sx_fx[0], sub( sub( 31, exp ), q_Sx ) ); // q_Sx - move32(); - Sx_fx[1] = L_shr( Sx_fx[1], sub( sub( 31, exp1 ), q_Sx ) ); // q_Sx - move32(); -#endif /* OPT_BIN_RENDERER_V1 */ matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx ); @@ -4811,18 +4703,11 @@ static void formulate2x2MixingMatrix_fx( move32(); q_Ghat = sub( 31, s_max( exp, exp1 ) ); -#ifdef OPT_BIN_RENDERER_V1 q_diff = sub( 31, q_Ghat ); Ghat_fx[0] = L_shr( Ghat_fx[0], sub( q_diff, exp ) ); // q_Ghat move32(); Ghat_fx[1] = L_shr( Ghat_fx[1], sub( q_diff, exp1 ) ); // q_Ghat move32(); -#else /* OPT_BIN_RENDERER_V1 */ - Ghat_fx[0] = L_shr( Ghat_fx[0], sub( sub( 31, exp ), q_Ghat ) ); // q_Ghat - move32(); - Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); // q_Ghat - move32(); -#endif /* OPT_BIN_RENDERER_V1 */ /* Matrix multiplication, tmp = Ky' * G_hat * Q */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4894,28 +4779,9 @@ static void formulate2x2MixingMatrix_fx( move32(); // 1310720000 = 10,000.0f in Q17 -#ifdef OPT_BIN_RENDERER_V1 Word32 thresh = L_shl_sat( 1310720000, sub( q_div, Q17 ) ); // q_div div_fx[0] = L_min( div_fx[0], thresh ); // q_div div_fx[1] = L_min( div_fx[1], thresh ); // q_div -#else /* OPT_BIN_RENDERER_V1 */ - IF( LT_16( q_div, Q17 ) ) - { - div_fx[0] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[0] ); // q_div - move32(); - div_fx[1] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[1] ); // q_div - move32(); - } - ELSE - { - div_fx[0] = L_min( 1310720000, L_shr( div_fx[0], sub( q_div, Q17 ) ) ); - move32(); - div_fx[1] = L_min( 1310720000, L_shr( div_fx[1], sub( q_div, Q17 ) ) ); - move32(); - q_div = Q17; - move16(); - } -#endif /* OPT_BIN_RENDERER_V1 */ matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); @@ -4932,21 +4798,11 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpRe_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { -#ifdef OPT_BIN_RENDERER_V1 Word16 hdrm = sub( W_norm( W_tmp ), 32 ); tmpRe_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); move32(); hdrm_re[chA][chB] = add( add( q_temp, q_div ), hdrm ); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - hdrm_re[chA][chB] = sub( W_norm( W_tmp ), 0 ); - move16(); - W_tmp = W_shl( W_tmp, hdrm_re[chA][chB] ); - tmpRe_fx[chA][chB] = W_extract_h( W_tmp ); - move32(); - hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 ); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4957,22 +4813,12 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpIm_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { -#ifdef OPT_BIN_RENDERER_V1 Word16 hdrm = sub( W_norm( W_tmp ), 32 ); move16(); tmpIm_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); move32(); hdrm_im[chA][chB] = add( add( q_temp, q_div ), hdrm ); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - hdrm_im[chA][chB] = sub( W_norm( W_tmp ), 0 ); - move16(); - W_tmp = W_shl( W_tmp, hdrm_im[chA][chB] ); - tmpIm_fx[chA][chB] = W_extract_h( W_tmp ); - move32(); - hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 ); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4987,9 +4833,7 @@ static void formulate2x2MixingMatrix_fx( move16(); minimum_s( hdrm_im[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_temp = s_min( q_temp, exp ); -#ifdef OPT_BIN_RENDERER_V1 q_temp = sub( q_temp, 1 ); -#endif /* OPT_BIN_RENDERER_V1 */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -5003,11 +4847,7 @@ static void formulate2x2MixingMatrix_fx( } matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, -#ifdef OPT_BIN_RENDERER_V1 0 /*int Ascale*/, -#else /* OPT_BIN_RENDERER_V1 */ - 1 /*int Ascale*/, -#endif /* OPT_BIN_RENDERER_V1 */ 0 /*int Bscale*/, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index aa4aed84cd85ed7c3792396b486c102560ab4843..28c3cd5e73fb7cc7b701a397045a64be1516f633 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -485,11 +485,19 @@ void ivas_dirac_dec_decorr_process_fx( set32_fx( aux_buffer_fx, 0, 2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX ); FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { - v_shr( &input_frame_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], negate( q_shift ), &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#ifdef OPT_MCH_DEC_V1_BE + v_shr( &input_frame_fx[2 * ch_idx * num_freq_bands], negate( q_shift ), &aux_buffer_fx[2 * ch_idx * num_freq_bands], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#else /* OPT_MCH_DEC_V1_BE */ + v_shr( &input_frame_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], negate( q_shift ), &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#endif /* OPT_MCH_DEC_V1_BE */ } FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { +#ifdef OPT_MCH_DEC_V1_BE + v_mult_fixed( &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * max_band_decorr_temp], imult1616( 2, max_band_decorr_temp ) ); // q_aux_buffer +#else /* OPT_MCH_DEC_V1_BE */ v_mult_fixed( &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) )], imult1616( 2, max_band_decorr_temp ) ); // q_aux_buffer +#endif /* OPT_MCH_DEC_V1_BE */ } q_aux_buffer = sub( add( add( add( q_input_frame, q_input_frame ), q_shift ), q_shift ), 31 ); @@ -506,6 +514,10 @@ void ivas_dirac_dec_decorr_process_fx( max_band_decorr = h_freq_domain_decorr_ap_params->max_band_decorr; move16(); +#if ( defined OPT_MCH_DEC_V1_NBE || defined OPT_MCH_DEC_V1_BE ) + Word16 decorX2 = shl( max_band_decorr, 1 ); +#endif + set32_fx( onset_filter_fx, ONE_IN_Q31, imult1616( num_protos_diff, num_freq_bands ) ); Word16 q_temp = s_min( q_onset_dec, q_aux_buffer ); @@ -678,7 +690,11 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); } +#ifdef OPT_MCH_DEC_V1_BE + decorr_buffer_ptr_fx = decorr_buffer_start_ptr_fx + ( pre_delay - 1 ) * decorr_buffer_step * 2; +#else /* OPT_MCH_DEC_V1_BE */ decorr_buffer_ptr_fx = decorr_buffer_start_ptr_fx + shl( imult1616( ( sub( pre_delay, 1 ) ), decorr_buffer_step ), 1 ); +#endif /* OPT_MCH_DEC_V1_BE */ /*add MA part to state */ decorr_buffer_ptr_fx[0] = L_add( decorr_buffer_ptr_fx[0], frame_ma_fx[0] ); @@ -723,7 +739,11 @@ void ivas_dirac_dec_decorr_process_fx( Word16 q_direct_energy; Word64 aux_64[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; Word16 e_reverb_energy_smooth, e_direct_energy_smooth; - Word16 offset1, offset2; + Word16 offset1; + +#ifndef OPT_MCH_DEC_V1_BE + Word16 offset2; +#endif /* OPT_MCH_DEC_V1_BE */ Word16 norm = 63; move16(); e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); @@ -732,6 +752,17 @@ void ivas_dirac_dec_decorr_process_fx( // scaling to get max precision for aux_buffer values// q_shift = Q31; move16(); +#ifdef OPT_MCH_DEC_V1_BE + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + q_shift = s_min( q_shift, + L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); + } + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); + } +#else /* OPT_MCH_DEC_V1_BE */ offset = shl( max_band_decorr, 1 ); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { @@ -742,6 +773,7 @@ void ivas_dirac_dec_decorr_process_fx( { scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset, q_shift ); } +#endif /* OPT_MCH_DEC_V1_BE */ q_frame_f = add( q_frame_f, q_shift ); @@ -773,12 +805,18 @@ void ivas_dirac_dec_decorr_process_fx( Word32 *m32_frame_dec_fx = frame_dec_fx; move32(); offset1 = shl( num_freq_bands, 1 ); +#ifndef OPT_MCH_DEC_V1_BE offset2 = shl( max_band_decorr, 1 ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + FOR( Word16 i = 0; i < decorX2; i++ ) +#else /* OPT_MCH_DEC_V1_BE */ FOR( Word16 i = 0; i < offset2; i++ ) +#endif /* OPT_MCH_DEC_V1_BE */ { m64_aux[i] = W_mult0_32_32( m32_frame_dec_fx[i], m32_frame_dec_fx[i] ); move64(); @@ -788,19 +826,35 @@ void ivas_dirac_dec_decorr_process_fx( move64(); } } +#ifdef OPT_MCH_DEC_V1_BE + m64_aux += decorX2; +#else /* OPT_MCH_DEC_V1_BE */ m64_aux += offset2; +#endif /* OPT_MCH_DEC_V1_BE */ m32_frame_dec_fx += offset1; move64(); move32(); } norm = W_norm( min64 ); +#ifdef OPT_MCH_DEC_V1_BE + norm = sub( norm, 33 ); +#else /* OPT_MCH_DEC_V1_BE */ norm = sub( norm, 1 /*find_guarded_bits_fx( 2 )*/ ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( Word16 i = 0; i < 2 * num_channels * max_band_decorr; i++ ) { +#ifdef OPT_MCH_DEC_V1_BE + aux_buffer_fx[i] = W_shl_sat_l( aux_64[i], norm ); +#else /* OPT_MCH_DEC_V1_BE */ aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], norm ) ); +#endif /* OPT_MCH_DEC_V1_BE */ move32(); } +#ifdef OPT_MCH_DEC_V1_BE + q_aux_buffer = add( shl( q_frame_f, 1 ), norm ); +#else /* OPT_MCH_DEC_V1_BE */ q_aux_buffer = add( shl( q_frame_f, 1 ), sub( norm, 32 ) ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) @@ -815,15 +869,25 @@ void ivas_dirac_dec_decorr_process_fx( Word16 max_e = s_max( aux_e, e_reverb_energy_smooth ); Word16 shr_aux = sub( max_e, aux_e ); /* Note: headroom is zero */ Word16 shr_res = sub( max_e, e_reverb_energy_smooth ); /* Note: headroom is zero */ +#ifdef OPT_MCH_DEC_V1_NBE + Word32 temp1 = L_shr( ONE_M_DIRAC_DUCK_ALPHA, shr_aux ); + Word32 temp2 = L_shr( DIRAC_DUCK_ALPHA_FX, shr_res ); +#endif /* OPT_MCH_DEC_V1_NBE */ /* Note: DIRAC_DUCK_ALPHA_FX and ONE_M_DIRAC_DUCK_ALPHA are both in Q31 (e=0) */ /* => a multiplication with this values does not change the q/e value. */ FOR( Word16 i = 0; i < len; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i] = Madd_32_32( + Mpy_32_32( aux_buffer_fx[i], temp1 ), + h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i], temp2 ); +#else /* OPT_MCH_DEC_V1_NBE */ h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i] = L_add( L_shr( Mpy_32_32( aux_buffer_fx[i], ONE_M_DIRAC_DUCK_ALPHA ), shr_aux ), L_shr( Mpy_32_32( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i], DIRAC_DUCK_ALPHA_FX ), shr_res ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); } e_reverb_energy_smooth = max_e; @@ -836,12 +900,22 @@ void ivas_dirac_dec_decorr_process_fx( Word16 max_x = s_max( den_e, e_direct_energy_smooth ); Word16 shr_den = sub( max_x, den_e ); /* Note: headroom is zero */ Word16 shr_des = sub( max_x, e_direct_energy_smooth ); /* Note: headroom is zero */ +#ifdef OPT_MCH_DEC_V1_NBE + temp1 = L_shr( ONE_M_DIRAC_DUCK_ALPHA, shr_den ); + temp2 = L_shr( DIRAC_DUCK_ALPHA_FX, shr_des ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( Word16 i = 0; i < len; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i] = Madd_32_32( + Mpy_32_32( direct_energy_fx[i], temp1 ), + h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i], temp2 ); +#else /* OPT_MCH_DEC_V1_NBE */ h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i] = L_add( L_shr( Mpy_32_32( direct_energy_fx[i], ONE_M_DIRAC_DUCK_ALPHA ), shr_den ), L_shr( Mpy_32_32( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i], DIRAC_DUCK_ALPHA_FX ), shr_des ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); } e_direct_energy_smooth = max_x; @@ -850,6 +924,7 @@ void ivas_dirac_dec_decorr_process_fx( move16(); // scaling energy buffers for better precision for higher values// +#ifndef OPT_MCH_DEC_V1_NBE q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); IF( q_shift != 0 ) { @@ -864,6 +939,7 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = add( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, q_shift ); move16(); } +#endif h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); h_freq_domain_decorr_ap_state->q_direct_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); @@ -875,15 +951,32 @@ void ivas_dirac_dec_decorr_process_fx( move16(); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_NBE + q_shift = s_min( q_shift, + L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); +#else /* OPT_MCH_DEC_V1_NBE */ q_shift = s_min( q_shift, sub( L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ), Q2 ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ } +#ifdef OPT_MCH_DEC_V1_NBE + q_shift = sub( q_shift, 2 ); + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + Scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); + } + q_frame_f = add( q_frame_f, q_shift ); + Word16 diff1 = sub( e_direct_energy_smooth, e_reverb_energy_smooth ); + Word16 diff2 = add( Q30, diff1 ); + diff1 = sub( Q30, diff1 ); +#else /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { Scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); } q_frame_f = add( q_frame_f, q_shift ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ch_idx++ ) { @@ -903,6 +996,14 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); +#ifdef OPT_MCH_DEC_V1_NBE + Word64 temp_1 = W_sub( W_shl( reverb_energy_loc, diff1 ), W_mult0_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ) ); + Word64 temp_2 = W_sub( W_shl( direct_energy_loc, diff2 ), W_mult0_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ) ); + + IF( temp_1 > 0 ) + { + duck_gain = BASOP_Util_Divide3232_Scale( Mpy_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ), L_add( reverb_energy_loc, EPSILON_FX ), &e_duck_gain ); +#else /* OPT_MCH_DEC_V1_NBE */ Word32 temp_1 = Mpy_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ); // e+1 Word32 temp_2 = Mpy_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ); // e+1 Word16 comp_flag_1 = BASOP_Util_Cmp_Mant32Exp( reverb_energy_loc, e_reverb_energy_smooth, temp_1, add( e_direct_energy_smooth, 1 ) ); @@ -910,6 +1011,7 @@ void ivas_dirac_dec_decorr_process_fx( IF( EQ_16( comp_flag_1, 1 ) ) { duck_gain = BASOP_Util_Divide3232_Scale( temp_1, L_add( reverb_energy_loc, EPSILON_FX ), &e_duck_gain ); +#endif /* OPT_MCH_DEC_V1_NBE */ e_duck_gain = add( e_duck_gain, sub( add( e_direct_energy_smooth, 1 ), e_reverb_energy_smooth ) ); duck_gain = Sqrt16( duck_gain, &e_duck_gain ); @@ -921,10 +1023,17 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); } +#ifdef OPT_MCH_DEC_V1_NBE + ELSE IF( temp_2 > 0 ) + { + + duck_gain = BASOP_Util_Divide3232_Scale( direct_energy_loc, L_add( Mpy_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ), EPSILON_FX ), &e_duck_gain ); +#else /* OPT_MCH_DEC_V1_NBE */ ELSE IF( EQ_16( comp_flag_2, 1 ) ) { duck_gain = BASOP_Util_Divide3232_Scale( direct_energy_loc, L_add( temp_2, EPSILON_FX ), &e_duck_gain ); +#endif /* OPT_MCH_DEC_V1_NBE */ e_duck_gain = add( e_duck_gain, sub( e_direct_energy_smooth, add( e_reverb_energy_smooth, 1 ) ) ); duck_gain = Sqrt16( duck_gain, &e_duck_gain ); @@ -954,7 +1063,11 @@ void ivas_dirac_dec_decorr_process_fx( Word16 sf = MAX_16; FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); +#else /* OPT_MCH_DEC_V1_BE */ sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ) ); +#endif /* OPT_MCH_DEC_V1_BE */ } sf = s_min( sub( sf, 1 ), q_shift ); q_if_local = sub( q_shift, sf ); @@ -963,7 +1076,11 @@ void ivas_dirac_dec_decorr_process_fx( // scaling it to sf FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); +#else /* OPT_MCH_DEC_V1_BE */ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); +#endif /* OPT_MCH_DEC_V1_BE */ } q_frame_f = add( q_frame_f, sf ); } @@ -972,7 +1089,11 @@ void ivas_dirac_dec_decorr_process_fx( // scaling it to input q FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); +#else /* OPT_MCH_DEC_V1_BE */ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); +#endif /* OPT_MCH_DEC_V1_BE */ } q_frame_f = q_input_frame; q_if_local = 0; @@ -983,6 +1104,44 @@ void ivas_dirac_dec_decorr_process_fx( IF( EQ_16( h_freq_domain_decorr_ap_params->add_back_onsets_on, 1 ) ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( q_if_local ) + { + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); + + FOR( k = 0; k < max_band_decorr; ++k ) + { + Word32 op2 = L_shr( L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ), q_if_local ); + aux_buffer_fx[2 * k] = Mpy_32_32( input_frame_fx[2 * ( offset + k )], op2 ); + aux_buffer_fx[2 * k + 1] = Mpy_32_32( input_frame_fx[2 * ( offset + k ) + 1], op2 ); // q_frame_f + move32(); + move32(); + } + + v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ); + } + } + ELSE + { + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); + + FOR( k = 0; k < max_band_decorr; ++k ) + { + Word32 op2 = L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ); + aux_buffer_fx[2 * k] = Mpy_32_32( input_frame_fx[2 * ( offset + k )], op2 ); + aux_buffer_fx[2 * k + 1] = Mpy_32_32( input_frame_fx[2 * ( offset + k ) + 1], op2 ); // q_frame_f + move32(); + move32(); + } + + v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ); + } + } +#else /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); @@ -997,6 +1156,7 @@ void ivas_dirac_dec_decorr_process_fx( v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ); } +#endif /* OPT_MCH_DEC_V1_NBE */ } /* avoid decorrelation above maximum frequency -> set to zero the remaining frequencies*/ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 87fa8b7d03f1a86713b618b3f862e76e6388880f..80dcf9009840c06f89035e3b26b35809a248d05c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -672,7 +672,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 num_freq_bands_diff, num_channels_diff; Word16 ch_idx; Word32 aux_buf[CLDFB_NO_CHANNELS_MAX]; - Word16 diff_start_band, tmp16; + Word16 diff_start_band; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; @@ -821,9 +821,282 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( ONE_IN_Q29 /*0.25f Q31*/, h_dirac_output_synthesis_state->diffuse_power_factor_fx, num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ +#ifdef OPT_SBA_DEC_PATH + /*Direct gain*/ + + Word16 *exp_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); + Word16 cy_cross_dir_smooth_e = sub( 31, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); + + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + exp_temp_cy_cross_dir_smooth_fx[kk] = cy_cross_dir_smooth_e; // h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + move16(); + } + + Word16 q_temp = sub( add( shl( h_dirac_output_synthesis_state->direct_responses_q, 1 ), q_diffuseness ), 62 ); + Word32 one_in_qdiff = L_shl( 1, q_diffuseness ); + Word32 c1 = Madd_32_16( ONE_IN_Q29 /*1 Q29*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ); /*Diffuseness modellling nrg compensation*/ /*Q29*/ + Word16 q_diff_c = sub( q_diffuseness, 2 ); + + FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) + { + Word16 k; + IF( ch_idx != 0 ) + { + Word32 a, c; + Word16 b, b_exp, sqr_exp, q_diff_aab; // , q_diff_c; + Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab; + Word32 sqr_inp, sqr; + + /*Directonal sound gain nrg compensation*/ + FOR( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + + + b_exp = 0; + move16(); + + b = 0; + move16(); + + if ( 0 == reference_power[k + ( ch_idx + 1 ) * num_freq_bands] ) + { + b = MAX_16; + move16(); + } + + test(); + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] && reference_power[k + num_freq_bands] ) + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*Q(15-b_exp)*/ + } + + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q(q_diff_aab) = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c1 ); // Q(q_diff_c) = q_diffuseness - 2 + + q_diff_aab = sub( q_temp, b_exp ); // add( sub( add( h_dirac_output_synthesis_state->direct_responses_q, sub( 15, b_exp ) ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + + Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 ); + Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) ); + Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) ); + sqr_inp = L_add( op1, op2 ); + sqr_exp = sub( 31, minq ); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; // L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + } + c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ + Word16 diff_c_exp = sub( q_diffuseness, 4 ); + FOR( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + IF( reference_power[k + num_freq_bands] == 0 ) + { + sqr_inp = Mpy_32_32( diffuseness[k], c ); + sqr_exp = sub( 31 + 4, q_diffuseness ); + } + ELSE + { + Word16 diff_aab_exp; + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) + { + mpy_a_a_b = Mpy_32_32( a, a ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = q_temp; + move16(); + } + ELSE + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = sub( q_temp, b_exp ); // sub(sub(add(sub(31 + 62, h_dirac_output_synthesis_state->direct_responses_q), b_exp), h_dirac_output_synthesis_state->direct_responses_q), q_diffuseness); + } + Word16 minq = sub( s_min( diff_aab_exp, diff_c_exp ), 1 ); + Word32 op1 = L_shr( mpy_diff_aab, sub( diff_aab_exp, minq ) ); + Word32 op2 = L_shr( mpy_diff_c, sub( diff_c_exp, minq ) ); + sqr_inp = L_add( op1, op2 ); + sqr_exp = sub( 31, minq ); + } + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + + + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; + move16(); + } + } + } + ELSE + { + Word32 sqr_inp, sqr; + Word16 sqr_exp; + Word32 One_in_qdiff = L_shl( 1, sub( q_diffuseness, 1 ) ); + Word32 diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx /*q29=0.5 * q30*/, ONE_IN_Q29 /*0.5 Q30*/ ); // Q30 + Word16 sq_e = sub( 32, q_diffuseness ); // 31-(q_diffuseness-1) + /*Diffuseness modellling nrg compensation*/ + FOR( k = 0; k < num_freq_bands_diff; k++ ) + { + /*diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) )*/ + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1 + sqr_exp = sq_e; + move16(); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( LT_16( cy_cross_dir_smooth_e, sqr_exp ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + } +#ifdef FIX_1822 + diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ); + diff = L_shl( diff, 2 ); // Q29 +#endif + FOR( ; k < num_freq_bands; k++ ) + { +#ifdef FIX_1822 + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1 +#else + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 +#endif + sqr_exp = sq_e; + move16(); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; + move16(); + } + } + } + } + Word16 temp = exp_temp_cy_cross_dir_smooth_fx[0]; /*q0*/ + move16(); + FOR( Word16 kk = 1; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + temp = s_max( exp_temp_cy_cross_dir_smooth_fx[kk], temp ); + } + + + /*Directional gain (panning)*/ + Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); + Word16 temp_exp = sub( 31, temp_q ); + IF( LT_16( temp, temp_exp ) ) + { + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp_exp ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ + move32(); + } + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; + move16(); + } + ELSE + { + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp ) ); /*exp_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + move32(); + } + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = sub( 31, temp ); + move16(); + } + free( exp_temp_cy_cross_dir_smooth_fx ); +#else /* OPT_SBA_DEC_PATH */ /*Direct gain*/ - tmp16 = imult1616( num_freq_bands, num_channels_dir ); + + Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); + + Word16 tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; @@ -924,7 +1197,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -991,89 +1263,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } -#else - FOR( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses - move32(); - IF( reference_power[k + num_freq_bands] == 0 ) - { - b = 0; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) - { - b = MAX_16; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ - } - } - - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - - q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); - q_diff_c = sub( q_diffuseness, 4 ); - - test(); - IF( mpy_diff_c != 0 && mpy_diff_aab != 0 ) - { - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ - } - ELSE - { - IF( mpy_diff_c == 0 ) - { - sqr_inp = mpy_diff_aab; /*q_diff_aab*/ - move32(); - sqr_exp = sub( 31, q_diff_aab ); - } - ELSE - { - sqr_inp = mpy_diff_c; - move32(); - sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ - } - } - sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ - sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) - { - IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ - move32(); - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); - move16(); - } - ELSE - { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; - move16(); - } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ - move32(); - } - ELSE - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ - move32(); - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); - move16(); - } - } -#endif } ELSE { @@ -1176,6 +1365,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); } +#endif /* OPT_SBA_DEC_PATH */ + Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { @@ -1228,17 +1419,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/ } -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( aux_buf, &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], - num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ -#endif /* VEC_ARITH_OPT_v1 */ } return; @@ -1571,7 +1755,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( } q_shift = sub( 26, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ); - move16(); /* Direct gains */ IF( hodirac_flag ) @@ -1687,11 +1870,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Direct input->output*/ p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q) p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx; +#ifdef OPT_SBA_DEC_PATH + q_shift = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ); +#endif /* OPT_SBA_DEC_PATH */ FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ ) { +#ifdef OPT_SBA_DEC_PATH + Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], + num_freq_bands, + q_shift ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#else /* OPT_SBA_DEC_PATH */ Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#endif /* OPT_SBA_DEC_PATH */ } h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); @@ -3003,19 +3195,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( exp_direct_response_dir2 = 0; move16(); -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx ivas_dirac_dec_get_response_fx_29( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order ); -#else - ivas_dirac_dec_get_response_fx( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_hoa ); -#endif IF( hodirac_flag ) { -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx ivas_dirac_dec_get_response_fx_29( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order ); -#else - ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); -#endif } test(); @@ -3779,11 +3963,15 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15 + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp +#ifdef ISSUE_1751_replace_shl_ro + lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 +#else + Flag Overflow; + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &Overflow ); // Q15 +#endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -3792,11 +3980,15 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &overFlow ); // Q15 + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp +#ifdef ISSUE_1751_replace_shl_ro + transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 +#else + Flag Overflow; + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &Overflow ); // Q15 +#endif } j = 0; move16(); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index fb92eab13840d74c3d69ba1d783bb39a5f8c582a..428d14f28f25b01d9d5581944921b9b5513b57a1 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -986,7 +986,12 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirAC_mem->reference_power_len = imult1616( 5, num_freq_bands ); +#ifdef FIX_867_CLDFB_NRG_SCALE set16_fx( hDirAC_mem->reference_power_q, Q31, 2 ); +#else + hDirAC_mem->reference_power_q = Q31; + move16(); +#endif } IF( hDirACRend->proto_signal_decorr_on ) @@ -4297,14 +4302,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4373,14 +4386,26 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; +#else DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[1]; +#endif move16(); } ELSE { - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4447,14 +4472,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4507,12 +4540,8 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#ifdef VEC_ARITH_OPT_v1 + v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ -#endif /* VEC_ARITH_OPT_v1 */ p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/ } ELSE @@ -4608,11 +4637,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); #endif -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); // DirAC_mem.reference_power_smooth_q -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q -#endif /* VEC_ARITH_OPT_v1 */ } } /*Rescaling proto_direct_buffer_f*/ @@ -4774,7 +4799,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) +#else Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4785,9 +4814,15 @@ static void ivas_masa_ext_dirac_render_sf_fx( } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ); move16(); +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) +#else FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4822,12 +4857,20 @@ static void ivas_masa_ext_dirac_render_sf_fx( /*Buffer rescaling*/ #ifdef FIX_867_CLDFB_NRG_SCALE - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#else + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#endif FOR( i = 0; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) - Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#else + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); move16(); @@ -4893,14 +4936,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4940,10 +4991,17 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + scale_factor = s_min( scale_factor, L_norm_arr( Cldfb_RealBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); + scale_factor = s_min( scale_factor, L_norm_arr( Cldfb_ImagBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); +#else scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ) ); scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ) ); +#endif } } scale_factor = sub( scale_factor, find_guarded_bits_fx( hSpatParamRendCom->num_freq_bands ) ); // guard bits @@ -4995,8 +5053,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( } ELSE { - scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); - scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + } } FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { @@ -5004,11 +5065,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, hMasaExtRend->cldfbSynRend[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 2ac397e2cb3bd0853b6531a7b914e5d045ee1b31..3a2092294a8d27118fe4cecdc88138bb3f787de5 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -1525,11 +1525,7 @@ static void get_poly_gains_fx( A[1] = elePoly[i - 1]; // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/ -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/ -#endif /* VEC_ARITH_OPT_v1 */ FOR( j = i; j < numChan - 2 + i; ++j ) { @@ -1582,11 +1578,7 @@ static Word32 get_tri_gain_fx( tmpN[1] = L_sub( C[0], B[0] ); // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( B, A, tmpSub1, 2 ); // tmpSub1 q22 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22 -#endif /* VEC_ARITH_OPT_v1 */ tmpDot1 = dotp_fixed( tmpN, tmpSub1, 2 ); // Q13 @@ -2245,11 +2237,7 @@ static void sort_channels_vertex_fx( move32(); } -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( tmpV1, tmpV2, tmpV3, 3 ); // tmpV3 Q30 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( tmpV1, tmpV2, tmpV3, 3, 0 ); // tmpV3 Q30 -#endif /* VEC_ARITH_OPT_v1 */ Word16 exp2 = 2; move16(); normV = ISqrt32( dotp_fixed( tmpV3, tmpV3, 3 ) /*q29*/, &exp2 ); // q=31-exp2 @@ -2431,11 +2419,7 @@ static Word16 in_poly_fx( /* Angles are in Q22 */ A[1] = poly.polyEle[0]; // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/ -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/ -#endif /* VEC_ARITH_OPT_v1 */ FOR( n = 1; n < sub( numVertices, 1 ); ++n ) { @@ -2504,13 +2488,8 @@ static Word16 in_tri_fx( I'll just compute the determinant and if it's equal to 0, that means the two vectors are colinear */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( B, A, tmpDot1, 2 ); // tmpDot1 q22 v_sub_fixed_no_hdrm( C, A, tmpDot2, 2 ); // tmpDot2 q22 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22 - v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22 -#endif /* VEC_ARITH_OPT_v1 */ /* Verification of the non-colinearity : Q22 * Q22 = Q13 */ #ifdef OPT_SBA_REND_V1_BE diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index fc89c4896825bdbfbee974eeeb8ae58296922ff6..528ee4d769520842037cc74c1f4a2ee8edb497b0 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -39,6 +39,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" +#define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ /*---------------------------------------------------------------------* * Local function prototypes @@ -46,9 +47,25 @@ static void copy_masa_meta_tile_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, const UWord8 sf, const UWord8 band ); -static void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, Word32 inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne1_e, MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, Word32 inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne2_e ); +static void full_stream_merge_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); -static void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne_e, MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEneISM_e ); +static void diffuse_meta_merge_1x1_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ + Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ + Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); /*---------------------------------------------------------------------* @@ -144,54 +161,60 @@ void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. energy after merge */ - Word16 *inEne_e, /* i : TF-energy of input 1 Exponent */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEneISM_e /* i : TF-energy of input 2 Exponent */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { Word8 sf, band; - Word16 max_e, in1_e[MASA_FREQUENCY_BANDS], i; FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { Word32 energyTimesRatio_fx, energyTimesRatioISM_fx, total_diff_nrg_fx, dir_nrg_ratio_fx, total_nrg_fx = 0; - Word32 dir_ratio_ism_fx, L_tmp1, L_tmp2; + Word32 dir_ratio_ism_fx, L_tmp, L_tmp1, L_tmp2; Word16 scale, energyTimesRatio_e, tmp, total_nrg_e = 0, total_diff_nrg_e, dir_ratio_ism_e, energyTimesRatioISM_e, dir_nrg_ratio_e; move32(); move16(); - tmp = BASOP_Util_Divide1616_Scale( inMeta->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - energyTimesRatio_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - energyTimesRatio_e = add( inEne_e[sf], scale ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + energyTimesRatio_fx = Mpy_32_32_r( inEne_fx[sf][band], L_tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ + energyTimesRatio_e = add( inEne_e[sf][band], scale ); + total_nrg_fx = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &total_nrg_e ); - IF( GT_16( inEne_e[sf], inEneISM_e[sf] ) ) - { - total_nrg_fx = L_add( L_shr( inEne_fx[sf][band], 1 ), L_shr( inEneISM_fx[sf][band], add( sub( inEne_e[sf], inEneISM_e[sf] ), 1 ) ) ); /* Q(30 - inEne_e[sf]) */ - total_nrg_e = add( inEne_e[sf], 1 ); - } - ELSE - { - total_nrg_fx = L_add( L_shr( inEneISM_fx[sf][band], 1 ), L_shr( inEne_fx[sf][band], add( sub( inEneISM_e[sf], inEne_e[sf] ), 1 ) ) ); /* Q(30 - inEneISM_e[sf]) */ - total_nrg_e = add( inEneISM_e[sf], 1 ); - } /* target is original MASA diffuseness */ - tmp = BASOP_Util_Divide1616_Scale( inMeta->diffuseToTotalRatio[sf][band], UINT8_MAX, &scale ); - total_diff_nrg_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - total_diff_nrg_e = add( inEne_e[sf], scale ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta->diffuseToTotalRatio[sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + total_diff_nrg_fx = Mpy_32_32_r( inEne_fx[sf][band], L_tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ + total_diff_nrg_e = add( inEne_e[sf][band], scale ); /* criterion is mean of ISM ratio and new ratio */ - dir_ratio_ism_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( inMetaISM->directToTotalRatio[0][sf][band], UINT8_MAX, &dir_ratio_ism_e ) ); + dir_ratio_ism_fx = Mpy_32_16_1( INV_UINT8_MAX, inMetaISM->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + dir_ratio_ism_e = 15; + move16(); tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( total_nrg_fx, EPSILON_FX ), &scale ); L_tmp1 = L_deposit_h( tmp ); /* Q( 31 - ( scale + total_nrg_e - total_diff_nrg_e ) ) */ scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); - L_tmp2 = L_sub( L_shl( 1, scale ), L_tmp1 ); + IF( L_tmp1 == 0 ) + { + scale = 0; + move16(); + L_tmp2 = MAX_32; + move32(); + } + ELSE + { + L_tmp2 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q31, 0, L_negate( L_tmp1 ), scale, &scale ); + } L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp ); L_tmp1 = L_shr( L_tmp1, 1 ); energyTimesRatioISM_fx = Mpy_32_32( L_tmp1, inEneISM_fx[sf][band] ); /* Q( 31 - ( tmp + inEneISM_e[sf] ) ) */ - energyTimesRatioISM_e = add( tmp, inEneISM_e[sf] ); + energyTimesRatioISM_e = add( tmp, inEneISM_e[sf][band] ); IF( ( BASOP_Util_Cmp_Mant32Exp( energyTimesRatioISM_fx, energyTimesRatioISM_e, energyTimesRatio_fx, energyTimesRatio_e ) > 0 ) ) { @@ -209,13 +232,16 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( EPSILON_FX, total_nrg_fx ), &scale ); scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); - dir_nrg_ratio_fx = L_sub( L_shl_sat( 1, sub( 31, scale ) ), L_deposit_h( tmp ) ); + Word32 temp32 = L_shr( L_deposit_h( tmp ), sub( sub( 31, scale ), Q30 ) ); // Q30 + scale = 1; + move16(); + dir_nrg_ratio_fx = L_sub( ONE_IN_Q30, temp32 ); dir_nrg_ratio_e = scale; move16(); - new_dir_ratio_fx = dir_nrg_ratio_fx; + new_dir_ratio_fx = dir_ratio_ism_fx; move32(); - new_dir_ratio_e = dir_nrg_ratio_e; + new_dir_ratio_e = dir_ratio_ism_e; move16(); tmp = BASOP_Util_Cmp_Mant32Exp( dir_nrg_ratio_fx, dir_nrg_ratio_e, dir_ratio_ism_fx, dir_ratio_ism_e ); IF( tmp <= 0 ) @@ -226,7 +252,7 @@ void diffuse_meta_merge_1x1_fx( move16(); } - outMeta->directToTotalRatio[0][sf][band] = (UWord8) imult1616( extract_l( L_shr( new_dir_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX ); + outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( Mpy_32_16_1( new_dir_ratio_fx, UINT8_MAX ) /* (31 - new_dir_ratio_e) - 15*/, sub( 31 - 15, new_dir_ratio_e ) ) ); move16(); IF( GT_16( sub( 31, new_dir_ratio_e ), Q30 ) ) { @@ -239,7 +265,7 @@ void diffuse_meta_merge_1x1_fx( { new_diff_ratio_fx = L_sub( L_shl( 1, sub( 31, new_dir_ratio_e ) ), new_dir_ratio_fx ); /* Q(31 - new_dir_ratiio_e) */ } - outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX ); + outMeta->diffuseToTotalRatio[sf][band] = (UWord8) extract_l( L_shr( new_diff_ratio_fx, sub( sub( 31, new_dir_ratio_e ), 8 ) ) ); move16(); } ELSE @@ -264,29 +290,9 @@ void diffuse_meta_merge_1x1_fx( outMeta->spreadCoherence[1][sf][band] = 0u; move16(); - inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf], inEneISM_fx[sf][band], inEneISM_e[sf], &in1_e[band] ); /* Update energy for subsequent mergings */ - move16(); - } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne_fx[sf][i] = L_shr( inEne_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q(31 - max_e) */ + inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &inEne_e[sf][band] ); /* Update energy for subsequent mergings */ move32(); } - - inEne_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -318,16 +324,15 @@ void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { UWord8 n_dirs_1, n_dirs_2; UWord8 sf, band; - Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e, max_e, i; - Word16 in1_e[MASA_FREQUENCY_BANDS]; + Word16 scale, dir_nrg_1_e, dir_nrg_2_e; Word32 dir_nrg_1_fx, dir_nrg_2_fx, L_tmp; /* full stream select based on total direct energy */ @@ -338,27 +343,35 @@ void full_stream_merge_fx( { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - dir_nrg_1_fx = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - dir_nrg_1_e = add( scale, inEne1_e[sf] ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta1->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + dir_nrg_1_fx = Mpy_32_32( L_tmp, inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ + dir_nrg_1_e = add( scale, inEne1_e[sf][band] ); - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - dir_nrg_2_fx = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - dir_nrg_2_e = add( scale, inEne2_e[sf] ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta2->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + dir_nrg_2_fx = Mpy_32_32( L_tmp, inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ + dir_nrg_2_e = add( scale, inEne2_e[sf][band] ); IF( EQ_16( n_dirs_1, 2 ) ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); - L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - scale = add( scale, inEne1_e[sf] ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta1->directToTotalRatio[1][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + L_tmp = Mpy_32_32( L_tmp, inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ + scale = add( scale, inEne1_e[sf][band] ); dir_nrg_1_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_1_fx, dir_nrg_1_e, &dir_nrg_1_e ); } IF( EQ_16( n_dirs_2, 2 ) ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); - L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - scale = add( scale, inEne2_e[sf] ); + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta2->directToTotalRatio[1][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + L_tmp = Mpy_32_32( L_tmp, inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ + scale = add( scale, inEne2_e[sf][band] ); dir_nrg_2_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_2_fx, dir_nrg_2_e, &dir_nrg_2_e ); } @@ -371,29 +384,9 @@ void full_stream_merge_fx( copy_masa_meta_tile_fx( outMeta, inMeta2, sf, band ); } - inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf], inEne2_fx[sf][band], inEne2_e[sf], &in1_e[band] ); - move32(); - } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne1_fx[sf][i] = L_shr( inEne1_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q( 31 - max_e ) */ + inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf][band], inEne2_fx[sf][band], inEne2_e[sf][band], &inEne1_e[sf][band] ); move32(); } - - inEne1_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -436,11 +429,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2. may be altered */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { /* mixing ISMs with non-ISM use different merge */ @@ -460,9 +453,8 @@ void ivas_prerend_merge_masa_metadata_fx( FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { Copy32( inEne2_fx[sf], inEne1_fx[sf], MASA_FREQUENCY_BANDS ); + Copy( inEne2_e[sf], inEne1_e[sf], MASA_FREQUENCY_BANDS ); } - *inEne1_e = *inEne2_e; - move16(); } ELSE IF( EQ_32( inType2, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) && NE_32( inType1, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) && ( inMeta1->descriptiveMeta.numberOfDirections == 0u && inMeta2->descriptiveMeta.numberOfDirections == 0u ) ) { diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index bce7a4a5a318d1dd210558a719ff6f6d82cea168..cf86608b29f89e2ebcabdf14622286ae63f6c9ec 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -521,6 +521,7 @@ void ivas_mcmasa_param_est_ana_fx( Word16 q_vdv[MASA_FREQUENCY_BANDS]; Word16 out_exp[MASA_FREQUENCY_BANDS]; Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 reference_power_q; Word32 dir_v_fx[DIRAC_NUM_DIMS]; Word32 Chnl_RealBuffer_fx[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX]; Word32 Chnl_ImagBuffer_fx[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX]; @@ -529,7 +530,10 @@ void ivas_mcmasa_param_est_ana_fx( Word32 FoaEven_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 FoaEven_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 intensity_even_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_even_real_q[MASA_FREQUENCY_BANDS]; + Word16 intensity_q, intensity_even_q; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; @@ -571,15 +575,32 @@ void ivas_mcmasa_param_est_ana_fx( Word16 i1, i2, i3; Word16 numAnalysisChannels; Word16 spreadCoh_e; + Word64 W_temp; + Word32 temp; + Word16 temp_e; + Word16 sf, scaled_data_q, s, shift = 31; + move16(); num_freq_bins = hMcMasa->cldfbAnaEnc[0]->no_channels; move16(); num_freq_bands = hMcMasa->nbands; move16(); - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); numAnalysisChannels = sub( nchan_inp, 1 ); set16_fx( q_vdv, 31, MASA_FREQUENCY_BANDS ); set16_fx( out_exp, 30, MASA_FREQUENCY_BANDS ); + + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); + } + shift = sub( shift, find_guarded_bits_fx( l_ts ) ); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, shift ); + } + scaled_data_q = add( q_data, shift ); + /* do processing over all CLDFB time slots */ FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) { @@ -625,24 +646,24 @@ void ivas_mcmasa_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { - Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; + Word16 cr_q = MAX_16, ci_q = MAX_16, c_e; move16(); move16(); - Word16 inp_q = q_data; + Word16 inp_q = scaled_data_q; move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - inp_q = q_data; + inp_q = scaled_data_q; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < numAnalysisChannels; i++ ) { - scale_sig32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); c_e = sub( 31, inp_q ); @@ -659,8 +680,12 @@ void ivas_mcmasa_param_est_ana_fx( { FOR( i = 0; i < numAnalysisChannels; i++ ) { - Word32 temp = L_add( Mult_32_32( Chnl_RealBuffer_fx[i][j], Chnl_RealBuffer_fx[i][j] ), Mult_32_32( Chnl_ImagBuffer_fx[i][j], Chnl_ImagBuffer_fx[i][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e - hMcMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->energy_fx[block_m_idx][band_m_idx], hMcMasa->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hMcMasa->energy_e[block_m_idx][band_m_idx] ); + W_temp = W_mac_32_32( W_mult_32_32( Chnl_RealBuffer_fx[i][j], Chnl_RealBuffer_fx[i][j] ), Chnl_ImagBuffer_fx[i][j], Chnl_ImagBuffer_fx[i][j] ); // Q-> 2*inp_q + 1 + sf = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, sf ) ); // 2 * inp_q + 1 + sf - 32 + temp_e = sub( 31 + 31, add( shl( inp_q, 1 ), sf ) ); // e = 31 - (2 * inp_q + 1 + sf - 32) + + hMcMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->energy_fx[block_m_idx][band_m_idx], hMcMasa->energy_e[block_m_idx][band_m_idx], temp, temp_e, &hMcMasa->energy_e[block_m_idx][band_m_idx] ); move32(); } } @@ -751,14 +776,39 @@ void ivas_mcmasa_param_est_ana_fx( } /* Direction estimation */ - computeIntensityVector_ana_fx( hMcMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ + computeIntensityVector_ana_fx( hMcMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), - NULL ); /* Q direction_vector_fx = Q30*/ + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, + intensity_real_q ); /* Q direction_vector_fx = Q30*/ /* Power and intensity estimation for diffuseness */ - computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx ); /*2*inp_q-31*/ - computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); /*2*inp_q-30*/ + computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx, intensity_even_real_q, inp_q ); + + computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); + + /* Aligning intensity_real and intensity_even_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + minimum_fx( intensity_even_real_q, num_freq_bands, &intensity_even_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + + tmp = sub( intensity_even_q, intensity_even_real_q[i] ); + intensity_even_real_fx[0][i] = L_shl( intensity_even_real_fx[0][i], tmp ); + move32(); + intensity_even_real_fx[1][i] = L_shl( intensity_even_real_fx[1][i], tmp ); + move32(); + intensity_even_real_fx[2][i] = L_shl( intensity_even_real_fx[2][i], tmp ); + move32(); + } /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hMcMasa->index_buffer_intensity = add( ( hMcMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ @@ -769,29 +819,36 @@ void ivas_mcmasa_param_est_ana_fx( /* only real part needed */ Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); } - hMcMasa->buffer_intensity_real_q[index - 1] = sub( shl( inp_q, 1 ), 31 ); + hMcMasa->buffer_intensity_real_q[index - 1] = intensity_even_q; move16(); Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[i_mult( index - 1, num_freq_bands )] ), num_freq_bands ); - hMcMasa->buffer_energy_q[index - 1] = sub( shl( inp_q, 1 ), 30 ); + hMcMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); computeDiffuseness_fixed( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp ); // out_exp = Q30 /* Compute vertical diffuseness, and tune original diffuseness if needed */ IF( !hMcMasa->isHorizontalSetup ) { Copy32( intensity_real_fx[2], &( hMcMasa->buffer_intensity_real_vert_fx[index - 1][0] ), num_freq_bands ); - hMcMasa->buffer_intensity_real_vert_q[index - 1] = sub( shl( inp_q, 1 ), 31 ); + hMcMasa->buffer_intensity_real_vert_q[index - 1] = intensity_q; move16(); computeVerticalDiffuseness_fx( hMcMasa->buffer_intensity_real_vert_fx, hMcMasa->buffer_energy_fx, num_freq_bands, vertical_diffuseness_vector_fx, hMcMasa->buffer_intensity_real_vert_q, hMcMasa->buffer_energy_q ); // Q vertical_diffuseness_vector_fx = 31 v_min_fx( diffuseness_vector_fx, out_exp, vertical_diffuseness_vector_fx, q_vdv, diffuseness_vector_fx, out_exp, num_freq_bands ); } FOR( band_m_idx = 0; band_m_idx < hMcMasa->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ - hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); - hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); - hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ + hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); + hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); + hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); + + W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); + s = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, s ) ); + temp_e = sub( 63, add( Q30, add( reference_power_q, s ) ) ); // 31 - ( reference_power_q + diffuseness_q + s - 32 ) + + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); + + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); move32(); move32(); @@ -827,7 +884,7 @@ void ivas_mcmasa_param_est_ana_fx( { FOR( j = i; j < numAnalysisChannels; j++ ) { - Word32 temp = BASOP_Util_Add_Mant32Exp( Mult_32_32( COVls[band_m_idx].xr_fx[i][j], COVls[band_m_idx].xr_fx[i][j] ), shl( COVls[band_m_idx].xr_e[i][j], 1 ), Mult_32_32( COVls[band_m_idx].xi_fx[i][j], COVls[band_m_idx].xi_fx[i][j] ), shl( COVls[band_m_idx].xi_e[i][j], 1 ), &absCOVls_e[i][j] ); + temp = BASOP_Util_Add_Mant32Exp( Mult_32_32( COVls[band_m_idx].xr_fx[i][j], COVls[band_m_idx].xr_fx[i][j] ), shl( COVls[band_m_idx].xr_e[i][j], 1 ), Mult_32_32( COVls[band_m_idx].xi_fx[i][j], COVls[band_m_idx].xi_fx[i][j] ), shl( COVls[band_m_idx].xi_e[i][j], 1 ), &absCOVls_e[i][j] ); absCOVls_fx[i][j] = Sqrt32( temp, &absCOVls_e[i][j] ); move32(); } @@ -880,7 +937,7 @@ void ivas_mcmasa_param_est_ana_fx( move16(); } Word16 temp_exp = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - Word32 temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_exp ); + temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_exp ); tempCoh_e = 0; move16(); tempCoh_fx = L_shl( BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i2], temp, &tempCoh_e ), 16 ); @@ -932,8 +989,8 @@ void ivas_mcmasa_param_est_ana_fx( move16(); i3 = hMcMasa->rightNearest[i1]; move16(); - Word16 temp_e = add( lsEnergy_e[i2], lsEnergy_e[i3] ); - Word32 temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i2], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ); + temp_e = add( lsEnergy_e[i2], lsEnergy_e[i3] ); + temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i2], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ); IF( LT_16( i2, i3 ) ) { stereoCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i2][i3], temp, &stereoCoh_e ); @@ -952,36 +1009,34 @@ void ivas_mcmasa_param_est_ana_fx( temp2 = L_add( temp2, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, temp2, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, temp2_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 stereoness_fx = Mult_32_32( stereoCoh_fx, lsEnergyRelation_fx ); stereoness_e = stereoCoh_e; move16(); IF( LT_16( i1, i2 ) ) { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - tempCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i2], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); + tempCoh_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i1][i2], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); tempCoh_e = add( tempCoh_e, sub( absCOVls_e[i1][i2], temp_e ) ); } ELSE { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - tempCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i2][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); + tempCoh_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i2][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); tempCoh_e = add( tempCoh_e, sub( absCOVls_e[i2][i1], temp_e ) ); } - tempCoh_fx = L_shl( tempCoh_fx, 16 ); IF( LT_16( i1, i3 ) ) { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i3] ); - tempCoh2_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i3], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); + tempCoh2_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i1][i3], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); tempCoh2_e = add( tempCoh2_e, sub( absCOVls_e[i1][i3], temp_e ) ); } ELSE { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i3] ); - tempCoh2_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i3][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); + tempCoh2_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i3][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); tempCoh2_e = add( tempCoh2_e, sub( absCOVls_e[i3][i1], temp_e ) ); } - tempCoh2_fx = L_shl( tempCoh2_fx, 16 ); IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tempCoh_fx, tempCoh_e, tempCoh2_fx, tempCoh2_e ), -1 ) ) { cohPanCoh_fx = tempCoh_fx; @@ -1105,12 +1160,12 @@ void ivas_mcmasa_param_est_ana_fx( lsEnergySum_fx = L_add_sat( lsEnergySum_fx, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, lsEnergySum_fx, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, lsEnergySum_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 stereoRatio_fx = L_sub( Mult_32_32( L_shl_sat( stereoCoh_fx, stereoCoh_e ), lsEnergyRelation_fx ), surrCoh_fx ); // Q31 - + temp2 = L_sub( temp2, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp2, lsEnergySum_fx, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp2_e, lsEnergySum_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 cohPanRatio_fx = L_sub( Mult_32_32( cohPanCoh_fx, lsEnergyRelation_fx ), surrCoh_fx ); // Q31 IF( GT_32( stereoRatio_fx, cohPanRatio_fx ) ) @@ -1192,6 +1247,12 @@ void ivas_mcmasa_param_est_ana_fx( } } } + + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, negate( shift ) ); + } + return; } @@ -1436,24 +1497,33 @@ static void computeVerticalDiffuseness_fx( { Word16 tmp_e1, tmp_e2; tmp = BASOP_Util_Divide3232_Scale( intensity_slow_abs[i], L_add( energy_slow[i], EPSILON_FX_SMALL ), &tmp_e1 ); - tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) ); - tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */ - tmp_e2 = add( tmp_e2, tmp_e1 ); - tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp ); - IF( tmp < 0 ) + IF( tmp != 0 ) { - tmp = 0; - move32(); + tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) ); + tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */ + tmp_e2 = add( tmp_e2, tmp_e1 ); + tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp ); + IF( tmp < 0 ) + { + tmp = 0; + move32(); + } + ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) ) + { + tmp = ONE_IN_Q31; // Q31 + move32(); + } + ELSE + { + tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31 + } } - ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) ) + ELSE { tmp = ONE_IN_Q31; // Q31 move32(); } - ELSE - { - tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31 - } + diffuseness[i] = tmp; // Q31 move32(); } @@ -1604,7 +1674,7 @@ void ivas_create_masa_out_meta_fx( /* Direct-to-total ratio */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->directToTotalRatio[0][sf][band] = (UWord8) L_shr( energyRatio[sf][band], sub( energyRatio_q, 8 ) ); // Q8 + extOutMeta->directToTotalRatio[0][sf][band] = (UWord8) L_shr( Mpy_32_16_1( energyRatio[sf][band], UINT8_MAX ), sub( energyRatio_q, 15 ) ); // Q0 move16(); extOutMeta->directToTotalRatio[1][sf][band] = 0; move16(); @@ -1613,7 +1683,7 @@ void ivas_create_masa_out_meta_fx( /* Spread coherence */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->spreadCoherence[0][sf][band] = (UWord8) L_shr( spreadCoherence[sf][band], sub( spreadCoherence_q, 8 ) ); // Q8 + extOutMeta->spreadCoherence[0][sf][band] = (UWord8) L_shr( Mpy_32_16_1( spreadCoherence[sf][band], UINT8_MAX ), sub( spreadCoherence_q, 15 ) ); // Q0 move16(); extOutMeta->spreadCoherence[1][sf][band] = 0; move16(); @@ -1622,14 +1692,14 @@ void ivas_create_masa_out_meta_fx( /* Diffuse-to-total ratio = 1 - sum(direct-to-total ratios) */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( UINT8_MAX, (UWord8) L_shr( energyRatio[sf][band], sub( energyRatio_q, 8 ) ) ); // Q8 + extOutMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( UINT8_MAX, (UWord8) L_shr( Mpy_32_16_1( energyRatio[sf][band], UINT8_MAX ), sub( energyRatio_q, 15 ) ) ); // Q0 move16(); } /* Surround coherence */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->surroundCoherence[sf][band] = (UWord8) L_shr( surroundingCoherence[sf][band], sub( surroundingCoherence_q, 8 ) ); // Q8 + extOutMeta->surroundCoherence[sf][band] = (UWord8) L_shr( Mpy_32_16_1( surroundingCoherence[sf][band], UINT8_MAX ), sub( surroundingCoherence_q, 15 ) ); // Q0 move16(); } } diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index a098aaa25e23a3567661fc4be6bca4f218a72e59..8504722afbf2c43686a2bb8a8ec5f3934deacb88 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -193,7 +193,6 @@ static void GenerateFilter_fx( ) { Word16 qp, p, k, i; - Word32 index; Word16 AzIdx[HRTF_MODEL_BSPLINE_NUM_COEFFS][HRTF_MODEL_BSPLINE_NUM_COEFFS], EvIdx[HRTF_MODEL_BSPLINE_NUM_COEFFS]; /* non-zero basis functions */ Word16 num_az_idx[HRTF_MODEL_BSPLINE_NUM_COEFFS]; Word16 num_ev_idx; @@ -255,6 +254,16 @@ static void GenerateFilter_fx( move16(); FOR( p = 0; p < num_ev_idx; p++ ) { +#ifdef OPT_MASA_DEC_V1_NBE + Word32 expt = L_shl_sat( modelEval->elevBfVec_fx[p], 1 ); + FOR( i = 0; i < num_az_idx[p]; i++ ) + { + modelEval->BM_fx[qp + i] = Mpy_32_32( expt, modelEval->azimBfVec_fx[p][i] ); /*Q30 - ( Q30 * 2 - 31 )*/ // Q30 + move32(); + BM_idx[qp + i] = add( model->azim_start_idx[EvIdx[p]], AzIdx[p][i] ); + move16(); + } +#else /* OPT_MASA_DEC_V1_NBE */ FOR( i = 0; i < num_az_idx[p]; i++ ) { modelEval->BM_fx[add( qp, i )] = L_shl( Mpy_32_32( modelEval->elevBfVec_fx[p], modelEval->azimBfVec_fx[p][i] ), 1 ); /*Q30 - ( Q30 * 2 - 31 )*/ // Q30 @@ -262,12 +271,21 @@ static void GenerateFilter_fx( BM_idx[add( qp, i )] = add( model->azim_start_idx[EvIdx[p]], AzIdx[p][i] ); move16(); } +#endif /* OPT_MASA_DEC_V1_NBE */ qp = add( qp, num_az_idx[p] ); } +#ifdef OPT_MASA_DEC_V1_NBE + Word16 expL = add( model->AlphaL_e, 1 ); + Word16 expR = add( model->AlphaR_e, 1 ); + BMEnergiesL_e = add( model->EL_e, 2 ); + BMEnergiesR_e = add( model->ER_e, 2 ); +#endif /* OPT_MASA_DEC_V1_NBE */ + /* Compute HR filters, approximate optimized model evaluation */ FOR( iSec = 0; iSec < HRTF_MODEL_N_SECTIONS; iSec++ ) { +#ifndef OPT_MASA_DEC_V1_NBE ETotL = 0; move32(); ETotR = 0; @@ -288,45 +306,102 @@ static void GenerateFilter_fx( BMEnergiesL_e = add( model->EL_e, 2 ); BMEnergiesR_e = add( model->ER_e, 2 ); +#else /* OPT_MASA_DEC_V1_NBE */ + Word64 temp1 = 0; + move64(); + Word64 temp2 = 0; + move64(); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Energy is precalculated part updated with square of BM value. Store index for sorting */ FOR( i = 0; i < qp; i++ ) { +#ifdef OPT_MASA_DEC_V1_NBE + modelEval->BMEnergiesL[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->EL_fx[( iSec * model->AlphaN ) + BM_idx[i]] ); // exp: model->EL_e + 2 + modelEval->BMEnergiesR[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->ER_fx[( iSec * model->AlphaN ) + BM_idx[i]] ); // exp: model->ER_e + 2 +#else /* OPT_MASA_DEC_V1_NBE */ modelEval->BMEnergiesL[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->EL_fx[add( i_mult( iSec, model->AlphaN ), BM_idx[i] )] ); // exp: model->EL_e + 2 modelEval->BMEnergiesR[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->ER_fx[add( i_mult( iSec, model->AlphaN ), BM_idx[i] )] ); // exp: model->ER_e + 2 +#endif /* OPT_MASA_DEC_V1_NBE */ move32(); move32(); modelEval->BMEnergiesL[i].i = i; move16(); modelEval->BMEnergiesR[i].i = i; move16(); - +#ifndef OPT_MASA_DEC_V1_NBE ETotL = BASOP_Util_Add_Mant32Exp( ETotL, ETotL_e, modelEval->BMEnergiesL[i].val_fx, BMEnergiesL_e, &ETotL_e ); ETotR = BASOP_Util_Add_Mant32Exp( ETotR, ETotR_e, modelEval->BMEnergiesR[i].val_fx, BMEnergiesR_e, &ETotR_e ); +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = W_add( temp1, modelEval->BMEnergiesL[i].val_fx ); // BMEnergiesL_e + temp2 = W_add( temp2, modelEval->BMEnergiesR[i].val_fx ); // BMEnergiesR_e +#endif /* OPT_MASA_DEC_V1_NBE */ } +#ifdef OPT_MASA_DEC_V1_NBE + ETotL_e = W_norm( temp1 ); + ETotL_e = sub( ETotL_e, 32 ); + ETotL = W_shl_sat_l( temp1, ETotL_e ); + ETotL_e = sub( BMEnergiesL_e, ETotL_e ); + + ETotR_e = W_norm( temp2 ); + ETotR_e = sub( ETotR_e, 32 ); + ETotR = W_shl_sat_l( temp2, ETotR_e ); + ETotR_e = sub( BMEnergiesR_e, ETotR_e ); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Number of basis components actually used. */ p = s_min( HRTF_MODEL_N_CPTS_VAR[iSec], qp ); SkipSmallest_ValueIndex_fx( modelEval->UseIndsL, modelEval->BMEnergiesL, qp, sub( qp, p ) ); SkipSmallest_ValueIndex_fx( modelEval->UseIndsR, modelEval->BMEnergiesR, qp, sub( qp, p ) ); +#ifndef OPT_MASA_DEC_V1_NBE /* Account for lost energy */ FOR( i = 0; i < p; i++ ) { ESynL = BASOP_Util_Add_Mant32Exp( ESynL, ESynL_e, modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val_fx, BMEnergiesL_e, &ESynL_e ); ESynR = BASOP_Util_Add_Mant32Exp( ESynR, ESynR_e, modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val_fx, BMEnergiesR_e, &ESynR_e ); } +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = 0; + move64(); + temp2 = 0; + move64(); + + /* Account for lost energy */ + FOR( i = 0; i < p; i++ ) + { + temp1 = W_add( temp1, modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val_fx ); // BMEnergiesL_e + temp2 = W_add( temp2, modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val_fx ); // BMEnergiesR_e + } + ESynL_e = W_norm( temp1 ); + ESynL_e = sub( ESynL_e, 32 ); + ESynL = W_shl_sat_l( temp1, ESynL_e ); + ESynL_e = sub( BMEnergiesL_e, ESynL_e ); + + ESynR_e = W_norm( temp2 ); + ESynR_e = sub( ESynR_e, 32 ); + ESynR = W_shl_sat_l( temp2, ESynR_e ); + ESynR_e = sub( BMEnergiesR_e, ESynR_e ); + +#endif /* OPT_MASA_DEC_V1_NBE */ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( ETotL, ESynL, &ScaleL_e ) ); ScaleL_e = add( ScaleL_e, sub( ETotL_e, ESynL_e ) ); ScaleL = Sqrt32( tmp32, &ScaleL_e ); +#ifdef OPT_MASA_DEC_V1_NBE + ScaleL_e = sub( ScaleL_e, 1 ); +#endif /* OPT_MASA_DEC_V1_NBE */ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( ETotR, ESynR, &ScaleR_e ) ); ScaleR_e = add( ScaleR_e, sub( ETotR_e, ESynR_e ) ); ScaleR = Sqrt32( tmp32, &ScaleR_e ); +#ifdef OPT_MASA_DEC_V1_NBE + ScaleR_e = sub( ScaleR_e, 1 ); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Build using only the most energetic components. */ FOR( k = model->iSecFirst[iSec]; k <= model->iSecLast[iSec]; k++ ) { +#ifndef OPT_MASA_DEC_V1_NBE modelEval->hrfModL_fx[k] = 0; move32(); modelEval->hrfModR_fx[k] = 0; @@ -337,6 +412,7 @@ static void GenerateFilter_fx( tmp_hrfModR_e = 0; move16(); + Word32 index; FOR( i = 0; i < p; i++ ) { index = L_add( BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], imult3216( model->AlphaN, k ) ); @@ -348,6 +424,42 @@ static void GenerateFilter_fx( modelEval->hrfModR_fx[k] = BASOP_Util_Add_Mant32Exp( modelEval->hrfModR_fx[k], tmp_hrfModR_e, tmp32, add( model->AlphaR_e, 1 ), &tmp_hrfModR_e ); move32(); } +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = 0; + move64(); + temp2 = 0; + move64(); + + FOR( i = 0; i < p; i++ ) + { + temp1 = W_add( temp1, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], model->AlphaL_fx[BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaL_e, 1) + temp2 = W_add( temp2, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i], model->AlphaR_fx[BM_idx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaR_e, 1) + } + + tmp_hrfModL_e = W_norm( temp1 ); + tmp_hrfModL_e = sub( tmp_hrfModL_e, 32 ); + modelEval->hrfModL_fx[k] = W_shl_sat_l( temp1, tmp_hrfModL_e ); + move32(); + tmp_hrfModL_e = sub( expL, tmp_hrfModL_e ); + if ( temp1 == 0 ) + { + tmp_hrfModL_e = 0; + move16(); + } + + tmp_hrfModR_e = W_norm( temp2 ); + tmp_hrfModR_e = sub( tmp_hrfModR_e, 32 ); + modelEval->hrfModR_fx[k] = W_shl_sat_l( temp2, tmp_hrfModR_e ); + move32(); + tmp_hrfModR_e = sub( expR, tmp_hrfModR_e ); + + if ( temp2 == 0 ) + { + tmp_hrfModR_e = 0; + move16(); + } + +#endif /* OPT_MASA_DEC_V1_NBE */ /* Account for lost energy */ modelEval->hrfModL_fx[k] = Mpy_32_32( modelEval->hrfModL_fx[k], ScaleL ); move32(); @@ -355,8 +467,13 @@ static void GenerateFilter_fx( move32(); /* NOTE: Assuming that finally, hrfMod values will be <= 1. Hence making it Q30 */ +#ifdef OPT_MASA_DEC_V1_NBE + modelEval->hrfModL_fx[k] = L_shl( modelEval->hrfModL_fx[k], add( tmp_hrfModL_e, ScaleL_e ) ); // assuming Q30 + modelEval->hrfModR_fx[k] = L_shl( modelEval->hrfModR_fx[k], add( tmp_hrfModR_e, ScaleR_e ) ); // assuming Q30 +#else /* OPT_MASA_DEC_V1_NBE */ modelEval->hrfModL_fx[k] = L_shl( modelEval->hrfModL_fx[k], sub( add( tmp_hrfModL_e, ScaleL_e ), 1 ) ); // assuming Q30 modelEval->hrfModR_fx[k] = L_shl( modelEval->hrfModR_fx[k], sub( add( tmp_hrfModR_e, ScaleR_e ), 1 ) ); // assuming Q30 +#endif /* OPT_MASA_DEC_V1_NBE */ // move32(); move32(); } @@ -487,11 +604,18 @@ static void GenerateITD_fx( } ELSE { +#ifdef OPT_MASA_DEC_V2_NBE + Word16 temp_e = add( imult1616( EvIdx[p], model->azimDim3 ), elev_offset ); +#endif /* OPT_MASA_DEC_V2_NBE */ FOR( i = 0; i < num_az_idx; i++ ) { modelEval->BM_ITD_fx[qp + i] = L_shl( Mpy_32_32( modelEval->elevBfVecITD_fx[p], modelEval->azimBfVecITD_fx[i] ), 1 ); // Q30 move32(); +#ifdef OPT_MASA_DEC_V2_NBE + BM_idx[qp + i] = add( temp_e, AzIdx[i] ); +#else /* OPT_MASA_DEC_V2_NBE */ BM_idx[qp + i] = add( add( imult1616( EvIdx[p], model->azimDim3 ), elev_offset ), AzIdx[i] ); +#endif /* OPT_MASA_DEC_V2_NBE */ move16(); } qp = add( qp, num_az_idx ); @@ -506,19 +630,35 @@ static void GenerateITD_fx( } /* Matrix multiplcation (row x column) */ +#ifndef OPT_MASA_DEC_V2_NBE modelEval->itdMod_fx = 0; move16(); itdMod_e = 0; move16(); +#else /* OPT_MASA_DEC_V2_NBE */ + Word64 temp = 0; + move64(); + Word16 res_e = add( model->W_e, 1 ); +#endif /* OPT_MASA_DEC_V2_NBE */ FOR( i = 0; i < qp; i++ ) { - Word16 tmp_e; index = BM_idx[i]; move32(); +#ifndef OPT_MASA_DEC_V2_NBE + Word16 tmp_e; modelEval->itdMod_fx = BASOP_Util_Add_Mant32Exp( modelEval->itdMod_fx, itdMod_e, Mpy_32_32( modelEval->BM_ITD_fx[i], model->W_fx[index] ), add( model->W_e, 1 ), &tmp_e ); itdMod_e = tmp_e; move16(); - } +#else /* OPT_MASA_DEC_V2_NBE */ + temp = W_add( temp, Mpy_32_32( modelEval->BM_ITD_fx[i], model->W_fx[index] ) ); +#endif /* OPT_MASA_DEC_V2_NBE */ + } +#ifdef OPT_MASA_DEC_V2_NBE + itdMod_e = W_norm( temp ); + itdMod_e = sub( itdMod_e, 32 ); + modelEval->itdMod_fx = W_shl_sat_l( temp, itdMod_e ); + itdMod_e = sub( res_e, itdMod_e ); +#endif /* OPT_MASA_DEC_V2_NBE */ Word32 tmp32 = Mpy_32_16_1( modelEval->itdMod_fx, model->resamp_factor_fx ); // Q = 31 - ( itdMod_e + 1 ) Word16 tmp_q = sub( 30, itdMod_e ); diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index a570273cfcc46e92c17c4184d7d7904307a02e53..5f6ee03a7e44e2146f6152fddde8320953e3026d 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -191,6 +191,9 @@ static void sincResample_fx( Word16 t_step_e; Word32 t_frac_fx; Word16 t_frac_e; +#ifdef OPT_MASA_DEC_V2_NBE + Word64 t_frac_fx_acc; +#endif /* OPT_MASA_DEC_V2_NBE */ Word64 tmp64_fx; // Qx + 32 const Word32 *p_mid_fx; const Word32 *p_forward_fx; @@ -212,6 +215,10 @@ static void sincResample_fx( /* Compute fractional time step */ t_step_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( length_in, length_out, &t_step_e ) ); // exp(t_step_e) +#ifdef OPT_MASA_DEC_V2_NBE + t_frac_fx_acc = 0; + move64(); +#endif /* OPT_MASA_DEC_V2_NBE */ t_frac_fx = 0; move32(); t_frac_e = 0; @@ -224,13 +231,21 @@ static void sincResample_fx( t = extract_l( L_shr( t_frac_plus_eps, sub( 31, t_frac_plus_eps_e ) ) ); // Q0 /* Calculate the sinc-index for the center value of the sinc */ - Word32 center_val; Word16 center_val_e; +#ifndef OPT_MASA_DEC_V2_NBE + Word32 center_val; center_val = BASOP_Util_Add_Mant32Exp( t_frac_plus_eps, t_frac_plus_eps_e, L_negate( L_deposit_h( t ) ), 15, ¢er_val_e ); // exp(center_val_e) center_val_e = add( center_val_e, 6 ); // center_val * SFX_SPAT_BIN_NUM_SUBSAMPLES (i.e. 64) center_val = BASOP_Util_Add_Mant32Exp( center_val, center_val_e, ONE_IN_Q29, 1, ¢er_val_e ); // exp(center_val_e) snc0 = extract_l( L_shr( center_val, sub( 31, center_val_e ) ) ); // Q0 - +#else /* OPT_MASA_DEC_V2_NBE */ + Word64 center_val; + center_val = W_sub( t_frac_plus_eps, W_shl( t, sub( 31, t_frac_plus_eps_e ) ) ); // exp(center_val_e) + center_val_e = add( t_frac_plus_eps_e, 6 ); + Word16 com_e = s_max( 0, center_val_e ); + center_val = W_add( W_shr( center_val, sub( com_e, center_val_e ) ), W_shl( 1, sub( 30, com_e ) ) ); // exp(center_val_e) + snc0 = extract_l( W_shl_sat_l( center_val, sub( com_e, 31 ) ) ); +#endif /* OPT_MASA_DEC_V2_NBE */ /* Run convolution forward and backward from mid point */ p_mid_fx = input_fx + t; // Qx p_forward_fx = p_mid_fx + 1; // Qx @@ -255,7 +270,16 @@ static void sincResample_fx( move32(); /* Advance fractional time */ +#ifndef OPT_MASA_DEC_V2_NBE t_frac_fx = BASOP_Util_Add_Mant32Exp( t_frac_fx, t_frac_e, t_step_fx, t_step_e, &t_frac_e ); // exp( t_frac_fx ) +#else /* OPT_MASA_DEC_V2_NBE */ + t_frac_fx_acc = W_add( t_frac_fx_acc, t_step_fx ); // t_step_e + Word16 hdrm = W_norm( t_frac_fx_acc ); + hdrm = sub( hdrm, 32 ); + t_frac_fx = W_shl_sat_l( t_frac_fx_acc, hdrm ); + t_frac_e = sub( t_step_e, hdrm ); + move16(); +#endif /* OPT_MASA_DEC_V2_NBE */ } return; @@ -292,7 +316,9 @@ void TDREND_firfilt_fx( Word32 step_fx /* Q31 */, gain_tmp_fx /* Q31 */, gain_delta_fx /* Q30 */; Word16 tmp_e; Word64 tmp64_fx; - +#ifdef OPT_MASA_DEC_V1_NBE + Word16 shift = sub( filter_e, 32 ); +#endif /* OPT_MASA_DEC_V1_NBE */ gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q30 step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e) tmp_e = sub( tmp_e, Q30 ); @@ -306,12 +332,18 @@ void TDREND_firfilt_fx( Copy32( signal_fx + add( sub( subframe_length, filterlength ), 1 ), mem_fx, sub( filterlength, 1 ) ); /* Update memory for next frame */ // Qx /* Convolution */ +#ifdef OPT_MASA_DEC_V1_NBE + FOR( i = 0; i < intp_count; i++ ) +#else /* OPT_MASA_DEC_V1_NBE */ FOR( i = 0; i < subframe_length; i++ ) +#endif /* OPT_MASA_DEC_V1_NBE */ { tmp64_fx = 0; move64(); +#ifndef OPT_MASA_DEC_V1_NBE tmp_e = 0; move16(); +#endif /* OPT_MASA_DEC_V1_NBE */ p_tmp_fx = p_signal_fx + i; // Qx p_filter_fx = filter_fx; // exp(filter_e) @@ -324,18 +356,50 @@ void TDREND_firfilt_fx( } // This is done to keep the output Q same as input Q for signal - tmp64_fx = W_shl( tmp64_fx, filter_e ); // Qx + 32 - tmp_fx = W_extract_h( tmp64_fx ); // Qx +#ifdef OPT_MASA_DEC_V1_NBE + tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx +#else /* OPT_MASA_DEC_V1_NBE */ + tmp64_fx = W_shl( tmp64_fx, filter_e ); // Qx + 32 + tmp_fx = W_extract_h( tmp64_fx ); // Qx +#endif /* OPT_MASA_DEC_V1_NBE */ /* Apply linear gain interpolation in case of abrupt gain changes */ gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx move32(); +#ifndef OPT_MASA_DEC_V1_NBE IF( LT_16( i, intp_count ) ) { v_add_fx( filter_fx, filter_delta_fx, filter_fx, filterlength ); // exp(filter_e) } } +#else /* OPT_MASA_DEC_V1_NBE */ + v_add_fx( filter_fx, filter_delta_fx, filter_fx, filterlength ); // exp(filter_e) + } + FOR( ; i < subframe_length; i++ ) + { + tmp64_fx = 0; + move64(); + p_tmp_fx = p_signal_fx + i; // Qx + p_filter_fx = filter_fx; // exp(filter_e) + + + FOR( j = 0; j < filterlength; j++ ) + { + tmp64_fx = W_mac_32_32( tmp64_fx, *p_filter_fx, *p_tmp_fx ); // Qx + (Q31 - filter_e) + 1 + p_filter_fx++; // exp(filter_e) + p_tmp_fx--; // Qx + } + + // This is done to keep the output Q same as input Q for signal + tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx + + /* Apply linear gain interpolation in case of abrupt gain changes */ + gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ + signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx + move32(); + } +#endif /* OPT_MASA_DEC_V1_NBE */ return; } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index d82346d34f2b45c2f27a887ccdf0f55264465306..67e72e84c0578a544a54372d4f469ae923a0bb2f 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -362,6 +362,7 @@ static void ivas_omasa_param_est_ana_fx( Word32 Foa_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 Foa_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word16 diffuseness_q = 0; @@ -451,14 +452,14 @@ static void ivas_omasa_param_est_ana_fx( inp_q = data_f_q; cldfbAnalysis_ts_fx_var_q( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < nchan_ism; i++ ) { - scale_sig32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); c_e = sub( 31, inp_q ); @@ -489,13 +490,8 @@ static void ivas_omasa_param_est_ana_fx( FOR( i = 1; i < nchan_ism; i++ ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // Q: Chnl_RealBuffer_q v_add_fixed_no_hdrm( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // Q: Chnl_ImagBuffer_q -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_RealBuffer_q - v_add_fixed( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_ImagBuffer_q -#endif /* VEC_ARITH_OPT_v1 */ } /* Y */ @@ -528,14 +524,27 @@ static void ivas_omasa_param_est_ana_fx( v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q } - computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ - intensity_q = sub( 31, shl( c_e, 1 ) ); + computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), NULL ); /* Q direction_vector_fx = Q30*/ + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); /* Q direction_vector_fx = Q30*/ /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); // 2 * inputq - 30 - reference_power_q = sub( shl( inp_q, 1 ), 30 ); + computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); + + /* Aligning intensity_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + } /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hOMasa->index_buffer_intensity = add( ( hOMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ @@ -558,17 +567,17 @@ static void ivas_omasa_param_est_ana_fx( FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ - hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ + hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); move32(); - hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); + hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); move32(); - hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); + hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); move32(); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( 31, reference_power_q ), &diffuseness_e[band_m_idx] ); move32(); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); } } @@ -697,25 +706,25 @@ static void ivas_omasa_dmx_fx( data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] ); move32(); } - } - max_e = in_e[0]; - move16(); - FOR( l = 1; l < L_FRAME48k; l++ ) - { - IF( LT_16( max_e, in_e[l] ) ) + max_e = in_e[0]; + move16(); + FOR( l = 1; l < L_FRAME48k; l++ ) { - max_e = in_e[l]; - move16(); + IF( LT_16( max_e, in_e[l] ) ) + { + max_e = in_e[l]; + move16(); + } } - } - FOR( l = 0; l < L_FRAME48k; l++ ) - { - data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) - move32(); + FOR( l = 0; l < L_FRAME48k; l++ ) + { + data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) + move32(); + } + data_e[j] = max_e; + move16(); } - data_e[j] = max_e; - move16(); prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31 move32(); @@ -766,8 +775,9 @@ void computeIntensityVector_ana_fx( Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity 2 * Qx -31 */ -) + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ) { /* Reminder * X = a + ib; Y = c + id @@ -776,33 +786,66 @@ void computeIntensityVector_ana_fx( Word16 i, j; Word32 real, img; Word16 brange[2]; - + Word16 shift_value = add( shl( inp_q, 1 ), 1 ); + Word16 tmp_norm; FOR( i = 0; i < num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; move16(); brange[1] = band_grouping[i + 1]; move16(); + Word16 num_bins = sub( brange[1], brange[0] ); + Word16 gb = find_guarded_bits_fx( num_bins ); + Word16 norm; - intensity_real[0][i] = 0; - move32(); - intensity_real[1][i] = 0; - move32(); - intensity_real[2][i] = 0; - move32(); + Word64 tmp_1 = 0, tmp_2 = 0, tmp_3 = 0; + move64(); + move64(); + move64(); FOR( j = brange[0]; j < brange[1]; j++ ) { - real = Cldfb_RealBuffer[0][j]; // Qx - img = Cldfb_ImagBuffer[0][j]; // Qx - /* Intensity is XYZ order, audio is WYZX order. */ - intensity_real[0][i] = L_add( intensity_real[0][i], L_add( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), Mpy_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q = 2 * Qx -31 - move32(); - intensity_real[1][i] = L_add( intensity_real[1][i], L_add( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), Mpy_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q = 2 * Qx -31 + real = Cldfb_RealBuffer[0][j]; move32(); - intensity_real[2][i] = L_add( intensity_real[2][i], L_add( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), Mpy_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q = 2 * Qx -31 + img = Cldfb_ImagBuffer[0][j]; move32(); + Word64 t1, t2, t3; + t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */ + t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */ + t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */ + t1 = W_shr( t1, gb ); + t2 = W_shr( t2, gb ); + t3 = W_shr( t3, gb ); + /* Intensity is XYZ order, audio is WYZX order. */ + tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */ + tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */ + tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */ + } + norm = 63; + move16(); + IF( tmp_1 != 0 ) + { + tmp_norm = W_norm( tmp_1 ); + norm = s_min( norm, tmp_norm ); + } + IF( tmp_2 != 0 ) + { + tmp_norm = W_norm( tmp_2 ); + norm = s_min( norm, tmp_norm ); + } + IF( tmp_3 != 0 ) + { + tmp_norm = W_norm( tmp_3 ); + norm = s_min( norm, tmp_norm ); } + norm = sub( norm, 32 ); + intensity_real[0][i] = W_shl_sat_l( tmp_1, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[1][i] = W_shl_sat_l( tmp_2, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[2][i] = W_shl_sat_l( tmp_3, norm ); // shift_value - (gb - norm) + q_intensity_real[i] = sub( shift_value, sub( gb, norm ) ); + move16(); } return; @@ -824,42 +867,43 @@ void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ - Word32 *reference_power, /* o : Estimated power 2 * inputq - 31 */ - const Word16 num_freq_bands /* i : Number of frequency bands */ + Word32 *reference_power, /* o : Estimated power */ + const Word16 num_freq_bands, /* i : Number of frequency bands */ + const Word16 input_q, /* i : Q-factor Real and Imag part of input signal */ + Word16 *reference_power_q /* o : Q-factor of the estimated power */ ) { Word16 brange[2]; - Word16 ch_idx, i, j; - + Word16 ch_idx, i, j, s; + Word64 reference_power64[MASA_FREQUENCY_BANDS]; FOR( i = 0; i < num_freq_bands; i++ ) { brange[0] = band_grouping[i]; move16(); brange[1] = band_grouping[i + 1]; move16(); - reference_power[i] = 0; - move32(); + reference_power64[i] = 0; + move64(); FOR( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ ) { /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { - // Q = 2*inputq - 31 - reference_power[i] = L_add( L_add( Mpy_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Mpy_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) ), reference_power[i] ); - move32(); + reference_power64[i] = W_add( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), reference_power64[i] ); // 2 * input_q + 1 + move64(); } } } - // v_multc( reference_power, 0.5f, reference_power, num_freq_bands ); + s = sub( W_norm_arr( reference_power64, num_freq_bands ), 1 ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + reference_power[i] = W_extract_h( W_shl( reference_power64[i], s ) ); // 2 * input_q + 1 + s - 32 + move32(); + } + *reference_power_q = sub( add( shl( input_q, 1 ), s ), 30 ); /* Bypassing the v_multc ,so output q = 2 * input_q + s - 30 */ + move16(); - /* Bypassing the v_multc ,so output q = 2*inputq - 30*/ return; } - -/*--------------------------------------------------------------------------* - * computeReferencePower_ana() - * - * - *--------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 0e2033fd4ef6baedcfab9dd81a5156c42c921706..a8729ddbf4b883aab78127611ec0aec0d417f4e9 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1433,19 +1433,22 @@ void ivas_omasa_ana_close( OMASA_ANA_HANDLE *hOMasa /* i/o: analysis OMASA handle */ ); void computeIntensityVector_ana_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation */ - Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal Qx */ - const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector 2 * Qx -31 */ -); + const Word16 *band_grouping, /* i : Band grouping for estimation */ + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ + const Word16 num_frequency_bands, /* i : Number of frequency bands */ + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ); void computeReferencePower_ana_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation */ - Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ - Word32 *reference_power, /* o : Estimated power */ - const Word16 num_freq_bands /* i : Number of frequency bands 2 * input_q - 31 */ + const Word16 *band_grouping, /* i : Band grouping for estimation */ + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ + Word32 *reference_power, /* o : Estimated power */ + const Word16 num_freq_bands, /* i : Number of frequency bands */ + const Word16 input_q, /* i : Q-factor Real and Imag part of input signal */ + Word16 *reference_power_q /* o : Q-factor of the estimated power */ ); void ivas_create_masa_out_meta_fx( @@ -1469,10 +1472,11 @@ ivas_error ivas_dirac_ana_open_fx( void ivas_dirac_ana_fx( DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ - Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals, Q7 */ + Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport /* i : Number of transport channels */ -); + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 data_q /*i : Q of data_in_fx*/ + ); void ivas_dirac_ana_close_fx( DIRAC_ANA_HANDLE ( *hDirAC ) /* i/o: analysis DIRAC handle */ @@ -1483,11 +1487,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ); ivas_error masaPrerendOpen_fx( diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index bbe077f8bacdb8d40e1e1cba411dc34bf727a88f..09720d202d72eaceaa847453fc8af51939d97b97 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -232,6 +232,9 @@ void ivas_reverb_t2f_f2t_ClearHistory( move32(); } + t2f_f2t->prev_shift = 31; + move16(); + return; } /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 8c5e8813d14f415a060ce1b7b6098aead7c130f5..b4b9f7d1ef02a7c2cbea89c3043d5a77ec49a6e8 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1779,6 +1779,7 @@ static void reverb_block_fx( Word32 pTemp_fx[INNER_BLK_SIZE]; Word32 *ppOutput_fx[IVAS_REV_MAX_NR_BRANCHES]; Word32 Output_fx[IVAS_REV_MAX_NR_BRANCHES][INNER_BLK_SIZE]; + Word16 shift; move16(); move16(); move16(); @@ -1849,6 +1850,27 @@ static void reverb_block_fx( } } + shift = s_min( L_norm_arr( pOut0_fx, hReverb->fft_filter_ols.block_size ), L_norm_arr( pOut1_fx, hReverb->fft_filter_ols.block_size ) ); + + IF( LT_16( shift, hReverb->fft_filter_ols.prev_shift ) ) + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( hReverb->fft_filter_ols.fft_history_L_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + scale_sig32( hReverb->fft_filter_ols.fft_history_R_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + + hReverb->fft_filter_ols.prev_shift = shift; + move16(); + } + ELSE + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + + shift = hReverb->fft_filter_ols.prev_shift; + move16(); + } + Word16 r_shift; r_shift = add( find_guarded_bits_fx( hReverb->fft_filter_ols.fft_size ), 1 ); // Applying guard bits for the DoRTFT inside the post_fft_filter function @@ -1868,9 +1890,9 @@ static void reverb_block_fx( FOR( k = 0; k < hReverb->fft_filter_ols.block_size; k++ ) { - pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], 1 ); + pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], sub( 1, shift ) ); move32(); - pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], 1 ); + pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], sub( 1, shift ) ); move32(); } @@ -2132,23 +2154,13 @@ void ivas_binaural_reverb_processSubframe_fx( { IF( s_and( ch, 1 ) ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins ); v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 ); - v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } ELSE { -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins ); v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 ); - v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } idx = add( idx, 1 ) % hReverb->preDelayBufferLength; @@ -2178,40 +2190,20 @@ void ivas_binaural_reverb_processSubframe_fx( SWITCH( phaseShiftTypePr[tapIdx] ) { case 0: /* 0 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; case 1: /* 90 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; case 2: /* 180 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; default: /* 270 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; } } @@ -2226,7 +2218,6 @@ void ivas_binaural_reverb_processSubframe_fx( { Word32 leftRe_fx, rightRe_fx, leftIm_fx, rightIm_fx; -#ifdef OPT_BIN_RENDERER_V2 leftRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ); // Q_in rightRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), @@ -2235,16 +2226,6 @@ void ivas_binaural_reverb_processSubframe_fx( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ); // Q_in rightIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ); // Q_in -#else /* OPT_BIN_RENDERER_V2 */ - leftRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ) ); // Q_in - rightRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ) ); // Q_in - leftIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ) ); // Q_in - rightIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ) ); // Q_in -#endif /* OPT_BIN_RENDERER_V2 */ hReverb->outputBufferReal_fx[bin][0][sample] = leftRe_fx; // Q_in move32(); @@ -2301,7 +2282,7 @@ static ivas_error ivas_binaural_reverb_open_fx( #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ #else - const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ #endif const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 8967421514c6e87aefe653eb5f38da671d270774..ff077e63ebe85d22865a09c14b7d8548f9826f49 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -87,11 +87,7 @@ void ivas_sba_prototype_renderer_fx( Word16 norm_q = 31; // to handle overflow move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { @@ -100,38 +96,21 @@ void ivas_sba_prototype_renderer_fx( } norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow Word16 q_inp[2][CLDFB_SLOTS_PER_SUBFRAME]; -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { -#ifdef OPT_BIN_RENDERER_V1 q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], num_cldfb_bands ), L_norm_arr( inIm_fx[i][j], num_cldfb_bands ) ); -#else /* OPT_BIN_RENDERER_V1 */ - q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); -#endif /* OPT_BIN_RENDERER_V1 */ move16(); norm_q = s_min( q_inp[i][j], norm_q ); } } -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { -#ifdef OPT_BIN_RENDERER_V1 scale_sig32( inRe_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q scale_sig32( inIm_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q -#else /* OPT_BIN_RENDERER_V1 */ - scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q - scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q -#endif /* OPT_BIN_RENDERER_V1 */ q_cldfb[i][j] = sub( add( q_cldfb[i][j], norm_q ), 2 ); move16(); } @@ -199,21 +178,12 @@ void ivas_sba_prototype_renderer_fx( FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ -#ifdef OPT_BIN_RENDERER_V1 cldfb_par_fx = Madd_32_32( cldfb_par_fx, mixer_mat_fx[out_ch][in_ch][spar_band], L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 ) ); // hMdDec->Q_mixer_matrix -#else /* OPT_BIN_RENDERER_V1 */ - cldfb_par_fx = L_add( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); // hMdDec->Q_mixer_matrix -#endif /* OPT_BIN_RENDERER_V1 */ } } -#ifdef OPT_BIN_RENDERER_V1 out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 -#else /* OPT_BIN_RENDERER_V1 */ - out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 - out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 -#endif /* OPT_BIN_RENDERER_V1 */ move32(); move32(); } @@ -272,17 +242,11 @@ void ivas_sba_prototype_renderer_fx( { IF( EQ_16( st_ivas->nchan_transport, 1 ) ) /* Dual mono */ { -#ifdef OPT_BIN_RENDERER_V1 Copy32( inRe_fx[0][ts], inRe_fx[1][ts], num_cldfb_bands ); Copy32( inIm_fx[0][ts], inIm_fx[1][ts], num_cldfb_bands ); -#else /* OPT_BIN_RENDERER_V1 */ - Copy32( inRe_fx[0][ts], inRe_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); - Copy32( inIm_fx[0][ts], inIm_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) /* Opposing cardioids */ { -#ifdef OPT_BIN_RENDERER_V1 Word32 temp_signal_fx; FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ ) { @@ -306,28 +270,6 @@ void ivas_sba_prototype_renderer_fx( inIm_fx[0][ts][idx] = temp_signal_fx; move32(); } -#else /* OPT_BIN_RENDERER_V1 */ - Word32 temp_signal_fx[CLDFB_NO_CHANNELS_MAX]; - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - temp_signal_fx[idx] = L_add( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inRe_fx[1][ts][idx] = L_sub( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inRe_fx[0][ts][idx] = temp_signal_fx[idx]; - move32(); - } - - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - temp_signal_fx[idx] = L_add( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inIm_fx[1][ts][idx] = L_sub( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inIm_fx[0][ts][idx] = temp_signal_fx[idx]; - move32(); - } -#endif /* OPT_BIN_RENDERER_V1 */ } } } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a4e9a3624e9a6ab67cf4d9ad49ee158adabe0360..638e928f17b44296dffeea6c8203702732610ec4 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -920,6 +920,7 @@ typedef struct ivas_reverb_t2f_f2t_t Word32 fft_history_L_fx[RV_FILTER_MAX_HISTORY]; // float fft_history_R[RV_FILTER_MAX_HISTORY]; Word32 fft_history_R_fx[RV_FILTER_MAX_HISTORY]; + Word16 prev_shift; } ivas_reverb_t2f_f2t_t; /* FFT filter with its frequency response coefficients */ @@ -1657,9 +1658,8 @@ typedef struct ivas_mcmasa_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE; @@ -1693,10 +1693,8 @@ typedef struct ivas_omasa_ana_data_structure Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_q; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 interpolator_fx[L_FRAME48k]; Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS]; @@ -1737,7 +1735,6 @@ typedef struct ivas_dirac_ana_data_structure Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } DIRAC_ANA_DATA, *DIRAC_ANA_HANDLE; /*----------------------------------------------------------------------------------* @@ -1753,8 +1750,8 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c2959b7a2b58d7e4b6e131cf43d47642ec9e5383..619c4a8b29bcaad11bd4b213660b0043729e0be0 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6410,7 +6410,7 @@ static ivas_error renderActiveInputsIsm( Word16 i; input_ism *pCurrentInput; ivas_error error; - Word16 input_q = Q8; + Word16 input_q = outAudio.q_factor; move16(); FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { @@ -6420,7 +6420,7 @@ static ivas_error renderActiveInputsIsm( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = input_q; move16(); IF( NE_32( ( error = renderInputIsm( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -6525,7 +6525,8 @@ static ivas_error renderLfeToBinaural_fx( FOR( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) { writePtr = getSmplPtr_fx( outAudio, add( i_mult( pose_idx, BINAURAL_CHANNELS ), ear_idx ), 0 ); - v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ + move32(); + v_add_fixed_no_hdrm( writePtr, tmpLfeBuffer, writePtr, frame_size ); /* Q(out_q) */ } } @@ -7223,7 +7224,7 @@ static ivas_error renderActiveInputsMc( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -7683,7 +7684,7 @@ static void renderSbaToMasa( push_wmops( "renderMcToMasa" ); copyBufferTo2dArray_fx( sbaInput->base.inputBuffer, tmpRendBuffer ); - ivas_dirac_ana_fx( sbaInput->hDirAC, tmpRendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels ); + ivas_dirac_ana_fx( sbaInput->hDirAC, tmpRendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, *outAudio.pq_fact ); accumulate2dArrayToBuffer_fx( tmpRendBuffer, &outAudio ); pop_wmops(); @@ -7769,7 +7770,7 @@ static ivas_error renderActiveInputsSba( /* Skip inactive inputs */ CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputSba( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -7854,7 +7855,6 @@ static void renderMasaToMasa( Word16 mrange[2]; Word16 brange[2]; Word16 numAnalysisChannels; - Word16 tmp_energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_fx ); Word16 q_cldfb = *outAudio.pq_fact; Word16 q_cldfb_out = *outAudio.pq_fact; @@ -7877,6 +7877,7 @@ static void renderMasaToMasa( move16(); set_zero_fx( masaInput->hMasaPrerend->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS ); + set16_fx( masaInput->hMasaPrerend->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -7889,10 +7890,10 @@ static void renderMasaToMasa( move16(); move16(); cldfbAnalysis_ts_fx_fixed_q( &( tmpBuffer_fx[i][l_ts * ts] ), Chan_RealBuffer_fx[i], Chan_ImagBuffer_fx[i], l_ts, masaInput->hMasaPrerend->cldfbAnaEnc[i], &q_cldfb_out ); - scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ) ); + scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Chan_RealBuffer_fx[i], l_ts ), getScaleFactor32( Chan_ImagBuffer_fx[i], l_ts ) ) ); scale_factor = sub( scale_factor, 1 ); - scale_sig32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ - scale_sig32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ + scale_sig32( Chan_RealBuffer_fx[i], l_ts, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ + scale_sig32( Chan_ImagBuffer_fx[i], l_ts, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ scale_fac_arr[i] = scale_factor; move16(); } @@ -7908,7 +7909,7 @@ static void renderMasaToMasa( { IF( NE_16( scale_factor, scale_fac_arr[i] ) ) { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( j = 0; j < l_ts; j++ ) { Chan_RealBuffer_fx[i][j] = L_shr( Chan_RealBuffer_fx[i][j], sub( scale_fac_arr[i], scale_factor ) ); /* Q(q_cldfb_out+scale_factor) */ move32(); @@ -7931,30 +7932,14 @@ static void renderMasaToMasa( FOR( i = 0; i < numAnalysisChannels; i++ ) { Word32 temp = L_add( Mpy_32_32( Chan_RealBuffer_fx[0][j], Chan_RealBuffer_fx[0][j] ), Mpy_32_32( Chan_ImagBuffer_fx[0][j], Chan_ImagBuffer_fx[0][j] ) ); /* 2 * Q(q_cldfb_out + scale_factor) - 31 */ - masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], tmp_energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &tmp_energy_e[block_m_idx][band_m_idx] ); + masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx] ); move32(); } } } } } - FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - Word16 max_e = MIN_16; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - max_e = s_max( max_e, tmp_energy_e[i][j] ); - } - masaInput->hMasaPrerend->energy_e[i] = max_e; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - masaInput->hMasaPrerend->energy_fx[i][j] = L_shr( masaInput->hMasaPrerend->energy_fx[i][j], sub( max_e, tmp_energy_e[i][j] ) ); /* Q(31 - max_e) */ - move32(); - } - } /* Copy audio channels if mismatch in number of transports */ test(); test(); @@ -7965,11 +7950,7 @@ static void renderMasaToMasa( ELSE IF( EQ_16( masaInput->base.inputBuffer.config.numChannels, 2 ) && EQ_16( outAudio.config.numChannels, 1 ) ) { // v_add( tmpBuffer[0], tmpBuffer[1], tmpBuffer[0], masaInput->base.inputBuffer.config.numSamplesPerChannel ); -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } /* Copy metadata */ @@ -8228,7 +8209,7 @@ static ivas_error renderActiveInputsMasa( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) @@ -8295,8 +8276,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 *inEne1_e; - Word16 *inEne2_e; + Word16( *inEne1_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16( *inEne2_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; IF( hIvasRend == NULL ) { @@ -8306,27 +8287,31 @@ ivas_error IVAS_REND_MergeMasaMetadata( /* Input1 metadata and energy */ IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { + *hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne1_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne1_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -8338,25 +8323,26 @@ ivas_error IVAS_REND_MergeMasaMetadata( { inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { inMeta2 = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { inMeta2 = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne2_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + inMeta2 = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne2_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -8364,7 +8350,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( } /* Merge metadata */ - ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e ); + ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, *inEne1_e, inMeta2, inputType2, *inEne2_fx, *inEne2_e ); IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) ) @@ -8730,7 +8716,9 @@ static ivas_error getSamplesInternal( if ( outAudio.config.is_cldfb == 0 ) { Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); +#ifndef DISABLE_LIMITER limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); +#endif } /* update global cominbed orientation start index */ @@ -9002,11 +8990,7 @@ void IVAS_REND_cldfbSynthesis_wrapper( { Scale_sig32( h_cldfb->cldfb_state_fx, h_cldfb->p_filter_length, sub( sub( Q_cldfb, 1 ), h_cldfb->Q_cldfb_state ) ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, 0, 0, h_cldfb ); // Q_cldfb - 1 -#else - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, timeOut, samplesToProcess, 0, h_cldfb ); // Q_cldfb - 1 -#endif *Q_out = sub( Q_cldfb, 1 ); move16(); h_cldfb->Q_cldfb_state = *Q_out;