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

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

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rebase onto cleanup change Created 4 years, 11 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true); 144 InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true);
145 145
146 if (error != 0) { 146 if (error != 0) {
147 error_code_ = error; 147 error_code_ = error;
148 return kFail; 148 return kFail;
149 } 149 }
150 return kOK; 150 return kOK;
151 } 151 }
152 152
153 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio, 153 int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio,
154 size_t* samples_per_channel, int* num_channels, 154 size_t* samples_per_channel, size_t* num_channels,
155 NetEqOutputType* type) { 155 NetEqOutputType* type) {
156 CriticalSectionScoped lock(crit_sect_.get()); 156 CriticalSectionScoped lock(crit_sect_.get());
157 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, 157 int error = GetAudioInternal(max_length, output_audio, samples_per_channel,
158 num_channels); 158 num_channels);
159 if (error != 0) { 159 if (error != 0) {
160 error_code_ = error; 160 error_code_ = error;
161 return kFail; 161 return kFail;
162 } 162 }
163 if (type) { 163 if (type) {
164 *type = LastOutputType(); 164 *type = LastOutputType();
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // but don't update statistics. 736 // but don't update statistics.
737 delay_manager_->set_last_pack_cng_or_dtmf(0); 737 delay_manager_->set_last_pack_cng_or_dtmf(0);
738 delay_manager_->ResetPacketIatCount(); 738 delay_manager_->ResetPacketIatCount();
739 } 739 }
740 return 0; 740 return 0;
741 } 741 }
742 742
743 int NetEqImpl::GetAudioInternal(size_t max_length, 743 int NetEqImpl::GetAudioInternal(size_t max_length,
744 int16_t* output, 744 int16_t* output,
745 size_t* samples_per_channel, 745 size_t* samples_per_channel,
746 int* num_channels) { 746 size_t* num_channels) {
747 PacketList packet_list; 747 PacketList packet_list;
748 DtmfEvent dtmf_event; 748 DtmfEvent dtmf_event;
749 Operations operation; 749 Operations operation;
750 bool play_dtmf; 750 bool play_dtmf;
751 int return_value = GetDecision(&operation, &packet_list, &dtmf_event, 751 int return_value = GetDecision(&operation, &packet_list, &dtmf_event,
752 &play_dtmf); 752 &play_dtmf);
753 if (return_value != 0) { 753 if (return_value != 0) {
754 last_mode_ = kModeError; 754 last_mode_ = kModeError;
755 return return_value; 755 return return_value;
756 } 756 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels(); 860 size_t num_output_samples = output_size_samples_ * sync_buffer_->Channels();
861 if (num_output_samples > max_length) { 861 if (num_output_samples > max_length) {
862 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " << 862 LOG(LS_WARNING) << "Output array is too short. " << max_length << " < " <<
863 output_size_samples_ << " * " << sync_buffer_->Channels(); 863 output_size_samples_ << " * " << sync_buffer_->Channels();
864 num_output_samples = max_length; 864 num_output_samples = max_length;
865 num_output_samples_per_channel = max_length / sync_buffer_->Channels(); 865 num_output_samples_per_channel = max_length / sync_buffer_->Channels();
866 } 866 }
867 const size_t samples_from_sync = 867 const size_t samples_from_sync =
868 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel, 868 sync_buffer_->GetNextAudioInterleaved(num_output_samples_per_channel,
869 output); 869 output);
870 *num_channels = static_cast<int>(sync_buffer_->Channels()); 870 *num_channels = sync_buffer_->Channels();
871 if (sync_buffer_->FutureLength() < expand_->overlap_length()) { 871 if (sync_buffer_->FutureLength() < expand_->overlap_length()) {
872 // The sync buffer should always contain |overlap_length| samples, but now 872 // The sync buffer should always contain |overlap_length| samples, but now
873 // too many samples have been extracted. Reinstall the |overlap_length| 873 // too many samples have been extracted. Reinstall the |overlap_length|
874 // lookahead by moving the index. 874 // lookahead by moving the index.
875 const size_t missing_lookahead_samples = 875 const size_t missing_lookahead_samples =
876 expand_->overlap_length() - sync_buffer_->FutureLength(); 876 expand_->overlap_length() - sync_buffer_->FutureLength();
877 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples); 877 RTC_DCHECK_GE(sync_buffer_->next_index(), missing_lookahead_samples);
878 sync_buffer_->set_next_index(sync_buffer_->next_index() - 878 sync_buffer_->set_next_index(sync_buffer_->next_index() -
879 missing_lookahead_samples); 879 missing_lookahead_samples);
880 } 880 }
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 2044
2045 void NetEqImpl::CreateDecisionLogic() { 2045 void NetEqImpl::CreateDecisionLogic() {
2046 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, 2046 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
2047 playout_mode_, 2047 playout_mode_,
2048 decoder_database_.get(), 2048 decoder_database_.get(),
2049 *packet_buffer_.get(), 2049 *packet_buffer_.get(),
2050 delay_manager_.get(), 2050 delay_manager_.get(),
2051 buffer_level_filter_.get())); 2051 buffer_level_filter_.get()));
2052 } 2052 }
2053 } // namespace webrtc 2053 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698