1/*
2Copyright 2018 Google Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS-IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#include "dsp/channel_converter.h"
18
19#include <cmath>
20
21#include "base/constants_and_types.h"
22#include "base/logging.h"
23#include "base/simd_utils.h"
24
25namespace vraudio {
26
27void ConvertStereoFromMono(const AudioBuffer& input, AudioBuffer* output) {
28 DCHECK(output);
29 DCHECK_EQ(input.num_channels(), kNumMonoChannels);
30 DCHECK_EQ(output->num_channels(), kNumStereoChannels);
31 DCHECK_EQ(input.num_frames(), output->num_frames());
32 StereoFromMonoSimd(length: input.num_frames(), mono: &input[0][0], left: &(*output)[0][0],
33 right: &(*output)[1][0]);
34}
35
36void ConvertMonoFromStereo(const AudioBuffer& input, AudioBuffer* output) {
37 DCHECK(output);
38 DCHECK_EQ(input.num_channels(), kNumStereoChannels);
39 DCHECK_EQ(output->num_channels(), kNumMonoChannels);
40 DCHECK_EQ(input.num_frames(), output->num_frames());
41 MonoFromStereoSimd(length: input.num_frames(), left: &input[0][0], right: &input[1][0],
42 mono: &(*output)[0][0]);
43}
44
45} // namespace vraudio
46

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/dsp/channel_converter.cc