Loading lib_util/ambi_convert.c +47 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include <stdint.h> #include <assert.h> #include <stdio.h> #include "ambi_convert.h" #define L_FRAME48k 960 Loading Loading @@ -123,15 +124,24 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); float tmp[AMBI_MAX_CHANNELS*L_FRAME48k]; float *p_tmp[AMBI_MAX_CHANNELS]; AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN, ch_ord_out = AMBI_NORM_SN3D; AMBI_CHANNEL_NORM ch_norm_in = AMBI_CHANNEL_ORDER_ACN, ch_norm_out = AMBI_NORM_SN3D; assert( order <= 3 ); if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } for(int16_t j=0;j<AMBI_MAX_CHANNELS;j++) { p_tmp[j]=&tmp[j*L_FRAME48k]; } switch ( in_format ) { case AMBI_FMT_ACN_SN3D: Loading Loading @@ -194,13 +204,47 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT if ( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ); } #if 0 { static FILE* f_foa = 0; if (f_foa == 0) f_foa = fopen("renorm.raw","wb"); for (int16_t j=0; j < 960;j++) { for ( int n = 0; n < 16; n++) { int16_t s1 = out[n][j]; fwrite(&s1,sizeof(int16_t),1,f_foa); } } } #endif if ( ch_ord_in != ch_ord_out ) { reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ); } #if 0 { static FILE* f_foa = 0; if (f_foa == 0) f_foa = fopen("reorder.raw","wb"); for (int16_t j=0; j < 960;j++) { for ( int n = 0; n < 16; n++) { int16_t s1 = out[n][j]; fwrite(&s1,sizeof(int16_t),1,f_foa); } } } #endif if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { Loading Loading
lib_util/ambi_convert.c +47 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include <stdint.h> #include <assert.h> #include <stdio.h> #include "ambi_convert.h" #define L_FRAME48k 960 Loading Loading @@ -123,15 +124,24 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); float tmp[AMBI_MAX_CHANNELS*L_FRAME48k]; float *p_tmp[AMBI_MAX_CHANNELS]; AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN, ch_ord_out = AMBI_NORM_SN3D; AMBI_CHANNEL_NORM ch_norm_in = AMBI_CHANNEL_ORDER_ACN, ch_norm_out = AMBI_NORM_SN3D; assert( order <= 3 ); if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } for(int16_t j=0;j<AMBI_MAX_CHANNELS;j++) { p_tmp[j]=&tmp[j*L_FRAME48k]; } switch ( in_format ) { case AMBI_FMT_ACN_SN3D: Loading Loading @@ -194,13 +204,47 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT if ( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ); } #if 0 { static FILE* f_foa = 0; if (f_foa == 0) f_foa = fopen("renorm.raw","wb"); for (int16_t j=0; j < 960;j++) { for ( int n = 0; n < 16; n++) { int16_t s1 = out[n][j]; fwrite(&s1,sizeof(int16_t),1,f_foa); } } } #endif if ( ch_ord_in != ch_ord_out ) { reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ); } #if 0 { static FILE* f_foa = 0; if (f_foa == 0) f_foa = fopen("reorder.raw","wb"); for (int16_t j=0; j < 960;j++) { for ( int n = 0; n < 16; n++) { int16_t s1 = out[n][j]; fwrite(&s1,sizeof(int16_t),1,f_foa); } } } #endif if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { Loading