-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
iamf/cli/proto/codec_config.proto
Outdated
@@ -41,6 +41,9 @@ message OpusEncoderMetadata { | |||
optional OpusApplicationFlag application = 2; | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think the proto may be better as
map<uint32, int32> substream_id_to_bitrate_override = 5;
In textproto it would look like.
# Substream ID 123 has a bitrate of 1000.
substream_id_to_bitrate_override {
key: 123
value: 1000
}
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 use_substream_rate_override
. When the substream is not present that implies it is not being overrided - using the "default" calculation would be reasonable.
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.
iamf/cli/codec/opus_encoder.cc
Outdated
0.5f))); | ||
opus_rate = | ||
encoder_metadata_.use_substream_rate_override() | ||
? encoder_metadata_.substream_rate_overrides()[substream_id_] |
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.
@@ -41,6 +41,9 @@ message OpusEncoderMetadata { | |||
optional OpusApplicationFlag application = 2; |
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.
Do you imagine any use cases where application
should vary per substream (or per audio element)?
I'm thinking of a use case where one audio element is music (best encoded as APPLICATION_AUDIO
) and a second audio element is voice chat (best encoded as APPLICATION_VOIP
).
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 comment
The 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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
std::unique_ptr<EncoderBase>& encoder, int substream_id = NULL) { | |
std::unique_ptr<EncoderBase>& encoder, int substream_id = 0) { |
This is an experimental tool that is useful for sound quality optimization. Open to suggestions about the UI etc. Also, not sure if this would somehow be a hindrance and is better left out.
Usage example in a .textproto config file: