-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add individual rate adjustment per substream for Opus #11
Changes from 2 commits
8734536
a047a41
908d161
44e837a
0461b2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ message OpusEncoderMetadata { | |
optional OpusApplicationFlag application = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you imagine any use cases where I'm thinking of a use case where one audio element is music (best encoded as If you think this would be useful, we may want to consider how we would handle this - even if it does not get implemented in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally don't see this as a critical addition right now; I'd think separate audio elements would be used in that case. But yeah, the need may materialize suddenly at some point. |
||
optional bool use_float_api = 3 [default = true]; | ||
optional float coupling_rate_adjustment = 4 [default = 1.0]; | ||
optional bool use_substream_rate_override = 5 [default = false]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the proto may be better as
In textproto it would look like.
This would be more reasonable if large substream IDs are used - which are generally supported elsewhere in the encoder. I think in this case it makes sense to check presence of the substream in the map, and there does not need to be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the help, was considering it but was not sure how maps worked here. |
||
// so far the below uses substream_id as array index | ||
repeated int32 substream_rate_overrides = 6 [packed = true]; | ||
} | ||
|
||
message OpusDecoderConfig { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -59,7 +59,7 @@ namespace { | |||||
absl::Status InitializeEncoder( | ||||||
const iamf_tools_cli_proto::CodecConfig& codec_config_metadata, | ||||||
const CodecConfigObu& codec_config, int num_channels, | ||||||
std::unique_ptr<EncoderBase>& encoder) { | ||||||
std::unique_ptr<EncoderBase>& encoder, int substream_id = NULL) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
switch (codec_config.GetCodecConfig().codec_id) { | ||||||
using enum CodecConfig::CodecId; | ||||||
case kCodecIdLpcm: | ||||||
|
@@ -68,7 +68,7 @@ absl::Status InitializeEncoder( | |||||
case kCodecIdOpus: | ||||||
encoder = std::make_unique<OpusEncoder>( | ||||||
codec_config_metadata.decoder_config_opus().opus_encoder_metadata(), | ||||||
codec_config, num_channels); | ||||||
codec_config, num_channels, substream_id); | ||||||
break; | ||||||
case kCodecIdAacLc: | ||||||
encoder = std::make_unique<AacEncoder>( | ||||||
|
@@ -109,9 +109,9 @@ absl::Status GetEncodingDataAndInitializeEncoders( | |||||
codec_config_obu.GetCodecConfigId())); | ||||||
} | ||||||
|
||||||
RETURN_IF_NOT_OK(InitializeEncoder(codec_config_metadata_iter->second, | ||||||
codec_config_obu, num_channels, | ||||||
substream_id_to_encoder[substream_id])); | ||||||
RETURN_IF_NOT_OK(InitializeEncoder( | ||||||
codec_config_metadata_iter->second, codec_config_obu, num_channels, | ||||||
substream_id_to_encoder[substream_id], substream_id)); | ||||||
} | ||||||
|
||||||
return absl::OkStatus(); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces an error if
encoder_metadata_.substream_rate_overrides()[substream_id_]
goes out of bounds.Before performing the lookup validate that it does not go out of bounds. At review time check against the size of the array. But if you take the "map"-based suggestion in another comment check that the substream_id is present.
I think if it would go out of bounds it is OK to fallback to the calculation based on
target_bitrate_per_channels
.Same in the else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help, was considering it but was not sure how maps worked here.