• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024, 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_RENDERER_RENDERER_UTILS_H_
13 #define CLI_RENDERER_RENDERER_UTILS_H_
14 #include <cstddef>
15 #include <string>
16 #include <vector>
17 
18 #include "absl/status/status.h"
19 #include "absl/status/statusor.h"
20 #include "iamf/cli/channel_label.h"
21 #include "iamf/cli/demixing_module.h"
22 #include "iamf/obu/mix_presentation.h"
23 #include "iamf/obu/types.h"
24 
25 namespace iamf_tools {
26 
27 namespace renderer_utils {
28 
29 /*!\brief Arranges the samples to be rendered in (time, channel) axes.
30  *
31  * \param labeled_frame Labeled frame determine which original or demixed
32  *        samples to trim and render.
33  * \param ordered_labels Ordered list of original labels. Samples are arranged
34  *        based on the original or demixed label samples in each time tick.
35  *        Slots corresponding with `ChannelLabel::Label::kOmitted` will create
36  *        zeroed-out samples.
37  * \param samples_to_render Output samples to render in (time, channel) axes.
38  *        Samples which should be trimmed are omitted from the output.
39  * \return `absl::OkStatus()` on success. A specific status on failure.
40  */
41 absl::Status ArrangeSamplesToRender(
42     const LabeledFrame& labeled_frame,
43     const std::vector<ChannelLabel::Label>& ordered_labels,
44     std::vector<std::vector<InternalSampleType>>& samples_to_render,
45     size_t& num_valid_samples);
46 
47 /*!\brief Gets a key associated with the playback layout.
48  *
49  * The output key is the layout name of sound systems described in [ITU2051-3],
50  * e.g. "0+2+0", "4+7+0".
51  *
52  * \param output_layout Layout to get key from.
53  * \return Key associated with the layout. Or a specific status on failure.
54  */
55 absl::StatusOr<std::string> LookupOutputKeyFromPlaybackLayout(
56     const Layout& output_layout);
57 
58 }  // namespace renderer_utils
59 
60 }  // namespace iamf_tools
61 #endif  // CLI_RENDERER_RENDERER_UTILS_H_
62