Commit 2b0ea951 authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

fix for 3gpp issue 381

parent 96c285ba
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -4591,7 +4591,7 @@ void ivas_dirac_dec_render_sf_fx(
        test();
        IF( L_and( h_dirac_output_synthesis_params->use_onset_filters, L_and( NE_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) ) )
        {
            Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_params->max_band_decorr, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) );
            Scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) );
            h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31;
            move16();

@@ -4603,11 +4603,11 @@ void ivas_dirac_dec_render_sf_fx(
        test();
        IF( L_and( EQ_16( hDirAC->hConfig->dec_param_estim, TRUE ), NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) )
        {
            scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) );
            scale_sig32( h_dirac_output_synthesis_state->direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->direct_power_factor_q ) );
            h_dirac_output_synthesis_state->direct_power_factor_q = Q31;
            move16();

            scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) );
            scale_sig32( h_dirac_output_synthesis_state->diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, h_dirac_output_synthesis_state->diffuse_power_factor_q ) );
            h_dirac_output_synthesis_state->diffuse_power_factor_q = Q31;
            move16();

@@ -4801,7 +4801,7 @@ void ivas_dirac_dec_render_sf_fx(
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, ( size_ho / hDirACRend->num_outputs_dir ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) );
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) );
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) )
        {
@@ -4809,7 +4809,7 @@ void ivas_dirac_dec_render_sf_fx(
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hDirACRend->h_output_synthesis_psd_params.max_band_decorr, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) );
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) );
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth, Q26 ) )
        {
@@ -4884,7 +4884,7 @@ void ivas_dirac_dec_render_sf_fx(

        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q, Q31 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) );
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q ) );
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.direct_responses_q, Q31 ) )
        {
@@ -4892,7 +4892,7 @@ void ivas_dirac_dec_render_sf_fx(
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q, Q31 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, hSpatParamRendCom->num_freq_bands, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) );
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, h_dirac_output_synthesis_state->diff_dir_power_factor_len, sub( Q31, hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_q ) );
        }
        IF( NE_16( q_diffuseness_vector, Q31 ) )
        {
+72 −26
Original line number Diff line number Diff line
@@ -178,9 +178,11 @@ static void matrixMul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Ai

static void matrixTransp2Mul( float Are[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Aim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bre[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float Bim[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outRe[BINAURAL_CHANNELS][BINAURAL_CHANNELS], float outIm[BINAURAL_CHANNELS][BINAURAL_CHANNELS] );
#endif

#ifdef IVAS_FLOAT_FIXED
static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[], const Word16 subframe );
#else
static void ivas_masa_ext_rend_parambin_internal( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, float *output_f[], const int16_t subframe );

#endif
#ifdef IVAS_FLOAT_FIXED
static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx, Word32 Ein2_fx, Word16 q_Ein, Word32 CinRe_fx, Word32 CinIm_fx, Word16 q_Cin, Word32 Eout1_fx, Word32 Eout2_fx, Word16 q_Eout, Word32 CoutRe_fx, Word32 CoutIm_fx, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS], Word16 *q_M, const Word16 regularizationFactor_fx );

@@ -7812,10 +7814,10 @@ static void ivas_masa_ext_rend_parambin_internal(
    return;
}
#else
static void ivas_masa_ext_rend_parambin_internal(
static void ivas_masa_ext_rend_parambin_internal_fx(
    MASA_EXT_REND_HANDLE hMasaExtRend,
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,
    float *output_f[],
    Word32 *output_fx[], /* Q11*/
    const Word16 subframe )
{

@@ -7828,21 +7830,20 @@ static void ivas_masa_ext_rend_parambin_internal(
    Word16 i, j;
    Word16 nchan_transport;
    Word16 q_mat;

#if 1
    hDiracDecBin = hMasaExtRend->hDiracDecBin;
    hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom;
    Word32 *output_fx[MAX_OUTPUT_CHANNELS];
    Word32 output_fx_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k];
    FOR( ch = 0; ch < 2; ch++ )
    {
        output_fx[ch] = output_fx_buff[ch];
        floatToFixed_arrL32( output_f[ch], output_fx[ch], Q11, L_FRAME48k );
    }
#endif

    Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];
    Word32 Cldfb_ImagBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX];

    FOR( i = 0; i < 6; i++ )
    {
        FOR( j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ )
        {
            set32_fx( Cldfb_RealBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
            set32_fx( Cldfb_ImagBuffer_in_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX );
        }
    }
    Word32 Rmat_fx[3][3];

    hDiracDecBin = hMasaExtRend->hDiracDecBin;
@@ -7863,8 +7864,16 @@ static void ivas_masa_ext_rend_parambin_internal(
    move16();
    config_data.qualityBasedSmFactor_fx = ONE_IN_Q31;
    move32();
    config_data.processReverb = hMasaExtRend->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ? 1 : 0;
    IF( EQ_16( hMasaExtRend->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
    {
        config_data.processReverb = 1;
        move16();
    }
    ELSE
    {
        config_data.processReverb = 0;
        move16();
    }
    config_data.ism_mode = ISM_MODE_NONE;
    move32();

@@ -7926,6 +7935,7 @@ static void ivas_masa_ext_rend_parambin_internal(
        }
    }
    Word16 q_inp = Q6;
    move16();
    IF( hCombinedOrientationData )
    {
        FOR( i = 0; i < 3; i++ )
@@ -7982,20 +7992,15 @@ static void ivas_masa_ext_rend_parambin_internal(
                                                              hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0,
                                                              0, NULL );

#if 1
    Word16 q_out;
    q_inp = Q6;
    move16();
    FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    {
        output_fx[ch] = output_fx_buff[ch];
    }

    FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    {
        hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11;
        move16();
    }
#endif // Float to fix ends

    q_mat = hDiracDecBin->q_processMtx;
    move16();
@@ -8042,20 +8047,18 @@ static void ivas_masa_ext_rend_parambin_internal(
    move16();
    move16();

#if 1 // Fix to float
    FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    {
        fixedToFloat_arrL32( output_fx[ch], output_f[ch], q_out, nBins * hSpatParamRendCom->subframe_nbslots[subframe] );
        scale_sig32( output_fx[ch], nBins * hSpatParamRendCom->subframe_nbslots[subframe], sub( Q11, q_out ) );
        scale_sig32( hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) );
        hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11;
    }
#endif

    return;
}
#endif


#ifndef IVAS_FLOAT_FIXED
void ivas_masa_ext_rend_parambin_render(
    MASA_EXT_REND_HANDLE hMasaExtRend,                    /* i/o: MASA ext rend structure                                  */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i  : combined orientation handle                              */
@@ -8095,3 +8098,46 @@ void ivas_masa_ext_rend_parambin_render(

    return;
}
#else
void ivas_masa_ext_rend_parambin_render_fx(
    MASA_EXT_REND_HANDLE hMasaExtRend,                    /* i/o: MASA ext rend structure                                   */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i  : combined orientation handle                               */
    Word32 *output_f[],                                   /* i/o: synthesized core-coder transport channels/DirAC output Q11*/
    const Word16 num_subframes )                          /* i  : number of subframes to render                             */
{
    Word16 subframe;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    Word32 *p_output[BINAURAL_CHANNELS];
    Word16 ch;

    hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom;

    FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
    {
        p_output[ch] = output_f[ch];
    }

    hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx;
    move16();
    FOR( subframe = 0; subframe < num_subframes; subframe++ )
    {
        Word16 n_samples_sf = i_mult( hSpatParamRendCom->slot_size, CLDFB_SLOTS_PER_SUBFRAME );
        hSpatParamRendCom->slots_rendered = 0;
        move16();

        ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx );

        FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            p_output[ch] += n_samples_sf;
        }

        ivas_combined_orientation_update_index( hCombinedOrientationData, n_samples_sf );

        hSpatParamRendCom->dirac_read_idx = ( add( hSpatParamRendCom->dirac_read_idx, 1 ) ) % hSpatParamRendCom->dirac_md_buffer_length;
        move16();
    }

    return;
}
#endif
+1 −0
Original line number Diff line number Diff line
@@ -1471,6 +1471,7 @@ ivas_error ivas_dirac_alloc_mem_fx(

    hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx = hDirAC_mem->direct_power_factor_fx;
    hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx = hDirAC_mem->diffuse_power_factor_fx;
    hDirACRend->h_output_synthesis_psd_state.diff_dir_power_factor_len = size_pf;
    set_zero_fx( hDirACRend->h_output_synthesis_psd_state.direct_power_factor_fx, size_pf );
    set_zero_fx( hDirACRend->h_output_synthesis_psd_state.diffuse_power_factor_fx, size_pf );
    hDirACRend->h_output_synthesis_psd_state.direct_power_factor_q = Q31;
+8 −0
Original line number Diff line number Diff line
@@ -357,12 +357,20 @@ void ivas_dirac_dec_binaural_render_fx(
    Word32 *output_f[]                                         /* o  : rendered time signal                    */
);
#endif
#ifndef IVAS_FLOAT_FIXED
void ivas_masa_ext_rend_parambin_render(
    MASA_EXT_REND_HANDLE hMasaExtRend,                              /* i/o: MASA ext rend structure                                  */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,           /* i  : combined orientation handle                              */
    float *output_f[],                                              /* i/o: synthesized core-coder transport channels/DirAC output   */
    const int16_t num_subframes                                      /* i  : number of subframes to render                            */
);
#else
void ivas_masa_ext_rend_parambin_render_fx(
    MASA_EXT_REND_HANDLE hMasaExtRend,                    /* i/o: MASA ext rend structure                                    */
    COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i  : combined orientation handle                                */
    Word32 *output_f[],                                   /* i/o: synthesized core-coder transport channels/DirAC output  Q11*/
    const Word16 num_subframes );                          /* i  : number of subframes to render                             */
#endif
#ifndef IVAS_FLOAT_FIXED
ivas_error ivas_dirac_dec_init_binaural_data(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
+1 −0
Original line number Diff line number Diff line
@@ -451,6 +451,7 @@ typedef struct dirac_output_synthesis_state_structure

    Word16 direct_power_factor_q;
    Word16 diffuse_power_factor_q;
    Word16 diff_dir_power_factor_len;

    Word32 *proto_power_smooth_fx; /* Smoothed power of the prototype signals. Size: num_freq_bands*num_channels. */
    Word16 proto_power_smooth_q;
Loading