Stop setting OPUS_SIGNAL_VOICE when DTX is enabled.
This was done in crbug.com/webrtc/4559 since "CELT-only mode does not have DTX", but that should not be the case anymore (support was added in Opus v1.2.1). One exception where DTX does not work is with OPUS_APPLICATION_AUDIO (used with stereo) and low complexity settings. This should not be a common config. Bug: None Change-Id: I1476083b836bcabeb73df83d5bf06c3878146d28 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288420 Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38923}
This commit is contained in:
parent
6903f713d2
commit
757da3cf70
@ -42,6 +42,9 @@ constexpr char kPlcUsePrevDecodedSamplesFieldTrial[] =
|
||||
constexpr char kAvoidNoisePumpingDuringDtxFieldTrial[] =
|
||||
"WebRTC-Audio-OpusAvoidNoisePumpingDuringDtx";
|
||||
|
||||
constexpr char kSetSignalVoiceWithDtxFieldTrial[] =
|
||||
"WebRTC-Audio-OpusSetSignalVoiceWithDtx";
|
||||
|
||||
static int FrameSizePerChannel(int frame_size_ms, int sample_rate_hz) {
|
||||
RTC_DCHECK_GT(frame_size_ms, 0);
|
||||
RTC_DCHECK_EQ(frame_size_ms % 10, 0);
|
||||
@ -358,27 +361,27 @@ int16_t WebRtcOpus_DisableFec(OpusEncInst* inst) {
|
||||
}
|
||||
|
||||
int16_t WebRtcOpus_EnableDtx(OpusEncInst* inst) {
|
||||
if (!inst) {
|
||||
if (inst) {
|
||||
if (webrtc::field_trial::IsEnabled(kSetSignalVoiceWithDtxFieldTrial)) {
|
||||
int ret = ENCODER_CTL(inst, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
|
||||
if (ret != OPUS_OK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ENCODER_CTL(inst, OPUS_SET_DTX(1));
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// To prevent Opus from entering CELT-only mode by forcing signal type to
|
||||
// voice to make sure that DTX behaves correctly. Currently, DTX does not
|
||||
// last long during a pure silence, if the signal type is not forced.
|
||||
// TODO(minyue): Remove the signal type forcing when Opus DTX works properly
|
||||
// without it.
|
||||
int ret = ENCODER_CTL(inst, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
|
||||
if (ret != OPUS_OK)
|
||||
return ret;
|
||||
|
||||
return ENCODER_CTL(inst, OPUS_SET_DTX(1));
|
||||
}
|
||||
|
||||
int16_t WebRtcOpus_DisableDtx(OpusEncInst* inst) {
|
||||
if (inst) {
|
||||
int ret = ENCODER_CTL(inst, OPUS_SET_SIGNAL(OPUS_AUTO));
|
||||
if (ret != OPUS_OK)
|
||||
return ret;
|
||||
if (webrtc::field_trial::IsEnabled(kSetSignalVoiceWithDtxFieldTrial)) {
|
||||
int ret = ENCODER_CTL(inst, OPUS_SET_SIGNAL(OPUS_AUTO));
|
||||
if (ret != OPUS_OK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ENCODER_CTL(inst, OPUS_SET_DTX(0));
|
||||
} else {
|
||||
return -1;
|
||||
|
||||
@ -736,7 +736,8 @@ TEST_P(OpusTest, OpusDtxOff) {
|
||||
}
|
||||
|
||||
TEST_P(OpusTest, OpusDtxOn) {
|
||||
if (channels_ > 2) {
|
||||
if (channels_ > 2 || application_ != 0) {
|
||||
// DTX does not work with OPUS_APPLICATION_AUDIO at low complexity settings.
|
||||
// TODO(webrtc:10218): adapt the test to the sizes and order of multi-stream
|
||||
// DTX packets.
|
||||
return;
|
||||
|
||||
@ -235,30 +235,6 @@ void TestOpusDtx::Perform() {
|
||||
expects[static_cast<int>(AudioFrameType::kAudioFrameCN)] = 1;
|
||||
Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 32000, 1,
|
||||
out_filename, true, expects);
|
||||
|
||||
// Register stereo Opus as send codec
|
||||
out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm";
|
||||
RegisterCodec({"opus", 48000, 2, {{"stereo", "1"}}}, absl::nullopt);
|
||||
acm_send_->ModifyEncoder([](std::unique_ptr<AudioEncoder>* encoder_ptr) {
|
||||
(*encoder_ptr)->SetDtx(false);
|
||||
});
|
||||
expects[static_cast<int>(AudioFrameType::kEmptyFrame)] = 0;
|
||||
expects[static_cast<int>(AudioFrameType::kAudioFrameCN)] = 0;
|
||||
Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
|
||||
2, out_filename, false, expects);
|
||||
|
||||
acm_send_->ModifyEncoder([](std::unique_ptr<AudioEncoder>* encoder_ptr) {
|
||||
(*encoder_ptr)->SetDtx(true);
|
||||
// The default bitrate will not generate frames recognized as CN on desktop
|
||||
// since the frames will be encoded as CELT. Set a low target bitrate to get
|
||||
// consistent behaviour across platforms.
|
||||
(*encoder_ptr)->OnReceivedTargetAudioBitrate(24000);
|
||||
});
|
||||
|
||||
expects[static_cast<int>(AudioFrameType::kEmptyFrame)] = 1;
|
||||
expects[static_cast<int>(AudioFrameType::kAudioFrameCN)] = 1;
|
||||
Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"), 32000,
|
||||
2, out_filename, true, expects);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user