OLD | NEW |
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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 float* imag, | 891 float* imag, |
892 float* magn) { | 892 float* magn) { |
893 int i; | 893 int i; |
894 | 894 |
895 assert(magnitude_length == time_data_length / 2 + 1); | 895 assert(magnitude_length == time_data_length / 2 + 1); |
896 | 896 |
897 WebRtc_rdft(time_data_length, 1, time_data, self->ip, self->wfft); | 897 WebRtc_rdft(time_data_length, 1, time_data, self->ip, self->wfft); |
898 | 898 |
899 imag[0] = 0; | 899 imag[0] = 0; |
900 real[0] = time_data[0]; | 900 real[0] = time_data[0]; |
901 magn[0] = fabs(real[0]) + 1.f; | 901 magn[0] = fabsf(real[0]) + 1.f; |
902 imag[magnitude_length - 1] = 0; | 902 imag[magnitude_length - 1] = 0; |
903 real[magnitude_length - 1] = time_data[1]; | 903 real[magnitude_length - 1] = time_data[1]; |
904 magn[magnitude_length - 1] = fabs(real[magnitude_length - 1]) + 1.f; | 904 magn[magnitude_length - 1] = fabsf(real[magnitude_length - 1]) + 1.f; |
905 for (i = 1; i < magnitude_length - 1; ++i) { | 905 for (i = 1; i < magnitude_length - 1; ++i) { |
906 real[i] = time_data[2 * i]; | 906 real[i] = time_data[2 * i]; |
907 imag[i] = time_data[2 * i + 1]; | 907 imag[i] = time_data[2 * i + 1]; |
908 // Magnitude spectrum. | 908 // Magnitude spectrum. |
909 magn[i] = sqrtf(real[i] * real[i] + imag[i] * imag[i]) + 1.f; | 909 magn[i] = sqrtf(real[i] * real[i] + imag[i] * imag[i]) + 1.f; |
910 } | 910 } |
911 } | 911 } |
912 | 912 |
913 // Transforms the signal from frequency to time domain. | 913 // Transforms the signal from frequency to time domain. |
914 // Inputs: | 914 // Inputs: |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1083 |
1084 self->blockInd++; // Update the block index only when we process a block. | 1084 self->blockInd++; // Update the block index only when we process a block. |
1085 | 1085 |
1086 FFT(self, winData, self->anaLen, self->magnLen, real, imag, magn); | 1086 FFT(self, winData, self->anaLen, self->magnLen, real, imag, magn); |
1087 | 1087 |
1088 for (i = 0; i < self->magnLen; i++) { | 1088 for (i = 0; i < self->magnLen; i++) { |
1089 signalEnergy += real[i] * real[i] + imag[i] * imag[i]; | 1089 signalEnergy += real[i] * real[i] + imag[i] * imag[i]; |
1090 sumMagn += magn[i]; | 1090 sumMagn += magn[i]; |
1091 if (self->blockInd < END_STARTUP_SHORT) { | 1091 if (self->blockInd < END_STARTUP_SHORT) { |
1092 if (i >= kStartBand) { | 1092 if (i >= kStartBand) { |
1093 tmpFloat2 = log((float)i); | 1093 tmpFloat2 = logf((float)i); |
1094 sum_log_i += tmpFloat2; | 1094 sum_log_i += tmpFloat2; |
1095 sum_log_i_square += tmpFloat2 * tmpFloat2; | 1095 sum_log_i_square += tmpFloat2 * tmpFloat2; |
1096 tmpFloat1 = log(magn[i]); | 1096 tmpFloat1 = logf(magn[i]); |
1097 sum_log_magn += tmpFloat1; | 1097 sum_log_magn += tmpFloat1; |
1098 sum_log_i_log_magn += tmpFloat2 * tmpFloat1; | 1098 sum_log_i_log_magn += tmpFloat2 * tmpFloat1; |
1099 } | 1099 } |
1100 } | 1100 } |
1101 } | 1101 } |
1102 signalEnergy = signalEnergy / ((float)self->magnLen); | 1102 signalEnergy = signalEnergy / ((float)self->magnLen); |
1103 self->signalEnergy = signalEnergy; | 1103 self->signalEnergy = signalEnergy; |
1104 self->sumMagn = sumMagn; | 1104 self->sumMagn = sumMagn; |
1105 | 1105 |
1106 // Quantile noise estimate. | 1106 // Quantile noise estimate. |
(...skipping 22 matching lines...) Expand all Loading... |
1129 } | 1129 } |
1130 if (tmpFloat3 > 1.f) { | 1130 if (tmpFloat3 > 1.f) { |
1131 tmpFloat3 = 1.f; | 1131 tmpFloat3 = 1.f; |
1132 } | 1132 } |
1133 self->pinkNoiseExp += tmpFloat3; | 1133 self->pinkNoiseExp += tmpFloat3; |
1134 | 1134 |
1135 // Calculate frequency independent parts of parametric noise estimate. | 1135 // Calculate frequency independent parts of parametric noise estimate. |
1136 if (self->pinkNoiseExp > 0.f) { | 1136 if (self->pinkNoiseExp > 0.f) { |
1137 // Use pink noise estimate. | 1137 // Use pink noise estimate. |
1138 parametric_num = | 1138 parametric_num = |
1139 exp(self->pinkNoiseNumerator / (float)(self->blockInd + 1)); | 1139 expf(self->pinkNoiseNumerator / (float)(self->blockInd + 1)); |
1140 parametric_num *= (float)(self->blockInd + 1); | 1140 parametric_num *= (float)(self->blockInd + 1); |
1141 parametric_exp = self->pinkNoiseExp / (float)(self->blockInd + 1); | 1141 parametric_exp = self->pinkNoiseExp / (float)(self->blockInd + 1); |
1142 } | 1142 } |
1143 for (i = 0; i < self->magnLen; i++) { | 1143 for (i = 0; i < self->magnLen; i++) { |
1144 // Estimate the background noise using the white and pink noise | 1144 // Estimate the background noise using the white and pink noise |
1145 // parameters. | 1145 // parameters. |
1146 if (self->pinkNoiseExp == 0.f) { | 1146 if (self->pinkNoiseExp == 0.f) { |
1147 // Use white noise estimate. | 1147 // Use white noise estimate. |
1148 self->parametricNoise[i] = self->whiteNoiseLevel; | 1148 self->parametricNoise[i] = self->whiteNoiseLevel; |
1149 } else { | 1149 } else { |
1150 // Use pink noise estimate. | 1150 // Use pink noise estimate. |
1151 float use_band = (float)(i < kStartBand ? kStartBand : i); | 1151 float use_band = (float)(i < kStartBand ? kStartBand : i); |
1152 self->parametricNoise[i] = | 1152 self->parametricNoise[i] = |
1153 parametric_num / pow(use_band, parametric_exp); | 1153 parametric_num / powf(use_band, parametric_exp); |
1154 } | 1154 } |
1155 // Weight quantile noise with modeled noise. | 1155 // Weight quantile noise with modeled noise. |
1156 noise[i] *= (self->blockInd); | 1156 noise[i] *= (self->blockInd); |
1157 tmpFloat2 = | 1157 tmpFloat2 = |
1158 self->parametricNoise[i] * (END_STARTUP_SHORT - self->blockInd); | 1158 self->parametricNoise[i] * (END_STARTUP_SHORT - self->blockInd); |
1159 noise[i] += (tmpFloat2 / (float)(self->blockInd + 1)); | 1159 noise[i] += (tmpFloat2 / (float)(self->blockInd + 1)); |
1160 noise[i] /= END_STARTUP_SHORT; | 1160 noise[i] /= END_STARTUP_SHORT; |
1161 } | 1161 } |
1162 } | 1162 } |
1163 // Compute average signal during END_STARTUP_LONG time: | 1163 // Compute average signal during END_STARTUP_LONG time: |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 for (i = 0; i < num_high_bands; ++i) { | 1406 for (i = 0; i < num_high_bands; ++i) { |
1407 for (j = 0; j < self->blockLen; j++) { | 1407 for (j = 0; j < self->blockLen; j++) { |
1408 outFrameHB[i][j] = | 1408 outFrameHB[i][j] = |
1409 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, | 1409 WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, |
1410 gainTimeDomainHB * self->dataBufHB[i][j], | 1410 gainTimeDomainHB * self->dataBufHB[i][j], |
1411 WEBRTC_SPL_WORD16_MIN); | 1411 WEBRTC_SPL_WORD16_MIN); |
1412 } | 1412 } |
1413 } | 1413 } |
1414 } // End of H band gain computation. | 1414 } // End of H band gain computation. |
1415 } | 1415 } |
OLD | NEW |