Loading lib_com/ivas_dirac_com.c +178 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,96 @@ ivas_error ivas_dirac_sba_config( return error; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * computeDirectionVectors() * * *------------------------------------------------------------------------*/ void computeDirectionVectors_fx( Word32 *intensity_real_x, Word32 *intensity_real_y, Word32 *intensity_real_z, const Word16 enc_param_start_band, const Word16 num_frequency_bands, Word32 *direction_vector_x, Word32 *direction_vector_y, Word32 *direction_vector_z, Word16 *i_q /*input/output Q*/ ) { Word16 i; Word32 intensityNorm; Word16 sq = 31 - ( 2 * ( *i_q ) - 31 ); Word16 sq1 = ( 2 * ( *i_q ) - 31 ); Word16 exp = sq; Word16 local_i_q = sq1; Word16 min_factor = 30; Word32 *init_x = intensity_real_x; Word32 *init_y = intensity_real_y; Word32 *init_z = intensity_real_z; // First loop to determine the Q for the direction vector for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; if ( intensityNorm <= EPSILON_FX ) { intensity_real_x++; intensity_real_y++; intensity_real_z++; } else { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp intensity_real_x++; // i_q + Q31-exp -31 = i_q -exp intensity_real_y++; // i_q + Q31-exp -31 = i_q -exp intensity_real_z++; // i_q + Q31-exp-31 = i_q -exo local_i_q = *i_q - exp; min_factor = min( min_factor, local_i_q ); } } intensity_real_x = init_x; intensity_real_y = init_y; intensity_real_z = init_z; // Actual processing loop for the direction vector for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; if ( intensityNorm <= EPSILON_FX ) { intensityNorm = L_shl( 1, min_factor ); *( direction_vector_x++ ) = L_shl( 1, min_factor ); *( direction_vector_y++ ) = 0; *( direction_vector_z++ ) = 0; intensity_real_x++; intensity_real_y++; intensity_real_z++; } else { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp Word32 temp = L_shr( Mpy_32_32( *( intensity_real_x++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_x++ ) = temp; // i_q + Q31-exp -31 = i_q -exp temp = L_shr( Mpy_32_32( *( intensity_real_y++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_y++ ) = temp; // i_q + Q31-exp -31 = i_q -exp temp = L_shr( Mpy_32_32( *( intensity_real_z++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_z++ ) = temp; // i_q + Q31-exp-31 = i_q -exp } } *i_q = min_factor; return; } #endif /*------------------------------------------------------------------------- * computeDirectionVectors() * Loading Loading @@ -927,7 +1017,95 @@ void computeDirectionVectors( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * computeDiffuseness() * * *------------------------------------------------------------------------*/ void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, const Word16 num_freq_bands, Word32 *diffuseness, Word16 q_factor_intensity, Word16 q_factor_energy, Word16 *out_exp /*Ouput Q*/ ) { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0, tmp_1; Word32 *p_tmp; const Word32 *p_tmp_c; /* Compute Intensity slow and energy slow */ set_val_Word32( intensity_slow, 0, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ); set_val_Word32( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX ); set_val_Word32( energy_slow, 0, CLDFB_NO_CHANNELS_MAX ); for ( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; for ( k = 0; k < num_freq_bands; k++ ) { energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy) } /* Intensity slow */ for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; for ( k = 0; k < num_freq_bands; k++ ) { intensity_slow[j * num_freq_bands + k] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] ); } } } /* intensity_slow.^2 + intensity_slow_abs*/ for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = intensity_slow + j * num_freq_bands; for ( k = 0; k < num_freq_bands; k++ ) { *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 ) intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] ); } } Word16 init_exp = 31 - (( 2 * ( q_factor_intensity ) ) - 31),exp; Word16 exp1 = 0, exp2; /* Compute Diffuseness */ p_tmp = intensity_slow_abs; for ( i = 0; i < num_freq_bands; ++i ) { exp = init_exp; Word32 temp = *( p_tmp++ ); tmp_1 = Sqrt32( temp, &exp ); tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i],1 ), &exp1 ) ); exp2 = 31 - exp1 + (31- exp - q_factor_energy ); if ( exp2 > 30 ) { tmp = L_shr( tmp, ( exp2 - 30 ) ); exp2 -= ( exp2 - 30 ); } tmp = L_sub( L_shl( 1, exp2 ), tmp ); diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) ); out_exp[i] = exp2; } return; } #endif /*------------------------------------------------------------------------- * computeDiffuseness() Loading lib_com/ivas_prot.h +25 −1 Original line number Diff line number Diff line Loading @@ -3962,7 +3962,19 @@ void computeDiffuseness_mdft( const uint16_t no_col_avg_diff, float *diffuseness ); #ifdef IVAS_FLOAT_FIXED void computeDirectionVectors_fx( Word32 *intensity_real_x, Word32 *intensity_real_y, Word32 *intensity_real_z, const Word16 enc_param_start_band, const Word16 num_frequency_bands, Word32 *direction_vector_x, Word32 *direction_vector_y, Word32 *direction_vector_z , Word16 *q_factor ); #endif void computeDirectionVectors( float *intensity_real_x, float *intensity_real_y, Loading @@ -3981,7 +3993,19 @@ void computeDiffuseness( float *diffuseness ); #ifdef IVAS_FLOAT_FIXED void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, const Word16 num_freq_bands, Word32 *diffuseness , Word16 q_factor_intensity, Word16 q_factor_energy, Word16 *out_exp ); #endif void ivas_dirac_dec_get_response( const int16_t azimuth, const int16_t elevation, Loading lib_rend/ivas_dirac_ana.c +387 −5 File changed.Preview size limit exceeded, changes collapsed. Show changes lib_rend/ivas_mcmasa_ana.c +90 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,9 @@ #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif /*------------------------------------------------------------------------- * Local constants Loading Loading @@ -1048,6 +1050,92 @@ static void computeEvenLayout( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * ivas_create_masa_out_meta() * * *------------------------------------------------------------------------*/ void ivas_create_masa_out_meta_fx( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ const Word16 nchan_transport, /* i : Number of transport channels */ Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated surround coherence */ Word16 energyRatio_q, Word16 spreadCoherence_q, Word16 surroundingCoherence_q ) { const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ int16_t i, sf, band; uint8_t numFrequencyBands; uint8_t numDirections; uint16_t spherical_index; numDirections = 1; numFrequencyBands = MASA_FREQUENCY_BANDS; /* Construct descriptive meta */ for ( i = 0; i < 8; i++ ) { extOutMeta->descriptiveMeta.formatDescriptor[i] = ivasmasaFormatDescriptor[i]; } extOutMeta->descriptiveMeta.numberOfDirections = numDirections - 1; extOutMeta->descriptiveMeta.numberOfChannels = (uint8_t) ( nchan_transport - 1 ); /* Following correspond to "unknown" values */ extOutMeta->descriptiveMeta.sourceFormat = 0x0u; extOutMeta->descriptiveMeta.transportDefinition = 0x0u; extOutMeta->descriptiveMeta.channelAngle = 0x0u; extOutMeta->descriptiveMeta.channelDistance = 0x0u; extOutMeta->descriptiveMeta.channelLayout = 0x0u; /* Construct spatial metadata from estimated values */ for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { /* Spherical index */ for ( band = 0; band < numFrequencyBands; band++ ) { spherical_index = index_theta_phi_16_fx( &elevation_m_values[sf][band], &azimuth_m_values[sf][band], Sph_Grid16 ); extOutMeta->directionIndex[0][sf][band] = spherical_index; extOutMeta->directionIndex[1][sf][band] = SPH_IDX_FRONT; } /* Direct-to-total ratio */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->directToTotalRatio[0][sf][band] = (uint8_t) L_shr( energyRatio[sf][band], energyRatio_q - 8 ); extOutMeta->directToTotalRatio[1][sf][band] = 0; } /* Spread coherence */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->spreadCoherence[0][sf][band] = (uint8_t) L_shr( spreadCoherence[sf][band], spreadCoherence_q - 8 ); extOutMeta->spreadCoherence[1][sf][band] = 0; } /* Diffuse-to-total ratio = 1 - sum(direct-to-total ratios) */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->diffuseToTotalRatio[sf][band] = UINT8_MAX - (uint8_t) L_shr( energyRatio[sf][band], energyRatio_q - 8 ); } /* Surround coherence */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->surroundCoherence[sf][band] = (uint8_t) L_shr( surroundingCoherence[sf][band], surroundingCoherence_q - 8 ); } } return; } #endif /*------------------------------------------------------------------------- * ivas_create_masa_out_meta() Loading lib_rend/ivas_omasa_ana.c +87 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,52 @@ static void ivas_omasa_dmx( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * computeIntensityVector_ana() * * *--------------------------------------------------------------------------*/ void computeIntensityVector_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ const Word16 num_frequency_bands, /* i : Number of frequency bands */ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ ) { /* Reminder * X = a + ib; Y = c + id * X*Y = ac - bd + i(ad +bc) */ Word16 i, j; Word32 real, img; Word16 brange[2]; for ( i = 0; i < num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; brange[1] = band_grouping[i + 1]; intensity_real[0][i] = 0; intensity_real[1][i] = 0; intensity_real[2][i] = 0; for ( j = brange[0]; j < brange[1]; j++ ) { real = Cldfb_RealBuffer[0][j]; img = Cldfb_ImagBuffer[0][j]; /* Intensity is XYZ order, audio is WYZX order. */ intensity_real[0][i] = L_add( intensity_real[0][i], L_add( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), Mpy_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); //output Q= 2* input_q -31 intensity_real[1][i] = L_add( intensity_real[1][i], L_add( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), Mpy_32_32( Cldfb_ImagBuffer[1][j], img ) ) );//output Q= 2* input_q -31 intensity_real[2][i] = L_add( intensity_real[2][i], L_add( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), Mpy_32_32( Cldfb_ImagBuffer[2][j], img ) ) );//output Q= 2* input_q -31 } } return; } #endif /*--------------------------------------------------------------------------* * computeIntensityVector_ana() * Loading Loading @@ -568,6 +613,47 @@ void computeIntensityVector_ana( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * computeReferencePower_ana() * * *--------------------------------------------------------------------------*/ void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ Word32 *reference_power, /* o : Estimated power */ const Word16 num_freq_bands /* i : Number of frequency bands */ ) { Word16 brange[2]; Word16 ch_idx, i, j; for ( i = 0; i < num_freq_bands; i++ ) { brange[0] = band_grouping[i]; brange[1] = band_grouping[i + 1]; reference_power[i] = 0; for ( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ ) { /* abs()^2 */ for ( j = brange[0]; j < brange[1]; j++ ) { //Q = 2*inputq - 31 reference_power[i] = L_add( L_add( Mpy_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Mpy_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) ), reference_power[i] ); } } } // v_multc( reference_power, 0.5f, reference_power, num_freq_bands ); /* Bypassing the v_multc ,so output q = 2*inputq - 30*/ return; } #endif /*--------------------------------------------------------------------------* * computeReferencePower_ana() Loading Loading
lib_com/ivas_dirac_com.c +178 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,96 @@ ivas_error ivas_dirac_sba_config( return error; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * computeDirectionVectors() * * *------------------------------------------------------------------------*/ void computeDirectionVectors_fx( Word32 *intensity_real_x, Word32 *intensity_real_y, Word32 *intensity_real_z, const Word16 enc_param_start_band, const Word16 num_frequency_bands, Word32 *direction_vector_x, Word32 *direction_vector_y, Word32 *direction_vector_z, Word16 *i_q /*input/output Q*/ ) { Word16 i; Word32 intensityNorm; Word16 sq = 31 - ( 2 * ( *i_q ) - 31 ); Word16 sq1 = ( 2 * ( *i_q ) - 31 ); Word16 exp = sq; Word16 local_i_q = sq1; Word16 min_factor = 30; Word32 *init_x = intensity_real_x; Word32 *init_y = intensity_real_y; Word32 *init_z = intensity_real_z; // First loop to determine the Q for the direction vector for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; if ( intensityNorm <= EPSILON_FX ) { intensity_real_x++; intensity_real_y++; intensity_real_z++; } else { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp intensity_real_x++; // i_q + Q31-exp -31 = i_q -exp intensity_real_y++; // i_q + Q31-exp -31 = i_q -exp intensity_real_z++; // i_q + Q31-exp-31 = i_q -exo local_i_q = *i_q - exp; min_factor = min( min_factor, local_i_q ); } } intensity_real_x = init_x; intensity_real_y = init_y; intensity_real_z = init_z; // Actual processing loop for the direction vector for ( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; ++i ) { intensityNorm = L_add( L_add( Mpy_32_32_r( *( intensity_real_x ), *( intensity_real_x ) ), Mpy_32_32_r( *( intensity_real_y ), *( intensity_real_y ) ) ), Mpy_32_32_r( *( intensity_real_z ), *( intensity_real_z ) ) ); /*Q (2*i_q - 31) */ exp = sq; if ( intensityNorm <= EPSILON_FX ) { intensityNorm = L_shl( 1, min_factor ); *( direction_vector_x++ ) = L_shl( 1, min_factor ); *( direction_vector_y++ ) = 0; *( direction_vector_z++ ) = 0; intensity_real_x++; intensity_real_y++; intensity_real_z++; } else { intensityNorm = ISqrt32( intensityNorm, &exp ); // Q31-exp Word32 temp = L_shr( Mpy_32_32( *( intensity_real_x++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_x++ ) = temp; // i_q + Q31-exp -31 = i_q -exp temp = L_shr( Mpy_32_32( *( intensity_real_y++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_y++ ) = temp; // i_q + Q31-exp -31 = i_q -exp temp = L_shr( Mpy_32_32( *( intensity_real_z++ ), intensityNorm ), ( *i_q - exp - min_factor ) ); *( direction_vector_z++ ) = temp; // i_q + Q31-exp-31 = i_q -exp } } *i_q = min_factor; return; } #endif /*------------------------------------------------------------------------- * computeDirectionVectors() * Loading Loading @@ -927,7 +1017,95 @@ void computeDirectionVectors( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * computeDiffuseness() * * *------------------------------------------------------------------------*/ void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, const Word16 num_freq_bands, Word32 *diffuseness, Word16 q_factor_intensity, Word16 q_factor_energy, Word16 *out_exp /*Ouput Q*/ ) { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0, tmp_1; Word32 *p_tmp; const Word32 *p_tmp_c; /* Compute Intensity slow and energy slow */ set_val_Word32( intensity_slow, 0, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ); set_val_Word32( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX ); set_val_Word32( energy_slow, 0, CLDFB_NO_CHANNELS_MAX ); for ( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; for ( k = 0; k < num_freq_bands; k++ ) { energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy) } /* Intensity slow */ for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; for ( k = 0; k < num_freq_bands; k++ ) { intensity_slow[j * num_freq_bands + k] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] ); } } } /* intensity_slow.^2 + intensity_slow_abs*/ for ( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = intensity_slow + j * num_freq_bands; for ( k = 0; k < num_freq_bands; k++ ) { *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 ) intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] ); } } Word16 init_exp = 31 - (( 2 * ( q_factor_intensity ) ) - 31),exp; Word16 exp1 = 0, exp2; /* Compute Diffuseness */ p_tmp = intensity_slow_abs; for ( i = 0; i < num_freq_bands; ++i ) { exp = init_exp; Word32 temp = *( p_tmp++ ); tmp_1 = Sqrt32( temp, &exp ); tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i],1 ), &exp1 ) ); exp2 = 31 - exp1 + (31- exp - q_factor_energy ); if ( exp2 > 30 ) { tmp = L_shr( tmp, ( exp2 - 30 ) ); exp2 -= ( exp2 - 30 ); } tmp = L_sub( L_shl( 1, exp2 ), tmp ); diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) ); out_exp[i] = exp2; } return; } #endif /*------------------------------------------------------------------------- * computeDiffuseness() Loading
lib_com/ivas_prot.h +25 −1 Original line number Diff line number Diff line Loading @@ -3962,7 +3962,19 @@ void computeDiffuseness_mdft( const uint16_t no_col_avg_diff, float *diffuseness ); #ifdef IVAS_FLOAT_FIXED void computeDirectionVectors_fx( Word32 *intensity_real_x, Word32 *intensity_real_y, Word32 *intensity_real_z, const Word16 enc_param_start_band, const Word16 num_frequency_bands, Word32 *direction_vector_x, Word32 *direction_vector_y, Word32 *direction_vector_z , Word16 *q_factor ); #endif void computeDirectionVectors( float *intensity_real_x, float *intensity_real_y, Loading @@ -3981,7 +3993,19 @@ void computeDiffuseness( float *diffuseness ); #ifdef IVAS_FLOAT_FIXED void computeDiffuseness_fx( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, const Word16 num_freq_bands, Word32 *diffuseness , Word16 q_factor_intensity, Word16 q_factor_energy, Word16 *out_exp ); #endif void ivas_dirac_dec_get_response( const int16_t azimuth, const int16_t elevation, Loading
lib_rend/ivas_dirac_ana.c +387 −5 File changed.Preview size limit exceeded, changes collapsed. Show changes
lib_rend/ivas_mcmasa_ana.c +90 −2 Original line number Diff line number Diff line Loading @@ -41,7 +41,9 @@ #include "ivas_stat_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif /*------------------------------------------------------------------------- * Local constants Loading Loading @@ -1048,6 +1050,92 @@ static void computeEvenLayout( return; } #ifdef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------- * ivas_create_masa_out_meta() * * *------------------------------------------------------------------------*/ void ivas_create_masa_out_meta_fx( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: MASA metadata handle */ SPHERICAL_GRID_DATA *Sph_Grid16, /* i : Spherical grid */ const Word16 nchan_transport, /* i : Number of transport channels */ Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated elevation */ Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated azimuth */ Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated direct-to-total ratio */ Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated spread coherence */ Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Estimated surround coherence */ Word16 energyRatio_q, Word16 spreadCoherence_q, Word16 surroundingCoherence_q ) { const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ int16_t i, sf, band; uint8_t numFrequencyBands; uint8_t numDirections; uint16_t spherical_index; numDirections = 1; numFrequencyBands = MASA_FREQUENCY_BANDS; /* Construct descriptive meta */ for ( i = 0; i < 8; i++ ) { extOutMeta->descriptiveMeta.formatDescriptor[i] = ivasmasaFormatDescriptor[i]; } extOutMeta->descriptiveMeta.numberOfDirections = numDirections - 1; extOutMeta->descriptiveMeta.numberOfChannels = (uint8_t) ( nchan_transport - 1 ); /* Following correspond to "unknown" values */ extOutMeta->descriptiveMeta.sourceFormat = 0x0u; extOutMeta->descriptiveMeta.transportDefinition = 0x0u; extOutMeta->descriptiveMeta.channelAngle = 0x0u; extOutMeta->descriptiveMeta.channelDistance = 0x0u; extOutMeta->descriptiveMeta.channelLayout = 0x0u; /* Construct spatial metadata from estimated values */ for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { /* Spherical index */ for ( band = 0; band < numFrequencyBands; band++ ) { spherical_index = index_theta_phi_16_fx( &elevation_m_values[sf][band], &azimuth_m_values[sf][band], Sph_Grid16 ); extOutMeta->directionIndex[0][sf][band] = spherical_index; extOutMeta->directionIndex[1][sf][band] = SPH_IDX_FRONT; } /* Direct-to-total ratio */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->directToTotalRatio[0][sf][band] = (uint8_t) L_shr( energyRatio[sf][band], energyRatio_q - 8 ); extOutMeta->directToTotalRatio[1][sf][band] = 0; } /* Spread coherence */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->spreadCoherence[0][sf][band] = (uint8_t) L_shr( spreadCoherence[sf][band], spreadCoherence_q - 8 ); extOutMeta->spreadCoherence[1][sf][band] = 0; } /* Diffuse-to-total ratio = 1 - sum(direct-to-total ratios) */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->diffuseToTotalRatio[sf][band] = UINT8_MAX - (uint8_t) L_shr( energyRatio[sf][band], energyRatio_q - 8 ); } /* Surround coherence */ for ( band = 0; band < numFrequencyBands; band++ ) { extOutMeta->surroundCoherence[sf][band] = (uint8_t) L_shr( surroundingCoherence[sf][band], surroundingCoherence_q - 8 ); } } return; } #endif /*------------------------------------------------------------------------- * ivas_create_masa_out_meta() Loading
lib_rend/ivas_omasa_ana.c +87 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,52 @@ static void ivas_omasa_dmx( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * computeIntensityVector_ana() * * *--------------------------------------------------------------------------*/ void computeIntensityVector_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ const Word16 num_frequency_bands, /* i : Number of frequency bands */ Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector */ ) { /* Reminder * X = a + ib; Y = c + id * X*Y = ac - bd + i(ad +bc) */ Word16 i, j; Word32 real, img; Word16 brange[2]; for ( i = 0; i < num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; brange[1] = band_grouping[i + 1]; intensity_real[0][i] = 0; intensity_real[1][i] = 0; intensity_real[2][i] = 0; for ( j = brange[0]; j < brange[1]; j++ ) { real = Cldfb_RealBuffer[0][j]; img = Cldfb_ImagBuffer[0][j]; /* Intensity is XYZ order, audio is WYZX order. */ intensity_real[0][i] = L_add( intensity_real[0][i], L_add( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), Mpy_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); //output Q= 2* input_q -31 intensity_real[1][i] = L_add( intensity_real[1][i], L_add( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), Mpy_32_32( Cldfb_ImagBuffer[1][j], img ) ) );//output Q= 2* input_q -31 intensity_real[2][i] = L_add( intensity_real[2][i], L_add( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), Mpy_32_32( Cldfb_ImagBuffer[2][j], img ) ) );//output Q= 2* input_q -31 } } return; } #endif /*--------------------------------------------------------------------------* * computeIntensityVector_ana() * Loading Loading @@ -568,6 +613,47 @@ void computeIntensityVector_ana( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------------------* * computeReferencePower_ana() * * *--------------------------------------------------------------------------*/ void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ Word32 *reference_power, /* o : Estimated power */ const Word16 num_freq_bands /* i : Number of frequency bands */ ) { Word16 brange[2]; Word16 ch_idx, i, j; for ( i = 0; i < num_freq_bands; i++ ) { brange[0] = band_grouping[i]; brange[1] = band_grouping[i + 1]; reference_power[i] = 0; for ( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ ) { /* abs()^2 */ for ( j = brange[0]; j < brange[1]; j++ ) { //Q = 2*inputq - 31 reference_power[i] = L_add( L_add( Mpy_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Mpy_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) ), reference_power[i] ); } } } // v_multc( reference_power, 0.5f, reference_power, num_freq_bands ); /* Bypassing the v_multc ,so output q = 2*inputq - 30*/ return; } #endif /*--------------------------------------------------------------------------* * computeReferencePower_ana() Loading