From ad1a2a99b12f0f550b67d794592ec207ce0ed9d6 Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Wed, 14 Jun 2023 07:44:25 +0200 Subject: [PATCH 1/6] Issue 549: Downmix energy compensation for ParamISM to raise output levels. --- lib_com/ivas_ism_com.c | 4 ++ lib_com/ivas_stat_com.h | 5 ++ lib_com/options.h | 2 + lib_dec/ivas_ism_param_dec.c | 94 ++++++++++++++++++++++++++++++++++++ lib_enc/ivas_ism_param_enc.c | 88 +++++++++++++++++++++++++++++++++ 5 files changed, 193 insertions(+) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index a28fb77d20..b3b2f71694 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -483,6 +483,10 @@ void ivas_param_ism_config( hParamIsm->last_el_sgn[i] = 1; } +#ifdef FIX_549_DMX_GAIN + hParamIsm->last_dmx_gain = 1.0f; + set_f( hParamIsm->last_cardioid_left, 1.0f, MAX_NUM_OBJECTS ); +#endif return; } diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 43b7adcc7c..1a65dc149f 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -169,6 +169,11 @@ typedef struct ivas_param_ism_data_structure int16_t noisy_speech_buffer[PARAM_ISM_HYS_BUF_SIZE]; int16_t flag_equal_energy; +#ifdef FIX_549_DMX_GAIN + float last_dmx_gain; + float last_cardioid_left[MAX_NUM_OBJECTS]; +#endif + } PARAM_ISM_CONFIG_DATA, *PARAM_ISM_CONFIG_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index aafa43e9af..d69ec7ae94 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -185,6 +185,8 @@ #define FIX_528_ISM_MD_FILE_TOO_SHORT /* VA: issue 528: ISM Metadata file too short */ +#define FIX_549_DMX_GAIN /* FhG: issue 549: ParamISM output too quiet */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 36e8516e29..fecc661b11 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -729,6 +729,11 @@ void ivas_param_ism_dec( int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t subframe_idx, slot_idx, index_slot, bin_idx; int32_t ivas_total_brate; +#ifdef FIX_549_DMX_GAIN + int16_t output_frame; + float gain, ene_tc, ene_sum, grad; + float *last_gain; +#endif float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* CLDFB Input Buffers */ @@ -752,6 +757,12 @@ void ivas_param_ism_dec( /* Initialization */ hDirAC = st_ivas->hDirAC; assert( hDirAC ); +#ifdef FIX_549_DMX_GAIN + ene_tc = 0.0f; + ene_sum = 0.0f; + last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); + output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif nchan_transport = st_ivas->nchan_transport; if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_EXTERNAL ) @@ -835,6 +846,42 @@ void ivas_param_ism_dec( } } +#ifdef FIX_549_DMX_GAIN + /* Energy Compensation */ + for ( i = 0; i < output_frame; i++ ) + { + ene_tc += output_f[0][i] * output_f[0][i] + output_f[1][i] * output_f[1][i]; // L*L + R*R + ene_sum += ( output_f[0][i] + output_f[1][i] ) * ( output_f[0][i] + output_f[1][i] ); // (L+R)*(L+R) + } + gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) + { + /* Smoothing */ + gain = 0.75f * gain + 0.25f * *( last_gain ); + /* 10ms ramp */ + grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */ + for ( i = 0; i < ( output_frame / 2 ); i++ ) + { + output_f[0][i] *= ( *( last_gain ) + i * grad ); + output_f[1][i] *= ( *( last_gain ) + i * grad ); + } + for ( ; i < output_frame; i++ ) + { + output_f[0][i] *= gain; + output_f[1][i] *= gain; + } + } + else + { + for ( i = 0; i < output_frame; i++ ) + { + output_f[0][i] *= gain; + output_f[1][i] *= gain; + } + } + *( last_gain ) = gain; +#endif + for ( ch = 0; ch < nchan_transport; ch++ ) { /*-----------------------------------------------------------------* @@ -1055,6 +1102,11 @@ void ivas_param_ism_dec_digest_tc( int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; int16_t slot_idx, bin_idx; int32_t ivas_total_brate; +#ifdef FIX_549_DMX_GAIN + int16_t output_frame; + float gain, ene_tc, ene_sum, grad; + float *last_gain; +#endif float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ @@ -1064,6 +1116,12 @@ void ivas_param_ism_dec_digest_tc( /* Initialization */ hDirAC = st_ivas->hDirAC; assert( hDirAC ); +#ifdef FIX_549_DMX_GAIN + ene_tc = 0.0f; + ene_sum = 0.0f; + last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); + output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); +#endif nchan_transport = st_ivas->nchan_transport; ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; @@ -1150,6 +1208,42 @@ void ivas_param_ism_dec_digest_tc( } } +#ifdef FIX_549_DMX_GAIN + /* Energy Compensation */ + for ( i = 0; i < output_frame; i++ ) + { + ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R + ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * (transport_channels_f[0][i] + transport_channels_f[1][i] ); // (L+R)*(L+R) + } + gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) + { + /* Smoothing */ + gain = 0.75f * gain + 0.25f * *( last_gain ); + /* 10ms ramp */ + grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */ + for ( i = 0; i < ( output_frame / 2 ); i++ ) + { + transport_channels_f[0][i] *= ( *( last_gain ) + i * grad ); + transport_channels_f[1][i] *= ( *( last_gain ) + i * grad ); + } + for ( ; i < output_frame; i++ ) + { + transport_channels_f[0][i] *= gain; + transport_channels_f[1][i] *= gain; + } + } + else + { + for ( i = 0; i < output_frame; i++ ) + { + transport_channels_f[0][i] *= gain; + transport_channels_f[1][i] *= gain; + } + } + *( last_gain ) = gain; +#endif + for ( ch = 0; ch < nchan_transport; ch++ ) { /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 7565bdcae6..a3d149a644 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -222,6 +222,11 @@ void ivas_param_ism_stereo_dmx( float alpha, azi_shift, tmp, tmp_1; float cardioid_left[MAX_NUM_OBJECTS], cardioid_right[MAX_NUM_OBJECTS]; float stereo_dmx[2][L_FRAME48k]; +#ifdef FIX_549_DMX_GAIN + float dmx_gain, ene_dmx, ene_data, grad; + float *last_dmx_gain; + float *last_cardioid_left; +#endif ISM_METADATA_HANDLE hIsmMetaData; push_wmops( "ivas_param_ism_st_dmx" ); @@ -229,6 +234,13 @@ void ivas_param_ism_stereo_dmx( /*Initialization*/ alpha = 0.5; azi_shift = 0; +#ifdef FIX_549_DMX_GAIN + dmx_gain = 0; + ene_dmx = 0; + ene_data = 0; + last_dmx_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); + last_cardioid_left = &( st_ivas->hDirAC->hParamIsm->last_cardioid_left[0] ); +#endif /* Set the stereo dmx to zero */ set_zero( stereo_dmx[0], L_FRAME48k ); @@ -243,6 +255,7 @@ void ivas_param_ism_stereo_dmx( tmp = hIsmMetaData->azimuth * ( EVS_PI / 180 ); tmp_1 = ( EVS_PI / 2 ) + azi_shift; cardioid_left[i] = alpha + ( 1 - alpha ) * cosf( tmp - tmp_1 ); +#ifndef FIX_549_DMX_GAIN cardioid_right[i] = alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); /* Loop over all samples */ @@ -252,8 +265,83 @@ void ivas_param_ism_stereo_dmx( stereo_dmx[0][j] += cardioid_left[i] * tmp; /* DMX Left */ stereo_dmx[1][j] += cardioid_right[i] * tmp; /* DMX Right */ } +#else + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) + { + /* Smoothing */ + cardioid_left[i] = 0.75f * cardioid_left[i] + 0.25f * *( last_cardioid_left ); + grad = ( cardioid_left[i] - *( last_cardioid_left ) ) * 2.0f / input_frame; /* for the right cardioid, multiply with -1 */ + /* Cardioids sum up to 1 */ + cardioid_right[i] = 1.0f - cardioid_left[i]; /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */ + /* Loop over all samples */ + for ( j = 0; j < input_frame / 2; j++ ) + { + float last_cardioid_right; + last_cardioid_right = 1.0f - *( last_cardioid_left ); + tmp = data[i][j]; + stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp ); /* DMX Left */ + stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1 ) ) * tmp ); /* DMX Right */ + } + for ( ; j < input_frame; j++ ) + { + tmp = data[i][j]; + stereo_dmx[0][j] += cardioid_left[i] * tmp; /* DMX Left */ + stereo_dmx[1][j] += cardioid_right[i] * tmp; /* DMX Right */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ + } + } + else + { + /* Cardioids sum up to 1 */ + cardioid_right[i] = 1.0f - cardioid_left[i]; /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */ + /* Loop over all samples */ + for ( j = 0; j < input_frame; j++ ) + { + tmp = data[i][j]; + stereo_dmx[0][j] += cardioid_left[i] * tmp; /* DMX Left */ + stereo_dmx[1][j] += cardioid_right[i] * tmp; /* DMX Right */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ + } + } + *( last_cardioid_left ) = cardioid_left[i]; + last_cardioid_left++; +#endif } +#ifdef FIX_549_DMX_GAIN + /* Energy compensation */ + for ( j = 0; j < input_frame; j++ ) + { + ene_dmx += stereo_dmx[0][j] * stereo_dmx[0][j] + stereo_dmx[1][j] * stereo_dmx[1][j]; + } + dmx_gain = sqrtf( ene_data / ( ene_dmx + EPSILON ) ); + /* Smoothing */ + if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) + { + dmx_gain = 0.75f * dmx_gain + 0.25f * *( last_dmx_gain ); + /* 10ms ramp */ + grad = ( dmx_gain - *( last_dmx_gain ) ) * 2.0f / input_frame; /* slope between two consecutive gains, 480 samples length */ + for ( i = 0; i < ( input_frame / 2 ); i++ ) + { + stereo_dmx[0][i] *= ( *( last_dmx_gain ) + i * grad ); + stereo_dmx[1][i] *= ( *( last_dmx_gain ) + i * grad ); + } + for ( ; i < input_frame; i++ ) + { + stereo_dmx[0][i] *= dmx_gain; + stereo_dmx[1][i] *= dmx_gain; + } + } + else + { + for ( j = 0; j < input_frame; j++ ) + { + stereo_dmx[0][j] *= dmx_gain; + stereo_dmx[1][j] *= dmx_gain; + } + } + *( last_dmx_gain ) = dmx_gain; +#endif /* Copy the stereo dmx to data variable */ mvr2r( stereo_dmx[0], data[0], input_frame ); mvr2r( stereo_dmx[1], data[1], input_frame ); -- GitLab From dbdb3028a0cc8bdee49c53adbe54ffda13e6d7ec Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Wed, 14 Jun 2023 10:14:30 +0200 Subject: [PATCH 2/6] Add missing line of code (incomplete energy summation). --- lib_enc/ivas_ism_param_enc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index a3d149a644..6f7ffd8c3f 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -281,6 +281,7 @@ void ivas_param_ism_stereo_dmx( tmp = data[i][j]; stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp ); /* DMX Left */ stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1 ) ) * tmp ); /* DMX Right */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ } for ( ; j < input_frame; j++ ) { -- GitLab From 8a580f7d8897e274154763dc574fc9d2ac2e3560 Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Wed, 14 Jun 2023 14:50:07 +0200 Subject: [PATCH 3/6] Clang format --- lib_dec/ivas_ism_param_dec.c | 6 +++--- lib_enc/ivas_ism_param_enc.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index fecc661b11..bbef9e7b4d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -850,7 +850,7 @@ void ivas_param_ism_dec( /* Energy Compensation */ for ( i = 0; i < output_frame; i++ ) { - ene_tc += output_f[0][i] * output_f[0][i] + output_f[1][i] * output_f[1][i]; // L*L + R*R + ene_tc += output_f[0][i] * output_f[0][i] + output_f[1][i] * output_f[1][i]; // L*L + R*R ene_sum += ( output_f[0][i] + output_f[1][i] ) * ( output_f[0][i] + output_f[1][i] ); // (L+R)*(L+R) } gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); @@ -1212,8 +1212,8 @@ void ivas_param_ism_dec_digest_tc( /* Energy Compensation */ for ( i = 0; i < output_frame; i++ ) { - ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R - ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * (transport_channels_f[0][i] + transport_channels_f[1][i] ); // (L+R)*(L+R) + ene_tc += transport_channels_f[0][i] * transport_channels_f[0][i] + transport_channels_f[1][i] * transport_channels_f[1][i]; // L*L + R*R + ene_sum += ( transport_channels_f[0][i] + transport_channels_f[1][i] ) * ( transport_channels_f[0][i] + transport_channels_f[1][i] ); // (L+R)*(L+R) } gain = sqrtf( ene_tc / ( ene_sum + EPSILON ) ); if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index 6f7ffd8c3f..fe0b5d33a5 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -279,16 +279,16 @@ void ivas_param_ism_stereo_dmx( float last_cardioid_right; last_cardioid_right = 1.0f - *( last_cardioid_left ); tmp = data[i][j]; - stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp ); /* DMX Left */ + stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp ); /* DMX Left */ stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1 ) ) * tmp ); /* DMX Right */ - ene_data += ( tmp * tmp ); /* energy of all objects combined */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ } for ( ; j < input_frame; j++ ) { tmp = data[i][j]; stereo_dmx[0][j] += cardioid_left[i] * tmp; /* DMX Left */ stereo_dmx[1][j] += cardioid_right[i] * tmp; /* DMX Right */ - ene_data += ( tmp * tmp ); /* energy of all objects combined */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ } } else @@ -301,7 +301,7 @@ void ivas_param_ism_stereo_dmx( tmp = data[i][j]; stereo_dmx[0][j] += cardioid_left[i] * tmp; /* DMX Left */ stereo_dmx[1][j] += cardioid_right[i] * tmp; /* DMX Right */ - ene_data += ( tmp * tmp ); /* energy of all objects combined */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ } } *( last_cardioid_left ) = cardioid_left[i]; -- GitLab From 21ca6bb2586cabd464d8f0fe617f4f5a24ac3817 Mon Sep 17 00:00:00 2001 From: Andrea Eichenseer Date: Thu, 15 Jun 2023 12:29:10 +0200 Subject: [PATCH 4/6] Re-add comment. --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 96dc4c580d..6e31fe6104 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,7 +154,7 @@ // #define FIX_532_ISM_MD_INACTIVE /* VA: issue 532: improve MD coding in ISM inactive frames */ #define FIX_547_NAN_IGF_DEC /* FhG: issue 547: fix possible nan in IGF decoder */ -#define FIX_549_DMX_GAIN +#define FIX_549_DMX_GAIN /* FhG: issue 549: ParamISM output too quiet */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ -- GitLab From 85d74a0440e1fcfd78f73e898738abe6f6607834 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 19 Jun 2023 09:41:08 +0200 Subject: [PATCH 5/6] small code beutifications --- lib_dec/ivas_ism_param_dec.c | 28 +++++++++++++------------- lib_enc/ivas_ism_param_enc.c | 38 ++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 10fc5c8822..e6748a988b 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -716,7 +716,7 @@ void ivas_param_ism_dec( #ifdef FIX_549_DMX_GAIN int16_t output_frame; float gain, ene_tc, ene_sum, grad; - float *last_gain; + float last_gain; #endif float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; @@ -744,7 +744,7 @@ void ivas_param_ism_dec( #ifdef FIX_549_DMX_GAIN ene_tc = 0.0f; ene_sum = 0.0f; - last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); + last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #endif @@ -841,13 +841,13 @@ void ivas_param_ism_dec( if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) { /* Smoothing */ - gain = 0.75f * gain + 0.25f * *( last_gain ); + gain = 0.75f * gain + 0.25f * last_gain; /* 10ms ramp */ - grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */ + grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( output_frame / 2 ); i++ ) { - output_f[0][i] *= ( *( last_gain ) + i * grad ); - output_f[1][i] *= ( *( last_gain ) + i * grad ); + output_f[0][i] *= ( last_gain + i * grad ); + output_f[1][i] *= ( last_gain + i * grad ); } for ( ; i < output_frame; i++ ) { @@ -863,7 +863,7 @@ void ivas_param_ism_dec( output_f[1][i] *= gain; } } - *( last_gain ) = gain; + st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain; #endif for ( ch = 0; ch < nchan_transport; ch++ ) @@ -1084,7 +1084,7 @@ void ivas_param_ism_dec_digest_tc( #ifdef FIX_549_DMX_GAIN int16_t output_frame; float gain, ene_tc, ene_sum, grad; - float *last_gain; + float last_gain; #endif float ref_power[CLDFB_NO_CHANNELS_MAX]; float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; @@ -1098,7 +1098,7 @@ void ivas_param_ism_dec_digest_tc( #ifdef FIX_549_DMX_GAIN ene_tc = 0.0f; ene_sum = 0.0f; - last_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); + last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain ; output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #endif @@ -1198,13 +1198,13 @@ void ivas_param_ism_dec_digest_tc( if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) { /* Smoothing */ - gain = 0.75f * gain + 0.25f * *( last_gain ); + gain = 0.75f * gain + 0.25f * last_gain ; /* 10ms ramp */ - grad = ( gain - *( last_gain ) ) * 2.0f / output_frame; /* slope between two consecutive gains, 480 samples length */ + grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( output_frame / 2 ); i++ ) { - transport_channels_f[0][i] *= ( *( last_gain ) + i * grad ); - transport_channels_f[1][i] *= ( *( last_gain ) + i * grad ); + transport_channels_f[0][i] *= ( last_gain + i * grad ); + transport_channels_f[1][i] *= ( last_gain + i * grad ); } for ( ; i < output_frame; i++ ) { @@ -1220,7 +1220,7 @@ void ivas_param_ism_dec_digest_tc( transport_channels_f[1][i] *= gain; } } - *( last_gain ) = gain; + st_ivas->hDirAC->hParamIsm->last_dmx_gain = gain; #endif for ( ch = 0; ch < nchan_transport; ch++ ) diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c index fe0b5d33a5..c3d50d24db 100644 --- a/lib_enc/ivas_ism_param_enc.c +++ b/lib_enc/ivas_ism_param_enc.c @@ -224,8 +224,8 @@ void ivas_param_ism_stereo_dmx( float stereo_dmx[2][L_FRAME48k]; #ifdef FIX_549_DMX_GAIN float dmx_gain, ene_dmx, ene_data, grad; - float *last_dmx_gain; - float *last_cardioid_left; + float last_dmx_gain; + float last_cardioid_left; #endif ISM_METADATA_HANDLE hIsmMetaData; @@ -238,8 +238,7 @@ void ivas_param_ism_stereo_dmx( dmx_gain = 0; ene_dmx = 0; ene_data = 0; - last_dmx_gain = &( st_ivas->hDirAC->hParamIsm->last_dmx_gain ); - last_cardioid_left = &( st_ivas->hDirAC->hParamIsm->last_cardioid_left[0] ); + last_dmx_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; #endif /* Set the stereo dmx to zero */ @@ -250,7 +249,9 @@ void ivas_param_ism_stereo_dmx( for ( i = 0; i < st_ivas->hEncoderConfig->nchan_ism; i++ ) { hIsmMetaData = st_ivas->hIsmMetaData[i]; - +#ifdef FIX_549_DMX_GAIN + last_cardioid_left = st_ivas->hDirAC->hParamIsm->last_cardioid_left[i]; +#endif /*Compute the Cardioids for the corresponding object direction */ tmp = hIsmMetaData->azimuth * ( EVS_PI / 180 ); tmp_1 = ( EVS_PI / 2 ) + azi_shift; @@ -268,20 +269,20 @@ void ivas_param_ism_stereo_dmx( #else if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) { + float last_cardioid_right; + last_cardioid_right = 1.0f - last_cardioid_left; /* Smoothing */ - cardioid_left[i] = 0.75f * cardioid_left[i] + 0.25f * *( last_cardioid_left ); - grad = ( cardioid_left[i] - *( last_cardioid_left ) ) * 2.0f / input_frame; /* for the right cardioid, multiply with -1 */ + cardioid_left[i] = 0.75f * cardioid_left[i] + 0.25f * last_cardioid_left; + grad = ( cardioid_left[i] - last_cardioid_left ) * 2.0f / (float) input_frame; /* for the right cardioid, multiply with -1 */ /* Cardioids sum up to 1 */ cardioid_right[i] = 1.0f - cardioid_left[i]; /* corresponds to: alpha + ( 1 - alpha ) * cosf( tmp + tmp_1 ); */ /* Loop over all samples */ for ( j = 0; j < input_frame / 2; j++ ) { - float last_cardioid_right; - last_cardioid_right = 1.0f - *( last_cardioid_left ); tmp = data[i][j]; - stereo_dmx[0][j] += ( ( *( last_cardioid_left ) + j * grad ) * tmp ); /* DMX Left */ - stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1 ) ) * tmp ); /* DMX Right */ - ene_data += ( tmp * tmp ); /* energy of all objects combined */ + stereo_dmx[0][j] += ( ( last_cardioid_left + j * grad ) * tmp ); /* DMX Left */ + stereo_dmx[1][j] += ( ( last_cardioid_right + j * grad * ( -1.0f ) ) * tmp ); /* DMX Right */ + ene_data += ( tmp * tmp ); /* energy of all objects combined */ } for ( ; j < input_frame; j++ ) { @@ -304,8 +305,7 @@ void ivas_param_ism_stereo_dmx( ene_data += ( tmp * tmp ); /* energy of all objects combined */ } } - *( last_cardioid_left ) = cardioid_left[i]; - last_cardioid_left++; + st_ivas->hDirAC->hParamIsm->last_cardioid_left[i] = cardioid_left[i]; #endif } @@ -319,13 +319,13 @@ void ivas_param_ism_stereo_dmx( /* Smoothing */ if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) { - dmx_gain = 0.75f * dmx_gain + 0.25f * *( last_dmx_gain ); + dmx_gain = 0.75f * dmx_gain + 0.25f * last_dmx_gain; /* 10ms ramp */ - grad = ( dmx_gain - *( last_dmx_gain ) ) * 2.0f / input_frame; /* slope between two consecutive gains, 480 samples length */ + grad = ( dmx_gain - last_dmx_gain ) * 2.0f / (float) input_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( input_frame / 2 ); i++ ) { - stereo_dmx[0][i] *= ( *( last_dmx_gain ) + i * grad ); - stereo_dmx[1][i] *= ( *( last_dmx_gain ) + i * grad ); + stereo_dmx[0][i] *= ( last_dmx_gain + i * grad ); + stereo_dmx[1][i] *= ( last_dmx_gain + i * grad ); } for ( ; i < input_frame; i++ ) { @@ -341,7 +341,7 @@ void ivas_param_ism_stereo_dmx( stereo_dmx[1][j] *= dmx_gain; } } - *( last_dmx_gain ) = dmx_gain; + st_ivas->hDirAC->hParamIsm->last_dmx_gain = dmx_gain; #endif /* Copy the stereo dmx to data variable */ mvr2r( stereo_dmx[0], data[0], input_frame ); -- GitLab From efe550d94ff31cf0f5bc39bc486210950dca3216 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Mon, 19 Jun 2023 09:52:34 +0200 Subject: [PATCH 6/6] clang-format --- lib_dec/ivas_ism_param_dec.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index e6748a988b..2497f5ab98 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -843,11 +843,11 @@ void ivas_param_ism_dec( /* Smoothing */ gain = 0.75f * gain + 0.25f * last_gain; /* 10ms ramp */ - grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ + grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( output_frame / 2 ); i++ ) { - output_f[0][i] *= ( last_gain + i * grad ); - output_f[1][i] *= ( last_gain + i * grad ); + output_f[0][i] *= ( last_gain + i * grad ); + output_f[1][i] *= ( last_gain + i * grad ); } for ( ; i < output_frame; i++ ) { @@ -1098,7 +1098,7 @@ void ivas_param_ism_dec_digest_tc( #ifdef FIX_549_DMX_GAIN ene_tc = 0.0f; ene_sum = 0.0f; - last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain ; + last_gain = st_ivas->hDirAC->hParamIsm->last_dmx_gain; output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); #endif @@ -1198,13 +1198,13 @@ void ivas_param_ism_dec_digest_tc( if ( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 ) { /* Smoothing */ - gain = 0.75f * gain + 0.25f * last_gain ; + gain = 0.75f * gain + 0.25f * last_gain; /* 10ms ramp */ grad = ( gain - last_gain ) * 2.0f / (float) output_frame; /* slope between two consecutive gains, 480 samples length */ for ( i = 0; i < ( output_frame / 2 ); i++ ) { - transport_channels_f[0][i] *= ( last_gain + i * grad ); - transport_channels_f[1][i] *= ( last_gain + i * grad ); + transport_channels_f[0][i] *= ( last_gain + i * grad ); + transport_channels_f[1][i] *= ( last_gain + i * grad ); } for ( ; i < output_frame; i++ ) { -- GitLab