From e449dbd15dd79ceb53d6bdacdfea0657774f4608 Mon Sep 17 00:00:00 2001 From: flim Date: Tue, 18 Jun 2024 14:54:29 -0400 Subject: [PATCH] Fill in remaining absl::Status messages (1/4). PiperOrigin-RevId: 644465424 --- iamf/cli/cli_util.cc | 36 ++++++++++++------------- iamf/cli/encoder_main_lib.cc | 8 +++--- iamf/cli/parameter_block_partitioner.cc | 12 ++++----- iamf/cli/parameters_manager.cc | 6 ++--- iamf/common/obu_util.h | 10 ++++--- iamf/obu/audio_element.cc | 3 ++- iamf/obu/codec_config.h | 3 ++- iamf/obu/param_definitions.cc | 24 ++++++++--------- iamf/obu/parameter_block.cc | 21 ++++++++++----- iamf/obu/parameter_block.h | 3 ++- 10 files changed, 69 insertions(+), 57 deletions(-) diff --git a/iamf/cli/cli_util.cc b/iamf/cli/cli_util.cc index 51586dfc..6e21c47b 100644 --- a/iamf/cli/cli_util.cc +++ b/iamf/cli/cli_util.cc @@ -67,10 +67,10 @@ absl::Status CopyParamDefinition( if (input_param_definition.num_subblocks() < input_param_definition.subblock_durations_size()) { - LOG(ERROR) << "Expected at least " << input_param_definition.num_subblocks() - << "subblock durations for parameter id: " - << input_param_definition.parameter_id(); - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Expected at least ", input_param_definition.num_subblocks(), + "subblock durations for parameter id = ", + input_param_definition.parameter_id())); } param_definition.InitializeSubblockDurations( @@ -137,7 +137,9 @@ absl::Status CopyDemixingInfoParameterData( dmixp_mode = kDMixPModeReserved2; break; default: - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + absl::StrCat("Unknown dmixp_mode = ", + input_demixing_info_parameter_data.dmixp_mode())); } RETURN_IF_NOT_OK(Uint32ToUint8(input_demixing_info_parameter_data.reserved(), obu_demixing_param_data.reserved)); @@ -172,9 +174,9 @@ absl::Status GetIncludeTemporalDelimiterObus( ia_sequence_header_obu.GetPrimaryProfile()) && !ProfileSupportsTemporalDelimiterObus( ia_sequence_header_obu.GetAdditionalProfile()))) { - LOG(ERROR) << "Temporal Delimiter OBUs need either `primary_profile` or " - "`additional_profile` to support them."; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + "Temporal Delimiter OBUs need either `primary_profile` or " + "`additional_profile` to support them."); } include_temporal_delimiter = input_include_temporal_delimiter; return absl::OkStatus(); @@ -192,9 +194,8 @@ absl::Status CollectAndValidateParamDefinitions( const auto [iter, inserted] = param_definitions.insert({parameter_id, param_definition}); if (!inserted && *iter->second != *param_definition) { - LOG(ERROR) << "Inequivalent `param_definition_mode` for id= " - << parameter_id; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Inequivalent `param_definition_mode` for id = ", parameter_id)); } return absl::OkStatus(); @@ -211,9 +212,9 @@ absl::Status CollectAndValidateParamDefinitions( ParamDefinition::kParameterDefinitionDemixing && param_definition_type != ParamDefinition::kParameterDefinitionReconGain) { - LOG(ERROR) << "Param definition type: " << param_definition_type - << " not allowed in an audio element"; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + absl::StrCat("Param definition type = ", param_definition_type, + " not allowed in an audio element")); } RETURN_IF_NOT_OK(insert_and_check_equivalence( audio_element_param.param_definition.get())); @@ -358,10 +359,9 @@ absl::Status GetCommonSamplesPerFrame( } if (common_samples_per_frame != codec_config_obu.GetNumSamplesPerFrame()) { - LOG(ERROR) - << "The encoder does not support Codec Config OBUs with a different " - "number of samples per frame yet."; - return absl::UnknownError(""); + return absl::UnknownError( + "The encoder does not support Codec Config OBUs with a different " + "number of samples per frame yet."); } } diff --git a/iamf/cli/encoder_main_lib.cc b/iamf/cli/encoder_main_lib.cc index dcf6a9ae..b82342f6 100644 --- a/iamf/cli/encoder_main_lib.cc +++ b/iamf/cli/encoder_main_lib.cc @@ -228,8 +228,8 @@ absl::Status CreateOutputDirectory(const std::string& output_directory) { std::error_code error_code; if (!std::filesystem::create_directories(output_directory, error_code)) { - LOG(ERROR) << "Failed to create output directory: " << output_directory; - return absl::UnknownError(""); + return absl::UnknownError( + absl::StrCat("Failed to create output directory = ", output_directory)); } return absl::OkStatus(); @@ -267,8 +267,8 @@ absl::Status GenerateObus( std::list& arbitrary_obus) { // IA Sequence Header OBU. Only one is allowed. if (user_metadata.ia_sequence_header_metadata_size() != 1) { - LOG(ERROR) << "Only one IA Sequence Header allowed in an IA Sequence."; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + "Only one IA Sequence Header allowed in an IA Sequence."); } IaSequenceHeaderGenerator ia_sequence_header_generator( user_metadata.ia_sequence_header_metadata(0)); diff --git a/iamf/cli/parameter_block_partitioner.cc b/iamf/cli/parameter_block_partitioner.cc index 60dbc027..62861609 100644 --- a/iamf/cli/parameter_block_partitioner.cc +++ b/iamf/cli/parameter_block_partitioner.cc @@ -145,14 +145,14 @@ absl::Status PartitionMixGain( } // TODO(b/279581032): Carefully split the bezier curve. Be careful with // Q7.8 format. - LOG(ERROR) << "The encoder does not fully support partitioning bezier " - "parameters yet."; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "The encoder does not fully support partitioning bezier ", + "parameters yet.")); } default: - LOG(ERROR) << "Unrecognized animation type: " - << subblock_mix_gain.animation_type(); - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + absl::StrCat("Unrecognized animation type = ", + subblock_mix_gain.animation_type())); } } diff --git a/iamf/cli/parameters_manager.cc b/iamf/cli/parameters_manager.cc index b8141cb7..eeefb163 100644 --- a/iamf/cli/parameters_manager.cc +++ b/iamf/cli/parameters_manager.cc @@ -44,9 +44,9 @@ absl::Status ParametersManager::Initialize() { } if (demixing_param_definition != nullptr) { - LOG(ERROR) << "Not allowed to have multiple demixing parameters in a " - "single Audio Element."; - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + "Not allowed to have multiple demixing parameters in a " + "single Audio Element."); } demixing_param_definition = diff --git a/iamf/common/obu_util.h b/iamf/common/obu_util.h index 9725771a..ed4c5918 100644 --- a/iamf/common/obu_util.h +++ b/iamf/common/obu_util.h @@ -220,7 +220,8 @@ absl::Status LookupInMap(const absl::flat_hash_map& map, T key, U& value) { auto iter = map.find(key); if (iter == map.end()) { - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + absl::StrCat("Key = ", key, " not found in the map.")); } value = iter->second; return absl::OkStatus(); @@ -390,7 +391,9 @@ absl::Status InterpolateMixGainValue( int16_t& target_mix_gain) { if (target_time < start_time || target_time > end_time || start_time > end_time) { - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Cannot interpolate mix gain value with start time = ", start_time, + ", target_time = ", target_time, " and end_time = ", end_time)); } // Shift times so start_time=0 to simplify calculations. @@ -434,7 +437,8 @@ absl::Status InterpolateMixGainValue( (1 - a) * (1 - a) * p_0 + 2 * (1 - a) * a * p_1 + a * a * p_2; RETURN_IF_NOT_OK(FloatToQ7_8(target_mix_gain_float, target_mix_gain)); } else { - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError( + absl::StrCat("Unknown animation_type = ", animation_type)); } return absl::OkStatus(); diff --git a/iamf/obu/audio_element.cc b/iamf/obu/audio_element.cc index 910cbfa0..a4961c43 100644 --- a/iamf/obu/audio_element.cc +++ b/iamf/obu/audio_element.cc @@ -159,7 +159,8 @@ absl::Status ValidateOutputChannelCount(const uint8_t channel_count) { return absl::OkStatus(); } - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Invalid Ambisonics output channel_count = ", channel_count)); } // Writes an element of the `audio_element_params` array of a scalable channel diff --git a/iamf/obu/codec_config.h b/iamf/obu/codec_config.h index a43b3785..c5485b08 100644 --- a/iamf/obu/codec_config.h +++ b/iamf/obu/codec_config.h @@ -182,7 +182,8 @@ class CodecConfigObu : public ObuBase { uint8_t bit_depth_to_measure_loudness_ = 0; // Tracks whether the OBU was initialized correctly. - absl::Status init_status_ = absl::UnknownError(""); + absl::Status init_status_ = + absl::UnknownError("Codec Config OBU was not initialized correctly."); /*!\brief Writes the OBU payload to the buffer. * diff --git a/iamf/obu/param_definitions.cc b/iamf/obu/param_definitions.cc index caad1f4d..1e255533 100644 --- a/iamf/obu/param_definitions.cc +++ b/iamf/obu/param_definitions.cc @@ -120,10 +120,9 @@ DecodedUleb128 ParamDefinition::GetSubblockDuration(int subblock_index) const { absl::Status ParamDefinition::SetSubblockDuration(int subblock_index, DecodedUleb128 duration) { if (subblock_index > subblock_durations_.size()) { - LOG(ERROR) << "Subblock index " << subblock_index - << " greater than `subblock_durations_.size()`= " - << subblock_durations_.size(); - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Subblock index greater than `subblock_durations_.size()`= ", + subblock_durations_.size())); } subblock_durations_[subblock_index] = duration; @@ -227,9 +226,8 @@ absl::Status ParamDefinition::Validate() const { // these are defined directly in the Parameter Block OBU. if (param_definition_mode_ == 0) { if (duration_ == 0) { - LOG(ERROR) << "Duration should not be zero. Parameter ID= " - << parameter_id; - status = absl::InvalidArgumentError(""); + status = absl::InvalidArgumentError(absl::StrCat( + "Duration should not be zero. Parameter ID = ", parameter_id)); } // Check if the `subblock_durations` is included. @@ -241,9 +239,9 @@ absl::Status ParamDefinition::Validate() const { uint32_t total_subblock_durations = 0; for (int i = 0; i < num_subblocks_; i++) { if (subblock_durations_[i] == 0) { - LOG(ERROR) << "Illegal zero duration for subblock[" << i << "]. " - << "Parameter ID= " << parameter_id; - status = absl::InvalidArgumentError(""); + status = absl::InvalidArgumentError( + absl::StrCat("Illegal zero duration for subblock[", i, "]. ", + "Parameter ID = ", parameter_id)); } RETURN_IF_NOT_OK(AddUint32CheckOverflow(total_subblock_durations, @@ -253,9 +251,9 @@ absl::Status ParamDefinition::Validate() const { // Check total duration matches expected duration. if (total_subblock_durations != duration_) { - LOG(ERROR) << "Inconsistent total duration and the cumulative " - << "durations of subblocks. Parameter ID= " << parameter_id; - status = absl::InvalidArgumentError(""); + status = absl::InvalidArgumentError(absl::StrCat( + "Inconsistent total duration and the cumulative durations of ", + "subblocks. Parameter ID = ", parameter_id)); } } } diff --git a/iamf/obu/parameter_block.cc b/iamf/obu/parameter_block.cc index 72c5c56c..c1d8282f 100644 --- a/iamf/obu/parameter_block.cc +++ b/iamf/obu/parameter_block.cc @@ -376,7 +376,9 @@ absl::Status ParameterBlockObu::SetSubblockDuration(int subblock_index, DecodedUleb128 duration) { const DecodedUleb128 num_subblocks = GetNumSubblocks(); if (subblock_index > num_subblocks) { - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Setting subblock duration for subblock_index = ", subblock_index, + " but there are only num_subblocks = ", num_subblocks)); } const DecodedUleb128 constant_subblock_duration = GetConstantSubblockDuration(); @@ -429,7 +431,10 @@ absl::Status ParameterBlockObu::GetMixGain(int32_t obu_relative_time, } if (target_subblock_index == -1) { - return absl::UnknownError(""); + return absl::UnknownError( + absl::StrCat("Trying to get mix gain for target_subblock_index = -1, " + "with num_subblocks = ", + num_subblocks)); } RETURN_IF_NOT_OK(InterpolateMixGainParameterData( @@ -456,10 +461,10 @@ absl::Status ParameterBlockObu::InitializeSubblocks( absl::Status ParameterBlockObu::InitializeSubblocks() { if (metadata_.param_definition.param_definition_mode_ != 0) { - LOG(ERROR) << "InitializeSubblocks() without input arguments should only " - << "be called when `param_definition_mode_ == 0`"; - init_status_ = absl::InvalidArgumentError(""); - return absl::InvalidArgumentError(""); + init_status_ = absl::InvalidArgumentError( + "InitializeSubblocks() without input arguments should only " + "be called when `param_definition_mode_ == 0`"); + return init_status_; } subblocks_.resize(static_cast(GetNumSubblocks())); init_status_ = absl::OkStatus(); @@ -629,7 +634,9 @@ absl::Status ParameterBlockObu::ValidateAndWritePayload( // Check total duration matches expected duration. if (validate_total_subblock_durations && total_subblock_durations != duration_) { - return absl::InvalidArgumentError(""); + return absl::InvalidArgumentError(absl::StrCat( + "Expected total_subblock_durations = ", total_subblock_durations, + " to match the expected duration_ = ", duration_)); } return absl::OkStatus(); diff --git a/iamf/obu/parameter_block.h b/iamf/obu/parameter_block.h index 49d89022..9475cdff 100644 --- a/iamf/obu/parameter_block.h +++ b/iamf/obu/parameter_block.h @@ -404,7 +404,8 @@ class ParameterBlockObu : public ObuBase { PerIdParameterMetadata& metadata_; // Tracks whether the OBU was initialized correctly. - absl::Status init_status_ = absl::UnknownError(""); + absl::Status init_status_ = + absl::UnknownError("Parameter Block OBU was not initialized correctly"); }; } // namespace iamf_tools