• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 3-Clause Clear License
5  * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
6  * License was not distributed with this source code in the LICENSE file, you
7  * can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the
8  * Alliance for Open Media Patent License 1.0 was not distributed with this
9  * source code in the PATENTS file, you can obtain it at
10  * www.aomedia.org/license/patent.
11  */
12 #ifndef CLI_INTERNAL_RENDERER_LOUDSPEAKERS_RENDERER_H_
13 #define CLI_INTERNAL_RENDERER_LOUDSPEAKERS_RENDERER_H_
14 
15 #include <vector>
16 
17 #include "absl/status/status.h"
18 #include "absl/status/statusor.h"
19 #include "absl/strings/string_view.h"
20 #include "absl/types/span.h"
21 #include "iamf/cli/channel_label.h"
22 #include "iamf/obu/audio_element.h"
23 #include "iamf/obu/demixing_info_parameter_data.h"
24 #include "iamf/obu/types.h"
25 
26 namespace iamf_tools {
27 
28 /*!\brief Looks up precomputed gains associated with the input/output layouts.
29  *
30  * \param input_key Key representing the input loudspeaker layout.
31  * \param output_key Key representing the output loudspeaker layout.
32  * \return Precomputed gains on success. A specific status on failure.
33  */
34 absl::StatusOr<std::vector<std::vector<double>>> LookupPrecomputedGains(
35     absl::string_view input_key, absl::string_view output_key);
36 
37 /*!\brief Renders channel-based samples to loudspeaker channels.
38  *
39  * \param input_samples Input samples to render.
40  * \param down_mixing_params Down-mixing parameters.
41  * \param channel_labels Labels of input channels.
42  * \param input_key Key representing the input loudspeaker layout.
43  * \param output_key Key representing the output loudspeaker layout.
44  * \param gains Gains matrix to apply to the output.
45  * \param rendered_samples Output rendered samples.
46  * \return `absl::OkStatus()` on success. A specific status on failure.
47  */
48 absl::Status RenderChannelLayoutToLoudspeakers(
49     absl::Span<const std::vector<InternalSampleType>>& input_samples,
50     const DownMixingParams& down_mixing_params,
51     const std::vector<ChannelLabel::Label>& channel_labels,
52     absl::string_view input_key, absl::string_view output_key,
53     const std::vector<std::vector<double>>& gains,
54     std::vector<InternalSampleType>& rendered_samples);
55 
56 /*!\brief Renders ambisonics samples to loudspeaker channels.
57  *
58  * \param input_samples Input samples to render.
59  * \param ambisonics_config Config for the ambisonics layout.
60  * \param gains Gains matrix to apply to the output.
61  * \param rendered_samples Output rendered samples.
62  * \return `absl::OkStatus()` on success. A specific status on failure.
63  */
64 absl::Status RenderAmbisonicsToLoudspeakers(
65     absl::Span<const std::vector<InternalSampleType>>& input_samples,
66     const AmbisonicsConfig& ambisonics_config,
67     const std::vector<std::vector<double>>& gains,
68     std::vector<InternalSampleType>& rendered_samples);
69 
70 }  // namespace iamf_tools
71 
72 #endif  // CLI_INTERNAL_RENDERER_LOUDSPEAKERS_RENDERER_H_
73