Commit f8c6ea9b authored by emerit's avatar emerit
Browse files

fix masa

parent 552def96
Loading
Loading
Loading
Loading
+47 −12
Original line number Diff line number Diff line
@@ -8076,11 +8076,15 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init(


static ivas_error ivas_masa_ext_rend_parambin_init(
    input_masa *inputMasa /* i/o: MASA external renderer structure        */
    input_masa *inputMasa,                  /* i/o: MASA external renderer structure        */
    const RENDER_CONFIG_DATA *hRendCfg,     /* i  : Renderer configuration data handle      */
    HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i  : HRTF statistics                         */
)
{
    DIRAC_DEC_BIN_HANDLE hDiracDecBin;
    HRTFS_PARAMBIN_HANDLE hHrtfParambin;
#ifdef FIX_POINT_HRTF_FILE_FORMAT
    HRTFS_PARAMBIN_HANDLE *phHrtfParambin;
#endif
    Word16 nBins;
    Word32 output_Fs;
    RENDERER_TYPE renderer_type;
@@ -8092,15 +8096,13 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    Word16 tmp;
    Word16 tmp_e;
    Word16 tmp2;

#ifdef FIX_POINT_HRTF_FILE_FORMAT
    const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics;
#endif
    error = IVAS_ERR_OK;
    move32();

#ifdef FIX_POINT_HRTF_FILE_FORMAT
    hHrtfParambin = *inputMasa->hMasaExtRend->hHrtfParambin;
#else
    hHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin;
#endif
    phHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin;

    /* Set common variables and defaults */
    output_Fs = *( inputMasa->base.ctx.pOutSampleRate );
@@ -8200,6 +8202,25 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    }
    ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */
    {
#ifdef FIX_POINT_HRTF_FILE_FORMAT
        IF( EQ_16( *inputMasa->base.ctx.pOutConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
        {
#ifdef FIX_1123_FASTCONV_PARAMBIN_16BIT_ROM
            Copy_Scale_sig_16_32_no_sat( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins, Q16 + ( Q15 - ( *phHrtfParambin )->factor_Q_EarlyPartEneCorrection_fx ) );
#else
            Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins );
#endif
            hDiracDecBin->q_earlyPartEneCorrection = Q28;
            move16();
            pRoomAcoustics = NULL;
        }
        ELSE
        {
            set_l( hDiracDecBin->earlyPartEneCorrection_fx, ONE_IN_Q31, CLDFB_NO_CHANNELS_MAX );
            hDiracDecBin->q_earlyPartEneCorrection = Q31;
            pRoomAcoustics = &( hRendCfg->roomAcoustics );
        }
#else
#ifdef FIX_1123_FASTCONV_PARAMBIN_16BIT_ROM
        Copy_Scale_sig_16_32_no_sat( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins, Q16 + ( Q15 - hHrtfParambin->factor_Q_EarlyPartEneCorrection_fx ) );
#else
@@ -8207,11 +8228,18 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
#endif
        hDiracDecBin->q_earlyPartEneCorrection = Q28;
        move16();

#endif
        IF( hDiracDecBin->hReverb == NULL )
        {
            /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */
            IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) )
#ifdef FIX_POINT_HRTF_FILE_FORMAT_REVERB
            IF( NE_32( error = ivas_binaural_reverb_init_fx( &( hDiracDecBin->hReverb ), hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, pRoomAcoustics, output_Fs,
                                                             ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->factor_Q_reverberationTimes_fx,
                                                             ( *phHrtfParambin )->parametricReverberationEneCorrections_fx, ( *phHrtfParambin )->factor_Q_EarlyPartEneCorrection_fx ),
                       IVAS_ERR_OK ) )
#else
            IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, *phHrtfParambin ) ), IVAS_ERR_OK ) )
#endif
            {
                return error;
            }
@@ -8251,6 +8279,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init(
    hDiracDecBin->reqularizationFactor_fx = 6554; /* 0.4f in Q14 */
    move16();

#ifdef FIX_POINT_HRTF_FILE_FORMAT
    hDiracDecBin->phHrtfParambin = phHrtfParambin;
#endif
    inputMasa->hMasaExtRend->hDiracDecBin = hDiracDecBin;

    return error;
@@ -8262,7 +8293,7 @@ static ivas_error initMasaExtRenderer(
#ifdef FIX_POINT_HRTF_FILE_FORMAT
    ,
    const RENDER_CONFIG_DATA *hRendCfg,
    hrtf_handles *hHrtfs
    hrtf_handles *hrtfs
#endif
)
{
@@ -8288,7 +8319,7 @@ static ivas_error initMasaExtRenderer(
    hMasaExtRend->hDiracDecBin = NULL;
    hMasaExtRend->hReverb = NULL;
#ifdef FIX_POINT_HRTF_FILE_FORMAT
    hMasaExtRend->hHrtfParambin = &hHrtfs->hHrtfParambin;
    hMasaExtRend->hHrtfParambin = &hrtfs->hHrtfParambin;
#else
    hMasaExtRend->hHrtfParambin = NULL;
#endif
@@ -8396,7 +8427,11 @@ static ivas_error initMasaExtRenderer(
            }
        }

#ifdef FIX_POINT_HRTF_FILE_FORMAT
        IF( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ), IVAS_ERR_OK ) )
#endif
        {
            return error;
        }