| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2013 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 96 void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { | 96 void DecisionLogic::SetSampleRate(int fs_hz, size_t output_size_samples) { | 
| 97   // TODO(hlundin): Change to an enumerator and skip assert. | 97   // TODO(hlundin): Change to an enumerator and skip assert. | 
| 98   assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz ==  32000 || fs_hz == 48000); | 98   assert(fs_hz == 8000 || fs_hz == 16000 || fs_hz ==  32000 || fs_hz == 48000); | 
| 99   fs_mult_ = fs_hz / 8000; | 99   fs_mult_ = fs_hz / 8000; | 
| 100   output_size_samples_ = output_size_samples; | 100   output_size_samples_ = output_size_samples; | 
| 101 } | 101 } | 
| 102 | 102 | 
| 103 Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer, | 103 Operations DecisionLogic::GetDecision(const SyncBuffer& sync_buffer, | 
| 104                                       const Expand& expand, | 104                                       const Expand& expand, | 
| 105                                       size_t decoder_frame_length, | 105                                       size_t decoder_frame_length, | 
| 106                                       const RTPHeader* packet_header, | 106                                       const Packet* next_packet, | 
| 107                                       Modes prev_mode, | 107                                       Modes prev_mode, | 
| 108                                       bool play_dtmf, | 108                                       bool play_dtmf, | 
| 109                                       size_t generated_noise_samples, | 109                                       size_t generated_noise_samples, | 
| 110                                       bool* reset_decoder) { | 110                                       bool* reset_decoder) { | 
| 111   // If last mode was CNG (or Expand, since this could be covering up for | 111   // If last mode was CNG (or Expand, since this could be covering up for | 
| 112   // a lost CNG packet), remember that CNG is on. This is needed if comfort | 112   // a lost CNG packet), remember that CNG is on. This is needed if comfort | 
| 113   // noise is interrupted by DTMF. | 113   // noise is interrupted by DTMF. | 
| 114   if (prev_mode == kModeRfc3389Cng) { | 114   if (prev_mode == kModeRfc3389Cng) { | 
| 115     cng_state_ = kCngRfc3389On; | 115     cng_state_ = kCngRfc3389On; | 
| 116   } else if (prev_mode == kModeCodecInternalCng) { | 116   } else if (prev_mode == kModeCodecInternalCng) { | 
| 117     cng_state_ = kCngInternalOn; | 117     cng_state_ = kCngInternalOn; | 
| 118   } | 118   } | 
| 119 | 119 | 
| 120   const size_t samples_left = | 120   const size_t samples_left = | 
| 121       sync_buffer.FutureLength() - expand.overlap_length(); | 121       sync_buffer.FutureLength() - expand.overlap_length(); | 
| 122   const size_t cur_size_samples = | 122   const size_t cur_size_samples = | 
| 123       samples_left + packet_buffer_.NumSamplesInBuffer(decoder_frame_length); | 123       samples_left + packet_buffer_.NumSamplesInBuffer(decoder_frame_length); | 
| 124 | 124 | 
| 125   prev_time_scale_ = prev_time_scale_ && | 125   prev_time_scale_ = prev_time_scale_ && | 
| 126       (prev_mode == kModeAccelerateSuccess || | 126       (prev_mode == kModeAccelerateSuccess || | 
| 127           prev_mode == kModeAccelerateLowEnergy || | 127           prev_mode == kModeAccelerateLowEnergy || | 
| 128           prev_mode == kModePreemptiveExpandSuccess || | 128           prev_mode == kModePreemptiveExpandSuccess || | 
| 129           prev_mode == kModePreemptiveExpandLowEnergy); | 129           prev_mode == kModePreemptiveExpandLowEnergy); | 
| 130 | 130 | 
| 131   FilterBufferLevel(cur_size_samples, prev_mode); | 131   FilterBufferLevel(cur_size_samples, prev_mode); | 
| 132 | 132 | 
| 133   return GetDecisionSpecialized(sync_buffer, expand, decoder_frame_length, | 133   return GetDecisionSpecialized(sync_buffer, expand, decoder_frame_length, | 
| 134                                 packet_header, prev_mode, play_dtmf, | 134                                 next_packet, prev_mode, play_dtmf, | 
| 135                                 reset_decoder, generated_noise_samples); | 135                                 reset_decoder, generated_noise_samples); | 
| 136 } | 136 } | 
| 137 | 137 | 
| 138 void DecisionLogic::ExpandDecision(Operations operation) { | 138 void DecisionLogic::ExpandDecision(Operations operation) { | 
| 139   if (operation == kExpand) { | 139   if (operation == kExpand) { | 
| 140     num_consecutive_expands_++; | 140     num_consecutive_expands_++; | 
| 141   } else { | 141   } else { | 
| 142     num_consecutive_expands_ = 0; | 142     num_consecutive_expands_ = 0; | 
| 143   } | 143   } | 
| 144 } | 144 } | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 162       timescale_countdown_ = | 162       timescale_countdown_ = | 
| 163           tick_timer_->GetNewCountdown(kMinTimescaleInterval); | 163           tick_timer_->GetNewCountdown(kMinTimescaleInterval); | 
| 164     } | 164     } | 
| 165     buffer_level_filter_->Update(buffer_size_packets, sample_memory_local, | 165     buffer_level_filter_->Update(buffer_size_packets, sample_memory_local, | 
| 166                                  packet_length_samples_); | 166                                  packet_length_samples_); | 
| 167     prev_time_scale_ = false; | 167     prev_time_scale_ = false; | 
| 168   } | 168   } | 
| 169 } | 169 } | 
| 170 | 170 | 
| 171 }  // namespace webrtc | 171 }  // namespace webrtc | 
| OLD | NEW | 
|---|