mapping_matrix.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (c) 2017 Google Inc.
  2. Written by Andrew Allen */
  3. /*
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. - Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  13. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  14. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  15. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  16. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  17. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  19. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  20. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  21. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. */
  24. /**
  25. * @file mapping_matrix.h
  26. * @brief Opus reference implementation mapping matrix API
  27. */
  28. #ifndef MAPPING_MATRIX_H
  29. #define MAPPING_MATRIX_H
  30. #include "opus_types.h"
  31. #include "opus_projection.h"
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. typedef struct MappingMatrix
  36. {
  37. int rows; /* number of channels outputted from matrix. */
  38. int cols; /* number of channels inputted to matrix. */
  39. int gain; /* in dB. S7.8-format. */
  40. /* Matrix cell data goes here using col-wise ordering. */
  41. } MappingMatrix;
  42. opus_int32 mapping_matrix_get_size(int rows, int cols);
  43. opus_int16 *mapping_matrix_get_data(const MappingMatrix *matrix);
  44. void mapping_matrix_init(
  45. MappingMatrix * const matrix,
  46. int rows,
  47. int cols,
  48. int gain,
  49. const opus_int16 *data,
  50. opus_int32 data_size
  51. );
  52. #ifndef DISABLE_FLOAT_API
  53. void mapping_matrix_multiply_channel_in_float(
  54. const MappingMatrix *matrix,
  55. const float *input,
  56. int input_rows,
  57. opus_val16 *output,
  58. int output_row,
  59. int output_rows,
  60. int frame_size
  61. );
  62. void mapping_matrix_multiply_channel_out_float(
  63. const MappingMatrix *matrix,
  64. const opus_val16 *input,
  65. int input_row,
  66. int input_rows,
  67. float *output,
  68. int output_rows,
  69. int frame_size
  70. );
  71. #endif /* DISABLE_FLOAT_API */
  72. void mapping_matrix_multiply_channel_in_short(
  73. const MappingMatrix *matrix,
  74. const opus_int16 *input,
  75. int input_rows,
  76. opus_val16 *output,
  77. int output_row,
  78. int output_rows,
  79. int frame_size
  80. );
  81. void mapping_matrix_multiply_channel_out_short(
  82. const MappingMatrix *matrix,
  83. const opus_val16 *input,
  84. int input_row,
  85. int input_rows,
  86. opus_int16 *output,
  87. int output_rows,
  88. int frame_size
  89. );
  90. /* Pre-computed mixing and demixing matrices for 1st to 3rd-order ambisonics.
  91. * foa: first-order ambisonics
  92. * soa: second-order ambisonics
  93. * toa: third-order ambisonics
  94. */
  95. extern const MappingMatrix mapping_matrix_foa_mixing;
  96. extern const opus_int16 mapping_matrix_foa_mixing_data[36];
  97. extern const MappingMatrix mapping_matrix_soa_mixing;
  98. extern const opus_int16 mapping_matrix_soa_mixing_data[121];
  99. extern const MappingMatrix mapping_matrix_toa_mixing;
  100. extern const opus_int16 mapping_matrix_toa_mixing_data[324];
  101. extern const MappingMatrix mapping_matrix_foa_demixing;
  102. extern const opus_int16 mapping_matrix_foa_demixing_data[36];
  103. extern const MappingMatrix mapping_matrix_soa_demixing;
  104. extern const opus_int16 mapping_matrix_soa_demixing_data[121];
  105. extern const MappingMatrix mapping_matrix_toa_demixing;
  106. extern const opus_int16 mapping_matrix_toa_demixing_data[324];
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif /* MAPPING_MATRIX_H */