Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 sync_buffer_->set_next_index(sync_buffer_->next_index() - | |
| 845 missing_lookahead_samples); | |
|
minyue-webrtc
2015/08/30 21:50:27
How do you know that next_index_ >= missing_lookah
hlundin-webrtc
2015/08/31 08:08:25
next_index_ is by definition FutureLength() from t
minyue-webrtc
2015/09/01 07:36:07
Acknowledged.
| |
| 846 } | |
| 838 if (samples_from_sync != output_size_samples_) { | 847 if (samples_from_sync != output_size_samples_) { |
| 839 LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync | 848 LOG(LS_ERROR) << "samples_from_sync (" << samples_from_sync |
| 840 << ") != output_size_samples_ (" << output_size_samples_ | 849 << ") != output_size_samples_ (" << output_size_samples_ |
| 841 << ")"; | 850 << ")"; |
| 842 // TODO(minyue): treatment of under-run, filling zeros | 851 // TODO(minyue): treatment of under-run, filling zeros |
| 843 memset(output, 0, num_output_samples * sizeof(int16_t)); | 852 memset(output, 0, num_output_samples * sizeof(int16_t)); |
| 844 *samples_per_channel = output_size_samples_; | 853 *samples_per_channel = output_size_samples_; |
| 845 return kSampleUnderrun; | 854 return kSampleUnderrun; |
| 846 } | 855 } |
| 847 *samples_per_channel = output_size_samples_; | 856 *samples_per_channel = output_size_samples_; |
| 848 | 857 |
| 849 // Should always have overlap samples left in the |sync_buffer_|. | 858 // Should always have overlap samples left in the |sync_buffer_|. |
| 850 assert(sync_buffer_->FutureLength() >= expand_->overlap_length()); | 859 DCHECK_GE(sync_buffer_->FutureLength(), expand_->overlap_length()); |
| 851 | 860 |
| 852 if (play_dtmf) { | 861 if (play_dtmf) { |
| 853 return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), output); | 862 return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), output); |
| 854 } | 863 } |
| 855 | 864 |
| 856 // Update the background noise parameters if last operation wrote data | 865 // Update the background noise parameters if last operation wrote data |
| 857 // straight from the decoder to the |sync_buffer_|. That is, none of the | 866 // 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. | 867 // operations that modify the signal can be followed by a parameter update. |
| 859 if ((last_mode_ == kModeNormal) || | 868 if ((last_mode_ == kModeNormal) || |
| 860 (last_mode_ == kModeAccelerateFail) || | 869 (last_mode_ == kModeAccelerateFail) || |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1985 | 1994 |
| 1986 void NetEqImpl::CreateDecisionLogic() { | 1995 void NetEqImpl::CreateDecisionLogic() { |
| 1987 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 1996 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
| 1988 playout_mode_, | 1997 playout_mode_, |
| 1989 decoder_database_.get(), | 1998 decoder_database_.get(), |
| 1990 *packet_buffer_.get(), | 1999 *packet_buffer_.get(), |
| 1991 delay_manager_.get(), | 2000 delay_manager_.get(), |
| 1992 buffer_level_filter_.get())); | 2001 buffer_level_filter_.get())); |
| 1993 } | 2002 } |
| 1994 } // namespace webrtc | 2003 } // namespace webrtc |
| OLD | NEW |