Skip to content

Commit

Permalink
Merge pull request #10 from thirv:main
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 653505187
  • Loading branch information
jwcullen committed Jul 18, 2024
2 parents 02d6318 + 85eb90b commit 1130013
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions iamf/cli/codec/opus_encoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,20 @@ absl::Status OpusEncoder::InitializeEncoder() {
opus_error_code, "Failed to initialize Opus encoder."));

// `OPUS_SET_BITRATE` treats this as the bit-rate for the entire substream.
// Configure `libopus` so coupled substreams and mono substreams have the same
// Configure `libopus` so coupled substreams and mono substreams have equally
// effective bit-rate per channel.
const auto substream_bitrate = static_cast<opus_int32>(
encoder_metadata_.target_bitrate_per_channel() * num_channels_);
opus_encoder_ctl(encoder_, OPUS_SET_BITRATE(substream_bitrate));
if (num_channels_ > 1) {
opus_encoder_ctl(
encoder_,
OPUS_SET_BITRATE(static_cast<opus_int32>(
encoder_metadata_.target_bitrate_per_channel() * num_channels_ *
encoder_metadata_.coupling_rate_adjustment() +
0.5f)));
} else {
opus_encoder_ctl(encoder_,
OPUS_SET_BITRATE(static_cast<opus_int32>(
encoder_metadata_.target_bitrate_per_channel())));
}

return absl::OkStatus();
}
Expand Down
1 change: 1 addition & 0 deletions iamf/cli/proto/codec_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ message OpusEncoderMetadata {
optional int32 target_bitrate_per_channel = 1;
optional OpusApplicationFlag application = 2;
optional bool use_float_api = 3 [default = true];
optional float coupling_rate_adjustment = 4 [default = 1.0];
}

message OpusDecoderConfig {
Expand Down

0 comments on commit 1130013

Please sign in to comment.