Skip to content

Commit

Permalink
Add a unique pointer wrapper to the MixGainParamDefinition field with…
Browse files Browse the repository at this point in the history
…in SubmixRenderingMetadata. This is done in order to make SubmixRenderingMetadata moveable in the non-google environment.

PiperOrigin-RevId: 700377816
  • Loading branch information
Googler authored and jwcullen committed Nov 26, 2024
1 parent 3ac9122 commit dcaf33f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions iamf/cli/rendering_mix_presentation_finalizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ absl::Status GenerateRenderingMetadataForSubmixes( // NOLINT

submix_rendering_metadata.audio_elements_in_sub_mix =
sub_mix.audio_elements;
submix_rendering_metadata.mix_gain = sub_mix.output_mix_gain;
submix_rendering_metadata.mix_gain =
std::make_unique<MixGainParamDefinition>(sub_mix.output_mix_gain);

// Data common to all audio elements and layouts.
bool requires_resampling;
Expand Down Expand Up @@ -852,10 +853,13 @@ absl::Status RenderWriteAndCalculateLoudnessForTemporalUnit(
continue;
}
std::vector<int32_t> rendered_samples;
if (submix_rendering_metadata.mix_gain == nullptr) {
return absl::InvalidArgumentError("Submix mix gain is null");
}
RETURN_IF_NOT_OK(RenderAllFramesForLayout(
layout_rendering_metadata.num_channels,
submix_rendering_metadata.audio_elements_in_sub_mix,
submix_rendering_metadata.mix_gain, id_to_labeled_frame,
*submix_rendering_metadata.mix_gain, id_to_labeled_frame,
layout_rendering_metadata.audio_element_rendering_metadata,
parameter_blocks_start, parameter_blocks_end,
submix_rendering_metadata.common_sample_rate, rendered_samples));
Expand Down Expand Up @@ -888,10 +892,13 @@ absl::Status RenderWriteAndCalculateLoudnessForTemporalUnit(
continue;
}
std::vector<int32_t> rendered_samples;
if (submix_rendering_metadata.mix_gain == nullptr) {
return absl::InvalidArgumentError("Submix mix gain is null");
}
RETURN_IF_NOT_OK(RenderAllFramesForLayout(
layout_rendering_metadata.num_channels,
submix_rendering_metadata.audio_elements_in_sub_mix,
submix_rendering_metadata.mix_gain, id_to_time_to_labeled_frame,
*submix_rendering_metadata.mix_gain, id_to_time_to_labeled_frame,
layout_rendering_metadata.audio_element_rendering_metadata,
parameter_blocks, submix_rendering_metadata.common_sample_rate,
layout_rendering_metadata.start_timestamp, rendered_samples));
Expand Down
2 changes: 1 addition & 1 deletion iamf/cli/rendering_mix_presentation_finalizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RenderingMixPresentationFinalizer {
uint8_t loudness_calculator_bit_depth;
std::vector<SubMixAudioElement> audio_elements_in_sub_mix;
// Mix gain applied to the entire submix.
MixGainParamDefinition mix_gain;
std::unique_ptr<MixGainParamDefinition> mix_gain;
// This vector will contain one LayoutRenderingMetadata per layout in the
// submix.
std::vector<LayoutRenderingMetadata> layout_rendering_metadata;
Expand Down

0 comments on commit dcaf33f

Please sign in to comment.