Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 657328713
  • Loading branch information
jwcullen committed Jul 29, 2024
1 parent a3425a7 commit 3a7cefa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
35 changes: 11 additions & 24 deletions iamf/cli/proto_to_obu/audio_frame_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ absl::Status InitializeSubstreamData(
const absl::flat_hash_map<uint32_t, std::unique_ptr<EncoderBase>>&
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<uint32_t, uint32_t>&
substream_id_to_user_samples_trim_end,
absl::flat_hash_map<uint32_t, SubstreamData>&
substream_id_to_substream_data) {
// Validate user start trim is correct; it depends on the encoder. Insert
Expand All @@ -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];
Expand Down Expand Up @@ -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<uint32_t, uint32_t>&
substream_id_to_user_samples_trim_end,
const absl::flat_hash_map<uint32_t, AudioFrameGenerator::TrimmingState>&
substream_id_to_trimming_state,
LabelSamplesMap& label_to_samples, ParametersManager& parameters_manager,
absl::flat_hash_map<uint32_t, SubstreamData>&
substream_id_to_substream_data,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<uint32_t, uint32_t>&
substream_id_to_user_samples_trim_end,
const absl::flat_hash_map<uint32_t, AudioFrameGenerator::TrimmingState>&
substream_id_to_trimming_state,
ParametersManager& parameters_manager,
absl::flat_hash_map<uint32_t, std::unique_ptr<EncoderBase>>&
substream_id_to_encoder,
Expand Down Expand Up @@ -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] :
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 0 additions & 5 deletions iamf/cli/proto_to_obu/audio_frame_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ class AudioFrameGenerator {
// Mapping from Audio Element ID to labeled samples.
absl::flat_hash_map<DecodedUleb128, LabelSamplesMap> id_to_labeled_samples_;

// Mapping from substream IDs to number of samples that the user requested
// to trim at end.
absl::flat_hash_map<uint32_t, uint32_t>
substream_id_to_user_samples_trim_end_;

// Mapping from substream IDs to substream data.
absl::flat_hash_map<uint32_t, SubstreamData> substream_id_to_substream_data_;

Expand Down

0 comments on commit 3a7cefa

Please sign in to comment.