Commit 38e4eb32 authored by Manuel Jander's avatar Manuel Jander
Browse files

Issue #867 : use 2 scale regions for reference_power vectors to improve...

Issue #867 : use 2 scale regions for reference_power vectors to improve precision. Work in progress. Format.
parent 71c85ce9
Loading
Loading
Loading
Loading
+85 −58
Original line number Diff line number Diff line
@@ -2468,20 +2468,24 @@ void ivas_dirac_dec_render_sf_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
        tmp1 = 31;
        move16();
        FOR (i=0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, CLDFB_NO_CHANNELS_HALF ) );
        }
        FOR (i=0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, CLDFB_NO_CHANNELS_HALF, tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], tmp1 );
        move16();
        tmp1 = 31;
        move16();
        FOR (i=0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        }
        FOR (i=0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); 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, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], tmp1 );
@@ -2792,27 +2796,38 @@ void ivas_dirac_dec_render_sf_fx(
            {
                Word32 sr;
                Word16 el;
                FOR ( el=0; el<st_ivas->nSCE; el++ ) {
                    test(); test();
                    IF ( st_ivas->hSCE[el]->hCoreCoder[0]->hIGFDec != NULL && st_ivas->hSCE[el]->hCoreCoder[0]->hIGFDec->isIGFActive ) {
                FOR( el = 0; el < st_ivas->nSCE; el++ )
                {
                    test();
                    test();
                    IF( st_ivas->hSCE[el]->hCoreCoder[0]->hIGFDec != NULL && st_ivas->hSCE[el]->hCoreCoder[0]->hIGFDec->isIGFActive )
                    {
                        cldfb_last_band = s_max( cldfb_last_band, st_ivas->hSCE[el]->hCoreCoder[0]->hIGFDec->infoIGFStopFreq );
                        sr = st_ivas->hSCE[el]->hCoreCoder[0]->output_Fs;
                    }
                }
                FOR ( el=0; el<st_ivas->nCPE; el++ ) {
                    test(); test();
                    IF ( st_ivas->hCPE[el]->hCoreCoder[0]->hIGFDec != NULL && st_ivas->hCPE[el]->hCoreCoder[0]->hIGFDec->isIGFActive ) {
                FOR( el = 0; el < st_ivas->nCPE; el++ )
                {
                    test();
                    test();
                    IF( st_ivas->hCPE[el]->hCoreCoder[0]->hIGFDec != NULL && st_ivas->hCPE[el]->hCoreCoder[0]->hIGFDec->isIGFActive )
                    {
                        cldfb_last_band = s_max( cldfb_last_band, st_ivas->hCPE[el]->hCoreCoder[0]->hIGFDec->infoIGFStopFreq );
                        sr = st_ivas->hCPE[el]->hCoreCoder[0]->output_Fs;
                    }
                    test(); test();
                    IF ( st_ivas->hCPE[el]->hCoreCoder[1]->hIGFDec != NULL && st_ivas->hCPE[el]->hCoreCoder[1]->hIGFDec->isIGFActive ) {
                    test();
                    test();
                    IF( st_ivas->hCPE[el]->hCoreCoder[1]->hIGFDec != NULL && st_ivas->hCPE[el]->hCoreCoder[1]->hIGFDec->isIGFActive )
                    {
                        cldfb_last_band = s_max( cldfb_last_band, st_ivas->hCPE[el]->hCoreCoder[1]->hIGFDec->infoIGFStopFreq );
                    }
                }
                IF ( EQ_16( cldfb_last_band, 0 ) ) {
                IF( EQ_16( cldfb_last_band, 0 ) )
                {
                    cldfb_last_band = hSpatParamRendCom->num_freq_bands;
                } ELSE {
                }
                ELSE
                {
                    cldfb_last_band = mult_r( div_s( shr( cldfb_last_band, 2 ), extract_l( L_shr( sr, 3 ) ) ), hSpatParamRendCom->num_freq_bands );
                }
            }
@@ -2837,10 +2852,12 @@ void ivas_dirac_dec_render_sf_fx(
                                           st_ivas->cldfbAnaDec[ch], &q_temp_cldfb );
#endif
#ifdef FIX_867_CLDFB_NRG_SCALE_CLDFB_MASK
                FOR (i=cldfb_last_band; i<hSpatParamRendCom->num_freq_bands; i++) {
                FOR( i = cldfb_last_band; i < hSpatParamRendCom->num_freq_bands; i++ )
                {
                    Cldfb_RealBuffer_fx[ch][0][i] = 0;
                    Cldfb_ImagBuffer_fx[ch][0][i] = 0;
                    move32(); move32();
                    move32();
                    move32();
                }
#endif
            }
@@ -3751,17 +3768,20 @@ void ivas_dirac_dec_render_sf_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
        exp = 31;
        move16();
        FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF ) );
        }
        FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF, exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], exp );
        move16();
        IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) )
        {
            FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
            FOR( i = 0; 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 + i, CLDFB_NO_CHANNELS_HALF, sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ) ); // proto_power_smooth_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0];
@@ -3769,7 +3789,8 @@ void ivas_dirac_dec_render_sf_fx(
        }
        ELSE
        {
            FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + i, CLDFB_NO_CHANNELS_HALF, sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] ) ); // proto_power_smooth_prev_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0];
@@ -3777,17 +3798,20 @@ void ivas_dirac_dec_render_sf_fx(
        }
        exp = 31;
        move16();
        FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            exp = s_min( exp, getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        }
        FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
        FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], exp );
        move16();
        IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) )
        {
            FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
            FOR( i = 0; 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, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // proto_power_smooth_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1];
@@ -3795,7 +3819,8 @@ void ivas_dirac_dec_render_sf_fx(
        }
        ELSE
        {
            FOR ( i=0; proto_power_smooth_len > i; i = add(i, hSpatParamRendCom->num_freq_bands ) ) {
            FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // proto_power_smooth_prev_q
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1];
@@ -3881,11 +3906,13 @@ void ivas_dirac_dec_render_sf_fx(
                move16();
            }
        }
        if (allZero) {
        if ( allZero )
        {
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = 31;
            move16();
        }
        if (allZero) {
        if ( allZero )
        {
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = 31;
            move16();
        }
+48 −41
Original line number Diff line number Diff line
@@ -308,7 +308,8 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
        dirac_output_synthesis_state->reference_power_smooth_prev_q[0] = Q31;
        dirac_output_synthesis_state->reference_power_smooth_prev_q[1] = Q31;
        move16(); move16();
        move16();
        move16();
#else
        dirac_output_synthesis_state->reference_power_smooth_prev_q = Q31;
        move16();
@@ -495,7 +496,8 @@ void ivas_dirac_dec_output_synthesis_init_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
        h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] = Q31;
        h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] = Q31;
        move16(); move16();
        move16();
        move16();
#else
        h_dirac_output_synthesis_state->proto_power_smooth_prev_q = Q31;
        move16();
@@ -2063,10 +2065,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
                         sub( q_com, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth -> q_com*/
            q_reference_power_smooth[0] = q_com;
            q_reference_power_smooth[1] = q_com;
            move16(); move16();
            move16();
            move16();
            h_dirac_output_synthesis_state->reference_power_smooth_prev_q[0] = q_com;
            h_dirac_output_synthesis_state->reference_power_smooth_prev_q[1] = q_com;
            move16(); move16();
            move16();
            move16();

            h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = q_com;
            move16();
@@ -2095,7 +2099,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
                                               h_dirac_output_synthesis_state->diffuse_responses_square_fx,
                                               h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx,
                                               &h_dirac_output_synthesis_state->q_cy_auto_diff_smooth );

    }

    /*-----------------------------------------------------------------*
@@ -2315,10 +2318,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
#ifdef FIX_867_CLDFB_NRG_SCALE
    Word16 min_exp2 = MIN_16;
    min_exp = MIN_16;
    move16(); move16();
    move16();
    move16();
    Word16 q_tmp2 = Q31;
    q_tmp = Q31;
    move16(); move16();
    move16();
    move16();

    FOR( k = 0; k < num_protos_dir; k++ )
    {
@@ -2355,10 +2360,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
    // Update the Q-factor
    h_dirac_output_synthesis_state->proto_power_smooth_prev_q[0] = h_dirac_output_synthesis_state->proto_power_smooth_q[0];
    h_dirac_output_synthesis_state->proto_power_smooth_prev_q[1] = h_dirac_output_synthesis_state->proto_power_smooth_q[1];
    move16(); move16();
    move16();
    move16();
    h_dirac_output_synthesis_state->proto_power_smooth_q[0] = q_tmp;
    h_dirac_output_synthesis_state->proto_power_smooth_q[1] = q_tmp2;
    move16(); move16();
    move16();
    move16();
#else
    min_exp = MIN_16;
    move16();
+87 −64

File changed.

Preview size limit exceeded, changes collapsed.

+12 −7
Original line number Diff line number Diff line
@@ -8309,7 +8309,8 @@ static void intermidiate_ext_dirac_render(
#ifdef FIX_867_CLDFB_NRG_SCALE
        DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0] = Q31;
        DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1] = Q31;
        move16(); move16();
        move16();
        move16();
#else
        DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q = Q31;
        move16();
@@ -8454,20 +8455,24 @@ static void intermidiate_ext_dirac_render(
            /* Possible improvement: normalize both scale regions individually. */
            tmp = 0;
            move16();
            FOR ( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands) ) {
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx, CLDFB_NO_CHANNELS_HALF ) );
            }
            FOR ( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands) ) {
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx, CLDFB_NO_CHANNELS_HALF, tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], tmp );
            move16();
            tmp = 0;
            move16();
            FOR ( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands) ) {
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                tmp = s_min( tmp, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
            }
            FOR ( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands) ) {
            FOR( slot_idx = 0; slot_idx < hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len; slot_idx = add( slot_idx, hSpatParamRendCom->num_freq_bands ) )
            {
                scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + slot_idx + CLDFB_NO_CHANNELS_HALF, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp ); /* Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + tmp) */
            }
            hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], tmp );