• 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 
13 #ifndef CLI_PROTO_CONVERSION_PROTO_UTILS_H_
14 #define CLI_PROTO_CONVERSION_PROTO_UTILS_H_
15 
16 #include <memory>
17 
18 #include "absl/status/status.h"
19 #include "iamf/cli/proto/obu_header.pb.h"
20 #include "iamf/cli/proto/param_definitions.pb.h"
21 #include "iamf/cli/proto/parameter_data.pb.h"
22 #include "iamf/cli/proto/test_vector_metadata.pb.h"
23 #include "iamf/common/leb_generator.h"
24 #include "iamf/obu/demixing_info_parameter_data.h"
25 #include "iamf/obu/obu_header.h"
26 #include "iamf/obu/param_definitions.h"
27 
28 namespace iamf_tools {
29 
30 /*!\brief Copies param definitions from the corresponding protocol buffer.
31  *
32  * \param input_param_definition Input protocol buffer.
33  * \param param_definition Destination param definition.
34  * \return `absl::OkStatus()` on success. A specific status on failure.
35  */
36 absl::Status CopyParamDefinition(
37     const iamf_tools_cli_proto::ParamDefinition& input_param_definition,
38     ParamDefinition& param_definition);
39 
40 /*!\brief Returns an `ObuHeader` based on the corresponding protocol buffer.
41  *
42  * \param input_obu_header Input protocol buffer.
43  * \return Result.
44  */
45 ObuHeader GetHeaderFromMetadata(
46     const iamf_tools_cli_proto::ObuHeaderMetadata& input_obu_header);
47 
48 /*!\brief Copies `DemixingInfoParameterData` from the input protocol buffer.
49  *
50  * \param input_demixing_info_parameter_data Input protocol buffer.
51  * \param obu_demixing_param_data Reference to the result.
52  * \return `absl::OkStatus()` on success. A specific status on failure.
53  */
54 absl::Status CopyDemixingInfoParameterData(
55     const iamf_tools_cli_proto::DemixingInfoParameterData&
56         input_demixing_info_parameter_data,
57     DemixingInfoParameterData& obu_demixing_param_data);
58 
59 /*!\brief Copies `DMixPMode` to the output protocol buffer.
60  *
61  * \param obu_dmixp_mode Input `DMixPMode`.
62  * \param dmixp_mode Reference to output protocol buffer.
63  * \return `absl::OkStatus()` on success. A specific status on failure.
64  */
65 absl::Status CopyDMixPMode(DemixingInfoParameterData::DMixPMode obu_dmixp_mode,
66                            iamf_tools_cli_proto::DMixPMode& dmixp_mode);
67 
68 /*!\brief Creates a `LebGenerator` based on the input config.
69  *
70  * \param user_config An instance of a `Leb128Generator` proto, from the
71  *        `UserMetadata.TestVectorMetadata` proto.
72  * \return `LebGenerator` on success. `nullptr` if the config is invalid.
73  */
74 std::unique_ptr<LebGenerator> CreateLebGenerator(
75     const iamf_tools_cli_proto::Leb128Generator& user_config);
76 
77 }  // namespace iamf_tools
78 
79 #endif  // CLI_PROTO_CONVERSION_PROTO_UTILS_H_
80