Skip to content

Commit

Permalink
Fill in remaining absl::Status messages (1/4).
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 644465424
  • Loading branch information
felicialim authored and jwcullen committed Jun 18, 2024
1 parent e3eae83 commit e449dbd
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 57 deletions.
36 changes: 18 additions & 18 deletions iamf/cli/cli_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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()));
Expand Down Expand Up @@ -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.");
}
}

Expand Down
8 changes: 4 additions & 4 deletions iamf/cli/encoder_main_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -267,8 +267,8 @@ absl::Status GenerateObus(
std::list<ArbitraryObu>& 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));
Expand Down
12 changes: 6 additions & 6 deletions iamf/cli/parameter_block_partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down
6 changes: 3 additions & 3 deletions iamf/cli/parameters_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
10 changes: 7 additions & 3 deletions iamf/common/obu_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ absl::Status LookupInMap(const absl::flat_hash_map<T, U>& 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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion iamf/obu/audio_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion iamf/obu/codec_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
24 changes: 11 additions & 13 deletions iamf/obu/param_definitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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));
}
}
}
Expand Down
21 changes: 14 additions & 7 deletions iamf/obu/parameter_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(
Expand All @@ -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<size_t>(GetNumSubblocks()));
init_status_ = absl::OkStatus();
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion iamf/obu/parameter_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e449dbd

Please sign in to comment.