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