Skip to content

Commit

Permalink
Prefer the overloaded ReadUnsignedLiteral instead of casting from `…
Browse files Browse the repository at this point in the history
…uint32_t` local variables.

PiperOrigin-RevId: 654080400
  • Loading branch information
jwcullen committed Jul 19, 2024
1 parent 5b771d1 commit fda0dee
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions iamf/obu/decoder_config/opus_decoder_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,13 @@ absl::Status OpusDecoderConfig::ReadAndValidate(uint32_t num_samples_per_frame,
ReadBitBuffer& rb) {
RETURN_IF_NOT_OK(
ValidateAudioRollDistance(num_samples_per_frame, audio_roll_distance));
// TODO(b/333893772): Add overloads for ReadUnsignedLiteral to accept other
// data types (uint8_t, uint16_t, uint32_t, etc.)
uint64_t version;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, version));
version_ = version;

uint64_t output_channel_count;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, output_channel_count));
output_channel_count_ = output_channel_count;

uint64_t pre_skip;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(16, pre_skip));
pre_skip_ = pre_skip;

uint64_t input_sample_rate;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(32, input_sample_rate));
input_sample_rate_ = input_sample_rate;

RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, version_));
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, output_channel_count_));
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(16, pre_skip_));
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(32, input_sample_rate_));
RETURN_IF_NOT_OK(rb.ReadSigned16(output_gain_));

uint64_t mapping_family;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, mapping_family));
mapping_family_ = mapping_family;
RETURN_IF_NOT_OK(rb.ReadUnsignedLiteral(8, mapping_family_));

RETURN_IF_NOT_OK(ValidatePayload(*this));
return absl::OkStatus();
Expand Down

0 comments on commit fda0dee

Please sign in to comment.