Chromium Code Reviews

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

Issue 1948483002: Using ring buffer for AudioVector in NetEq. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: removing a unittest Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 49 matching lines...)
60 number_of_samples = requested_length + overlap_length_; 60 number_of_samples = requested_length + overlap_length_;
61 new_period = true; 61 new_period = true;
62 } 62 }
63 output->AssertSize(number_of_samples); 63 output->AssertSize(number_of_samples);
64 // Get the decoder from the database. 64 // Get the decoder from the database.
65 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder(); 65 ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
66 if (!cng_decoder) { 66 if (!cng_decoder) {
67 LOG(LS_ERROR) << "Unknwown payload type"; 67 LOG(LS_ERROR) << "Unknwown payload type";
68 return kUnknownPayloadType; 68 return kUnknownPayloadType;
69 } 69 }
70 // The expression &(*output)[0][0] is a pointer to the first element in 70
71 // the first channel. 71 std::unique_ptr<int16_t[]> temp(new int16_t[number_of_samples]);
72 if (!cng_decoder->Generate( 72 if (!cng_decoder->Generate(
73 rtc::ArrayView<int16_t>(&(*output)[0][0], number_of_samples), 73 rtc::ArrayView<int16_t>(temp.get(), number_of_samples),
74 new_period)) { 74 new_period)) {
75 // Error returned. 75 // Error returned.
76 output->Zeros(requested_length); 76 output->Zeros(requested_length);
77 LOG(LS_ERROR) << 77 LOG(LS_ERROR) <<
78 "ComfortNoiseDecoder::Genererate failed to generate comfort noise"; 78 "ComfortNoiseDecoder::Genererate failed to generate comfort noise";
79 return kInternalError; 79 return kInternalError;
80 } 80 }
81 (*output)[0].OverwriteAt(temp.get(), number_of_samples, 0);
81 82
82 if (first_call_) { 83 if (first_call_) {
83 // Set tapering window parameters. Values are in Q15. 84 // Set tapering window parameters. Values are in Q15.
84 int16_t muting_window; // Mixing factor for overlap data. 85 int16_t muting_window; // Mixing factor for overlap data.
85 int16_t muting_window_increment; // Mixing factor increment (negative). 86 int16_t muting_window_increment; // Mixing factor increment (negative).
86 int16_t unmuting_window; // Mixing factor for comfort noise. 87 int16_t unmuting_window; // Mixing factor for comfort noise.
87 int16_t unmuting_window_increment; // Mixing factor increment. 88 int16_t unmuting_window_increment; // Mixing factor increment.
88 if (fs_hz_ == 8000) { 89 if (fs_hz_ == 8000) {
89 muting_window = DspHelper::kMuteFactorStart8kHz; 90 muting_window = DspHelper::kMuteFactorStart8kHz;
90 muting_window_increment = DspHelper::kMuteFactorIncrement8kHz; 91 muting_window_increment = DspHelper::kMuteFactorIncrement8kHz;
(...skipping 30 matching lines...)
121 } 122 }
122 // Remove |overlap_length_| samples from the front of |output| since they 123 // Remove |overlap_length_| samples from the front of |output| since they
123 // were mixed into |sync_buffer_| above. 124 // were mixed into |sync_buffer_| above.
124 output->PopFront(overlap_length_); 125 output->PopFront(overlap_length_);
125 } 126 }
126 first_call_ = false; 127 first_call_ = false;
127 return kOK; 128 return kOK;
128 } 129 }
129 130
130 } // namespace webrtc 131 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/background_noise.cc ('k') | webrtc/modules/audio_coding/neteq/dsp_helper.h » ('j') | no next file with comments »

Powered by Google App Engine