Commit 7ae27c06 authored by vasilache's avatar vasilache
Browse files

Merge branch '1716_basop_portMR1400' into 'main-pc'

Port MR1400 changes to main-pc.

See merge request !1685
parents 0f680f28 e960acc1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@
#define FIX_1001_ARI_HM_OVERFLOW                        /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */
#define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE                  /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */
#define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS            /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */
/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF   */           /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */

/* #################### End BASOP porting switches ############################ */

+4 −0
Original line number Diff line number Diff line
@@ -1150,7 +1150,11 @@ ivas_error ivas_dirac_dec_config_fx(
            IF( st_ivas->hDiracDecBin == NULL )
#endif
            {
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
                IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
#else
                IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
#endif
                {
                    return error;
                }
+4 −0
Original line number Diff line number Diff line
@@ -2254,7 +2254,11 @@ ivas_error ivas_init_decoder_fx(
            }
        }

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
        IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
        }
+8 −0
Original line number Diff line number Diff line
@@ -303,7 +303,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
                return error;
            }

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
#else
            IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
#endif
            {
                return error;
            }
@@ -334,7 +338,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
                return error;
            }

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
#else
            IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
#endif
            {
                return error;
            }
+89 −6
Original line number Diff line number Diff line
@@ -128,9 +128,17 @@ static void adaptTransportSignalsHeadtracked_fx( COMBINED_ORIENTATION_HANDLE hHe

static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( COMBINED_ORIENTATION_HANDLE hHeadTrackData, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 nBins, const Word16 nSlots, Word32 Rmat[3][3] /*Q30*/ );


#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue, HRTFS_PARAMBIN_HANDLE hHrtfParambin );
#else
static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue );
#endif

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked, HRTFS_PARAMBIN_HANDLE hHrtfParambin );
#else
static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] );
@@ -162,7 +170,11 @@ static void matrixTransp2Mul_fx(
 *------------------------------------------------------------------------*/
ivas_error ivas_dirac_dec_init_binaural_data_fx(
    Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure                  */
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
    HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i  : HRTF structure for rendering            */
#else
    HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i  : HRTF structure for rendering            */
#endif
)
{
    DIRAC_DEC_BIN_HANDLE hDiracDecBin;
@@ -206,6 +218,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
            hDiracDecBin->hReverb = NULL;
            hDiracDecBin->h_freq_domain_decorr_ap_params = NULL;
            hDiracDecBin->h_freq_domain_decorr_ap_state = NULL;
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            hDiracDecBin->phHrtfParambin = NULL;
#endif
        }

        output_Fs = st_ivas->hDecoderConfig->output_Fs;
@@ -297,7 +312,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
        }
        ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */
        {
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins );
#else
        Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins );
#endif
            hDiracDecBin->q_earlyPartEneCorrection = Q28;
            move16();
            /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */
@@ -317,7 +336,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
            {

#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
                if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) )
#else
                if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK )
#endif
#else
            /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */
            if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK )
@@ -395,6 +418,10 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
        hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */
        move16();

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
        hDiracDecBin->phHrtfParambin = phHrtfParambin;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
        st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin;
    }
@@ -1802,7 +1829,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx(
                spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx );
            }

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked, *hDiracDecBin->phHrtfParambin );
#else
            getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked );
#endif

            Word16 q_lr = Q28;
            move16();
@@ -1853,7 +1884,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx(
                rImagp_fx = Mpy_32_32( rImagp_fx, centerMul_fx ); // Q25

                /* Apply the gain for the left source of the three coherent sources */
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
                getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked, *hDiracDecBin->phHrtfParambin );
#else
                getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked );
#endif

                hrtfEneSides_fx = L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ),                     // Q25
                                         L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ),              // Q25
@@ -1867,7 +1902,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx(
                /* Apply the gain for the right source of the three coherent sources.
                 * -30 degrees to 330 wrapping due to internal functions. */

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
                getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked, *hDiracDecBin->phHrtfParambin );
#else
                getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked );
#endif

                hrtfEneSides_fx = L_add( hrtfEneSides_fx,
                                         L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ),                       // Q25
@@ -3313,7 +3352,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx(
                q_processMtxPrev_SCCR[bin] = q_processMtx_bin;
                move16();

#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
                getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked, *hDiracDecBin->phHrtfParambin );
#else
                getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked );
#endif

                hDiracDecBin->processMtxRe_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) );
                move16();
@@ -5603,7 +5646,13 @@ static void getDirectPartGains_fx(
    const UWord8 renderStereoOutputInsteadOfBinaural,
    Word32 Rmat[3][3], /*Q30*/
    PARAMBIN_HRTF_GAIN_CACHE *gainCache,
    const Word16 isHeadtracked )
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
    const Word16 isHeadtracked,
    HRTFS_PARAMBIN_HANDLE hHrtfParambin
#else
    const Word16 isHeadtracked
#endif
)
{
    // float aziRad, eleRad;
    Word32 y, mappedX;
@@ -5732,7 +5781,11 @@ static void getDirectPartGains_fx(
        test();
        IF( EQ_16( aziDeg, gainCache->azi ) && EQ_16( eleDeg, gainCache->ele ) )
        {
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, TRUE, hHrtfParambin );
#else
            hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, TRUE );
#endif
        }
        ELSE
        {
@@ -5747,7 +5800,11 @@ static void getDirectPartGains_fx(
                                                                              // eleDeg = L_shr(eleDeg_32, 22);
                                                                              // aziDeg = L_shr(aziDeg_32, 22);
            }
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, FALSE, hHrtfParambin );
#else
            hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, FALSE );
#endif
        }
    }

@@ -5763,9 +5820,21 @@ static void hrtfShGetHrtf_fx(
    Word32 *rRealp,
    Word32 *rImagp,
    PARAMBIN_HRTF_GAIN_CACHE *gainCache,
    const Word16 useCachedValue )
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
    const Word16 useCachedValue,
    HRTFS_PARAMBIN_HANDLE hHrtfParambin
#else
    const Word16 useCachedValue
#endif
)
{
    Word16 k;
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
    Word16( *hrtfShCoeffsReInt_fx )[16][60];
    Word16( *hrtfShCoeffsImInt_fx )[16][60];
    hrtfShCoeffsReInt_fx = hHrtfParambin->hrtfShCoeffsRe_fx;
    hrtfShCoeffsImInt_fx = hHrtfParambin->hrtfShCoeffsIm_fx;
#endif

    *lRealp = 0;
    *lImagp = 0;
@@ -5783,10 +5852,17 @@ static void hrtfShGetHrtf_fx(

        FOR( k = 0; k < HRTF_SH_CHANNELS; k++ )
        {
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsReInt_fx[0][k][bin] ); // Q28
            *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsImInt_fx[0][k][bin] ); // Q28
            *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsReInt_fx[1][k][bin] ); // Q28
            *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsImInt_fx[1][k][bin] ); // Q28
#else
            *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsRe_fx[0][k][bin] ); // Q28
            *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsIm_fx[0][k][bin] ); // Q28
            *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsRe_fx[1][k][bin] ); // Q28
            *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsIm_fx[1][k][bin] ); // Q28
#endif
            move32();
            move32();
            move32();
@@ -5805,10 +5881,17 @@ static void hrtfShGetHrtf_fx(

        FOR( k = 0; k < HRTF_SH_CHANNELS; k++ )
        {
#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
            *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsReInt_fx[0][k][bin] ); // Q28
            *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsImInt_fx[0][k][bin] ); // Q28
            *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsReInt_fx[1][k][bin] ); // Q28
            *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsImInt_fx[1][k][bin] ); // Q28
#else
            *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsRe_fx[0][k][bin] ); // Q28
            *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsIm_fx[0][k][bin] ); // Q28
            *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsRe_fx[1][k][bin] ); // Q28
            *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsIm_fx[1][k][bin] ); // Q28
#endif
            gainCache->shVec_fx[k] = shVec[k]; // Q29
            move32();
            move32();
Loading