Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1324453002: NetEq: Fixing a corner case with depleted sync buffer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Adding a DCHECK Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 num_output_samples = max_length; 828 num_output_samples = max_length;
829 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); 829 num_output_samples_per_channel = max_length / sync_buffer_->Channels();
830 } 830 }
831 const size_t samples_from_sync = 831 const size_t samples_from_sync =
832 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, 832 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel,
833 output); 833 output);
834 *num_channels = static_cast<int>(sync_buffer_->Channels()); 834 *num_channels = static_cast<int>(sync_buffer_->Channels());
835 LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" << 835 LOG(LS_VERBOSE) << "Sync buffer (" << *num_channels << " channel(s)):" <<
836 " insert " << algorithm_buffer_->Size() << " samples, extract " << 836 " insert " << algorithm_buffer_->Size() << " samples, extract " <<
837 samples_from_sync << " samples"; 837 samples_from_sync << " samples";
838 if (sync_buffer_->FutureLength() < expand_->overlap_length()) {
839 // The sync buffer should always contain |overlap_length| samples, but now
840 // too many samples have been extracted. Reinstall the |overlap_length|
841 // lookahead by moving the index.
842 const size_t missing_lookahead_samples =
843 expand_->overlap_length() - sync_buffer_->FutureLength();
844 DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples);
845 sync_buffer_->set_next_index(sync_buffer_->next_index() -
846 missing_lookahead_samples);
847 }
838 if (samples_from_sync != output_size_samples_) { 848 if (samples_from_sync != output_size_samples_) {
839 LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync 849 LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync
840 << ") != output_size_samples_ (" << output_size_samples_ 850 << ") != output_size_samples_ (" << output_size_samples_
841 << ")"; 851 << ")";
842 // TODO(minyue): treatment of under-run, filling zeros 852 // TODO(minyue): treatment of under-run, filling zeros
843 memset(output, 0, num_output_samples * sizeof(int16_t)); 853 memset(output, 0, num_output_samples * sizeof(int16_t));
844 *samples_per_channel = output_size_samples_; 854 *samples_per_channel = output_size_samples_;
845 return kSampleUnderrun; 855 return kSampleUnderrun;
846 } 856 }
847 *samples_per_channel = output_size_samples_; 857 *samples_per_channel = output_size_samples_;
848 858
849 // Should always have overlap samples left in the |sync_buffer_|. 859 // Should always have overlap samples left in the |sync_buffer_|.
850 assert(sync_buffer_->FutureLength() >= expand_->overlap_length()); 860 DCHECK_GE(sync_buffer_->FutureLength(), expand_->overlap_length());
851 861
852 if (play_dtmf) { 862 if (play_dtmf) {
853 return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), output); 863 return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), output);
854 } 864 }
855 865
856 // Update the background noise parameters if last operation wrote data 866 // Update the background noise parameters if last operation wrote data
857 // straight from the decoder to the |sync_buffer_|. That is, none of the 867 // straight from the decoder to the |sync_buffer_|. That is, none of the
858 // operations that modify the signal can be followed by a parameter update. 868 // operations that modify the signal can be followed by a parameter update.
859 if ((last_mode_ == kModeNormal) || 869 if ((last_mode_ == kModeNormal) ||
860 (last_mode_ == kModeAccelerateFail) || 870 (last_mode_ == kModeAccelerateFail) ||
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 1995
1986 void NetEqImpl::CreateDecisionLogic() { 1996 void NetEqImpl::CreateDecisionLogic() {
1987 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, 1997 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
1988 playout_mode_, 1998 playout_mode_,
1989 decoder_database_.get(), 1999 decoder_database_.get(),
1990 *packet_buffer_.get(), 2000 *packet_buffer_.get(),
1991 delay_manager_.get(), 2001 delay_manager_.get(),
1992 buffer_level_filter_.get())); 2002 buffer_level_filter_.get()));
1993 } 2003 }
1994 } // namespace webrtc 2004 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h ('k') | webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698