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 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 int16_t realImag_buff[ANAL_BLOCKL_MAX * 2 + 16]; | 1208 int16_t realImag_buff[ANAL_BLOCKL_MAX * 2 + 16]; |
1209 | 1209 |
1210 // Align the structures to 32-byte boundary for the FFT function. | 1210 // Align the structures to 32-byte boundary for the FFT function. |
1211 int16_t* winData = (int16_t*) (((uintptr_t)winData_buff + 31) & ~31); | 1211 int16_t* winData = (int16_t*) (((uintptr_t)winData_buff + 31) & ~31); |
1212 int16_t* realImag = (int16_t*) (((uintptr_t) realImag_buff + 31) & ~31); | 1212 int16_t* realImag = (int16_t*) (((uintptr_t) realImag_buff + 31) & ~31); |
1213 | 1213 |
1214 // Update analysis buffer for lower band, and window data before FFT. | 1214 // Update analysis buffer for lower band, and window data before FFT. |
1215 WebRtcNsx_AnalysisUpdate(inst, winData, speechFrame); | 1215 WebRtcNsx_AnalysisUpdate(inst, winData, speechFrame); |
1216 | 1216 |
1217 // Get input energy | 1217 // Get input energy |
1218 inst->energyIn = WebRtcSpl_Energy(winData, (int)inst->anaLen, &(inst->scaleEne
rgyIn)); | 1218 inst->energyIn = |
| 1219 WebRtcSpl_Energy(winData, inst->anaLen, &inst->scaleEnergyIn); |
1219 | 1220 |
1220 // Reset zero input flag | 1221 // Reset zero input flag |
1221 inst->zeroInputSignal = 0; | 1222 inst->zeroInputSignal = 0; |
1222 // Acquire norm for winData | 1223 // Acquire norm for winData |
1223 maxWinData = WebRtcSpl_MaxAbsValueW16(winData, inst->anaLen); | 1224 maxWinData = WebRtcSpl_MaxAbsValueW16(winData, inst->anaLen); |
1224 inst->normData = WebRtcSpl_NormW16(maxWinData); | 1225 inst->normData = WebRtcSpl_NormW16(maxWinData); |
1225 if (maxWinData == 0) { | 1226 if (maxWinData == 0) { |
1226 // Treat zero input separately. | 1227 // Treat zero input separately. |
1227 inst->zeroInputSignal = 1; | 1228 inst->zeroInputSignal = 1; |
1228 return; | 1229 return; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 // Inverse FFT output will be in rfft_out[]. | 1454 // Inverse FFT output will be in rfft_out[]. |
1454 outCIFFT = WebRtcSpl_RealInverseFFT(inst->real_fft, realImag, rfft_out); | 1455 outCIFFT = WebRtcSpl_RealInverseFFT(inst->real_fft, realImag, rfft_out); |
1455 | 1456 |
1456 WebRtcNsx_Denormalize(inst, rfft_out, outCIFFT); | 1457 WebRtcNsx_Denormalize(inst, rfft_out, outCIFFT); |
1457 | 1458 |
1458 //scale factor: only do it after END_STARTUP_LONG time | 1459 //scale factor: only do it after END_STARTUP_LONG time |
1459 gainFactor = 8192; // 8192 = Q13(1.0) | 1460 gainFactor = 8192; // 8192 = Q13(1.0) |
1460 if (inst->gainMap == 1 && | 1461 if (inst->gainMap == 1 && |
1461 inst->blockIndex > END_STARTUP_LONG && | 1462 inst->blockIndex > END_STARTUP_LONG && |
1462 inst->energyIn > 0) { | 1463 inst->energyIn > 0) { |
1463 energyOut = WebRtcSpl_Energy(inst->real, (int)inst->anaLen, &scaleEnergyOut)
; // Q(-scaleEnergyOut) | 1464 // Q(-scaleEnergyOut) |
| 1465 energyOut = WebRtcSpl_Energy(inst->real, inst->anaLen, &scaleEnergyOut); |
1464 if (scaleEnergyOut == 0 && !(energyOut & 0x7f800000)) { | 1466 if (scaleEnergyOut == 0 && !(energyOut & 0x7f800000)) { |
1465 energyOut = WEBRTC_SPL_SHIFT_W32(energyOut, 8 + scaleEnergyOut | 1467 energyOut = WEBRTC_SPL_SHIFT_W32(energyOut, 8 + scaleEnergyOut |
1466 - inst->scaleEnergyIn); | 1468 - inst->scaleEnergyIn); |
1467 } else { | 1469 } else { |
1468 // |energyIn| is currently in Q(|scaleEnergyIn|), but to later on end up | 1470 // |energyIn| is currently in Q(|scaleEnergyIn|), but to later on end up |
1469 // with an |energyRatio| in Q8 we need to change the Q-domain to | 1471 // with an |energyRatio| in Q8 we need to change the Q-domain to |
1470 // Q(-8-scaleEnergyOut). | 1472 // Q(-8-scaleEnergyOut). |
1471 inst->energyIn >>= 8 + scaleEnergyOut - inst->scaleEnergyIn; | 1473 inst->energyIn >>= 8 + scaleEnergyOut - inst->scaleEnergyIn; |
1472 } | 1474 } |
1473 | 1475 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 | 2102 |
2101 //apply gain | 2103 //apply gain |
2102 for (i = 0; i < num_high_bands; ++i) { | 2104 for (i = 0; i < num_high_bands; ++i) { |
2103 for (j = 0; j < inst->blockLen10ms; j++) { | 2105 for (j = 0; j < inst->blockLen10ms; j++) { |
2104 outFrameHB[i][j] = (int16_t)((gainTimeDomainHB * | 2106 outFrameHB[i][j] = (int16_t)((gainTimeDomainHB * |
2105 inst->dataBufHBFX[i][j]) >> 14); // Q0 | 2107 inst->dataBufHBFX[i][j]) >> 14); // Q0 |
2106 } | 2108 } |
2107 } | 2109 } |
2108 } // end of H band gain computation | 2110 } // end of H band gain computation |
2109 } | 2111 } |
OLD | NEW |