From 6001b7ae4afa48e89dd8fde2a5c65861b4e4f5b9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 15 Jul 2022 16:45:07 +0200 Subject: [PATCH 1/4] fix for 5_1_4 to 5_1_2 downmix matrix --- lib_com/options.h | 2 ++ lib_dec/ivas_rom_dec.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 3429351609..c58d39ad46 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,8 @@ #define REFACTOR_REVERB_INIT_ADD_CFG_CHECKS /* Simplify and improve reverb initialization + add range checks on config parameter values */ +#define FIX_I54_LS_DMX /* FhG: fix incorrect downmix matrix for 5_1_4 to 5_1_2 */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 84a0db9765..51ba671d51 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -620,6 +620,18 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[] = /* First row indicates the number of non-zero elements */ {10, 0.0f}, /* Index of non-zero element, value of non-zero element*/ +#ifdef FIX_I54_LS_DMX + {0, 1.000000000f}, + {9, 1.000000000f}, + {18, 1.000000000f}, + {27, 1.000000000f}, + {36, 1.000000000f}, + {45, 1.000000000f}, + {54, 1.000000000f}, + {63, 1.000000000f}, + {68, 0.849999964f}, + {77, 0.849999964f}, +#else {0, 1.000000000f}, {11, 1.000000000f}, {22, 1.000000000f}, @@ -630,6 +642,7 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[] = {59, 0.849999964f}, {66, 1.000000000f}, {77, 1.000000000f}, +#endif }; const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[] = -- GitLab From 006afa87deb0389eb49037d91b14aaf908c48055 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 18 Jul 2022 11:57:48 +0200 Subject: [PATCH 2/4] rename switch to FIX_I54_LS_CONVERSION and also fix a bug in the 7_1 to 7_1_4 upmix matrix --- lib_com/options.h | 2 +- lib_dec/ivas_rom_dec.c | 23 ++++++++++++++++++++++- lib_dec/ivas_rom_dec.h | 3 +++ scripts/pyaudio3dtools/constants.py | 6 +++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c58d39ad46..f372904f4f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,7 +155,7 @@ #define REFACTOR_REVERB_INIT_ADD_CFG_CHECKS /* Simplify and improve reverb initialization + add range checks on config parameter values */ -#define FIX_I54_LS_DMX /* FhG: fix incorrect downmix matrix for 5_1_4 to 5_1_2 */ +#define FIX_I54_LS_CONVERSION /* FhG: fix incorrect downmix matrix for 5_1_4 to 5_1_2 and upmix matrix for 7_1 to 7_1_4 */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 51ba671d51..e16529323d 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -620,7 +620,7 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[] = /* First row indicates the number of non-zero elements */ {10, 0.0f}, /* Index of non-zero element, value of non-zero element*/ -#ifdef FIX_I54_LS_DMX +#ifdef FIX_I54_LS_CONVERSION {0, 1.000000000f}, {9, 1.000000000f}, {18, 1.000000000f}, @@ -760,6 +760,23 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[] = {75, 1.0f} }; +#define FIX_I54_LS_CONVERSION +const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[] = +{ + /* First row indicates the number of non-zero elements */ + {8, 0.0f}, + /* Index of non-zero element, value of non-zero element*/ + {0, 1.0f}, + {13, 1.0f}, + {26, 1.0f}, + {39, 1.0f}, + {54, 1.0f}, + {67, 1.0f}, + {76, 1.0f}, + {89, 1.0f} +}; +#endif + const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[] = { /* First row indicates the number of non-zero elements */ @@ -840,7 +857,11 @@ const LS_CONVERSION_MAPPING ls_conversion_mapping[LS_SETUP_CONVERSION_NUM_MAPPIN {AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1_2, ls_conversion_cicp12_cicp14}, {AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1_4, ls_conversion_cicp12_cicp16}, +#ifdef FIX_I54_LS_CONVERSION + {AUDIO_CONFIG_7_1, AUDIO_CONFIG_7_1_4, ls_conversion_cicp12_cicp19}, +#else {AUDIO_CONFIG_7_1, AUDIO_CONFIG_7_1_4, NULL}, +#endif {AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_5_1_4, NULL}, {AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_7_1_4, ls_conversion_cicp14_cicp19}, diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index 5979d8d64b..e70d59b8d0 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -130,6 +130,9 @@ extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp16[]; /* Upmix matrices */ extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp14[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[]; +#ifdef FIX_I54_LS_CONVERSION +extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[]; +#endif extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp19[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp19[]; diff --git a/scripts/pyaudio3dtools/constants.py b/scripts/pyaudio3dtools/constants.py index 7a68725451..de6431deb8 100644 --- a/scripts/pyaudio3dtools/constants.py +++ b/scripts/pyaudio3dtools/constants.py @@ -134,6 +134,10 @@ IVAS_CICP12_TO_16 = np.zeros(8 * 10) IVAS_CICP12_TO_16[[0, 11, 22, 33, 44, 55, 64, 75]] = 1 IVAS_CICP12_TO_16 = IVAS_CICP12_TO_16.reshape(8, 10) +IVAS_CICP12_TO_19 = np.zeros(8 * 12) +IVAS_CICP12_TO_19[[0, 13, 26, 39, 54, 67, 76, 89]] = 1 +IVAS_CICP12_TO_19 = IVAS_CICP12_TO_19.reshape(8, 12) + IVAS_CICP14_TO_19 = np.zeros(8 * 12) IVAS_CICP14_TO_19[[0, 13, 26, 39, 52, 65, 80, 93]] = 1 IVAS_CICP14_TO_19 = IVAS_CICP14_TO_19.reshape(8, 12) @@ -178,7 +182,7 @@ IVAS_MC_CONVERSION = { # upmix "5_1_2": IVAS_CICP12_TO_14, "5_1_4": IVAS_CICP12_TO_16, - "7_1_4": np.pad(np.eye(8), [[0, 0], [0, 4]]), + "7_1_4": IVAS_CICP12_TO_19, }, "5_1_2": { # downmix -- GitLab From a788f0dac45446f78ed107cd18fa2746697f5c42 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 18 Jul 2022 12:40:27 +0200 Subject: [PATCH 3/4] fix build and typo in pyaudio3dtools coefficients --- lib_dec/ivas_rom_dec.c | 2 +- scripts/pyaudio3dtools/constants.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index e16529323d..06695146d9 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -760,7 +760,7 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp16[] = {75, 1.0f} }; -#define FIX_I54_LS_CONVERSION +#ifdef FIX_I54_LS_CONVERSION const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp19[] = { /* First row indicates the number of non-zero elements */ diff --git a/scripts/pyaudio3dtools/constants.py b/scripts/pyaudio3dtools/constants.py index de6431deb8..24c8b7aaba 100644 --- a/scripts/pyaudio3dtools/constants.py +++ b/scripts/pyaudio3dtools/constants.py @@ -78,17 +78,17 @@ IVAS_CICP14_TO_6 = IVAS_CICP14_TO_6.reshape(8, 6) IVAS_CICP16_TO_6 = np.zeros(10 * 6) IVAS_CICP16_TO_6[[0, 7, 14, 21, 28, 35]] = 1 -IVAS_CICP16_TO_6[[36, 43, 52, 59]] = 0.89999964 +IVAS_CICP16_TO_6[[36, 43, 52, 59]] = 0.849999964 IVAS_CICP16_TO_6 = IVAS_CICP16_TO_6.reshape(10, 6) IVAS_CICP16_TO_12 = np.zeros(10 * 8) IVAS_CICP16_TO_12[[0, 9, 18, 27, 36, 45]] = 1 -IVAS_CICP16_TO_12[[48, 57, 68, 77]] = 0.89999964 +IVAS_CICP16_TO_12[[48, 57, 68, 77]] = 0.849999964 IVAS_CICP16_TO_12 = IVAS_CICP16_TO_12.reshape(10, 8) IVAS_CICP16_TO_14 = np.zeros(10 * 8) IVAS_CICP16_TO_14[[0, 9, 18, 27, 36, 45, 54, 63]] = 1 -IVAS_CICP16_TO_14[[68, 77]] = 0.899999964 +IVAS_CICP16_TO_14[[68, 77]] = 0.849999964 IVAS_CICP16_TO_14 = IVAS_CICP16_TO_14.reshape(10, 8) IVAS_CICP19_TO_6 = np.zeros(12 * 6) -- GitLab From c6da31000c58fdf42c15ff8fd5bc97a00c55dfa4 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 18 Jul 2022 13:48:30 +0200 Subject: [PATCH 4/4] fix another incorrect matrix for 5_1_2 to 7_1 conversion (indices should be different because of different shape) --- lib_dec/ivas_rom_dec.c | 21 +++++++++++++++++++++ lib_dec/ivas_rom_dec.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/lib_dec/ivas_rom_dec.c b/lib_dec/ivas_rom_dec.c index 06695146d9..c442da1c75 100644 --- a/lib_dec/ivas_rom_dec.c +++ b/lib_dec/ivas_rom_dec.c @@ -580,6 +580,23 @@ const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[] = {43, 0.849999964f} }; +#ifdef FIX_I54_LS_CONVERSION +const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[] = +{ + /* First row indicates the number of non-zero elements */ + {8, 0.0f}, + /* Index of non-zero element, value of non-zero element*/ + {0, 1.000000000f}, + {9, 1.000000000f}, + {18, 1.000000000f}, + {27, 1.000000000f}, + {36, 1.000000000f}, + {45, 1.000000000f}, + {48, 0.849999964f}, + {57, 0.849999964f} +}; +#endif + const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[] = { /* First row indicates the number of non-zero elements */ @@ -832,7 +849,11 @@ const LS_CONVERSION_MAPPING ls_conversion_mapping[LS_SETUP_CONVERSION_NUM_MAPPIN {AUDIO_CONFIG_7_1, AUDIO_CONFIG_5_1, ls_conversion_cicp12_cicp6}, {AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_5_1, ls_conversion_cicp14_cicp6}, +#ifdef FIX_I54_LS_CONVERSION + {AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_7_1, ls_conversion_cicp14_cicp12}, +#else {AUDIO_CONFIG_5_1_2, AUDIO_CONFIG_7_1, ls_conversion_cicp14_cicp6}, +#endif {AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_5_1, ls_conversion_cicp16_cicp6}, {AUDIO_CONFIG_5_1_4, AUDIO_CONFIG_7_1, ls_conversion_cicp16_cicp12}, diff --git a/lib_dec/ivas_rom_dec.h b/lib_dec/ivas_rom_dec.h index e70d59b8d0..a445f1e2cf 100644 --- a/lib_dec/ivas_rom_dec.h +++ b/lib_dec/ivas_rom_dec.h @@ -120,6 +120,9 @@ extern const float ls_conversion_cicpX_stereo[12][2]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp6[]; +#ifdef FIX_I54_LS_CONVERSION +extern const LS_CONVERSION_MATRIX ls_conversion_cicp14_cicp12[]; +#endif extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp6[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp16_cicp14[]; extern const LS_CONVERSION_MATRIX ls_conversion_cicp19_cicp6[]; -- GitLab