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 13 #ifndef CLI_ADM_TO_USER_METADATA_ADM_ADM_ELEMENTS_H_ 14 #define CLI_ADM_TO_USER_METADATA_ADM_ADM_ELEMENTS_H_ 15 16 #include <cstddef> 17 #include <cstdint> 18 #include <optional> 19 #include <string> 20 #include <utility> 21 #include <vector> 22 23 #include "absl/strings/string_view.h" 24 25 namespace iamf_tools { 26 namespace adm_to_user_metadata { 27 28 /*!\brief Specific ADM file type, or default if no extensions are detected. */ 29 enum AdmFileType { 30 kAdmFileTypeDefault, 31 kAdmFileTypeDolby, 32 }; 33 34 // This struct holds the Audio Definition Model (ADM) elements. 35 struct ADM { 36 std::vector<struct AudioProgramme> audio_programmes; 37 std::vector<struct AudioContent> audio_contents; 38 std::vector<struct AudioObject> audio_objects; 39 std::vector<struct AudioPackFormat> audio_packs; 40 std::vector<struct AudioChannelFormat> audio_channels; 41 // Holds the ADM file type. 42 AdmFileType file_type = kAdmFileTypeDefault; 43 }; 44 45 // This structure holds the sub-elements of loudness metadata. 46 struct LoudnessMetadata { 47 static constexpr float kDefaultIntegratedLoudness = 0.0; 48 49 float integrated_loudness = kDefaultIntegratedLoudness; 50 std::optional<float> max_true_peak; 51 std::optional<float> dialogue_loudness; 52 }; 53 54 // This structure holds the reference layout of an audio programme. 55 struct ReferenceLayout { 56 std::vector<std::string> audio_pack_format_id_ref; 57 }; 58 59 // This structure holds the authoring information of an audio programme. 60 struct AuthoringInformation { 61 ReferenceLayout reference_layout; 62 }; 63 64 // This structure holds the attributes of an audio programme in ADM. 65 struct AudioProgramme { 66 std::string id; 67 std::string name; 68 std::string audio_programme_label; 69 std::vector<std::string> audio_content_id_refs; 70 LoudnessMetadata loudness_metadata; 71 AuthoringInformation authoring_information; 72 }; 73 74 // This structure holds the attributes of an audio content in ADM. 75 struct AudioContent { 76 std::string id; 77 std::string name; 78 std::vector<std::string> audio_object_id_ref; 79 }; 80 81 // This structure holds the attributes of an audio object in ADM. 82 struct AudioObject { 83 static constexpr absl::string_view kDefaultLocalizedElementAnnotations = 84 "test_sub_mix_0_audio_element_0"; 85 static constexpr int32_t kDefaultADMImportance = 10; 86 static constexpr float kDefaultADMGain = 0.0; 87 88 std::string id; 89 std::string name; 90 std::string audio_object_label = 91 std::string(kDefaultLocalizedElementAnnotations); 92 int32_t importance = kDefaultADMImportance; 93 float gain = kDefaultADMGain; 94 std::vector<std::string> audio_pack_format_id_refs; 95 std::vector<std::string> audio_comple_object_id_ref; 96 std::vector<std::string> audio_track_uid_ref; 97 }; 98 99 // This structure holds the attributes of an audio pack format in ADM. 100 struct AudioPackFormat { 101 std::string id; 102 std::string name; 103 std::string audio_pack_label; 104 105 // A vector to map the channel ID refs to their corresponding indices. 106 std::vector<std::pair<std::string, size_t>> audio_channel_format_id_refs_map; 107 }; 108 109 // This structure holds cartesian position associated with an audio block. 110 struct CartesianPosition { 111 float x; 112 float y; 113 float z; 114 }; 115 116 struct BlockTime { 117 int hour = 0; 118 int minute = 0; 119 double second = 0.0; 120 }; 121 122 // This structure holds the attributes of an audio block format in ADM. 123 struct AudioBlockFormat { 124 static constexpr float kDefaultBlockGain = 1.0f; 125 std::string id; 126 std::string name; 127 BlockTime rtime; 128 BlockTime duration; 129 float gain = kDefaultBlockGain; 130 CartesianPosition position; 131 }; 132 133 // This structure holds the attributes of an audio channel format in ADM. 134 struct AudioChannelFormat { 135 std::string id; 136 std::string name; 137 std::string audio_channel_label; 138 std::vector<AudioBlockFormat> audio_blocks; 139 }; 140 141 } // namespace adm_to_user_metadata 142 } // namespace iamf_tools 143 144 #endif // CLI_ADM_TO_USER_METADATA_ADM_ADM_ELEMENTS_H_ 145