| 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 |
| 11 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h" | 11 #include "webrtc/modules/audio_coding/neteq/neteq_impl.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <memory.h> // memset | |
| 15 | 14 |
| 16 #include <algorithm> | 15 #include <algorithm> |
| 17 #include <utility> | 16 #include <utility> |
| 18 #include <vector> | 17 #include <vector> |
| 19 | 18 |
| 20 #include "webrtc/api/audio_codecs/audio_decoder.h" | 19 #include "webrtc/api/audio_codecs/audio_decoder.h" |
| 21 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
| 22 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
| 23 #include "webrtc/base/safe_conversions.h" | 22 #include "webrtc/base/safe_conversions.h" |
| 24 #include "webrtc/base/sanitizer.h" | 23 #include "webrtc/base/sanitizer.h" |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples); | 1055 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples); |
| 1057 sync_buffer_->set_next_index(sync_buffer_->next_index() - | 1056 sync_buffer_->set_next_index(sync_buffer_->next_index() - |
| 1058 missing_lookahead_samples); | 1057 missing_lookahead_samples); |
| 1059 } | 1058 } |
| 1060 if (audio_frame->samples_per_channel_ != output_size_samples_) { | 1059 if (audio_frame->samples_per_channel_ != output_size_samples_) { |
| 1061 LOG(LS_ERROR) << "audio_frame->samples_per_channel_ (" | 1060 LOG(LS_ERROR) << "audio_frame->samples_per_channel_ (" |
| 1062 << audio_frame->samples_per_channel_ | 1061 << audio_frame->samples_per_channel_ |
| 1063 << ") != output_size_samples_ (" << output_size_samples_ | 1062 << ") != output_size_samples_ (" << output_size_samples_ |
| 1064 << ")"; | 1063 << ")"; |
| 1065 // TODO(minyue): treatment of under-run, filling zeros | 1064 // TODO(minyue): treatment of under-run, filling zeros |
| 1066 memset(audio_frame->data_, 0, num_output_samples * sizeof(int16_t)); | 1065 audio_frame->Mute(); |
| 1067 return kSampleUnderrun; | 1066 return kSampleUnderrun; |
| 1068 } | 1067 } |
| 1069 | 1068 |
| 1070 // Should always have overlap samples left in the |sync_buffer_|. | 1069 // Should always have overlap samples left in the |sync_buffer_|. |
| 1071 RTC_DCHECK_GE(sync_buffer_->FutureLength(), expand_->overlap_length()); | 1070 RTC_DCHECK_GE(sync_buffer_->FutureLength(), expand_->overlap_length()); |
| 1072 | 1071 |
| 1072 // TODO(yujo): For muted frames, this can be a copy rather than an addition. |
| 1073 if (play_dtmf) { | 1073 if (play_dtmf) { |
| 1074 return_value = | 1074 return_value = DtmfOverdub(dtmf_event, sync_buffer_->Channels(), |
| 1075 DtmfOverdub(dtmf_event, sync_buffer_->Channels(), audio_frame->data_); | 1075 audio_frame->mutable_data()); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 // Update the background noise parameters if last operation wrote data | 1078 // Update the background noise parameters if last operation wrote data |
| 1079 // straight from the decoder to the |sync_buffer_|. That is, none of the | 1079 // straight from the decoder to the |sync_buffer_|. That is, none of the |
| 1080 // operations that modify the signal can be followed by a parameter update. | 1080 // operations that modify the signal can be followed by a parameter update. |
| 1081 if ((last_mode_ == kModeNormal) || | 1081 if ((last_mode_ == kModeNormal) || |
| 1082 (last_mode_ == kModeAccelerateFail) || | 1082 (last_mode_ == kModeAccelerateFail) || |
| 1083 (last_mode_ == kModePreemptiveExpandFail) || | 1083 (last_mode_ == kModePreemptiveExpandFail) || |
| 1084 (last_mode_ == kModeRfc3389Cng) || | 1084 (last_mode_ == kModeRfc3389Cng) || |
| 1085 (last_mode_ == kModeCodecInternalCng)) { | 1085 (last_mode_ == kModeCodecInternalCng)) { |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 } | 2180 } |
| 2181 } | 2181 } |
| 2182 | 2182 |
| 2183 void NetEqImpl::CreateDecisionLogic() { | 2183 void NetEqImpl::CreateDecisionLogic() { |
| 2184 decision_logic_.reset(DecisionLogic::Create( | 2184 decision_logic_.reset(DecisionLogic::Create( |
| 2185 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), | 2185 fs_hz_, output_size_samples_, playout_mode_, decoder_database_.get(), |
| 2186 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), | 2186 *packet_buffer_.get(), delay_manager_.get(), buffer_level_filter_.get(), |
| 2187 tick_timer_.get())); | 2187 tick_timer_.get())); |
| 2188 } | 2188 } |
| 2189 } // namespace webrtc | 2189 } // namespace webrtc |
| OLD | NEW |