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

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: Created 4 years, 7 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // The expression &(*output)[0][0] is a pointer to the first element in
71 // the first channel. 71 // the first channel.
72 std::unique_ptr<int16_t[]> temp(new int16_t[number_of_samples]);
72 if (!cng_decoder->Generate( 73 if (!cng_decoder->Generate(
73 rtc::ArrayView<int16_t>(&(*output)[0][0], number_of_samples), 74 rtc::ArrayView<int16_t>(temp.get(), number_of_samples),
74 new_period)) { 75 new_period)) {
75 // Error returned. 76 // Error returned.
76 output->Zeros(requested_length); 77 output->Zeros(requested_length);
77 LOG(LS_ERROR) << 78 LOG(LS_ERROR) <<
78 "ComfortNoiseDecoder::Genererate failed to generate comfort noise"; 79 "ComfortNoiseDecoder::Genererate failed to generate comfort noise";
79 return kInternalError; 80 return kInternalError;
80 } 81 }
82 (*output)[0].OverwriteAt(temp.get(), number_of_samples, 0);
81 83
82 if (first_call_) { 84 if (first_call_) {
83 // Set tapering window parameters. Values are in Q15. 85 // Set tapering window parameters. Values are in Q15.
84 int16_t muting_window; // Mixing factor for overlap data. 86 int16_t muting_window; // Mixing factor for overlap data.
85 int16_t muting_window_increment; // Mixing factor increment (negative). 87 int16_t muting_window_increment; // Mixing factor increment (negative).
86 int16_t unmuting_window; // Mixing factor for comfort noise. 88 int16_t unmuting_window; // Mixing factor for comfort noise.
87 int16_t unmuting_window_increment; // Mixing factor increment. 89 int16_t unmuting_window_increment; // Mixing factor increment.
88 if (fs_hz_ == 8000) { 90 if (fs_hz_ == 8000) {
89 muting_window = DspHelper::kMuteFactorStart8kHz; 91 muting_window = DspHelper::kMuteFactorStart8kHz;
90 muting_window_increment = DspHelper::kMuteFactorIncrement8kHz; 92 muting_window_increment = DspHelper::kMuteFactorIncrement8kHz;
(...skipping 30 matching lines...) Expand all
121 } 123 }
122 // Remove |overlap_length_| samples from the front of |output| since they 124 // Remove |overlap_length_| samples from the front of |output| since they
123 // were mixed into |sync_buffer_| above. 125 // were mixed into |sync_buffer_| above.
124 output->PopFront(overlap_length_); 126 output->PopFront(overlap_length_);
125 } 127 }
126 first_call_ = false; 128 first_call_ = false;
127 return kOK; 129 return kOK;
128 } 130 }
129 131
130 } // namespace webrtc 132 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698