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

Side by Side Diff: webrtc/modules/audio_processing/ns/nsx_core.c

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 3 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 188, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 61 188, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200,
62 201, 202, 203, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 212, 62 201, 202, 203, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 212,
63 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 224, 63 213, 214, 215, 216, 216, 217, 218, 219, 220, 220, 221, 222, 223, 224, 224,
64 225, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 64 225, 226, 227, 228, 228, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236,
65 237, 238, 238, 239, 240, 241, 241, 242, 243, 244, 244, 245, 246, 247, 247, 65 237, 238, 238, 239, 240, 241, 241, 242, 243, 244, 244, 245, 246, 247, 247,
66 248, 249, 249, 250, 251, 252, 252, 253, 254, 255, 255 66 248, 249, 249, 250, 251, 252, 252, 253, 254, 255, 255
67 }; 67 };
68 #endif // WEBRTC_DETECT_NEON || WEBRTC_HAS_NEON 68 #endif // WEBRTC_DETECT_NEON || WEBRTC_HAS_NEON
69 69
70 // Skip first frequency bins during estimation. (0 <= value < 64) 70 // Skip first frequency bins during estimation. (0 <= value < 64)
71 static const int kStartBand = 5; 71 static const size_t kStartBand = 5;
72 72
73 // hybrib Hanning & flat window 73 // hybrib Hanning & flat window
74 static const int16_t kBlocks80w128x[128] = { 74 static const int16_t kBlocks80w128x[128] = {
75 0, 536, 1072, 1606, 2139, 2669, 3196, 3720, 4240, 4756, 5 266, 75 0, 536, 1072, 1606, 2139, 2669, 3196, 3720, 4240, 4756, 5 266,
76 5771, 6270, 6762, 7246, 7723, 8192, 8652, 9102, 9543, 9974, 10394, 76 5771, 6270, 6762, 7246, 7723, 8192, 8652, 9102, 9543, 9974, 10394,
77 10803, 11200, 11585, 11958, 12318, 12665, 12998, 13318, 13623, 13913, 14189, 77 10803, 11200, 11585, 11958, 12318, 12665, 12998, 13318, 13623, 13913, 14189,
78 14449, 14694, 14924, 15137, 15334, 15515, 15679, 15826, 15956, 16069, 16165, 78 14449, 14694, 14924, 15137, 15334, 15515, 15679, 15826, 15956, 16069, 16165,
79 16244, 16305, 16349, 16375, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 79 16244, 16305, 16349, 16375, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
80 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 80 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
81 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 81 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384,
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 355, 330 299 355, 330
300 }; 300 };
301 301
302 // Update the noise estimation information. 302 // Update the noise estimation information.
303 static void UpdateNoiseEstimate(NoiseSuppressionFixedC* inst, int offset) { 303 static void UpdateNoiseEstimate(NoiseSuppressionFixedC* inst, int offset) {
304 int32_t tmp32no1 = 0; 304 int32_t tmp32no1 = 0;
305 int32_t tmp32no2 = 0; 305 int32_t tmp32no2 = 0;
306 int16_t tmp16 = 0; 306 int16_t tmp16 = 0;
307 const int16_t kExp2Const = 11819; // Q13 307 const int16_t kExp2Const = 11819; // Q13
308 308
309 int i = 0; 309 size_t i = 0;
310 310
311 tmp16 = WebRtcSpl_MaxValueW16(inst->noiseEstLogQuantile + offset, 311 tmp16 = WebRtcSpl_MaxValueW16(inst->noiseEstLogQuantile + offset,
312 inst->magnLen); 312 inst->magnLen);
313 // Guarantee a Q-domain as high as possible and still fit in int16 313 // Guarantee a Q-domain as high as possible and still fit in int16
314 inst->qNoise = 14 - (int) WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( 314 inst->qNoise = 14 - (int) WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
315 kExp2Const, tmp16, 21); 315 kExp2Const, tmp16, 21);
316 for (i = 0; i < inst->magnLen; i++) { 316 for (i = 0; i < inst->magnLen; i++) {
317 // inst->quantile[i]=exp(inst->lquantile[offset+i]); 317 // inst->quantile[i]=exp(inst->lquantile[offset+i]);
318 // in Q21 318 // in Q21
319 tmp32no2 = kExp2Const * inst->noiseEstLogQuantile[offset + i]; 319 tmp32no2 = kExp2Const * inst->noiseEstLogQuantile[offset + i];
(...skipping 14 matching lines...) Expand all
334 static void NoiseEstimationC(NoiseSuppressionFixedC* inst, 334 static void NoiseEstimationC(NoiseSuppressionFixedC* inst,
335 uint16_t* magn, 335 uint16_t* magn,
336 uint32_t* noise, 336 uint32_t* noise,
337 int16_t* q_noise) { 337 int16_t* q_noise) {
338 int16_t lmagn[HALF_ANAL_BLOCKL], counter, countDiv; 338 int16_t lmagn[HALF_ANAL_BLOCKL], counter, countDiv;
339 int16_t countProd, delta, zeros, frac; 339 int16_t countProd, delta, zeros, frac;
340 int16_t log2, tabind, logval, tmp16, tmp16no1, tmp16no2; 340 int16_t log2, tabind, logval, tmp16, tmp16no1, tmp16no2;
341 const int16_t log2_const = 22713; // Q15 341 const int16_t log2_const = 22713; // Q15
342 const int16_t width_factor = 21845; 342 const int16_t width_factor = 21845;
343 343
344 int i, s, offset; 344 size_t i, s, offset;
345 345
346 tabind = inst->stages - inst->normData; 346 tabind = inst->stages - inst->normData;
347 assert(tabind < 9); 347 assert(tabind < 9);
348 assert(tabind > -9); 348 assert(tabind > -9);
349 if (tabind < 0) { 349 if (tabind < 0) {
350 logval = -WebRtcNsx_kLogTable[-tabind]; 350 logval = -WebRtcNsx_kLogTable[-tabind];
351 } else { 351 } else {
352 logval = WebRtcNsx_kLogTable[tabind]; 352 logval = WebRtcNsx_kLogTable[tabind];
353 } 353 }
354 354
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 } 447 }
448 448
449 for (i = 0; i < inst->magnLen; i++) { 449 for (i = 0; i < inst->magnLen; i++) {
450 noise[i] = (uint32_t)(inst->noiseEstQuantile[i]); // Q(qNoise) 450 noise[i] = (uint32_t)(inst->noiseEstQuantile[i]); // Q(qNoise)
451 } 451 }
452 (*q_noise) = (int16_t)inst->qNoise; 452 (*q_noise) = (int16_t)inst->qNoise;
453 } 453 }
454 454
455 // Filter the data in the frequency domain, and create spectrum. 455 // Filter the data in the frequency domain, and create spectrum.
456 static void PrepareSpectrumC(NoiseSuppressionFixedC* inst, int16_t* freq_buf) { 456 static void PrepareSpectrumC(NoiseSuppressionFixedC* inst, int16_t* freq_buf) {
457 int i = 0, j = 0; 457 size_t i = 0, j = 0;
458 458
459 for (i = 0; i < inst->magnLen; i++) { 459 for (i = 0; i < inst->magnLen; i++) {
460 inst->real[i] = (int16_t)((inst->real[i] * 460 inst->real[i] = (int16_t)((inst->real[i] *
461 (int16_t)(inst->noiseSupFilter[i])) >> 14); // Q(normData-stages) 461 (int16_t)(inst->noiseSupFilter[i])) >> 14); // Q(normData-stages)
462 inst->imag[i] = (int16_t)((inst->imag[i] * 462 inst->imag[i] = (int16_t)((inst->imag[i] *
463 (int16_t)(inst->noiseSupFilter[i])) >> 14); // Q(normData-stages) 463 (int16_t)(inst->noiseSupFilter[i])) >> 14); // Q(normData-stages)
464 } 464 }
465 465
466 freq_buf[0] = inst->real[0]; 466 freq_buf[0] = inst->real[0];
467 freq_buf[1] = -inst->imag[0]; 467 freq_buf[1] = -inst->imag[0];
468 for (i = 1, j = 2; i < inst->anaLen2; i += 1, j += 2) { 468 for (i = 1, j = 2; i < inst->anaLen2; i += 1, j += 2) {
469 freq_buf[j] = inst->real[i]; 469 freq_buf[j] = inst->real[i];
470 freq_buf[j + 1] = -inst->imag[i]; 470 freq_buf[j + 1] = -inst->imag[i];
471 } 471 }
472 freq_buf[inst->anaLen] = inst->real[inst->anaLen2]; 472 freq_buf[inst->anaLen] = inst->real[inst->anaLen2];
473 freq_buf[inst->anaLen + 1] = -inst->imag[inst->anaLen2]; 473 freq_buf[inst->anaLen + 1] = -inst->imag[inst->anaLen2];
474 } 474 }
475 475
476 // Denormalize the real-valued signal |in|, the output from inverse FFT. 476 // Denormalize the real-valued signal |in|, the output from inverse FFT.
477 static void DenormalizeC(NoiseSuppressionFixedC* inst, 477 static void DenormalizeC(NoiseSuppressionFixedC* inst,
478 int16_t* in, 478 int16_t* in,
479 int factor) { 479 int factor) {
480 int i = 0; 480 size_t i = 0;
481 int32_t tmp32 = 0; 481 int32_t tmp32 = 0;
482 for (i = 0; i < inst->anaLen; i += 1) { 482 for (i = 0; i < inst->anaLen; i += 1) {
483 tmp32 = WEBRTC_SPL_SHIFT_W32((int32_t)in[i], 483 tmp32 = WEBRTC_SPL_SHIFT_W32((int32_t)in[i],
484 factor - inst->normData); 484 factor - inst->normData);
485 inst->real[i] = WebRtcSpl_SatW32ToW16(tmp32); // Q0 485 inst->real[i] = WebRtcSpl_SatW32ToW16(tmp32); // Q0
486 } 486 }
487 } 487 }
488 488
489 // For the noise supression process, synthesis, read out fully processed 489 // For the noise supression process, synthesis, read out fully processed
490 // segment, and update synthesis buffer. 490 // segment, and update synthesis buffer.
491 static void SynthesisUpdateC(NoiseSuppressionFixedC* inst, 491 static void SynthesisUpdateC(NoiseSuppressionFixedC* inst,
492 int16_t* out_frame, 492 int16_t* out_frame,
493 int16_t gain_factor) { 493 int16_t gain_factor) {
494 int i = 0; 494 size_t i = 0;
495 int16_t tmp16a = 0; 495 int16_t tmp16a = 0;
496 int16_t tmp16b = 0; 496 int16_t tmp16b = 0;
497 int32_t tmp32 = 0; 497 int32_t tmp32 = 0;
498 498
499 // synthesis 499 // synthesis
500 for (i = 0; i < inst->anaLen; i++) { 500 for (i = 0; i < inst->anaLen; i++) {
501 tmp16a = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( 501 tmp16a = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
502 inst->window[i], inst->real[i], 14); // Q0, window in Q14 502 inst->window[i], inst->real[i], 14); // Q0, window in Q14
503 tmp32 = WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(tmp16a, gain_factor, 13); // Q0 503 tmp32 = WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(tmp16a, gain_factor, 13); // Q0
504 // Down shift with rounding 504 // Down shift with rounding
(...skipping 11 matching lines...) Expand all
516 memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms, 516 memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
517 (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer)); 517 (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
518 WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer 518 WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
519 + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms); 519 + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
520 } 520 }
521 521
522 // Update analysis buffer for lower band, and window data before FFT. 522 // Update analysis buffer for lower band, and window data before FFT.
523 static void AnalysisUpdateC(NoiseSuppressionFixedC* inst, 523 static void AnalysisUpdateC(NoiseSuppressionFixedC* inst,
524 int16_t* out, 524 int16_t* out,
525 int16_t* new_speech) { 525 int16_t* new_speech) {
526 int i = 0; 526 size_t i = 0;
527 527
528 // For lower band update analysis buffer. 528 // For lower band update analysis buffer.
529 memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms, 529 memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
530 (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer)); 530 (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
531 memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech, 531 memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech,
532 inst->blockLen10ms * sizeof(*inst->analysisBuffer)); 532 inst->blockLen10ms * sizeof(*inst->analysisBuffer));
533 533
534 // Window data before FFT. 534 // Window data before FFT.
535 for (i = 0; i < inst->anaLen; i++) { 535 for (i = 0; i < inst->anaLen; i++) {
536 out[i] = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND( 536 out[i] = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
537 inst->window[i], inst->analysisBuffer[i], 14); // Q0 537 inst->window[i], inst->analysisBuffer[i], 14); // Q0
538 } 538 }
539 } 539 }
540 540
541 // Normalize the real-valued signal |in|, the input to forward FFT. 541 // Normalize the real-valued signal |in|, the input to forward FFT.
542 static void NormalizeRealBufferC(NoiseSuppressionFixedC* inst, 542 static void NormalizeRealBufferC(NoiseSuppressionFixedC* inst,
543 const int16_t* in, 543 const int16_t* in,
544 int16_t* out) { 544 int16_t* out) {
545 int i = 0; 545 size_t i = 0;
546 assert(inst->normData >= 0); 546 assert(inst->normData >= 0);
547 for (i = 0; i < inst->anaLen; ++i) { 547 for (i = 0; i < inst->anaLen; ++i) {
548 out[i] = in[i] << inst->normData; // Q(normData) 548 out[i] = in[i] << inst->normData; // Q(normData)
549 } 549 }
550 } 550 }
551 551
552 // Declare function pointers. 552 // Declare function pointers.
553 NoiseEstimation WebRtcNsx_NoiseEstimation; 553 NoiseEstimation WebRtcNsx_NoiseEstimation;
554 PrepareSpectrum WebRtcNsx_PrepareSpectrum; 554 PrepareSpectrum WebRtcNsx_PrepareSpectrum;
555 SynthesisUpdate WebRtcNsx_SynthesisUpdate; 555 SynthesisUpdate WebRtcNsx_SynthesisUpdate;
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 void WebRtcNsx_ComputeSpectralFlatness(NoiseSuppressionFixedC* inst, 1019 void WebRtcNsx_ComputeSpectralFlatness(NoiseSuppressionFixedC* inst,
1020 uint16_t* magn) { 1020 uint16_t* magn) {
1021 uint32_t tmpU32; 1021 uint32_t tmpU32;
1022 uint32_t avgSpectralFlatnessNum, avgSpectralFlatnessDen; 1022 uint32_t avgSpectralFlatnessNum, avgSpectralFlatnessDen;
1023 1023
1024 int32_t tmp32; 1024 int32_t tmp32;
1025 int32_t currentSpectralFlatness, logCurSpectralFlatness; 1025 int32_t currentSpectralFlatness, logCurSpectralFlatness;
1026 1026
1027 int16_t zeros, frac, intPart; 1027 int16_t zeros, frac, intPart;
1028 1028
1029 int i; 1029 size_t i;
1030 1030
1031 // for flatness 1031 // for flatness
1032 avgSpectralFlatnessNum = 0; 1032 avgSpectralFlatnessNum = 0;
1033 avgSpectralFlatnessDen = inst->sumMagn - (uint32_t)magn[0]; // Q(normData-stag es) 1033 avgSpectralFlatnessDen = inst->sumMagn - (uint32_t)magn[0]; // Q(normData-stag es)
1034 1034
1035 // compute log of ratio of the geometric to arithmetic mean: check for log(0) case 1035 // compute log of ratio of the geometric to arithmetic mean: check for log(0) case
1036 // flatness = exp( sum(log(magn[i]))/N - log(sum(magn[i])/N) ) 1036 // flatness = exp( sum(log(magn[i]))/N - log(sum(magn[i])/N) )
1037 // = exp( sum(log(magn[i]))/N ) * N / sum(magn[i]) 1037 // = exp( sum(log(magn[i]))/N ) * N / sum(magn[i])
1038 // = 2^( sum(log2(magn[i]))/N - (log2(sum(magn[i])) - log2(N)) ) [Thi s is used] 1038 // = 2^( sum(log2(magn[i]))/N - (log2(sum(magn[i])) - log2(N)) ) [Thi s is used]
1039 for (i = 1; i < inst->magnLen; i++) { 1039 for (i = 1; i < inst->magnLen; i++) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 uint32_t tmpU32no1, tmpU32no2; 1093 uint32_t tmpU32no1, tmpU32no2;
1094 uint32_t varMagnUFX, varPauseUFX, avgDiffNormMagnUFX; 1094 uint32_t varMagnUFX, varPauseUFX, avgDiffNormMagnUFX;
1095 1095
1096 int32_t tmp32no1, tmp32no2; 1096 int32_t tmp32no1, tmp32no2;
1097 int32_t avgPauseFX, avgMagnFX, covMagnPauseFX; 1097 int32_t avgPauseFX, avgMagnFX, covMagnPauseFX;
1098 int32_t maxPause, minPause; 1098 int32_t maxPause, minPause;
1099 1099
1100 int16_t tmp16no1; 1100 int16_t tmp16no1;
1101 1101
1102 int i, norm32, nShifts; 1102 size_t i;
1103 int norm32, nShifts;
1103 1104
1104 avgPauseFX = 0; 1105 avgPauseFX = 0;
1105 maxPause = 0; 1106 maxPause = 0;
1106 minPause = inst->avgMagnPause[0]; // Q(prevQMagn) 1107 minPause = inst->avgMagnPause[0]; // Q(prevQMagn)
1107 // compute average quantities 1108 // compute average quantities
1108 for (i = 0; i < inst->magnLen; i++) { 1109 for (i = 0; i < inst->magnLen; i++) {
1109 // Compute mean of magn_pause 1110 // Compute mean of magn_pause
1110 avgPauseFX += inst->avgMagnPause[i]; // in Q(prevQMagn) 1111 avgPauseFX += inst->avgMagnPause[i]; // in Q(prevQMagn)
1111 maxPause = WEBRTC_SPL_MAX(maxPause, inst->avgMagnPause[i]); 1112 maxPause = WEBRTC_SPL_MAX(maxPause, inst->avgMagnPause[i]);
1112 minPause = WEBRTC_SPL_MIN(minPause, inst->avgMagnPause[i]); 1113 minPause = WEBRTC_SPL_MIN(minPause, inst->avgMagnPause[i]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 uint16_t sum_log_magn_u16 = 0; 1192 uint16_t sum_log_magn_u16 = 0;
1192 uint16_t tmp_u16 = 0; 1193 uint16_t tmp_u16 = 0;
1193 1194
1194 int16_t sum_log_i = 0; 1195 int16_t sum_log_i = 0;
1195 int16_t sum_log_i_square = 0; 1196 int16_t sum_log_i_square = 0;
1196 int16_t frac = 0; 1197 int16_t frac = 0;
1197 int16_t log2 = 0; 1198 int16_t log2 = 0;
1198 int16_t matrix_determinant = 0; 1199 int16_t matrix_determinant = 0;
1199 int16_t maxWinData; 1200 int16_t maxWinData;
1200 1201
1201 int i, j; 1202 size_t i, j;
1202 int zeros; 1203 int zeros;
1203 int net_norm = 0; 1204 int net_norm = 0;
1204 int right_shifts_in_magnU16 = 0; 1205 int right_shifts_in_magnU16 = 0;
1205 int right_shifts_in_initMagnEst = 0; 1206 int right_shifts_in_initMagnEst = 0;
1206 1207
1207 int16_t winData_buff[ANAL_BLOCKL_MAX * 2 + 16]; 1208 int16_t winData_buff[ANAL_BLOCKL_MAX * 2 + 16];
1208 int16_t realImag_buff[ANAL_BLOCKL_MAX * 2 + 16]; 1209 int16_t realImag_buff[ANAL_BLOCKL_MAX * 2 + 16];
1209 1210
1210 // Align the structures to 32-byte boundary for the FFT function. 1211 // Align the structures to 32-byte boundary for the FFT function.
1211 int16_t* winData = (int16_t*) (((uintptr_t)winData_buff + 31) & ~31); 1212 int16_t* winData = (int16_t*) (((uintptr_t)winData_buff + 31) & ~31);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 int16_t rfft_out_buff[ANAL_BLOCKL_MAX * 2 + 16]; 1424 int16_t rfft_out_buff[ANAL_BLOCKL_MAX * 2 + 16];
1424 1425
1425 // Align the structures to 32-byte boundary for the FFT function. 1426 // Align the structures to 32-byte boundary for the FFT function.
1426 int16_t* realImag = (int16_t*) (((uintptr_t)realImag_buff + 31) & ~31); 1427 int16_t* realImag = (int16_t*) (((uintptr_t)realImag_buff + 31) & ~31);
1427 int16_t* rfft_out = (int16_t*) (((uintptr_t) rfft_out_buff + 31) & ~31); 1428 int16_t* rfft_out = (int16_t*) (((uintptr_t) rfft_out_buff + 31) & ~31);
1428 1429
1429 int16_t tmp16no1, tmp16no2; 1430 int16_t tmp16no1, tmp16no2;
1430 int16_t energyRatio; 1431 int16_t energyRatio;
1431 int16_t gainFactor, gainFactor1, gainFactor2; 1432 int16_t gainFactor, gainFactor1, gainFactor2;
1432 1433
1433 int i; 1434 size_t i;
1434 int outCIFFT; 1435 int outCIFFT;
1435 int scaleEnergyOut = 0; 1436 int scaleEnergyOut = 0;
1436 1437
1437 if (inst->zeroInputSignal) { 1438 if (inst->zeroInputSignal) {
1438 // synthesize the special case of zero input 1439 // synthesize the special case of zero input
1439 // read out fully processed segment 1440 // read out fully processed segment
1440 for (i = 0; i < inst->blockLen10ms; i++) { 1441 for (i = 0; i < inst->blockLen10ms; i++) {
1441 outFrame[i] = inst->synthesisBuffer[i]; // Q0 1442 outFrame[i] = inst->synthesisBuffer[i]; // Q0
1442 } 1443 }
1443 // update synthesis buffer 1444 // update synthesis buffer
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 uint16_t magnU16[HALF_ANAL_BLOCKL]; 1525 uint16_t magnU16[HALF_ANAL_BLOCKL];
1525 uint16_t prevNoiseU16[HALF_ANAL_BLOCKL]; 1526 uint16_t prevNoiseU16[HALF_ANAL_BLOCKL];
1526 uint16_t nonSpeechProbFinal[HALF_ANAL_BLOCKL]; 1527 uint16_t nonSpeechProbFinal[HALF_ANAL_BLOCKL];
1527 uint16_t gammaNoise, prevGammaNoise; 1528 uint16_t gammaNoise, prevGammaNoise;
1528 uint16_t noiseSupFilterTmp[HALF_ANAL_BLOCKL]; 1529 uint16_t noiseSupFilterTmp[HALF_ANAL_BLOCKL];
1529 1530
1530 int16_t qMagn, qNoise; 1531 int16_t qMagn, qNoise;
1531 int16_t avgProbSpeechHB, gainModHB, avgFilterGainHB, gainTimeDomainHB; 1532 int16_t avgProbSpeechHB, gainModHB, avgFilterGainHB, gainTimeDomainHB;
1532 int16_t pink_noise_exp_avg = 0; 1533 int16_t pink_noise_exp_avg = 0;
1533 1534
1534 int i, j; 1535 size_t i, j;
1535 int nShifts, postShifts; 1536 int nShifts, postShifts;
1536 int norm32no1, norm32no2; 1537 int norm32no1, norm32no2;
1537 int flag, sign; 1538 int flag, sign;
1538 int q_domain_to_use = 0; 1539 int q_domain_to_use = 0;
1539 1540
1540 // Code for ARMv7-Neon platform assumes the following: 1541 // Code for ARMv7-Neon platform assumes the following:
1541 assert(inst->anaLen > 0); 1542 assert(inst->anaLen > 0);
1542 assert(inst->anaLen2 > 0); 1543 assert(inst->anaLen2 > 0);
1543 assert(inst->anaLen % 16 == 0); 1544 assert(inst->anaLen % 16 == 0);
1544 assert(inst->anaLen2 % 8 == 0); 1545 assert(inst->anaLen2 % 8 == 0);
1545 assert(inst->blockLen10ms > 0); 1546 assert(inst->blockLen10ms > 0);
1546 assert(inst->blockLen10ms % 16 == 0); 1547 assert(inst->blockLen10ms % 16 == 0);
1547 assert(inst->magnLen == inst->anaLen2 + 1); 1548 assert(inst->magnLen == inst->anaLen2 + 1);
1548 1549
1549 #ifdef NS_FILEDEBUG 1550 #ifdef NS_FILEDEBUG
1550 if (fwrite(spframe, sizeof(short), 1551 if (fwrite(spframe, sizeof(short),
1551 inst->blockLen10ms, inst->infile) != inst->blockLen10ms) { 1552 inst->blockLen10ms, inst->infile) != inst->blockLen10ms) {
1552 assert(false); 1553 assert(false);
1553 } 1554 }
1554 #endif 1555 #endif
1555 1556
1556 // Check that initialization has been done 1557 // Check that initialization has been done
1557 assert(inst->initFlag == 1); 1558 assert(inst->initFlag == 1);
1558 assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX); 1559 assert((num_bands - 1) <= NUM_HIGH_BANDS_MAX);
1559 1560
1560 const short* const* speechFrameHB = NULL; 1561 const short* const* speechFrameHB = NULL;
1561 short* const* outFrameHB = NULL; 1562 short* const* outFrameHB = NULL;
1562 int num_high_bands = 0; 1563 size_t num_high_bands = 0;
1563 if (num_bands > 1) { 1564 if (num_bands > 1) {
1564 speechFrameHB = &speechFrame[1]; 1565 speechFrameHB = &speechFrame[1];
1565 outFrameHB = &outFrame[1]; 1566 outFrameHB = &outFrame[1];
1566 num_high_bands = num_bands - 1; 1567 num_high_bands = (size_t)(num_bands - 1);
1567 } 1568 }
1568 1569
1569 // Store speechFrame and transform to frequency domain 1570 // Store speechFrame and transform to frequency domain
1570 WebRtcNsx_DataAnalysis(inst, (short*)speechFrame[0], magnU16); 1571 WebRtcNsx_DataAnalysis(inst, (short*)speechFrame[0], magnU16);
1571 1572
1572 if (inst->zeroInputSignal) { 1573 if (inst->zeroInputSignal) {
1573 WebRtcNsx_DataSynthesis(inst, outFrame[0]); 1574 WebRtcNsx_DataSynthesis(inst, outFrame[0]);
1574 1575
1575 if (num_bands > 1) { 1576 if (num_bands > 1) {
1576 // update analysis buffer for H band 1577 // update analysis buffer for H band
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 2103
2103 //apply gain 2104 //apply gain
2104 for (i = 0; i < num_high_bands; ++i) { 2105 for (i = 0; i < num_high_bands; ++i) {
2105 for (j = 0; j < inst->blockLen10ms; j++) { 2106 for (j = 0; j < inst->blockLen10ms; j++) {
2106 outFrameHB[i][j] = (int16_t)((gainTimeDomainHB * 2107 outFrameHB[i][j] = (int16_t)((gainTimeDomainHB *
2107 inst->dataBufHBFX[i][j]) >> 14); // Q0 2108 inst->dataBufHBFX[i][j]) >> 14); // Q0
2108 } 2109 }
2109 } 2110 }
2110 } // end of H band gain computation 2111 } // end of H band gain computation
2111 } 2112 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/ns/nsx_core.h ('k') | webrtc/modules/audio_processing/ns/nsx_core_c.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698