Loading lib_util/ambi_cenvert.c +65 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,16 @@ #define INV_SQRT_5 0.4472135f #define INV_SQRT_7 0.3779644f #define TWO_OVER_SQRT_3 1.1547005f #define SQRT_8_OVER_5 1.2649110f #define SQRT_3_OVER_5 0.7745966f #define SQRT_45_OVER_32 1.1858541f #define INV_TWO_OVER_SQRT_3 0.8660254f #define INV_SQRT_8_OVER_5 0.7905694f #define INV_SQRT_3_OVER_5 1.2909944f #define INV_SQRT_45_OVER_32 0.8432740f #define AMBI_MAX_CHANNELS 16 static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, Loading @@ -56,7 +66,16 @@ static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7 }; static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, TWO_OVER_SQRT_3, TWO_OVER_SQRT_3, 1, TWO_OVER_SQRT_3, TWO_OVER_SQRT_3, SQRT_8_OVER_5, SQRT_3_OVER_5, SQRT_45_OVER_32, 1, SQRT_45_OVER_32, SQRT_3_OVER_5, SQRT_8_OVER_5 }; static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, INV_TWO_OVER_SQRT_3, INV_TWO_OVER_SQRT_3, 1.0f, INV_TWO_OVER_SQRT_3, INV_TWO_OVER_SQRT_3, INV_SQRT_8_OVER_5, INV_SQRT_3_OVER_5, INV_SQRT_45_OVER_32, 1.0f, INV_SQRT_45_OVER_32, INV_SQRT_3_OVER_5, INV_SQRT_8_OVER_5 }; int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { Loading Loading @@ -122,10 +141,54 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ) { int16_t nchan = ( order + 1 ) * ( order + 1 ); int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; float *conversion_table; /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ if ( in_format == AMBI_NORM_SN3D ) { if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; } if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; } else { assert( 0 && "Unsupported conversion" ); } } else if ( out_format == AMBI_NORM_SN3D ) { if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; } if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; } else { assert( 0 && "Unsupported conversion" ); } } else { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ 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; } } return 0; } Loading Loading
lib_util/ambi_cenvert.c +65 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,16 @@ #define INV_SQRT_5 0.4472135f #define INV_SQRT_7 0.3779644f #define TWO_OVER_SQRT_3 1.1547005f #define SQRT_8_OVER_5 1.2649110f #define SQRT_3_OVER_5 0.7745966f #define SQRT_45_OVER_32 1.1858541f #define INV_TWO_OVER_SQRT_3 0.8660254f #define INV_SQRT_8_OVER_5 0.7905694f #define INV_SQRT_3_OVER_5 1.2909944f #define INV_SQRT_45_OVER_32 0.8432740f #define AMBI_MAX_CHANNELS 16 static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, Loading @@ -56,7 +66,16 @@ static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7 }; static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, TWO_OVER_SQRT_3, TWO_OVER_SQRT_3, 1, TWO_OVER_SQRT_3, TWO_OVER_SQRT_3, SQRT_8_OVER_5, SQRT_3_OVER_5, SQRT_45_OVER_32, 1, SQRT_45_OVER_32, SQRT_3_OVER_5, SQRT_8_OVER_5 }; static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, INV_TWO_OVER_SQRT_3, INV_TWO_OVER_SQRT_3, 1.0f, INV_TWO_OVER_SQRT_3, INV_TWO_OVER_SQRT_3, INV_SQRT_8_OVER_5, INV_SQRT_3_OVER_5, INV_SQRT_45_OVER_32, 1.0f, INV_SQRT_45_OVER_32, INV_SQRT_3_OVER_5, INV_SQRT_8_OVER_5 }; int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { Loading Loading @@ -122,10 +141,54 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ) { int16_t nchan = ( order + 1 ) * ( order + 1 ); int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; float *conversion_table; /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ if ( in_format == AMBI_NORM_SN3D ) { if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; } if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; } else { assert( 0 && "Unsupported conversion" ); } } else if ( out_format == AMBI_NORM_SN3D ) { if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; } if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; } else { assert( 0 && "Unsupported conversion" ); } } else { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ 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; } } return 0; } Loading