Skip to content

Commit

Permalink
Add names for all reserved values for the internal representation of …
Browse files Browse the repository at this point in the history
…`loudspeaker_layout`.

  - To start making room for `expanded_loudspeaker_layout` which relates to `kLayoutReserved15`.

PiperOrigin-RevId: 654014622
  • Loading branch information
jwcullen committed Jul 19, 2024
1 parent b77fc64 commit 5b771d1
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 32 deletions.
14 changes: 9 additions & 5 deletions iamf/cli/profile_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,20 @@ absl::Status FilterChannelBasedConfig(
case kLayout3_1_2_ch:
case kLayoutBinaural:
break;
case kLayoutReservedEnd:
case kLayoutReserved10:
case kLayoutReserved11:
case kLayoutReserved12:
case kLayoutReserved13:
case kLayoutReserved14:
profile_versions.erase(ProfileVersion::kIamfSimpleProfile);
profile_versions.erase(ProfileVersion::kIamfBaseProfile);
// TODO(b/350765228): Filter out any `expanded_loudspeaker_layout` which
// are invalid under Base-enhnaced profile.
profile_versions.erase(ProfileVersion::kIamfBaseEnhancedProfile);
break;
default:
case kLayoutReserved15:
profile_versions.erase(ProfileVersion::kIamfSimpleProfile);
profile_versions.erase(ProfileVersion::kIamfBaseProfile);
profile_versions.erase(ProfileVersion::kIamfBaseEnhancedProfile);
// TODO(b/350765228): Filter out any `expanded_loudspeaker_layout` which
// are invalid under Base-enhnaced profile.
break;
}

Expand Down
4 changes: 2 additions & 2 deletions iamf/cli/proto_to_obu/audio_element_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ absl::Status CopyLoudspeakerLayout(
{LOUDSPEAKER_LAYOUT_7_1_4_CH, kLayout7_1_4_ch},
{LOUDSPEAKER_LAYOUT_3_1_2_CH, kLayout3_1_2_ch},
{LOUDSPEAKER_LAYOUT_BINAURAL, kLayoutBinaural},
{LOUDSPEAKER_LAYOUT_RESERVED_BEGIN, kLayoutReservedBegin},
{LOUDSPEAKER_LAYOUT_RESERVED_END, kLayoutReservedEnd},
{LOUDSPEAKER_LAYOUT_RESERVED_BEGIN, kLayoutReserved10},
{LOUDSPEAKER_LAYOUT_RESERVED_END, kLayoutReserved15},
});

if (!LookupInMap(*kInputLoudspeakerLayoutToOutputLoudspeakerLayout,
Expand Down
31 changes: 27 additions & 4 deletions iamf/cli/renderer/tests/renderer_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,33 @@ TEST(LookupInputChannelOrderFromScalableLoudspeakerLayout,
}

TEST(LookupInputChannelOrderFromScalableLoudspeakerLayout,
FailsForReservedLayout) {
EXPECT_FALSE(LookupInputChannelOrderFromScalableLoudspeakerLayout(
ChannelAudioLayerConfig::kLayoutReservedEnd)
.ok());
FailsForReservedLayouts10Through14) {
using enum ChannelAudioLayerConfig::LoudspeakerLayout;

EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved10)
.ok());
EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved11)
.ok());
EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved12)
.ok());
EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved13)
.ok());
EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved14)
.ok());
}

TEST(LookupInputChannelOrderFromScalableLoudspeakerLayout,
FailsForReservedLayout15) {
using enum ChannelAudioLayerConfig::LoudspeakerLayout;

EXPECT_FALSE(
LookupInputChannelOrderFromScalableLoudspeakerLayout(kLayoutReserved15)
.ok());
}

TEST(LookupOutputKeyFromPlaybackLayout, SucceedsForChannelBasedLayout) {
Expand Down
4 changes: 2 additions & 2 deletions iamf/cli/tests/demixing_module_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ TEST(InitializeForReconstruction, CreatesOneDemixerForTwoLayerStereo) {
EXPECT_EQ(demixer->size(), 1);
}

TEST(InitializeForReconstruction, InvalidForReservedLoudspeakerLayout) {
TEST(InitializeForReconstruction, InvalidForReservedLoudspeakerLayout15) {
absl::flat_hash_map<DecodedUleb128, AudioElementWithData> audio_elements;
InitAudioElementWithLabelsAndLayers(
{{0, {"MaybeLFE"}}}, {ChannelAudioLayerConfig::kLayoutReservedEnd},
{{0, {"MaybeLFE"}}}, {ChannelAudioLayerConfig::kLayoutReserved15},
audio_elements);
DemixingModule demixing_module;

Expand Down
11 changes: 5 additions & 6 deletions iamf/cli/tests/profile_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ TEST(FilterProfilesForAudioElement,
auto& first_layer =
std::get<ScalableChannelLayoutConfig>(audio_element_obu.config_)
.channel_audio_layer_configs[0];
first_layer.loudspeaker_layout =
ChannelAudioLayerConfig::kLayoutReservedBegin;
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved10;
absl::flat_hash_set<ProfileVersion> all_known_profiles =
kAllKnownProfileVersions;

Expand All @@ -125,7 +124,7 @@ TEST(FilterProfilesForAudioElement,
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutStereo;
std::get<ScalableChannelLayoutConfig>(audio_element_obu.config_)
.channel_audio_layer_configs[1]
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedBegin;
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved10;

absl::flat_hash_set<ProfileVersion> all_known_profiles =
kAllKnownProfileVersions;
Expand Down Expand Up @@ -184,7 +183,7 @@ TEST(FilterProfilesForAudioElement,
auto& first_layer =
std::get<ScalableChannelLayoutConfig>(audio_element_obu.config_)
.channel_audio_layer_configs[0];
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedEnd;
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved15;
absl::flat_hash_set<ProfileVersion> simple_profile = {kIamfSimpleProfile};

EXPECT_FALSE(ProfileFilter::FilterProfilesForAudioElement(
Expand Down Expand Up @@ -236,7 +235,7 @@ TEST(FilterProfilesForAudioElement,
auto& first_layer =
std::get<ScalableChannelLayoutConfig>(audio_element_obu.config_)
.channel_audio_layer_configs[0];
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedEnd;
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved15;
absl::flat_hash_set<ProfileVersion> base_profile = {kIamfBaseProfile};

EXPECT_FALSE(ProfileFilter::FilterProfilesForAudioElement(
Expand Down Expand Up @@ -288,7 +287,7 @@ TEST(FilterProfilesForAudioElement,
auto& first_layer =
std::get<ScalableChannelLayoutConfig>(audio_element_obu.config_)
.channel_audio_layer_configs[0];
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedEnd;
first_layer.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved15;
absl::flat_hash_set<ProfileVersion> base_enhanced_profile = {
kIamfBaseEnhancedProfile};

Expand Down
8 changes: 6 additions & 2 deletions iamf/obu/audio_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ struct ChannelAudioLayerConfig {
kLayout7_1_4_ch = 7, // L/C/R/Lss/Rss/Lrs/Rrs/Ltf/Rtf/Ltb/Rtb/LFE.
kLayout3_1_2_ch = 8, // L/C/R//Ltf/Rtf/LFE.
kLayoutBinaural = 9, // L/R.
kLayoutReservedBegin = 10,
kLayoutReservedEnd = 15,
kLayoutReserved10 = 10,
kLayoutReserved11 = 11,
kLayoutReserved12 = 12,
kLayoutReserved13 = 13,
kLayoutReserved14 = 14,
kLayoutReserved15 = 15,
};

friend bool operator==(const ChannelAudioLayerConfig& lhs,
Expand Down
149 changes: 138 additions & 11 deletions iamf/obu/tests/audio_element_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,34 +527,109 @@ TEST(ChannelAudioLayerConfig, WritesReserved10Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved10 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedBegin,
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved10,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReservedBegin
<< kLoudspeakerLayoutBitShift,
ChannelAudioLayerConfig::kLayoutReserved10 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved10.Write(wb), IsOk());

ValidateWriteResults(wb, kExpectedData);
}

TEST(ChannelAudioLayerConfig, WritesReserved11Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved11 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved11,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReserved11 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved11.Write(wb), IsOk());

ValidateWriteResults(wb, kExpectedData);
}

TEST(ChannelAudioLayerConfig, WritesReserved12Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved12 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved12,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReserved12 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved12.Write(wb), IsOk());

ValidateWriteResults(wb, kExpectedData);
}

TEST(ChannelAudioLayerConfig, WritesReserved13Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved13 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved13,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReserved13 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved13.Write(wb), IsOk());

ValidateWriteResults(wb, kExpectedData);
}

TEST(ChannelAudioLayerConfig, WritesReserved14Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved14 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved14,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReserved14 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved14.Write(wb), IsOk());

ValidateWriteResults(wb, kExpectedData);
}

TEST(ChannelAudioLayerConfig, WritesReserved15Layer) {
constexpr uint8_t kExpectedSubstreamCount = 1;
constexpr uint8_t kExpectedCoupledSubstreamCount = 1;
const ChannelAudioLayerConfig kChannelAudioLayerConfigReserved15 = {
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReservedEnd,
.loudspeaker_layout = ChannelAudioLayerConfig::kLayoutReserved15,
.output_gain_is_present_flag = false,
.recon_gain_is_present_flag = false,
.substream_count = kExpectedSubstreamCount,
.coupled_substream_count = kExpectedCoupledSubstreamCount};

const std::vector<uint8_t> kExpectedData = {
ChannelAudioLayerConfig::kLayoutReservedEnd << kLoudspeakerLayoutBitShift,
ChannelAudioLayerConfig::kLayoutReserved15 << kLoudspeakerLayoutBitShift,
kExpectedSubstreamCount, kExpectedCoupledSubstreamCount};
WriteBitBuffer wb(1024);
EXPECT_THAT(kChannelAudioLayerConfigReserved15.Write(wb), IsOk());
Expand Down Expand Up @@ -652,29 +727,81 @@ TEST(ChannelAudioLayerConfig, ReadsBinauralLayer) {
}

TEST(ChannelAudioLayerConfig, ReadsReserved10Layer) {
std::vector<uint8_t> data = {ChannelAudioLayerConfig::kLayoutReservedBegin
<< kLoudspeakerLayoutBitShift,
1, 1};
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReserved10 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReserved10);
}

TEST(ChannelAudioLayerConfig, ReadsReserved11Layer) {
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReserved11 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReserved11);
}

TEST(ChannelAudioLayerConfig, ReadsReserved12Layer) {
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReserved12 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReserved12);
}

TEST(ChannelAudioLayerConfig, ReadsReserved13Layer) {
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReserved13 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReserved13);
}

TEST(ChannelAudioLayerConfig, ReadsReserved14Layer) {
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReserved14 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReservedBegin);
ChannelAudioLayerConfig::kLayoutReserved14);
}

TEST(ChannelAudioLayerConfig, ReadsReserved15Layer) {
std::vector<uint8_t> data = {
ChannelAudioLayerConfig::kLayoutReservedEnd << kLoudspeakerLayoutBitShift,
ChannelAudioLayerConfig::kLayoutReserved15 << kLoudspeakerLayoutBitShift,
1, 1};
ReadBitBuffer buffer(1024, &data);
ChannelAudioLayerConfig config;

EXPECT_THAT(config.Read(buffer), IsOk());

EXPECT_EQ(config.loudspeaker_layout,
ChannelAudioLayerConfig::kLayoutReservedEnd);
ChannelAudioLayerConfig::kLayoutReserved15);
}

TEST(ChannelAudioLayerConfig, ReadsOutputGainIsPresentRelatedFields) {
Expand Down

0 comments on commit 5b771d1

Please sign in to comment.