From 3a7cefa4b7c957a2bfee9cee866e5328d3ef8713 Mon Sep 17 00:00:00 2001 From: jwcullen Date: Mon, 29 Jul 2024 17:33:43 -0400 Subject: [PATCH] No public description PiperOrigin-RevId: 657328713 --- .../cli/proto_to_obu/audio_frame_generator.cc | 35 ++++++------------- iamf/cli/proto_to_obu/audio_frame_generator.h | 5 --- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/iamf/cli/proto_to_obu/audio_frame_generator.cc b/iamf/cli/proto_to_obu/audio_frame_generator.cc index b8700a78..5a0e1337 100644 --- a/iamf/cli/proto_to_obu/audio_frame_generator.cc +++ b/iamf/cli/proto_to_obu/audio_frame_generator.cc @@ -174,9 +174,6 @@ absl::Status InitializeSubstreamData( const absl::flat_hash_map>& substream_id_to_encoder, const uint32_t user_samples_to_trim_at_start, - const uint32_t user_samples_to_trim_at_end, - absl::flat_hash_map& - substream_id_to_user_samples_trim_end, absl::flat_hash_map& substream_id_to_substream_data) { // Validate user start trim is correct; it depends on the encoder. Insert @@ -196,14 +193,6 @@ absl::Status InitializeSubstreamData( RETURN_IF_NOT_OK(ValidateUserStartTrim(user_samples_to_trim_at_start, encoder_required_samples_to_delay)); - // Track number of samples requested and prevent trimming samples the user - // did not request. Although an error will be thrown later as it creates an - // invalid IAMF stream. - // All substreams in the same Audio Element have the same user trim - // applied. - substream_id_to_user_samples_trim_end[substream_id] = - user_samples_to_trim_at_end; - // Initialize a `SubstreamData` with virtual samples for any delay // introduced by the encoder. auto& substream_data_for_id = substream_id_to_substream_data[substream_id]; @@ -282,8 +271,8 @@ absl::Status GetNextFrameSubstreamData( const DecodedUleb128 audio_element_id, const DemixingModule& demixing_module, const size_t num_samples_per_frame, const SubstreamIdLabelsMap& substream_id_to_labels, - const absl::flat_hash_map& - substream_id_to_user_samples_trim_end, + const absl::flat_hash_map& + substream_id_to_trimming_state, LabelSamplesMap& label_to_samples, ParametersManager& parameters_manager, absl::flat_hash_map& substream_id_to_substream_data, @@ -313,7 +302,8 @@ absl::Status GetNextFrameSubstreamData( uint32_t num_samples_to_pad_at_end; RETURN_IF_NOT_OK(GetNumSamplesToPadAtEndAndValidate( num_samples_per_frame - substream_data.samples_obu.size(), - substream_id_to_user_samples_trim_end.at(substream_id), + substream_id_to_trimming_state.at(substream_id) + .user_samples_left_to_trim_at_end, num_samples_to_pad_at_end)); PadSamples(num_samples_to_pad_at_end, num_channels, @@ -363,8 +353,8 @@ absl::Status EncodeFramesForAudioElement( const DecodedUleb128 audio_element_id, const AudioElementWithData& audio_element_with_data, const DemixingModule& demixing_module, LabelSamplesMap& label_to_samples, - const absl::flat_hash_map& - substream_id_to_user_samples_trim_end, + const absl::flat_hash_map& + substream_id_to_trimming_state, ParametersManager& parameters_manager, absl::flat_hash_map>& substream_id_to_encoder, @@ -411,9 +401,8 @@ absl::Status EncodeFramesForAudioElement( RETURN_IF_NOT_OK(GetNextFrameSubstreamData( audio_element_id, demixing_module, num_samples_per_frame, audio_element_with_data.substream_id_to_labels, - substream_id_to_user_samples_trim_end, label_to_samples, - parameters_manager, substream_id_to_substream_data, - down_mixing_params)); + substream_id_to_trimming_state, label_to_samples, parameters_manager, + substream_id_to_substream_data, down_mixing_params)); more_samples_to_encode = false; for (const auto& [substream_id, labels] : @@ -655,8 +644,6 @@ absl::Status AudioFrameGenerator::Initialize() { InitializeSubstreamData(audio_element_with_data.substream_id_to_labels, substream_id_to_encoder_, audio_frame_metadata.samples_to_trim_at_start(), - audio_frame_metadata.samples_to_trim_at_end(), - substream_id_to_user_samples_trim_end_, substream_id_to_substream_data_)); // Validate that a `DemixingParamDefinition` is available if down-mixing @@ -721,9 +708,9 @@ absl::Status AudioFrameGenerator::AddSamples( absl::MutexLock lock(&mutex_); RETURN_IF_NOT_OK(EncodeFramesForAudioElement( audio_element_id, audio_element_with_data, demixing_module_, - labeled_samples, substream_id_to_user_samples_trim_end_, - parameters_manager_, substream_id_to_encoder_, - substream_id_to_substream_data_, global_timing_module_)); + labeled_samples, substream_id_to_trimming_state_, parameters_manager_, + substream_id_to_encoder_, substream_id_to_substream_data_, + global_timing_module_)); labeled_samples.clear(); } diff --git a/iamf/cli/proto_to_obu/audio_frame_generator.h b/iamf/cli/proto_to_obu/audio_frame_generator.h index 6cd7feba..23406357 100644 --- a/iamf/cli/proto_to_obu/audio_frame_generator.h +++ b/iamf/cli/proto_to_obu/audio_frame_generator.h @@ -187,11 +187,6 @@ class AudioFrameGenerator { // Mapping from Audio Element ID to labeled samples. absl::flat_hash_map id_to_labeled_samples_; - // Mapping from substream IDs to number of samples that the user requested - // to trim at end. - absl::flat_hash_map - substream_id_to_user_samples_trim_end_; - // Mapping from substream IDs to substream data. absl::flat_hash_map substream_id_to_substream_data_;