From 3447d9da1e7f4b8f175dfba8f4550dcd58c0e586 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 15 Mar 2024 16:55:44 +0100 Subject: [PATCH 001/130] add conversion functions for ambisonics input/output --- Workspace_msvc/lib_util.vcxproj | 2 + lib_util/ambi_cenvert.c | 90 +++++++++++++++++++++++++++++++++ lib_util/ambi_convert.h | 66 ++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 lib_util/ambi_cenvert.c create mode 100644 lib_util/ambi_convert.h diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 80e744c4f1..bd70056f36 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -100,6 +100,7 @@ + @@ -126,6 +127,7 @@ + diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c new file mode 100644 index 0000000000..711baba8d5 --- /dev/null +++ b/lib_util/ambi_cenvert.c @@ -0,0 +1,90 @@ +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "ivas_cnst.h" +#include "ambi_convert.h" + +int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) +{ + assert( order <= 3 ); + + 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 ); + reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM ); + } + 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 ( in_format == AMBI_FMT_ACN_N3D ) + { + } + else + { + assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + } + + return 0; +} + +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 ); + + return 0; +} + +int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) +{ + int16_t nchan = ( order + 1 ) * ( order + 1 ); + + return 0; +} diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h new file mode 100644 index 0000000000..c4ad6d234f --- /dev/null +++ b/lib_util/ambi_convert.h @@ -0,0 +1,66 @@ +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include + +typedef enum +{ + AMBI_FMT_ACN_SN3D = 0, + AMBI_FMT_ACN_N3D, + + AMBI_FMT_FM_MAXN, + + AMBI_FMT_SID_SN3D, + AMBI_FMT_SID_N3D +} AMBI_FMT; + +typedef enum +{ + AMBI_NORM_SN3D = 0, + AMBI_NORM_N3D = 1, + AMBI_NORM_MAXN = 2 +} AMBI_CHANNEL_NORM; + +typedef enum +{ + AMBI_CHANNEL_ORDER_ACN = 0, + AMBI_CHANNEL_ORDER_FM = 1, + AMBI_CHANNEL_ORDER_SID = 2 +} AMBI_CHANNEL_ORDER; + +int16_t convert_ambi_format(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format); + +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 reorder_channels(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format); + + -- GitLab From 635182b05d02adeb207f172cd4f08433aae7d678 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 10:40:18 +0100 Subject: [PATCH 002/130] re-order conversion options in convert_ambi_format --- lib_util/ambi_cenvert.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index 711baba8d5..327a4918bf 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -43,7 +43,6 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in if ( out_format == AMBI_FMT_ACN_N3D ) { renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_N3D ); - reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_FM ); } else if ( out_format == AMBI_FMT_FM_MAXN ) { @@ -64,8 +63,30 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in assert( 0 && "Unsupported conversion" ); } } - else if ( in_format == AMBI_FMT_ACN_N3D ) + 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 { -- GitLab From f612094a16e15a7ea9ebff4097f2984666f46343 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 10:59:07 +0100 Subject: [PATCH 003/130] insert arrays with conversion factors for N3D<->SN3D --- lib_util/ambi_cenvert.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index 327a4918bf..9d41035f0e 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -34,6 +34,30 @@ #include "ivas_cnst.h" #include "ambi_convert.h" +#define SQRT_3 1.7320508f +#define SQRT_5 2.2360679f +#define SQRT_7 2.64575131f + +#define INV_SQRT_3 0.5773502f +#define INV_SQRT_5 0.4472135f +#define INV_SQRT_7 0.3779644f + +#define AMBI_MAX_CHANNELS 16 + +static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, + SQRT_3, SQRT_3, SQRT_3, + SQRT_5, SQRT_5, SQRT_5, SQRT_5, SQRT_5, + SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7 +}; + +static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, + INV_SQRT_3, INV_SQRT_3, INV_SQRT_3, + INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, + INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7 +}; + + + int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); @@ -100,6 +124,9 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i { int16_t nchan = ( order + 1 ) * ( order + 1 ); + /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ + + return 0; } -- GitLab From 7cf0c276b11338e233b2180d9f76a66a7833cd61 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 11:36:15 +0100 Subject: [PATCH 004/130] add more conversion tables --- lib_util/ambi_cenvert.c | 67 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index 9d41035f0e..7fbd457809 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -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, @@ -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 ) { @@ -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; } -- GitLab From b0d818ec57a1977463e66734c3c9f02ae8b6c558 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 11:59:09 +0100 Subject: [PATCH 005/130] add channel re-ordering tables --- lib_util/ambi_cenvert.c | 79 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index 7fbd457809..8cd0e46235 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -54,6 +54,10 @@ #define AMBI_MAX_CHANNELS 16 +/* -------------------------------- + normalization conversion tables + -------------------------------- */ + static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, SQRT_3, SQRT_3, SQRT_3, SQRT_5, SQRT_5, SQRT_5, SQRT_5, SQRT_5, @@ -77,6 +81,40 @@ static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 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 }; +/* ---------------------------- + channel re-ordering tables + ---------------------------- */ + +static const int16_t REORDER_FM_ACN[AMBI_MAX_CHANNELS] = { 0, + 2, 3, 1, + 8, 6, 4, 5, 7, + 15, 13, 11, 9, 10, 12, 14 +}; + +static const int16_t REORDER_SID_ACN[AMBI_MAX_CHANNELS] = { 0, + 2, 3, 1, + 5, 7, 8, 6, 4, + 10, 12, 14, 15, 13, 11, 9 +}; + +static const int16_t REORDER_ACN_FM[AMBI_MAX_CHANNELS] = { 0, + 3, 1, 2, + 6, 7, 5, 8, 4, + 12, 13, 11, 14, 10, 15, 9 +}; + +static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, + 3, 1, 2, + 8, 4, 7, 5, 6, + 15, 9, 14, 10, 13, 11, 12 +}; + + +/* ---------------------------------- + API functions for the conversion + ---------------------------------- */ + + int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); @@ -143,7 +181,9 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; - float *conversion_table; + const 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 ) { @@ -180,7 +220,6 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i 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]; @@ -196,6 +235,42 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) { int16_t nchan = ( order + 1 ) * ( order + 1 ); + int16_t *idx_table; + + if ( in_format == AMBI_CHANNEL_ORDER_ACN ) + { + if ( out_format == AMBI_CHANNEL_ORDER_FM ) + { + idx_table = REORDER_ACN_FM; + } + if ( out_format == AMBI_CHANNEL_ORDER_SID ) + { + idx_table = REORDER_ACN_SID; + } + else + { + assert( 0 && "Unsupported conversion" ); + } + } + else if ( out_format == AMBI_CHANNEL_ORDER_ACN ) + { + if ( in_format == AMBI_CHANNEL_ORDER_FM ) + { + idx_table = REORDER_ACN_FM; + } + if ( in_format == AMBI_CHANNEL_ORDER_SID ) + { + idx_table = REORDER_ACN_SID; + } + else + { + assert( 0 && "Unsupported conversion" ); + } + } + else + { + assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + } return 0; } -- GitLab From d77535cbd50aa372740fe32285d0ec92b89b7d04 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 12:52:49 +0100 Subject: [PATCH 006/130] add code to re-order the channels --- lib_util/ambi_cenvert.c | 22 +++++++++++++++++++--- scripts/check-format.sh | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index 8cd0e46235..e79998215e 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include +#include #include "ivas_cnst.h" #include "ambi_convert.h" @@ -181,7 +182,7 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; - const float *conversion_table; + const float *conversion_table = 0; /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ @@ -234,8 +235,10 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) { - int16_t nchan = ( order + 1 ) * ( order + 1 ); - int16_t *idx_table; + int16_t n_chan = ( order + 1 ) * ( order + 1 ); + int16_t i_chan, i; + float tmp[AMBI_MAX_CHANNELS]; + const int16_t *idx_table = 0; if ( in_format == AMBI_CHANNEL_ORDER_ACN ) { @@ -272,5 +275,18 @@ int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16 assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } + for ( i = 0; i < L_FRAME48k; i++ ) + { + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + int16_t idx = idx_table[i_chan]; + tmp[i_chan] = in[idx][i]; + } + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + out[i_chan][i] = tmp[i_chan]; + } + } + return 0; } diff --git a/scripts/check-format.sh b/scripts/check-format.sh index 079a1ed334..154349de9f 100755 --- a/scripts/check-format.sh +++ b/scripts/check-format.sh @@ -38,7 +38,7 @@ if [ ! -d "lib_com" ]; then exit 255 fi -CLANG_FORMAT=clang-format +CLANG_FORMAT=./clang-format.exe CLANG_FORMAT_REQUIRED_VERSION="13.0" # list (with space between entries) of substrings that are excluded from the file list, e.g. very large files -- GitLab From 90df46559400dea51db1c1d68170ad8301f7c4f9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 13:17:10 +0100 Subject: [PATCH 007/130] add normalization tables for FM (with a factor of sqrt(2) as compared to MAXN) --- lib_util/ambi_cenvert.c | 68 +++++++++++++++++++++++------------------ lib_util/ambi_convert.h | 9 +++--- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_cenvert.c index e79998215e..fb2875e918 100644 --- a/lib_util/ambi_cenvert.c +++ b/lib_util/ambi_cenvert.c @@ -35,23 +35,25 @@ #include "ivas_cnst.h" #include "ambi_convert.h" -#define SQRT_3 1.7320508f -#define SQRT_5 2.2360679f -#define SQRT_7 2.64575131f - -#define INV_SQRT_3 0.5773502f -#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 SQRT_2_ 1.4142135f +#define SQRT_3_ 1.7320508f +#define SQRT_5_ 2.2360679f +#define SQRT_7_ 2.64575131f + +#define INV_SQRT_2_ 0.7071067f +#define INV_SQRT_3_ 0.5773502f +#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 @@ -60,27 +62,37 @@ -------------------------------- */ static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, - SQRT_3, SQRT_3, SQRT_3, - SQRT_5, SQRT_5, SQRT_5, SQRT_5, SQRT_5, - SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7, SQRT_7 + SQRT_3_, SQRT_3_, SQRT_3_, + SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, + SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_ }; static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, - INV_SQRT_3, INV_SQRT_3, INV_SQRT_3, - INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, INV_SQRT_5, - INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7, INV_SQRT_7 + INV_SQRT_3_, INV_SQRT_3_, INV_SQRT_3_, + INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, + 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 + 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 }; + 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_ }; + +static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, + 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 FM_MAXN[AMBI_MAX_CHANNELS] = { INV_SQRT_2, + 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_ }; /* ---------------------------- channel re-ordering tables @@ -110,12 +122,10 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, 15, 9, 14, 10, 13, 11, 12 }; - /* ---------------------------------- API functions for the conversion ---------------------------------- */ - int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index c4ad6d234f..d2296625c3 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -46,15 +46,16 @@ typedef enum typedef enum { AMBI_NORM_SN3D = 0, - AMBI_NORM_N3D = 1, - AMBI_NORM_MAXN = 2 + AMBI_NORM_N3D, + AMBI_NORM_MAXN, + AMBI_NORM_FM } AMBI_CHANNEL_NORM; typedef enum { AMBI_CHANNEL_ORDER_ACN = 0, - AMBI_CHANNEL_ORDER_FM = 1, - AMBI_CHANNEL_ORDER_SID = 2 + AMBI_CHANNEL_ORDER_FM, + AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; int16_t convert_ambi_format(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format); -- GitLab From e0928ecaf1f5a20ef8591c91e8811b62f8205c3c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 13:18:15 +0100 Subject: [PATCH 008/130] fix typo in file name --- Workspace_msvc/lib_util.vcxproj | 2 +- lib_util/{ambi_cenvert.c => ambi_convert.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib_util/{ambi_cenvert.c => ambi_convert.c} (100%) diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index bd70056f36..72f1c9f7c4 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -100,7 +100,7 @@ - + diff --git a/lib_util/ambi_cenvert.c b/lib_util/ambi_convert.c similarity index 100% rename from lib_util/ambi_cenvert.c rename to lib_util/ambi_convert.c -- GitLab From b64f5f62c6ed2058a972324c3a81703b0e6396a1 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 13:33:00 +0100 Subject: [PATCH 009/130] fix formattting --- lib_util/ambi_convert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index fb2875e918..5044325114 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -231,10 +231,10 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } - for (i_chan = 0; i_chan < n_chan; i_chan++) + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { float conversion_factor = conversion_table[i_chan]; - for (i = 0; i < L_FRAME48k; i++) + for ( i = 0; i < L_FRAME48k; i++ ) { out[i_chan][i] = in[i_chan][i] * conversion_factor; } -- GitLab From b0712abeb92fd51dc4330ddb6db3170307a4f7b6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 15:14:23 +0100 Subject: [PATCH 010/130] implement encoder command line option to select SBA input convention --- Workspace_msvc/lib_enc.vcxproj | 2 +- apps/encoder.c | 44 ++- lib_com/options.h | 2 + lib_enc/ivas_enc.c | 589 +++++++++++++++++---------------- lib_enc/ivas_stat_enc.h | 3 + lib_enc/lib_enc.c | 19 +- lib_enc/lib_enc.h | 8 + lib_util/ambi_convert.h | 11 +- 8 files changed, 377 insertions(+), 301 deletions(-) diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index aac96693ce..f1ff59c863 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_util;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/encoder.c b/apps/encoder.c index b00f4f75fd..6578c82ee2 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -38,6 +38,9 @@ #include "ism_file_reader.h" #include "jbm_file_reader.h" #include "masa_file_reader.h" +#ifdef AMBISONICS_CONVENTIONS +#include "ambi_convert.h" +#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -58,8 +61,7 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig -{ +typedef union _EncInputFormatConfig { /* MONO details */ bool stereoToMonoDownmix; @@ -121,6 +123,9 @@ typedef struct bool max_bwidth_user; IVAS_ENC_BANDWIDTH maxBandwidth; const char *bandwithProfileFile; +#ifdef AMBISONICS_CONVENTIONS + int16_t sba_input_fmt; +#endif IVAS_ENC_DTX_CONFIG dtxConfig; int32_t initBitrate; const char *bitrateProfileFile; @@ -408,6 +413,10 @@ int main( #ifdef DEBUG_SBA_AUDIO_DUMP , &numTransportChannels +#endif +#ifdef AMBISONICS_CONVENTIONS + , + arg.sba_input_fmt #endif ) ) != IVAS_ERR_OK ) { @@ -431,7 +440,12 @@ int main( } break; case IVAS_ENC_INPUT_SBA_ISM: - if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca +#ifdef AMBISONICS_CONVENTIONS + , + arg.sba_input_fmt +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); exit( -1 ); @@ -1183,6 +1197,30 @@ static bool parseCmdlIVAS_enc( } } + /* ---------------------------------------------------------------- + * SBA input convention + *------------------------------------------------------------------*/ +#ifdef AMBISONICS_CONVENTIONS + else if ( strcmp( argv_to_upper, "SBA_CONVENTION" ) == 0 ) + { + i++; + arg->inputFormat = AMBI_FMT_ACN_SN3D; + + /* SBA configuration */ + if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + else + { + tmp = -1; /* this is to avoid a compilation warning */ + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number!\n\n" ); + usage_enc(); + return false; + } + } +#endif + /*-----------------------------------------------------------------* * MIME output file format *-----------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index 52357d6c25..38e2f8d580 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,8 @@ #define FIX_1027_GSC_INT_OVERFLOW /* VA: issue 2207: overflow in GSC */ +#define AMBISONICS_CONVENTIONS + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5ddcf9a506..73533d0b3a 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -34,6 +34,7 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" +#include "ambi_convert.h" #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" @@ -79,7 +80,7 @@ ivas_error ivas_enc( nchan_inp = hEncoderConfig->nchan_inp; ivas_total_brate = hEncoderConfig->ivas_total_brate; - input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); + input_frame = ( int16_t )( input_Fs / FRAMES_PER_SEC ); n_samples_chan = n_samples / nchan_inp; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); @@ -126,439 +127,449 @@ ivas_error ivas_enc( dbgwrite( data_f[LFE_CHANNEL], sizeof( float ), n_samples_chan, 1, "./res/lfe_input" ); #endif - if ( ivas_format == SBA_FORMAT ) +#ifdef AMBISONICS_CONVENTIONS + if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) { - if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + if ( hEncoderConfig->sba_input_fmt != 0 ) { - return error; + convert_ambi_format( data_f, data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_input_fmt, AMBI_FMT_ACN_SN3D ); } - } - else if ( ivas_format == SBA_ISM_FORMAT ) - { - if ( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + } +#endif + + if ( ivas_format == SBA_FORMAT ) + { + if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( ivas_format == SBA_ISM_FORMAT ) { - return error; + if ( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * HP filtering *----------------------------------------------------------------*/ - n = getNumChanAnalysis( st_ivas ); + n = getNumChanAnalysis( st_ivas ); #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC - /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ - for ( i = 0; i < n; i++ ) - { - if ( ( ivas_format == SBA_FORMAT ) && !( st_ivas->sba_analysis_order > 1 ) ) + /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ + for ( i = 0; i < n; i++ ) { - hp20( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); - } - else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) - { - hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + if ( ( ivas_format == SBA_FORMAT ) && !( st_ivas->sba_analysis_order > 1 ) ) + { + hp20( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + } + else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) + { + hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + } } - } #endif - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * write IVAS format signaling *----------------------------------------------------------------*/ - ivas_write_format( st_ivas ); + ivas_write_format( st_ivas ); - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Encoding *----------------------------------------------------------------*/ - if ( ivas_format == STEREO_FORMAT ) - { - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, 0 /* no metadata */ ) ) != IVAS_ERR_OK ) + if ( ivas_format == STEREO_FORMAT ) { - return error; - } - } - else if ( ivas_format == ISM_FORMAT ) - { - /* select ISM format mode; reconfigure the ISM format encoder */ - if ( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - ivas_param_ism_enc( st_ivas, data_f, input_frame ); - - /* Stereo DMX generation */ - ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); - - /* Core coding of Stereo DMX */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, 0 /* no metadata */ ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + else if ( ivas_format == ISM_FORMAT ) { - /* Analysis, decision about bitrates per channel & core coding */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + /* select ISM format mode; reconfigure the ISM format encoder */ + if ( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK ) { return error; } - } - } - else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) - { - /* MASA configuration */ - if ( ivas_format == MASA_FORMAT ) - { - ivas_masa_enc_reconfigure( st_ivas ); - } - /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ - hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) + { + ivas_param_ism_enc( st_ivas, data_f, input_frame ); - if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) - { - ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ + /* Stereo DMX generation */ + ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); - if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; + /* Core coding of Stereo DMX */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } - - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + else if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - return error; + /* Analysis, decision about bitrates per channel & core coding */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } } - else if ( ivas_format == SBA_FORMAT ) + else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) { - if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + /* MASA configuration */ + if ( ivas_format == MASA_FORMAT ) { - return error; + ivas_masa_enc_reconfigure( st_ivas ); } - } - if ( ivas_format == SBA_FORMAT ) - { - ivas_sba_getTCs( data_f, st_ivas, input_frame ); - } + /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ + hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - /* core-coding of transport channels */ - if ( st_ivas->nSCE == 1 ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) { - return error; + ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ + + if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ - { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + else if ( ivas_format == SBA_FORMAT ) { - return error; + if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ - { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + + if ( ivas_format == SBA_FORMAT ) { - return error; + ivas_sba_getTCs( data_f, st_ivas, input_frame ); } - } - } - else if ( ivas_format == MASA_ISM_FORMAT ) - { - float *data_separated_object; - int16_t idx_separated_object; - int16_t flag_omasa_ener_brate; - - flag_omasa_ener_brate = 0; - - /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */ - if ( ( st_ivas->hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism ) == 1 ) - { - v_multc( data_f[hEncoderConfig->nchan_ism], 1.0f / SQRT2, data_f[hEncoderConfig->nchan_ism], input_frame ); - mvr2r( data_f[hEncoderConfig->nchan_ism], data_f[hEncoderConfig->nchan_ism + 1], input_frame ); - } - - /* Estimate TF-tile energy for the input MASA stream */ - ivas_masa_estimate_energy( st_ivas->hMasa, &( data_f[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport ); - if ( ( error = ivas_omasa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); - idx_separated_object = 0; - - data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; - - /* put audio object data in SCE's */ - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) - { - /* Estimate MASA parameters for the objects */ - ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); - } - - /* Encode ISMs transport channels */ - n = 0; - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_separated_object, input_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) /* there are no metadata bits in SCE in this mode */ + /* core-coding of transport channels */ + if ( st_ivas->nSCE == 1 ) { - return error; + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) - { - if ( ( error = ivas_ism_enc( st_ivas, &data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ) != IVAS_ERR_OK ) + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - return error; + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } } } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) + else if ( ivas_format == MASA_ISM_FORMAT ) { - flag_omasa_ener_brate = ivas_omasa_ener_brate( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_f, input_frame ); + float *data_separated_object; + int16_t idx_separated_object; + int16_t flag_omasa_ener_brate; - /* Analysis, decision about bitrates per channel & core coding */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + flag_omasa_ener_brate = 0; + + /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */ + if ( ( st_ivas->hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism ) == 1 ) { - return error; + v_multc( data_f[hEncoderConfig->nchan_ism], 1.0f / SQRT2, data_f[hEncoderConfig->nchan_ism], input_frame ); + mvr2r( data_f[hEncoderConfig->nchan_ism], data_f[hEncoderConfig->nchan_ism + 1], input_frame ); } - n = st_ivas->hEncoderConfig->nchan_ism; - } - - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( st_ivas->nSCE > 0 ) - { - /* update pointer to the buffer of indices (ISM indices were alredy written) */ - hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; - st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; - } + /* Estimate TF-tile energy for the input MASA stream */ + ivas_masa_estimate_energy( st_ivas->hMasa, &( data_f[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport ); - /* Encode MASA parameters and write MASA metadata bitstream */ - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, - st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = ivas_omasa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } - /* Configuration of combined-format bit-budget distribution */ -#ifdef DEBUG_MODE_INFO - ivas_set_surplus_brate_enc( st_ivas, nb_bits_metadata ); -#else - ivas_set_surplus_brate_enc( st_ivas ); -#endif + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + idx_separated_object = 0; - /* Encode MASA transport channels */ - if ( ( ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( ivas_format == SBA_ISM_FORMAT ) - { - int16_t planar_sba_orig; - planar_sba_orig = hEncoderConfig->sba_planar; + data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; - /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); + /* put audio object data in SCE's */ + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + { + /* Estimate MASA parameters for the objects */ + ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); + } - if ( st_ivas->ism_mode == ISM_MODE_NONE ) - { - /*once SBA and ISM are combined into SBA signal then disable planar flag*/ - hEncoderConfig->sba_planar = 0; - if ( st_ivas->nchan_transport == 1 ) + /* Encode ISMs transport channels */ + n = 0; + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) { - hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; + if ( ( error = ivas_sce_enc( st_ivas, 0, data_separated_object, input_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) /* there are no metadata bits in SCE in this mode */ + { + return error; + } } - else + else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) { - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + if ( ( error = ivas_ism_enc( st_ivas, &data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } - - /* SBA metadata encoding and SBA metadata bitstream writing */ - if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - return error; + flag_omasa_ener_brate = ivas_omasa_ener_brate( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_f, input_frame ); + + /* Analysis, decision about bitrates per channel & core coding */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + { + return error; + } + n = st_ivas->hEncoderConfig->nchan_ism; } - hEncoderConfig->sba_planar = planar_sba_orig; - } - else - { - n = hEncoderConfig->nchan_ism; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) + if ( st_ivas->nSCE > 0 ) { - return error; + /* update pointer to the buffer of indices (ISM indices were alredy written) */ + hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; + st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; } - /* SBA metadata encoding and SBA metadata bitstream writing */ - if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + /* Encode MASA parameters and write MASA metadata bitstream */ + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) { return error; } - /* get SBA TCs */ - ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); - } + /* Configuration of combined-format bit-budget distribution */ +#ifdef DEBUG_MODE_INFO + ivas_set_surplus_brate_enc( st_ivas, nb_bits_metadata ); +#else + ivas_set_surplus_brate_enc( st_ivas ); +#endif - /* core-coding of transport channels */ - if ( st_ivas->nSCE == 1 ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ - { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + /* Encode MASA transport channels */ + if ( ( ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + else if ( ivas_format == SBA_ISM_FORMAT ) { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + int16_t planar_sba_orig; + planar_sba_orig = hEncoderConfig->sba_planar; + + /* Analyze objects and determine needed audio signals */ + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); + + if ( st_ivas->ism_mode == ISM_MODE_NONE ) { - return error; - } - } - } - else if ( ivas_format == MC_FORMAT ) - { - /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ - if ( ( error = ivas_mc_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + /*once SBA and ISM are combined into SBA signal then disable planar flag*/ + hEncoderConfig->sba_planar = 0; + if ( st_ivas->nchan_transport == 1 ) + { + hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; + } + else + { + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + } - hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } - /* LFE low pass filter */ - ivas_lfe_lpf_enc_apply( st_ivas->hLfeLpf, data_f[LFE_CHANNEL], input_frame ); + hEncoderConfig->sba_planar = planar_sba_orig; + } + else + { + n = hEncoderConfig->nchan_ism; + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - /* LFE channel encoder */ - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; + if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) + { + return error; + } - ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); - } + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( st_ivas->mc_mode == MC_MODE_MCT ) - { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, 0 ) ) != IVAS_ERR_OK ) - { - return error; + /* get SBA TCs */ + ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); } - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - /* encode MC ParamUpmix parameters and write bitstream */ - ivas_mc_paramupmix_enc( st_ivas, hMetaData, data_f, input_frame ); - - st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; - ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + /* core-coding of transport channels */ + if ( st_ivas->nSCE == 1 ) { - return error; + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } } - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) - { - /* encode Parametric MC parameters and write bitstream */ - ivas_param_mc_enc( st_ivas, hMetaData, data_f, input_frame ); - - if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->nCPE > 1 ) + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + else if ( ivas_format == MC_FORMAT ) { - if ( st_ivas->hMcMasa->separateChannelEnabled ) + /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ + if ( ( error = ivas_mc_enc_config( st_ivas ) ) != IVAS_ERR_OK ) { - hMetaData = st_ivas->hCPE[0]->hMetaData; /* Metadata is always with CPE in the case of separated channel */ + return error; } - ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); + hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + + /* LFE low pass filter */ + ivas_lfe_lpf_enc_apply( st_ivas->hLfeLpf, data_f[LFE_CHANNEL], input_frame ); - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + /* LFE channel encoder */ + if ( st_ivas->mc_mode == MC_MODE_MCT ) { - return error; + st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; + + ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); } - if ( st_ivas->hMcMasa->separateChannelEnabled ) + if ( st_ivas->mc_mode == MC_MODE_MCT ) { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + /* encode MC ParamUpmix parameters and write bitstream */ + ivas_mc_paramupmix_enc( st_ivas, hMetaData, data_f, input_frame ); - st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot; + st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; + ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - else + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) { - if ( st_ivas->nSCE == 1 ) + /* encode Parametric MC parameters and write bitstream */ + ivas_param_mc_enc( st_ivas, hMetaData, data_f, input_frame ); + + if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + else if ( st_ivas->nCPE > 1 ) { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) + { + if ( st_ivas->hMcMasa->separateChannelEnabled ) + { + hMetaData = st_ivas->hCPE[0]->hMetaData; /* Metadata is always with CPE in the case of separated channel */ + } + + ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); + + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->hMcMasa->separateChannelEnabled ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + + st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot; + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } + else + { + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + { + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } } } - } - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ - hEncoderConfig->last_ivas_total_brate = ivas_total_brate; + hEncoderConfig->last_ivas_total_brate = ivas_total_brate; #ifdef DEBUG_MODE_INFO - { - float tmpF = ivas_total_brate / 1000.0f; - dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); - } + { + float tmpF = ivas_total_brate / 1000.0f; + dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); + } #endif - pop_wmops(); - return error; -} + pop_wmops(); + return error; + } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 3962ac055f..f92a598afb 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1188,6 +1188,9 @@ typedef struct encoder_config_structure int16_t Opt_DTX_ON; /* flag indicating DTX operation */ int16_t interval_SID; /* CNG and DTX - interval of SID update, default 8 */ int16_t var_SID_rate_flag; /* CNG and DTX - flag for variable SID rate */ +#ifdef AMBISONICS_CONVENTIONS + int16_t sba_input_fmt; +#endif int16_t Opt_RF_ON; /* flag indicating RF (channel-aware) mode */ int16_t rf_fec_offset; /* RF FEC offset */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 4a4be81734..39026d6992 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -492,6 +492,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( , int16_t *numTransportChannels #endif +#ifdef AMBISONICS_CONVENTIONS + , + const int16_t sba_input_fmt +#endif ) { ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -509,6 +513,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->sba_planar = isPlanar; hEncoderConfig->sba_order = order; +#ifdef AMBISONICS_CONVENTIONS + hEncoderConfig->sba_input_fmt = sba_input_fmt; +#endif + /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ hEncoderConfig->nchan_inp = ivas_sba_get_nchan( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ @@ -548,6 +556,10 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ +#ifdef AMBISONICS_CONVENTIONS + , + const int16_t sba_input_fmt +#endif ) { Encoder_Struct *st_ivas; @@ -562,11 +574,14 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( { return IVAS_ERR_TOO_MANY_INPUTS; } - st_ivas = hIvasEnc->st_ivas; + st_ivas = hIvasEnc->st_ivas; st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ st_ivas->hEncoderConfig->sba_planar = isPlanar; st_ivas->hEncoderConfig->sba_order = order; +#ifdef AMBISONICS_CONVENTIONS + st_ivas->hEncoderConfig->sba_input_fmt = sba_input_fmt; +#endif /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ /*Input file will always contain all channels for a given order irrespective of planar flag*/ @@ -1079,7 +1094,7 @@ static int16_t getInputBufferSize( const Encoder_Struct *st_ivas /* i : IVAS encoder handle */ ) { - return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); + return ( int16_t )( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); } /*---------------------------------------------------------------------* diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 2f40c1ab1b..58860e3107 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -223,6 +223,10 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ +#ifdef AMBISONICS_CONVENTIONS + , + const int16_t sba_input_fmt +#endif ); /*! r: error code */ @@ -243,6 +247,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( , int16_t *numTransportChannels #endif +#ifdef AMBISONICS_CONVENTIONS + , + const int16_t sba_input_fmt +#endif ); /*! r: error code */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index d2296625c3..598c830ab8 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -31,16 +31,15 @@ *******************************************************************************************************/ #include +#include "ivas_cnst.h" typedef enum { AMBI_FMT_ACN_SN3D = 0, - AMBI_FMT_ACN_N3D, - - AMBI_FMT_FM_MAXN, - - AMBI_FMT_SID_SN3D, - AMBI_FMT_SID_N3D + AMBI_FMT_ACN_N3D = 1, + AMBI_FMT_FM_MAXN = 2 , + AMBI_FMT_SID_SN3D = 3, + AMBI_FMT_SID_N3D = 4 } AMBI_FMT; typedef enum -- GitLab From 1fc47fa610b421e5cda8691af1a30a2f191ee4f2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 15:26:31 +0100 Subject: [PATCH 011/130] fix formatting --- apps/encoder.c | 19 +- lib_enc/ivas_enc.c | 582 ++++++++++++++++++++-------------------- lib_enc/lib_enc.c | 2 +- lib_util/ambi_convert.c | 91 +++---- lib_util/ambi_convert.h | 14 +- 5 files changed, 350 insertions(+), 358 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 6578c82ee2..1e88ada4af 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,7 +61,8 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig { +typedef union _EncInputFormatConfig +{ /* MONO details */ bool stereoToMonoDownmix; @@ -415,8 +416,8 @@ int main( &numTransportChannels #endif #ifdef AMBISONICS_CONVENTIONS - , - arg.sba_input_fmt + , + arg.sba_input_fmt #endif ) ) != IVAS_ERR_OK ) { @@ -440,12 +441,12 @@ int main( } break; case IVAS_ENC_INPUT_SBA_ISM: - if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca + if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca #ifdef AMBISONICS_CONVENTIONS - , - arg.sba_input_fmt + , + arg.sba_input_fmt #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); exit( -1 ); @@ -1198,8 +1199,8 @@ static bool parseCmdlIVAS_enc( } /* ---------------------------------------------------------------- - * SBA input convention - *------------------------------------------------------------------*/ + * SBA input convention + *------------------------------------------------------------------*/ #ifdef AMBISONICS_CONVENTIONS else if ( strcmp( argv_to_upper, "SBA_CONVENTION" ) == 0 ) { diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 73533d0b3a..5869e28a51 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -80,7 +80,7 @@ ivas_error ivas_enc( nchan_inp = hEncoderConfig->nchan_inp; ivas_total_brate = hEncoderConfig->ivas_total_brate; - input_frame = ( int16_t )( input_Fs / FRAMES_PER_SEC ); + input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); n_samples_chan = n_samples / nchan_inp; set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); @@ -134,442 +134,442 @@ ivas_error ivas_enc( { convert_ambi_format( data_f, data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_input_fmt, AMBI_FMT_ACN_SN3D ); } - } + } #endif - if ( ivas_format == SBA_FORMAT ) + if ( ivas_format == SBA_FORMAT ) + { + if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( ivas_format == SBA_ISM_FORMAT ) + } + else if ( ivas_format == SBA_ISM_FORMAT ) + { + if ( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_osba_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } + } - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * HP filtering *----------------------------------------------------------------*/ - n = getNumChanAnalysis( st_ivas ); + n = getNumChanAnalysis( st_ivas ); #ifndef DEBUG_SPAR_BYPASS_EVS_CODEC - /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ - for ( i = 0; i < n; i++ ) + /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */ + for ( i = 0; i < n; i++ ) + { + if ( ( ivas_format == SBA_FORMAT ) && !( st_ivas->sba_analysis_order > 1 ) ) { - if ( ( ivas_format == SBA_FORMAT ) && !( st_ivas->sba_analysis_order > 1 ) ) - { - hp20( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); - } - else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) - { - hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); - } + hp20( data_f[HOA_keep_ind[st_ivas->hSpar->hMdEnc->HOA_md_ind[i]]], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); + } + else if ( !( ivas_format == MC_FORMAT && i == LFE_CHANNEL ) ) + { + hp20( data_f[i], input_frame, st_ivas->mem_hp20_in[i], input_Fs ); } + } #endif - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * write IVAS format signaling *----------------------------------------------------------------*/ - ivas_write_format( st_ivas ); + ivas_write_format( st_ivas ); - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Encoding *----------------------------------------------------------------*/ - if ( ivas_format == STEREO_FORMAT ) + if ( ivas_format == STEREO_FORMAT ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, 0 /* no metadata */ ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( ivas_format == ISM_FORMAT ) + { + /* select ISM format mode; reconfigure the ISM format encoder */ + if ( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, 0 /* no metadata */ ) ) != IVAS_ERR_OK ) + ivas_param_ism_enc( st_ivas, data_f, input_frame ); + + /* Stereo DMX generation */ + ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); + + /* Core coding of Stereo DMX */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) { return error; } } - else if ( ivas_format == ISM_FORMAT ) + else if ( st_ivas->ism_mode == ISM_MODE_DISC ) { - /* select ISM format mode; reconfigure the ISM format encoder */ - if ( ( error = ivas_ism_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + /* Analysis, decision about bitrates per channel & core coding */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) { return error; } + } + } + else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) + { + /* MASA configuration */ + if ( ivas_format == MASA_FORMAT ) + { + ivas_masa_enc_reconfigure( st_ivas ); + } - if ( st_ivas->ism_mode == ISM_MODE_PARAM ) - { - ivas_param_ism_enc( st_ivas, data_f, input_frame ); + /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ + hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - /* Stereo DMX generation */ - ivas_param_ism_stereo_dmx( st_ivas, data_f, input_frame ); + if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) + { + ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ - /* Core coding of Stereo DMX */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; } - else if ( st_ivas->ism_mode == ISM_MODE_DISC ) + + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { - /* Analysis, decision about bitrates per channel & core coding */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, nb_bits_metadata, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } - else if ( ivas_format == SBA_FORMAT || ivas_format == MASA_FORMAT ) + else if ( ivas_format == SBA_FORMAT ) { - /* MASA configuration */ - if ( ivas_format == MASA_FORMAT ) + if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) { - ivas_masa_enc_reconfigure( st_ivas ); + return error; } + } - /* SBA/MASA metadata encoding and SBA/MASA metadata bitstream writing */ - hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + if ( ivas_format == SBA_FORMAT ) + { + ivas_sba_getTCs( data_f, st_ivas, input_frame ); + } - if ( st_ivas->hQMetaData != NULL && ivas_format == MASA_FORMAT ) + /* core-coding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - ivas_masa_estimate_energy( st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport ); /* energy-estimation uses TF-resolution: 4x24 */ - - if ( ( error = ivas_masa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( ivas_format == SBA_FORMAT ) + } + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + { + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - - if ( ivas_format == SBA_FORMAT ) + } + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - ivas_sba_getTCs( data_f, st_ivas, input_frame ); + return error; } + } + } + else if ( ivas_format == MASA_ISM_FORMAT ) + { + float *data_separated_object; + int16_t idx_separated_object; + int16_t flag_omasa_ener_brate; - /* core-coding of transport channels */ - if ( st_ivas->nSCE == 1 ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + flag_omasa_ener_brate = 0; + + /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */ + if ( ( st_ivas->hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism ) == 1 ) + { + v_multc( data_f[hEncoderConfig->nchan_ism], 1.0f / SQRT2, data_f[hEncoderConfig->nchan_ism], input_frame ); + mvr2r( data_f[hEncoderConfig->nchan_ism], data_f[hEncoderConfig->nchan_ism + 1], input_frame ); + } + + /* Estimate TF-tile energy for the input MASA stream */ + ivas_masa_estimate_energy( st_ivas->hMasa, &( data_f[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport ); + + if ( ( error = ivas_omasa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); + idx_separated_object = 0; + + data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; + + /* put audio object data in SCE's */ + if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) + { + /* Estimate MASA parameters for the objects */ + ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); + } + + /* Encode ISMs transport channels */ + n = 0; + if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_separated_object, input_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) /* there are no metadata bits in SCE in this mode */ { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + } + else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + { + if ( ( error = ivas_ism_enc( st_ivas, &data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } } - else if ( ivas_format == MASA_ISM_FORMAT ) + else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - float *data_separated_object; - int16_t idx_separated_object; - int16_t flag_omasa_ener_brate; - - flag_omasa_ener_brate = 0; + flag_omasa_ener_brate = ivas_omasa_ener_brate( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_f, input_frame ); - /* Stereo transport is used also with monoMASA, duplicate mono if monoMASA */ - if ( ( st_ivas->hEncoderConfig->nchan_inp - hEncoderConfig->nchan_ism ) == 1 ) + /* Analysis, decision about bitrates per channel & core coding */ + if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) { - v_multc( data_f[hEncoderConfig->nchan_ism], 1.0f / SQRT2, data_f[hEncoderConfig->nchan_ism], input_frame ); - mvr2r( data_f[hEncoderConfig->nchan_ism], data_f[hEncoderConfig->nchan_ism + 1], input_frame ); + return error; } + n = st_ivas->hEncoderConfig->nchan_ism; + } - /* Estimate TF-tile energy for the input MASA stream */ - ivas_masa_estimate_energy( st_ivas->hMasa, &( data_f[hEncoderConfig->nchan_ism] ), input_frame, st_ivas->nchan_transport ); + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( ( error = ivas_omasa_enc_config( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } + if ( st_ivas->nSCE > 0 ) + { + /* update pointer to the buffer of indices (ISM indices were alredy written) */ + hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; + st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; + } + + /* Encode MASA parameters and write MASA metadata bitstream */ + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, + st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + { + return error; + } - set_s( nb_bits_metadata, 0, MAX_SCE + 1 ); - idx_separated_object = 0; + /* Configuration of combined-format bit-budget distribution */ +#ifdef DEBUG_MODE_INFO + ivas_set_surplus_brate_enc( st_ivas, nb_bits_metadata ); +#else + ivas_set_surplus_brate_enc( st_ivas ); +#endif - data_separated_object = data_f[hEncoderConfig->nchan_ism + CPE_CHANNELS]; + /* Encode MASA transport channels */ + if ( ( ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + { + return error; + } + } + else if ( ivas_format == SBA_ISM_FORMAT ) + { + int16_t planar_sba_orig; + planar_sba_orig = hEncoderConfig->sba_planar; - /* put audio object data in SCE's */ - if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC ) - { - /* Estimate MASA parameters for the objects */ - ivas_omasa_enc( st_ivas->hOMasa, st_ivas->hMasa, st_ivas->hIsmMetaData, data_f, input_frame, st_ivas->nchan_transport, hEncoderConfig->nchan_ism, st_ivas->ism_mode, data_separated_object, &idx_separated_object ); - } + /* Analyze objects and determine needed audio signals */ + ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); - /* Encode ISMs transport channels */ - n = 0; - if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) + if ( st_ivas->ism_mode == ISM_MODE_NONE ) + { + /*once SBA and ISM are combined into SBA signal then disable planar flag*/ + hEncoderConfig->sba_planar = 0; + if ( st_ivas->nchan_transport == 1 ) { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_separated_object, input_frame, nb_bits_metadata[1] ) ) != IVAS_ERR_OK ) /* there are no metadata bits in SCE in this mode */ - { - return error; - } + hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ ) + else { - if ( ( error = ivas_ism_enc( st_ivas, &data_separated_object, input_frame, &nb_bits_metadata[1], 0 ) ) != IVAS_ERR_OK ) - { - return error; - } + hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; } - else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) - { - flag_omasa_ener_brate = ivas_omasa_ener_brate( st_ivas->hEncoderConfig->nchan_ism, ivas_total_brate, data_f, input_frame ); - /* Analysis, decision about bitrates per channel & core coding */ - if ( ( error = ivas_ism_enc( st_ivas, data_f, input_frame, &nb_bits_metadata[1], flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - n = st_ivas->hEncoderConfig->nchan_ism; + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) + { + return error; } + hEncoderConfig->sba_planar = planar_sba_orig; + } + else + { + n = hEncoderConfig->nchan_ism; hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - if ( st_ivas->nSCE > 0 ) + if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) { - /* update pointer to the buffer of indices (ISM indices were alredy written) */ - hMetaData->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData->nb_ind_tot; - st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[st_ivas->nSCE - 1]->hCoreCoder[0]->hBstr->nb_ind_tot; + return error; } - /* Encode MASA parameters and write MASA metadata bitstream */ - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, nb_bits_metadata, st_ivas->nchan_transport, ivas_format, ivas_total_brate, st_ivas->hEncoderConfig->Opt_DTX_ON, st_ivas->nchan_transport == 2 ? st_ivas->hCPE[0]->element_mode : -1, - st_ivas->ism_mode, hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, idx_separated_object, st_ivas->hOMasa, st_ivas->hIsmMetaData[0]->ism_imp, flag_omasa_ener_brate ) ) != IVAS_ERR_OK ) + /* SBA metadata encoding and SBA metadata bitstream writing */ + if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) { return error; } - /* Configuration of combined-format bit-budget distribution */ -#ifdef DEBUG_MODE_INFO - ivas_set_surplus_brate_enc( st_ivas, nb_bits_metadata ); -#else - ivas_set_surplus_brate_enc( st_ivas ); -#endif + /* get SBA TCs */ + ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); + } - /* Encode MASA transport channels */ - if ( ( ivas_cpe_enc( st_ivas, 0, data_f[n], data_f[n + 1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + /* core-coding of transport channels */ + if ( st_ivas->nSCE == 1 ) + { + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { return error; } } - else if ( ivas_format == SBA_ISM_FORMAT ) + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - int16_t planar_sba_orig; - planar_sba_orig = hEncoderConfig->sba_planar; - - /* Analyze objects and determine needed audio signals */ - ivas_osba_enc( st_ivas->hOSba, st_ivas->hIsmMetaData, data_f, input_frame, hEncoderConfig->nchan_ism, st_ivas->ism_mode, st_ivas->sba_analysis_order, hEncoderConfig->input_Fs, hEncoderConfig->sba_planar ); - - if ( st_ivas->ism_mode == ISM_MODE_NONE ) + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - /*once SBA and ISM are combined into SBA signal then disable planar flag*/ - hEncoderConfig->sba_planar = 0; - if ( st_ivas->nchan_transport == 1 ) - { - hMetaData = st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData; - } - else - { - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - } - - /* SBA metadata encoding and SBA metadata bitstream writing */ - if ( ( error = ivas_spar_enc( st_ivas, data_f, input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) - { - return error; - } - - hEncoderConfig->sba_planar = planar_sba_orig; + return error; } - else + } + else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) { - n = hEncoderConfig->nchan_ism; - hMetaData = st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; + return error; + } + } + } + else if ( ivas_format == MC_FORMAT ) + { + /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ + if ( ( error = ivas_mc_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } - if ( ( error = ivas_ism_metadata_enc( &st_ivas->hEncoderConfig->ivas_total_brate, n, st_ivas->hEncoderConfig->nchan_ism, st_ivas->hIsmMetaData, NULL, hMetaData, &nb_bits_metadata[1], 0, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, -1, 0, NULL, st_ivas->hCPE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) - { - return error; - } + hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - /* SBA metadata encoding and SBA metadata bitstream writing */ - if ( ( error = ivas_spar_enc( st_ivas, &data_f[n], input_frame, nb_bits_metadata, hMetaData ) ) != IVAS_ERR_OK ) - { - return error; - } + /* LFE low pass filter */ + ivas_lfe_lpf_enc_apply( st_ivas->hLfeLpf, data_f[LFE_CHANNEL], input_frame ); - /* get SBA TCs */ - ivas_sba_getTCs( &data_f[n], st_ivas, input_frame ); + /* LFE channel encoder */ + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; + + ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); + } + + if ( st_ivas->mc_mode == MC_MODE_MCT ) + { + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; } + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) + { + /* encode MC ParamUpmix parameters and write bitstream */ + ivas_mc_paramupmix_enc( st_ivas, hMetaData, data_f, input_frame ); - /* core-coding of transport channels */ - if ( st_ivas->nSCE == 1 ) + st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; + ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); + + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ + } + else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + /* encode Parametric MC parameters and write bitstream */ + ivas_param_mc_enc( st_ivas, hMetaData, data_f, input_frame ); + + if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->nCPE > 1 ) /* FOA/HOA format */ + else if ( st_ivas->nCPE > 1 ) { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } } - else if ( ivas_format == MC_FORMAT ) + else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - /* select MC format mode; write MC LS setup; reconfigure the MC format encoder */ - if ( ( error = ivas_mc_enc_config( st_ivas ) ) != IVAS_ERR_OK ) + if ( st_ivas->hMcMasa->separateChannelEnabled ) { - return error; + hMetaData = st_ivas->hCPE[0]->hMetaData; /* Metadata is always with CPE in the case of separated channel */ } - hMetaData = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData : st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData; - - /* LFE low pass filter */ - ivas_lfe_lpf_enc_apply( st_ivas->hLfeLpf, data_f[LFE_CHANNEL], input_frame ); + ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); - /* LFE channel encoder */ - if ( st_ivas->mc_mode == MC_MODE_MCT ) + if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { - st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; - - ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); + return error; } - if ( st_ivas->mc_mode == MC_MODE_MCT ) + if ( st_ivas->hMcMasa->separateChannelEnabled ) { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, 0 ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK ) { return error; } - } - else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) - { - /* encode MC ParamUpmix parameters and write bitstream */ - ivas_mc_paramupmix_enc( st_ivas, hMetaData, data_f, input_frame ); - st_ivas->hLFE->hBstr = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0]->hBstr : st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; - ivas_lfe_enc( st_ivas->hLFE, data_f[LFE_CHANNEL], input_frame, st_ivas->hLFE->hBstr ); + st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot; - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - else if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + else { - /* encode Parametric MC parameters and write bitstream */ - ivas_param_mc_enc( st_ivas, hMetaData, data_f, input_frame ); - - if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ - { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE > 1 ) + if ( st_ivas->nSCE == 1 ) { - if ( ( error = ivas_mct_enc( st_ivas, data_f, input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - } - else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) - { - if ( st_ivas->hMcMasa->separateChannelEnabled ) - { - hMetaData = st_ivas->hCPE[0]->hMetaData; /* Metadata is always with CPE in the case of separated channel */ - } - - ivas_mcmasa_enc( st_ivas->hMcMasa, st_ivas->hQMetaData, st_ivas->hMasa, data_f, input_frame, st_ivas->nchan_transport, nchan_inp ); - - if ( ( error = ivas_masa_encode( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) + else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ { - return error; - } - - if ( st_ivas->hMcMasa->separateChannelEnabled ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[2], input_frame, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list = st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list + st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->nb_ind_tot; - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) { return error; } } - else - { - if ( st_ivas->nSCE == 1 ) - { - if ( ( error = ivas_sce_enc( st_ivas, 0, data_f[0], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) - { - return error; - } - } - else if ( st_ivas->nCPE == 1 ) /* Stereo DMX */ - { - if ( ( error = ivas_cpe_enc( st_ivas, 0, data_f[0], data_f[1], input_frame, hMetaData->nb_bits_tot ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } } } + } - /*----------------------------------------------------------------* + /*----------------------------------------------------------------* * Common updates *----------------------------------------------------------------*/ - hEncoderConfig->last_ivas_total_brate = ivas_total_brate; + hEncoderConfig->last_ivas_total_brate = ivas_total_brate; #ifdef DEBUG_MODE_INFO - { - float tmpF = ivas_total_brate / 1000.0f; - dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); - } + { + float tmpF = ivas_total_brate / 1000.0f; + dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); + } #endif - pop_wmops(); - return error; - } + pop_wmops(); + return error; +} diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 39026d6992..03d16c98e2 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1094,7 +1094,7 @@ static int16_t getInputBufferSize( const Encoder_Struct *st_ivas /* i : IVAS encoder handle */ ) { - return ( int16_t )( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); + return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); } /*---------------------------------------------------------------------* diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 5044325114..317737482f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -40,10 +40,10 @@ #define SQRT_5_ 2.2360679f #define SQRT_7_ 2.64575131f -#define INV_SQRT_2_ 0.7071067f -#define INV_SQRT_3_ 0.5773502f -#define INV_SQRT_5_ 0.4472135f -#define INV_SQRT_7_ 0.3779644f +#define INV_SQRT_2_ 0.7071067f +#define INV_SQRT_3_ 0.5773502f +#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 @@ -57,27 +57,24 @@ #define AMBI_MAX_CHANNELS 16 -/* -------------------------------- +/* -------------------------------- normalization conversion tables -------------------------------- */ static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, SQRT_3_, SQRT_3_, SQRT_3_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, - SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_ -}; + SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_ }; static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_3_, INV_SQRT_3_, INV_SQRT_3_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, - INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_ -}; + 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_ -}; + 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, @@ -101,26 +98,22 @@ static const float FM_MAXN[AMBI_MAX_CHANNELS] = { INV_SQRT_2, static const int16_t REORDER_FM_ACN[AMBI_MAX_CHANNELS] = { 0, 2, 3, 1, 8, 6, 4, 5, 7, - 15, 13, 11, 9, 10, 12, 14 -}; + 15, 13, 11, 9, 10, 12, 14 }; static const int16_t REORDER_SID_ACN[AMBI_MAX_CHANNELS] = { 0, - 2, 3, 1, - 5, 7, 8, 6, 4, - 10, 12, 14, 15, 13, 11, 9 -}; + 2, 3, 1, + 5, 7, 8, 6, 4, + 10, 12, 14, 15, 13, 11, 9 }; static const int16_t REORDER_ACN_FM[AMBI_MAX_CHANNELS] = { 0, 3, 1, 2, 6, 7, 5, 8, 4, - 12, 13, 11, 14, 10, 15, 9 -}; + 12, 13, 11, 14, 10, 15, 9 }; static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, 3, 1, 2, 8, 4, 7, 5, 6, - 15, 9, 14, 10, 13, 11, 12 -}; + 15, 9, 14, 10, 13, 11, 12 }; /* ---------------------------------- API functions for the conversion @@ -153,8 +146,8 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in else { assert( 0 && "Unsupported conversion" ); - } - } + } + } else if ( out_format == AMBI_FMT_ACN_SN3D ) { if ( in_format == AMBI_FMT_ACN_N3D ) @@ -194,14 +187,14 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i int16_t i_chan, i; const float *conversion_table = 0; - /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ + /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ - if ( in_format == AMBI_NORM_SN3D ) + if ( in_format == AMBI_NORM_SN3D ) { - if ( out_format == AMBI_NORM_N3D ) - { - conversion_table = SN3D_N3D; - } + if ( out_format == AMBI_NORM_N3D ) + { + conversion_table = SN3D_N3D; + } if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; @@ -210,9 +203,9 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i { assert( 0 && "Unsupported conversion" ); } - } - else if ( out_format == AMBI_NORM_SN3D ) - { + } + else if ( out_format == AMBI_NORM_SN3D ) + { if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; @@ -225,20 +218,20 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i { assert( 0 && "Unsupported conversion" ); } - } + } else { assert( 0 && "Conversion only supported to and from ACN-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; - } - } + 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; } @@ -250,7 +243,7 @@ int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16 float tmp[AMBI_MAX_CHANNELS]; const int16_t *idx_table = 0; - if ( in_format == AMBI_CHANNEL_ORDER_ACN ) + if ( in_format == AMBI_CHANNEL_ORDER_ACN ) { if ( out_format == AMBI_CHANNEL_ORDER_FM ) { @@ -285,18 +278,18 @@ int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16 assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } - for ( i = 0; i < L_FRAME48k; i++ ) + for ( i = 0; i < L_FRAME48k; i++ ) { - for ( i_chan = 0; i_chan < n_chan; i_chan++ ) - { - int16_t idx = idx_table[i_chan]; - tmp[i_chan] = in[idx][i]; - } + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + int16_t idx = idx_table[i_chan]; + tmp[i_chan] = in[idx][i]; + } for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { out[i_chan][i] = tmp[i_chan]; } - } + } return 0; } diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 598c830ab8..3251824ab8 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -37,7 +37,7 @@ typedef enum { AMBI_FMT_ACN_SN3D = 0, AMBI_FMT_ACN_N3D = 1, - AMBI_FMT_FM_MAXN = 2 , + AMBI_FMT_FM_MAXN = 2, AMBI_FMT_SID_SN3D = 3, AMBI_FMT_SID_N3D = 4 } AMBI_FMT; @@ -47,20 +47,18 @@ typedef enum AMBI_NORM_SN3D = 0, AMBI_NORM_N3D, AMBI_NORM_MAXN, - AMBI_NORM_FM + AMBI_NORM_FM } AMBI_CHANNEL_NORM; typedef enum { - AMBI_CHANNEL_ORDER_ACN = 0, + AMBI_CHANNEL_ORDER_ACN = 0, AMBI_CHANNEL_ORDER_FM, AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; -int16_t convert_ambi_format(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format); - -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 reorder_channels(float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format); +int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); +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 reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); -- GitLab From 851575d92317c1b72d5fdd7874562fdc357790f8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 15:43:14 +0100 Subject: [PATCH 012/130] change signatures of conversion functions to match the type of the float input buffer in the encoder --- apps/encoder.c | 2 +- lib_util/ambi_convert.c | 6 +++--- lib_util/ambi_convert.h | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 1e88ada4af..a2e2287694 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1205,7 +1205,7 @@ static bool parseCmdlIVAS_enc( else if ( strcmp( argv_to_upper, "SBA_CONVENTION" ) == 0 ) { i++; - arg->inputFormat = AMBI_FMT_ACN_SN3D; + arg->inputFormat = ( int16_t ) AMBI_FMT_ACN_SN3D; /* SBA configuration */ if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 317737482f..8155688354 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -119,7 +119,7 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, API functions for the conversion ---------------------------------- */ -int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) +int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) { assert( order <= 3 ); @@ -181,7 +181,7 @@ int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], in return 0; } -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 renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; @@ -236,7 +236,7 @@ int16_t renormalize_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], i return 0; } -int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) +int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 3251824ab8..9bc0bb5d86 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include "ivas_cnst.h" typedef enum { @@ -57,8 +56,8 @@ typedef enum AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; -int16_t convert_ambi_format( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); +int16_t convert_ambi_format( float* in[], float* out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); -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 renormalize_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ); -int16_t reorder_channels( float in[][L_FRAME48k], float out[][L_FRAME48k], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); +int16_t reorder_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); -- GitLab From 843a8257b5162f4c6aafee6444577a4992282d30 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 15:54:09 +0100 Subject: [PATCH 013/130] fix encoder command line parsing --- apps/encoder.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index a2e2287694..68373f2c3e 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -125,7 +125,7 @@ typedef struct IVAS_ENC_BANDWIDTH maxBandwidth; const char *bandwithProfileFile; #ifdef AMBISONICS_CONVENTIONS - int16_t sba_input_fmt; + AMBI_FMT sba_input_fmt; #endif IVAS_ENC_DTX_CONFIG dtxConfig; int32_t initBitrate; @@ -1202,10 +1202,10 @@ static bool parseCmdlIVAS_enc( * SBA input convention *------------------------------------------------------------------*/ #ifdef AMBISONICS_CONVENTIONS - else if ( strcmp( argv_to_upper, "SBA_CONVENTION" ) == 0 ) + else if ( strcmp( argv_to_upper, "-SBA_CONVENTION" ) == 0 ) { i++; - arg->inputFormat = ( int16_t ) AMBI_FMT_ACN_SN3D; + arg->sba_input_fmt = AMBI_FMT_ACN_SN3D; /* SBA configuration */ if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) @@ -1219,6 +1219,7 @@ static bool parseCmdlIVAS_enc( usage_enc(); return false; } + arg->sba_input_fmt = tmp; } #endif -- GitLab From a26392d2d13e8c69e49b3ece68097046a1dff548 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 15:57:17 +0100 Subject: [PATCH 014/130] fix table selection --- lib_util/ambi_convert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8155688354..8a6461d51f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -195,7 +195,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = SN3D_N3D; } - if ( out_format == AMBI_NORM_MAXN ) + else if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; } @@ -210,7 +210,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = N3D_SN3D; } - if ( in_format == AMBI_NORM_MAXN ) + else if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; } -- GitLab From b1436fe650cd93eb3cdc9b658ccb73fd4149020e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 18 Mar 2024 17:15:39 +0100 Subject: [PATCH 015/130] implement sba output convention selection on the decoder command line --- Workspace_msvc/decoder.vcxproj | 2 +- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_rend.vcxproj | 2 +- apps/decoder.c | 38 ++++++++++++++++++++++++++++++--- lib_dec/ivas_stat_dec.h | 16 ++++++++------ lib_dec/lib_dec.c | 8 +++++++ lib_dec/lib_dec.h | 4 ++++ lib_enc/ivas_stat_enc.h | 4 ++-- lib_util/ambi_convert.h | 5 +++++ 9 files changed, 67 insertions(+), 14 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 2228349d5e..a2661ac082 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_dec;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) + ..\lib_dec;..\lib_util;..\lib_com;..\lib_util;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;WIN32;$(Macros);%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index ea7ad47897..cf9efaf458 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_util;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index de8e09d283..ce6ff51bf7 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_util;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/decoder.c b/apps/decoder.c index d993eb4144..3114484255 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -43,6 +43,9 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" +#ifdef AMBISONICS_CONVENTIONS +#include "ambi_convert.h" +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" #endif @@ -144,6 +147,9 @@ typedef struct uint16_t acousticEnvironmentId; int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; +#ifdef AMBISONICS_CONVENTIONS + AMBI_FMT sba_output_fmt; +#endif } DecArguments; @@ -433,7 +439,12 @@ int main( asked_frame_size = arg.renderFramesize; if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, - arg.Opt_dpid_on, arg.acousticEnvironmentId, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) + arg.Opt_dpid_on, arg.acousticEnvironmentId, arg.delayCompensationEnabled +#ifdef AMBISONICS_CONVENTIONS + , + arg.sba_output_fmt +#endif + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1253,7 +1264,28 @@ static bool parseCmdlIVAS_dec( } #endif #endif /* #ifdef DEBUGGING */ +#ifdef AMBISONICS_CONVENTIONS + else if ( strcmp( argv_to_upper, "-SBA_CONVENTION" ) == 0 ) + { + int16_t tmp; + i++; + arg->sba_output_fmt = AMBI_FMT_ACN_SN3D; + /* SBA configuration */ + if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) + { + i++; + } + else + { + tmp = -1; /* this is to avoid a compilation warning */ + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number!\n\n" ); + usage_dec(); + return false; + } + arg->sba_output_fmt = tmp; + } +#endif else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { arg->inputFormat = IVAS_DEC_INPUT_FORMAT_MIME; @@ -1741,7 +1773,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = (int16_t) ( *seed * 31821L + 13849L ); + *seed = ( int16_t )( *seed * 31821L + 13849L ); return ( *seed ); } @@ -3212,7 +3244,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4deb6748e2..a1ef49e599 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -38,6 +38,7 @@ #include "cnst.h" #include "ivas_cnst.h" #include "stat_dec.h" +#include "ambi_convert.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" @@ -1016,12 +1017,15 @@ typedef struct decoder_config_structure int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ - float non_diegetic_pan_gain; /* non diegetic panning gain*/ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ +#ifdef AMBISONICS_CONVENTIONS + AMBI_FMT sba_output_fmt; +#endif + int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + float non_diegetic_pan_gain; /* non diegetic panning gain*/ + int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ + int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ + int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ #ifdef DEBUGGING /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index aeb8f84303..9943fb4f37 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -38,6 +38,7 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" +#include "ambi_convert.h" #include #include #include @@ -383,6 +384,10 @@ ivas_error IVAS_DEC_Configure( const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#ifdef AMBISONICS_CONVENTIONS + , + const AMBI_FMT sba_output_fmt +#endif ) { Decoder_Struct *st_ivas; @@ -423,6 +428,9 @@ ivas_error IVAS_DEC_Configure( st_ivas->element_mode_init = EVS_MONO; hDecoderConfig->nchan_out = 1; } +#ifdef AMBISONICS_CONVENTIONS + hDecoderConfig->sba_output_fmt = sba_output_fmt; +#endif if ( outputConfig != IVAS_AUDIO_CONFIG_EXTERNAL && outputConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 2dccb45525..9bedeb773f 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -137,6 +137,10 @@ ivas_error IVAS_DEC_Configure( const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#ifdef AMBISONICS_CONVENTIONS + , + const AMBI_FMT sba_output_fmt +#endif ); void IVAS_DEC_Close( diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index f92a598afb..5118765deb 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -37,6 +37,7 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" +#include "ambi_convert.h" #include "stat_enc.h" #include "ivas_stat_com.h" @@ -1182,14 +1183,13 @@ typedef struct encoder_config_structure int16_t sba_planar; /* Ambisonic (SBA) planar flag */ MC_LS_SETUP mc_input_setup; /* multichannel input ls setup */ int16_t ism_extended_metadata_flag; /* flag indicating extended metadata encoding, including radius and orientation (yaw, pitch) in ISM format */ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ int16_t Opt_DTX_ON; /* flag indicating DTX operation */ int16_t interval_SID; /* CNG and DTX - interval of SID update, default 8 */ int16_t var_SID_rate_flag; /* CNG and DTX - flag for variable SID rate */ #ifdef AMBISONICS_CONVENTIONS - int16_t sba_input_fmt; + AMBI_FMT sba_input_fmt; #endif int16_t Opt_RF_ON; /* flag indicating RF (channel-aware) mode */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 9bc0bb5d86..f789d4f18d 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -30,6 +30,9 @@ *******************************************************************************************************/ +#ifndef AMBI_CONVERT_H +#define AMBI_CONVERT_H + #include typedef enum @@ -61,3 +64,5 @@ int16_t convert_ambi_format( float* in[], float* out[], int16_t order, AMBI_FMT int16_t renormalize_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ); int16_t reorder_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); + +#endif \ No newline at end of file -- GitLab From 254ca1e575f60d54f49d599086e9be19ebbeef84 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Mar 2024 14:15:05 +0100 Subject: [PATCH 016/130] fix compile errors --- Workspace_msvc/lib_com.vcxproj | 4 ++-- apps/decoder.c | 2 +- lib_dec/lib_dec.h | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index d11b9087ee..8312a63fa5 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -59,7 +59,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_util;..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -308,4 +308,4 @@ - + \ No newline at end of file diff --git a/apps/decoder.c b/apps/decoder.c index 3114484255..998f814aa2 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1272,7 +1272,7 @@ static bool parseCmdlIVAS_dec( arg->sba_output_fmt = AMBI_FMT_ACN_SN3D; /* SBA configuration */ - if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) + if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%hd", &tmp ) > 0 ) { i++; } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 9bedeb773f..dc7b7dffe8 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -34,6 +34,9 @@ #define LIB_DEC_H #include "common_api_types.h" +#ifdef AMBISONICS_CONVENTIONS +#include "ambi_convert.h" +#endif #include /*---------------------------------------------------------------------* -- GitLab From ac2ef780b43f8175c0774a3e6a6fce33528e3ac5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Mar 2024 14:58:06 +0100 Subject: [PATCH 017/130] implement output conversion for SBA format --- apps/decoder.c | 2 +- lib_dec/ivas_sba_dec.c | 13 +++++++++++++ lib_dec/ivas_spar_decoder.c | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 998f814aa2..b9ec69f6f1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1279,7 +1279,7 @@ static bool parseCmdlIVAS_dec( else { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number!\n\n" ); + fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number!\n\n" ); usage_dec(); return false; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index af102dd96e..9628f7f47a 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -840,6 +840,19 @@ ivas_error ivas_sba_dec_render( } } +#ifdef AMBISONICS_CONVENTIONS + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 + ) + { + if ( st_ivas->hDecoderConfig->sba_output_fmt != 0 ) + { + convert_ambi_format( output_f, output_f, st_ivas->sba_analysis_order, AMBI_FMT_ACN_SN3D, st_ivas->hDecoderConfig->sba_output_fmt ); + } + } +#endif + if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 2e0f4ae0eb..533949fd6c 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1717,6 +1717,7 @@ void ivas_spar_dec_upmixer_sf( ivas_spar_dump_signal_wav( output_frame, NULL, output, hSpar->numOutChannels, spar_foa_dec_wav[3], "cldfbSynthesis()" ); #endif + hSpar->slots_rendered += hSpar->subframe_nbslots[hSpar->subframes_rendered]; hSpar->subframes_rendered++; -- GitLab From cbaa644e0c483ee5a02a66ca79b60b9a8ca5e922 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 19 Mar 2024 15:53:39 +0100 Subject: [PATCH 018/130] fix formatting --- apps/decoder.c | 6 +++--- lib_dec/ivas_sba_dec.c | 7 +++---- lib_dec/lib_dec.c | 4 ++-- lib_util/ambi_convert.h | 6 +++--- scripts/check-format.sh | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b9ec69f6f1..706aa39346 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -444,7 +444,7 @@ int main( , arg.sba_output_fmt #endif - ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -1773,7 +1773,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = ( int16_t )( *seed * 31821L + 13849L ); + *seed = (int16_t) ( *seed * 31821L + 13849L ); return ( *seed ); } @@ -3244,7 +3244,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 9628f7f47a..c4efaa1bc8 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -841,10 +841,9 @@ ivas_error ivas_sba_dec_render( } #ifdef AMBISONICS_CONVENTIONS - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 - ) + if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || + st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) { if ( st_ivas->hDecoderConfig->sba_output_fmt != 0 ) { diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 9943fb4f37..58eac4e99e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -385,8 +385,8 @@ ivas_error IVAS_DEC_Configure( const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ #ifdef AMBISONICS_CONVENTIONS - , - const AMBI_FMT sba_output_fmt + , + const AMBI_FMT sba_output_fmt #endif ) { diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index f789d4f18d..1848a218b4 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -59,10 +59,10 @@ typedef enum AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; -int16_t convert_ambi_format( float* in[], float* out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); +int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); -int16_t renormalize_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ); +int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ); -int16_t reorder_channels( float* in[], float* out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); +int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); #endif \ No newline at end of file diff --git a/scripts/check-format.sh b/scripts/check-format.sh index 154349de9f..079a1ed334 100755 --- a/scripts/check-format.sh +++ b/scripts/check-format.sh @@ -38,7 +38,7 @@ if [ ! -d "lib_com" ]; then exit 255 fi -CLANG_FORMAT=./clang-format.exe +CLANG_FORMAT=clang-format CLANG_FORMAT_REQUIRED_VERSION="13.0" # list (with space between entries) of substrings that are excluded from the file list, e.g. very large files -- GitLab From 8aff9db964d63f36b6d7819f8c3ab5b02bde7485 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 09:05:24 +0100 Subject: [PATCH 019/130] fix formatting --- lib_util/ambi_convert.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 1848a218b4..538cc5bbce 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -65,4 +65,5 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); -#endif \ No newline at end of file +#endif + -- GitLab From 2aee653eb1be7d4f3877c1eea2071289035a8b44 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 09:44:19 +0100 Subject: [PATCH 020/130] fix cmake build errors --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b96aa88d11..0267f6cc4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ add_library(lib_com ${libComSrcs} ${libComHeaders}) if(UNIX) target_link_libraries(lib_com PRIVATE m) endif() -target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug) +target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_util) if(INCLUDE_SPLIT) target_include_directories(lib_com PRIVATE lib_lc3plus) endif() @@ -147,13 +147,13 @@ file(GLOB libDebugSrcs "lib_debug/*.c") file(GLOB libDebugHeaders "lib_debug/*.h") add_library(lib_debug ${libDebugSrcs} ${libDebugHeaders}) target_link_libraries(lib_debug lib_com) -target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend) +target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend lib_util) file(GLOB libEncSrcs "lib_enc/*.c") file(GLOB libEncHeaders "lib_enc/*.h") add_library(lib_enc ${libEncSrcs} ${libEncHeaders}) target_link_libraries(lib_enc lib_com lib_debug) -target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend) +target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_util ) if(INCLUDE_SPLIT) target_include_directories(lib_enc PRIVATE lib_lc3plus) endif() @@ -188,18 +188,18 @@ if(NOT INCLUDE_SPLIT) endif() add_library(lib_rend ${libRendSrcs} ${libRendHeaders}) -target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed. +target_link_libraries(lib_rend lib_dec lib_com lib_debug lib_util) # Todo refactor: This dependency on lib_dec should be removed. if(INCLUDE_SPLIT) target_link_libraries(lib_rend lib_lc3plus) endif() -target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc) +target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc lib_util) file(GLOB libDecSrcs "lib_dec/*.c") file(GLOB libDecHeaders "lib_dec/*.h") add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) target_link_libraries(lib_dec lib_com lib_rend lib_debug) -target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc lib_util) file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") @@ -207,7 +207,7 @@ if(NOT INCLUDE_SPLIT) list(FILTER libUtilSrcs EXCLUDE REGEX ".*lib_util\/.*split_rend.*\.c$") endif() add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) -target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug) +target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug lib_util) if(INCLUDE_SPLIT) target_include_directories(lib_util PRIVATE lib_lc3plus) endif() @@ -233,7 +233,7 @@ endif() add_executable(IVAS_rend apps/renderer.c) target_link_libraries(IVAS_rend lib_rend lib_util) -target_include_directories(IVAS_rend PRIVATE lib_enc) +target_include_directories(IVAS_rend PRIVATE lib_enc lib_util) if(COPY_EXECUTABLES_FROM_BUILD_DIR) # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places) -- GitLab From 30ed7f00b266032b25d9b3a4b9b6a1fd1fc7d090 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 10:27:17 +0100 Subject: [PATCH 021/130] add missing conversions --- lib_util/ambi_convert.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8a6461d51f..8a7af6b078 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -71,6 +71,8 @@ static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, 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_, @@ -81,15 +83,16 @@ static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 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_ }; -static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, - 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 FM_MAXN[AMBI_MAX_CHANNELS] = { INV_SQRT_2, - 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_ }; +static const float SN3D_FM[AMBI_MAX_CHANNELS] = { SQRT_2_, + 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 FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, + 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_ }; /* ---------------------------- channel re-ordering tables @@ -199,6 +202,10 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = SN3D_MAXN; } + else if ( out_format == AMBI_NORM_FM ) + { + conversion_table = SN3D_FM; + } else { assert( 0 && "Unsupported conversion" ); @@ -214,6 +221,10 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = MAXN_SN3D; } + else if ( in_format == AMBI_NORM_FM ) + { + conversion_table = FM_SN3D; + } else { assert( 0 && "Unsupported conversion" ); @@ -262,11 +273,11 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL { if ( in_format == AMBI_CHANNEL_ORDER_FM ) { - idx_table = REORDER_ACN_FM; + idx_table = REORDER_FM_ACN; } if ( in_format == AMBI_CHANNEL_ORDER_SID ) { - idx_table = REORDER_ACN_SID; + idx_table = REORDER_SID_ACN; } else { -- GitLab From b053ae95032a3af7f9198fe7fff14697a9c59b69 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 10:35:24 +0100 Subject: [PATCH 022/130] fix formatting --- lib_util/ambi_convert.c | 23 +++++++++++------------ lib_util/ambi_convert.h | 1 - 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8a7af6b078..d804e1079d 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -72,7 +72,6 @@ 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_, @@ -84,15 +83,15 @@ static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, 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_ }; -static const float SN3D_FM[AMBI_MAX_CHANNELS] = { SQRT_2_, - 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_FM[AMBI_MAX_CHANNELS] = { SQRT_2_, + 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 FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, - 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_ }; +static const float FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, + 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_ }; /* ---------------------------- channel re-ordering tables @@ -202,10 +201,10 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = SN3D_MAXN; } - else if ( out_format == AMBI_NORM_FM ) - { + else if ( out_format == AMBI_NORM_FM ) + { conversion_table = SN3D_FM; - } + } else { assert( 0 && "Unsupported conversion" ); diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 538cc5bbce..b326dc4499 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -66,4 +66,3 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); #endif - -- GitLab From c6f168806d0093b328059df8af38918c45376637 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 16:51:22 +0100 Subject: [PATCH 023/130] fix uninitialized variable in decoder command line arguments --- apps/decoder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 706aa39346..3b6f03b6cf 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1085,6 +1085,10 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; +#ifdef AMBISONICS_CONVENTIONS + arg->sba_output_fmt = AMBI_FMT_ACN_SN3D; +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT arg->outputMdFilename = NULL; #endif @@ -1773,7 +1777,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = (int16_t) ( *seed * 31821L + 13849L ); + *seed = ( int16_t )( *seed * 31821L + 13849L ); return ( *seed ); } @@ -3244,7 +3248,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } -- GitLab From d705d8a9ec176aebd6a757e52b8eefc7dd31820a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 20 Mar 2024 16:59:15 +0100 Subject: [PATCH 024/130] fix formatting --- apps/decoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 3b6f03b6cf..db0eec6a8d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1777,7 +1777,7 @@ static void usage_dec( void ) static int16_t app_own_random( int16_t *seed ) { - *seed = ( int16_t )( *seed * 31821L + 13849L ); + *seed = (int16_t) ( *seed * 31821L + 13849L ); return ( *seed ); } @@ -3248,7 +3248,7 @@ static ivas_error decodeVoIP( /* we are finished when all packets have been received and jitter buffer is empty */ /* also stop when the input file contains less than two frames, because JBM cannot calculate a delay value and won't start decoding */ /* last clause should make sure that for BE tests we end up with the same number of samples...*/ - if ( nextPacketRcvTime_ms == ( uint32_t )( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) + if ( nextPacketRcvTime_ms == (uint32_t) ( -1 ) && ( IVAS_DEC_VoIP_IsEmpty( hIvasDec, nOutSamples ) || nFramesFed < 2 ) ) { break; } -- GitLab From 28b7306fc3f92f7609d966423c755dd50eb74e63 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 21 Mar 2024 08:55:58 +0100 Subject: [PATCH 025/130] fix uninitialized value in the arguments structure in the encoder --- apps/encoder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 68373f2c3e..948ed28372 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,8 +61,7 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig -{ +typedef union _EncInputFormatConfig { /* MONO details */ bool stereoToMonoDownmix; @@ -894,6 +893,9 @@ static void initArgStruct( EncArguments *arg ) arg->outputBitstreamFilename = NULL; arg->inputFs = 0; arg->inputFormat = IVAS_ENC_INPUT_MONO; +#ifdef AMBISONICS_CONVENTIONS + arg->sba_input_fmt = AMBI_FMT_ACN_SN3D; +#endif arg->is_binaural = false; arg->inputFormatConfig.stereoToMonoDownmix = false; arg->max_bwidth_user = false; @@ -926,6 +928,8 @@ static void initArgStruct( EncArguments *arg ) #endif arg->pca = false; + + return; } -- GitLab From e883a27e0bdc623105c92479328b4f4f4a268661 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 21 Mar 2024 08:57:08 +0100 Subject: [PATCH 026/130] fix formatting --- apps/encoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 948ed28372..8a4ac80608 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,7 +61,8 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig { +typedef union _EncInputFormatConfig +{ /* MONO details */ bool stereoToMonoDownmix; @@ -929,7 +930,6 @@ static void initArgStruct( EncArguments *arg ) arg->pca = false; - return; } -- GitLab From edd731083a6f3e2f3839bb0801ef7c4188969742 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 27 Mar 2024 13:40:14 +0100 Subject: [PATCH 027/130] add conversion tables for AmbiX convention --- lib_util/ambi_convert.c | 36 ++++++++++++++++++++++++++++++++++++ lib_util/ambi_convert.h | 10 ++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index d804e1079d..d99472d991 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -55,6 +55,9 @@ #define INV_SQRT_3_OVER_5_ 1.2909944f #define INV_SQRT_45_OVER_32_ 0.8432740f +#define INV_SQRT_FOUR_PI_ 0.2820947f /* 1/sqrt(4/pi) */ +#define SQRT_FOUR_PI_ 3.5449077f + #define AMBI_MAX_CHANNELS 16 /* -------------------------------- @@ -93,6 +96,23 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 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_ }; +/* + Curiously, not everyone seems to have the same understanding of what SN3D means. The Ambix paper + (Nachbar et al. : AMBIX - A SUGGESTED AMBISONICS FORMAT) has an additional 1/sqrt(4*pi) in the + normalization factor (see Eq. (3)) as compared to the tables in IVAS. +*/ + +static const float AMBIX_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_FOUR_PI_, + INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, + INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, + INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_ }; + +static const float SN3D_AMBIX[AMBI_MAX_CHANNELS] = { SQRT_FOUR_PI_, + SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, + SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, + SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_ }; + + /* ---------------------------- channel re-ordering tables ---------------------------- */ @@ -136,6 +156,10 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT 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_AMBIX ) + { + renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_AMBIX ); + } else if ( out_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); @@ -161,6 +185,10 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT 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_AMBIX ) + { + renormalize_channels( in, out, order, AMBI_NORM_AMBIX, AMBI_NORM_SN3D ); + } else if ( in_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); @@ -201,6 +229,10 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = SN3D_MAXN; } + else if ( out_format == AMBI_NORM_AMBIX ) + { + conversion_table = SN3D_AMBIX; + } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; @@ -220,6 +252,10 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = MAXN_SN3D; } + if ( in_format == AMBI_NORM_AMBIX ) + { + conversion_table = AMBIX_SN3D; + } else if ( in_format == AMBI_NORM_FM ) { conversion_table = FM_SN3D; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index b326dc4499..8e04212013 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -38,16 +38,18 @@ typedef enum { AMBI_FMT_ACN_SN3D = 0, - AMBI_FMT_ACN_N3D = 1, - AMBI_FMT_FM_MAXN = 2, - AMBI_FMT_SID_SN3D = 3, - AMBI_FMT_SID_N3D = 4 + AMBI_FMT_ACN_N3D, + AMBI_FMT_AMBIX, + AMBI_FMT_FM_MAXN, + AMBI_FMT_SID_SN3D, + AMBI_FMT_SID_N3D } AMBI_FMT; typedef enum { AMBI_NORM_SN3D = 0, AMBI_NORM_N3D, + AMBI_NORM_AMBIX, AMBI_NORM_MAXN, AMBI_NORM_FM } AMBI_CHANNEL_NORM; -- GitLab From f31ae5ffe2d5e4e5306cb56a31e2791c473ec5fc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 27 Mar 2024 13:46:56 +0100 Subject: [PATCH 028/130] explain ambisonics conventions in usage_enc/dec --- apps/decoder.c | 4 ++++ apps/encoder.c | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index db0eec6a8d..c4c38e8640 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1688,6 +1688,10 @@ static void usage_dec( void ) #else fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); +#endif +#ifdef AMBISONICS_CONVENTIONS + fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); #endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); diff --git a/apps/encoder.c b/apps/encoder.c index 8a4ac80608..6dfa5472ce 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,8 +61,7 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig -{ +typedef union _EncInputFormatConfig { /* MONO details */ bool stereoToMonoDownmix; @@ -1900,6 +1899,10 @@ static void usage_enc( void ) fprintf( stdout, "-sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D),\n" ); fprintf( stdout, " where Order specifies the Ambisionics order (1-3),\n" ); fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); +#ifdef AMBISONICS_CONVENTIONS + fprintf( stdout, "-sba_convention n : Ambisonics convention of the input signal" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); +#endif fprintf( stdout, "-masa Ch File : MASA format \n" ); fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); -- GitLab From b3671fada72a42597a31162ea2326d30b0f1ec1b Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 27 Mar 2024 14:00:01 +0100 Subject: [PATCH 029/130] fix formatting --- apps/encoder.c | 3 ++- lib_util/ambi_convert.c | 10 +++++----- lib_util/ambi_convert.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 6dfa5472ce..047faaaea8 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -61,7 +61,8 @@ static #define DEFAULT_FIXED_SID_RATE 8 /* DTX SID rate */ /* Additional config info for each input format */ -typedef union _EncInputFormatConfig { +typedef union _EncInputFormatConfig +{ /* MONO details */ bool stereoToMonoDownmix; diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index d99472d991..487491b388 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -55,8 +55,8 @@ #define INV_SQRT_3_OVER_5_ 1.2909944f #define INV_SQRT_45_OVER_32_ 0.8432740f -#define INV_SQRT_FOUR_PI_ 0.2820947f /* 1/sqrt(4/pi) */ -#define SQRT_FOUR_PI_ 3.5449077f +#define INV_SQRT_FOUR_PI_ 0.2820947f /* 1/sqrt(4/pi) */ +#define SQRT_FOUR_PI_ 3.5449077f #define AMBI_MAX_CHANNELS 16 @@ -96,9 +96,9 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 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_ }; -/* - Curiously, not everyone seems to have the same understanding of what SN3D means. The Ambix paper - (Nachbar et al. : AMBIX - A SUGGESTED AMBISONICS FORMAT) has an additional 1/sqrt(4*pi) in the +/* + Curiously, not everyone seems to have the same understanding of what SN3D means. The Ambix paper + (Nachbar et al. : AMBIX - A SUGGESTED AMBISONICS FORMAT) has an additional 1/sqrt(4*pi) in the normalization factor (see Eq. (3)) as compared to the tables in IVAS. */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 8e04212013..591194a06c 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -49,7 +49,7 @@ typedef enum { AMBI_NORM_SN3D = 0, AMBI_NORM_N3D, - AMBI_NORM_AMBIX, + AMBI_NORM_AMBIX, AMBI_NORM_MAXN, AMBI_NORM_FM } AMBI_CHANNEL_NORM; -- GitLab From df137ff081fe55fc8294b675c562ea0f4867b2a9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 27 Mar 2024 15:38:47 +0100 Subject: [PATCH 030/130] update readme.txt and README.md --- README.md | 2 +- readme.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 899e52ddc1..836d130196 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -please refer to the [Wiki](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/home) +please refer to the [Wiki](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/home). For the Ambisonics conventions see [here](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/Ambisonics-conventions). diff --git a/readme.txt b/readme.txt index 25275a7951..0cdb7ddaaf 100644 --- a/readme.txt +++ b/readme.txt @@ -191,6 +191,8 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D), where Order specifies the Ambisionics order (1-3), where positive (+) means full 3D and negative (-) only 2D/planar components to be coded +-sba_convention n : Ambisonics convention of the input signal + where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D) -masa Ch File : MASA format where Ch specifies the number of MASA input/transport channels (1 or 2): and File specifies input file containing parametric MASA metadata @@ -250,6 +252,8 @@ output_file : Output audio filename Options: -------- +-sba_convention n : Ambisonics convention of the output signal + where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D) -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump -VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump -- GitLab From f237cc7b57fdb1146c4aff46cce587fa06150c91 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 27 Mar 2024 17:17:48 +0100 Subject: [PATCH 031/130] fix usage_dec message --- apps/decoder.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index c4c38e8640..d3f6f8bcc3 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1688,10 +1688,6 @@ static void usage_dec( void ) #else fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); -#endif -#ifdef AMBISONICS_CONVENTIONS - fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); #endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); @@ -1703,6 +1699,10 @@ static void usage_dec( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); +#ifdef AMBISONICS_CONVENTIONS + fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); +#endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); -- GitLab From d4b187551c95ccb32795214a74ef1871f50e4833 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 14:39:24 +0200 Subject: [PATCH 032/130] fix conversion direction in the tables --- lib_util/ambi_convert.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 487491b388..2cefa3a11f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -64,34 +64,34 @@ normalization conversion tables -------------------------------- */ -static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, +static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, SQRT_3_, SQRT_3_, SQRT_3_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_5_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_, SQRT_7_ }; -static const float SN3D_N3D[AMBI_MAX_CHANNELS] = { 1.0f, +static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_3_, INV_SQRT_3_, INV_SQRT_3_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, 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, +static const float SN3D_MAXN[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, +static const float MAXN_SN3D[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_ }; -static const float SN3D_FM[AMBI_MAX_CHANNELS] = { SQRT_2_, +static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 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 FM_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_2, +static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_ }; -- GitLab From e5c322970a00564f9988f5d93952a0303177f3b6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 15:25:45 +0200 Subject: [PATCH 033/130] fix build errors with cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b400a28027..abc646562b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,7 +183,7 @@ file(GLOB libISARHeaders "lib_isar/*.h") add_library(lib_isar ${libISARSrcs} ${libISARHeaders}) target_link_libraries(lib_isar lib_com lib_debug lib_lc3plus) # Todo refactor: This dependency on lib_dec should be removed. -target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend) +target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend lib_util) add_executable(IVAS_cod apps/encoder.c) -- GitLab From a4acf15bed27c71c422ee7166af08a00e90e7def Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 10 Jun 2024 16:06:17 +0200 Subject: [PATCH 034/130] remove trivial conversion AMBIX<->SN3D --- lib_util/ambi_convert.c | 33 --------------------------------- lib_util/ambi_convert.h | 1 - 2 files changed, 34 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 2cefa3a11f..29298d37d4 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -96,23 +96,6 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_ }; -/* - Curiously, not everyone seems to have the same understanding of what SN3D means. The Ambix paper - (Nachbar et al. : AMBIX - A SUGGESTED AMBISONICS FORMAT) has an additional 1/sqrt(4*pi) in the - normalization factor (see Eq. (3)) as compared to the tables in IVAS. -*/ - -static const float AMBIX_SN3D[AMBI_MAX_CHANNELS] = { INV_SQRT_FOUR_PI_, - INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, - INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, - INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_, INV_SQRT_FOUR_PI_ }; - -static const float SN3D_AMBIX[AMBI_MAX_CHANNELS] = { SQRT_FOUR_PI_, - SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, - SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, - SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_, SQRT_FOUR_PI_ }; - - /* ---------------------------- channel re-ordering tables ---------------------------- */ @@ -156,10 +139,6 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT 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_AMBIX ) - { - renormalize_channels( in, out, order, AMBI_NORM_SN3D, AMBI_NORM_AMBIX ); - } else if ( out_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_ACN, AMBI_CHANNEL_ORDER_SID ); @@ -185,10 +164,6 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT 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_AMBIX ) - { - renormalize_channels( in, out, order, AMBI_NORM_AMBIX, AMBI_NORM_SN3D ); - } else if ( in_format == AMBI_FMT_SID_SN3D ) { reorder_channels( in, out, order, AMBI_CHANNEL_ORDER_SID, AMBI_CHANNEL_ORDER_ACN ); @@ -229,10 +204,6 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = SN3D_MAXN; } - else if ( out_format == AMBI_NORM_AMBIX ) - { - conversion_table = SN3D_AMBIX; - } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; @@ -252,10 +223,6 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = MAXN_SN3D; } - if ( in_format == AMBI_NORM_AMBIX ) - { - conversion_table = AMBIX_SN3D; - } else if ( in_format == AMBI_NORM_FM ) { conversion_table = FM_SN3D; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 591194a06c..2508b59307 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -49,7 +49,6 @@ typedef enum { AMBI_NORM_SN3D = 0, AMBI_NORM_N3D, - AMBI_NORM_AMBIX, AMBI_NORM_MAXN, AMBI_NORM_FM } AMBI_CHANNEL_NORM; -- GitLab From 924b0803c367b5733fec1a2398594256520f9231 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 15:36:17 +0200 Subject: [PATCH 035/130] fix command line parsing and add a check for a meaningful argument --- apps/decoder.c | 4 ++-- apps/encoder.c | 11 +++++++++-- lib_util/ambi_convert.h | 1 - 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 9cb609e539..6399263754 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1726,8 +1726,8 @@ static void usage_dec( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); #ifdef AMBISONICS_CONVENTIONS - fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); + fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D)" ); #endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); diff --git a/apps/encoder.c b/apps/encoder.c index 047faaaea8..ce5a55fe61 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1219,11 +1219,18 @@ static bool parseCmdlIVAS_enc( else { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number!\n\n" ); + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); usage_enc(); return false; } - arg->sba_input_fmt = tmp; + if( tmp < 0 || tmp > 4 ) + { + tmp = -1; /* this is to avoid a compilation warning */ + fprintf(stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n"); + usage_enc(); + return false; + } + arg->sba_input_fmt = tmp; } #endif diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 2508b59307..05aea37881 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -39,7 +39,6 @@ typedef enum { AMBI_FMT_ACN_SN3D = 0, AMBI_FMT_ACN_N3D, - AMBI_FMT_AMBIX, AMBI_FMT_FM_MAXN, AMBI_FMT_SID_SN3D, AMBI_FMT_SID_N3D -- GitLab From 794160673ead3fec1cb00d92a08b448be298f73f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 16:06:44 +0200 Subject: [PATCH 036/130] fix argument type in function IVAS_ENC_ConfigureForAmbisonics --- lib_enc/lib_enc.c | 6 +++--- lib_enc/lib_enc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 68b37bab7d..cb598c074f 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -485,16 +485,16 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ + const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ #endif - const bool Opt_PCA_ON /* i : PCA option flag */ + const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP , int16_t *numTransportChannels #endif #ifdef AMBISONICS_CONVENTIONS , - const int16_t sba_input_fmt + AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ #endif ) { diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 58860e3107..1ad4f15d6c 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -249,7 +249,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( #endif #ifdef AMBISONICS_CONVENTIONS , - const int16_t sba_input_fmt + AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ #endif ); -- GitLab From 73207853688ded55ab0ce8f563e20051a041bb97 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 16:08:10 +0200 Subject: [PATCH 037/130] remove unnecessary constant --- lib_util/ambi_convert.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 29298d37d4..ea2ff355e6 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -56,7 +56,6 @@ #define INV_SQRT_45_OVER_32_ 0.8432740f #define INV_SQRT_FOUR_PI_ 0.2820947f /* 1/sqrt(4/pi) */ -#define SQRT_FOUR_PI_ 3.5449077f #define AMBI_MAX_CHANNELS 16 -- GitLab From 32e5bb36ea4d7a05c3d0afd3662b888960eb8133 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 16:13:13 +0200 Subject: [PATCH 038/130] fix formatting --- apps/encoder.c | 16 ++++++++-------- lib_enc/lib_enc.c | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index ce5a55fe61..7600a23d5e 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1223,14 +1223,14 @@ static bool parseCmdlIVAS_enc( usage_enc(); return false; } - if( tmp < 0 || tmp > 4 ) - { - tmp = -1; /* this is to avoid a compilation warning */ - fprintf(stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n"); - usage_enc(); - return false; - } - arg->sba_input_fmt = tmp; + if ( tmp < 0 || tmp > 4 ) + { + tmp = -1; /* this is to avoid a compilation warning */ + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); + usage_enc(); + return false; + } + arg->sba_input_fmt = tmp; } #endif diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index cb598c074f..84f9fe2421 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -485,16 +485,16 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION - const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ + const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ #endif - const bool Opt_PCA_ON /* i : PCA option flag */ + const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP , int16_t *numTransportChannels #endif #ifdef AMBISONICS_CONVENTIONS , - AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ + AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ #endif ) { -- GitLab From 69c56ab38e06659ede1f646999563011ebf7515e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 11 Jun 2024 16:30:15 +0200 Subject: [PATCH 039/130] fix compile errors --- lib_enc/lib_enc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 1ad4f15d6c..13177c7cb9 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -34,6 +34,9 @@ #define LIB_ENC_H #include "common_api_types.h" +#ifdef AMBISONICS_CONVENTIONS +#include "ambi_convert.h" +#endif #include -- GitLab From af85f142b9966e272d4b23a00c49ece7503dc8e1 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 11:34:34 +0200 Subject: [PATCH 040/130] fix usage_enc output --- apps/encoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/encoder.c b/apps/encoder.c index 7600a23d5e..e063d7a7d7 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1909,7 +1909,7 @@ static void usage_enc( void ) fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); #ifdef AMBISONICS_CONVENTIONS fprintf( stdout, "-sba_convention n : Ambisonics convention of the input signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D)" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D)" ); #endif fprintf( stdout, "-masa Ch File : MASA format \n" ); fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); -- GitLab From 676ab6b65b7898a71d3b6f7084af85827ff4c481 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 11:38:05 +0200 Subject: [PATCH 041/130] add check for argument range to decoder command line parser --- apps/decoder.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index 6399263754..77a9138927 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1280,10 +1280,17 @@ static bool parseCmdlIVAS_dec( else { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number!\n\n" ); + fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number [0-4]!\n\n" ); usage_dec(); return false; } + if ( tmp < 0 || tmp > 4 ) + { + tmp = -1; + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); + usage_enc(); + return false; + } arg->sba_output_fmt = tmp; } #endif -- GitLab From 7aaf328a6539dd60f7e68b316aea20ff3adae622 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 11:56:03 +0200 Subject: [PATCH 042/130] fix compile error --- apps/decoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 77a9138927..84ec71a32f 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1287,8 +1287,8 @@ static bool parseCmdlIVAS_dec( if ( tmp < 0 || tmp > 4 ) { tmp = -1; - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); - usage_enc(); + fprintf( stderr, "Error: SBA output convention must be specified, expecting a number in [0,4]!\n\n" ); + usage_dec(); return false; } arg->sba_output_fmt = tmp; -- GitLab From a253dffe488b353020c39559d877ef7851281871 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 11:56:24 +0200 Subject: [PATCH 043/130] update readme.txt --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index a50bc83c1e..92907bedfd 100644 --- a/readme.txt +++ b/readme.txt @@ -195,7 +195,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, where Order specifies the Ambisionics order (1-3), where positive (+) means full 3D and negative (-) only 2D/planar components to be coded -sba_convention n : Ambisonics convention of the input signal - where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D) + where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D) -masa Ch File : MASA format where Ch specifies the number of MASA input/transport channels (1 or 2): and File specifies input file containing parametric MASA metadata @@ -257,7 +257,7 @@ output_file : Output audio filename Options: -------- -sba_convention n : Ambisonics convention of the output signal - where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (AMBIX), 3 (FuMa-MaxN), 4 (SID-SN3D), 5 (SID-N3D) + where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D) -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump -VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump -- GitLab From b958e6f09ff1955bac9727d59e2b9be5b173261d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 12:26:40 +0200 Subject: [PATCH 044/130] always attenuate the signal when converting to SN3D --- lib_util/ambi_convert.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index ea2ff355e6..314cf2edea 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -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 -------------------------------- */ @@ -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" ); } - for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + 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] = GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; + } + } + } + else { - float conversion_factor = conversion_table[i_chan]; - for ( i = 0; i < L_FRAME48k; i++ ) + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { - out[i_chan][i] = in[i_chan][i] * conversion_factor; + 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; + } } } -- GitLab From 1f9fadfc557dc48182fdab3ee0df423f3b629524 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 12:44:35 +0200 Subject: [PATCH 045/130] do rescaling for each conversion individually --- lib_util/ambi_convert.c | 47 +++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 314cf2edea..e5cdb4125a 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -55,18 +55,8 @@ #define INV_SQRT_3_OVER_5_ 1.2909944f #define INV_SQRT_45_OVER_32_ 0.8432740f -#define INV_SQRT_FOUR_PI_ 0.2820947f /* 1/sqrt(4/pi) */ - #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 @@ -82,6 +72,8 @@ static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_ }; +static const float N3D_SCALING_FACTOR = 1.0f; + static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, @@ -93,6 +85,8 @@ static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 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_ }; +static const float MAXN_SCALING_FACTOR = SQRT_3_OVER_5_; + static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 1.0f, 1.0f, 1.0f, @@ -104,6 +98,9 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_ }; +static const float FM_SCALING_FACTOR = INV_SQRT_2; + + /* ---------------------------- channel re-ordering tables ---------------------------- */ @@ -199,6 +196,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; const float *conversion_table = 0; + float sf = 1.0f; /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ @@ -207,14 +205,17 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; + sf = 1.f / N3D_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; + sf = 1.f / MAXN_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; + sf = 1.f / FM_SCALING_FACTOR; } else { @@ -226,14 +227,17 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; + sf = N3D_SCALING_FACTOR; } else if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; + sf = MAXN_SCALING_FACTOR; } else if ( in_format == AMBI_NORM_FM ) { conversion_table = FM_SN3D; + sf = FM_SCALING_FACTOR; } else { @@ -245,26 +249,13 @@ 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] = GLOBAL_SCALING_FACTOR * in[i_chan][i] * conversion_factor; - } - } - } - else + + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) { - for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + float conversion_factor = conversion_table[i_chan]; + for ( i = 0; i < L_FRAME48k; i++ ) { - 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; - } + out[i_chan][i] = sf * in[i_chan][i] * conversion_factor; } } -- GitLab From fa80b6ace2eb2094e2da566dd560cf9060fe60e2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 14:40:21 +0200 Subject: [PATCH 046/130] fix errors in MAXN and FuMa scaling tables --- lib_util/ambi_convert.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index e5cdb4125a..2e14c8a3e2 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -45,15 +45,15 @@ #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 TWO_OVER_SQRT_3_ 1.1547005f +#define THREE_OVER_SQRT_5_ 1.3416408f +#define SQRT_8_OVER_5_ 1.2649110f +#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 INV_TWO_OVER_SQRT_3_ 0.8660254f +#define INV_THREE_OVER_SQRT_5_ 0.7453560f +#define INV_SQRT_8_OVER_5_ 0.7905694f +#define INV_SQRT_45_OVER_32_ 0.8432740f #define AMBI_MAX_CHANNELS 16 @@ -77,26 +77,26 @@ static const float N3D_SCALING_FACTOR = 1.0f; static const float SN3D_MAXN[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_ }; + TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, + SQRT_8_OVER_5_, THREE_OVER_SQRT_5_, SQRT_45_OVER_32_, 1.0f, SQRT_45_OVER_32_, THREE_OVER_SQRT_5_, SQRT_8_OVER_5_ }; static const float MAXN_SN3D[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_ }; + INV_SQRT_8_OVER_5_, INV_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float MAXN_SCALING_FACTOR = SQRT_3_OVER_5_; +static const float MAXN_SCALING_FACTOR = 1.0f; static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 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_ }; + TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, + SQRT_8_OVER_5_, THREE_OVER_SQRT_5_, SQRT_45_OVER_32_, 1.0f, SQRT_45_OVER_32_, THREE_OVER_SQRT_5_, SQRT_8_OVER_5_ }; static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_ }; + INV_SQRT_8_OVER_5_, INV_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; static const float FM_SCALING_FACTOR = INV_SQRT_2; -- GitLab From b5ee967dfc6c1c13b6f3cb8796c4b3ee4f8cf9c9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 12 Jun 2024 17:14:08 +0200 Subject: [PATCH 047/130] wrap code in ib_util/ambi_convert.c into AMBISONICS_CONVENTIONS --- lib_util/ambi_convert.c | 3 +++ lib_util/ambi_convert.h | 1 + 2 files changed, 4 insertions(+) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 2e14c8a3e2..4da919a636 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -29,7 +29,9 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ +#include "options.h" +#ifdef AMBISONICS_CONVENTIONS #include #include #include "ivas_cnst.h" @@ -319,3 +321,4 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL return 0; } +#endif diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 05aea37881..d6db18a742 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -33,6 +33,7 @@ #ifndef AMBI_CONVERT_H #define AMBI_CONVERT_H +#include "options.h" #include typedef enum -- GitLab From aaa1cd10253580bb981a15d0d6f4be1332302e31 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 10:33:53 +0200 Subject: [PATCH 048/130] beautify code in convert_ambi_format --- lib_util/ambi_convert.c | 115 +++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 4da919a636..8af419b9c0 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -134,60 +134,79 @@ 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 ( in_format != AMBI_FMT_ACN_SN3D && out_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" ); - } + assert( 0 && "Conversion only supported to and from ACN-SN3D" ); } - else if ( out_format == AMBI_FMT_ACN_SN3D ) + + switch ( in_format ) { - 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" ); - } + 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!" ); } - else + + switch ( out_format ) { - assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + 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; -- GitLab From d9d83cc59a610533ad037648dafc0d97a9c10724 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 12:38:27 +0200 Subject: [PATCH 049/130] add format AMBI_FMT_FM_FM --- apps/decoder.c | 2 +- apps/encoder.c | 2 +- lib_util/ambi_convert.c | 10 +++++++++- lib_util/ambi_convert.h | 1 + readme.txt | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 84ec71a32f..30b5d0f265 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1734,7 +1734,7 @@ static void usage_dec( void ) fprintf( stdout, "--------\n" ); #ifdef AMBISONICS_CONVENTIONS fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D)" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D)" ); #endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); diff --git a/apps/encoder.c b/apps/encoder.c index e063d7a7d7..ec1773d5d2 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1909,7 +1909,7 @@ static void usage_enc( void ) fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); #ifdef AMBISONICS_CONVENTIONS fprintf( stdout, "-sba_convention n : Ambisonics convention of the input signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D)" ); + fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D)" ); #endif fprintf( stdout, "-masa Ch File : MASA format \n" ); fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8af419b9c0..7f70b8d721 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -156,6 +156,10 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT ch_ord_in = AMBI_CHANNEL_ORDER_FM; ch_norm_in = AMBI_NORM_MAXN; break; + case AMBI_FMT_FM_FM: + ch_ord_in = AMBI_CHANNEL_ORDER_FM; + ch_norm_in = AMBI_NORM_FM; + break; case AMBI_FMT_SID_SN3D: ch_ord_in = AMBI_CHANNEL_ORDER_SID; ch_norm_in = AMBI_NORM_SN3D; @@ -180,7 +184,11 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT break; case AMBI_FMT_FM_MAXN: ch_ord_out = AMBI_CHANNEL_ORDER_FM; - ch_norm_in = AMBI_NORM_MAXN; + ch_norm_out = AMBI_NORM_MAXN; + break; + case AMBI_FMT_FM_FM: + ch_ord_out = AMBI_CHANNEL_ORDER_FM; + ch_norm_out = AMBI_NORM_FM; break; case AMBI_FMT_SID_SN3D: ch_ord_out = AMBI_CHANNEL_ORDER_SID; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index d6db18a742..49fdc38838 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -41,6 +41,7 @@ typedef enum AMBI_FMT_ACN_SN3D = 0, AMBI_FMT_ACN_N3D, AMBI_FMT_FM_MAXN, + AMBI_FMT_FM_FM, AMBI_FMT_SID_SN3D, AMBI_FMT_SID_N3D } AMBI_FMT; diff --git a/readme.txt b/readme.txt index 92907bedfd..d360a541e5 100644 --- a/readme.txt +++ b/readme.txt @@ -195,7 +195,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, where Order specifies the Ambisionics order (1-3), where positive (+) means full 3D and negative (-) only 2D/planar components to be coded -sba_convention n : Ambisonics convention of the input signal - where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D) + where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D) -masa Ch File : MASA format where Ch specifies the number of MASA input/transport channels (1 or 2): and File specifies input file containing parametric MASA metadata @@ -257,7 +257,7 @@ output_file : Output audio filename Options: -------- -sba_convention n : Ambisonics convention of the output signal - where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (SID-SN3D), 4 (SID-N3D) + : where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D) -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump -VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump -- GitLab From bc335b7601282fea46a11406c06af6b89905bd50 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 15:25:03 +0200 Subject: [PATCH 050/130] add comments to clarify the meaning of the constants in ambi_convert.c --- lib_util/ambi_convert.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 7f70b8d721..de5ba47841 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -37,25 +37,25 @@ #include "ivas_cnst.h" #include "ambi_convert.h" -#define SQRT_2_ 1.4142135f -#define SQRT_3_ 1.7320508f -#define SQRT_5_ 2.2360679f -#define SQRT_7_ 2.64575131f - -#define INV_SQRT_2_ 0.7071067f -#define INV_SQRT_3_ 0.5773502f -#define INV_SQRT_5_ 0.4472135f -#define INV_SQRT_7_ 0.3779644f - -#define TWO_OVER_SQRT_3_ 1.1547005f -#define THREE_OVER_SQRT_5_ 1.3416408f -#define SQRT_8_OVER_5_ 1.2649110f -#define SQRT_45_OVER_32_ 1.1858541f - -#define INV_TWO_OVER_SQRT_3_ 0.8660254f -#define INV_THREE_OVER_SQRT_5_ 0.7453560f -#define INV_SQRT_8_OVER_5_ 0.7905694f -#define INV_SQRT_45_OVER_32_ 0.8432740f +#define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ +#define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ +#define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ +#define SQRT_7_ 2.64575131f /* sqrtf(7.0f) */ + +#define INV_SQRT_2_ 0.7071067f /* 1.0f/sqrtf(2.0f) */ +#define INV_SQRT_3_ 0.5773502f /* 1.0f/sqrtf(3.0f) */ +#define INV_SQRT_5_ 0.4472135f /* 1.0f/sqrtf(5.0f) */ +#define INV_SQRT_7_ 0.3779644f /* 1.0f/sqrtf(7.0f) */ + +#define TWO_OVER_SQRT_3_ 1.1547005f /* 2.0f/sqrtf(3.0f) */ +#define THREE_OVER_SQRT_5_ 1.3416408f /* 3.0f/sqrtf(5.0f) */ +#define SQRT_8_OVER_5_ 1.2649110f /* sqrtf(8.0f/5.0f) */ +#define SQRT_45_OVER_32_ 1.1858541f /* sqrtf(45.0f/32.0f) */ + +#define INV_TWO_OVER_SQRT_3_ 0.8660254f /* 1.0f/TWO_OVER_SQRT_3_ */ +#define INV_THREE_OVER_SQRT_5_ 0.7453560f /* 1.0f/THREE_OVER_SQRT_5_ */ +#define INV_SQRT_8_OVER_5_ 0.7905694f /* 1.0f/INV_SQRT_8_OVER_5_ */ +#define INV_SQRT_45_OVER_32_ 0.8432740f /* 1.0f/SQRT_45_OVER_32_ */ #define AMBI_MAX_CHANNELS 16 -- GitLab From 9216fb470ef298a01beabad20640fe5e690303d7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 15:25:35 +0200 Subject: [PATCH 051/130] fix formatting --- lib_util/ambi_convert.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index de5ba47841..8bd31cb95f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -37,25 +37,25 @@ #include "ivas_cnst.h" #include "ambi_convert.h" -#define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ -#define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ -#define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ -#define SQRT_7_ 2.64575131f /* sqrtf(7.0f) */ - -#define INV_SQRT_2_ 0.7071067f /* 1.0f/sqrtf(2.0f) */ -#define INV_SQRT_3_ 0.5773502f /* 1.0f/sqrtf(3.0f) */ -#define INV_SQRT_5_ 0.4472135f /* 1.0f/sqrtf(5.0f) */ -#define INV_SQRT_7_ 0.3779644f /* 1.0f/sqrtf(7.0f) */ - -#define TWO_OVER_SQRT_3_ 1.1547005f /* 2.0f/sqrtf(3.0f) */ -#define THREE_OVER_SQRT_5_ 1.3416408f /* 3.0f/sqrtf(5.0f) */ -#define SQRT_8_OVER_5_ 1.2649110f /* sqrtf(8.0f/5.0f) */ -#define SQRT_45_OVER_32_ 1.1858541f /* sqrtf(45.0f/32.0f) */ - -#define INV_TWO_OVER_SQRT_3_ 0.8660254f /* 1.0f/TWO_OVER_SQRT_3_ */ -#define INV_THREE_OVER_SQRT_5_ 0.7453560f /* 1.0f/THREE_OVER_SQRT_5_ */ -#define INV_SQRT_8_OVER_5_ 0.7905694f /* 1.0f/INV_SQRT_8_OVER_5_ */ -#define INV_SQRT_45_OVER_32_ 0.8432740f /* 1.0f/SQRT_45_OVER_32_ */ +#define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ +#define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ +#define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ +#define SQRT_7_ 2.64575131f /* sqrtf(7.0f) */ + +#define INV_SQRT_2_ 0.7071067f /* 1.0f/sqrtf(2.0f) */ +#define INV_SQRT_3_ 0.5773502f /* 1.0f/sqrtf(3.0f) */ +#define INV_SQRT_5_ 0.4472135f /* 1.0f/sqrtf(5.0f) */ +#define INV_SQRT_7_ 0.3779644f /* 1.0f/sqrtf(7.0f) */ + +#define TWO_OVER_SQRT_3_ 1.1547005f /* 2.0f/sqrtf(3.0f) */ +#define THREE_OVER_SQRT_5_ 1.3416408f /* 3.0f/sqrtf(5.0f) */ +#define SQRT_8_OVER_5_ 1.2649110f /* sqrtf(8.0f/5.0f) */ +#define SQRT_45_OVER_32_ 1.1858541f /* sqrtf(45.0f/32.0f) */ + +#define INV_TWO_OVER_SQRT_3_ 0.8660254f /* 1.0f/TWO_OVER_SQRT_3_ */ +#define INV_THREE_OVER_SQRT_5_ 0.7453560f /* 1.0f/THREE_OVER_SQRT_5_ */ +#define INV_SQRT_8_OVER_5_ 0.7905694f /* 1.0f/INV_SQRT_8_OVER_5_ */ +#define INV_SQRT_45_OVER_32_ 0.8432740f /* 1.0f/SQRT_45_OVER_32_ */ #define AMBI_MAX_CHANNELS 16 -- GitLab From 356897de0595fcb6b88e98d760fb72442ddf3a0a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 15:27:28 +0200 Subject: [PATCH 052/130] store the constant SQRT_7_ with 7 digits precision --- lib_util/ambi_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8bd31cb95f..5cfa1832e5 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -40,7 +40,7 @@ #define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ #define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ #define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ -#define SQRT_7_ 2.64575131f /* sqrtf(7.0f) */ +#define SQRT_7_ 2.6457513f /* sqrtf(7.0f) */ #define INV_SQRT_2_ 0.7071067f /* 1.0f/sqrtf(2.0f) */ #define INV_SQRT_3_ 0.5773502f /* 1.0f/sqrtf(3.0f) */ -- GitLab From 260155369f00dc29b86f06620c49a9753513e7c7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 13 Jun 2024 15:33:58 +0200 Subject: [PATCH 053/130] fix formatting --- lib_util/ambi_convert.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 5cfa1832e5..ba12b8ec1e 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -37,10 +37,10 @@ #include "ivas_cnst.h" #include "ambi_convert.h" -#define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ -#define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ -#define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ -#define SQRT_7_ 2.6457513f /* sqrtf(7.0f) */ +#define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ +#define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ +#define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ +#define SQRT_7_ 2.6457513f /* sqrtf(7.0f) */ #define INV_SQRT_2_ 0.7071067f /* 1.0f/sqrtf(2.0f) */ #define INV_SQRT_3_ 0.5773502f /* 1.0f/sqrtf(3.0f) */ -- GitLab From 0ef5c4cd8b358330aa9c12b098d2ce89f7315621 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 12:49:14 +0200 Subject: [PATCH 054/130] add test vectors in different ambisonics conventions --- scripts/testv/stv3OA48c_FuMa.wav | 3 +++ scripts/testv/stv3OA48c_N3D.wav | 3 +++ scripts/testv/stv3OA48c_SN3D-SID.wav | 3 +++ 3 files changed, 9 insertions(+) create mode 100644 scripts/testv/stv3OA48c_FuMa.wav create mode 100644 scripts/testv/stv3OA48c_N3D.wav create mode 100644 scripts/testv/stv3OA48c_SN3D-SID.wav diff --git a/scripts/testv/stv3OA48c_FuMa.wav b/scripts/testv/stv3OA48c_FuMa.wav new file mode 100644 index 0000000000..6b52c739ce --- /dev/null +++ b/scripts/testv/stv3OA48c_FuMa.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:95f21ed4f2134ff6a43e2f3a1654396e1c02bc5e78f3ddd69071adb16567cb53 +size 30720844 diff --git a/scripts/testv/stv3OA48c_N3D.wav b/scripts/testv/stv3OA48c_N3D.wav new file mode 100644 index 0000000000..150b8a91d9 --- /dev/null +++ b/scripts/testv/stv3OA48c_N3D.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68c29e8be1afe7cac05914a6152438f86a417b30e88241eb25b061de14a98b73 +size 30720844 diff --git a/scripts/testv/stv3OA48c_SN3D-SID.wav b/scripts/testv/stv3OA48c_SN3D-SID.wav new file mode 100644 index 0000000000..6e46a91732 --- /dev/null +++ b/scripts/testv/stv3OA48c_SN3D-SID.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:363204e18b68f242fd97d76fbd0a911d9b8a479ecf9b68ffaa47114ddc2ab9af +size 30720844 -- GitLab From 86103456f5c158a6f25536757f5467e454d6a527 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 13:09:37 +0200 Subject: [PATCH 055/130] add test cases with SBA input and output conversions --- scripts/config/self_test.prm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 3a071276cb..474d501e27 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -750,6 +750,18 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 1 96000 48 testv/stvFOA48c.wav bit ../IVAS_dec FOA 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_FOA.tst +// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, ACN-N3D input +../IVAS_cod -sba 3 -sba_convention 1 96000 48 testv/stvHOA48c_N3D.wav bit +../IVAS_dec -sba_convention 3 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_ACN-N3D_FM-FM.tst + +// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, FM input +../IVAS_cod -sba 3 -sba_convention 3 96000 48 testv/stvHOA48c_FuMa.wav bit +../IVAS_dec -sba_convention 5 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_FM-FM_SID-SN3D.tst + +// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, SN3D-SID input +../IVAS_cod -sba 5 -sba_convention 3 96000 48 testv/stvHOA48c_SN3D-SID.wav bit +../IVAS_dec -sba_convention 0 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_SN3D-SID_ACN-SN3D.tst + // SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, HR ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_128000_32-32_Binaural_room_Headrot.tst -- GitLab From eb4ee2b3368a5578eac3d20a60be5267a5fd8ed6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 13:47:38 +0200 Subject: [PATCH 056/130] fix typo in scripts/config/self_test.prm --- scripts/config/self_test.prm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 474d501e27..51911eda41 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -759,7 +759,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_dec -sba_convention 5 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_FM-FM_SID-SN3D.tst // SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, SN3D-SID input -../IVAS_cod -sba 5 -sba_convention 3 96000 48 testv/stvHOA48c_SN3D-SID.wav bit +../IVAS_cod -sba 3 -sba_convention 5 96000 48 testv/stvHOA48c_SN3D-SID.wav bit ../IVAS_dec -sba_convention 0 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_SN3D-SID_ACN-SN3D.tst // SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, HR -- GitLab From dffd6aa0fdd39e3fce46b7c65bfd776b0877cef9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 13:50:36 +0200 Subject: [PATCH 057/130] fix argument check in encoder and decoder command line parser --- apps/decoder.c | 6 +++--- apps/encoder.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 30b5d0f265..85b0413315 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1280,14 +1280,14 @@ static bool parseCmdlIVAS_dec( else { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number [0-4]!\n\n" ); + fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number [0-5]!\n\n" ); usage_dec(); return false; } - if ( tmp < 0 || tmp > 4 ) + if ( tmp < 0 || tmp > 5 ) { tmp = -1; - fprintf( stderr, "Error: SBA output convention must be specified, expecting a number in [0,4]!\n\n" ); + fprintf( stderr, "Error: SBA output convention must be specified, expecting a number in [0,5]!\n\n" ); usage_dec(); return false; } diff --git a/apps/encoder.c b/apps/encoder.c index ec1773d5d2..521298262e 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1219,14 +1219,14 @@ static bool parseCmdlIVAS_enc( else { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,5]!\n\n" ); usage_enc(); return false; } - if ( tmp < 0 || tmp > 4 ) + if ( tmp < 0 || tmp > 5 ) { tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,4]!\n\n" ); + fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,5]!\n\n" ); usage_enc(); return false; } -- GitLab From 6d7399875414d7254667418caf4cdccb355f8c62 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 13:58:33 +0200 Subject: [PATCH 058/130] rename scaling-factors variables --- lib_util/ambi_convert.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index ba12b8ec1e..bcb997a2ca 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -74,7 +74,7 @@ static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_ }; -static const float N3D_SCALING_FACTOR = 1.0f; +static const float N3D_SN3D_SCALING_FACTOR = 1.0f; static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, @@ -87,7 +87,7 @@ static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 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_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float MAXN_SCALING_FACTOR = 1.0f; +static const float MAXN_SN3D_SCALING_FACTOR = 1.0f; static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, @@ -100,7 +100,7 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float FM_SCALING_FACTOR = INV_SQRT_2; +static const float FM_SN3D_SCALING_FACTOR = INV_SQRT_2; /* ---------------------------- @@ -234,17 +234,17 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; - sf = 1.f / N3D_SCALING_FACTOR; + sf = 1.f / N3D_SN3D_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; - sf = 1.f / MAXN_SCALING_FACTOR; + sf = 1.f / MAXN_SN3D_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; - sf = 1.f / FM_SCALING_FACTOR; + sf = 1.f / FM_SN3D_SCALING_FACTOR; } else { @@ -256,17 +256,17 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; - sf = N3D_SCALING_FACTOR; - } + sf = N3D_SN3D_SCALING_FACTOR; + } else if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; - sf = MAXN_SCALING_FACTOR; + sf = MAXN_SN3D_SCALING_FACTOR; } else if ( in_format == AMBI_NORM_FM ) { conversion_table = FM_SN3D; - sf = FM_SCALING_FACTOR; + sf = FM_SN3D_SCALING_FACTOR; } else { -- GitLab From a0dad85404efe1b6e1b0ec287c7a2f980f1355a8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 14 Jun 2024 14:20:15 +0200 Subject: [PATCH 059/130] fix formatting --- lib_util/ambi_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index bcb997a2ca..aaaff3ed55 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -257,7 +257,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA { conversion_table = N3D_SN3D; sf = N3D_SN3D_SCALING_FACTOR; - } + } else if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; -- GitLab From 2da1bb0cc52ed3210c9c7c4f8539048fa2ae536c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 08:54:11 +0200 Subject: [PATCH 060/130] temporarily delete the new test cases to fix pipeline --- scripts/config/self_test.prm | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index 51911eda41..3a071276cb 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -750,18 +750,6 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 ../IVAS_cod -sba 1 96000 48 testv/stvFOA48c.wav bit ../IVAS_dec FOA 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_FOA.tst -// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, ACN-N3D input -../IVAS_cod -sba 3 -sba_convention 1 96000 48 testv/stvHOA48c_N3D.wav bit -../IVAS_dec -sba_convention 3 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_ACN-N3D_FM-FM.tst - -// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, FM input -../IVAS_cod -sba 3 -sba_convention 3 96000 48 testv/stvHOA48c_FuMa.wav bit -../IVAS_dec -sba_convention 5 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_FM-FM_SID-SN3D.tst - -// SBA at 96 kbps, 48kHz in, 48kHz out, HOA out, SN3D-SID input -../IVAS_cod -sba 3 -sba_convention 5 96000 48 testv/stvHOA48c_SN3D-SID.wav bit -../IVAS_dec -sba_convention 0 HOA3 48 bit testv/stvFOA48c.wav_SBA_96000_48-48_HOA_SN3D-SID_ACN-SN3D.tst - // SBA at 128 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, HR ../IVAS_cod -sba 3 128000 32 testv/stv3OA32c.wav bit ../IVAS_dec -t testv/headrot_case00_3000_q.csv BINAURAL_ROOM_IR 32 bit testv/stv3OA32c.wav_SBA_128000_32-32_Binaural_room_Headrot.tst -- GitLab From fc159995a2fa0b3da36893f602890939e6fae370 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 12:29:17 +0200 Subject: [PATCH 061/130] never amplify any channel with any conversion --- lib_util/ambi_convert.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index aaaff3ed55..d31704063f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -75,6 +75,7 @@ static const float N3D_SN3D[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 N3D_SN3D_SCALING_FACTOR = 1.0f; +static const float SN3D_N3D_SCALING_FACTOR = INV_SQRT_7_; static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, @@ -88,6 +89,8 @@ static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_8_OVER_5_, INV_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; static const float MAXN_SN3D_SCALING_FACTOR = 1.0f; +static const float SN3D_MAXN_SCALING_FACTOR = INV_THREE_OVER_SQRT_5_; + static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, @@ -101,6 +104,7 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, INV_SQRT_8_OVER_5_, INV_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; static const float FM_SN3D_SCALING_FACTOR = INV_SQRT_2; +static const float SN3D_FM_SCALING_FACTOR = INV_THREE_OVER_SQRT_5_; /* ---------------------------- @@ -234,17 +238,17 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; - sf = 1.f / N3D_SN3D_SCALING_FACTOR; + sf = SN3D_N3D_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; - sf = 1.f / MAXN_SN3D_SCALING_FACTOR; + sf = SN3D_MAXN_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; - sf = 1.f / FM_SN3D_SCALING_FACTOR; + sf = SN3D_FM_SCALING_FACTOR; } else { -- GitLab From 2e77d3d9c061b18338c71584e8950c322aed7f15 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 17 Jun 2024 12:36:59 +0200 Subject: [PATCH 062/130] fix formatting --- lib_util/ambi_convert.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index d31704063f..76939aa659 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -92,7 +92,6 @@ static const float MAXN_SN3D_SCALING_FACTOR = 1.0f; static const float SN3D_MAXN_SCALING_FACTOR = INV_THREE_OVER_SQRT_5_; - static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 1.0f, 1.0f, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, -- GitLab From d5db6eb00aaade7f2c8611d1f2bd5f7fe700eb28 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:33:10 +0200 Subject: [PATCH 063/130] revert changes to VS project files --- Workspace_msvc/decoder.vcxproj | 2 +- Workspace_msvc/lib_com.vcxproj | 4 ++-- Workspace_msvc/lib_dec.vcxproj | 4 ++-- Workspace_msvc/lib_enc.vcxproj | 4 ++-- Workspace_msvc/lib_isar.vcxproj | 4 ++-- Workspace_msvc/lib_rend.vcxproj | 4 ++-- Workspace_msvc/lib_util.vcxproj | 4 +--- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Workspace_msvc/decoder.vcxproj b/Workspace_msvc/decoder.vcxproj index 00e29933a4..c124382c9c 100644 --- a/Workspace_msvc/decoder.vcxproj +++ b/Workspace_msvc/decoder.vcxproj @@ -173,4 +173,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 9706441d6d..223f837a2e 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -59,7 +59,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -311,4 +311,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 4f4803ac82..3c7ea3e597 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_rend;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -348,4 +348,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 91a19db89b..ba0c4c9b6f 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -364,4 +364,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_isar.vcxproj b/Workspace_msvc/lib_isar.vcxproj index 2f089e3002..fceeb731ce 100644 --- a/Workspace_msvc/lib_isar.vcxproj +++ b/Workspace_msvc/lib_isar.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_util;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -197,4 +197,4 @@ - \ No newline at end of file + diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index fcb56e1d21..27d4a19a69 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -68,7 +68,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_isar;..\lib_lc3plus;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -209,4 +209,4 @@ - + \ No newline at end of file diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 37dc0515c5..79e5545f3f 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -100,7 +100,6 @@ - @@ -128,7 +127,6 @@ - @@ -165,4 +163,4 @@ - + \ No newline at end of file -- GitLab From 52dfffedfeb6871d7a2fb54b778be567973acf54 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:35:26 +0200 Subject: [PATCH 064/130] remove sba_convention argument from encoder.c and decoder.c --- apps/decoder.c | 245 +++++++++++++++++++++++++++++++++++++------------ apps/encoder.c | 57 +----------- 2 files changed, 187 insertions(+), 115 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 85b0413315..2cd7608cbc 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -43,11 +43,10 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" -#ifdef AMBISONICS_CONVENTIONS -#include "ambi_convert.h" -#endif #include "aeid_file_reader.h" +#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" +#endif #ifdef VARIABLE_SPEED_DECODING #include "tsm_scale_file_reader.h" #include @@ -135,7 +134,9 @@ typedef struct float non_diegetic_pan_gain; bool renderConfigEnabled; char *renderConfigFilename; +#ifdef SPLIT_REND_WITH_HEAD_ROT char *outputMdFilename; +#endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; @@ -153,9 +154,6 @@ typedef struct AcousticEnvironmentSequence aeSequence; int16_t Opt_dpid_on; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; -#ifdef AMBISONICS_CONVENTIONS - AMBI_FMT sba_output_fmt; -#endif } DecArguments; @@ -166,7 +164,11 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); +#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#else +static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); +#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING @@ -188,8 +190,10 @@ int main( bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; ivas_error error = IVAS_ERR_UNKNOWN; +#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA splitRendBits; uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; +#endif /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; @@ -222,7 +226,9 @@ int main( reset_mem( USE_BYTES ); #endif +#ifdef SPLIT_REND_WITH_HEAD_ROT splitRendBits.bits_buf = splitRendBitsBuf; +#endif /*------------------------------------------------------------------------------------------* * Parse command-line arguments @@ -270,6 +276,7 @@ int main( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { fprintf( stdout, "Output metadata file: %s\n", arg.outputWavFilename ); @@ -280,6 +287,7 @@ int main( fprintf( stdout, "Output metadata file: %s\n", arg.outputMdFilename ); } else +#endif { fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); } @@ -313,7 +321,11 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM +#endif + ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -413,8 +425,12 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - arg.Opt_non_diegetic_pan == 0 ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB +#ifdef SPLIT_REND_WITH_HEAD_ROT + && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 +#endif + ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -434,13 +450,7 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, - arg.Opt_dpid_on, aeID, arg.delayCompensationEnabled -#ifdef AMBISONICS_CONVENTIONS - , - arg.sba_output_fmt -#endif - ) ) != IVAS_ERR_OK ) - + arg.Opt_dpid_on, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -456,6 +466,7 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } +#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ @@ -477,6 +488,7 @@ int main( arg.enableHeadRotation = true; } +#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -605,6 +617,7 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 ) @@ -612,6 +625,13 @@ int main( fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); goto cleanup; } +#else + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" ); + goto cleanup; + } +#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { @@ -635,6 +655,7 @@ int main( fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && @@ -658,6 +679,7 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } } +#endif if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -677,9 +699,13 @@ int main( renderConfig.roomAcoustics.override = true; } +#ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; +#endif +#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -837,7 +863,11 @@ int main( } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); +#else + error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); +#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -997,6 +1027,7 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL; } +#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; @@ -1005,6 +1036,7 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; } +#endif else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -1080,11 +1112,9 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; -#ifdef AMBISONICS_CONVENTIONS - arg->sba_output_fmt = AMBI_FMT_ACN_SN3D; -#endif - +#ifdef SPLIT_REND_WITH_HEAD_ROT arg->outputMdFilename = NULL; +#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; @@ -1265,35 +1295,7 @@ static bool parseCmdlIVAS_dec( } #endif #endif /* #ifdef DEBUGGING */ -#ifdef AMBISONICS_CONVENTIONS - else if ( strcmp( argv_to_upper, "-SBA_CONVENTION" ) == 0 ) - { - int16_t tmp; - i++; - arg->sba_output_fmt = AMBI_FMT_ACN_SN3D; - /* SBA configuration */ - if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%hd", &tmp ) > 0 ) - { - i++; - } - else - { - tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA ouput convention must be specified, expecting a number [0-5]!\n\n" ); - usage_dec(); - return false; - } - if ( tmp < 0 || tmp > 5 ) - { - tmp = -1; - fprintf( stderr, "Error: SBA output convention must be specified, expecting a number in [0,5]!\n\n" ); - usage_dec(); - return false; - } - arg->sba_output_fmt = tmp; - } -#endif else if ( strcmp( argv_to_upper, "-MIME" ) == 0 ) { arg->inputFormat = IVAS_DEC_INPUT_FORMAT_MIME; @@ -1440,6 +1442,7 @@ static bool parseCmdlIVAS_dec( } i += 2; } +#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) { arg->outputMdFilename = argv[i + 1]; @@ -1451,6 +1454,7 @@ static bool parseCmdlIVAS_dec( } i += 2; } +#endif else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; @@ -1720,8 +1724,13 @@ static void usage_dec( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" ); +#else + fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); + fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); +#endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); fprintf( stdout, " layout file. See readme.txt for details.\n" ); @@ -1732,10 +1741,6 @@ static void usage_dec( void ) fprintf( stdout, "Options:\n" ); fprintf( stdout, "--------\n" ); -#ifdef AMBISONICS_CONVENTIONS - fprintf( stdout, "-sba_convention n : Ambisonics convention of the output signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D)" ); -#endif fprintf( stdout, "-VOIP : VoIP mode: RTP in G192\n" ); fprintf( stdout, "-VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump\n" ); fprintf( stdout, "-VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump\n" ); @@ -1771,7 +1776,9 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); +#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); +#endif fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); #ifdef DEBUGGING @@ -1828,11 +1835,15 @@ static int16_t app_own_random( int16_t *seed ) *---------------------------------------------------------------------*/ static ivas_error initOnFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: */ - const DecArguments arg, /* i : */ - const int16_t numInitialBadFrames, /* i : */ - int16_t *numOutSamples, /* i/o: */ - int16_t *vec_pos_len, /* i/o: */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: */ + const DecArguments arg, /* i : */ + const int16_t numInitialBadFrames, /* i : */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + int16_t *numOutSamples, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ +#else + const uint16_t numOutSamples, /* i : */ +#endif int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1841,10 +1852,17 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ - uint16_t *pNumObj, /* o : */ - SplitFileReadWrite **splitRendWriter ) +#ifdef SPLIT_REND_WITH_HEAD_ROT + uint16_t *pNumObj, /* o : */ + SplitFileReadWrite **splitRendWriter +#else + uint16_t *pNumObj /* o : */ +#endif +) { +#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t isSplitRend, isSplitCoded; +#endif ivas_error error = IVAS_ERR_UNKNOWN; /* Now delay, number of output channels and frame size are known */ @@ -1854,6 +1872,7 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); @@ -1870,6 +1889,7 @@ static ivas_error initOnFirstGoodFrame( { pFullDelayNumSamples[0] = 0; } +#endif if ( !arg.delayCompensationEnabled ) { @@ -1891,6 +1911,7 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { /* Open split rendering metadata writer */ @@ -1899,8 +1920,10 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_CODEC splitRendCodec; int16_t splitRendCodecFrameSizeMs; ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; +#endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) { @@ -1908,7 +1931,11 @@ static ivas_error initOnFirstGoodFrame( return error; } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, &splitRendCodecFrameSizeMs, &lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); return error; @@ -1916,7 +1943,11 @@ static ivas_error initOnFirstGoodFrame( if ( isSplitCoded ) { +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -1930,7 +1961,11 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_INVALID_SPLIT_REND_CONFIG; } +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) +#else + if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -1940,19 +1975,23 @@ static ivas_error initOnFirstGoodFrame( if ( !isSplitCoded ) { +#endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); return error; } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; @@ -1962,8 +2001,12 @@ static ivas_error initOnFirstGoodFrame( splitRendBitsZero.buf_len = 0; splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; +#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS splitRendBitsZero.codec_frame_size_ms = 0; splitRendBitsZero.isar_frame_size_ms = 20; +#else + splitRendBitsZero.codec_frame_size_ms = 20; +#endif if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) { @@ -1973,10 +2016,19 @@ static ivas_error initOnFirstGoodFrame( } else { +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *pRemainingDelayNumSamples < *numOutSamples ) +#else + if ( *pRemainingDelayNumSamples < numOutSamples ) +#endif { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#else + if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -1985,9 +2037,15 @@ static ivas_error initOnFirstGoodFrame( } else { +#ifdef SPLIT_REND_WITH_HEAD_ROT *pRemainingDelayNumSamples -= *numOutSamples; +#else + *pRemainingDelayNumSamples -= numOutSamples; +#endif } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } free( zeroBuf ); @@ -2074,6 +2132,7 @@ static ivas_error initOnFirstGoodFrame( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { if ( numOutSamples == NULL || vec_pos_len == NULL ) @@ -2093,6 +2152,7 @@ static ivas_error initOnFirstGoodFrame( return error; } } +#endif return IVAS_ERR_OK; } @@ -2111,7 +2171,9 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, +#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA *splitRendBits, +#endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -2147,6 +2209,7 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; +#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; int16_t isSplitRend, isSplitCoded; @@ -2161,6 +2224,7 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); return error; } +#endif IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; @@ -2319,6 +2383,7 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -2334,6 +2399,7 @@ static ivas_error decodeG192( } else { +#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -2342,11 +2408,17 @@ static ivas_error decodeG192( goto cleanup; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif for ( i = 0; i < num_subframes; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2470,6 +2542,7 @@ static ivas_error decodeG192( } } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) @@ -2483,14 +2556,21 @@ static ivas_error decodeG192( } else { +#endif +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } nSamplesRendered += nSamplesRendered_loop; nSamplesToRender -= nSamplesRendered_loop; +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif if ( needNewFrame ) { frame++; @@ -2524,7 +2604,11 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } @@ -2538,6 +2622,7 @@ static ivas_error decodeG192( /* Write current frame */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) @@ -2549,6 +2634,7 @@ static ivas_error decodeG192( if ( !isSplitCoded ) { +#endif if ( delayNumSamples < nOutSamples ) { if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) @@ -2562,7 +2648,9 @@ static ivas_error decodeG192( { delayNumSamples -= nOutSamples; } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif } /* Write ISm metadata to external file(s) */ @@ -2683,7 +2771,11 @@ static ivas_error decodeG192( goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2691,7 +2783,11 @@ static ivas_error decodeG192( } /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2810,14 +2906,18 @@ static ivas_error decodeG192( memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( afWriter != NULL ) { +#endif if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); goto cleanup; } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -2828,7 +2928,9 @@ static ivas_error decodeG192( cleanup: RenderConfigReader_close( &renderConfigReader ); +#ifdef SPLIT_REND_WITH_HEAD_ROT split_rend_reader_writer_close( &splitRendWriter ); +#endif AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); #ifdef DEBUGGING @@ -3180,6 +3282,7 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -3195,6 +3298,7 @@ static ivas_error decodeVoIP( } else { +#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -3204,11 +3308,17 @@ static ivas_error decodeVoIP( goto cleanup; } } +#ifdef SPLIT_REND_WITH_HEAD_ROT } +#endif for ( i = 0; i < num_subframes; i++ ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3295,10 +3405,18 @@ static ivas_error decodeVoIP( /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef SUPPORT_JBM_TRACEFILE + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3335,10 +3453,15 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { +#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) +#else + if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, + &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) +#endif { goto cleanup; } @@ -3443,7 +3566,11 @@ static ivas_error decodeVoIP( int16_t nSamplesFlushed = 0; /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/encoder.c b/apps/encoder.c index 521298262e..b00f4f75fd 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -38,9 +38,6 @@ #include "ism_file_reader.h" #include "jbm_file_reader.h" #include "masa_file_reader.h" -#ifdef AMBISONICS_CONVENTIONS -#include "ambi_convert.h" -#endif #ifdef DEBUGGING #include "debug.h" #endif @@ -124,9 +121,6 @@ typedef struct bool max_bwidth_user; IVAS_ENC_BANDWIDTH maxBandwidth; const char *bandwithProfileFile; -#ifdef AMBISONICS_CONVENTIONS - AMBI_FMT sba_input_fmt; -#endif IVAS_ENC_DTX_CONFIG dtxConfig; int32_t initBitrate; const char *bitrateProfileFile; @@ -414,10 +408,6 @@ int main( #ifdef DEBUG_SBA_AUDIO_DUMP , &numTransportChannels -#endif -#ifdef AMBISONICS_CONVENTIONS - , - arg.sba_input_fmt #endif ) ) != IVAS_ERR_OK ) { @@ -441,12 +431,7 @@ int main( } break; case IVAS_ENC_INPUT_SBA_ISM: - if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca -#ifdef AMBISONICS_CONVENTIONS - , - arg.sba_input_fmt -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_ConfigureForSBAObjects( hIvasEnc, arg.inputFs, totalBitrate, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba_ism.numObjects, arg.inputFormatConfig.sba_ism.order, arg.inputFormatConfig.sba_ism.isPlanar, arg.pca ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_ENC_ConfigureForSBAObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); exit( -1 ); @@ -894,9 +879,6 @@ static void initArgStruct( EncArguments *arg ) arg->outputBitstreamFilename = NULL; arg->inputFs = 0; arg->inputFormat = IVAS_ENC_INPUT_MONO; -#ifdef AMBISONICS_CONVENTIONS - arg->sba_input_fmt = AMBI_FMT_ACN_SN3D; -#endif arg->is_binaural = false; arg->inputFormatConfig.stereoToMonoDownmix = false; arg->max_bwidth_user = false; @@ -929,7 +911,6 @@ static void initArgStruct( EncArguments *arg ) #endif arg->pca = false; - return; } @@ -1202,38 +1183,6 @@ static bool parseCmdlIVAS_enc( } } - /* ---------------------------------------------------------------- - * SBA input convention - *------------------------------------------------------------------*/ -#ifdef AMBISONICS_CONVENTIONS - else if ( strcmp( argv_to_upper, "-SBA_CONVENTION" ) == 0 ) - { - i++; - arg->sba_input_fmt = AMBI_FMT_ACN_SN3D; - - /* SBA configuration */ - if ( i < argc - 4 && is_number( argv[i] ) && sscanf( argv[i], "%d", &tmp ) > 0 ) - { - i++; - } - else - { - tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,5]!\n\n" ); - usage_enc(); - return false; - } - if ( tmp < 0 || tmp > 5 ) - { - tmp = -1; /* this is to avoid a compilation warning */ - fprintf( stderr, "Error: SBA input convention must be specified, expecting a number in [0,5]!\n\n" ); - usage_enc(); - return false; - } - arg->sba_input_fmt = tmp; - } -#endif - /*-----------------------------------------------------------------* * MIME output file format *-----------------------------------------------------------------*/ @@ -1907,10 +1856,6 @@ static void usage_enc( void ) fprintf( stdout, "-sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D),\n" ); fprintf( stdout, " where Order specifies the Ambisionics order (1-3),\n" ); fprintf( stdout, " where positive (+) means full 3D and negative (-) only 2D/planar components to be coded\n" ); -#ifdef AMBISONICS_CONVENTIONS - fprintf( stdout, "-sba_convention n : Ambisonics convention of the input signal" ); - fprintf( stdout, " where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D)" ); -#endif fprintf( stdout, "-masa Ch File : MASA format \n" ); fprintf( stdout, " where Ch specifies the number of MASA input/transport channels (1 or 2): \n" ); fprintf( stdout, " and File specifies input file containing parametric MASA metadata \n" ); -- GitLab From ab56b0497036f4ffe572bee1191b8ab1d2047339 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:39:19 +0200 Subject: [PATCH 065/130] remove call to the conversion functioins from the codec itself --- lib_com/options.h | 2 -- lib_dec/ivas_sba_dec.c | 12 ------------ lib_dec/ivas_stat_dec.h | 3 --- lib_dec/lib_dec.c | 7 ------- lib_dec/lib_dec.h | 7 ------- lib_enc/ivas_enc.c | 10 ---------- lib_enc/ivas_stat_enc.h | 3 --- lib_enc/lib_enc.c | 15 --------------- lib_enc/lib_enc.h | 11 ----------- 9 files changed, 70 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8833f14762..6a7b5fc981 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,8 +164,6 @@ #define FIX_1099_JBM_MD_HANDLE_ALLOC /* VA: issue 1099: Limit the allocation of `hJbmMetadata` handle to MASA and OMASA only */ #define FIX_1111_TDM_LSP_BUFFER /* VA: issue 1111: remove unused buffer `tdm_lspQ_PCh[]' */ -#define AMBISONICS_CONVENTIONS - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 5bc779829b..d13268858c 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -812,18 +812,6 @@ ivas_error ivas_sba_dec_render( } } -#ifdef AMBISONICS_CONVENTIONS - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_FOA || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 || - st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) - { - if ( st_ivas->hDecoderConfig->sba_output_fmt != 0 ) - { - convert_ambi_format( output_f, output_f, st_ivas->sba_analysis_order, AMBI_FMT_ACN_SN3D, st_ivas->hDecoderConfig->sba_output_fmt ); - } - } -#endif - if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 913867183a..2c9b2e99d1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -988,9 +988,6 @@ typedef struct decoder_config_structure int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ -#ifdef AMBISONICS_CONVENTIONS - AMBI_FMT sba_output_fmt; -#endif int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ float non_diegetic_pan_gain; /* non diegetic panning gain*/ int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 35d460da39..7ce36f86d6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -418,10 +418,6 @@ ivas_error IVAS_DEC_Configure( const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ -#ifdef AMBISONICS_CONVENTIONS - , - const AMBI_FMT sba_output_fmt -#endif ) { Decoder_Struct *st_ivas; @@ -462,9 +458,6 @@ ivas_error IVAS_DEC_Configure( st_ivas->element_mode_init = EVS_MONO; hDecoderConfig->nchan_out = 1; } -#ifdef AMBISONICS_CONVENTIONS - hDecoderConfig->sba_output_fmt = sba_output_fmt; -#endif if ( outputConfig != IVAS_AUDIO_CONFIG_EXTERNAL && outputConfig != IVAS_AUDIO_CONFIG_LS_CUSTOM ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index e30b2b5eae..0be389a61d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -34,9 +34,6 @@ #define LIB_DEC_H #include "common_api_types.h" -#ifdef AMBISONICS_CONVENTIONS -#include "ambi_convert.h" -#endif #include /*---------------------------------------------------------------------* @@ -138,10 +135,6 @@ ivas_error IVAS_DEC_Configure( const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ const int16_t delayCompensationEnabled /* i : enable delay compensation */ -#ifdef AMBISONICS_CONVENTIONS - , - const AMBI_FMT sba_output_fmt -#endif ); void IVAS_DEC_Close( diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 5869e28a51..4914b59625 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -127,16 +127,6 @@ ivas_error ivas_enc( dbgwrite( data_f[LFE_CHANNEL], sizeof( float ), n_samples_chan, 1, "./res/lfe_input" ); #endif -#ifdef AMBISONICS_CONVENTIONS - if ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) - { - if ( hEncoderConfig->sba_input_fmt != 0 ) - { - convert_ambi_format( data_f, data_f, st_ivas->sba_analysis_order, hEncoderConfig->sba_input_fmt, AMBI_FMT_ACN_SN3D ); - } - } -#endif - if ( ivas_format == SBA_FORMAT ) { if ( ( error = ivas_sba_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 5118765deb..66656a9273 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -1188,9 +1188,6 @@ typedef struct encoder_config_structure int16_t Opt_DTX_ON; /* flag indicating DTX operation */ int16_t interval_SID; /* CNG and DTX - interval of SID update, default 8 */ int16_t var_SID_rate_flag; /* CNG and DTX - flag for variable SID rate */ -#ifdef AMBISONICS_CONVENTIONS - AMBI_FMT sba_input_fmt; -#endif int16_t Opt_RF_ON; /* flag indicating RF (channel-aware) mode */ int16_t rf_fec_offset; /* RF FEC offset */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 84f9fe2421..e54dfdb803 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -492,10 +492,6 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( , int16_t *numTransportChannels #endif -#ifdef AMBISONICS_CONVENTIONS - , - AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ -#endif ) { ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -513,10 +509,6 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->sba_planar = isPlanar; hEncoderConfig->sba_order = order; -#ifdef AMBISONICS_CONVENTIONS - hEncoderConfig->sba_input_fmt = sba_input_fmt; -#endif - /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ hEncoderConfig->nchan_inp = ivas_sba_get_nchan( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ @@ -556,10 +548,6 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ -#ifdef AMBISONICS_CONVENTIONS - , - const int16_t sba_input_fmt -#endif ) { Encoder_Struct *st_ivas; @@ -579,9 +567,6 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ st_ivas->hEncoderConfig->sba_planar = isPlanar; st_ivas->hEncoderConfig->sba_order = order; -#ifdef AMBISONICS_CONVENTIONS - st_ivas->hEncoderConfig->sba_input_fmt = sba_input_fmt; -#endif /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ /*Input file will always contain all channels for a given order irrespective of planar flag*/ diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 13177c7cb9..2f40c1ab1b 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -34,9 +34,6 @@ #define LIB_ENC_H #include "common_api_types.h" -#ifdef AMBISONICS_CONVENTIONS -#include "ambi_convert.h" -#endif #include @@ -226,10 +223,6 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_PCA_ON /* i : PCA option flag */ -#ifdef AMBISONICS_CONVENTIONS - , - const int16_t sba_input_fmt -#endif ); /*! r: error code */ @@ -250,10 +243,6 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( , int16_t *numTransportChannels #endif -#ifdef AMBISONICS_CONVENTIONS - , - AMBI_FMT sba_input_fmt /* i : input ambisonics convention */ -#endif ); /*! r: error code */ -- GitLab From b6ecb4c966bca25b04dae584958af3080daa6eb5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:51:44 +0200 Subject: [PATCH 066/130] remove lib_util from build configs in CMakeLists.txt --- CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index abc646562b..17799f0db0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,20 +131,20 @@ add_library(lib_com ${libComSrcs} ${libComHeaders}) if(UNIX) target_link_libraries(lib_com PRIVATE m) endif() -target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_isar lib_util) +target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug lib_isar) target_include_directories(lib_com PRIVATE lib_lc3plus) file(GLOB libDebugSrcs "lib_debug/*.c") file(GLOB libDebugHeaders "lib_debug/*.h") add_library(lib_debug ${libDebugSrcs} ${libDebugHeaders}) target_link_libraries(lib_debug lib_com) -target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend lib_isar lib_util) +target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend lib_isar) file(GLOB libEncSrcs "lib_enc/*.c") file(GLOB libEncHeaders "lib_enc/*.h") add_library(lib_enc ${libEncSrcs} ${libEncHeaders}) target_link_libraries(lib_enc lib_com lib_debug) -target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_isar lib_util) +target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend lib_isar) target_include_directories(lib_enc PRIVATE lib_lc3plus) file(GLOB libLC3plusSrcs "lib_lc3plus/*.c") @@ -156,21 +156,21 @@ file(GLOB libRendSrcs "lib_rend/*.c") file(GLOB libRendHeaders "lib_rend/*.h") add_library(lib_rend ${libRendSrcs} ${libRendHeaders}) -target_link_libraries(lib_rend lib_dec lib_com lib_debug lib_util) # Todo refactor: This dependency on lib_dec should be removed. +target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed. target_link_libraries(lib_rend lib_lc3plus lib_isar) -target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc lib_isar lib_util) +target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc lib_isar) file(GLOB libDecSrcs "lib_dec/*.c") file(GLOB libDecHeaders "lib_dec/*.h") add_library(lib_dec ${libDecSrcs} ${libDecHeaders}) target_link_libraries(lib_dec lib_com lib_rend lib_debug lib_isar) -target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc lib_isar lib_util) +target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc lib_isar) file(GLOB libUtilSrcs "lib_util/*.c") file(GLOB libUtilHeaders "lib_util/*.h") add_library(lib_util ${libUtilSrcs} ${libUtilHeaders}) -target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug lib_util) +target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug) target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar) if(NOT WMOPS) @@ -183,7 +183,7 @@ file(GLOB libISARHeaders "lib_isar/*.h") add_library(lib_isar ${libISARSrcs} ${libISARHeaders}) target_link_libraries(lib_isar lib_com lib_debug lib_lc3plus) # Todo refactor: This dependency on lib_dec should be removed. -target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend lib_util) +target_include_directories(lib_isar PUBLIC lib_isar PRIVATE lib_enc lib_dec lib_rend) add_executable(IVAS_cod apps/encoder.c) @@ -200,7 +200,7 @@ endif() add_executable(IVAS_rend apps/renderer.c) target_link_libraries(IVAS_rend lib_rend lib_util lib_isar) -target_include_directories(IVAS_rend PRIVATE lib_enc lib_util) +target_include_directories(IVAS_rend PRIVATE lib_enc) add_executable(ISAR_post_rend apps/isar_post_rend.c) target_link_libraries(ISAR_post_rend lib_isar lib_util) -- GitLab From 8bfbe8ef20feb9afe165701937dc948490e28d9f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:52:41 +0200 Subject: [PATCH 067/130] remove sb_conversion parameter from readme.txt --- readme.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/readme.txt b/readme.txt index d360a541e5..cd5a01d4be 100644 --- a/readme.txt +++ b/readme.txt @@ -194,8 +194,6 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, -sba +/-Order : Scene Based Audio input format (Ambisonics ACN/SN3D), where Order specifies the Ambisionics order (1-3), where positive (+) means full 3D and negative (-) only 2D/planar components to be coded --sba_convention n : Ambisonics convention of the input signal - where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D) -masa Ch File : MASA format where Ch specifies the number of MASA input/transport channels (1 or 2): and File specifies input file containing parametric MASA metadata @@ -256,8 +254,6 @@ output_file : Output audio filename Options: -------- --sba_convention n : Ambisonics convention of the output signal - : where n = 0 (ACN-SN3D), 1 (ACN-N3D), 2 (FuMa-MaxN), 3 (FuMa-FuMa), 4 (SID-SN3D), 5 (SID-N3D) -VOIP : VoIP mode: RTP in G192 -VOIP_hf_only=0 : VoIP mode: EVS RTP Payload Format hf_only=0 in rtpdump -VOIP_hf_only=1 : VoIP mode: EVS RTP Payload Format hf_only=1 in rtpdump -- GitLab From f29bc448a4614db8bc6746068fac728d27aa3bdd Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Tue, 18 Jun 2024 16:53:54 +0200 Subject: [PATCH 068/130] remove hint to SBA conventions from README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 836d130196..899e52ddc1 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -please refer to the [Wiki](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/home). For the Ambisonics conventions see [here](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/Ambisonics-conventions). +please refer to the [Wiki](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/wikis/home) -- GitLab From dd7e30dc7994ac38b26bdb7d14c879d6555edb0d Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 18 Jun 2024 17:12:48 +0200 Subject: [PATCH 069/130] prevent R[0] from being zero --- lib_com/options.h | 1 + lib_enc/swb_tbe_enc.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cdff54f506..10de6b53cc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,7 @@ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ #define REVERT_ZERO_FLUSH_TRESH /* FhG: issue 1069: revert threshold value introduced with !1518 due to significant complexity increase*/ #define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ +#define NONBE_FIX_1130_DIV_ZERO_LEV_DUR /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 758fa4fe76..9df90fa119 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -280,6 +280,15 @@ void wb_tbe_enc( } autocorr( hb_old_speech, R, LPC_SHB_ORDER_WB + 1, ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16, win_lpc_hb_wb, 0, 1, 1 ); + +#ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR + if ( st->element_mode > EVS_MONO ) + { + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + R[0] = max( R[0], 1.0e-8f ); + } +#endif + lev_dur( lpc_wb_temp, R, LPC_SHB_ORDER_WB, ervec_temp ); a2lsp( lsp_wb_temp, lpc_wb_temp, LPC_SHB_ORDER_WB ); lsp_spacing = 0.5f; @@ -638,7 +647,7 @@ void swb_tbe_enc( mvr2r( shb_old_speech + L_FRAME16k, hBWE_TD->old_speech_shb, delay ); autocorr( shb_old_speech, R, LPC_SHB_ORDER + 1, NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k + L_FRAME16k, win_lpc_shb, 0, 1, 1 ); - + /* Spectral smoothing of autocorrelation coefficients */ if ( st->rf_mode || st->extl_brate == SWB_TBE_0k95 || st->extl_brate == SWB_TBE_1k10 ) { -- GitLab From a240b368ffa1189de2cb77cac90d88e9d2015818 Mon Sep 17 00:00:00 2001 From: Vladimir Malenovsky Date: Tue, 18 Jun 2024 17:22:54 +0200 Subject: [PATCH 070/130] clang format --- lib_enc/swb_tbe_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 9df90fa119..1cf69fab8a 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -284,7 +284,7 @@ void wb_tbe_enc( #ifdef NONBE_FIX_1130_DIV_ZERO_LEV_DUR if ( st->element_mode > EVS_MONO ) { - /* Ensure R[0] isn't zero when entering Levinson-Durbin */ + /* Ensure R[0] isn't zero when entering Levinson-Durbin */ R[0] = max( R[0], 1.0e-8f ); } #endif @@ -647,7 +647,7 @@ void swb_tbe_enc( mvr2r( shb_old_speech + L_FRAME16k, hBWE_TD->old_speech_shb, delay ); autocorr( shb_old_speech, R, LPC_SHB_ORDER + 1, NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k + L_FRAME16k, win_lpc_shb, 0, 1, 1 ); - + /* Spectral smoothing of autocorrelation coefficients */ if ( st->rf_mode || st->extl_brate == SWB_TBE_0k95 || st->extl_brate == SWB_TBE_1k10 ) { -- GitLab From e62166c6b8d954d18760c34952d1640234bbc07c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 08:30:46 +0200 Subject: [PATCH 071/130] undo experimental changes to lib_enc, lib_dec, and apps --- apps/decoder.c | 195 ++---------------------------------- lib_dec/ivas_spar_decoder.c | 1 - lib_dec/ivas_stat_dec.h | 13 ++- lib_dec/lib_dec.c | 1 - lib_enc/ivas_enc.c | 1 - lib_enc/ivas_stat_enc.h | 2 +- lib_enc/lib_enc.c | 2 +- 7 files changed, 18 insertions(+), 197 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 2cd7608cbc..354d611a95 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -44,9 +44,7 @@ #include "render_config_reader.h" #include "rotation_file_reader.h" #include "aeid_file_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" -#endif #ifdef VARIABLE_SPEED_DECODING #include "tsm_scale_file_reader.h" #include @@ -134,9 +132,7 @@ typedef struct float non_diegetic_pan_gain; bool renderConfigEnabled; char *renderConfigFilename; -#ifdef SPLIT_REND_WITH_HEAD_ROT char *outputMdFilename; -#endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; @@ -164,11 +160,7 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -#else -static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING @@ -190,10 +182,8 @@ int main( bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; ivas_error error = IVAS_ERR_UNKNOWN; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA splitRendBits; uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; -#endif /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; @@ -226,9 +216,7 @@ int main( reset_mem( USE_BYTES ); #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT splitRendBits.bits_buf = splitRendBitsBuf; -#endif /*------------------------------------------------------------------------------------------* * Parse command-line arguments @@ -276,7 +264,6 @@ int main( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { fprintf( stdout, "Output metadata file: %s\n", arg.outputWavFilename ); @@ -287,7 +274,6 @@ int main( fprintf( stdout, "Output metadata file: %s\n", arg.outputMdFilename ); } else -#endif { fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); } @@ -321,11 +307,7 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB -#ifdef SPLIT_REND_WITH_HEAD_ROT - && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM -#endif - ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -425,12 +407,8 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB -#ifdef SPLIT_REND_WITH_HEAD_ROT - && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - arg.Opt_non_diegetic_pan == 0 -#endif - ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -466,7 +444,6 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ @@ -488,7 +465,6 @@ int main( arg.enableHeadRotation = true; } -#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -617,7 +593,6 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 ) @@ -625,13 +600,6 @@ int main( fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); goto cleanup; } -#else - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" ); - goto cleanup; - } -#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { @@ -655,7 +623,6 @@ int main( fprintf( stderr, "Failed to get Distance Attenuation \n\n" ); goto cleanup; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS && @@ -679,7 +646,6 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } } -#endif if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -699,13 +665,9 @@ int main( renderConfig.roomAcoustics.override = true; } -#ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; -#endif -#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -863,11 +825,7 @@ int main( } else { -#ifdef SPLIT_REND_WITH_HEAD_ROT error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); -#else - error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); -#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -1027,7 +985,6 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; @@ -1036,7 +993,6 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; } -#endif else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -1112,9 +1068,7 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT arg->outputMdFilename = NULL; -#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; @@ -1442,7 +1396,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) { arg->outputMdFilename = argv[i + 1]; @@ -1454,7 +1407,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } -#endif else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; @@ -1724,13 +1676,8 @@ static void usage_dec( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" ); -#else - fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); - fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); -#endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); fprintf( stdout, " layout file. See readme.txt for details.\n" ); @@ -1776,9 +1723,7 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); -#endif fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); #ifdef DEBUGGING @@ -1835,15 +1780,11 @@ static int16_t app_own_random( int16_t *seed ) *---------------------------------------------------------------------*/ static ivas_error initOnFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: */ - const DecArguments arg, /* i : */ - const int16_t numInitialBadFrames, /* i : */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - int16_t *numOutSamples, /* i/o: */ - int16_t *vec_pos_len, /* i/o: */ -#else - const uint16_t numOutSamples, /* i : */ -#endif + IVAS_DEC_HANDLE hIvasDec, /* i/o: */ + const DecArguments arg, /* i : */ + const int16_t numInitialBadFrames, /* i : */ + int16_t *numOutSamples, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1852,17 +1793,10 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ -#ifdef SPLIT_REND_WITH_HEAD_ROT - uint16_t *pNumObj, /* o : */ - SplitFileReadWrite **splitRendWriter -#else - uint16_t *pNumObj /* o : */ -#endif -) + uint16_t *pNumObj, /* o : */ + SplitFileReadWrite **splitRendWriter ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t isSplitRend, isSplitCoded; -#endif ivas_error error = IVAS_ERR_UNKNOWN; /* Now delay, number of output channels and frame size are known */ @@ -1872,7 +1806,6 @@ static ivas_error initOnFirstGoodFrame( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error ); @@ -1889,7 +1822,6 @@ static ivas_error initOnFirstGoodFrame( { pFullDelayNumSamples[0] = 0; } -#endif if ( !arg.delayCompensationEnabled ) { @@ -1911,7 +1843,6 @@ static ivas_error initOnFirstGoodFrame( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { /* Open split rendering metadata writer */ @@ -1920,10 +1851,8 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_CODEC splitRendCodec; int16_t splitRendCodecFrameSizeMs; ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; -#endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) { @@ -1931,11 +1860,7 @@ static ivas_error initOnFirstGoodFrame( return error; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, &splitRendCodecFrameSizeMs, &lc3plusHighRes ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); return error; @@ -1943,11 +1868,7 @@ static ivas_error initOnFirstGoodFrame( if ( isSplitCoded ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) -#else - if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -1961,11 +1882,7 @@ static ivas_error initOnFirstGoodFrame( return IVAS_ERR_INVALID_SPLIT_REND_CONFIG; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK ) -#else - if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -1975,23 +1892,19 @@ static ivas_error initOnFirstGoodFrame( if ( !isSplitCoded ) { -#endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; @@ -2001,12 +1914,8 @@ static ivas_error initOnFirstGoodFrame( splitRendBitsZero.buf_len = 0; splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS splitRendBitsZero.codec_frame_size_ms = 0; splitRendBitsZero.isar_frame_size_ms = 20; -#else - splitRendBitsZero.codec_frame_size_ms = 20; -#endif if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) { @@ -2016,19 +1925,10 @@ static ivas_error initOnFirstGoodFrame( } else { -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *pRemainingDelayNumSamples < *numOutSamples ) -#else - if ( *pRemainingDelayNumSamples < numOutSamples ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) -#else - if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -2037,15 +1937,9 @@ static ivas_error initOnFirstGoodFrame( } else { -#ifdef SPLIT_REND_WITH_HEAD_ROT *pRemainingDelayNumSamples -= *numOutSamples; -#else - *pRemainingDelayNumSamples -= numOutSamples; -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } free( zeroBuf ); @@ -2132,7 +2026,6 @@ static ivas_error initOnFirstGoodFrame( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { if ( numOutSamples == NULL || vec_pos_len == NULL ) @@ -2152,7 +2045,6 @@ static ivas_error initOnFirstGoodFrame( return error; } } -#endif return IVAS_ERR_OK; } @@ -2171,9 +2063,7 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA *splitRendBits, -#endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -2209,7 +2099,6 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; -#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; int16_t isSplitRend, isSplitCoded; @@ -2224,7 +2113,6 @@ static ivas_error decodeG192( fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error ); return error; } -#endif IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; @@ -2383,7 +2271,6 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -2399,7 +2286,6 @@ static ivas_error decodeG192( } else { -#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -2408,17 +2294,11 @@ static ivas_error decodeG192( goto cleanup; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif for ( i = 0; i < num_subframes; i++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2542,7 +2422,6 @@ static ivas_error decodeG192( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) @@ -2556,21 +2435,14 @@ static ivas_error decodeG192( } else { -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } nSamplesRendered += nSamplesRendered_loop; nSamplesToRender -= nSamplesRendered_loop; -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif if ( needNewFrame ) { frame++; @@ -2604,11 +2476,7 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) -#endif { goto cleanup; } @@ -2622,7 +2490,6 @@ static ivas_error decodeG192( /* Write current frame */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( isSplitRend ) { if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) @@ -2634,7 +2501,6 @@ static ivas_error decodeG192( if ( !isSplitCoded ) { -#endif if ( delayNumSamples < nOutSamples ) { if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) @@ -2648,9 +2514,7 @@ static ivas_error decodeG192( { delayNumSamples -= nOutSamples; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } /* Write ISm metadata to external file(s) */ @@ -2771,11 +2635,7 @@ static ivas_error decodeG192( goto cleanup; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2783,11 +2643,7 @@ static ivas_error decodeG192( } /* decode and get samples */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2906,18 +2762,14 @@ static ivas_error decodeG192( memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( afWriter != NULL ) { -#endif if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -2928,9 +2780,7 @@ static ivas_error decodeG192( cleanup: RenderConfigReader_close( &renderConfigReader ); -#ifdef SPLIT_REND_WITH_HEAD_ROT split_rend_reader_writer_close( &splitRendWriter ); -#endif AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); #ifdef DEBUGGING @@ -3282,7 +3132,6 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -3298,7 +3147,6 @@ static ivas_error decodeVoIP( } else { -#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -3308,17 +3156,11 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif for ( i = 0; i < num_subframes; i++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -3405,18 +3247,10 @@ static ivas_error decodeVoIP( /* decode and get samples */ -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) -#endif #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3453,15 +3287,10 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, - &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) -#endif { goto cleanup; } @@ -3566,11 +3395,7 @@ static ivas_error decodeVoIP( int16_t nSamplesFlushed = 0; /* decode and get samples */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index aed98cbe3b..bb09116de7 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1714,7 +1714,6 @@ void ivas_spar_dec_upmixer_sf( ivas_spar_dump_signal_wav( output_frame, NULL, output, hSpar->numOutChannels, spar_foa_dec_wav[3], "cldfbSynthesis()" ); #endif - hSpar->slots_rendered += hSpar->subframe_nbslots[hSpar->subframes_rendered]; hSpar->subframes_rendered++; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2c9b2e99d1..8f096dd705 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -38,7 +38,6 @@ #include "cnst.h" #include "ivas_cnst.h" #include "stat_dec.h" -#include "ambi_convert.h" #include "ivas_stat_com.h" #include "ivas_stat_rend.h" @@ -988,12 +987,12 @@ typedef struct decoder_config_structure int16_t Opt_Headrotation; /* indicates whether head-rotation is used */ int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */ IVAS_HEAD_ORIENT_TRK_T orientation_tracking; /* indicates orientation tracking type */ - int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ - float non_diegetic_pan_gain; /* non diegetic panning gain*/ - int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ - int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ - int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ - int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ + int16_t Opt_non_diegetic_pan; /* indicates diegetic or not */ + float non_diegetic_pan_gain; /* non diegetic panning gain*/ + int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ + int16_t Opt_ExternalOrientation; /* indiates whether external orientations are used */ + int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ + int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ #ifdef DEBUGGING /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 7ce36f86d6..66032833c1 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -40,7 +40,6 @@ #include "jbm_jb4sb.h" #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" -#include "ambi_convert.h" #include #include #include diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index 4914b59625..5ddcf9a506 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -34,7 +34,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ambi_convert.h" #include "rom_com.h" #include "prot.h" #include "ivas_prot.h" diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 66656a9273..3962ac055f 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -37,7 +37,6 @@ #include "options.h" #include "cnst.h" #include "ivas_cnst.h" -#include "ambi_convert.h" #include "stat_enc.h" #include "ivas_stat_com.h" @@ -1183,6 +1182,7 @@ typedef struct encoder_config_structure int16_t sba_planar; /* Ambisonic (SBA) planar flag */ MC_LS_SETUP mc_input_setup; /* multichannel input ls setup */ int16_t ism_extended_metadata_flag; /* flag indicating extended metadata encoding, including radius and orientation (yaw, pitch) in ISM format */ + int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */ int16_t Opt_DTX_ON; /* flag indicating DTX operation */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index e54dfdb803..23e666a7f0 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -562,8 +562,8 @@ ivas_error IVAS_ENC_ConfigureForSBAObjects( { return IVAS_ERR_TOO_MANY_INPUTS; } - st_ivas = hIvasEnc->st_ivas; + st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ st_ivas->hEncoderConfig->sba_planar = isPlanar; st_ivas->hEncoderConfig->sba_order = order; -- GitLab From 6d573d584f771929ecf02f6175a195958125de2d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 09:27:53 +0200 Subject: [PATCH 072/130] fix compile warning --- lib_util/ambi_convert.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 76939aa659..8fa7b5ca58 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include "options.h" -#ifdef AMBISONICS_CONVENTIONS #include #include #include "ivas_cnst.h" @@ -350,5 +349,4 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL } return 0; -} -#endif +} \ No newline at end of file -- GitLab From b5db8f0ffc63acdcb511e368b11ee1306a6058e2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 09:29:13 +0200 Subject: [PATCH 073/130] add ambi_convert.c and ambi_convert.h to lib_util.vcxproj --- Workspace_msvc/lib_util.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Workspace_msvc/lib_util.vcxproj b/Workspace_msvc/lib_util.vcxproj index 79e5545f3f..4ec7948021 100644 --- a/Workspace_msvc/lib_util.vcxproj +++ b/Workspace_msvc/lib_util.vcxproj @@ -101,6 +101,7 @@ + @@ -128,6 +129,7 @@ + -- GitLab From fdcaee463a9d4020df89b220a3e18f822fbb3a25 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 09:40:08 +0200 Subject: [PATCH 074/130] do not scale down channels in format conversions --- lib_util/ambi_convert.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 8fa7b5ca58..a4c817d6b1 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -73,9 +73,6 @@ static const float N3D_SN3D[AMBI_MAX_CHANNELS] = { 1.0f, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_5_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_, INV_SQRT_7_ }; -static const float N3D_SN3D_SCALING_FACTOR = 1.0f; -static const float SN3D_N3D_SCALING_FACTOR = INV_SQRT_7_; - static const float SN3D_MAXN[AMBI_MAX_CHANNELS] = { 1.0f, 1.0f, 1.0f, 1.0f, @@ -87,10 +84,6 @@ static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 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_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float MAXN_SN3D_SCALING_FACTOR = 1.0f; -static const float SN3D_MAXN_SCALING_FACTOR = INV_THREE_OVER_SQRT_5_; - - static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, 1.0f, 1.0f, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, @@ -101,10 +94,6 @@ static const float FM_SN3D[AMBI_MAX_CHANNELS] = { SQRT_2_, 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_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float FM_SN3D_SCALING_FACTOR = INV_SQRT_2; -static const float SN3D_FM_SCALING_FACTOR = INV_THREE_OVER_SQRT_5_; - - /* ---------------------------- channel re-ordering tables ---------------------------- */ @@ -236,17 +225,14 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( out_format == AMBI_NORM_N3D ) { conversion_table = SN3D_N3D; - sf = SN3D_N3D_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_MAXN ) { conversion_table = SN3D_MAXN; - sf = SN3D_MAXN_SCALING_FACTOR; } else if ( out_format == AMBI_NORM_FM ) { conversion_table = SN3D_FM; - sf = SN3D_FM_SCALING_FACTOR; } else { @@ -258,17 +244,14 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA if ( in_format == AMBI_NORM_N3D ) { conversion_table = N3D_SN3D; - sf = N3D_SN3D_SCALING_FACTOR; } else if ( in_format == AMBI_NORM_MAXN ) { conversion_table = MAXN_SN3D; - sf = MAXN_SN3D_SCALING_FACTOR; } else if ( in_format == AMBI_NORM_FM ) { conversion_table = FM_SN3D; - sf = FM_SN3D_SCALING_FACTOR; } else { @@ -286,7 +269,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA float conversion_factor = conversion_table[i_chan]; for ( i = 0; i < L_FRAME48k; i++ ) { - out[i_chan][i] = sf * in[i_chan][i] * conversion_factor; + out[i_chan][i] = in[i_chan][i] * conversion_factor; } } -- GitLab From f601893c9fddc0666ff78101e263557ca3f88330 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 09:49:10 +0200 Subject: [PATCH 075/130] fix formatting --- lib_util/ambi_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index a4c817d6b1..126eeab1e0 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -332,4 +332,4 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL } return 0; -} \ No newline at end of file +} -- GitLab From 82d214b03220ae53360caaf9603c4088ddf5c62c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 20 Jun 2024 09:56:13 +0200 Subject: [PATCH 076/130] fix compile warning --- lib_util/ambi_convert.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 126eeab1e0..d42f7527de 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -216,7 +216,6 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; const float *conversion_table = 0; - float sf = 1.0f; /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ -- GitLab From 01f58a6ba463a0d16187b3dbc3d10cbec68b78a1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 20 Jun 2024 11:49:45 +0200 Subject: [PATCH 077/130] issue 745: implicit data type conversion when calling IVAS_DEC_Configure(); UNDER FIX_745_FIX_DATA_TYPE_CONVERSION --- apps/decoder.c | 48 ++++++++++++++++++++++++++++ lib_com/options.h | 1 + lib_dec/lib_dec.c | 79 ++++++++++++++++++++++++++++++++++++++--------- lib_dec/lib_dec.h | 24 ++++++++++++++ 4 files changed, 137 insertions(+), 15 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 354d611a95..8bc31fdea6 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -128,7 +128,11 @@ typedef struct bool customLsOutputEnabled; char *customLsSetupFilename; int16_t orientation_tracking; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + bool non_diegetic_pan_enabled; +#else int16_t Opt_non_diegetic_pan; +#endif float non_diegetic_pan_gain; bool renderConfigEnabled; char *renderConfigFilename; @@ -148,7 +152,11 @@ typedef struct #endif #endif AcousticEnvironmentSequence aeSequence; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + bool dpidEnabled; +#else int16_t Opt_dpid_on; +#endif uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; } DecArguments; @@ -407,8 +415,12 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.non_diegetic_pan_enabled == false ) +#else if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 ) +#endif { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -427,8 +439,14 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; + +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, + arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.Opt_dpid_on, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -594,8 +612,12 @@ int main( /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.non_diegetic_pan_enabled == false ) +#else arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 ) +#endif { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); goto cleanup; @@ -1066,12 +1088,20 @@ static bool parseCmdlIVAS_dec( arg->renderConfigEnabled = false; arg->renderConfigFilename = NULL; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + arg->dpidEnabled = false; +#else arg->Opt_dpid_on = 0; +#endif arg->outputMdFilename = NULL; arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + arg->non_diegetic_pan_enabled = false; +#else arg->Opt_non_diegetic_pan = 0; +#endif arg->non_diegetic_pan_gain = 0.f; arg->tsmEnabled = false; arg->renderFramesize = IVAS_RENDER_FRAMESIZE_20MS; @@ -1410,7 +1440,11 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + arg->non_diegetic_pan_enabled = true; +#else arg->Opt_non_diegetic_pan = 1; +#endif strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 ); argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0'; to_upper( argv_to_upper ); @@ -1507,7 +1541,11 @@ static bool parseCmdlIVAS_dec( { int16_t id, tmp; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + arg->dpidEnabled = true; +#else arg->Opt_dpid_on = 1; +#endif ++i; tmp = 0; while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS ) @@ -1587,7 +1625,12 @@ static bool parseCmdlIVAS_dec( arg->customLsSetupFilename = argv[i]; } i++; + +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + if ( arg->non_diegetic_pan_enabled && arg->outputConfig != IVAS_AUDIO_CONFIG_STEREO ) +#else if ( ( arg->Opt_non_diegetic_pan ) && ( arg->outputConfig != IVAS_AUDIO_CONFIG_STEREO ) ) +#endif { fprintf( stderr, "Error: non-diegetic panning is supported in stereo only\n\n" ); usage_dec(); @@ -1605,7 +1648,12 @@ static bool parseCmdlIVAS_dec( { arg->outputConfig = IVAS_AUDIO_CONFIG_MONO; arg->decMode = IVAS_DEC_MODE_EVS; + +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + if ( arg->non_diegetic_pan_enabled ) +#else if ( ( arg->Opt_non_diegetic_pan ) ) +#endif { arg->outputConfig = IVAS_AUDIO_CONFIG_STEREO; } diff --git a/lib_com/options.h b/lib_com/options.h index 1e56a65dcf..5b273c2513 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ #define FIX_1099_JBM_MD_HANDLE_ALLOC /* VA: issue 1099: Limit the allocation of `hJbmMetadata` handle to MASA and OMASA only */ #define FIX_1111_TDM_LSP_BUFFER /* VA: issue 1111: remove unused buffer `tdm_lspQ_PCh[]' */ #define FIX_1101_CLEANING_JBM_CALL /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */ +#define FIX_745_FIX_DATA_TYPE_CONVERSION /* VA: issue 745: implicit data type conversion when calling IVAS_DEC_Configure() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 66032833c1..487beb8c62 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -401,22 +401,46 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_Configure( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const uint32_t sampleRate, /* i : output sampling frequency */ - const AUDIO_CONFIG outputConfig, /* i : output configuration */ - const int16_t tsmEnabled, /* i : enable time scale modification */ - const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ - const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ - const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ - const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ - const int16_t enableExternalOrientation, /* i : enable external orientations */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const uint32_t sampleRate, /* i : output sampling frequency */ + const AUDIO_CONFIG outputConfig, /* i : output configuration */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool tsmEnabled, /* i : enable TSM */ +#else + const int16_t tsmEnabled, /* i : enable time scale modification */ +#endif + const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ + const bool enableHeadRotation, /* i : enable head rotation for binaural output */ + const bool enableExternalOrientation, /* i : enable external orientations */ +#else + const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ + const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ + const int16_t enableExternalOrientation, /* i : enable external orientations */ +#endif const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ - const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ - const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ - const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ - const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ - const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ - const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ + const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ +#else + const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ + const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ +#endif + const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool dpidEnabled, /* i : enable directivity pattern option */ +#else + const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#endif + const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool delayCompensationEnabled /* i : enable delay compensation */ +#else + const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#endif ) { Decoder_Struct *st_ivas; @@ -434,8 +458,13 @@ ivas_error IVAS_DEC_Configure( return IVAS_ERR_WRONG_PARAMS; } +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && !( ( outputConfig == IVAS_AUDIO_CONFIG_MONO && !non_diegetic_pan_enabled ) || + ( outputConfig == IVAS_AUDIO_CONFIG_STEREO && non_diegetic_pan_enabled ) ) ) +#else if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && !( ( outputConfig == IVAS_AUDIO_CONFIG_MONO && Opt_non_diegetic_pan == 0 ) || ( outputConfig == IVAS_AUDIO_CONFIG_STEREO && Opt_non_diegetic_pan == 1 ) ) ) +#endif { return IVAS_ERR_WRONG_MODE; } @@ -463,17 +492,37 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + hDecoderConfig->Opt_tsm = (int16_t) tsmEnabled; + hDecoderConfig->Opt_LsCustom = (int16_t) customLsOutputEnabled; + hDecoderConfig->Opt_Headrotation = (int16_t) enableHeadRotation; +#else hDecoderConfig->Opt_tsm = tsmEnabled; hDecoderConfig->Opt_LsCustom = customLsOutputEnabled; hDecoderConfig->Opt_Headrotation = enableHeadRotation; +#endif hDecoderConfig->orientation_tracking = orientation_tracking; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + hDecoderConfig->Opt_HRTF_binary = (int16_t) hrtfReaderEnabled; + hDecoderConfig->Opt_RendConfigCustom = (int16_t) renderConfigEnabled; + hDecoderConfig->Opt_non_diegetic_pan = (int16_t) non_diegetic_pan_enabled; +#else hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled; hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled; hDecoderConfig->Opt_non_diegetic_pan = Opt_non_diegetic_pan; +#endif hDecoderConfig->non_diegetic_pan_gain = non_diegetic_pan_gain; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + hDecoderConfig->Opt_delay_comp = (int16_t) delayCompensationEnabled; +#else hDecoderConfig->Opt_delay_comp = delayCompensationEnabled; +#endif hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + hDecoderConfig->Opt_dpid_on = (int16_t) dpidEnabled; +#else hDecoderConfig->Opt_dpid_on = Opt_dpid_on; +#endif hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 0be389a61d..85f5d60566 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -122,19 +122,43 @@ ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool tsmEnabled, /* i : enable TSM */ +#else const int16_t tsmEnabled, /* i : enable TSM */ +#endif const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ + const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ + const bool enableHeadRotation, /* i : enable head rotation for binaural output */ + const bool enableExternalOrientation, /* i : enable external orientations */ +#else const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ const int16_t enableExternalOrientation, /* i : enable external orientations */ +#endif const IVAS_HEAD_ORIENT_TRK_T orientation_tracking, /* i : head orientation tracking type */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ + const bool non_diegetic_pan_enabled, /* i : enabled diegetic panning */ +#else const int16_t renderConfigEnabled, /* i : enable Renderer config. file for binaural output */ const int16_t Opt_non_diegetic_pan, /* i : diegetic or not */ +#endif const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool dpidEnabled, /* i : enable directivity pattern option */ +#else const int16_t Opt_dpid_on, /* i : enable directivity pattern option */ +#endif const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ +#ifdef FIX_745_FIX_DATA_TYPE_CONVERSION + const bool delayCompensationEnabled /* i : enable delay compensation */ +#else const int16_t delayCompensationEnabled /* i : enable delay compensation */ +#endif ); void IVAS_DEC_Close( -- GitLab From f815cfb8f88c0b864d859685ae968afb1d624505 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 24 Jun 2024 17:26:56 +0200 Subject: [PATCH 078/130] don't de-whiten the bg noise shape on first good frame if it is an SID --- lib_com/options.h | 1 + lib_dec/ivas_core_dec.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4d8e7d5f74..02f4e07ed0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,6 +177,7 @@ #define NONBE_FIX_1097_SBA_DTX_BRATE_SWITCHING_ENC /* FhG: fix out-of-bound errors when switching from SID frame to active frame*/ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ #define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ +#define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 73c5001153..f077802dc0 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -402,10 +402,16 @@ ivas_error ivas_core_dec( { updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); } +#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES + /* On first good active frame after frameloss undo the whitening of the bg noise shape */ + if ( sts[0]->core_brate > SID_2k40 && sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 ) + { +#else if ( sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 ) { /* On first good frame after frameloss undo the whitening of the bg noise shape */ +#endif for ( n = 0; n < n_channels; ++n ) { if ( sts[n]->last_core_bfi != ACELP_CORE ) -- GitLab From 0eb68c065ec91c67a795f8354970f0112c833bf7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 26 Jun 2024 09:22:45 +0200 Subject: [PATCH 079/130] initialize local variables using the names from the struct --- lib_util/ambi_convert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index d42f7527de..53b8e7049f 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -125,8 +125,8 @@ 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; + 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; if ( in_format != AMBI_FMT_ACN_SN3D && out_format != AMBI_FMT_ACN_SN3D ) { -- GitLab From 123f3f513eda71be9b2b09bddba556d0982f2a4e Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 26 Jun 2024 11:56:04 +0200 Subject: [PATCH 080/130] remove IVAS-specific dependencies from ambi_convert.h and ambi_convert.c --- lib_util/ambi_convert.c | 7 +++---- lib_util/ambi_convert.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 53b8e7049f..cbb2a3da55 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -29,13 +29,12 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -#include "options.h" - #include #include -#include "ivas_cnst.h" #include "ambi_convert.h" +#define L_FRAME48k 960 + #define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ #define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ #define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ @@ -84,7 +83,7 @@ static const float MAXN_SN3D[AMBI_MAX_CHANNELS] = { 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_THREE_OVER_SQRT_5_, INV_SQRT_45_OVER_32_, 1.0f, INV_SQRT_45_OVER_32_, INV_THREE_OVER_SQRT_5_, INV_SQRT_8_OVER_5_ }; -static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2, +static const float SN3D_FM[AMBI_MAX_CHANNELS] = { INV_SQRT_2_, 1.0f, 1.0f, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, 1.0f, TWO_OVER_SQRT_3_, TWO_OVER_SQRT_3_, SQRT_8_OVER_5_, THREE_OVER_SQRT_5_, SQRT_45_OVER_32_, 1.0f, SQRT_45_OVER_32_, THREE_OVER_SQRT_5_, SQRT_8_OVER_5_ }; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 49fdc38838..c61bd79177 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -33,7 +33,6 @@ #ifndef AMBI_CONVERT_H #define AMBI_CONVERT_H -#include "options.h" #include typedef enum -- GitLab From 0e1ee7cdfededff3be5a19977339e3f6b85a61c7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 26 Jun 2024 12:22:56 +0200 Subject: [PATCH 081/130] add standalone ambisonics converter program ambi_converter.c --- apps/ambi_converter.c | 110 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 apps/ambi_converter.c diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c new file mode 100644 index 0000000000..d572b0e722 --- /dev/null +++ b/apps/ambi_converter.c @@ -0,0 +1,110 @@ +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ +#include +#include +#include +#include "tinywavein_c.h" +#include "tinywaveout_c.h" +#include "ambi_convert.h" + +#define L_FRAME48k 960 +#define MAX_CHANNELS 16 + +int main(int argc, char* argv[]) +{ + + WAVEFILEIN *wavFile_in; + WAVEFILEOUT *wavFile_out; + char* fileName_in, *fileName_out; + + uint32_t samplingRate; + uint32_t samplesInFile; + uint32_t numSamples = L_FRAME48k; + uint32_t numSamplesRead32 = 0; + + int16_t bps; + int16_t samples[L_FRAME48k*MAX_CHANNELS]; + int16_t order = 0; + int16_t numChannels; + + AMBI_FMT in_format, out_format; + + float samples_f_in[L_FRAME48k*MAX_CHANNELS]; + float samples_f_out[L_FRAME48k*MAX_CHANNELS]; + float *in[MAX_CHANNELS], *out[MAX_CHANNELS]; + + for(int16_t j=0;j 0 && order <=3 ); + + while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) != __TWI_SUCCESS ) + { + int16_t err = 0; + for (int16_t i=0;i Date: Wed, 26 Jun 2024 14:26:05 +0200 Subject: [PATCH 082/130] fix bugs in apps/ambi_converter.c --- apps/ambi_converter.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index d572b0e722..eddcf06e19 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -79,20 +79,27 @@ int main(int argc, char* argv[]) order = (int16_t)sqrtf(numChannels) - 1; assert( order > 0 && order <=3 ); - while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) != __TWI_SUCCESS ) + + while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) == __TWI_SUCCESS ) { int16_t err = 0; - for (int16_t i=0;i Date: Wed, 26 Jun 2024 14:39:44 +0200 Subject: [PATCH 083/130] fix typo in lib_util/ambi_convert.c --- lib_util/ambi_convert.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index cbb2a3da55..700d7db12e 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -216,8 +216,7 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA int16_t i_chan, i; const float *conversion_table = 0; - /* conversion factors are aplpied on the channels assuming that they are still/already in ACN order */ - + /* conversion factors are applied on the channels assuming that they are still/already in ACN order */ if ( in_format == AMBI_NORM_SN3D ) { if ( out_format == AMBI_NORM_N3D ) -- GitLab From 4d788620a3f99c8082f0f8d83ababb55023b4c0a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 26 Jun 2024 15:28:41 +0200 Subject: [PATCH 084/130] fix if condition in renormalize_channels --- lib_util/ambi_convert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index cbb2a3da55..2a737c9b71 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -287,7 +287,7 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL { idx_table = REORDER_ACN_FM; } - if ( out_format == AMBI_CHANNEL_ORDER_SID ) + else if ( out_format == AMBI_CHANNEL_ORDER_SID ) { idx_table = REORDER_ACN_SID; } @@ -302,7 +302,7 @@ int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL { idx_table = REORDER_FM_ACN; } - if ( in_format == AMBI_CHANNEL_ORDER_SID ) + else if ( in_format == AMBI_CHANNEL_ORDER_SID ) { idx_table = REORDER_SID_ACN; } -- GitLab From 49637baf521df429de9faeb8dab803362c98ffd6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 28 Jun 2024 11:29:39 +0200 Subject: [PATCH 085/130] fix bug in channel reordering --- lib_util/ambi_convert.c | 50 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index b37a984327..093cf6142c 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -31,6 +31,7 @@ *******************************************************************************************************/ #include #include +#include #include "ambi_convert.h" #define L_FRAME48k 960 @@ -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 Date: Fri, 28 Jun 2024 12:04:56 +0200 Subject: [PATCH 086/130] add format-number printout to ambi_converter.c --- apps/ambi_converter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index eddcf06e19..8fdb3573fc 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -73,6 +73,8 @@ int main(int argc, char* argv[]) in_format = atoi(argv[3]); out_format = atoi(argv[4]); + printf("In %d, Out: %d\n",in_format,out_format); + wavFile_in = OpenWav( fileName_in, &samplingRate, &numChannels, &samplesInFile, &bps ); wavFile_out = CreateWav( fileName_out, samplingRate, numChannels, 16 ); -- GitLab From 62fc6aca3711026cbb1f3abecfbb0e2dd00d7d65 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 28 Jun 2024 12:24:40 +0200 Subject: [PATCH 087/130] fix logic in convert_ambi_format --- lib_util/ambi_convert.c | 82 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 093cf6142c..416b3e5c0a 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -203,52 +203,54 @@ 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 ) + { + if ( ch_ord_in != ch_ord_out ) + { + renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ); + reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ); + } + else + { + renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); + } + } + else if( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ); + reorder_channels( in, out, order, ch_ord_in, ch_ord_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 ) + else if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) + { + if ( ch_ord_in != ch_ord_out ) + { + reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ); + renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ); + } + else + { + renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); + } + } + else if ( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ); + reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); } + else if ( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D) + { + int16_t i_chan = 0; + int16_t n_chan = ( order + 1 ) * ( order + 1 ); -#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 ) + for ( i_chan = 0; i_chan < n_chan; i_chan++ ) + { + int16_t i = 0; + for ( i = 0; i < L_FRAME48k; i++ ) + { + out[i_chan][i] = in[i_chan][i]; + } + } + } + else { - renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); + assert ( 0 && "This should never happen!"); } return 0; -- GitLab From aa9ca52d0667711efbbd1cc3d269fdea0d94e12c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 28 Jun 2024 13:15:01 +0200 Subject: [PATCH 088/130] Updated detailed report. --- scripts/parse_xml_report.py | 57 +++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 4b61dc1a94..f48b5d9e19 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -40,6 +40,12 @@ if __name__ == "__main__": results_unsorted = {} count = {'PASS':0,'FAIL':0,'ERROR':0} + # Formats, categories and MLD histogram limits + formats = {'**Unidentified format**':r'.*','Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', + 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer'} + categories = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' } + limits = [0,5,10,20,math.inf] + for testcase in testcases: if testcase.find(".//skipped") is None: if testcase.get("file") is None: @@ -64,43 +70,50 @@ if __name__ == "__main__": testresult = 'PASS' properties_values = [str(properties_found.get(p)) for p in PROPERTIES] + + # Identify format and category (mode of operation) + fmt = [f for f in formats if re.search(formats[f], fulltestname, re.IGNORECASE)][-1] + cat = [c for c in categories if re.search(categories[c], fulltestname, re.IGNORECASE)][-1] + # For ERROR cases, both a FAIL and an ERROR result is generated. # Here, a FAIL would be overwritten with an ERROR result since it has the same name. - results_unsorted[fulltestname] = (testresult, properties_values) + # Todo: Change to fielded dict for all entries to eliminate confusing literal indices + results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) results_sorted = dict(sorted(results_unsorted.items())) with open(csv_file, "w") as outfile: - headerline = ";".join(["testcase","Result"] + PROPERTIES) + "\n" + headerline = ";".join(["testcase","Format","Category","Result"] + PROPERTIES) + "\n" outfile.write(headerline) for test in results_sorted: - count[results_sorted[test][0]] += 1 - line = ";".join([test,results_sorted[test][0]] + results_sorted[test][1]) + "\n" + count[results_sorted[test][2]] += 1 + line = ";".join([test] + list(results_sorted[test])[0:-1] + results_sorted[test][-1]) + "\n" outfile.write(line) - categories = {'Normal operation':r'.*', 'JBM':r'JBM', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching'} - limits = [0,5,10,20,math.inf] tmp = {} + for fmt in formats: + tmp[fmt] = {} + for cat in categories: + tmp[fmt][cat] = [] if summary_file is not None: with open(summary_file, "w") as fp: for testcase in results_sorted: - cat = [c for c in categories if re.search(categories[c],testcase)][-1] - if cat in tmp: - tmp[cat].append(results_sorted[testcase][1][0]) # Add MLD score to list - else: - tmp[cat] = [results_sorted[testcase][1][0]] - - headerline = "Category;0;" + ";".join([f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])]) + ";None\n" - fp.write(headerline) - for cat in tmp: - # Separate 0 and None as special cases - mld = [float(x) for x in tmp[cat] if x != 'None' and x != '0'] - zero = sum([1 for x in tmp[cat] if x == '0']) - none = sum([1 for x in tmp[cat] if x == 'None']) - hist, _ = np.histogram(mld,limits) - line = f"{cat}; {str(zero)}; {'; '.join(map(str,hist))}; {str(none)}\n" - fp.write(line) + (fmt, cat, _, _) = results_sorted[testcase] + tmp[fmt][cat].append(results_sorted[testcase][-1][0]) # Add MLD score to list + + for fmt in tmp: + headerline = f"{fmt};\nCategory;0;" + ";".join([f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])]) + ";None\n" + fp.write(headerline) + for cat in categories: + # Separate 0 and None as special cases + mld = [float(x) for x in tmp[fmt][cat] if x != 'None' and x != '0'] + zero = sum([1 for x in tmp[fmt][cat] if x == '0']) + none = sum([1 for x in tmp[fmt][cat] if x == 'None']) + hist, _ = np.histogram(mld,limits) + line = f"{cat}; {str(zero)}; {'; '.join(map(str,hist))}; {str(none)}\n" + fp.write(line) + fp.write("\n") print( f"Parsed testsuite with {count['PASS']+count['FAIL']+count['ERROR']} tests: {count['PASS']} passes, {count['FAIL']} failures and {count['ERROR']} errors." -- GitLab From efafa468cfc62336c528a2cab466273bcc2bdebc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 28 Jun 2024 13:46:43 +0200 Subject: [PATCH 089/130] fix compiler warning --- lib_util/ambi_convert.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 416b3e5c0a..28a49fdba8 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -127,8 +127,12 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT 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; + + AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN; + AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN; + + AMBI_CHANNEL_NORM ch_norm_in = AMBI_NORM_SN3D; + AMBI_CHANNEL_NORM ch_norm_out = AMBI_NORM_SN3D; assert( order <= 3 ); -- GitLab From dce7def874026657523c011da0b42ca0bc4ac87f Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 28 Jun 2024 13:54:54 +0200 Subject: [PATCH 090/130] fix formatting --- apps/ambi_converter.c | 48 ++++++++++++++++++++--------------------- lib_util/ambi_convert.c | 20 ++++++++--------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 8fdb3573fc..45f12acd45 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -36,50 +36,50 @@ #include "tinywaveout_c.h" #include "ambi_convert.h" -#define L_FRAME48k 960 +#define L_FRAME48k 960 #define MAX_CHANNELS 16 -int main(int argc, char* argv[]) +int main( int argc, char *argv[] ) { WAVEFILEIN *wavFile_in; WAVEFILEOUT *wavFile_out; - char* fileName_in, *fileName_out; - + char *fileName_in, *fileName_out; + uint32_t samplingRate; uint32_t samplesInFile; uint32_t numSamples = L_FRAME48k; uint32_t numSamplesRead32 = 0; - + int16_t bps; - int16_t samples[L_FRAME48k*MAX_CHANNELS]; + int16_t samples[L_FRAME48k * MAX_CHANNELS]; int16_t order = 0; int16_t numChannels; AMBI_FMT in_format, out_format; - float samples_f_in[L_FRAME48k*MAX_CHANNELS]; - float samples_f_out[L_FRAME48k*MAX_CHANNELS]; + float samples_f_in[L_FRAME48k * MAX_CHANNELS]; + float samples_f_out[L_FRAME48k * MAX_CHANNELS]; float *in[MAX_CHANNELS], *out[MAX_CHANNELS]; - for(int16_t j=0;j 0 && order <=3 ); + order = (int16_t) sqrtf( numChannels ) - 1; + assert( order > 0 && order <= 3 ); while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) == __TWI_SUCCESS ) @@ -91,21 +91,21 @@ int main(int argc, char* argv[]) break; } - for (int16_t i=0;i Date: Fri, 28 Jun 2024 14:27:42 +0200 Subject: [PATCH 091/130] delete unused test vectors stv3OA48c_FuMa.wav, stv3OA48c_N3D.wav, stv3OA48c_SN3D-SID.wav --- scripts/testv/stv3OA48c_FuMa.wav | 3 --- scripts/testv/stv3OA48c_N3D.wav | 3 --- scripts/testv/stv3OA48c_SN3D-SID.wav | 3 --- 3 files changed, 9 deletions(-) delete mode 100644 scripts/testv/stv3OA48c_FuMa.wav delete mode 100644 scripts/testv/stv3OA48c_N3D.wav delete mode 100644 scripts/testv/stv3OA48c_SN3D-SID.wav diff --git a/scripts/testv/stv3OA48c_FuMa.wav b/scripts/testv/stv3OA48c_FuMa.wav deleted file mode 100644 index 6b52c739ce..0000000000 --- a/scripts/testv/stv3OA48c_FuMa.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:95f21ed4f2134ff6a43e2f3a1654396e1c02bc5e78f3ddd69071adb16567cb53 -size 30720844 diff --git a/scripts/testv/stv3OA48c_N3D.wav b/scripts/testv/stv3OA48c_N3D.wav deleted file mode 100644 index 150b8a91d9..0000000000 --- a/scripts/testv/stv3OA48c_N3D.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:68c29e8be1afe7cac05914a6152438f86a417b30e88241eb25b061de14a98b73 -size 30720844 diff --git a/scripts/testv/stv3OA48c_SN3D-SID.wav b/scripts/testv/stv3OA48c_SN3D-SID.wav deleted file mode 100644 index 6e46a91732..0000000000 --- a/scripts/testv/stv3OA48c_SN3D-SID.wav +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:363204e18b68f242fd97d76fbd0a911d9b8a479ecf9b68ffaa47114ddc2ab9af -size 30720844 -- GitLab From 81caf0df5a00e045891deded02edb4bfcd6e4b9c Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 28 Jun 2024 15:12:54 +0200 Subject: [PATCH 092/130] fix length of output file --- apps/ambi_converter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 45f12acd45..17aaf3ac24 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -109,7 +109,7 @@ int main( int argc, char *argv[] ) } } - err = WriteWavShort( wavFile_out, samples, numSamples ); + err = WriteWavShort( wavFile_out, samples, numSamplesRead32 ); numSamplesRead32 = 0; } -- GitLab From 557ed1186c35540a3d655977aa6a03c37a66fcb0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 28 Jun 2024 16:12:47 +0200 Subject: [PATCH 093/130] fix for #1133 and add testcase in SID frames after burst errors with fadeout to noise in MDCT-Stereo, skip scaling of the old output stored in HQ core handle --- lib_com/options.h | 1 + lib_dec/ivas_core_dec.c | 4 ++++ scripts/config/self_test.prm | 5 +++++ scripts/dly_error_profiles/ep_5pct_burst.g192 | 1 + 4 files changed, 11 insertions(+) create mode 100644 scripts/dly_error_profiles/ep_5pct_burst.g192 diff --git a/lib_com/options.h b/lib_com/options.h index fa38e730d1..f56a74b007 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -177,6 +177,7 @@ #define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ #define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ #define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */ +#define NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID /* FhG: issue 1133: in TCX PLC, don't scale hHQ_core->old_out after applying fade to noise in burst frame error */ #define NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /* FhG: issue 1128: set output ambisonics order to input order for EXT output */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index f077802dc0..f52a21c25e 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -189,7 +189,11 @@ ivas_error ivas_core_dec( st->flagGuidedAcelp = 0; } +#ifdef NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID + if ( !st->bfi && st->prev_bfi && st->total_brate > SID_2k40 && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL ) +#else if ( !st->bfi && st->prev_bfi && ( st->last_core_bfi == TCX_20_CORE || st->last_core_bfi == TCX_10_CORE ) && st->hTcxDec != NULL ) +#endif { v_multc( st->hHQ_core->old_out, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_out, st->hTcxDec->L_frameTCX ); v_multc( st->hHQ_core->old_outLB, st->hTcxDec->conceal_eof_gain * st->last_concealed_gain_syn_deemph, st->hHQ_core->old_outLB, st->L_frame ); diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index c3ff72f61d..1c42440ca6 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -275,6 +275,11 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec MONO 48 bit_error testv/stvST48n.wav_stereo_48000_48-48_DTX_MONO_FER5.tst +// stereo at 48 kbps, 48 kHz in, 48 kHz out, DTX on, FER with burst error before SID +../IVAS_cod -stereo -dtx 48000 48 testv/stvST48n.wav bit +eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct_burst.g192 bit_error +../IVAS_dec stereo 48 bit_error testv/stvST48n.wav_stereo_48000_48-48_DTX_stereo_FER5.tst + // stereo at 48 kbps, 32 kHz in, 32 kHz out, DTX on, MONO out ../IVAS_cod -stereo -dtx 48000 32 testv/stvST32n.wav bit ../IVAS_dec MONO 32 bit testv/stvST32n.wav_stereo_48000_32-32_DTX_MONO.tst diff --git a/scripts/dly_error_profiles/ep_5pct_burst.g192 b/scripts/dly_error_profiles/ep_5pct_burst.g192 new file mode 100644 index 0000000000..6c0655b3de --- /dev/null +++ b/scripts/dly_error_profiles/ep_5pct_burst.g192 @@ -0,0 +1 @@ +!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k k k k k k k k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k!k k!k!k!k!k!k k!k!k k!k!k \ No newline at end of file -- GitLab From f16c1b209e4ae6e0f69f18d1bb513de880dc625a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 28 Jun 2024 16:55:56 +0200 Subject: [PATCH 094/130] clang format --- lib_dec/ivas_core_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index f52a21c25e..47e6bf25b4 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -406,7 +406,7 @@ ivas_error ivas_core_dec( { updateBuffersForDmxMdctStereo( hCPE, output_frame, output, synth ); } -#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES +#ifdef NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* On first good active frame after frameloss undo the whitening of the bg noise shape */ if ( sts[0]->core_brate > SID_2k40 && sts[0]->bfi == 0 && sts[0]->prev_bfi == 1 ) -- GitLab From 884f6f26cc22f0b455c9eab7a78927a06e6026ec Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 1 Jul 2024 07:37:29 +0200 Subject: [PATCH 095/130] Fix for format identification to pick the earliest match in the test case --- scripts/parse_xml_report.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index f48b5d9e19..5b9492d958 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -41,8 +41,8 @@ if __name__ == "__main__": count = {'PASS':0,'FAIL':0,'ERROR':0} # Formats, categories and MLD histogram limits - formats = {'**Unidentified format**':r'.*','Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer'} + formats = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', + 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer','**Unidentified format**':r'.*'} categories = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' } limits = [0,5,10,20,math.inf] @@ -72,7 +72,8 @@ if __name__ == "__main__": properties_values = [str(properties_found.get(p)) for p in PROPERTIES] # Identify format and category (mode of operation) - fmt = [f for f in formats if re.search(formats[f], fulltestname, re.IGNORECASE)][-1] + # For the format, favor the earliest match in the test case name + fmt = min([(f, re.search(formats[f], fulltestname, re.IGNORECASE).end()) for f in formats if re.search(formats[f], fulltestname, re.IGNORECASE)] , key=lambda x: x[1])[0] cat = [c for c in categories if re.search(categories[c], fulltestname, re.IGNORECASE)][-1] # For ERROR cases, both a FAIL and an ERROR result is generated. -- GitLab From 56e874cc602c78993c04be80f1f2c2c3a41e19ad Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 1 Jul 2024 08:22:03 +0200 Subject: [PATCH 096/130] Harmonize results into a dict --- scripts/parse_xml_report.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 5b9492d958..ef3c5823a6 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -79,16 +79,21 @@ if __name__ == "__main__": # For ERROR cases, both a FAIL and an ERROR result is generated. # Here, a FAIL would be overwritten with an ERROR result since it has the same name. # Todo: Change to fielded dict for all entries to eliminate confusing literal indices - results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) + #results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) + results_unsorted[fulltestname] = {'Format':fmt, 'Category':cat, 'Result':testresult} + for propertyname, propertyvalue in zip(PROPERTIES, properties_values): + results_unsorted[fulltestname][propertyname] = propertyvalue results_sorted = dict(sorted(results_unsorted.items())) + keys = list(results_sorted[list(results_unsorted.keys())[0]].keys()) + with open(csv_file, "w") as outfile: - headerline = ";".join(["testcase","Format","Category","Result"] + PROPERTIES) + "\n" + headerline = ";".join(["testcase"] + keys) + "\n" outfile.write(headerline) for test in results_sorted: - count[results_sorted[test][2]] += 1 - line = ";".join([test] + list(results_sorted[test])[0:-1] + results_sorted[test][-1]) + "\n" + count[results_sorted[test]["Result"]] += 1 + line = ";".join([test] + list(results_sorted[test].values())) + "\n" outfile.write(line) tmp = {} @@ -100,8 +105,9 @@ if __name__ == "__main__": if summary_file is not None: with open(summary_file, "w") as fp: for testcase in results_sorted: - (fmt, cat, _, _) = results_sorted[testcase] - tmp[fmt][cat].append(results_sorted[testcase][-1][0]) # Add MLD score to list + fmt = results_sorted[testcase]["Format"] + cat = results_sorted[testcase]["Category"] + tmp[fmt][cat].append(results_sorted[testcase]["MLD"]) # Add MLD score to list for fmt in tmp: headerline = f"{fmt};\nCategory;0;" + ";".join([f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])]) + ";None\n" -- GitLab From dd7428e18a4571eeba7b0dbf55edc9a5b2764ba6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 1 Jul 2024 11:05:01 +0200 Subject: [PATCH 097/130] Change layout of matplotlib histogram --- scripts/parse_xml_report.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index ef3c5823a6..addddafda4 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -4,6 +4,7 @@ import argparse import re import math import numpy as np +import matplotlib.pyplot as plt from xml.etree import ElementTree """ @@ -41,8 +42,10 @@ if __name__ == "__main__": count = {'PASS':0,'FAIL':0,'ERROR':0} # Formats, categories and MLD histogram limits + # formats = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', + # 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer'} formats = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer','**Unidentified format**':r'.*'} + 'OSBA':r'OSBA', 'OMASA':r'OMASA','MASA':r'MASA','SBA':r'SBA', 'Renderer':r'renderer'} categories = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' } limits = [0,5,10,20,math.inf] @@ -108,20 +111,41 @@ if __name__ == "__main__": fmt = results_sorted[testcase]["Format"] cat = results_sorted[testcase]["Category"] tmp[fmt][cat].append(results_sorted[testcase]["MLD"]) # Add MLD score to list - + + subplot = 0 + fig, ax = plt.subplots(len(formats)//2, 2) for fmt in tmp: - headerline = f"{fmt};\nCategory;0;" + ";".join([f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])]) + ";None\n" + limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + headerline = f"{fmt};\nCategory;" + ";".join(limits_labels) + "\n" fp.write(headerline) + bottom = np.zeros(len(limits)+1) for cat in categories: + # CSV output # Separate 0 and None as special cases mld = [float(x) for x in tmp[fmt][cat] if x != 'None' and x != '0'] zero = sum([1 for x in tmp[fmt][cat] if x == '0']) - none = sum([1 for x in tmp[fmt][cat] if x == 'None']) + none = sum([1 for x in tmp[fmt][cat] if x == 'None']) hist, _ = np.histogram(mld,limits) - line = f"{cat}; {str(zero)}; {'; '.join(map(str,hist))}; {str(none)}\n" + data = np.array([zero] + list(hist) + [none]) + line = f"{cat}; {'; '.join(map(str,data))}\n" fp.write(line) + + # Matplotlib histogram + a = subplot % 4 + b = subplot // 4 + ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) + bottom += data fp.write("\n") + ax[a][b].set_title(fmt) + ax[a][b].legend(loc="best") + ax[a][b].set_xlabel("MLD") + ax[a][b].set_ylabel("Number of test cases") + subplot += 1 + fig.set_figheight(20) + fig.set_figwidth(16) + plt.savefig(summary_file +".png") + print( f"Parsed testsuite with {count['PASS']+count['FAIL']+count['ERROR']} tests: {count['PASS']} passes, {count['FAIL']} failures and {count['ERROR']} errors." ) -- GitLab From d3d1ce8ad8a557fe223202f0adff099f5de0e539 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 1 Jul 2024 11:40:56 +0200 Subject: [PATCH 098/130] add same condition in ltv test file + correct output name --- scripts/config/self_test.prm | 2 +- scripts/config/self_test_ltv.prm | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/config/self_test.prm b/scripts/config/self_test.prm index e1a0d2d6ec..acbef95686 100644 --- a/scripts/config/self_test.prm +++ b/scripts/config/self_test.prm @@ -278,7 +278,7 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 // stereo at 48 kbps, 48 kHz in, 48 kHz out, DTX on, FER with burst error before SID ../IVAS_cod -stereo -dtx 48000 48 testv/stvST48n.wav bit eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct_burst.g192 bit_error -../IVAS_dec stereo 48 bit_error testv/stvST48n.wav_stereo_48000_48-48_DTX_stereo_FER5.tst +../IVAS_dec stereo 48 bit_error testv/stvST48n.wav_stereo_48000_48-48_DTX_stereo_FER5_burst.tst // stereo at 48 kbps, 32 kHz in, 32 kHz out, DTX on, MONO out ../IVAS_cod -stereo -dtx 48000 32 testv/stvST32n.wav bit diff --git a/scripts/config/self_test_ltv.prm b/scripts/config/self_test_ltv.prm index 9003fec9a1..45cc65beb1 100644 --- a/scripts/config/self_test_ltv.prm +++ b/scripts/config/self_test_ltv.prm @@ -274,6 +274,11 @@ eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g1 eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct.g192 bit_error ../IVAS_dec MONO 48 bit_error testv/ltv48_STEREO.wav_stereo_48000_48-48_DTX_MONO_FER5.tst +// stereo at 48 kbps, 48 kHz in, 48 kHz out, DTX on, FER with burst error before SID +../IVAS_cod -stereo -dtx 48000 48 testv/ltv48_STEREO.wav bit +eid-xor -fer -vbr -bs g192 -ep g192 bit ../scripts/dly_error_profiles/ep_5pct_burst.g192 bit_error +../IVAS_dec stereo 48 bit_error testv/ltv48_STEREO.wav_stereo_48000_48-48_DTX_stereo_FER5_burst.tst + // stereo at 48 kbps, 32 kHz in, 32 kHz out, DTX on, MONO out ../IVAS_cod -stereo -dtx 48000 32 testv/ltv32_STEREO.wav bit ../IVAS_dec MONO 32 bit testv/ltv32_STEREO.wav_stereo_48000_32-32_DTX_MONO.tst -- GitLab From 407fed135b2bdfb3a691945562606bdd2e9750e5 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 1 Jul 2024 16:07:26 +0200 Subject: [PATCH 099/130] Put report summary into separate script scripts/create_histogram_summary.py --- scripts/create_histogram_summary.py | 93 +++++++++++++++++++++++++++++ scripts/parse_xml_report.py | 81 +++++-------------------- 2 files changed, 109 insertions(+), 65 deletions(-) create mode 100644 scripts/create_histogram_summary.py diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py new file mode 100644 index 0000000000..4116a97e21 --- /dev/null +++ b/scripts/create_histogram_summary.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +import argparse +import math +import numpy as np +import matplotlib.pyplot as plt +import csv +from parse_xml_report import FORMATS, CATEGORIES + +""" +Parses a CSV report and creates a summary report. +""" + + + +# Main routine +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Parses a CSV report and creates a summary report." + ) + parser.add_argument( + "csv_report", + type=str, + help="CSV report file of test cases, e.g. report.csv", + ) + parser.add_argument( + "csv_summary", type=str, help="Output CSV file, e.g. summary.csv" + ) + parser.add_argument( + "csv_image", + type=str, + nargs='?', + help="Summary image file, e.g. summary.png", + default = None + ) + args = parser.parse_args() + csv_report = args.csv_report + csv_summary = args.csv_summary + csv_image = args.csv_image + + limits = [0, 5, 10, math.inf] + + # Load CSV report + results_sorted = {} + with open(csv_report,'r') as fp: + reader = csv.reader(fp, delimiter=';') + header = next(reader) + keys = header[1:-1] + for row in reader: + testcase = row[0] + results_sorted[testcase] = {} + for k, val in zip(keys, row[1:-1]): + results_sorted[testcase][k] = val + + # Output CSV file + with open(csv_summary, "w") as fp: + limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" + fp.write(headerline) + + subplot = 0 + fig, ax = plt.subplots(len(FORMATS)//2, 2) + for fmt in FORMATS: + bottom = np.zeros(len(limits)+1) + for cat in CATEGORIES: + mld_vals = [x for x in [m["MLD"] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] + mld = [float(x) for x in mld_vals if x != 'None' and x != '0'] + zero = sum([1 for x in mld_vals if x == '0']) + none = sum([1 for x in mld_vals if x == 'None']) + hist, _ = np.histogram(mld,limits) + data = np.array([zero] + list(hist) + [none]) + + # CSV output + line = f"{fmt};{cat};{'; '.join(map(str,data))}\n" + fp.write(line) + + # Matplotlib histogram + a = subplot % 4 + b = subplot // 4 + ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) + bottom += data + + # Histogram layout + ax[a][b].set_title(fmt) + ax[a][b].legend(loc="best") + ax[a][b].set_xlabel("MLD") + ax[a][b].set_ylabel("Number of test cases") + subplot += 1 + + fig.set_figheight(20) + fig.set_figwidth(16) + if csv_image: + plt.savefig(csv_image) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index addddafda4..87c660b8c3 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -13,41 +13,39 @@ Parse a junit report and create a summary report. PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] +FORMATS = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', + 'OSBA':r'OSBA', 'OMASA':r'OMASA','MASA':r'MASA','SBA':r'SBA', 'Renderer':r'renderer'} + +CATEGORIES = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' } # Main routine if __name__ == "__main__": parser = argparse.ArgumentParser( - description="Parse a junit report and create a MLD summary report." + description="Parse a junit report and create an MLD summary report." ) parser.add_argument( "xml_report", type=str, help="XML junit report input file, e.g. report-junit.xml", ) - parser.add_argument("csv_file", type=str, help="Output CSV file, e.g. mld.csv") - parser.add_argument("summary_file", type=str, nargs='?', help="Summary CSV file, e.g. summary.csv", default = None) + parser.add_argument( + "csv_file", + type=str, + help="Output CSV file, e.g. report.csv" + ) args = parser.parse_args() xml_report = args.xml_report csv_file = args.csv_file - summary_file = args.summary_file tree = ElementTree.parse(xml_report) testsuite = tree.find(".//testsuite") - - testcases = tree.findall(".//testcase") results_unsorted = {} count = {'PASS':0,'FAIL':0,'ERROR':0} - # Formats, categories and MLD histogram limits - # formats = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - # 'MASA':r'MASA','SBA':r'SBA', 'OSBA':r'OSBA', 'OMASA':r'OMASA','Renderer':r'renderer'} - formats = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - 'OSBA':r'OSBA', 'OMASA':r'OMASA','MASA':r'MASA','SBA':r'SBA', 'Renderer':r'renderer'} - categories = {'Normal operation':r'.*', 'DTX':r'DTX', 'PLC':r'%', 'Bitrate switching':r'br sw|bitrate switching', 'JBM':r'JBM' } - limits = [0,5,10,20,math.inf] + for testcase in testcases: if testcase.find(".//skipped") is None: @@ -76,21 +74,21 @@ if __name__ == "__main__": # Identify format and category (mode of operation) # For the format, favor the earliest match in the test case name - fmt = min([(f, re.search(formats[f], fulltestname, re.IGNORECASE).end()) for f in formats if re.search(formats[f], fulltestname, re.IGNORECASE)] , key=lambda x: x[1])[0] - cat = [c for c in categories if re.search(categories[c], fulltestname, re.IGNORECASE)][-1] + fmt = min([(f, re.search(FORMATS[f], fulltestname, re.IGNORECASE).end()) for f in FORMATS if re.search(FORMATS[f], fulltestname, re.IGNORECASE)] , key=lambda x: x[1])[0] + + # Note that only one category is selected, even though several may match, e.g. bitrate switching + JBM. Here the last match is picked. + cat = [c for c in CATEGORIES if re.search(CATEGORIES[c], fulltestname, re.IGNORECASE)][-1] # For ERROR cases, both a FAIL and an ERROR result is generated. # Here, a FAIL would be overwritten with an ERROR result since it has the same name. - # Todo: Change to fielded dict for all entries to eliminate confusing literal indices - #results_unsorted[fulltestname] = (fmt, cat, testresult, properties_values) results_unsorted[fulltestname] = {'Format':fmt, 'Category':cat, 'Result':testresult} for propertyname, propertyvalue in zip(PROPERTIES, properties_values): results_unsorted[fulltestname][propertyname] = propertyvalue results_sorted = dict(sorted(results_unsorted.items())) - keys = list(results_sorted[list(results_unsorted.keys())[0]].keys()) + # Write CSV file with open(csv_file, "w") as outfile: headerline = ";".join(["testcase"] + keys) + "\n" outfile.write(headerline) @@ -99,53 +97,6 @@ if __name__ == "__main__": line = ";".join([test] + list(results_sorted[test].values())) + "\n" outfile.write(line) - tmp = {} - for fmt in formats: - tmp[fmt] = {} - for cat in categories: - tmp[fmt][cat] = [] - - if summary_file is not None: - with open(summary_file, "w") as fp: - for testcase in results_sorted: - fmt = results_sorted[testcase]["Format"] - cat = results_sorted[testcase]["Category"] - tmp[fmt][cat].append(results_sorted[testcase]["MLD"]) # Add MLD score to list - - subplot = 0 - fig, ax = plt.subplots(len(formats)//2, 2) - for fmt in tmp: - limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] - headerline = f"{fmt};\nCategory;" + ";".join(limits_labels) + "\n" - fp.write(headerline) - bottom = np.zeros(len(limits)+1) - for cat in categories: - # CSV output - # Separate 0 and None as special cases - mld = [float(x) for x in tmp[fmt][cat] if x != 'None' and x != '0'] - zero = sum([1 for x in tmp[fmt][cat] if x == '0']) - none = sum([1 for x in tmp[fmt][cat] if x == 'None']) - hist, _ = np.histogram(mld,limits) - data = np.array([zero] + list(hist) + [none]) - line = f"{cat}; {'; '.join(map(str,data))}\n" - fp.write(line) - - # Matplotlib histogram - a = subplot % 4 - b = subplot // 4 - ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) - bottom += data - fp.write("\n") - - ax[a][b].set_title(fmt) - ax[a][b].legend(loc="best") - ax[a][b].set_xlabel("MLD") - ax[a][b].set_ylabel("Number of test cases") - subplot += 1 - fig.set_figheight(20) - fig.set_figwidth(16) - plt.savefig(summary_file +".png") - print( f"Parsed testsuite with {count['PASS']+count['FAIL']+count['ERROR']} tests: {count['PASS']} passes, {count['FAIL']} failures and {count['ERROR']} errors." ) -- GitLab From a4559d8e3299802bffdf37b378e6f0e2165f87da Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 1 Jul 2024 20:56:33 +0200 Subject: [PATCH 100/130] [cleanup] accept FIX_1101_CLEANING_JBM_CALL, NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING, NONBE_1131_ACELP_OOB --- lib_com/ivas_cnst.h | 3 -- lib_com/options.h | 3 -- lib_dec/acelp_core_dec.c | 8 ----- lib_dec/ivas_init_dec.c | 11 ------- lib_dec/ivas_jbm_dec.c | 46 ----------------------------- lib_dec/ivas_stereo_cng_dec.c | 2 -- lib_dec/ivas_stereo_switching_dec.c | 2 -- lib_enc/acelp_core_enc.c | 4 --- lib_enc/ivas_stereo_switching_enc.c | 2 -- 9 files changed, 81 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d2ae6f9bdd..90cfa67775 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -179,9 +179,6 @@ typedef enum typedef enum { -#ifndef FIX_1101_CLEANING_JBM_CALL - TC_BUFFER_MODE_NONE = 0, -#endif TC_BUFFER_MODE_RENDERER, TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; diff --git a/lib_com/options.h b/lib_com/options.h index 1ff12b05ae..b091d002cd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,7 +162,6 @@ //#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT /* Orange issue 1031 : new fix point hrtf binary file format */ //#define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ #define FLOAT_FIX_POINT_HRTF_FILE_FORMAT /* allows reading floation or fix point hrtf binary file format */ -#define FIX_1101_CLEANING_JBM_CALL /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */ #define FIX_1053_AEID_FILE_TEST /* Philips: Tests for the -aeid file and fix for memory error */ #define FIX_1121_MASA_DESCRIPTOR /* VA: issue 1121: Define 'ivasmasaFormatDescriptor' at one common place */ #define FIX_1113_CLDFB_REND_IN_ISAR /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */ @@ -174,8 +173,6 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ -#define NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING /* VA: issue 1110: fix encoder crash in the stereo DTX bitrate switching condition */ -#define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ #define NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /* FhG: issue 1128: set output ambisonics order to input order for EXT output */ #define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ diff --git a/lib_dec/acelp_core_dec.c b/lib_dec/acelp_core_dec.c index d444c03ea7..4ac0e098be 100644 --- a/lib_dec/acelp_core_dec.c +++ b/lib_dec/acelp_core_dec.c @@ -231,11 +231,7 @@ ivas_error acelp_core_dec( st->hGSCDec->Last_frame_ener = (float) MAX_32; } -#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING if ( st->hFdCngDec != NULL && ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) -#else - if ( ( st->element_mode == IVAS_CPE_DFT || st->element_mode == IVAS_CPE_TD ) && ( st->last_core_brate == SID_2k40 || st->last_core_brate == FRAME_NO_DATA ) ) -#endif { set_zero( st->hFdCngDec->hFdCngCom->olapBufferSynth2, FFTLEN ); set_zero( hStereoCng->olapBufferSynth22, FFTLEN ); @@ -703,11 +699,7 @@ ivas_error acelp_core_dec( old_exc_s = st->old_exc + L_EXC_MEM_DEC - st->L_frame; tmpF = *old_exc_s; st->mem_deemph = old_exc_s[st->L_frame - 1]; -#ifdef NONBE_1131_ACELP_OOB preemph( old_exc_s, st->preemph_fac, st->L_frame, &tmpF ); -#else - preemph( old_exc_s, st->preemph_fac, L_FRAME16k, &tmpF ); -#endif mvr2r( old_exc_s + st->L_frame - M, st->mem_syn2, M ); residu( Aq, M, old_exc_s, old_exc + L_EXC_MEM_DEC - st->L_frame, st->L_frame ); } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 8548689f64..839894d1e3 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2126,17 +2126,6 @@ ivas_error ivas_init_decoder( } } -#ifndef FIX_1101_CLEANING_JBM_CALL - if ( st_ivas->hTcBuffer == NULL ) - { - /* we need the handle anyway, but without the buffer*/ - if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_NONE, 0, 0, 0, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } - } - -#endif if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && st_ivas->hDecoderConfig->Opt_tsm ) { if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index da386ac0bb..b005723168 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -103,15 +103,6 @@ ivas_error ivas_jbm_dec_tc( } } -#ifndef FIX_1101_CLEANING_JBM_CALL - if ( !st_ivas->hDecoderConfig->Opt_tsm ) - { - for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) - { - st_ivas->hTcBuffer->tc[n] = st_ivas->p_output_f[n]; - } - } -#endif /*----------------------------------------------------------------* * Decoding + pre-rendering *----------------------------------------------------------------*/ @@ -801,7 +792,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( p_data_f[n] = &data_f[n][0]; } -#ifdef FIX_1101_CLEANING_JBM_CALL if ( !st_ivas->hDecoderConfig->Opt_tsm ) { for ( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) @@ -810,7 +800,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( } } -#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_tc( st_ivas, nSamplesForRendering, nSamplesResidual, data, p_data_f ); @@ -2291,18 +2280,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open( set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); -#ifndef FIX_1101_CLEANING_JBM_CALL - if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_NONE ) - { - hTcBuffer->tc_buffer = NULL; - - for ( ch_idx = 0; ch_idx < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) - { - hTcBuffer->tc[ch_idx] = NULL; - } - } - else -#endif { int16_t n_samp_full, n_samp_residual; int32_t offset; @@ -2729,9 +2706,6 @@ void ivas_jbm_dec_copy_tc_no_tsm( const int16_t output_frame /* i : output frame size */ ) { -#ifndef FIX_1101_CLEANING_JBM_CALL - int16_t n_ch_full_copy; -#endif int16_t n_ch_cldfb; int16_t ch_idx; DECODER_TC_BUFFER_HANDLE hTcBuffer; @@ -2739,26 +2713,10 @@ void ivas_jbm_dec_copy_tc_no_tsm( hTcBuffer = st_ivas->hTcBuffer; hTcBuffer->n_samples_buffered = output_frame; hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; -#ifndef FIX_1101_CLEANING_JBM_CALL - n_ch_full_copy = min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); -#endif n_ch_cldfb = hTcBuffer->nchan_transport_jbm - hTcBuffer->nchan_buffer_full; -#ifdef FIX_1101_CLEANING_JBM_CALL #ifdef DEBUGGING assert( st_ivas->hDecoderConfig->Opt_tsm == 0 ); -#endif -#else - /* copy full tcs*/ - if ( st_ivas->hDecoderConfig->Opt_tsm ) - { - for ( ch_idx = 0; ch_idx < n_ch_full_copy; ch_idx++ ) - { - mvr2r( tc[ch_idx], st_ivas->hTcBuffer->tc[ch_idx], hTcBuffer->n_samples_buffered ); - } - } - ch_idx = 0; - #endif /* CLDFB ana for ParamMC/ParamISM */ if ( n_ch_cldfb > 0 ) @@ -2792,11 +2750,7 @@ void ivas_jbm_dec_copy_tc_no_tsm( #endif /* CLDFB Analysis*/ -#ifdef FIX_1101_CLEANING_JBM_CALL for ( ch_idx = 0, cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch_idx++ ) -#else - for ( cldfb_ch = 0; cldfb_ch < n_ch_cldfb; cldfb_ch++, ch_idx++ ) -#endif { for ( slot_idx = 0; slot_idx < DEFAULT_JBM_CLDFB_TIMESLOTS; slot_idx++ ) { diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 0f0ff9d7aa..a63e7c7cc2 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -923,9 +923,7 @@ void stereo_cna_update_params( } else { -#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING hFdCngDec->first_cna_noise_updated = 0; -#endif return; } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 6444378280..f56a53ba96 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1552,9 +1552,7 @@ void stereo_switching_dec( mvr2r( sts[0]->lsf_old, sts[1]->lsf_old, M ); mvr2r( sts[0]->lsp_old, sts[1]->lsp_old, M ); -#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING sts[1]->last_core_brate = sts[0]->last_core_brate; -#endif if ( hCPE->element_mode == IVAS_CPE_MDCT ) { diff --git a/lib_enc/acelp_core_enc.c b/lib_enc/acelp_core_enc.c index eca6e6d71c..e305e0ce80 100644 --- a/lib_enc/acelp_core_enc.c +++ b/lib_enc/acelp_core_enc.c @@ -379,11 +379,7 @@ ivas_error acelp_core_enc( * After inactive period, use the most up-to-date ISPs *-----------------------------------------------------------------*/ -#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING if ( st->hDtxEnc != NULL && ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) ) -#else - if ( st->last_core_brate == FRAME_NO_DATA || st->last_core_brate == SID_2k40 ) -#endif { mvr2r( st->hDtxEnc->lspCNG, st->lsp_old, M ); lsp2lsf( st->hDtxEnc->lspCNG, st->lsf_old, M, int_fs ); diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 0c883721eb..8bbfd39321 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -801,9 +801,7 @@ void stereo_switching_enc( mvr2r( sts[0]->lsf_old1, sts[1]->lsf_old1, M ); mvr2r( sts[0]->lsp_old1, sts[1]->lsp_old1, M ); -#ifdef NONBE_FIX_1110_STEREO_DTX_BRATE_SWITCHING sts[1]->last_core_brate = sts[0]->last_core_brate; -#endif sts[1]->GSC_noisy_speech = 0; if ( hCPE->element_mode == IVAS_CPE_MDCT ) -- GitLab From d3184f60c4218a59973e8810347cead94e2657ff Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 2 Jul 2024 08:30:16 +0200 Subject: [PATCH 101/130] also collect failed jobs in floating point repo --- ci/setup_pages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/setup_pages.py b/ci/setup_pages.py index a28c12675e..e4195da443 100755 --- a/ci/setup_pages.py +++ b/ci/setup_pages.py @@ -42,7 +42,7 @@ def main(): project_id = int(os.environ["CI_PROJECT_ID"]) jobs = JOBS_FOR_PROJECT_ID[project_id] - success_only = project_id == PROJECT_ID_FLOAT_REPO + success_only = True failed_count = get_artifacts_for_jobs_and_return_num_failed( jobs, project_id, success_only ) -- GitLab From 64f890dfa898946e70dc7912dc53977a20c0663e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 2 Jul 2024 13:46:59 +0200 Subject: [PATCH 102/130] Add option to select SSNR and MAX ABS DIFF from create_histogram_summary.py --- scripts/create_histogram_summary.py | 60 +++++++++++++++++++---------- scripts/parse_xml_report.py | 1 - 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 4116a97e21..61cec7eef2 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -33,61 +33,79 @@ if __name__ == "__main__": help="Summary image file, e.g. summary.png", default = None ) + parser.add_argument( + "--measure", + type=str, + nargs=1, + help="Measure, any of: MLD, DIFF, SSNR, default: MLD", + default = ['MLD'] + ) args = parser.parse_args() csv_report = args.csv_report csv_summary = args.csv_summary csv_image = args.csv_image + measure = args.measure[0] - limits = [0, 5, 10, math.inf] + limits_per_measure = {'MLD':('MLD',[0, 5, 10, math.inf]), 'DIFF':('MAXIMUM ABS DIFF',[0, 1024, 16384, 32769]), 'SSNR':('MIN_SSNR',[-math.inf, 0, 20, 40, 60, 100])} + (measure_label, limits) = limits_per_measure[measure] # Load CSV report results_sorted = {} with open(csv_report,'r') as fp: reader = csv.reader(fp, delimiter=';') header = next(reader) - keys = header[1:-1] + keys = header[1:] for row in reader: testcase = row[0] results_sorted[testcase] = {} - for k, val in zip(keys, row[1:-1]): + for k, val in zip(keys, row[1:]): results_sorted[testcase][k] = val # Output CSV file with open(csv_summary, "w") as fp: - limits_labels = ["0"] + [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + limits_labels = [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF + if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": + limits_labels = ["0"] + limits_labels headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" fp.write(headerline) subplot = 0 - fig, ax = plt.subplots(len(FORMATS)//2, 2) + fig, ax = plt.subplots(len(FORMATS)//4, 4) for fmt in FORMATS: - bottom = np.zeros(len(limits)+1) + bottom = np.zeros(len(limits_labels)) + row = subplot // 4 + col = subplot % 4 for cat in CATEGORIES: - mld_vals = [x for x in [m["MLD"] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] - mld = [float(x) for x in mld_vals if x != 'None' and x != '0'] - zero = sum([1 for x in mld_vals if x == '0']) - none = sum([1 for x in mld_vals if x == 'None']) - hist, _ = np.histogram(mld,limits) - data = np.array([zero] + list(hist) + [none]) + values = [x for x in [m[measure_label] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] + # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF + if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": + val = [float(x) for x in values if x != 'None' and x != '0' and x != ''] + zero = [sum([1 for x in values if x == '0'])] + none = [sum([1 for x in values if x == 'None' or x == ''])] + else: + val = [float(x) for x in values if x != 'None' and x != ''] + zero = [] + none = [sum([1 for x in values if x == 'None' or x == ''])] + hist, _ = np.histogram(val,limits) + data = np.array(zero + list(hist) + none) # CSV output line = f"{fmt};{cat};{'; '.join(map(str,data))}\n" fp.write(line) # Matplotlib histogram - a = subplot % 4 - b = subplot // 4 - ax[a][b].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) + ax[row][col].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) bottom += data # Histogram layout - ax[a][b].set_title(fmt) - ax[a][b].legend(loc="best") - ax[a][b].set_xlabel("MLD") - ax[a][b].set_ylabel("Number of test cases") + ax[row][col].set_title(fmt) + ax[row][col].legend(loc="best") + ax[row][col].set_xlabel(measure_label) + ax[row][col].set_ylabel("Number of test cases") subplot += 1 - fig.set_figheight(20) - fig.set_figwidth(16) + fig.set_figheight(16) + fig.set_figwidth(32) if csv_image: plt.savefig(csv_image) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index 87c660b8c3..e466304393 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -4,7 +4,6 @@ import argparse import re import math import numpy as np -import matplotlib.pyplot as plt from xml.etree import ElementTree """ -- GitLab From a9c36213f010cd6a26ff180662f3254fb273e0c8 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 3 Jul 2024 09:07:20 +0200 Subject: [PATCH 103/130] Sort results in full report by FORMATS and CATEGORIES --- scripts/parse_xml_report.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index e466304393..cdd504c977 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -13,7 +13,7 @@ Parse a junit report and create a summary report. PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] FORMATS = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - 'OSBA':r'OSBA', 'OMASA':r'OMASA','MASA':r'MASA','SBA':r'SBA', 'Renderer':r'renderer'} + 'MASA':r'(? Date: Wed, 3 Jul 2024 09:41:42 +0200 Subject: [PATCH 104/130] set correct value for success_only --- ci/setup_pages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/setup_pages.py b/ci/setup_pages.py index e4195da443..f131dfb4e4 100755 --- a/ci/setup_pages.py +++ b/ci/setup_pages.py @@ -42,7 +42,7 @@ def main(): project_id = int(os.environ["CI_PROJECT_ID"]) jobs = JOBS_FOR_PROJECT_ID[project_id] - success_only = True + success_only = False failed_count = get_artifacts_for_jobs_and_return_num_failed( jobs, project_id, success_only ) -- GitLab From 4b3e2eb937ad4dfcec781d7dd00ba7d252837b3d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 10:39:33 +0200 Subject: [PATCH 105/130] move definition of L_FRAME48k and AMBI_MAX_CHANNELS to lib_util/ambi_convert.h --- lib_util/ambi_convert.c | 5 ----- lib_util/ambi_convert.h | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 5e2ab047e7..aedf4aaa88 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -34,8 +34,6 @@ #include #include "ambi_convert.h" -#define L_FRAME48k 960 - #define SQRT_2_ 1.4142135f /* sqrtf(2.0f) */ #define SQRT_3_ 1.7320508f /* sqrtf(3.0f) */ #define SQRT_5_ 2.2360679f /* sqrtf(5.0f) */ @@ -56,9 +54,6 @@ #define INV_SQRT_8_OVER_5_ 0.7905694f /* 1.0f/INV_SQRT_8_OVER_5_ */ #define INV_SQRT_45_OVER_32_ 0.8432740f /* 1.0f/SQRT_45_OVER_32_ */ -#define AMBI_MAX_CHANNELS 16 - - /* -------------------------------- normalization conversion tables -------------------------------- */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index c61bd79177..39b65f2b88 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -35,6 +35,9 @@ #include +#define L_FRAME48k 960 +#define AMBI_MAX_CHANNELS 16 + typedef enum { AMBI_FMT_ACN_SN3D = 0, -- GitLab From e6f667a7831ea39b6a47b24c70f12e591bdfd848 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 10:43:41 +0200 Subject: [PATCH 106/130] use constants from ambi_convert.h in ambi_converter.c --- apps/ambi_converter.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 17aaf3ac24..4f44e1c00c 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -36,8 +36,6 @@ #include "tinywaveout_c.h" #include "ambi_convert.h" -#define L_FRAME48k 960 -#define MAX_CHANNELS 16 int main( int argc, char *argv[] ) { @@ -52,17 +50,17 @@ int main( int argc, char *argv[] ) uint32_t numSamplesRead32 = 0; int16_t bps; - int16_t samples[L_FRAME48k * MAX_CHANNELS]; + int16_t samples[L_FRAME48k * AMBI_MAX_CHANNELS]; int16_t order = 0; int16_t numChannels; AMBI_FMT in_format, out_format; - float samples_f_in[L_FRAME48k * MAX_CHANNELS]; - float samples_f_out[L_FRAME48k * MAX_CHANNELS]; - float *in[MAX_CHANNELS], *out[MAX_CHANNELS]; + float samples_f_in[L_FRAME48k * AMBI_MAX_CHANNELS]; + float samples_f_out[L_FRAME48k * AMBI_MAX_CHANNELS]; + float *in[AMBI_MAX_CHANNELS], *out[AMBI_MAX_CHANNELS]; - for ( int16_t j = 0; j < MAX_CHANNELS; j++ ) + for ( int16_t j = 0; j < AMBI_MAX_CHANNELS; j++ ) { in[j] = &samples_f_in[j * L_FRAME48k]; out[j] = &samples_f_out[j * L_FRAME48k]; -- GitLab From 2d0c2275463238dc7b9f5d4d5419250dba0bfc6a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 11:24:40 +0200 Subject: [PATCH 107/130] fix formatting --- lib_util/ambi_convert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 39b65f2b88..e969f2b25d 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -35,7 +35,7 @@ #include -#define L_FRAME48k 960 +#define L_FRAME48k 960 #define AMBI_MAX_CHANNELS 16 typedef enum -- GitLab From 00c1f94e267e0a9f412cc38115307e86c5122e88 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 12:03:02 +0200 Subject: [PATCH 108/130] add descriptions to function arguments in lib_util/ambi_convert.c and lib_util/ambi_convert.h --- lib_util/ambi_convert.c | 24 +++++++++++++++++++++--- lib_util/ambi_convert.h | 29 +++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index aedf4aaa88..20a043b714 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -117,7 +117,13 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, API functions for the conversion ---------------------------------- */ -int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ) +int16_t convert_ambi_format( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ +) { float tmp[AMBI_MAX_CHANNELS * L_FRAME48k]; @@ -255,7 +261,13 @@ int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT return 0; } -int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ) +int16_t renormalize_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ +) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; @@ -318,7 +330,13 @@ int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHA return 0; } -int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ) +int16_t reorder_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ +) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); int16_t i_chan, i; diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index e969f2b25d..13d09cf56f 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -63,10 +63,27 @@ typedef enum AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; -int16_t convert_ambi_format( float *in[], float *out[], int16_t order, AMBI_FMT in_format, AMBI_FMT out_format ); - -int16_t renormalize_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_NORM in_format, AMBI_CHANNEL_NORM out_format ); - -int16_t reorder_channels( float *in[], float *out[], int16_t order, AMBI_CHANNEL_ORDER in_format, AMBI_CHANNEL_ORDER out_format ); - +int16_t convert_ambi_format( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ +); + +int16_t renormalize_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ +); + +int16_t reorder_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ +); #endif -- GitLab From a256c3a37c7001b36e286c553a535ad9951628b2 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 12:04:01 +0200 Subject: [PATCH 109/130] fix formatting --- lib_util/ambi_convert.c | 36 ++++++++++++++++++------------------ lib_util/ambi_convert.h | 30 +++++++++++++++--------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 20a043b714..91e686612d 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -117,12 +117,12 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, API functions for the conversion ---------------------------------- */ -int16_t convert_ambi_format( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_FMT in_format, /* i: input ambisonics format */ - AMBI_FMT out_format /* i: output ambisonics format */ +int16_t convert_ambi_format( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ ) { @@ -261,12 +261,12 @@ int16_t convert_ambi_format( return 0; } -int16_t renormalize_channels( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ - AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ +int16_t renormalize_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ ) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); @@ -330,12 +330,12 @@ int16_t renormalize_channels( return 0; } -int16_t reorder_channels( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ - AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ +int16_t reorder_channels( + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ ) { int16_t n_chan = ( order + 1 ) * ( order + 1 ); diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 13d09cf56f..842283c1cd 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -64,26 +64,26 @@ typedef enum } AMBI_CHANNEL_ORDER; int16_t convert_ambi_format( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_FMT in_format, /* i: input ambisonics format */ - AMBI_FMT out_format /* i: output ambisonics format */ + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_FMT in_format, /* i: input ambisonics format */ + AMBI_FMT out_format /* i: output ambisonics format */ ); int16_t renormalize_channels( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ - AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_NORM in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ ); int16_t reorder_channels( - float *in[], /* i: input ambisonics channels */ - float *out[], /* o: output ambisonics channels */ - int16_t order, /* i: ambisonics order */ - AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ - AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ + float *in[], /* i: input ambisonics channels */ + float *out[], /* o: output ambisonics channels */ + int16_t order, /* i: ambisonics order */ + AMBI_CHANNEL_ORDER in_format, /* i: input ambisonics format */ + AMBI_CHANNEL_ORDER out_format /* i: output ambisonics format */ ); #endif -- GitLab From 3a3dd65eb18c70fe62b416dbf5682536d7283dbb Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 12:22:13 +0200 Subject: [PATCH 110/130] add more detailes functions descriptions --- lib_util/ambi_convert.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 91e686612d..961b48d2a3 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -117,6 +117,12 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, API functions for the conversion ---------------------------------- */ +/*-------------------------------------------------------------------------* +* convert_ambi_format() +* +* Convert signal between ACN-SN3D and other common ambisonics conventions +--------------------------------------------------------------------------*/ + int16_t convert_ambi_format( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ @@ -261,6 +267,12 @@ int16_t convert_ambi_format( return 0; } +/*-------------------------------------------------------------------------* +* renormalize_channels() +* +* Rescale audio channels according to the selected ambisonics convention +--------------------------------------------------------------------------*/ + int16_t renormalize_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ @@ -330,6 +342,12 @@ int16_t renormalize_channels( return 0; } +/*-------------------------------------------------------------------------* +* reorder_channels() +* +* Reorder channels according to the selected ambisonics convention +--------------------------------------------------------------------------*/ + int16_t reorder_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ -- GitLab From 9b774f294ca9501b66b444dcfcf8c66403c685d3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 13:08:39 +0200 Subject: [PATCH 111/130] implement error handling in convert_ambi_format --- apps/ambi_converter.c | 14 ++++++-- lib_util/ambi_convert.c | 71 ++++++++++++++++++++++++++++------------- lib_util/ambi_convert.h | 12 +++++-- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 4f44e1c00c..d7c981c214 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -79,7 +79,6 @@ int main( int argc, char *argv[] ) order = (int16_t) sqrtf( numChannels ) - 1; assert( order > 0 && order <= 3 ); - while ( ReadWavShort( wavFile_in, samples, numSamples, &numSamplesRead32 ) == __TWI_SUCCESS ) { int16_t err = 0; @@ -97,7 +96,12 @@ int main( int argc, char *argv[] ) } } - err = convert_ambi_format( in, out, order, in_format, out_format ); + if ( (err = convert_ambi_format( in, out, order, in_format, out_format )) != 0 ) + { + printf("Error converting the input signal!\n"); + return err; + } + for ( int16_t i = 0; i < numSamplesRead32; i++ ) { @@ -107,7 +111,11 @@ int main( int argc, char *argv[] ) } } - err = WriteWavShort( wavFile_out, samples, numSamplesRead32 ); + if ( (err = WriteWavShort( wavFile_out, samples, numSamplesRead32 )) != __TWO_SUCCESS ) + { + printf("Error writing output wave file!\n"); + return err; + } numSamplesRead32 = 0; } diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 961b48d2a3..b5cef0ef2e 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -123,7 +123,7 @@ static const int16_t REORDER_ACN_SID[AMBI_MAX_CHANNELS] = { 0, * Convert signal between ACN-SN3D and other common ambisonics conventions --------------------------------------------------------------------------*/ -int16_t convert_ambi_format( +AMBI_CONVERT_ERROR convert_ambi_format( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ @@ -134,6 +134,7 @@ int16_t convert_ambi_format( float tmp[AMBI_MAX_CHANNELS * L_FRAME48k]; float *p_tmp[AMBI_MAX_CHANNELS]; + AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK; AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN; AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN; @@ -180,7 +181,7 @@ int16_t convert_ambi_format( ch_norm_in = AMBI_NORM_N3D; break; default: - assert( 0 && "Unsupported in_format!" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } switch ( out_format ) @@ -210,40 +211,64 @@ int16_t convert_ambi_format( ch_norm_out = AMBI_NORM_N3D; break; default: - assert( 0 && "Unsupported out_format!" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } if ( in_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { if ( ch_ord_in != ch_ord_out ) { - renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ); - reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ); + if( (err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK ) + { + return err; + } + if( (err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK ) + { + return err; + } } else { - renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); + if (( err=renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) != AMBI_CONVERT_OK )) + { + return err; + } } } else if ( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); + if ((err=reorder_channels( in, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) + { + return err; + } } else if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { if ( ch_ord_in != ch_ord_out ) { - reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ); - renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ); + if (( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) + { + return err; + } + if (( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK) + { + return err; + } } else { - renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ); + if ( (err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK) + { + return err; + } } } else if ( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - reorder_channels( in, out, order, ch_ord_in, ch_ord_out ); + if ( (err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) + { + return err; + } } else if ( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D ) { @@ -264,7 +289,7 @@ int16_t convert_ambi_format( assert( 0 && "This should never happen!" ); } - return 0; + return AMBI_CONVERT_OK; } /*-------------------------------------------------------------------------* @@ -273,7 +298,7 @@ int16_t convert_ambi_format( * Rescale audio channels according to the selected ambisonics convention --------------------------------------------------------------------------*/ -int16_t renormalize_channels( +AMBI_CONVERT_ERROR renormalize_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ @@ -302,7 +327,7 @@ int16_t renormalize_channels( } else { - assert( 0 && "Unsupported conversion" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } } else if ( out_format == AMBI_NORM_SN3D ) @@ -321,12 +346,12 @@ int16_t renormalize_channels( } else { - assert( 0 && "Unsupported conversion" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } } else { - assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } @@ -339,7 +364,7 @@ int16_t renormalize_channels( } } - return 0; + return AMBI_CONVERT_OK; } /*-------------------------------------------------------------------------* @@ -348,7 +373,7 @@ int16_t renormalize_channels( * Reorder channels according to the selected ambisonics convention --------------------------------------------------------------------------*/ -int16_t reorder_channels( +AMBI_CONVERT_ERROR reorder_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ @@ -373,8 +398,8 @@ int16_t reorder_channels( } else { - assert( 0 && "Unsupported conversion" ); - } + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } } else if ( out_format == AMBI_CHANNEL_ORDER_ACN ) { @@ -388,12 +413,12 @@ int16_t reorder_channels( } else { - assert( 0 && "Unsupported conversion" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } } else { - assert( 0 && "Conversion only supported to and from ACN-SN3D" ); + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } for ( i = 0; i < L_FRAME48k; i++ ) @@ -409,5 +434,5 @@ int16_t reorder_channels( } } - return 0; + return AMBI_CONVERT_OK; } diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 842283c1cd..13acbb7d33 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -63,7 +63,13 @@ typedef enum AMBI_CHANNEL_ORDER_SID } AMBI_CHANNEL_ORDER; -int16_t convert_ambi_format( +typedef enum +{ + AMBI_CONVERT_OK = 0, + AMBI_CONVERT_UNSUPPORTED_CONVERSION +} AMBI_CONVERT_ERROR; + +AMBI_CONVERT_ERROR convert_ambi_format( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ @@ -71,7 +77,7 @@ int16_t convert_ambi_format( AMBI_FMT out_format /* i: output ambisonics format */ ); -int16_t renormalize_channels( +AMBI_CONVERT_ERROR renormalize_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ @@ -79,7 +85,7 @@ int16_t renormalize_channels( AMBI_CHANNEL_NORM out_format /* i: output ambisonics format */ ); -int16_t reorder_channels( +AMBI_CONVERT_ERROR reorder_channels( float *in[], /* i: input ambisonics channels */ float *out[], /* o: output ambisonics channels */ int16_t order, /* i: ambisonics order */ -- GitLab From c6a905b02a7d4c85f25259e4846df5c9aac0738d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 13:09:48 +0200 Subject: [PATCH 112/130] fix formatting --- apps/ambi_converter.c | 8 ++--- lib_util/ambi_convert.c | 72 ++++++++++++++++++++--------------------- lib_util/ambi_convert.h | 4 +-- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index d7c981c214..60e8848261 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -96,9 +96,9 @@ int main( int argc, char *argv[] ) } } - if ( (err = convert_ambi_format( in, out, order, in_format, out_format )) != 0 ) + if ( ( err = convert_ambi_format( in, out, order, in_format, out_format ) ) != 0 ) { - printf("Error converting the input signal!\n"); + printf( "Error converting the input signal!\n" ); return err; } @@ -111,9 +111,9 @@ int main( int argc, char *argv[] ) } } - if ( (err = WriteWavShort( wavFile_out, samples, numSamplesRead32 )) != __TWO_SUCCESS ) + if ( ( err = WriteWavShort( wavFile_out, samples, numSamplesRead32 ) ) != __TWO_SUCCESS ) { - printf("Error writing output wave file!\n"); + printf( "Error writing output wave file!\n" ); return err; } diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index b5cef0ef2e..dfddd82bf3 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -134,7 +134,7 @@ AMBI_CONVERT_ERROR convert_ambi_format( float tmp[AMBI_MAX_CHANNELS * L_FRAME48k]; float *p_tmp[AMBI_MAX_CHANNELS]; - AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK; + AMBI_CONVERT_ERROR err = AMBI_CONVERT_OK; AMBI_CHANNEL_ORDER ch_ord_in = AMBI_CHANNEL_ORDER_ACN; AMBI_CHANNEL_ORDER ch_ord_out = AMBI_CHANNEL_ORDER_ACN; @@ -218,57 +218,57 @@ AMBI_CONVERT_ERROR convert_ambi_format( { if ( ch_ord_in != ch_ord_out ) { - if( (err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK ) - { - return err; - } - if( (err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK ) - { - return err; - } + if ( ( err = renormalize_channels( in, p_tmp, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + if ( ( err = reorder_channels( p_tmp, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } } else { - if (( err=renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) != AMBI_CONVERT_OK )) - { - return err; - } + if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) != AMBI_CONVERT_OK ) ) + { + return err; + } } } else if ( in_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - if ((err=reorder_channels( in, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) - { - return err; - } + if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } } else if ( out_format == AMBI_FMT_ACN_SN3D && ch_norm_in != ch_norm_out ) { if ( ch_ord_in != ch_ord_out ) { - if (( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) - { - return err; - } - if (( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK) - { - return err; - } + if ( ( err = reorder_channels( in, p_tmp, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } + if ( ( err = renormalize_channels( p_tmp, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } } else { - if ( (err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out )) != AMBI_CONVERT_OK) - { - return err; - } + if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } } } else if ( out_format == AMBI_FMT_ACN_SN3D && ch_ord_in != ch_ord_out ) { - if ( (err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out )) != AMBI_CONVERT_OK) - { - return err; - } + if ( ( err = reorder_channels( in, out, order, ch_ord_in, ch_ord_out ) ) != AMBI_CONVERT_OK ) + { + return err; + } } else if ( out_format == AMBI_FMT_ACN_SN3D && in_format == AMBI_FMT_ACN_SN3D ) { @@ -327,7 +327,7 @@ AMBI_CONVERT_ERROR renormalize_channels( } else { - return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; } } else if ( out_format == AMBI_NORM_SN3D ) @@ -398,8 +398,8 @@ AMBI_CONVERT_ERROR reorder_channels( } else { - return AMBI_CONVERT_UNSUPPORTED_CONVERSION; - } + return AMBI_CONVERT_UNSUPPORTED_CONVERSION; + } } else if ( out_format == AMBI_CHANNEL_ORDER_ACN ) { diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index 13acbb7d33..7b3093c5d3 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -65,8 +65,8 @@ typedef enum typedef enum { - AMBI_CONVERT_OK = 0, - AMBI_CONVERT_UNSUPPORTED_CONVERSION + AMBI_CONVERT_OK = 0, + AMBI_CONVERT_UNSUPPORTED_CONVERSION } AMBI_CONVERT_ERROR; AMBI_CONVERT_ERROR convert_ambi_format( -- GitLab From d116e642f280df93c9867fad7589b5937dc5bb41 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 13:18:29 +0200 Subject: [PATCH 113/130] fix compiler warning --- lib_util/ambi_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index dfddd82bf3..92711b8e61 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -229,7 +229,7 @@ AMBI_CONVERT_ERROR convert_ambi_format( } else { - if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) != AMBI_CONVERT_OK ) ) + if ( ( err = renormalize_channels( in, out, order, ch_norm_in, ch_norm_out ) ) != AMBI_CONVERT_OK ) { return err; } -- GitLab From e0f504dd165e500f1e562dfbd34acb488a96159a Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 13:28:54 +0200 Subject: [PATCH 114/130] check if wave files have been opened sucessfully in the converter program --- apps/ambi_converter.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/ambi_converter.c b/apps/ambi_converter.c index 60e8848261..d4210932c7 100644 --- a/apps/ambi_converter.c +++ b/apps/ambi_converter.c @@ -74,7 +74,18 @@ int main( int argc, char *argv[] ) printf( "In %d, Out: %d\n", in_format, out_format ); wavFile_in = OpenWav( fileName_in, &samplingRate, &numChannels, &samplesInFile, &bps ); + if ( !wavFile_in ) + { + fprintf( stderr, "Failed to open input wav file: %s\n", fileName_in ); + return -1; + } + wavFile_out = CreateWav( fileName_out, samplingRate, numChannels, 16 ); + if ( !wavFile_out ) + { + fprintf( stderr, "Failed to open output wav file: %s\n", fileName_out ); + return -1; + } order = (int16_t) sqrtf( numChannels ) - 1; assert( order > 0 && order <= 3 ); -- GitLab From 4b9756740f946a33655679fb311297b76d5bf967 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 13:38:55 +0200 Subject: [PATCH 115/130] move apps/ambi_converter.c -> scripts/ambi_converter.c --- {apps => scripts}/ambi_converter.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {apps => scripts}/ambi_converter.c (100%) diff --git a/apps/ambi_converter.c b/scripts/ambi_converter.c similarity index 100% rename from apps/ambi_converter.c rename to scripts/ambi_converter.c -- GitLab From 461a221a97dcff4a2e2f37c54f3c730691a9800e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 3 Jul 2024 14:11:06 +0200 Subject: [PATCH 116/130] Add fix which may be needed for using matplotlib on computer without DISPLAY --- scripts/create_histogram_summary.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 61cec7eef2..3bfdd207df 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -3,6 +3,8 @@ import argparse import math import numpy as np +import matplotlib # These steps are added as a precaution in case the gitlab runner +matplotlib.use('Agg') # needs DISPLAY to render the plots, even if they are written to file. import matplotlib.pyplot as plt import csv from parse_xml_report import FORMATS, CATEGORIES -- GitLab From d3fcd8eb389b3f24c2afb292ba5f469615d0bc09 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 14:38:45 +0200 Subject: [PATCH 117/130] add description to ambisonics converter program --- scripts/ambi_converter.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/ambi_converter.c b/scripts/ambi_converter.c index d4210932c7..eb02467ac6 100644 --- a/scripts/ambi_converter.c +++ b/scripts/ambi_converter.c @@ -36,6 +36,11 @@ #include "tinywaveout_c.h" #include "ambi_convert.h" +/*-------------------------------------------------------------------------------------* +* Ambisonics converter program +* +* gcc ambi_converter.c ../lib_util/ambi_convert.c -I../lib_util/ -lm -o ambi_converter +*--------------------------------------------------------------------------------------*/ int main( int argc, char *argv[] ) { @@ -66,6 +71,26 @@ int main( int argc, char *argv[] ) out[j] = &samples_f_out[j * L_FRAME48k]; } + if( argc != 5 ) + { + printf("Ambisonics converter program\n"); + printf("----------------------------------------------------------------------------------\n"); + printf("Usage:\n"); + printf("./ambi_conveter input_file output_file input_convention output_convention\n"); + printf("\n"); + printf("input_convention and output convention must be an integer number in [0,5]\n"); + printf("the following conventions are supported:\n"); + printf("0 : ACN-SN3D\n"); + printf("1 : ACN-N3D\n"); + printf("2 : FuMa-MaxN\n"); + printf("3 : FuMa-FuMa\n"); + printf("4 : SID-SN3D\n"); + printf("5 : SID-N3D\n"); + printf("\n"); + printf("Either the input or the output convention must always be ACN-SN3D!\n"); + return -1; + } + fileName_in = argv[1]; fileName_out = argv[2]; in_format = atoi( argv[3] ); -- GitLab From d4307584378af123f4c6b404180754558fce9019 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 14:39:25 +0200 Subject: [PATCH 118/130] fix formatting --- scripts/ambi_converter.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/ambi_converter.c b/scripts/ambi_converter.c index eb02467ac6..9bb6d06f2b 100644 --- a/scripts/ambi_converter.c +++ b/scripts/ambi_converter.c @@ -37,10 +37,10 @@ #include "ambi_convert.h" /*-------------------------------------------------------------------------------------* -* Ambisonics converter program -* -* gcc ambi_converter.c ../lib_util/ambi_convert.c -I../lib_util/ -lm -o ambi_converter -*--------------------------------------------------------------------------------------*/ + * Ambisonics converter program + * + * gcc ambi_converter.c ../lib_util/ambi_convert.c -I../lib_util/ -lm -o ambi_converter + *--------------------------------------------------------------------------------------*/ int main( int argc, char *argv[] ) { @@ -71,23 +71,23 @@ int main( int argc, char *argv[] ) out[j] = &samples_f_out[j * L_FRAME48k]; } - if( argc != 5 ) + if ( argc != 5 ) { - printf("Ambisonics converter program\n"); - printf("----------------------------------------------------------------------------------\n"); - printf("Usage:\n"); - printf("./ambi_conveter input_file output_file input_convention output_convention\n"); - printf("\n"); - printf("input_convention and output convention must be an integer number in [0,5]\n"); - printf("the following conventions are supported:\n"); - printf("0 : ACN-SN3D\n"); - printf("1 : ACN-N3D\n"); - printf("2 : FuMa-MaxN\n"); - printf("3 : FuMa-FuMa\n"); - printf("4 : SID-SN3D\n"); - printf("5 : SID-N3D\n"); - printf("\n"); - printf("Either the input or the output convention must always be ACN-SN3D!\n"); + printf( "Ambisonics converter program\n" ); + printf( "----------------------------------------------------------------------------------\n" ); + printf( "Usage:\n" ); + printf( "./ambi_conveter input_file output_file input_convention output_convention\n" ); + printf( "\n" ); + printf( "input_convention and output convention must be an integer number in [0,5]\n" ); + printf( "the following conventions are supported:\n" ); + printf( "0 : ACN-SN3D\n" ); + printf( "1 : ACN-N3D\n" ); + printf( "2 : FuMa-MaxN\n" ); + printf( "3 : FuMa-FuMa\n" ); + printf( "4 : SID-SN3D\n" ); + printf( "5 : SID-N3D\n" ); + printf( "\n" ); + printf( "Either the input or the output convention must always be ACN-SN3D!\n" ); return -1; } -- GitLab From 2e98f7fd15cccb6e77638af8e0e08eebc4965c47 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 3 Jul 2024 15:11:06 +0200 Subject: [PATCH 119/130] Fix in create_report_pages.py for added columns -- to be verified --- ci/basop-pages/create_report_pages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index c849b160be..58d0e1ecef 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -92,9 +92,9 @@ ARROW_DOWN = '' # expected columns. actual columns are filtered from the incoming data later, this # is mainly for controlling the order in the output table -COLUMNS = ["testcase", "Result", "MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] +COLUMNS = ["testcase", "Format", "Category", "Result", "MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] COLUMNS_GLOBAL = COLUMNS[:1] -COLUMNS_DIFFERENTIAL = COLUMNS[1:] +COLUMNS_DIFFERENTIAL = COLUMNS[3:] COLUMNS_DIFFERENTIAL_NOT_MLD = COLUMNS_DIFFERENTIAL[2:] -- GitLab From 10c395a94bced4eefb4ea6c6c37c6370e5c18f9d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 3 Jul 2024 15:52:09 +0200 Subject: [PATCH 120/130] Fix for empty cells in csv report and optional argument for histogram png --- ci/basop-pages/create_report_pages.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 58d0e1ecef..5fda318b33 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -34,6 +34,8 @@ Comparing:
  • Merged csv data
  • + +
    How is the table sorted?
      @@ -106,6 +108,7 @@ def create_subpage( id_current: int, id_previous: int, job_name: str, + histogram: str, ): merged_reports = merge_and_cleanup_mld_reports( csv_current, csv_previous, id_current, id_previous @@ -135,6 +138,7 @@ def create_subpage( job_name=job_name, table_header_a=table_header_a, table_header_b=table_header_b, + histogram=histogram ) with open(html_out, "w") as f: f.write(new_subpage) @@ -242,7 +246,8 @@ def merge_and_cleanup_mld_reports( for col_pair in other_col_pairs: col_prev = col_pair[0] col_curr = col_pair[1] - diff_other += abs(float(x[col_curr]) - float(x[col_prev])) + if x[col_curr] != '' and x[col_prev] != '': + diff_other += abs(float(x[col_curr]) - float(x[col_prev])) if diff_other > 0: diff = -1000000 @@ -293,8 +298,14 @@ if __name__ == "__main__": parser.add_argument("id_current", type=int) parser.add_argument("id_previous", type=int) parser.add_argument("job_name") + parser.add_argument("--histogram", type=str, nargs=1, help="histogram picture", default = None) args = parser.parse_args() + if args.histogram != None: + histogram = args.histogram[0] + else: + histogram = "None" + create_subpage( args.html_out, args.csv_out, @@ -303,4 +314,5 @@ if __name__ == "__main__": args.id_current, args.id_previous, args.job_name, + histogram, ) -- GitLab From c4ffb1befadb4c8ec5a96b3b1ade6ca7f8d80755 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 3 Jul 2024 16:59:15 +0200 Subject: [PATCH 121/130] Separate images per format --- ci/basop-pages/create_report_pages.py | 16 +++++++--------- scripts/create_histogram_summary.py | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 5fda318b33..40f0832e21 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -34,7 +34,7 @@ Comparing:
    • Merged csv data
    - +{images}
    How is the table sorted? @@ -108,7 +108,7 @@ def create_subpage( id_current: int, id_previous: int, job_name: str, - histogram: str, + histogram, ): merged_reports = merge_and_cleanup_mld_reports( csv_current, csv_previous, id_current, id_previous @@ -131,6 +131,7 @@ def create_subpage( table_body = "\n".join( tr_from_row(row, id_current, id_previous) for row in merged_reports ) + images = " ".join([f"" for x in histogram]) new_subpage = SUBPAGE_TMPL_CSS + SUBPAGE_TMPL_HTML.format( id_current=id_current, id_previous=id_previous, @@ -138,7 +139,7 @@ def create_subpage( job_name=job_name, table_header_a=table_header_a, table_header_b=table_header_b, - histogram=histogram + images=images ) with open(html_out, "w") as f: f.write(new_subpage) @@ -298,13 +299,10 @@ if __name__ == "__main__": parser.add_argument("id_current", type=int) parser.add_argument("id_previous", type=int) parser.add_argument("job_name") - parser.add_argument("--histogram", type=str, nargs=1, help="histogram picture", default = None) + parser.add_argument("--histogram", type=str, nargs='+', help="histogram picture(s)", default = []) args = parser.parse_args() - if args.histogram != None: - histogram = args.histogram[0] - else: - histogram = "None" + create_subpage( args.html_out, @@ -314,5 +312,5 @@ if __name__ == "__main__": args.id_current, args.id_previous, args.job_name, - histogram, + args.histogram, ) diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index 3bfdd207df..caabd4b3c7 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -7,6 +7,7 @@ import matplotlib # These steps are added as a precaution in case the gitlab matplotlib.use('Agg') # needs DISPLAY to render the plots, even if they are written to file. import matplotlib.pyplot as plt import csv +import os from parse_xml_report import FORMATS, CATEGORIES """ @@ -72,12 +73,9 @@ if __name__ == "__main__": headerline = f"Format;Category;" + ";".join(limits_labels) + "\n" fp.write(headerline) - subplot = 0 - fig, ax = plt.subplots(len(FORMATS)//4, 4) for fmt in FORMATS: + fig, ax = plt.subplots() bottom = np.zeros(len(limits_labels)) - row = subplot // 4 - col = subplot % 4 for cat in CATEGORIES: values = [x for x in [m[measure_label] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF @@ -97,17 +95,17 @@ if __name__ == "__main__": fp.write(line) # Matplotlib histogram - ax[row][col].bar(limits_labels, data, 0.5, label=cat, bottom=bottom) + ax.bar(limits_labels, data, 0.5, label=cat, bottom=bottom) bottom += data # Histogram layout - ax[row][col].set_title(fmt) - ax[row][col].legend(loc="best") - ax[row][col].set_xlabel(measure_label) - ax[row][col].set_ylabel("Number of test cases") - subplot += 1 + ax.set_title(fmt) + ax.legend(loc="best") + ax.set_xlabel(measure_label) + ax.set_ylabel("Number of test cases") - fig.set_figheight(16) - fig.set_figwidth(32) - if csv_image: - plt.savefig(csv_image) + fig.set_figheight(4) + fig.set_figwidth(6) + if csv_image: + base, ext = os.path.splitext(csv_image) + plt.savefig(f"{base}_{fmt}{ext}") -- GitLab From b86613774f9182940ba565b0c345917663c04a12 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 17:28:22 +0200 Subject: [PATCH 122/130] implement clipping detection in the ambisonics converter program --- scripts/ambi_converter.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/ambi_converter.c b/scripts/ambi_converter.c index 9bb6d06f2b..67ba451970 100644 --- a/scripts/ambi_converter.c +++ b/scripts/ambi_converter.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "tinywavein_c.h" #include "tinywaveout_c.h" #include "ambi_convert.h" @@ -53,6 +54,7 @@ int main( int argc, char *argv[] ) uint32_t samplesInFile; uint32_t numSamples = L_FRAME48k; uint32_t numSamplesRead32 = 0; + uint32_t numSamplesClipped = 0; int16_t bps; int16_t samples[L_FRAME48k * AMBI_MAX_CHANNELS]; @@ -143,7 +145,23 @@ int main( int argc, char *argv[] ) { for ( int16_t j = 0; j < numChannels; j++ ) { - samples[i * numChannels + j] = (int16_t) out[j][i]; + int s1_i; + float s1 = out[j][i]; + if ( s1 < INT16_MIN ) + { + s1_i = INT16_MIN; + numSamplesClipped++; + } + else if ( s1 > INT16_MAX ) + { + s1_i = INT16_MAX; + numSamplesClipped++; + } + else + { + s1_i = (int16_t) s1; + } + samples[i * numChannels + j] = s1_i; } } -- GitLab From ecbfde338890595ed227c203c74b7d13873fbf62 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Wed, 3 Jul 2024 17:30:38 +0200 Subject: [PATCH 123/130] print clipping warning --- scripts/ambi_converter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/ambi_converter.c b/scripts/ambi_converter.c index 67ba451970..087e90a3fd 100644 --- a/scripts/ambi_converter.c +++ b/scripts/ambi_converter.c @@ -177,5 +177,10 @@ int main( int argc, char *argv[] ) CloseWav( wavFile_out ); CloseWavIn( wavFile_in ); + if ( numSamplesClipped ) + { + printf( "Warning: %d samples have clipped!\n", numSamplesClipped ); + } + return 0; } -- GitLab From 2d7f4c0b7f246547f8fef4c96d46c9a70a32b8c1 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 4 Jul 2024 12:50:14 +0200 Subject: [PATCH 124/130] Add images in separate subfolder images --- ci/basop-pages/create_report_pages.py | 26 +++++++++++++++++++++----- scripts/create_histogram_summary.py | 2 +- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 40f0832e21..830032c6f2 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -3,6 +3,7 @@ import pathlib import argparse from functools import partial +FORMATS = ['Stereo', 'ISM', 'Multichannel','MASA','SBA', 'OSBA', 'OMASA', 'Renderer'] CSV_DELIM = ";" SUBPAGE_TMPL_CSS = """ @@ -25,7 +26,7 @@ SUBPAGE_TMPL_CSS = """ SUBPAGE_TMPL_HTML = """ -

    Report for job {job_name}

    Report for job {job_name} Comparing: -{images} +{images_mld} + +{images_diff} + +{images_ssnr} +
    How is the table sorted? @@ -131,7 +137,15 @@ def create_subpage( table_body = "\n".join( tr_from_row(row, id_current, id_previous) for row in merged_reports ) - images = " ".join([f"" for x in histogram]) + if histogram: + images_mld = f"

    MLD summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + images_ssnr = f"

    MIN_SSNR summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + images_diff = f"

    MAX ABS DIFFERENCE summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + else: + images_mld = "" + images_ssnr = "" + images_diff = "" + new_subpage = SUBPAGE_TMPL_CSS + SUBPAGE_TMPL_HTML.format( id_current=id_current, id_previous=id_previous, @@ -139,7 +153,9 @@ def create_subpage( job_name=job_name, table_header_a=table_header_a, table_header_b=table_header_b, - images=images + images_mld=images_mld, + images_ssnr=images_ssnr, + images_diff=images_diff, ) with open(html_out, "w") as f: f.write(new_subpage) @@ -299,7 +315,7 @@ if __name__ == "__main__": parser.add_argument("id_current", type=int) parser.add_argument("id_previous", type=int) parser.add_argument("job_name") - parser.add_argument("--histogram", type=str, nargs='+', help="histogram picture(s)", default = []) + parser.add_argument("--histogram", action='store_true') args = parser.parse_args() diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index caabd4b3c7..eab71dacf8 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -66,7 +66,7 @@ if __name__ == "__main__": # Output CSV file with open(csv_summary, "w") as fp: - limits_labels = [f"{str(a)} -- {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + limits_labels = [f"{str(a)} --\n {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": limits_labels = ["0"] + limits_labels -- GitLab From 57cb11bb93d826cc8285025e8b3a20867f641308 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 4 Jul 2024 12:58:21 +0200 Subject: [PATCH 125/130] Fix for empty cells in report --- ci/basop-pages/create_report_pages.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 830032c6f2..4177930597 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -247,8 +247,9 @@ def merge_and_cleanup_mld_reports( are uninteresting and are put last. """ try: - float(x[mld_col_curr]) - float(x[mld_col_prev]) + cols = [mld_col_curr, mld_col_prev] + [p[1] for p in other_col_pairs] + for c in cols: + float(x[c]) except ValueError: # Value is no valid floating point value return float("inf") @@ -263,8 +264,7 @@ def merge_and_cleanup_mld_reports( for col_pair in other_col_pairs: col_prev = col_pair[0] col_curr = col_pair[1] - if x[col_curr] != '' and x[col_prev] != '': - diff_other += abs(float(x[col_curr]) - float(x[col_prev])) + diff_other += abs(float(x[col_curr]) - float(x[col_prev])) if diff_other > 0: diff = -1000000 -- GitLab From 60ee3d8d675448850e9ddbb4460bd1df6ad47b6c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Jul 2024 13:26:04 +0200 Subject: [PATCH 126/130] accept FIX_1121_MASA_DESCRIPTOR and FIX_1053_AEID_FILE_TEST --- lib_com/ivas_rom_com.c | 2 -- lib_com/ivas_rom_com.h | 2 -- lib_com/options.h | 2 -- lib_dec/ivas_masa_dec.c | 3 --- lib_dec/lib_dec.c | 2 -- lib_rend/ivas_mcmasa_ana.c | 3 --- lib_util/masa_file_reader.c | 5 ----- 7 files changed, 19 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 2c4ab2f661..744fdf25b0 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -2471,13 +2471,11 @@ const uint16_t ivas_param_mc_sym_freq_ild_delta_combined_48_16bits[2 * PARAM_MC_ * MASA ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_1121_MASA_DESCRIPTOR const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 /* "IVASMASA" */ }; -#endif const float diffuseness_reconstructions_hr[HR_MASA_ER_LEVELS] = { 0.00f, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 18f2062d7f..774aef466a 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -264,10 +264,8 @@ extern const uint16_t ivas_param_mc_sym_freq_icc_delta_combined_48_16bits[2 * PA * MASA ROM tables *----------------------------------------------------------------------------------*/ -#ifdef FIX_1121_MASA_DESCRIPTOR extern const uint8_t ivasmasaFormatDescriptor[8]; /* "IVASMASA" */ -#endif extern const int16_t bits_direction_masa[DIRAC_DIFFUSE_LEVELS]; extern const int16_t no_theta_masa[NO_SPHERICAL_GRIDS - 2]; extern const int16_t no_phi_masa[NO_SPHERICAL_GRIDS][MAX_NO_THETA]; diff --git a/lib_com/options.h b/lib_com/options.h index e490d7750e..98bb3e48e0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,8 +162,6 @@ //#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT /* Orange issue 1031 : new fix point hrtf binary file format */ //#define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ #define FLOAT_FIX_POINT_HRTF_FILE_FORMAT /* allows reading floation or fix point hrtf binary file format */ -#define FIX_1053_AEID_FILE_TEST /* Philips: Tests for the -aeid file and fix for memory error */ -#define FIX_1121_MASA_DESCRIPTOR /* VA: issue 1121: Define 'ivasmasaFormatDescriptor' at one common place */ #define FIX_1113_CLDFB_REND_IN_ISAR /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */ #define ADJUST_MCT_CHANNELS_MAX /* FhG: set correct max mct channels constant*/ #define FIX_745_FIX_DATA_TYPE_CONVERSION /* VA: issue 745: implicit data type conversion when calling IVAS_DEC_Configure() */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 121cb3df43..50cd432dea 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -1835,9 +1835,6 @@ static void create_masa_ext_out_meta( IVAS_QMETADATA_HANDLE hQMetaData, const int16_t nchan_transport ) { -#ifndef FIX_1121_MASA_DESCRIPTOR - const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ -#endif int16_t i, sf, b_old, b_new, dir; MASA_DECRIPTIVE_META *descMeta; int16_t *bandMap; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 88dc02d3ed..7cca9fc39b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -2133,9 +2133,7 @@ static ivas_error copyRendererConfigStruct( mvr2r( hRCin->roomAcoustics.pAcoustic_rt60, hRCout->roomAcoustics.pAcoustic_rt60, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->roomAcoustics.pAcoustic_dsr, hRCout->roomAcoustics.pAcoustic_dsr, CLDFB_NO_CHANNELS_MAX ); mvr2r( hRCin->directivity, hRCout->directivity, 3 * MAX_NUM_OBJECTS ); -#ifdef FIX_1053_AEID_FILE_TEST mvr2r( hRCin->distAtt, hRCout->distAtt, 3 ); -#endif hRCout->split_rend_config = hRCin->split_rend_config; diff --git a/lib_rend/ivas_mcmasa_ana.c b/lib_rend/ivas_mcmasa_ana.c index 49e7d00eec..0449159a2f 100644 --- a/lib_rend/ivas_mcmasa_ana.c +++ b/lib_rend/ivas_mcmasa_ana.c @@ -1069,9 +1069,6 @@ void ivas_create_masa_out_meta( float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : Estimated surround coherence */ ) { -#ifndef FIX_1121_MASA_DESCRIPTOR - const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ -#endif int16_t i, sf, band; uint8_t numFrequencyBands; uint8_t numDirections; diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index bc75b0bdbd..56f22d3fed 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -33,9 +33,7 @@ #include "masa_file_reader.h" #include "ivas_prot.h" #include "ivas_stat_com.h" -#ifdef FIX_1121_MASA_DESCRIPTOR #include "ivas_rom_com.h" /* load 'ivasmasaFormatDescriptor[8]' */ -#endif #include #include @@ -114,9 +112,6 @@ ivas_error MasaFileReader_readNextFrame( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifndef FIX_1121_MASA_DESCRIPTOR - const uint8_t ivasmasaFormatDescriptor[8] = { 0x49, 0x56, 0x41, 0x53, 0x4D, 0x41, 0x53, 0x41 }; /* "IVASMASA" */ -#endif uint16_t twoByteBuffer = 0; int16_t i, j, b; IVAS_MASA_METADATA_HANDLE hMeta; -- GitLab From a7381d5d51d2282c6e005ec8a9b1f39adc63c28d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Jul 2024 13:28:14 +0200 Subject: [PATCH 127/130] accept ADJUST_MCT_CHANNELS_MAX and FIX_1113_CLDFB_REND_IN_ISAR --- lib_com/ivas_cnst.h | 6 ------ lib_com/options.h | 2 -- lib_dec/ivas_binRenderer_internal.c | 4 ---- lib_dec/ivas_mct_core_dec.c | 20 -------------------- lib_enc/ivas_mct_core_enc.c | 4 ---- 5 files changed, 36 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 90cfa67775..c31fa83049 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1289,14 +1289,8 @@ typedef enum #define LFE_CHANNEL 3 #define MIN_LFE_NRG 0.5f -#ifdef ADJUST_MCT_CHANNELS_MAX #define MCT_MAX_CHANNELS 11 /* == 7.1.4 LS channels without the LFE channel */ #define MCT_MAX_BLOCKS ( ( MCT_MAX_CHANNELS + 1 ) / CPE_CHANNELS ) /* max. number of channel pairs (MCT_MAX_CHANNELS/2) within MCT*/ -#else -#define MCT_MAX_CHANNELS 12 -#define MCT_MAX_BLOCKS ( MCT_MAX_CHANNELS / CPE_CHANNELS ) /* max. number of channel pairs (MCT_MAX_CHANNELS/2) within MCT*/ -#define MAX_NUM_DATA max( MCT_MAX_CHANNELS, 4 ) -#endif #define NBBITS_MCT_RATIO 4 #define BITRATE_MCT_RATIO_RANGE ( 1 << NBBITS_MCT_RATIO ) /* Range of the coded bitrate distribution ratio */ diff --git a/lib_com/options.h b/lib_com/options.h index 98bb3e48e0..938ad2e9fe 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,8 +162,6 @@ //#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT /* Orange issue 1031 : new fix point hrtf binary file format */ //#define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ #define FLOAT_FIX_POINT_HRTF_FILE_FORMAT /* allows reading floation or fix point hrtf binary file format */ -#define FIX_1113_CLDFB_REND_IN_ISAR /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */ -#define ADJUST_MCT_CHANNELS_MAX /* FhG: set correct max mct channels constant*/ #define FIX_745_FIX_DATA_TYPE_CONVERSION /* VA: issue 745: implicit data type conversion when calling IVAS_DEC_Configure() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index 1ed443d618..f4e3e39fdd 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1014,11 +1014,7 @@ ivas_error ivas_rend_openCldfbRend( return error; } -#ifdef FIX_1113_CLDFB_REND_IN_ISAR pCldfbRend->binaural_latency_ns = (int32_t) ( pCldfbRend->hHrtfFastConv->FASTCONV_HOA3_latency_s * 1000000000.f ); -#else - pCldfbRend->binaural_latency_ns = (int32_t) ( FASTCONV_HOA3_latency_s * 1000000000.f ); -#endif hBinRenderer->hReverb = NULL; hBinRenderer->hEFAPdata = NULL; diff --git a/lib_dec/ivas_mct_core_dec.c b/lib_dec/ivas_mct_core_dec.c index 909d08058e..6774b473db 100644 --- a/lib_dec/ivas_mct_core_dec.c +++ b/lib_dec/ivas_mct_core_dec.c @@ -77,15 +77,11 @@ void ivas_mct_side_bits( { for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef ADJUST_MCT_CHANNELS_MAX if ( i < MCT_MAX_CHANNELS ) { -#endif sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; i++; -#ifdef ADJUST_MCT_CHANNELS_MAX } -#endif } } @@ -201,30 +197,14 @@ void ivas_mct_core_dec( { for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef ADJUST_MCT_CHANNELS_MAX if ( i < MCT_MAX_CHANNELS ) { -#endif sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; i++; -#ifdef ADJUST_MCT_CHANNELS_MAX } -#endif - } - } - -#ifndef ADJUST_MCT_CHANNELS_MAX - /*seems like obsolete code*/ - for ( ch = 0, i = 0; ch < nChannels; ch++ ) - { - if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) - { - continue; } - i++; } -#endif bfi = sts[0]->bfi; for ( ch = 0; ch < nChannels; ch++ ) diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index fa25c6cece..9df01a9459 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -265,14 +265,10 @@ void ivas_mct_core_enc( { for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { -#ifdef ADJUST_MCT_CHANNELS_MAX if ( cpe_id * CPE_CHANNELS + ch < nChannels ) { -#endif sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; -#ifdef ADJUST_MCT_CHANNELS_MAX } -#endif if ( hCPE[cpe_id]->hCoreCoder[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { -- GitLab From b6b18432e8216f92520c67286992f518467703fd Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Jul 2024 13:32:01 +0200 Subject: [PATCH 128/130] accept NONBE_FIX_1052_SBA_EXT_FIX and NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER --- lib_com/ivas_prot.h | 4 --- lib_com/options.h | 2 -- lib_dec/ivas_init_dec.c | 64 ------------------------------------ lib_dec/ivas_output_config.c | 8 ----- lib_dec/ivas_spar_decoder.c | 12 ------- lib_enc/ivas_cpe_enc.c | 12 ------- lib_enc/ivas_init_enc.c | 12 ++----- lib_enc/ivas_ism_enc.c | 4 --- lib_enc/ivas_sce_enc.c | 12 ------- 9 files changed, 3 insertions(+), 127 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 68c08c1312..3e9c15a2a5 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -84,13 +84,9 @@ void ivas_write_format( void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ -#ifdef NONBE_FIX_1052_SBA_EXT_FIX BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const int16_t sba_order, /* i : Ambisonic (SBA) order */ const int16_t sba_planar /* i : SBA planar flag */ -#else - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -#endif ); ivas_error create_sce_enc( diff --git a/lib_com/options.h b/lib_com/options.h index 938ad2e9fe..6b1a8d303a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,8 +172,6 @@ #define NONBE_MDCT_ST_DTX_SKIP_DEWHITENING_OF_NOISE_SHAPES_ON_SID_FRAMES /* FhG: issue 1133: skip de-whitening of bg noise shape after frameloss period if the first good frame is an SID */ #define NONBE_MDCT_ST_PLC_DO_NOT_SCALE_OLD_OUT_IF_FIRST_GOOD_IS_SID /* FhG: issue 1133: in TCX PLC, don't scale hHQ_core->old_out after applying fade to noise in burst frame error */ -#define NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /* FhG: issue 1128: set output ambisonics order to input order for EXT output */ -#define NONBE_FIX_1052_SBA_EXT_FIX /* VA: SBA external output support fix - do not overwrite "output_config" parameter */ #define NONBE_FIX_1130_DIV_ZERO_LEV_DUR /* VA: issue 1130: avoid div by zero in L-D by thresholding R[0] to a min value of 100.0 */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 839894d1e3..907f5619ab 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -55,7 +55,6 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, int16_t *num_bits_r static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER /*-------------------------------------------------------------------* * ivas_set_audio_config_from_sba_order() * @@ -66,12 +65,6 @@ static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); static AUDIO_CONFIG ivas_set_audio_config_from_sba_order( const int16_t sba_order /* i : Ambisonic (SBA) order */ ) -#else -static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ); - - -static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_order ) -#endif { AUDIO_CONFIG output_config; @@ -89,12 +82,8 @@ static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const int16_t sba_ord output_config = IVAS_AUDIO_CONFIG_HOA3; break; default: -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER output_config = IVAS_AUDIO_CONFIG_INVALID; break; -#else - assert( 0 ); -#endif } return output_config; @@ -179,17 +168,6 @@ ivas_error ivas_dec_setup( /* read Ambisonic (SBA) order */ st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1]; st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read]; -#ifndef NONBE_FIX_1052_SBA_EXT_FIX - if ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - st_ivas->hDecoderConfig->output_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); -#else - st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); -#endif - st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); - } -#endif num_bits_read += SBA_ORDER_BITS; if ( st_ivas->ini_frame > 0 && ivas_total_brate != st_ivas->last_active_ivas_total_brate && ivas_total_brate > IVAS_SID_5k2 ) @@ -429,18 +407,6 @@ ivas_error ivas_dec_setup( break; } -#ifndef NONBE_FIX_1052_SBA_EXT_FIX - if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - st_ivas->hDecoderConfig->output_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); -#else - st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order ); -#endif - st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config ); - } - -#endif if ( st_ivas->ini_frame > 0 && st_ivas->ivas_format == SBA_FORMAT ) { int16_t nchan_transport_old, nchan_transport; @@ -808,9 +774,7 @@ ivas_error ivas_init_decoder_front( st_ivas->nSCE = 0; st_ivas->nCPE = 0; -#ifdef NONBE_FIX_1052_SBA_EXT_FIX st_ivas->nchan_ism = 0; -#endif st_ivas->nchan_transport = -1; st_ivas->ism_mode = ISM_MODE_NONE; @@ -976,17 +940,9 @@ ivas_error ivas_init_decoder( { hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->transport_config ); } -#ifdef NONBE_FIX_1052_SBA_EXT_FIX else if ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) -#else - else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) -#endif { -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER hDecoderConfig->nchan_out = audioCfg2channels( ivas_set_audio_config_from_sba_order( st_ivas->sba_order ) ); -#else - hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); -#endif hDecoderConfig->nchan_out += st_ivas->nchan_ism; } else if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) @@ -1012,17 +968,11 @@ ivas_error ivas_init_decoder( ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->transport_config ); st_ivas->intern_config = st_ivas->transport_config; } -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER -#ifdef NONBE_FIX_1052_SBA_EXT_FIX else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && ( st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == SBA_FORMAT ) ) -#else - else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->ivas_format == SBA_ISM_FORMAT ) -#endif { st_ivas->intern_config = ivas_set_audio_config_from_sba_order( st_ivas->sba_order ); ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->intern_config ); } -#endif else { ivas_output_init( &( st_ivas->hOutSetup ), output_config ); @@ -1036,16 +986,6 @@ ivas_error ivas_init_decoder( st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( st_ivas->intern_config ); } -#ifndef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) - { - st_ivas->hOutSetup.ambisonics_order = SBA_HOA3_ORDER; - st_ivas->intern_config = IVAS_AUDIO_CONFIG_HOA3; - st_ivas->hOutSetup.output_config = IVAS_AUDIO_CONFIG_HOA3; - st_ivas->hOutSetup.nchan_out_woLFE = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); - } - -#endif /* Only initialize transport setup if it is used */ if ( st_ivas->transport_config != IVAS_AUDIO_CONFIG_INVALID ) { @@ -1232,11 +1172,7 @@ ivas_error ivas_init_decoder( return error; } -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && !( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) -#else - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) -#endif { if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_output_config.c b/lib_dec/ivas_output_config.c index 5b331378ca..44a10edbe2 100644 --- a/lib_dec/ivas_output_config.c +++ b/lib_dec/ivas_output_config.c @@ -318,15 +318,11 @@ void ivas_renderer_select( if ( ivas_format == SBA_FORMAT && ( output_config != IVAS_AUDIO_CONFIG_5_1 && output_config != IVAS_AUDIO_CONFIG_5_1_2 && output_config != IVAS_AUDIO_CONFIG_5_1_4 && output_config != IVAS_AUDIO_CONFIG_7_1 && output_config != IVAS_AUDIO_CONFIG_7_1_4 && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && output_config != IVAS_AUDIO_CONFIG_MONO && output_config != IVAS_AUDIO_CONFIG_STEREO ) ) { -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) { /* 'internal_config' was already set in ivas_set_audio_config_from_sba_order() */ } else if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) -#else - if ( output_config == IVAS_AUDIO_CONFIG_HOA2 || output_config == IVAS_AUDIO_CONFIG_FOA ) -#endif { *internal_config = output_config; } @@ -334,11 +330,7 @@ void ivas_renderer_select( { *internal_config = IVAS_AUDIO_CONFIG_FOA; } -#ifdef NONBE_FIX_1128_OSBA_EXT_OUTPUT_ORDER else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) -#else - if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) -#endif { *internal_config = IVAS_AUDIO_CONFIG_HOA3; } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 82b87bdcd2..ff086adb54 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1556,11 +1556,7 @@ void ivas_spar_dec_upmixer_sf( } } -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( hDecoderConfig->ivas_total_brate < IVAS_24k4 && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) -#else - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) -#endif { ivas_spar_calc_smooth_facs( cldfb_in_ts_re[0], cldfb_in_ts_im[0], num_spar_bands, hSpar->subframe_nbslots[hSpar->subframes_rendered], hSpar->subframes_rendered == 0, &hSpar->hFbMixer->pFb->fb_bin_to_band, hSpar->hMdDec->smooth_fac, hSpar->hMdDec->smooth_buf ); } @@ -1570,11 +1566,7 @@ void ivas_spar_dec_upmixer_sf( md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( hDecoderConfig->ivas_total_brate < IVAS_24k4 && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) -#else - if ( ( hDecoderConfig->ivas_total_brate < IVAS_24k4 ) && ( ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_HOA3 ) ) ) -#endif { for ( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { @@ -1663,11 +1655,7 @@ void ivas_spar_dec_upmixer_sf( } } -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO && !( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA ) ) -#else - if ( hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_FOA && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_MONO ) -#endif { ivas_dirac_dec_render_sf( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im ); } diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c index 044fb1c59a..a3a2bec257 100644 --- a/lib_enc/ivas_cpe_enc.c +++ b/lib_enc/ivas_cpe_enc.c @@ -599,19 +599,7 @@ ivas_error ivas_cpe_enc( if ( sts[0]->core_brate == SID_2k40 ) { -#ifdef NONBE_FIX_1052_SBA_EXT_FIX ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr, hEncoderConfig->sba_order, hEncoderConfig->sba_planar ); -#else - ivas_write_format_sid( ivas_format, hCPE->element_mode, sts[0]->hBstr ); - if ( ivas_format == SBA_FORMAT ) - { - /* Write SBA planar flag */ - push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - - /* Write SBA order */ - push_indice( sts[0]->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); - } -#endif } /*----------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index e9b2b5765f..05621dfaaa 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -135,13 +135,9 @@ void ivas_write_format( void ivas_write_format_sid( const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t element_mode, /* i : element bitrate */ -#ifdef NONBE_FIX_1052_SBA_EXT_FIX - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t sba_planar /* i : SBA planar flag */ -#else - BSTR_ENC_HANDLE hBstr /* i/o: encoder bitstream handle */ -#endif + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int16_t sba_planar /* i : SBA planar flag */ ) { int16_t ind = 0; /* to avoid compilation warning */ @@ -199,7 +195,6 @@ void ivas_write_format_sid( push_indice( hBstr, IND_IVAS_FORMAT, ind, SID_FORMAT_NBITS ); -#ifdef NONBE_FIX_1052_SBA_EXT_FIX if ( ivas_format == SBA_FORMAT ) { /* Write SBA planar flag */ @@ -208,7 +203,6 @@ void ivas_write_format_sid( /* Write SBA order */ push_indice( hBstr, IND_SMODE, sba_order, SBA_ORDER_BITS ); } -#endif return; } diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 88713e7409..6e2732f44a 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -280,11 +280,7 @@ ivas_error ivas_ism_enc( if ( sid_flag ) { -#ifdef NONBE_FIX_1052_SBA_EXT_FIX ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr, -1, -1 ); -#else - ivas_write_format_sid( st_ivas->hEncoderConfig->ivas_format, IVAS_SCE, st->hBstr ); -#endif } /*only metadata encoding is needed for this case*/ diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c index b36048ce0b..8f5d472ea9 100644 --- a/lib_enc/ivas_sce_enc.c +++ b/lib_enc/ivas_sce_enc.c @@ -223,19 +223,7 @@ ivas_error ivas_sce_enc( if ( st->core_brate == SID_2k40 ) { -#ifdef NONBE_FIX_1052_SBA_EXT_FIX ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr, st_ivas->hEncoderConfig->sba_order, st_ivas->hEncoderConfig->sba_planar ); -#else - ivas_write_format_sid( ivas_format, IVAS_SCE, st->hBstr ); - if ( ivas_format == SBA_FORMAT ) - { - /* Write SBA planar flag */ - push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_planar, SBA_PLANAR_BITS ); - - /* Write SBA order */ - push_indice( st->hBstr, IND_SMODE, st_ivas->hEncoderConfig->sba_order, SBA_ORDER_BITS ); - } -#endif } /*----------------------------------------------------------------* -- GitLab From 389bb7cfa72376466c4118b08d53bddb948a9624 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 4 Jul 2024 14:24:16 +0200 Subject: [PATCH 129/130] Added links to summary csv files --- ci/basop-pages/create_report_pages.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 4177930597..38a5106326 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -138,9 +138,9 @@ def create_subpage( tr_from_row(row, id_current, id_previous) for row in merged_reports ) if histogram: - images_mld = f"

    MLD summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) - images_ssnr = f"

    MIN_SSNR summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) - images_diff = f"

    MAX ABS DIFFERENCE summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + images_mld = f"

    MLD summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_MLD.csv" + images_ssnr = f"

    MIN_SSNR summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_SSNR.csv" + images_diff = f"

    MAX ABS DIFFERENCE summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_DIFF.csv" else: images_mld = "" images_ssnr = "" -- GitLab From c8d0817f11d2ce072932c670ec68b9c94756335a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 4 Jul 2024 15:06:59 +0200 Subject: [PATCH 130/130] run formatter on new files --- ci/basop-pages/create_report_pages.py | 42 +++++++++++---- scripts/create_histogram_summary.py | 58 +++++++++++++-------- scripts/parse_xml_report.py | 73 ++++++++++++++++++--------- 3 files changed, 119 insertions(+), 54 deletions(-) diff --git a/ci/basop-pages/create_report_pages.py b/ci/basop-pages/create_report_pages.py index 38a5106326..25fde10409 100644 --- a/ci/basop-pages/create_report_pages.py +++ b/ci/basop-pages/create_report_pages.py @@ -3,7 +3,7 @@ import pathlib import argparse from functools import partial -FORMATS = ['Stereo', 'ISM', 'Multichannel','MASA','SBA', 'OSBA', 'OMASA', 'Renderer'] +FORMATS = ["Stereo", "ISM", "Multichannel", "MASA", "SBA", "OSBA", "OMASA", "Renderer"] CSV_DELIM = ";" SUBPAGE_TMPL_CSS = """ @@ -100,7 +100,15 @@ ARROW_DOWN = '' # expected columns. actual columns are filtered from the incoming data later, this # is mainly for controlling the order in the output table -COLUMNS = ["testcase", "Format", "Category", "Result", "MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] +COLUMNS = [ + "testcase", + "Format", + "Category", + "Result", + "MLD", + "MAXIMUM ABS DIFF", + "MIN_SSNR", +] COLUMNS_GLOBAL = COLUMNS[:1] COLUMNS_DIFFERENTIAL = COLUMNS[3:] COLUMNS_DIFFERENTIAL_NOT_MLD = COLUMNS_DIFFERENTIAL[2:] @@ -138,9 +146,27 @@ def create_subpage( tr_from_row(row, id_current, id_previous) for row in merged_reports ) if histogram: - images_mld = f"

    MLD summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_MLD.csv" - images_ssnr = f"

    MIN_SSNR summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_SSNR.csv" - images_diff = f"

    MAX ABS DIFFERENCE summary {job_name}

    \n" + " ".join([f"" for x in FORMATS]) + f"\n
    summary_{id_current}_DIFF.csv" + images_mld = ( + f"

    MLD summary {job_name}

    \n" + + " ".join( + [f"" for x in FORMATS] + ) + + f'\n
    summary_{id_current}_MLD.csv' + ) + images_ssnr = ( + f"

    MIN_SSNR summary {job_name}

    \n" + + " ".join( + [f"" for x in FORMATS] + ) + + f'\n
    summary_{id_current}_SSNR.csv' + ) + images_diff = ( + f"

    MAX ABS DIFFERENCE summary {job_name}

    \n" + + " ".join( + [f"" for x in FORMATS] + ) + + f'\n
    summary_{id_current}_DIFF.csv' + ) else: images_mld = "" images_ssnr = "" @@ -155,7 +181,7 @@ def create_subpage( table_header_b=table_header_b, images_mld=images_mld, images_ssnr=images_ssnr, - images_diff=images_diff, + images_diff=images_diff, ) with open(html_out, "w") as f: f.write(new_subpage) @@ -315,11 +341,9 @@ if __name__ == "__main__": parser.add_argument("id_current", type=int) parser.add_argument("id_previous", type=int) parser.add_argument("job_name") - parser.add_argument("--histogram", action='store_true') + parser.add_argument("--histogram", action="store_true") args = parser.parse_args() - - create_subpage( args.html_out, args.csv_out, diff --git a/scripts/create_histogram_summary.py b/scripts/create_histogram_summary.py index eab71dacf8..1ab951ac72 100644 --- a/scripts/create_histogram_summary.py +++ b/scripts/create_histogram_summary.py @@ -3,8 +3,10 @@ import argparse import math import numpy as np -import matplotlib # These steps are added as a precaution in case the gitlab runner -matplotlib.use('Agg') # needs DISPLAY to render the plots, even if they are written to file. +# These next three lines are added as a precaution in case the gitlab runner +# needs DISPLAY to render the plots, even if they are written to file. +import matplotlib +matplotlib.use("Agg") import matplotlib.pyplot as plt import csv import os @@ -15,7 +17,6 @@ Parses a CSV report and creates a summary report. """ - # Main routine if __name__ == "__main__": parser = argparse.ArgumentParser( @@ -30,18 +31,18 @@ if __name__ == "__main__": "csv_summary", type=str, help="Output CSV file, e.g. summary.csv" ) parser.add_argument( - "csv_image", - type=str, - nargs='?', - help="Summary image file, e.g. summary.png", - default = None + "csv_image", + type=str, + nargs="?", + help="Summary image file, e.g. summary.png", + default=None, ) parser.add_argument( "--measure", type=str, nargs=1, help="Measure, any of: MLD, DIFF, SSNR, default: MLD", - default = ['MLD'] + default=["MLD"], ) args = parser.parse_args() csv_report = args.csv_report @@ -49,13 +50,17 @@ if __name__ == "__main__": csv_image = args.csv_image measure = args.measure[0] - limits_per_measure = {'MLD':('MLD',[0, 5, 10, math.inf]), 'DIFF':('MAXIMUM ABS DIFF',[0, 1024, 16384, 32769]), 'SSNR':('MIN_SSNR',[-math.inf, 0, 20, 40, 60, 100])} + limits_per_measure = { + "MLD": ("MLD", [0, 5, 10, math.inf]), + "DIFF": ("MAXIMUM ABS DIFF", [0, 1024, 16384, 32769]), + "SSNR": ("MIN_SSNR", [-math.inf, 0, 20, 40, 60, 100]), + } (measure_label, limits) = limits_per_measure[measure] # Load CSV report results_sorted = {} - with open(csv_report,'r') as fp: - reader = csv.reader(fp, delimiter=';') + with open(csv_report, "r") as fp: + reader = csv.reader(fp, delimiter=";") header = next(reader) keys = header[1:] for row in reader: @@ -66,7 +71,9 @@ if __name__ == "__main__": # Output CSV file with open(csv_summary, "w") as fp: - limits_labels = [f"{str(a)} --\n {str(b)}" for (a,b) in zip(limits[0:-1],limits[1:])] + ["None"] + limits_labels = [ + f"{str(a)} --\n {str(b)}" for (a, b) in zip(limits[0:-1], limits[1:]) + ] + ["None"] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": limits_labels = ["0"] + limits_labels @@ -77,23 +84,32 @@ if __name__ == "__main__": fig, ax = plt.subplots() bottom = np.zeros(len(limits_labels)) for cat in CATEGORIES: - values = [x for x in [m[measure_label] for m in results_sorted.values() if m["Format"] == fmt and m["Category"] == cat]] + values = [ + x + for x in [ + m[measure_label] + for m in results_sorted.values() + if m["Format"] == fmt and m["Category"] == cat + ] + ] # Zero difference is treated as a special category for MLD and MAXIMUM ABS DIFF if measure_label == "MLD" or measure_label == "MAXIMUM ABS DIFF": - val = [float(x) for x in values if x != 'None' and x != '0' and x != ''] - zero = [sum([1 for x in values if x == '0'])] - none = [sum([1 for x in values if x == 'None' or x == ''])] + val = [ + float(x) for x in values if x != "None" and x != "0" and x != "" + ] + zero = [sum([1 for x in values if x == "0"])] + none = [sum([1 for x in values if x == "None" or x == ""])] else: - val = [float(x) for x in values if x != 'None' and x != ''] + val = [float(x) for x in values if x != "None" and x != ""] zero = [] - none = [sum([1 for x in values if x == 'None' or x == ''])] - hist, _ = np.histogram(val,limits) + none = [sum([1 for x in values if x == "None" or x == ""])] + hist, _ = np.histogram(val, limits) data = np.array(zero + list(hist) + none) # CSV output line = f"{fmt};{cat};{'; '.join(map(str,data))}\n" fp.write(line) - + # Matplotlib histogram ax.bar(limits_labels, data, 0.5, label=cat, bottom=bottom) bottom += data diff --git a/scripts/parse_xml_report.py b/scripts/parse_xml_report.py index cdd504c977..3bc0b619ab 100644 --- a/scripts/parse_xml_report.py +++ b/scripts/parse_xml_report.py @@ -12,10 +12,24 @@ Parse a junit report and create a summary report. PROPERTIES = ["MLD", "MAXIMUM ABS DIFF", "MIN_SSNR"] -FORMATS = {'Stereo':r'stereo', 'ISM':r'ISM', 'Multichannel':r'Multi-channel', - 'MASA':r'(?