Loading lib_util/ambi_convert.c +27 −4 Original line number Diff line number Diff line Loading @@ -59,6 +59,15 @@ #define AMBI_MAX_CHANNELS 16 /* For conversions to SN3D we want to avoid clipping the decoder input. The GLOBAL_SCALING_FACTOR ensures that the amplitude is always attenuated. The inverse INV_GLOBAL_SCALING_FACTOR restores the original amplitude when converting back to the input convention after the decoding. */ #define GLOBAL_SCALING_FACTOR 0.7071067f #define INV_GLOBAL_SCALING_FACTOR 0.7071067f /* -------------------------------- normalization conversion tables -------------------------------- */ Loading Loading @@ -236,12 +245,26 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } if ( out_format == AMBI_NORM_SN3D ) { for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { float conversion_factor = conversion_table[i_chan]; for ( i = 0; i < L_FRAME48k; i++ ) { out[i_chan][i] = in[i_chan][i] * conversion_factor; out[i_chan][i] = GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; } } } else { for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { float conversion_factor = conversion_table[i_chan]; for ( i = 0; i < L_FRAME48k; i++ ) { out[i_chan][i] = INV_GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; } } } Loading Loading
lib_util/ambi_convert.c +27 −4 Original line number Diff line number Diff line Loading @@ -59,6 +59,15 @@ #define AMBI_MAX_CHANNELS 16 /* For conversions to SN3D we want to avoid clipping the decoder input. The GLOBAL_SCALING_FACTOR ensures that the amplitude is always attenuated. The inverse INV_GLOBAL_SCALING_FACTOR restores the original amplitude when converting back to the input convention after the decoding. */ #define GLOBAL_SCALING_FACTOR 0.7071067f #define INV_GLOBAL_SCALING_FACTOR 0.7071067f /* -------------------------------- normalization conversion tables -------------------------------- */ Loading Loading @@ -236,12 +245,26 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } if ( out_format == AMBI_NORM_SN3D ) { for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { float conversion_factor = conversion_table[i_chan]; for ( i = 0; i < L_FRAME48k; i++ ) { out[i_chan][i] = in[i_chan][i] * conversion_factor; out[i_chan][i] = GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; } } } else { for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { float conversion_factor = conversion_table[i_chan]; for ( i = 0; i < L_FRAME48k; i++ ) { out[i_chan][i] = INV_GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; } } } Loading