1// Copyright (c) 2023, Alliance for Open Media. All rights reserved 2// 3// This source code is subject to the terms of the BSD 3-Clause Clear License 4// and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear 5// License was not distributed with this source code in the LICENSE file, you 6// can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the 7// Alliance for Open Media Patent License 1.0 was not distributed with this 8// source code in the PATENTS file, you can obtain it at 9// www.aomedia.org/license/patent. 10 11syntax = "proto2"; 12 13package iamf_tools_cli_proto; 14 15import "iamf/cli/proto/obu_header.proto"; 16 17// Valid proto enums start at index 1, which are different from the 18// corresponding enums in C++, e.g. kLpcmBigEndian = 0. 19enum LpcmFormatFlags { 20 LPCM_INVALID = 0; 21 LPCM_BIG_ENDIAN = 1; 22 LPCM_LITTLE_ENDIAN = 2; 23} 24 25message LpcmDecoderConfig { 26 optional LpcmFormatFlags sample_format_flags = 1; 27 optional uint32 sample_size = 2; 28 optional uint32 sample_rate = 3; 29} 30 31enum OpusApplicationFlag { 32 APPLICATION_INVALID = 0; 33 APPLICATION_VOIP = 1; 34 APPLICATION_AUDIO = 2; 35 APPLICATION_RESTRICTED_LOWDELAY = 3; 36} 37 38// Settings to configure `libopus`. 39message OpusEncoderMetadata { 40 optional OpusApplicationFlag application = 2; 41 optional bool use_float_api = 3 [default = true]; 42 43 // Fields to control the bitrate. 44 // 45 // - If the substream is present in `substream_id_to_bitrate_override`, the 46 // bitrate override is used. 47 // - Otherwise a bitrate is calculated based on the number of channels. 48 // - One channel: `target_bitrate_per_channel`. 49 // - Two channels: `target_bitrate_per_channel * 2 * 50 // coupling_rate_adjustment`. 51 optional int32 target_bitrate_per_channel = 1; 52 optional float coupling_rate_adjustment = 4 [default = 1.0]; 53 map<uint32, int32> substream_id_to_bitrate_override = 5; 54} 55 56message OpusDecoderConfig { 57 optional uint32 version = 1; 58 optional uint32 output_channel_count = 2 [default = 2]; 59 optional uint32 pre_skip = 3; 60 optional uint32 input_sample_rate = 4; 61 optional int32 output_gain = 5 [default = 0]; 62 optional uint32 mapping_family = 6 [default = 0]; 63 optional OpusEncoderMetadata opus_encoder_metadata = 7; 64} 65 66enum SampleFrequencyIndex { 67 AAC_SAMPLE_FREQUENCY_INDEX_INVALID = 0; 68 AAC_SAMPLE_FREQUENCY_INDEX_96000 = 1; 69 AAC_SAMPLE_FREQUENCY_INDEX_88200 = 2; 70 AAC_SAMPLE_FREQUENCY_INDEX_64000 = 3; 71 AAC_SAMPLE_FREQUENCY_INDEX_48000 = 4; 72 AAC_SAMPLE_FREQUENCY_INDEX_44100 = 5; 73 AAC_SAMPLE_FREQUENCY_INDEX_32000 = 6; 74 AAC_SAMPLE_FREQUENCY_INDEX_24000 = 7; 75 AAC_SAMPLE_FREQUENCY_INDEX_22050 = 8; 76 AAC_SAMPLE_FREQUENCY_INDEX_16000 = 9; 77 AAC_SAMPLE_FREQUENCY_INDEX_12000 = 10; 78 AAC_SAMPLE_FREQUENCY_INDEX_11025 = 11; 79 AAC_SAMPLE_FREQUENCY_INDEX_8000 = 12; 80 AAC_SAMPLE_FREQUENCY_INDEX_7350 = 13; 81 AAC_SAMPLE_FREQUENCY_INDEX_RESERVED_A = 14; 82 AAC_SAMPLE_FREQUENCY_INDEX_RESERVED_B = 15; 83 AAC_SAMPLE_FREQUENCY_INDEX_ESCAPE_VALUE = 16; 84} 85 86// Settings to configure `fdk_aac`. 87message AacEncoderMetadata { 88 optional int32 bitrate_mode = 1; 89 optional bool enable_afterburner = 2 [default = true]; 90 optional int32 signaling_mode = 3 [default = 2]; 91} 92 93message AacDecoderSpecificInfo { 94 optional uint32 decoder_specific_info_descriptor_tag = 5 [default = 0x05]; 95 optional uint32 audio_object_type = 1 [default = 2]; 96 optional SampleFrequencyIndex sample_frequency_index = 2; 97 optional uint32 sampling_frequency = 3; 98 optional uint32 channel_configuration = 4 [default = 2]; 99 100 // Next ID: 6 101} 102 103message AacGaSpecificConfig { 104 optional bool frame_length_flag = 1 [default = false]; 105 optional bool depends_on_core_coder = 2 [default = false]; 106 optional bool extension_flag = 3 [default = false]; 107} 108 109message AacDecoderConfig { 110 optional uint32 decoder_config_descriptor_tag = 11 [default = 0x04]; 111 optional uint32 object_type_indication = 1 [default = 0x40]; 112 optional uint32 stream_type = 2 [default = 5]; 113 optional bool upstream = 3 [default = false]; 114 optional bool reserved = 4 [default = true]; // As per ISO 14496-1:2010. 115 optional uint32 buffer_size_db = 5; 116 optional uint32 max_bitrate = 6; 117 optional uint32 average_bit_rate = 7; 118 optional AacDecoderSpecificInfo decoder_specific_info = 8; 119 optional AacGaSpecificConfig ga_specific_config = 9; 120 optional AacEncoderMetadata aac_encoder_metadata = 10; 121} 122 123enum FlacBlockType { 124 FLAC_BLOCK_TYPE_INVALID = 0; 125 FLAC_BLOCK_TYPE_STREAMINFO = 1; 126 FLAC_BLOCK_TYPE_PADDING = 2; 127 FLAC_BLOCK_TYPE_APPLICATION = 3; 128 FLAC_BLOCK_TYPE_SEEKTABLE = 4; 129 FLAC_BLOCK_TYPE_VORBIS_COMMENT = 5; 130 FLAC_BLOCK_TYPE_CUESHEET = 6; 131 FLAC_BLOCK_TYPE_PICTURE = 7; 132} 133 134message FlacMetaBlockHeader { 135 optional bool last_metadata_block_flag = 1; 136 optional FlacBlockType block_type = 2; 137 optional uint32 metadata_data_block_length = 3; 138} 139 140message FlacMetaBlockStreamInfo { 141 optional uint32 minimum_block_size = 1; 142 optional uint32 maximum_block_size = 2; 143 optional uint32 minimum_frame_size = 3 [default = 0]; 144 optional uint32 maximum_frame_size = 4 [default = 0]; 145 optional uint32 sample_rate = 5; 146 optional uint32 number_of_channels = 6 [default = 1]; 147 optional uint32 bits_per_sample = 7; 148 optional uint64 total_samples_in_stream = 8; 149 optional bytes md5_signature = 9 150 [default = 151 "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]; 152} 153 154// Settings to configure `libflac`. 155message FlacEncoderMetadata { 156 optional uint32 compression_level = 1; 157} 158 159message FlacMetaBlock { 160 optional FlacMetaBlockHeader header = 1; 161 oneof data { 162 FlacMetaBlockStreamInfo stream_info = 2; 163 bytes generic_block = 3; 164 } 165} 166 167message FlacDecoderConfig { 168 reserved 1, 2; 169 170 repeated FlacMetaBlock metadata_blocks = 3; 171 optional FlacEncoderMetadata flac_encoder_metadata = 4; 172} 173 174enum CodecId { 175 CODEC_ID_INVALID = 0; 176 CODEC_ID_OPUS = 0x4f707573; // "Opus" 177 CODEC_ID_LPCM = 0x6970636d; // "ipcm" 178 CODEC_ID_AAC_LC = 0x6d703461; // "mp4a" 179 CODEC_ID_FLAC = 0x664c6143; // "fLaC" 180} 181 182message CodecConfig { 183 reserved 3, 4; 184 185 optional uint32 deprecated_codec_id = 1 [deprecated = true]; 186 optional CodecId codec_id = 10; 187 optional uint32 num_samples_per_frame = 2; 188 optional int32 audio_roll_distance = 9; 189 oneof decoder_config { 190 LpcmDecoderConfig decoder_config_lpcm = 5; 191 OpusDecoderConfig decoder_config_opus = 6; 192 AacDecoderConfig decoder_config_aac = 7; 193 FlacDecoderConfig decoder_config_flac = 8; 194 } 195 196 // If true, the codec-delay related fields will be ignored and automatically 197 // determined. For example, the OpusDecoderConfig.pre_skip field will be 198 // ignored and set to the number of samples reported by the underlying encoder 199 // library. 200 optional bool automatically_override_codec_delay = 11 [default = true]; 201 202 // If true, the `audio_roll_distance` will be ignored and automatically be set 203 // to the correct value. 204 optional bool automatically_override_audio_roll_distance = 12 205 [default = true]; 206 // Next ID: 13 207} 208 209message CodecConfigObuMetadata { 210 optional uint32 codec_config_id = 1; 211 optional CodecConfig codec_config = 2; 212 optional ObuHeaderMetadata obu_header = 3; 213} 214