1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef foodownmixhfoo
16 #define foodownmixhfoo
17 #include <pulse/channelmap.h>
18 #include <config.h>
19 #include <pulsecore/bitset.h>
20 
21 /* formats that can be downmixed with channelMixMatrix */
22 typedef enum pa_channel_layout_index {
23     PA_CHANNEL_LAYOUT_OTHER = -1,
24     PA_CHANNEL_LAYOUT_STEREO = 0,
25     PA_CHANNEL_LAYOUT_5POINT1,
26     PA_CHANNEL_LAYOUT_5POINT1POINT2,
27     PA_CHANNEL_LAYOUT_5POINT1POINT4,
28     PA_CHANNEL_LAYOUT_7POINT1,
29     PA_CHANNEL_LAYOUT_7POINT1POINT2,
30     PA_CHANNEL_LAYOUT_7POINT1POINT4,
31     PA_CHANNEL_LAYOUT_COUNT
32 } pa_channel_layout_index_t;
33 
34 #define RESCALE_COEF 10000
35 #define SKIPPED_CHANNEL_COUNT 32
36 enum channel_position_downmix {
37     PA_DOWNMIX_POSITION_TOP_CENTER = PA_CHANNEL_POSITION_TOP_CENTER - SKIPPED_CHANNEL_COUNT,   /* AUX0 - AUX31 unused */
38     PA_DOWNMIX_POSITION_TOP_FRONT_LEFT,           /**< Apple calls this 'Vertical Height Left' */
39     PA_DOWNMIX_POSITION_TOP_FRONT_RIGHT,          /**< Apple calls this 'Vertical Height Right' */
40     PA_DOWNMIX_POSITION_TOP_FRONT_CENTER,         /**< Apple calls this 'Vertical Height Center' */
41     PA_DOWNMIX_POSITION_TOP_REAR_LEFT,            /**< Microsoft and Apple call this 'Top Back Left' */
42     PA_DOWNMIX_POSITION_TOP_REAR_RIGHT,           /**< Microsoft and Apple call this 'Top Back Right' */
43     PA_DOWNMIX_POSITION_TOP_REAR_CENTER,          /**< Microsoft and Apple call this 'Top Back Center' */
44     PA_DOWNMIX_CHANNEL_MAX
45 };
46 
47 extern const uint16_t channelDownmixMatrix[PA_CHANNEL_LAYOUT_COUNT][PA_DOWNMIX_CHANNEL_MAX][PA_DOWNMIX_CHANNEL_MAX];
48 
49 /* check if input channel map is supported by downmix matrix, otherwise return PA_FORMAT_OTHER*/
50 pa_channel_layout_index_t pa_channel_map_to_index(const pa_channel_map *map) PA_GCC_PURE;
51 int pa_to_downmix_position(const pa_channel_position_t channel_position);
52 
53 #endif