Commit 3ebcda9b authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

fix diffuseness calculation

parent 7cc8960c
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -1372,8 +1372,13 @@ void computeDiffuseness_fixed(
    /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */
    min_q_shift1 = Q31;
    move16();
#ifndef FIX_867
    min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) );
	min_q_shift1 = sub(min_q_shift1, find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF));
#else
	min_q_shift1 = find_guarded_bits_fx(DIRAC_NO_COL_AVG_DIFF);
#endif


    min_q_shift2 = Q31;
    move16();
@@ -1386,20 +1391,33 @@ void computeDiffuseness_fixed(
    }
    min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) );

#ifdef FIX_867
	q_ene = min_q_shift1;
#else
    q_ene = add( q_factor_energy[0], min_q_shift1 );
#endif
    move16();
    q_intensity = add( q_factor_intensity[0], min_q_shift2 );
    move16();


    FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i )
    {
        /* Energy slow */
        p_tmp_c = buffer_energy + i * num_freq_bands;

#ifndef FIX_867
        q_tmp = add( q_factor_energy[i], min_q_shift1 );
#endif
        FOR( k = 0; k < num_freq_bands; k++ )
        {
#ifdef FIX_867
			q_tmp = add(q_factor_energy[i*num_freq_bands + k], min_q_shift1);
			tmp = L_shr(p_tmp_c[k], min_q_shift1);
#else
            tmp = L_shl( p_tmp_c[k], min_q_shift1 );
#endif

            IF( LT_16( q_tmp, q_ene ) )
            {
                energy_slow[k] = L_add( L_shr( energy_slow[k], sub( q_ene, q_tmp ) ), tmp );
@@ -1410,11 +1428,18 @@ void computeDiffuseness_fixed(
                energy_slow[k] = L_add( energy_slow[k], L_shr( tmp, sub( q_tmp, q_ene ) ) );
                move32();
            }
#ifdef FIX_867
			q_ene = s_min(q_ene, q_tmp);
#endif
        }
#ifndef FIX_867
        q_ene = s_min( q_ene, q_tmp );
#endif

        /* Intensity slow */
#ifndef FIX_867
        q_tmp = add( q_factor_intensity[i], min_q_shift2 );
#endif
        FOR( j = 0; j < DIRAC_NUM_DIMS; ++j )
        {
            p_tmp = buffer_intensity[j][i];
@@ -1433,7 +1458,6 @@ void computeDiffuseness_fixed(
                }
            }
        }
        q_intensity = s_min( q_intensity, q_tmp );
    }

    min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) );
+9 −2
Original line number Diff line number Diff line
@@ -978,7 +978,11 @@ static ivas_error ivas_dirac_rend_config_fx(
            }
        }
        set32_fx( hDirACRend->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX );
#ifdef FIX_867
        set16_fx( hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF * CLDFB_NO_CHANNELS_MAX);
#else
		set16_fx(hDirACRend->q_buffer_energy, Q31, DIRAC_NO_COL_AVG_DIFF);
#endif
    }
    ELSE IF( ( EQ_16( flag_config, DIRAC_OPEN ) && hDirAC->hConfig->dec_param_estim == FALSE ) || ( EQ_16( flag_config, DIRAC_RECONFIGURE ) && ( ( hDirAC->hConfig->dec_param_estim == FALSE ) && EQ_16( dec_param_estim_old, TRUE ) ) ) )
    {
@@ -4624,7 +4628,10 @@ void ivas_dirac_dec_render_sf_fx(

            Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands );
#ifdef FIX_867
            hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0];
			FOR(Word16 kk=0;kk<num_freq_bands;kk++)
			{
				hDirACRend->q_buffer_energy[(index - 1)*num_freq_bands + kk] = DirAC_mem.reference_power_q[kk];
			}
#else
            hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q;
#endif
+2 −0
Original line number Diff line number Diff line
@@ -2644,8 +2644,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx(
                         sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/
#endif
        }
#ifndef FIX_867
        h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev;
        move16();
#endif

        FOR( ch_idx = 0; ch_idx < nchan_transport_foa; ch_idx++ )
        {
+5 −1
Original line number Diff line number Diff line
@@ -712,8 +712,12 @@ typedef struct ivas_dirac_rend_data_structure
    Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; /* Q(q_buffer_intensity_real[]) */
    Word16 q_buffer_intensity_real[DIRAC_NO_COL_AVG_DIFF];
    Word32 *buffer_energy_fx; /* Q(q_buffer_energy[]) */
#ifdef FIX_867
    Word16 q_buffer_energy[CLDFB_NO_CHANNELS_MAX*DIRAC_NO_COL_AVG_DIFF];
#else
	Word16 q_buffer_energy[DIRAC_NO_COL_AVG_DIFF];
#endif
#endif

#ifndef IVAS_FLOAT_FIXED
    float *frequency_axis;