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

Side by Side Diff: webrtc/modules/audio_coding/codecs/cng/cng_unittest.cc

Issue 1171033002: Ensures that modules_unittests runs on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebased Created 5 years, 6 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
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 #include <string> 10 #include <string>
11 11
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "webrtc/test/testsupport/fileutils.h" 13 #include "webrtc/test/testsupport/fileutils.h"
14 #include "webrtc/test/testsupport/gtest_disable.h"
14 #include "webrtc_cng.h" 15 #include "webrtc_cng.h"
15 16
16 namespace webrtc { 17 namespace webrtc {
17 18
18 enum { 19 enum {
19 kSidShortIntervalUpdate = 1, 20 kSidShortIntervalUpdate = 1,
20 kSidNormalIntervalUpdate = 100, 21 kSidNormalIntervalUpdate = 100,
21 kSidLongIntervalUpdate = 10000 22 kSidLongIntervalUpdate = 10000
22 }; 23 };
23 24
(...skipping 30 matching lines...) Expand all
54 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); 55 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
55 input_file = fopen(file_name.c_str(), "rb"); 56 input_file = fopen(file_name.c_str(), "rb");
56 ASSERT_TRUE(input_file != NULL); 57 ASSERT_TRUE(input_file != NULL);
57 ASSERT_EQ(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t), 58 ASSERT_EQ(640, static_cast<int32_t>(fread(speech_data_, sizeof(int16_t),
58 640, input_file))); 59 640, input_file)));
59 fclose(input_file); 60 fclose(input_file);
60 input_file = NULL; 61 input_file = NULL;
61 } 62 }
62 63
63 // Test failing Create. 64 // Test failing Create.
64 TEST_F(CngTest, CngCreateFail) { 65 TEST_F(CngTest, DISABLED_ON_IOS(CngCreateFail)) {
65 // Test to see that an invalid pointer is caught. 66 // Test to see that an invalid pointer is caught.
66 EXPECT_EQ(-1, WebRtcCng_CreateEnc(NULL)); 67 EXPECT_EQ(-1, WebRtcCng_CreateEnc(NULL));
67 EXPECT_EQ(-1, WebRtcCng_CreateDec(NULL)); 68 EXPECT_EQ(-1, WebRtcCng_CreateDec(NULL));
68 } 69 }
69 70
70 // Test normal Create. 71 // Test normal Create.
71 TEST_F(CngTest, CngCreate) { 72 TEST_F(CngTest, DISABLED_ON_IOS(CngCreate)) {
72 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 73 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
73 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 74 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
74 EXPECT_TRUE(cng_enc_inst_ != NULL); 75 EXPECT_TRUE(cng_enc_inst_ != NULL);
75 EXPECT_TRUE(cng_dec_inst_ != NULL); 76 EXPECT_TRUE(cng_dec_inst_ != NULL);
76 // Free encoder and decoder memory. 77 // Free encoder and decoder memory.
77 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 78 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
78 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 79 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
79 } 80 }
80 81
81 // Create CNG encoder, init with faulty values, free CNG encoder. 82 // Create CNG encoder, init with faulty values, free CNG encoder.
82 TEST_F(CngTest, CngInitFail) { 83 TEST_F(CngTest, DISABLED_ON_IOS(CngInitFail)) {
83 // Create encoder memory. 84 // Create encoder memory.
84 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 85 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
85 86
86 // Call with too few parameters. 87 // Call with too few parameters.
87 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, 88 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate,
88 kCNGNumParamsLow)); 89 kCNGNumParamsLow));
89 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); 90 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_));
90 91
91 // Call with too many parameters. 92 // Call with too many parameters.
92 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, 93 EXPECT_EQ(-1, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate,
93 kCNGNumParamsTooHigh)); 94 kCNGNumParamsTooHigh));
94 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); 95 EXPECT_EQ(6130, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_));
95 96
96 // Free encoder memory. 97 // Free encoder memory.
97 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 98 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
98 } 99 }
99 100
100 TEST_F(CngTest, CngEncode) { 101 TEST_F(CngTest, DISABLED_ON_IOS(CngEncode)) {
101 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 102 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
102 int16_t number_bytes; 103 int16_t number_bytes;
103 104
104 // Create encoder memory. 105 // Create encoder memory.
105 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 106 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
106 107
107 // 8 kHz, Normal number of parameters 108 // 8 kHz, Normal number of parameters
108 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, 109 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate,
109 kCNGNumParamsNormal)); 110 kCNGNumParamsNormal));
110 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 80, sid_data, 111 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 80, sid_data,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, 143 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data,
143 &number_bytes, kNoSid)); 144 &number_bytes, kNoSid));
144 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( 145 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode(
145 cng_enc_inst_, speech_data_, 640, sid_data, &number_bytes, kForceSid)); 146 cng_enc_inst_, speech_data_, 640, sid_data, &number_bytes, kForceSid));
146 147
147 // Free encoder memory. 148 // Free encoder memory.
148 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 149 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
149 } 150 }
150 151
151 // Encode Cng with too long input vector. 152 // Encode Cng with too long input vector.
152 TEST_F(CngTest, CngEncodeTooLong) { 153 TEST_F(CngTest, DISABLED_ON_IOS(CngEncodeTooLong)) {
153 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 154 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
154 int16_t number_bytes; 155 int16_t number_bytes;
155 156
156 // Create and init encoder memory. 157 // Create and init encoder memory.
157 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 158 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
158 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate, 159 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 8000, kSidNormalIntervalUpdate,
159 kCNGNumParamsNormal)); 160 kCNGNumParamsNormal));
160 161
161 // Run encoder with too much data. 162 // Run encoder with too much data.
162 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 641, sid_data, 163 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 641, sid_data,
163 &number_bytes, kNoSid)); 164 &number_bytes, kNoSid));
164 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); 165 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_));
165 166
166 // Free encoder memory. 167 // Free encoder memory.
167 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 168 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
168 } 169 }
169 170
170 // Call encode without calling init. 171 // Call encode without calling init.
171 TEST_F(CngTest, CngEncodeNoInit) { 172 TEST_F(CngTest, DISABLED_ON_IOS(CngEncodeNoInit)) {
172 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 173 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
173 int16_t number_bytes; 174 int16_t number_bytes;
174 175
175 // Create encoder memory. 176 // Create encoder memory.
176 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 177 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
177 178
178 // Run encoder without calling init. 179 // Run encoder without calling init.
179 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data, 180 EXPECT_EQ(-1, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 640, sid_data,
180 &number_bytes, kNoSid)); 181 &number_bytes, kNoSid));
181 EXPECT_EQ(6120, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_)); 182 EXPECT_EQ(6120, WebRtcCng_GetErrorCodeEnc(cng_enc_inst_));
182 183
183 // Free encoder memory. 184 // Free encoder memory.
184 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 185 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
185 } 186 }
186 187
187 // Update SID parameters, for both 9 and 16 parameters. 188 // Update SID parameters, for both 9 and 16 parameters.
188 TEST_F(CngTest, CngUpdateSid) { 189 TEST_F(CngTest, DISABLED_ON_IOS(CngUpdateSid)) {
189 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 190 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
190 int16_t number_bytes; 191 int16_t number_bytes;
191 192
192 // Create and initialize encoder and decoder memory. 193 // Create and initialize encoder and decoder memory.
193 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 194 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
194 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 195 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
195 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, 196 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate,
196 kCNGNumParamsNormal)); 197 kCNGNumParamsNormal));
197 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); 198 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_));
198 199
(...skipping 16 matching lines...) Expand all
215 kForceSid)); 216 kForceSid));
216 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, 217 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data,
217 kCNGNumParamsNormal + 1)); 218 kCNGNumParamsNormal + 1));
218 219
219 // Free encoder and decoder memory. 220 // Free encoder and decoder memory.
220 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 221 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
221 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 222 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
222 } 223 }
223 224
224 // Update SID parameters, with wrong parameters or without calling decode. 225 // Update SID parameters, with wrong parameters or without calling decode.
225 TEST_F(CngTest, CngUpdateSidErroneous) { 226 TEST_F(CngTest, DISABLED_ON_IOS(CngUpdateSidErroneous)) {
226 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 227 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
227 int16_t number_bytes; 228 int16_t number_bytes;
228 229
229 // Create encoder and decoder memory. 230 // Create encoder and decoder memory.
230 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 231 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
231 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 232 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
232 233
233 // Encode. 234 // Encode.
234 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, 235 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate,
235 kCNGNumParamsNormal)); 236 kCNGNumParamsNormal));
(...skipping 15 matching lines...) Expand all
251 kCNGNumParamsNormal + 1)); 252 kCNGNumParamsNormal + 1));
252 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data, 253 EXPECT_EQ(0, WebRtcCng_UpdateSid(cng_dec_inst_, sid_data,
253 kCNGNumParamsTooHigh + 1)); 254 kCNGNumParamsTooHigh + 1));
254 255
255 // Free encoder and decoder memory. 256 // Free encoder and decoder memory.
256 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 257 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
257 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 258 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
258 } 259 }
259 260
260 // Test to generate cng data, by forcing SID. Both normal and faulty condition. 261 // Test to generate cng data, by forcing SID. Both normal and faulty condition.
261 TEST_F(CngTest, CngGenerate) { 262 TEST_F(CngTest, DISABLED_ON_IOS(CngGenerate)) {
262 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 263 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
263 int16_t out_data[640]; 264 int16_t out_data[640];
264 int16_t number_bytes; 265 int16_t number_bytes;
265 266
266 // Create and initialize encoder and decoder memory. 267 // Create and initialize encoder and decoder memory.
267 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 268 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
268 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 269 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
269 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, 270 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate,
270 kCNGNumParamsNormal)); 271 kCNGNumParamsNormal));
271 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); 272 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_));
(...skipping 13 matching lines...) Expand all
285 // Call Genereate with too much data. 286 // Call Genereate with too much data.
286 EXPECT_EQ(-1, WebRtcCng_Generate(cng_dec_inst_, out_data, 641, 0)); 287 EXPECT_EQ(-1, WebRtcCng_Generate(cng_dec_inst_, out_data, 641, 0));
287 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeDec(cng_dec_inst_)); 288 EXPECT_EQ(6140, WebRtcCng_GetErrorCodeDec(cng_dec_inst_));
288 289
289 // Free encoder and decoder memory. 290 // Free encoder and decoder memory.
290 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 291 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
291 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 292 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
292 } 293 }
293 294
294 // Test automatic SID. 295 // Test automatic SID.
295 TEST_F(CngTest, CngAutoSid) { 296 TEST_F(CngTest, DISABLED_ON_IOS(CngAutoSid)) {
296 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 297 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
297 int16_t number_bytes; 298 int16_t number_bytes;
298 299
299 // Create and initialize encoder and decoder memory. 300 // Create and initialize encoder and decoder memory.
300 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 301 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
301 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 302 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
302 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate, 303 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidNormalIntervalUpdate,
303 kCNGNumParamsNormal)); 304 kCNGNumParamsNormal));
304 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); 305 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_));
305 306
306 // Normal Encode, 100 msec, where no SID data should be generated. 307 // Normal Encode, 100 msec, where no SID data should be generated.
307 for (int i = 0; i < 10; i++) { 308 for (int i = 0; i < 10; i++) {
308 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, 309 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data,
309 &number_bytes, kNoSid)); 310 &number_bytes, kNoSid));
310 } 311 }
311 312
312 // We have reached 100 msec, and SID data should be generated. 313 // We have reached 100 msec, and SID data should be generated.
313 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( 314 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode(
314 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); 315 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid));
315 316
316 // Free encoder and decoder memory. 317 // Free encoder and decoder memory.
317 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 318 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
318 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 319 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
319 } 320 }
320 321
321 // Test automatic SID, with very short interval. 322 // Test automatic SID, with very short interval.
322 TEST_F(CngTest, CngAutoSidShort) { 323 TEST_F(CngTest, DISABLED_ON_IOS(CngAutoSidShort)) {
323 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1]; 324 uint8_t sid_data[WEBRTC_CNG_MAX_LPC_ORDER + 1];
324 int16_t number_bytes; 325 int16_t number_bytes;
325 326
326 // Create and initialize encoder and decoder memory. 327 // Create and initialize encoder and decoder memory.
327 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_)); 328 EXPECT_EQ(0, WebRtcCng_CreateEnc(&cng_enc_inst_));
328 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_)); 329 EXPECT_EQ(0, WebRtcCng_CreateDec(&cng_dec_inst_));
329 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidShortIntervalUpdate, 330 EXPECT_EQ(0, WebRtcCng_InitEnc(cng_enc_inst_, 16000, kSidShortIntervalUpdate,
330 kCNGNumParamsNormal)); 331 kCNGNumParamsNormal));
331 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_)); 332 EXPECT_EQ(0, WebRtcCng_InitDec(cng_dec_inst_));
332 333
333 // First call will never generate SID, unless forced to. 334 // First call will never generate SID, unless forced to.
334 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data, 335 EXPECT_EQ(0, WebRtcCng_Encode(cng_enc_inst_, speech_data_, 160, sid_data,
335 &number_bytes, kNoSid)); 336 &number_bytes, kNoSid));
336 337
337 // Normal Encode, 100 msec, SID data should be generated all the time. 338 // Normal Encode, 100 msec, SID data should be generated all the time.
338 for (int i = 0; i < 10; i++) { 339 for (int i = 0; i < 10; i++) {
339 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode( 340 EXPECT_EQ(kCNGNumParamsNormal + 1, WebRtcCng_Encode(
340 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid)); 341 cng_enc_inst_, speech_data_, 160, sid_data, &number_bytes, kNoSid));
341 } 342 }
342 343
343 // Free encoder and decoder memory. 344 // Free encoder and decoder memory.
344 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_)); 345 EXPECT_EQ(0, WebRtcCng_FreeEnc(cng_enc_inst_));
345 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_)); 346 EXPECT_EQ(0, WebRtcCng_FreeDec(cng_dec_inst_));
346 } 347 }
347 348
348 } // namespace webrtc 349 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/codecs/isac/main/source/isac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698