Loading lib_util/ambi_convert.c +67 −48 Original line number Diff line number Diff line Loading @@ -134,62 +134,81 @@ 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 ); AMBI_CHANNEL_ORDER ch_ord_in = 0, ch_ord_out = 0; AMBI_CHANNEL_NORM ch_norm_in = 0, ch_norm_out = 0; if ( in_format == AMBI_FMT_ACN_SN3D ) { if ( out_format == AMBI_FMT_ACN_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D ); } else if ( out_format == AMBI_FMT_FM_MAXN ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_MAXN ); reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM ); } else if ( out_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); } else if ( out_format == AMBI_FMT_SID_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D ); reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); } else { assert( 0 && "Unsupported conversion" ); } } else if ( out_format == AMBI_FMT_ACN_SN3D ) { if ( in_format == AMBI_FMT_ACN_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_N3D, AMBI_NORM_SN3D ); } else if ( in_format == AMBI_FMT_FM_MAXN ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_FM, AMBI_CHANNEL_ORDER_ACN ); renormalize_channels( in, out, order, AMBI_NORM_MAXN, AMBI_NORM_SN3D ); } else if ( in_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); } else if ( in_format == AMBI_FMT_SID_N3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); renormalize_channels( in, out, order, AMBI_NORM_N3D, AMBI_NORM_SN3D ); } else { assert( 0 && "Unsupported conversion" ); } } else if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } switch ( in_format ) { case AMBI_FMT_ACN_SN3D: ch_ord_in = AMBI_CHANNEL_ORDER_ACN; ch_norm_in = AMBI_NORM_SN3D; break; case AMBI_FMT_ACN_N3D: ch_ord_in = AMBI_CHANNEL_ORDER_ACN; ch_norm_in = AMBI_NORM_N3D; break; case AMBI_FMT_FM_MAXN: ch_ord_in = AMBI_CHANNEL_ORDER_FM; ch_norm_in = AMBI_NORM_MAXN; break; case AMBI_FMT_SID_SN3D: ch_ord_in = AMBI_CHANNEL_ORDER_SID; ch_norm_in = AMBI_NORM_SN3D; break; case AMBI_FMT_SID_N3D: ch_ord_in = AMBI_CHANNEL_ORDER_SID; ch_norm_in = AMBI_NORM_N3D; break; default: assert( 0 && "Unsupported in_format!" ); } switch ( out_format ) { case AMBI_FMT_ACN_SN3D: ch_ord_out = AMBI_CHANNEL_ORDER_ACN; ch_norm_out = AMBI_NORM_SN3D; break; case AMBI_FMT_ACN_N3D: ch_ord_out = AMBI_CHANNEL_ORDER_ACN; ch_norm_out = AMBI_NORM_N3D; break; case AMBI_FMT_FM_MAXN: ch_ord_out = AMBI_CHANNEL_ORDER_FM; ch_norm_in = AMBI_NORM_MAXN; break; case AMBI_FMT_SID_SN3D: ch_ord_out = AMBI_CHANNEL_ORDER_SID; ch_norm_out = AMBI_NORM_SN3D; break; case AMBI_FMT_SID_N3D: ch_ord_out = AMBI_CHANNEL_ORDER_SID; ch_norm_out = AMBI_NORM_N3D; break; default: assert( 0 && "Unsupported out_format!" ); } if ( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); } if ( ch_ord_in != ch_ord_out ) { reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); } if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); } return 0; } Loading Loading
lib_util/ambi_convert.c +67 −48 Original line number Diff line number Diff line Loading @@ -134,62 +134,81 @@ 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 ); AMBI_CHANNEL_ORDER ch_ord_in = 0, ch_ord_out = 0; AMBI_CHANNEL_NORM ch_norm_in = 0, ch_norm_out = 0; if ( in_format == AMBI_FMT_ACN_SN3D ) { if ( out_format == AMBI_FMT_ACN_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D ); } else if ( out_format == AMBI_FMT_FM_MAXN ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_MAXN ); reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM ); } else if ( out_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); } else if ( out_format == AMBI_FMT_SID_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D ); reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); } else { assert( 0 && "Unsupported conversion" ); } } else if ( out_format == AMBI_FMT_ACN_SN3D ) { if ( in_format == AMBI_FMT_ACN_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_N3D, AMBI_NORM_SN3D ); } else if ( in_format == AMBI_FMT_FM_MAXN ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_FM, AMBI_CHANNEL_ORDER_ACN ); renormalize_channels( in, out, order, AMBI_NORM_MAXN, AMBI_NORM_SN3D ); } else if ( in_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); } else if ( in_format == AMBI_FMT_SID_N3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); renormalize_channels( in, out, order, AMBI_NORM_N3D, AMBI_NORM_SN3D ); } else { assert( 0 && "Unsupported conversion" ); } } else if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) { assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } switch ( in_format ) { case AMBI_FMT_ACN_SN3D: ch_ord_in = AMBI_CHANNEL_ORDER_ACN; ch_norm_in = AMBI_NORM_SN3D; break; case AMBI_FMT_ACN_N3D: ch_ord_in = AMBI_CHANNEL_ORDER_ACN; ch_norm_in = AMBI_NORM_N3D; break; case AMBI_FMT_FM_MAXN: ch_ord_in = AMBI_CHANNEL_ORDER_FM; ch_norm_in = AMBI_NORM_MAXN; break; case AMBI_FMT_SID_SN3D: ch_ord_in = AMBI_CHANNEL_ORDER_SID; ch_norm_in = AMBI_NORM_SN3D; break; case AMBI_FMT_SID_N3D: ch_ord_in = AMBI_CHANNEL_ORDER_SID; ch_norm_in = AMBI_NORM_N3D; break; default: assert( 0 && "Unsupported in_format!" ); } switch ( out_format ) { case AMBI_FMT_ACN_SN3D: ch_ord_out = AMBI_CHANNEL_ORDER_ACN; ch_norm_out = AMBI_NORM_SN3D; break; case AMBI_FMT_ACN_N3D: ch_ord_out = AMBI_CHANNEL_ORDER_ACN; ch_norm_out = AMBI_NORM_N3D; break; case AMBI_FMT_FM_MAXN: ch_ord_out = AMBI_CHANNEL_ORDER_FM; ch_norm_in = AMBI_NORM_MAXN; break; case AMBI_FMT_SID_SN3D: ch_ord_out = AMBI_CHANNEL_ORDER_SID; ch_norm_out = AMBI_NORM_SN3D; break; case AMBI_FMT_SID_N3D: ch_ord_out = AMBI_CHANNEL_ORDER_SID; ch_norm_out = AMBI_NORM_N3D; break; default: assert( 0 && "Unsupported out_format!" ); } if ( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); } if ( ch_ord_in != ch_ord_out ) { reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); } if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); } return 0; } Loading