diff options
author | Chris Hold <Christoph.Hold@aalto.fi> | 2024-02-15 14:42:53 +0200 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2024-02-16 16:14:54 -0500 |
commit | 965afac29b33465c53b4b98b07aa350322af16ea (patch) | |
tree | 4dd93abcf5fa4410f9cd3beb1a2acbb4dc2af7b3 | |
parent | befc25fb766be73e360d4a9482fc13e0360f616c (diff) | |
download | libopus-965afac29b33465c53b4b98b07aa350322af16ea.tar.gz |
Provide 4th order HOA map 3 mixing and demixing
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
-rw-r--r-- | src/mapping_matrix.c | 191 | ||||
-rw-r--r-- | src/mapping_matrix.h | 6 | ||||
-rw-r--r-- | src/opus_projection_encoder.c | 21 | ||||
-rw-r--r-- | tests/test_opus_projection.c | 2 |
4 files changed, 219 insertions, 1 deletions
diff --git a/src/mapping_matrix.c b/src/mapping_matrix.c index 238cb784..792e0de2 100644 --- a/src/mapping_matrix.c +++ b/src/mapping_matrix.c @@ -302,6 +302,102 @@ const opus_int16 mapping_matrix_toa_mixing_data[324] = { 0, 0, 0, 32767 }; +const MappingMatrix mapping_matrix_fourthoa_mixing = { 27, 27, 0 }; +const opus_int16 mapping_matrix_fourthoa_mixing_data[729] = { + 9243, 0, 16010, 0, 0, 0, 20669, 0, + 0, 0, 0, 0, 24456, 0, 0, 0, + 0, 0, 0, 0, 27731, 0, 0, 0, + 0, 0, 0, 9243, 0, 10884, 11741, 0, + 0, 3995, 17849, 9626, 0, 0, 0, -5727, + 14399, 17315, 7625, 0, 0, 0, 0, -11747, + 2574, 18637, 15552, 5930, 0, 0, 9243, -14302, + -2682, -6677, 13337, 5357, -9464, 2501, -11170, 4770, + -5911, 11501, 5858, 5369, 4951, 17901, -19071, -2397, + -9281, -9198, 7576, -4294, 7773, -8997, -3399, 0, + 0, 9243, 9940, 11991, -3705, -5144, 16647, 7057, + -6206, -5941, -2698, -10194, 16781, -1788, -6256, -11772, + 4935, 3912, -6062, -13039, 9446, -9758, -3521, -15058, + 11089, 565, 0, 0, 9243, -15376, 3720, 2461, + -5285, -7989, -8660, 1278, -16087, 15811, -3249, 10500, + -7757, -1680, -9890, -8153, 10884, 11022, 2847, 12828, + 5137, -2053, 8666, -5684, 14776, 0, 0, 9243, + -10577, 10304, -6186, 9139, -15222, 2507, -8902, -5140, + -145, 15562, -10596, -7311, -6197, -8753, 8667, -6014, + -281, 15033, 938, -11859, 548, -8456, 16735, -3654, + 0, 0, 9243, 8974, 4839, -12343, -15472, 6066, + -7501, -8343, 5015, 15920, -12374, -4559, -9400, 6271, + 4011, 5191, -9932, 14438, 4828, -8768, 1909, 12059, + -1565, 4707, -13711, 0, 0, 9243, 15799, 2085, + -1534, -3386, 4602, -9808, -447, -17267, -18054, -1167, + -13525, -4644, 1313, -5951, 5397, 7485, -7056, 2584, + -8120, 8669, 788, 13177, 2109, 18349, 0, 0, + 9243, 12371, -10036, 1597, 2760, -17341, 1848, -2239, + -10509, -8474, -4577, 11164, 7935, 1441, 17430, -3436, + -3713, 15936, 4184, 2647, -11730, 341, -15934, 6462, + 6581, 0, 0, 9243, -8963, 2184, 13084, -16381, + -2734, -9757, 3991, 6345, -18297, -5912, 7604, -4849, + -11100, 2290, -4304, -13305, -7488, 12338, 4805, 8505, + -7014, -4779, -1761, -14597, 0, 0, 9243, 1301, + -15498, 3799, 690, -2816, 18718, -8223, 889, 255, + -1768, 4485, -19951, 13097, -2278, 167, 78, -740, + 3324, -6139, 19488, -17925, 4283, -486, 20, 0, + 0, 9243, -13470, -6719, 5452, -10257, 12641, -4873, + -5116, -10595, 5856, 11389, 1502, 10876, -608, 11765, + -13218, 13911, -7373, -2070, -13679, -4154, 5536, -2138, + 16643, 451, 0, 0, 9243, 2455, -3679, -15387, + -5277, -1261, -8697, 7906, 16112, 8147, 3208, -1690, + 7687, 10593, -9796, -15852, -10884, -5616, 2881, 2032, + 5246, -12735, -8796, 10928, 14833, 0, 0, 9243, + -6849, 2775, -14202, 13586, -2655, -9402, -5505, 10809, + -18013, 6231, 5444, -6041, 11288, 4958, -4078, 18799, + -9368, -9291, 4535, 7383, 9405, -7391, -2121, -4336, + 0, 0, 9243, 6423, -9040, 11548, 10359, -8109, + -450, -14580, 6431, 10857, -15475, 3569, 9707, 6416, + -9607, 521, 8528, -18391, 11049, 3815, -10423, 6860, + 6860, -883, -4221, 0, 0, 9243, 11932, -5968, + -8850, -14749, -9946, -6026, 7377, -4472, 5206, 14547, + -3406, 10508, 2526, 4411, 14543, 8444, -5822, 347, + 12347, -1709, -9158, 105, -16265, -12642, 0, 0, + 9243, 13044, -150, 9282, 16910, -274, -10332, -194, + -5864, 5428, -420, -12196, 344, -8679, 145, -18554, + -12695, -152, -14635, 503, 10389, 358, 5076, 522, + -16100, 0, 0, 9243, -8374, -13590, -1221, 1428, + 15896, 12005, 2318, -4793, 2590, -3209, -20390, -6256, + -2974, 10766, 1202, -876, -6597, 5004, 19896, -1541, + 2902, -16788, -3062, 1340, 0, 0, 9243, 9879, + 10267, 7300, 10073, 14167, 2416, 10469, -3094, 2899, + 17092, 9762, -7400, 7214, -5250, -8238, -3989, 5578, + 16392, -1050, -11848, -776, -5034, -15850, -5882, 0, + 0, 9243, -4974, -9068, 12221, -8490, 6299, -388, + -15478, 8702, -9920, 12723, -2810, 9668, 6905, -13040, + 4325, -9456, 16856, -9159, -2909, -10476, 7149, 9387, + -7350, 233, 0, 0, 9243, 3627, -13823, -7218, + -3656, -7002, 12776, 13935, 2719, 2446, 8352, 9252, + -7676, -18413, -6212, -429, -1272, -6335, -13356, -9510, + 295, 18926, 9934, 1112, -382, 0, 0, 9243, + -6383, -9343, -11326, 10097, 8329, 223, 14780, 6114, + -10348, -15590, -4195, 9257, -7445, -9439, -323, 7902, + 18117, 12101, -3142, -10944, -5577, 7327, 566, -4133, + 0, 0, 9243, 2626, 865, 15769, 5783, 317, + -10244, 1905, 16884, 9144, 826, -2420, -1972, -14536, + 2413, 16939, 12500, 1482, -4906, -578, 10096, -3476, + -14323, 2745, 16105, 0, 0, 9243, -8975, 12086, + 5450, -6832, -15149, 7333, 9200, -3550, -362, -13645, + -15525, -1391, 9428, -7091, -5442, 3105, -820, -17685, + -9175, -9462, 5572, -9191, -12325, -2180, 0, 0, + 9243, -114, 11576, -11058, 177, -185, 5875, -17880, + 8539, -198, 339, -173, -3411, -16698, 16336, -6369, + 193, -430, 408, -75, -10806, -7225, 19670, -13817, + 4665, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 32767, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32767 +}; + const MappingMatrix mapping_matrix_fifthoa_mixing = { 38, 38, 0 }; const opus_int16 mapping_matrix_fifthoa_mixing_data[1444] = { 9244, 0, 16011, 0, 0, 0, 20670, 0, @@ -561,6 +657,101 @@ const opus_int16 mapping_matrix_toa_demixing_data[324] = { 0, 0, 0, 32767 }; +const MappingMatrix mapping_matrix_fourthoa_demixing = { 27, 27, 0 }; +const opus_int16 mapping_matrix_fourthoa_demixing_data[729] = { + 4870, 4484, 4870, 4347, 4440, 4726, 4683, 4821, + 4883, 4842, 4603, 4484, 4683, 4698, 4234, 4368, + 4603, 4783, 4783, 4820, 4821, 4347, 4820, 4440, + 4698, 0, 0, 101, 84, -7818, 4640, -7178, + -5492, 4629, 8384, 6547, -4966, 617, -6345, 1061, + -3241, 2939, 5549, 6390, -4434, 4994, -2610, 1993, + -2873, 1547, -4356, -164, 0, 0, 8797, 5074, + -1553, 5383, 1906, 5297, 2722, 1158, -5226, 1311, + -7760, -3327, -1940, 1586, -4093, -2951, -214, -6873, + 5450, -4875, -7193, -4438, 558, 5593, 5607, 0, + 0, -26, 5761, -3723, -1460, 1195, -3065, -6357, + -1175, 608, 6965, 2310, 2759, -8023, -7138, 5162, + -3624, 5006, -809, 3592, 6209, -4159, -4968, 8150, + 2513, -5702, 0, 0, 301, 109, 7161, -2462, + -2443, 5044, -7125, -2256, 1967, -9107, 259, -4928, + -2592, 6514, 4111, -7236, 8695, 635, 5009, -4025, + -1937, 4794, 3420, -3507, -400, 0, 0, -134, + 85, 2771, 7842, -3649, -8225, 2866, 2586, -9200, + -1945, -1563, 6155, -720, -1061, -3494, -4513, -487, + 8389, 7317, 3348, -3721, 3806, 371, -6896, 70, + 0, 0, 10919, 2072, -4867, 3472, -4429, 1721, + -4066, -5193, 1032, -5253, 9501, -2017, -3971, -5261, + -306, -2737, -5137, 5713, 1237, -8, 6387, 364, + -5423, 3364, 2888, 0, 0, -48, 8946, 1048, + -2691, 602, -4332, -4302, -514, -1730, 2459, -4328, + -2156, 3335, -2748, -6029, 4023, 155, 897, 5268, + -8380, 7625, 7395, 508, 3945, -8951, 0, 0, + 39, 4151, -5965, -3398, -7006, -3534, 2697, -8989, + -5237, 2913, 46, -5540, 8196, 5766, 2711, -2520, + -3043, -2146, -948, 4965, 1806, 2472, 8988, -1266, + 4840, 0, 0, -407, -189, 2179, -1627, 6516, + 259, 7196, -9449, -4905, -9766, 561, 4021, 3371, + -8650, 5032, 3329, 2534, 641, 2224, -5747, 1047, + -4074, 5252, -24, 674, 0, 0, 664, 237, + -2837, -4072, -1205, 8252, -5875, -1670, -2743, -3984, + 381, 5059, 1765, 2666, -8295, 7403, 1154, -2086, + 7622, 7105, 3677, -6943, 1050, -6632, -694, 0, + 0, 382, -133, 5699, 7650, 5154, -5713, -1645, + -6902, 6181, 4450, 1151, 410, -993, 3829, 2444, + -2405, -6618, -9514, 5366, -1896, 5844, -2886, -1524, + -7321, -1007, 0, 0, 12767, -2530, 3183, -1409, + -4015, -2894, -5155, -1710, 3841, -2107, -10274, 5119, + 3979, -4010, 5550, 4822, -746, -2507, -3080, 4289, + -3675, 4333, -1416, -1230, -1122, 0, 0, 17, + 8048, 2398, -2167, -73, -3606, 3125, 398, 731, + -5973, 5705, -1032, 4679, 7305, 3134, 1301, -3858, + -89, 2938, 4359, -9155, -4805, -8407, 3673, -8645, + 0, 0, 187, 7355, 3145, -6719, -4432, -5939, + 2541, -2810, 9723, 778, -1105, 5687, -4174, 2534, + -4461, 1017, -244, 5481, -1655, -6765, -3350, -4894, + 1592, -2318, 8827, 0, 0, 196, 3588, 9631, + 3063, -4564, 6043, 2683, 2595, -2488, -2186, 173, + -6059, -8270, -2386, 409, 7441, -8608, 376, -4364, + 2321, -280, 97, 8331, -3022, -4721, 0, 0, + 117, -748, -10833, 1533, 4200, -2875, -997, -109, + -3661, -6119, 4454, 8808, -9189, 8294, 1521, 7265, + -2348, -5094, -948, -5400, -3193, 8914, 5763, 1716, + -1070, 0, 0, 2497, 399, -5201, -2038, 7843, + -376, 7567, -5073, 7616, -5537, 2086, -3453, -5544, + -56, -11648, -1314, 3546, -3432, -117, 8694, -4245, + 9621, 3098, -2582, -2351, 0, 0, 4386, -3104, + -3132, -10512, 566, 5217, 5128, 4967, 1348, 7035, + -1470, 91, -125, -3548, 8244, -3029, -10033, 2186, + 9745, -6440, -2074, 3638, -1477, -7045, -562, 0, + 0, 2154, 8116, -6102, 6570, 12998, -712, -4126, + -4996, 30, 1571, -6393, -12794, 425, 5036, 1190, + 5763, 5653, 12933, -6671, 5197, -2964, -3316, -6354, + -10554, -2652, 0, 0, 12618, -3737, 93, -5901, + 4262, -3364, 4444, 3103, -2767, 3403, 4925, -2584, + -989, 4977, -3714, -1965, 3076, 326, -2946, -2568, + 1026, -2980, 3362, -6132, -5966, 0, 0, 6001, + 48, -1979, -7275, 3476, -2096, 10591, 3793, 2629, + -447, -14747, -3689, -5525, 8358, 6883, -9703, -4556, + 7471, 2965, 4056, 13221, -7327, -3073, -2353, -6720, + 0, 0, 621, 11034, -44, -2828, 5978, -1850, + -1772, 3894, -7471, -1397, 945, -2028, -2928, -2240, + 3172, 2222, 4544, -4243, -5645, 3745, 2573, 3511, + -8206, -7286, 5700, 0, 0, 321, 10818, -4982, + 7813, -749, 9907, 1360, -1443, 568, -1103, 2305, + 6045, 2270, -1063, -1920, -3073, 5893, -3476, -11346, + -1657, -588, 2957, -2287, -8527, -8041, 0, 0, + 119, -268, 2372, -3040, 4979, -3789, -5630, 10619, + 5900, -5109, -4585, -3862, 10467, -3527, -385, -10034, + -9991, 4860, 984, 2362, 2311, -6804, 6324, 433, + 5291, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 32767, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 32767 +}; const MappingMatrix mapping_matrix_fifthoa_demixing = { 38, 38, 0 }; const opus_int16 mapping_matrix_fifthoa_demixing_data[1444] = { diff --git a/src/mapping_matrix.h b/src/mapping_matrix.h index 1851ec32..53646cb1 100644 --- a/src/mapping_matrix.h +++ b/src/mapping_matrix.h @@ -117,6 +117,9 @@ extern const opus_int16 mapping_matrix_soa_mixing_data[121]; extern const MappingMatrix mapping_matrix_toa_mixing; extern const opus_int16 mapping_matrix_toa_mixing_data[324]; +extern const MappingMatrix mapping_matrix_fourthoa_mixing; +extern const opus_int16 mapping_matrix_fourthoa_mixing_data[729]; + extern const MappingMatrix mapping_matrix_fifthoa_mixing; extern const opus_int16 mapping_matrix_fifthoa_mixing_data[1444]; @@ -129,6 +132,9 @@ extern const opus_int16 mapping_matrix_soa_demixing_data[121]; extern const MappingMatrix mapping_matrix_toa_demixing; extern const opus_int16 mapping_matrix_toa_demixing_data[324]; +extern const MappingMatrix mapping_matrix_fourthoa_demixing; +extern const opus_int16 mapping_matrix_fourthoa_demixing_data[729]; + extern const MappingMatrix mapping_matrix_fifthoa_demixing; extern const opus_int16 mapping_matrix_fifthoa_demixing_data[1444]; diff --git a/src/opus_projection_encoder.c b/src/opus_projection_encoder.c index 652415e9..92813ad0 100644 --- a/src/opus_projection_encoder.c +++ b/src/opus_projection_encoder.c @@ -177,6 +177,13 @@ opus_int32 opus_projection_ambisonics_encoder_get_size(int channels, demixing_matrix_rows = mapping_matrix_toa_demixing.rows; demixing_matrix_cols = mapping_matrix_toa_demixing.cols; } + else if (order_plus_one == 5) + { + mixing_matrix_rows = mapping_matrix_fourthoa_mixing.rows; + mixing_matrix_cols = mapping_matrix_fourthoa_mixing.cols; + demixing_matrix_rows = mapping_matrix_fourthoa_demixing.rows; + demixing_matrix_cols = mapping_matrix_fourthoa_demixing.cols; + } else if (order_plus_one == 6) { mixing_matrix_rows = mapping_matrix_fifthoa_mixing.rows; @@ -252,6 +259,13 @@ int opus_projection_ambisonics_encoder_init(OpusProjectionEncoder *st, opus_int3 mapping_matrix_toa_mixing_data, sizeof(mapping_matrix_toa_mixing_data)); } + else if (order_plus_one == 5) + { + mapping_matrix_init(mixing_matrix, mapping_matrix_fourthoa_mixing.rows, + mapping_matrix_fourthoa_mixing.cols, mapping_matrix_fourthoa_mixing.gain, + mapping_matrix_fourthoa_mixing_data, + sizeof(mapping_matrix_fourthoa_mixing_data)); + } else if (order_plus_one == 6) { mapping_matrix_init(mixing_matrix, mapping_matrix_fifthoa_mixing.rows, @@ -290,6 +304,13 @@ int opus_projection_ambisonics_encoder_init(OpusProjectionEncoder *st, opus_int3 mapping_matrix_toa_demixing_data, sizeof(mapping_matrix_toa_demixing_data)); } + else if (order_plus_one == 5) + { + mapping_matrix_init(demixing_matrix, mapping_matrix_fourthoa_demixing.rows, + mapping_matrix_fourthoa_demixing.cols, mapping_matrix_fourthoa_demixing.gain, + mapping_matrix_fourthoa_demixing_data, + sizeof(mapping_matrix_fourthoa_demixing_data)); + } else if (order_plus_one == 6) { mapping_matrix_init(demixing_matrix, mapping_matrix_fifthoa_demixing.rows, diff --git a/tests/test_opus_projection.c b/tests/test_opus_projection.c index 7f19599d..9bdf86bb 100644 --- a/tests/test_opus_projection.c +++ b/tests/test_opus_projection.c @@ -231,7 +231,7 @@ void test_creation_arguments(const int channels, const int mapping_family) opus_free(matrix); } - is_channels_valid = ((order_plus_one >= 2 && order_plus_one <= 4) || order_plus_one == 6) && + is_channels_valid = (order_plus_one >= 2 && order_plus_one <= 6) && (nondiegetic_channels == 0 || nondiegetic_channels == 2); is_projection_valid = (enc_error == OPUS_OK && dec_error == OPUS_OK); if (is_channels_valid ^ is_projection_valid) |