153a5a1b3Sopenharmony_ci/*
253a5a1b3Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
353a5a1b3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
453a5a1b3Sopenharmony_ci * you may not use this file except in compliance with the License.
553a5a1b3Sopenharmony_ci * You may obtain a copy of the License at
653a5a1b3Sopenharmony_ci *
753a5a1b3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
853a5a1b3Sopenharmony_ci *
953a5a1b3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1053a5a1b3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1153a5a1b3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1253a5a1b3Sopenharmony_ci * See the License for the specific language governing permissions and
1353a5a1b3Sopenharmony_ci * limitations under the License.
1453a5a1b3Sopenharmony_ci */
1553a5a1b3Sopenharmony_ci#ifndef foodownmixhfoo
1653a5a1b3Sopenharmony_ci#define foodownmixhfoo
1753a5a1b3Sopenharmony_ci#include <pulse/channelmap.h>
1853a5a1b3Sopenharmony_ci#include <config.h>
1953a5a1b3Sopenharmony_ci#include <pulsecore/bitset.h>
2053a5a1b3Sopenharmony_ci
2153a5a1b3Sopenharmony_ci/* formats that can be downmixed with channelMixMatrix */
2253a5a1b3Sopenharmony_citypedef enum pa_channel_layout_index {
2353a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_OTHER = -1,
2453a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_STEREO = 0,
2553a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_5POINT1,
2653a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_5POINT1POINT2,
2753a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_5POINT1POINT4,
2853a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_7POINT1,
2953a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_7POINT1POINT2,
3053a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_7POINT1POINT4,
3153a5a1b3Sopenharmony_ci    PA_CHANNEL_LAYOUT_COUNT
3253a5a1b3Sopenharmony_ci} pa_channel_layout_index_t;
3353a5a1b3Sopenharmony_ci
3453a5a1b3Sopenharmony_ci#define RESCALE_COEF 10000
3553a5a1b3Sopenharmony_ci#define SKIPPED_CHANNEL_COUNT 32
3653a5a1b3Sopenharmony_cienum channel_position_downmix {
3753a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_CENTER = PA_CHANNEL_POSITION_TOP_CENTER - SKIPPED_CHANNEL_COUNT,   /* AUX0 - AUX31 unused */
3853a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_FRONT_LEFT,           /**< Apple calls this 'Vertical Height Left' */
3953a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_FRONT_RIGHT,          /**< Apple calls this 'Vertical Height Right' */
4053a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_FRONT_CENTER,         /**< Apple calls this 'Vertical Height Center' */
4153a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_REAR_LEFT,            /**< Microsoft and Apple call this 'Top Back Left' */
4253a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_REAR_RIGHT,           /**< Microsoft and Apple call this 'Top Back Right' */
4353a5a1b3Sopenharmony_ci    PA_DOWNMIX_POSITION_TOP_REAR_CENTER,          /**< Microsoft and Apple call this 'Top Back Center' */
4453a5a1b3Sopenharmony_ci    PA_DOWNMIX_CHANNEL_MAX
4553a5a1b3Sopenharmony_ci};
4653a5a1b3Sopenharmony_ci
4753a5a1b3Sopenharmony_ciextern const uint16_t channelDownmixMatrix[PA_CHANNEL_LAYOUT_COUNT][PA_DOWNMIX_CHANNEL_MAX][PA_DOWNMIX_CHANNEL_MAX];
4853a5a1b3Sopenharmony_ci
4953a5a1b3Sopenharmony_ci/* check if input channel map is supported by downmix matrix, otherwise return PA_FORMAT_OTHER*/
5053a5a1b3Sopenharmony_cipa_channel_layout_index_t pa_channel_map_to_index(const pa_channel_map *map) PA_GCC_PURE;
5153a5a1b3Sopenharmony_ciint pa_to_downmix_position(const pa_channel_position_t channel_position);
5253a5a1b3Sopenharmony_ci
5353a5a1b3Sopenharmony_ci#endif