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

Side by Side Diff: webrtc/modules/audio_coding/acm2/rent_a_codec.cc

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 27 matching lines...) Expand all
38 #endif 38 #endif
39 #include "webrtc/modules/audio_coding/acm2/acm_codec_database.h" 39 #include "webrtc/modules/audio_coding/acm2/acm_codec_database.h"
40 #include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" 40 #include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
41 41
42 namespace webrtc { 42 namespace webrtc {
43 namespace acm2 { 43 namespace acm2 {
44 44
45 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams( 45 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams(
46 const char* payload_name, 46 const char* payload_name,
47 int sampling_freq_hz, 47 int sampling_freq_hz,
48 int channels) { 48 size_t channels) {
49 return CodecIdFromIndex( 49 return CodecIdFromIndex(
50 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels)); 50 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels));
51 } 51 }
52 52
53 rtc::Optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) { 53 rtc::Optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) {
54 rtc::Optional<int> mi = CodecIndexFromId(codec_id); 54 rtc::Optional<int> mi = CodecIndexFromId(codec_id);
55 return mi ? rtc::Optional<CodecInst>(Database()[*mi]) 55 return mi ? rtc::Optional<CodecInst>(Database()[*mi])
56 : rtc::Optional<CodecInst>(); 56 : rtc::Optional<CodecInst>();
57 } 57 }
58 58
59 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByInst( 59 rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByInst(
60 const CodecInst& codec_inst) { 60 const CodecInst& codec_inst) {
61 return CodecIdFromIndex(ACMCodecDB::CodecNumber(codec_inst)); 61 return CodecIdFromIndex(ACMCodecDB::CodecNumber(codec_inst));
62 } 62 }
63 63
64 rtc::Optional<CodecInst> RentACodec::CodecInstByParams(const char* payload_name, 64 rtc::Optional<CodecInst> RentACodec::CodecInstByParams(const char* payload_name,
65 int sampling_freq_hz, 65 int sampling_freq_hz,
66 int channels) { 66 size_t channels) {
67 rtc::Optional<CodecId> codec_id = 67 rtc::Optional<CodecId> codec_id =
68 CodecIdByParams(payload_name, sampling_freq_hz, channels); 68 CodecIdByParams(payload_name, sampling_freq_hz, channels);
69 if (!codec_id) 69 if (!codec_id)
70 return rtc::Optional<CodecInst>(); 70 return rtc::Optional<CodecInst>();
71 rtc::Optional<CodecInst> ci = CodecInstById(*codec_id); 71 rtc::Optional<CodecInst> ci = CodecInstById(*codec_id);
72 RTC_DCHECK(ci); 72 RTC_DCHECK(ci);
73 73
74 // Keep the number of channels from the function call. For most codecs it 74 // Keep the number of channels from the function call. For most codecs it
75 // will be the same value as in default codec settings, but not for all. 75 // will be the same value as in default codec settings, but not for all.
76 ci->channels = channels; 76 ci->channels = channels;
77 77
78 return ci; 78 return ci;
79 } 79 }
80 80
81 bool RentACodec::IsCodecValid(const CodecInst& codec_inst) { 81 bool RentACodec::IsCodecValid(const CodecInst& codec_inst) {
82 return ACMCodecDB::CodecNumber(codec_inst) >= 0; 82 return ACMCodecDB::CodecNumber(codec_inst) >= 0;
83 } 83 }
84 84
85 rtc::Optional<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id, 85 rtc::Optional<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id,
86 int num_channels) { 86 size_t num_channels) {
87 auto i = CodecIndexFromId(codec_id); 87 auto i = CodecIndexFromId(codec_id);
88 return i ? rtc::Optional<bool>( 88 return i ? rtc::Optional<bool>(
89 ACMCodecDB::codec_settings_[*i].channel_support >= 89 ACMCodecDB::codec_settings_[*i].channel_support >=
90 num_channels) 90 num_channels)
91 : rtc::Optional<bool>(); 91 : rtc::Optional<bool>();
92 } 92 }
93 93
94 rtc::ArrayView<const CodecInst> RentACodec::Database() { 94 rtc::ArrayView<const CodecInst> RentACodec::Database() {
95 return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_, 95 return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_,
96 NumberOfCodecs()); 96 NumberOfCodecs());
97 } 97 }
98 98
99 rtc::Optional<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId( 99 rtc::Optional<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId(
100 CodecId codec_id, 100 CodecId codec_id,
101 int num_channels) { 101 size_t num_channels) {
102 rtc::Optional<int> i = CodecIndexFromId(codec_id); 102 rtc::Optional<int> i = CodecIndexFromId(codec_id);
103 if (!i) 103 if (!i)
104 return rtc::Optional<NetEqDecoder>(); 104 return rtc::Optional<NetEqDecoder>();
105 const NetEqDecoder ned = ACMCodecDB::neteq_decoders_[*i]; 105 const NetEqDecoder ned = ACMCodecDB::neteq_decoders_[*i];
106 return rtc::Optional<NetEqDecoder>( 106 return rtc::Optional<NetEqDecoder>(
107 (ned == NetEqDecoder::kDecoderOpus && num_channels == 2) 107 (ned == NetEqDecoder::kDecoderOpus && num_channels == 2)
108 ? NetEqDecoder::kDecoderOpus_2ch 108 ? NetEqDecoder::kDecoderOpus_2ch
109 : ned); 109 : ned);
110 } 110 }
111 111
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 AudioDecoder* RentACodec::RentIsacDecoder() { 300 AudioDecoder* RentACodec::RentIsacDecoder() {
301 if (!isac_decoder_) 301 if (!isac_decoder_)
302 isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_); 302 isac_decoder_ = CreateIsacDecoder(&isac_bandwidth_info_);
303 return isac_decoder_.get(); 303 return isac_decoder_.get();
304 } 304 }
305 305
306 } // namespace acm2 306 } // namespace acm2
307 } // namespace webrtc 307 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/rent_a_codec.h ('k') | webrtc/modules/audio_coding/codecs/audio_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698