• 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 
13 #include "iamf/cli/user_metadata_builder/iamf_input_layout.h"
14 
15 #include "absl/base/no_destructor.h"
16 #include "absl/container/flat_hash_map.h"
17 #include "absl/status/statusor.h"
18 #include "absl/strings/string_view.h"
19 #include "iamf/common/utils/map_utils.h"
20 
21 namespace iamf_tools {
22 
LookupInputLayoutFromAudioPackFormatId(absl::string_view audio_pack_format_id)23 absl::StatusOr<IamfInputLayout> LookupInputLayoutFromAudioPackFormatId(
24     absl::string_view audio_pack_format_id) {
25   // Map which holds the audioPackFormatID in ADM and the corresponding
26   // loudspeaker layout in IAMF.
27   using enum IamfInputLayout;
28   static const absl::NoDestructor<
29       absl::flat_hash_map<absl::string_view, IamfInputLayout>>
30       kAudioPackFormatIdToIamfInputLayoutInputLayout({
31           {"AP_00010001", IamfInputLayout::kMono},
32           {"AP_00010002", IamfInputLayout::kStereo},
33           {"AP_00010003", IamfInputLayout::k5_1},
34           {"AP_00010004", IamfInputLayout::k5_1_2},
35           {"AP_00010005", IamfInputLayout::k5_1_4},
36           {"AP_0001000f", IamfInputLayout::k7_1},
37           {"AP_00010017", IamfInputLayout::k7_1_4},
38           {"AP_00050001", IamfInputLayout::kBinaural},
39           {"AP_00011FFF", IamfInputLayout::kLFE},
40           {"AP_00040001", IamfInputLayout::kAmbisonicsOrder1},
41           {"AP_00040002", IamfInputLayout::kAmbisonicsOrder2},
42           {"AP_00040003", IamfInputLayout::kAmbisonicsOrder3},
43       });
44 
45   return LookupInMap(*kAudioPackFormatIdToIamfInputLayoutInputLayout,
46                      audio_pack_format_id,
47                      "`IamfInputLayout` for `audio_pack_format_id`");
48 }
49 
50 }  // namespace iamf_tools
51