ACM2/NetEq4 did not decode Opus in stereo

Two problems fixed in this CL:
- setting Opus decoder to stereo had no effect, and decoding always generated mono audio
- changing decoding setting from mono to stereo, or stereo to mono, for OPUS also had no effect (but required another change than the first one).

BUG=3082
R=henrik.lundin@webrtc.org, turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/10389004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5754 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2014-03-23 09:58:48 +00:00
parent 152208adeb
commit ba5a6c3d89
3 changed files with 17 additions and 7 deletions

View File

@ -473,19 +473,25 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
assert(acm_codec_id >= 0 && acm_codec_id < ACMCodecDB::kMaxNumCodecs);
NetEqDecoder neteq_decoder = ACMCodecDB::neteq_decoders_[acm_codec_id];
// Make sure the right decoder is registered for Opus.
if (neteq_decoder == kDecoderOpus && channels == 2) {
neteq_decoder = kDecoderOpus_2ch;
}
CriticalSectionScoped lock(neteq_crit_sect_);
// The corresponding NetEq decoder ID.
// If this coder has been registered before.
if (decoders_[acm_codec_id].registered) {
if (decoders_[acm_codec_id].payload_type == payload_type) {
if (decoders_[acm_codec_id].payload_type == payload_type &&
decoders_[acm_codec_id].channels == channels) {
// Re-registering the same codec with the same payload-type. Do nothing
// and return.
return 0;
}
// Changing the payload-type of this codec. First unregister. Then register
// with new payload-type.
// Changing the payload-type or number of channels for this codec.
// First unregister. Then register with new payload-type/channels.
if (neteq_->RemovePayloadType(decoders_[acm_codec_id].payload_type) !=
NetEq::kOK) {
LOG_F(LS_ERROR) << "Cannot remover payload "

View File

@ -333,6 +333,11 @@ void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
// Write stand-alone speech to file.
out_file_standalone_.Write10MsData(out_audio, decoded_samples * channels);
// Number of channels should be the same for both stand-alone and
// ACM-decoding.
EXPECT_EQ(audio_frame.num_channels_, channels);
decoded_samples = 0;
}

View File

@ -1145,12 +1145,11 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
PacketBuffer::DeleteAllPackets(packet_list);
return kDecoderNotFound;
}
// We should have correct sampling rate and number of channels. They
// are set when packets are inserted.
// If sampling rate or number of channels has changed, we need to make
// a reset.
if (decoder_info->fs_hz != fs_hz_ ||
decoder->channels() != algorithm_buffer_->Channels()) {
LOG_F(LS_ERROR) << "Sampling rate or number of channels mismatch.";
assert(false);
// TODO(tlegrand): Add unittest to cover this event.
SetSampleRateAndChannels(decoder_info->fs_hz, decoder->channels());
}
sync_buffer_->set_end_timestamp(timestamp_);