-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PiperOrigin-RevId: 628081076
- Loading branch information
Showing
7 changed files
with
258 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2024, Alliance for Open Media. All rights reserved | ||
* | ||
* This source code is subject to the terms of the BSD 3-Clause Clear License | ||
* and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear | ||
* License was not distributed with this source code in the LICENSE file, you | ||
* can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the | ||
* Alliance for Open Media Patent License 1.0 was not distributed with this | ||
* source code in the PATENTS file, you can obtain it at | ||
* www.aomedia.org/license/patent. | ||
*/ | ||
#include "iamf/cli/renderer_factory.h" | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "iamf/cli/audio_element_with_data.h" | ||
#include "iamf/cli/renderer/audio_element_renderer_base.h" | ||
#include "iamf/obu/audio_element.h" | ||
#include "iamf/obu/leb128.h" | ||
#include "iamf/obu/mix_presentation.h" | ||
|
||
namespace iamf_tools { | ||
|
||
RendererFactoryBase::~RendererFactoryBase() {} | ||
|
||
std::unique_ptr<AudioElementRendererBase> | ||
RendererFactory::CreateRendererForLayout( | ||
const std::vector<DecodedUleb128>& audio_substream_ids, | ||
const SubstreamIdLabelsMap& substream_id_to_labels, | ||
AudioElementObu::AudioElementType audio_element_type, | ||
const AudioElementObu::AudioElementConfig& config, | ||
const Layout& loudness_layout) const { | ||
// TODO(b/332567539): Implement and return renderers depending on the input | ||
// audio element and output layout. | ||
|
||
return nullptr; | ||
} | ||
|
||
} // namespace iamf_tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2024, Alliance for Open Media. All rights reserved | ||
* | ||
* This source code is subject to the terms of the BSD 3-Clause Clear License | ||
* and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear | ||
* License was not distributed with this source code in the LICENSE file, you | ||
* can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the | ||
* Alliance for Open Media Patent License 1.0 was not distributed with this | ||
* source code in the PATENTS file, you can obtain it at | ||
* www.aomedia.org/license/patent. | ||
*/ | ||
#ifndef CLI_RENDERER_FACTORY_H_ | ||
#define CLI_RENDERER_FACTORY_H_ | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "iamf/cli/audio_element_with_data.h" | ||
#include "iamf/cli/renderer/audio_element_renderer_base.h" | ||
#include "iamf/obu/audio_element.h" | ||
#include "iamf/obu/leb128.h" | ||
#include "iamf/obu/mix_presentation.h" | ||
|
||
namespace iamf_tools { | ||
|
||
/*\!brief Abstract class to create renderers. | ||
* | ||
* This class will be used when rendering the loudness of a mix presentation | ||
* layout. The mix presentation finalizer will take in a factory and use them to | ||
* create a renderers. By taking in a factory the finalizer can be agnostic to | ||
* the collection of renderers that are being used and it what circumstances | ||
* they are used. | ||
*/ | ||
class RendererFactoryBase { | ||
public: | ||
/*\!brief Creates a renderer based on the audio element and layout. | ||
* | ||
* \param audio_substream_ids Audio susbtream IDs. | ||
* \param substream_id_to_labels Mapping of substream IDs to labels. | ||
* \param audio_element_type Type of the audio element. | ||
* \param config Configuration of the audio element. | ||
* \param loudness_layout Layout to render to. | ||
* \return Unique pointer to an audio element renderer or `nullptr` if it not | ||
* known how to render the audio element. | ||
*/ | ||
virtual std::unique_ptr<AudioElementRendererBase> CreateRendererForLayout( | ||
const std::vector<DecodedUleb128>& audio_substream_ids, | ||
const SubstreamIdLabelsMap& substream_id_to_labels, | ||
AudioElementObu::AudioElementType audio_element_type, | ||
const AudioElementObu::AudioElementConfig& config, | ||
const Layout& loudness_layout) const = 0; | ||
|
||
/*\!brief Destructor. */ | ||
virtual ~RendererFactoryBase() = 0; | ||
}; | ||
|
||
/*\!brief Factory which creates a renderers. | ||
* | ||
* This factory provides renderers in a best-effort manner according to the | ||
* recommendations in the IAMF specification. When a recommended renderer is not | ||
* implemented by `iamf-tools` the factory will fallback to returning a | ||
* `nullptr`. | ||
*/ | ||
class RendererFactory : public RendererFactoryBase { | ||
public: | ||
/*\!brief Creates a renderer based on the audio element and layout. | ||
* | ||
* \param audio_substream_ids Audio susbtream IDs. | ||
* \param substream_id_to_labels Mapping of substream IDs to labels. | ||
* \param audio_element_type Type of the audio element. | ||
* \param config Configuration of the audio element. | ||
* \param loudness_layout Layout to render to. | ||
* \return Unique pointer to an audio element renderer or `nullptr` if it not | ||
* known how to render the audio element. | ||
*/ | ||
std::unique_ptr<AudioElementRendererBase> CreateRendererForLayout( | ||
const std::vector<DecodedUleb128>& audio_substream_ids, | ||
const SubstreamIdLabelsMap& substream_id_to_labels, | ||
AudioElementObu::AudioElementType audio_element_type, | ||
const AudioElementObu::AudioElementConfig& config, | ||
const Layout& loudness_layout) const override; | ||
|
||
/*\!brief Destructor. */ | ||
~RendererFactory() override = default; | ||
}; | ||
|
||
} // namespace iamf_tools | ||
|
||
#endif // CLI_LOUDNESS_CALCULATOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (c) 2024, Alliance for Open Media. All rights reserved | ||
* | ||
* This source code is subject to the terms of the BSD 3-Clause Clear License | ||
* and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear | ||
* License was not distributed with this source code in the LICENSE file, you | ||
* can obtain it at www.aomedia.org/license/software-license/bsd-3-c-c. If the | ||
* Alliance for Open Media Patent License 1.0 was not distributed with this | ||
* source code in the PATENTS file, you can obtain it at | ||
* www.aomedia.org/license/patent. | ||
*/ | ||
#include "iamf/cli/renderer_factory.h" | ||
|
||
#include "gtest/gtest.h" | ||
#include "iamf/cli/proto/obu_header.pb.h" | ||
#include "iamf/cli/proto/parameter_data.pb.h" | ||
#include "iamf/cli/proto/temporal_delimiter.pb.h" | ||
#include "iamf/cli/proto/user_metadata.pb.h" | ||
#include "iamf/obu/audio_element.h" | ||
#include "iamf/obu/mix_presentation.h" | ||
|
||
namespace iamf_tools { | ||
namespace { | ||
|
||
using enum LoudspeakersSsConventionLayout::SoundSystem; | ||
using enum ChannelAudioLayerConfig::LoudspeakerLayout; | ||
|
||
const Layout kMonoLayout = { | ||
.layout_type = Layout::kLayoutTypeLoudspeakersSsConvention, | ||
.specific_layout = | ||
LoudspeakersSsConventionLayout{.sound_system = kSoundSystem12_0_1_0}}; | ||
const Layout kBinauralLayout = {.layout_type = Layout::kLayoutTypeBinaural}; | ||
|
||
const ScalableChannelLayoutConfig kMonoScalableChannelLayoutConfig = { | ||
.num_layers = 1, | ||
.channel_audio_layer_configs = {{.loudspeaker_layout = kLayoutMono}}}; | ||
|
||
const ScalableChannelLayoutConfig kStereoScalableChannelLayoutConfig = { | ||
.num_layers = 1, | ||
.channel_audio_layer_configs = {{.loudspeaker_layout = kLayoutStereo}}}; | ||
|
||
const AmbisonicsConfig kFullZerothOrderAmbisonicsConfig = { | ||
.ambisonics_mode = AmbisonicsConfig::kAmbisonicsModeMono, | ||
.ambisonics_config = AmbisonicsMonoConfig{.output_channel_count = 1, | ||
.substream_count = 1, | ||
.channel_mapping = {0}}}; | ||
|
||
TEST(CreateRendererForLayout, ReturnsNullPtrForPassThroughRenderer) { | ||
const RendererFactory factory; | ||
|
||
EXPECT_EQ(factory.CreateRendererForLayout( | ||
{0}, {{0, {"M"}}}, AudioElementObu::kAudioElementChannelBased, | ||
kMonoScalableChannelLayoutConfig, kMonoLayout), | ||
nullptr); | ||
} | ||
|
||
TEST(CreateRendererForLayout, ReturnsNullPtrForChannelToBinauralRenderer) { | ||
const RendererFactory factory; | ||
|
||
EXPECT_EQ(factory.CreateRendererForLayout( | ||
{0}, {{0, {"M"}}}, AudioElementObu::kAudioElementChannelBased, | ||
kMonoScalableChannelLayoutConfig, kBinauralLayout), | ||
nullptr); | ||
} | ||
|
||
TEST(CreateRendererForLayout, ReturnsNullPtrForChannelToChannelRenderer) { | ||
const RendererFactory factory; | ||
|
||
EXPECT_EQ( | ||
factory.CreateRendererForLayout( | ||
{0}, {{0, {"L2", "R2"}}}, AudioElementObu::kAudioElementChannelBased, | ||
kStereoScalableChannelLayoutConfig, kMonoLayout), | ||
nullptr); | ||
} | ||
|
||
TEST(CreateRendererForLayout, ReturnsNullPtrForAmbisonicsToChannelRenderer) { | ||
const RendererFactory factory; | ||
|
||
EXPECT_EQ(factory.CreateRendererForLayout( | ||
{0}, {{0, {"A0"}}}, AudioElementObu::kAudioElementSceneBased, | ||
kFullZerothOrderAmbisonicsConfig, kMonoLayout), | ||
nullptr); | ||
} | ||
|
||
TEST(CreateRendererForLayout, ReturnsNullPtrForAmbisonicsToBinauralRenderer) { | ||
const RendererFactory factory; | ||
|
||
EXPECT_EQ(factory.CreateRendererForLayout( | ||
{0}, {{0, {"A0"}}}, AudioElementObu::kAudioElementSceneBased, | ||
kFullZerothOrderAmbisonicsConfig, kBinauralLayout), | ||
nullptr); | ||
} | ||
|
||
} // namespace | ||
} // namespace iamf_tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters