Commit 714426d6 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Implement MR1400 changes to main-pc. Not including changes in split rendering off path.

parent add4f598
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@
#define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN        /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig                    */
#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_991_PARAMBIN_BINARY_HRTF              /* Nokia: issue #991: fix using of binary file HRTF in ParamBin */

/* #################### 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
@@ -2234,7 +2234,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
@@ -291,7 +291,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;
            }
@@ -322,7 +326,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;
            }
+87 −5
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 */
@@ -315,8 +334,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx(
        IF( hDiracDecBin->hReverb == NULL )
#endif
            {
                /* 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( NE_32( ( 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 ) )
#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, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK) )
#else
                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, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) )
#endif
                {
                    return error;
                }
@@ -390,6 +412,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;
    }
@@ -1797,7 +1823,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();
@@ -1848,7 +1878,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
@@ -1862,7 +1896,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
@@ -3308,7 +3346,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();
@@ -5598,7 +5640,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;
@@ -5727,7 +5775,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
        {
@@ -5742,7 +5794,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
        }
    }

@@ -5758,9 +5814,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
    Word32( *hrtfShCoeffsReInt_fx )[16][60];
    Word32( *hrtfShCoeffsImInt_fx )[16][60];
    hrtfShCoeffsReInt_fx = hHrtfParambin->hrtfShCoeffsRe_fx;
    hrtfShCoeffsImInt_fx = hHrtfParambin->hrtfShCoeffsIm_fx;
#endif

    *lRealp = 0;
    *lImagp = 0;
@@ -5778,10 +5846,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();
@@ -5800,10 +5875,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