2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
13 #include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h"
14 #include "webrtc/modules/audio_processing/ns/nsx_core.h"
16 static const int16_t kIndicatorTable[17] = {
17 0, 2017, 3809, 5227, 6258, 6963, 7424, 7718,
18 7901, 8014, 8084, 8126, 8152, 8168, 8177, 8183, 8187
21 // Compute speech/noise probability
22 // speech/noise probability is returned in: probSpeechFinal
23 //snrLocPrior is the prior SNR for each frequency (in Q11)
24 //snrLocPost is the post SNR for each frequency (in Q11)
25 void WebRtcNsx_SpeechNoiseProb(NsxInst_t* inst,
26 uint16_t* nonSpeechProbFinal,
27 uint32_t* priorLocSnr,
28 uint32_t* postLocSnr) {
30 uint32_t tmpU32no1, tmpU32no2, tmpU32no3;
31 int32_t indPriorFX, tmp32no1;
32 int32_t logLrtTimeAvgKsumFX;
34 int16_t tmp16, tmp16no1, tmp16no2, tmpIndFX, tableIndex, frac;
35 int i, normTmp, nShifts;
37 int32_t r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;
38 int32_t const_max = 0x7fffffff;
39 int32_t const_neg43 = -43;
40 int32_t const_5412 = 5412;
41 int32_t const_11rsh12 = (11 << 12);
42 int32_t const_178 = 178;
45 // compute feature based on average LR factor
46 // this is the average over all frequencies of the smooth log LRT
47 logLrtTimeAvgKsumFX = 0;
48 for (i = 0; i < inst->magnLen; i++) {
49 r0 = postLocSnr[i]; // Q11
51 r2 = inst->logLrtTimeAvgW32[i];
56 "clz %[r3], %[r0] \n\t"
57 "clz %[r5], %[r1] \n\t"
58 "slti %[r4], %[r3], 32 \n\t"
59 "slti %[r6], %[r5], 32 \n\t"
60 "movz %[r3], $0, %[r4] \n\t"
61 "movz %[r5], $0, %[r6] \n\t"
62 "slti %[r4], %[r3], 11 \n\t"
63 "addiu %[r6], %[r3], -11 \n\t"
64 "neg %[r7], %[r6] \n\t"
65 "sllv %[r6], %[r1], %[r6] \n\t"
66 "srav %[r7], %[r1], %[r7] \n\t"
67 "movn %[r6], %[r7], %[r4] \n\t"
68 "sllv %[r1], %[r1], %[r5] \n\t"
69 "and %[r1], %[r1], %[const_max] \n\t"
70 "sra %[r1], %[r1], 19 \n\t"
71 "mul %[r7], %[r1], %[r1] \n\t"
72 "sllv %[r3], %[r0], %[r3] \n\t"
73 "divu %[r8], %[r3], %[r6] \n\t"
74 "slti %[r6], %[r6], 1 \n\t"
75 "mul %[r7], %[r7], %[const_neg43] \n\t"
76 "sra %[r7], %[r7], 19 \n\t"
77 "movz %[r3], %[r8], %[r6] \n\t"
78 "subu %[r0], %[r0], %[r3] \n\t"
79 "movn %[r0], $0, %[r6] \n\t"
80 "mul %[r1], %[r1], %[const_5412] \n\t"
81 "sra %[r1], %[r1], 12 \n\t"
82 "addu %[r7], %[r7], %[r1] \n\t"
83 "addiu %[r1], %[r7], 37 \n\t"
84 "addiu %[r5], %[r5], -31 \n\t"
85 "neg %[r5], %[r5] \n\t"
86 "sll %[r5], %[r5], 12 \n\t"
87 "addu %[r5], %[r5], %[r1] \n\t"
88 "subu %[r7], %[r5], %[const_11rsh12] \n\t"
89 "mul %[r7], %[r7], %[const_178] \n\t"
90 "sra %[r7], %[r7], 8 \n\t"
91 "addu %[r7], %[r7], %[r2] \n\t"
92 "sra %[r7], %[r7], 1 \n\t"
93 "subu %[r2], %[r2], %[r7] \n\t"
94 "addu %[r2], %[r2], %[r0] \n\t"
96 : [r0] "+r" (r0), [r1] "+r" (r1), [r2] "+r" (r2),
97 [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
98 [r6] "=&r" (r6), [r7] "=&r" (r7), [r8] "=&r" (r8)
99 : [const_max] "r" (const_max), [const_neg43] "r" (const_neg43),
100 [const_5412] "r" (const_5412), [const_11rsh12] "r" (const_11rsh12),
101 [const_178] "r" (const_178)
104 inst->logLrtTimeAvgW32[i] = r2;
105 logLrtTimeAvgKsumFX += r2;
108 inst->featureLogLrt = (logLrtTimeAvgKsumFX * BIN_SIZE_LRT) >>
111 // done with computation of LR factor
114 // compute the indicator functions
117 // average LRT feature
119 // indicator0 = 0.5 * (tanh(widthPrior *
120 // (logLrtTimeAvgKsum - threshPrior0)) + 1.0);
121 tmpIndFX = 16384; // Q14(1.0)
122 tmp32no1 = logLrtTimeAvgKsumFX - inst->thresholdLogLrt; // Q12
123 nShifts = 7 - inst->stages; // WIDTH_PR_MAP_SHIFT - inst->stages + 5;
124 //use larger width in tanh map for pause regions
127 tmp32no1 = -tmp32no1;
128 //widthPrior = widthPrior * 2.0;
131 tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, nShifts); // Q14
132 // compute indicator function: sigmoid map
133 tableIndex = (int16_t)(tmp32no1 >> 14);
134 if ((tableIndex < 16) && (tableIndex >= 0)) {
135 tmp16no2 = kIndicatorTable[tableIndex];
136 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
137 frac = (int16_t)(tmp32no1 & 0x00003fff); // Q14
138 tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, frac, 14);
140 tmpIndFX = 8192 - tmp16no2; // Q14
142 tmpIndFX = 8192 + tmp16no2; // Q14
145 indPriorFX = WEBRTC_SPL_MUL_16_16(inst->weightLogLrt, tmpIndFX); // 6*Q14
147 //spectral flatness feature
148 if (inst->weightSpecFlat) {
149 tmpU32no1 = WEBRTC_SPL_UMUL(inst->featureSpecFlat, 400); // Q10
150 tmpIndFX = 16384; // Q14(1.0)
151 //use larger width in tanh map for pause regions
152 tmpU32no2 = inst->thresholdSpecFlat - tmpU32no1; //Q10
154 if (inst->thresholdSpecFlat < tmpU32no1) {
156 tmpU32no2 = tmpU32no1 - inst->thresholdSpecFlat;
157 //widthPrior = widthPrior * 2.0;
160 tmpU32no1 = WebRtcSpl_DivU32U16(tmpU32no2 << nShifts, 25); //Q14
161 // compute indicator function: sigmoid map
163 // indicator1 = 0.5 * (tanh(sgnMap * widthPrior *
164 // (threshPrior1 - tmpFloat1)) + 1.0);
165 tableIndex = (int16_t)(tmpU32no1 >> 14);
166 if (tableIndex < 16) {
167 tmp16no2 = kIndicatorTable[tableIndex];
168 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
169 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
170 tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, frac, 14);
172 tmpIndFX = 8192 + tmp16no2; // Q14
174 tmpIndFX = 8192 - tmp16no2; // Q14
177 indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecFlat, tmpIndFX); // 6*Q14
180 //for template spectral-difference
181 if (inst->weightSpecDiff) {
183 if (inst->featureSpecDiff) {
184 normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
185 WebRtcSpl_NormU32(inst->featureSpecDiff));
186 assert(normTmp >= 0);
187 tmpU32no1 = inst->featureSpecDiff << normTmp; // Q(normTmp-2*stages)
188 tmpU32no2 = inst->timeAvgMagnEnergy >> (20 - inst->stages - normTmp);
190 // Q(20 - inst->stages)
191 tmpU32no1 /= tmpU32no2;
193 tmpU32no1 = (uint32_t)(0x7fffffff);
196 tmpU32no3 = (inst->thresholdSpecDiff << 17) / 25;
197 tmpU32no2 = tmpU32no1 - tmpU32no3;
199 tmpIndFX = 16384; // Q14(1.0)
200 //use larger width in tanh map for pause regions
201 if (tmpU32no2 & 0x80000000) {
203 tmpU32no2 = tmpU32no3 - tmpU32no1;
204 //widthPrior = widthPrior * 2.0;
207 tmpU32no1 = tmpU32no2 >> nShifts;
208 // compute indicator function: sigmoid map
210 indicator2 = 0.5 * (tanh(widthPrior * (tmpFloat1 - threshPrior2)) + 1.0);
212 tableIndex = (int16_t)(tmpU32no1 >> 14);
213 if (tableIndex < 16) {
214 tmp16no2 = kIndicatorTable[tableIndex];
215 tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
216 frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
217 tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
220 tmpIndFX = 8192 + tmp16no2;
222 tmpIndFX = 8192 - tmp16no2;
225 indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecDiff, tmpIndFX); // 6*Q14
228 //combine the indicator function with the feature weights
230 // indPrior = 1 - (weightIndPrior0 * indicator0 + weightIndPrior1 *
231 // indicator1 + weightIndPrior2 * indicator2);
232 indPriorFX16 = WebRtcSpl_DivW32W16ResW16(98307 - indPriorFX, 6); // Q14
233 // done with computing indicator function
235 //compute the prior probability
237 // inst->priorNonSpeechProb += PRIOR_UPDATE *
238 // (indPriorNonSpeech - inst->priorNonSpeechProb);
239 tmp16 = indPriorFX16 - inst->priorNonSpeechProb; // Q14
240 inst->priorNonSpeechProb += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(
241 PRIOR_UPDATE_Q14, tmp16, 14); // Q14
243 //final speech probability: combine prior model with LR factor:
245 memset(nonSpeechProbFinal, 0, sizeof(uint16_t) * inst->magnLen);
247 if (inst->priorNonSpeechProb > 0) {
248 r0 = inst->priorNonSpeechProb;
250 int32_t const_23637 = 23637;
251 int32_t const_44 = 44;
252 int32_t const_84 = 84;
254 int32_t const_neg8 = -8;
255 for (i = 0; i < inst->magnLen; i++) {
256 r2 = inst->logLrtTimeAvgW32[i];
260 ".set noreorder \n\t"
261 "mul %[r2], %[r2], %[const_23637] \n\t"
262 "sll %[r6], %[r1], 16 \n\t"
263 "clz %[r7], %[r6] \n\t"
264 "clo %[r8], %[r6] \n\t"
265 "slt %[r9], %[r6], $0 \n\t"
266 "movn %[r7], %[r8], %[r9] \n\t"
267 "sra %[r2], %[r2], 14 \n\t"
268 "andi %[r3], %[r2], 0xfff \n\t"
269 "mul %[r4], %[r3], %[r3] \n\t"
270 "mul %[r3], %[r3], %[const_84] \n\t"
271 "sra %[r2], %[r2], 12 \n\t"
272 "slt %[r5], %[r2], %[const_neg8] \n\t"
273 "movn %[r2], %[const_neg8], %[r5] \n\t"
274 "mul %[r4], %[r4], %[const_44] \n\t"
275 "sra %[r3], %[r3], 7 \n\t"
276 "addiu %[r7], %[r7], -1 \n\t"
277 "slti %[r9], %[r7], 31 \n\t"
278 "movz %[r7], $0, %[r9] \n\t"
279 "sra %[r4], %[r4], 19 \n\t"
280 "addu %[r4], %[r4], %[r3] \n\t"
281 "addiu %[r3], %[r2], 8 \n\t"
282 "addiu %[r2], %[r2], -4 \n\t"
283 "neg %[r5], %[r2] \n\t"
284 "sllv %[r6], %[r4], %[r2] \n\t"
285 "srav %[r5], %[r4], %[r5] \n\t"
286 "slt %[r2], %[r2], $0 \n\t"
287 "movn %[r6], %[r5], %[r2] \n\t"
288 "sllv %[r3], %[const_1], %[r3] \n\t"
289 "addu %[r2], %[r3], %[r6] \n\t"
290 "clz %[r4], %[r2] \n\t"
291 "clo %[r5], %[r2] \n\t"
292 "slt %[r8], %[r2], $0 \n\t"
293 "movn %[r4], %[r5], %[r8] \n\t"
294 "addiu %[r4], %[r4], -1 \n\t"
295 "slt %[r5], $0, %[r2] \n\t"
296 "or %[r5], %[r5], %[r7] \n\t"
297 "movz %[r4], $0, %[r5] \n\t"
298 "addiu %[r6], %[r7], -7 \n\t"
299 "addu %[r6], %[r6], %[r4] \n\t"
300 "bltz %[r6], 1f \n\t"
302 "addiu %[r4], %[r6], -8 \n\t"
303 "neg %[r3], %[r4] \n\t"
304 "srav %[r5], %[r2], %[r3] \n\t"
305 "mul %[r5], %[r5], %[r1] \n\t"
306 "mul %[r2], %[r2], %[r1] \n\t"
307 "slt %[r4], %[r4], $0 \n\t"
308 "srav %[r5], %[r5], %[r6] \n\t"
309 "sra %[r2], %[r2], 8 \n\t"
310 "movn %[r2], %[r5], %[r4] \n\t"
311 "sll %[r3], %[r0], 8 \n\t"
312 "addu %[r2], %[r0], %[r2] \n\t"
313 "divu %[r3], %[r3], %[r2] \n\t"
316 : [r2] "+r" (r2), [r3] "=&r" (r3), [r4] "=&r" (r4),
317 [r5] "=&r" (r5), [r6] "=&r" (r6), [r7] "=&r" (r7),
318 [r8] "=&r" (r8), [r9] "=&r" (r9)
319 : [r0] "r" (r0), [r1] "r" (r1), [const_23637] "r" (const_23637),
320 [const_neg8] "r" (const_neg8), [const_84] "r" (const_84),
321 [const_1] "r" (const_1), [const_44] "r" (const_44)
324 nonSpeechProbFinal[i] = r3;
330 // Update analysis buffer for lower band, and window data before FFT.
331 void WebRtcNsx_AnalysisUpdate_mips(NsxInst_t* inst,
333 int16_t* new_speech) {
336 int anaLen = inst->anaLen;
337 int *window = (int*)inst->window;
338 int *anaBuf = (int*)inst->analysisBuffer;
339 int *outBuf = (int*)out;
340 int r0, r1, r2, r3, r4, r5, r6, r7;
341 #if defined(MIPS_DSP_R1_LE)
345 // For lower band update analysis buffer.
346 WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer,
347 inst->analysisBuffer + inst->blockLen10ms,
348 inst->anaLen - inst->blockLen10ms);
349 WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer
350 + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
352 // Window data before FFT.
353 #if defined(MIPS_DSP_R1_LE)
356 ".set noreorder \n\t"
357 "sra %[iters], %[anaLen], 3 \n\t"
359 "blez %[iters], 2f \n\t"
361 "lw %[r0], 0(%[window]) \n\t"
362 "lw %[r1], 0(%[anaBuf]) \n\t"
363 "lw %[r2], 4(%[window]) \n\t"
364 "lw %[r3], 4(%[anaBuf]) \n\t"
365 "lw %[r4], 8(%[window]) \n\t"
366 "lw %[r5], 8(%[anaBuf]) \n\t"
367 "lw %[r6], 12(%[window]) \n\t"
368 "lw %[r7], 12(%[anaBuf]) \n\t"
369 "muleq_s.w.phl %[r8], %[r0], %[r1] \n\t"
370 "muleq_s.w.phr %[r0], %[r0], %[r1] \n\t"
371 "muleq_s.w.phl %[r1], %[r2], %[r3] \n\t"
372 "muleq_s.w.phr %[r2], %[r2], %[r3] \n\t"
373 "muleq_s.w.phl %[r3], %[r4], %[r5] \n\t"
374 "muleq_s.w.phr %[r4], %[r4], %[r5] \n\t"
375 "muleq_s.w.phl %[r5], %[r6], %[r7] \n\t"
376 "muleq_s.w.phr %[r6], %[r6], %[r7] \n\t"
377 #if defined(MIPS_DSP_R2_LE)
378 "precr_sra_r.ph.w %[r8], %[r0], 15 \n\t"
379 "precr_sra_r.ph.w %[r1], %[r2], 15 \n\t"
380 "precr_sra_r.ph.w %[r3], %[r4], 15 \n\t"
381 "precr_sra_r.ph.w %[r5], %[r6], 15 \n\t"
382 "sw %[r8], 0(%[outBuf]) \n\t"
383 "sw %[r1], 4(%[outBuf]) \n\t"
384 "sw %[r3], 8(%[outBuf]) \n\t"
385 "sw %[r5], 12(%[outBuf]) \n\t"
387 "shra_r.w %[r8], %[r8], 15 \n\t"
388 "shra_r.w %[r0], %[r0], 15 \n\t"
389 "shra_r.w %[r1], %[r1], 15 \n\t"
390 "shra_r.w %[r2], %[r2], 15 \n\t"
391 "shra_r.w %[r3], %[r3], 15 \n\t"
392 "shra_r.w %[r4], %[r4], 15 \n\t"
393 "shra_r.w %[r5], %[r5], 15 \n\t"
394 "shra_r.w %[r6], %[r6], 15 \n\t"
395 "sll %[r0], %[r0], 16 \n\t"
396 "sll %[r2], %[r2], 16 \n\t"
397 "sll %[r4], %[r4], 16 \n\t"
398 "sll %[r6], %[r6], 16 \n\t"
399 "packrl.ph %[r0], %[r8], %[r0] \n\t"
400 "packrl.ph %[r2], %[r1], %[r2] \n\t"
401 "packrl.ph %[r4], %[r3], %[r4] \n\t"
402 "packrl.ph %[r6], %[r5], %[r6] \n\t"
403 "sw %[r0], 0(%[outBuf]) \n\t"
404 "sw %[r2], 4(%[outBuf]) \n\t"
405 "sw %[r4], 8(%[outBuf]) \n\t"
406 "sw %[r6], 12(%[outBuf]) \n\t"
408 "addiu %[window], %[window], 16 \n\t"
409 "addiu %[anaBuf], %[anaBuf], 16 \n\t"
410 "addiu %[outBuf], %[outBuf], 16 \n\t"
412 " addiu %[iters], %[iters], -1 \n\t"
414 "andi %[after], %[anaLen], 7 \n\t"
416 "blez %[after], 4f \n\t"
418 "lh %[r0], 0(%[window]) \n\t"
419 "lh %[r1], 0(%[anaBuf]) \n\t"
420 "mul %[r0], %[r0], %[r1] \n\t"
421 "addiu %[window], %[window], 2 \n\t"
422 "addiu %[anaBuf], %[anaBuf], 2 \n\t"
423 "addiu %[outBuf], %[outBuf], 2 \n\t"
424 "shra_r.w %[r0], %[r0], 14 \n\t"
425 "sh %[r0], -2(%[outBuf]) \n\t"
427 " addiu %[after], %[after], -1 \n\t"
430 : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
431 [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
432 [r6] "=&r" (r6), [r7] "=&r" (r7), [r8] "=&r" (r8),
433 [iters] "=&r" (iters), [after] "=&r" (after),
434 [window] "+r" (window),[anaBuf] "+r" (anaBuf),
435 [outBuf] "+r" (outBuf)
436 : [anaLen] "r" (anaLen)
437 : "memory", "hi", "lo"
442 ".set noreorder \n\t"
443 "sra %[iters], %[anaLen], 2 \n\t"
445 "blez %[iters], 2f \n\t"
447 "lh %[r0], 0(%[window]) \n\t"
448 "lh %[r1], 0(%[anaBuf]) \n\t"
449 "lh %[r2], 2(%[window]) \n\t"
450 "lh %[r3], 2(%[anaBuf]) \n\t"
451 "lh %[r4], 4(%[window]) \n\t"
452 "lh %[r5], 4(%[anaBuf]) \n\t"
453 "lh %[r6], 6(%[window]) \n\t"
454 "lh %[r7], 6(%[anaBuf]) \n\t"
455 "mul %[r0], %[r0], %[r1] \n\t"
456 "mul %[r2], %[r2], %[r3] \n\t"
457 "mul %[r4], %[r4], %[r5] \n\t"
458 "mul %[r6], %[r6], %[r7] \n\t"
459 "addiu %[window], %[window], 8 \n\t"
460 "addiu %[anaBuf], %[anaBuf], 8 \n\t"
461 "addiu %[r0], %[r0], 0x2000 \n\t"
462 "addiu %[r2], %[r2], 0x2000 \n\t"
463 "addiu %[r4], %[r4], 0x2000 \n\t"
464 "addiu %[r6], %[r6], 0x2000 \n\t"
465 "sra %[r0], %[r0], 14 \n\t"
466 "sra %[r2], %[r2], 14 \n\t"
467 "sra %[r4], %[r4], 14 \n\t"
468 "sra %[r6], %[r6], 14 \n\t"
469 "sh %[r0], 0(%[outBuf]) \n\t"
470 "sh %[r2], 2(%[outBuf]) \n\t"
471 "sh %[r4], 4(%[outBuf]) \n\t"
472 "sh %[r6], 6(%[outBuf]) \n\t"
473 "addiu %[outBuf], %[outBuf], 8 \n\t"
475 " addiu %[iters], %[iters], -1 \n\t"
477 "andi %[after], %[anaLen], 3 \n\t"
479 "blez %[after], 4f \n\t"
481 "lh %[r0], 0(%[window]) \n\t"
482 "lh %[r1], 0(%[anaBuf]) \n\t"
483 "mul %[r0], %[r0], %[r1] \n\t"
484 "addiu %[window], %[window], 2 \n\t"
485 "addiu %[anaBuf], %[anaBuf], 2 \n\t"
486 "addiu %[outBuf], %[outBuf], 2 \n\t"
487 "addiu %[r0], %[r0], 0x2000 \n\t"
488 "sra %[r0], %[r0], 14 \n\t"
489 "sh %[r0], -2(%[outBuf]) \n\t"
491 " addiu %[after], %[after], -1 \n\t"
494 : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
495 [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
496 [r6] "=&r" (r6), [r7] "=&r" (r7), [iters] "=&r" (iters),
497 [after] "=&r" (after), [window] "+r" (window),
498 [anaBuf] "+r" (anaBuf), [outBuf] "+r" (outBuf)
499 : [anaLen] "r" (anaLen)
500 : "memory", "hi", "lo"
505 // For the noise supression process, synthesis, read out fully processed
506 // segment, and update synthesis buffer.
507 void WebRtcNsx_SynthesisUpdate_mips(NsxInst_t* inst,
509 int16_t gain_factor) {
511 int iters = inst->blockLen10ms >> 2;
512 int after = inst->blockLen10ms & 3;
513 int r0, r1, r2, r3, r4, r5, r6, r7;
514 int16_t *window = (int16_t*)inst->window;
515 int16_t *real = inst->real;
516 int16_t *synthBuf = inst->synthesisBuffer;
517 int16_t *out = out_frame;
518 int sat_pos = 0x7fff;
519 int sat_neg = 0xffff8000;
520 int block10 = (int)inst->blockLen10ms;
521 int anaLen = (int)inst->anaLen;
525 ".set noreorder \n\t"
527 "blez %[iters], 2f \n\t"
529 "lh %[r0], 0(%[window]) \n\t"
530 "lh %[r1], 0(%[real]) \n\t"
531 "lh %[r2], 2(%[window]) \n\t"
532 "lh %[r3], 2(%[real]) \n\t"
533 "lh %[r4], 4(%[window]) \n\t"
534 "lh %[r5], 4(%[real]) \n\t"
535 "lh %[r6], 6(%[window]) \n\t"
536 "lh %[r7], 6(%[real]) \n\t"
537 "mul %[r0], %[r0], %[r1] \n\t"
538 "mul %[r2], %[r2], %[r3] \n\t"
539 "mul %[r4], %[r4], %[r5] \n\t"
540 "mul %[r6], %[r6], %[r7] \n\t"
541 "addiu %[r0], %[r0], 0x2000 \n\t"
542 "addiu %[r2], %[r2], 0x2000 \n\t"
543 "addiu %[r4], %[r4], 0x2000 \n\t"
544 "addiu %[r6], %[r6], 0x2000 \n\t"
545 "sra %[r0], %[r0], 14 \n\t"
546 "sra %[r2], %[r2], 14 \n\t"
547 "sra %[r4], %[r4], 14 \n\t"
548 "sra %[r6], %[r6], 14 \n\t"
549 "mul %[r0], %[r0], %[gain_factor] \n\t"
550 "mul %[r2], %[r2], %[gain_factor] \n\t"
551 "mul %[r4], %[r4], %[gain_factor] \n\t"
552 "mul %[r6], %[r6], %[gain_factor] \n\t"
553 "addiu %[r0], %[r0], 0x1000 \n\t"
554 "addiu %[r2], %[r2], 0x1000 \n\t"
555 "addiu %[r4], %[r4], 0x1000 \n\t"
556 "addiu %[r6], %[r6], 0x1000 \n\t"
557 "sra %[r0], %[r0], 13 \n\t"
558 "sra %[r2], %[r2], 13 \n\t"
559 "sra %[r4], %[r4], 13 \n\t"
560 "sra %[r6], %[r6], 13 \n\t"
561 "slt %[r1], %[r0], %[sat_pos] \n\t"
562 "slt %[r3], %[r2], %[sat_pos] \n\t"
563 "slt %[r5], %[r4], %[sat_pos] \n\t"
564 "slt %[r7], %[r6], %[sat_pos] \n\t"
565 "movz %[r0], %[sat_pos], %[r1] \n\t"
566 "movz %[r2], %[sat_pos], %[r3] \n\t"
567 "movz %[r4], %[sat_pos], %[r5] \n\t"
568 "movz %[r6], %[sat_pos], %[r7] \n\t"
569 "lh %[r1], 0(%[synthBuf]) \n\t"
570 "lh %[r3], 2(%[synthBuf]) \n\t"
571 "lh %[r5], 4(%[synthBuf]) \n\t"
572 "lh %[r7], 6(%[synthBuf]) \n\t"
573 "addu %[r0], %[r0], %[r1] \n\t"
574 "addu %[r2], %[r2], %[r3] \n\t"
575 "addu %[r4], %[r4], %[r5] \n\t"
576 "addu %[r6], %[r6], %[r7] \n\t"
577 "slt %[r1], %[r0], %[sat_pos] \n\t"
578 "slt %[r3], %[r2], %[sat_pos] \n\t"
579 "slt %[r5], %[r4], %[sat_pos] \n\t"
580 "slt %[r7], %[r6], %[sat_pos] \n\t"
581 "movz %[r0], %[sat_pos], %[r1] \n\t"
582 "movz %[r2], %[sat_pos], %[r3] \n\t"
583 "movz %[r4], %[sat_pos], %[r5] \n\t"
584 "movz %[r6], %[sat_pos], %[r7] \n\t"
585 "slt %[r1], %[r0], %[sat_neg] \n\t"
586 "slt %[r3], %[r2], %[sat_neg] \n\t"
587 "slt %[r5], %[r4], %[sat_neg] \n\t"
588 "slt %[r7], %[r6], %[sat_neg] \n\t"
589 "movn %[r0], %[sat_neg], %[r1] \n\t"
590 "movn %[r2], %[sat_neg], %[r3] \n\t"
591 "movn %[r4], %[sat_neg], %[r5] \n\t"
592 "movn %[r6], %[sat_neg], %[r7] \n\t"
593 "sh %[r0], 0(%[synthBuf]) \n\t"
594 "sh %[r2], 2(%[synthBuf]) \n\t"
595 "sh %[r4], 4(%[synthBuf]) \n\t"
596 "sh %[r6], 6(%[synthBuf]) \n\t"
597 "sh %[r0], 0(%[out]) \n\t"
598 "sh %[r2], 2(%[out]) \n\t"
599 "sh %[r4], 4(%[out]) \n\t"
600 "sh %[r6], 6(%[out]) \n\t"
601 "addiu %[window], %[window], 8 \n\t"
602 "addiu %[real], %[real], 8 \n\t"
603 "addiu %[synthBuf],%[synthBuf], 8 \n\t"
604 "addiu %[out], %[out], 8 \n\t"
606 " addiu %[iters], %[iters], -1 \n\t"
608 "blez %[after], 3f \n\t"
609 " subu %[block10], %[anaLen], %[block10] \n\t"
610 "lh %[r0], 0(%[window]) \n\t"
611 "lh %[r1], 0(%[real]) \n\t"
612 "mul %[r0], %[r0], %[r1] \n\t"
613 "addiu %[window], %[window], 2 \n\t"
614 "addiu %[real], %[real], 2 \n\t"
615 "addiu %[r0], %[r0], 0x2000 \n\t"
616 "sra %[r0], %[r0], 14 \n\t"
617 "mul %[r0], %[r0], %[gain_factor] \n\t"
618 "addiu %[r0], %[r0], 0x1000 \n\t"
619 "sra %[r0], %[r0], 13 \n\t"
620 "slt %[r1], %[r0], %[sat_pos] \n\t"
621 "movz %[r0], %[sat_pos], %[r1] \n\t"
622 "lh %[r1], 0(%[synthBuf]) \n\t"
623 "addu %[r0], %[r0], %[r1] \n\t"
624 "slt %[r1], %[r0], %[sat_pos] \n\t"
625 "movz %[r0], %[sat_pos], %[r1] \n\t"
626 "slt %[r1], %[r0], %[sat_neg] \n\t"
627 "movn %[r0], %[sat_neg], %[r1] \n\t"
628 "sh %[r0], 0(%[synthBuf]) \n\t"
629 "sh %[r0], 0(%[out]) \n\t"
630 "addiu %[synthBuf],%[synthBuf], 2 \n\t"
631 "addiu %[out], %[out], 2 \n\t"
633 " addiu %[after], %[after], -1 \n\t"
635 "sra %[iters], %[block10], 2 \n\t"
637 "blez %[iters], 5f \n\t"
638 " andi %[after], %[block10], 3 \n\t"
639 "lh %[r0], 0(%[window]) \n\t"
640 "lh %[r1], 0(%[real]) \n\t"
641 "lh %[r2], 2(%[window]) \n\t"
642 "lh %[r3], 2(%[real]) \n\t"
643 "lh %[r4], 4(%[window]) \n\t"
644 "lh %[r5], 4(%[real]) \n\t"
645 "lh %[r6], 6(%[window]) \n\t"
646 "lh %[r7], 6(%[real]) \n\t"
647 "mul %[r0], %[r0], %[r1] \n\t"
648 "mul %[r2], %[r2], %[r3] \n\t"
649 "mul %[r4], %[r4], %[r5] \n\t"
650 "mul %[r6], %[r6], %[r7] \n\t"
651 "addiu %[r0], %[r0], 0x2000 \n\t"
652 "addiu %[r2], %[r2], 0x2000 \n\t"
653 "addiu %[r4], %[r4], 0x2000 \n\t"
654 "addiu %[r6], %[r6], 0x2000 \n\t"
655 "sra %[r0], %[r0], 14 \n\t"
656 "sra %[r2], %[r2], 14 \n\t"
657 "sra %[r4], %[r4], 14 \n\t"
658 "sra %[r6], %[r6], 14 \n\t"
659 "mul %[r0], %[r0], %[gain_factor] \n\t"
660 "mul %[r2], %[r2], %[gain_factor] \n\t"
661 "mul %[r4], %[r4], %[gain_factor] \n\t"
662 "mul %[r6], %[r6], %[gain_factor] \n\t"
663 "addiu %[r0], %[r0], 0x1000 \n\t"
664 "addiu %[r2], %[r2], 0x1000 \n\t"
665 "addiu %[r4], %[r4], 0x1000 \n\t"
666 "addiu %[r6], %[r6], 0x1000 \n\t"
667 "sra %[r0], %[r0], 13 \n\t"
668 "sra %[r2], %[r2], 13 \n\t"
669 "sra %[r4], %[r4], 13 \n\t"
670 "sra %[r6], %[r6], 13 \n\t"
671 "slt %[r1], %[r0], %[sat_pos] \n\t"
672 "slt %[r3], %[r2], %[sat_pos] \n\t"
673 "slt %[r5], %[r4], %[sat_pos] \n\t"
674 "slt %[r7], %[r6], %[sat_pos] \n\t"
675 "movz %[r0], %[sat_pos], %[r1] \n\t"
676 "movz %[r2], %[sat_pos], %[r3] \n\t"
677 "movz %[r4], %[sat_pos], %[r5] \n\t"
678 "movz %[r6], %[sat_pos], %[r7] \n\t"
679 "lh %[r1], 0(%[synthBuf]) \n\t"
680 "lh %[r3], 2(%[synthBuf]) \n\t"
681 "lh %[r5], 4(%[synthBuf]) \n\t"
682 "lh %[r7], 6(%[synthBuf]) \n\t"
683 "addu %[r0], %[r0], %[r1] \n\t"
684 "addu %[r2], %[r2], %[r3] \n\t"
685 "addu %[r4], %[r4], %[r5] \n\t"
686 "addu %[r6], %[r6], %[r7] \n\t"
687 "slt %[r1], %[r0], %[sat_pos] \n\t"
688 "slt %[r3], %[r2], %[sat_pos] \n\t"
689 "slt %[r5], %[r4], %[sat_pos] \n\t"
690 "slt %[r7], %[r6], %[sat_pos] \n\t"
691 "movz %[r0], %[sat_pos], %[r1] \n\t"
692 "movz %[r2], %[sat_pos], %[r3] \n\t"
693 "movz %[r4], %[sat_pos], %[r5] \n\t"
694 "movz %[r6], %[sat_pos], %[r7] \n\t"
695 "slt %[r1], %[r0], %[sat_neg] \n\t"
696 "slt %[r3], %[r2], %[sat_neg] \n\t"
697 "slt %[r5], %[r4], %[sat_neg] \n\t"
698 "slt %[r7], %[r6], %[sat_neg] \n\t"
699 "movn %[r0], %[sat_neg], %[r1] \n\t"
700 "movn %[r2], %[sat_neg], %[r3] \n\t"
701 "movn %[r4], %[sat_neg], %[r5] \n\t"
702 "movn %[r6], %[sat_neg], %[r7] \n\t"
703 "sh %[r0], 0(%[synthBuf]) \n\t"
704 "sh %[r2], 2(%[synthBuf]) \n\t"
705 "sh %[r4], 4(%[synthBuf]) \n\t"
706 "sh %[r6], 6(%[synthBuf]) \n\t"
707 "addiu %[window], %[window], 8 \n\t"
708 "addiu %[real], %[real], 8 \n\t"
709 "addiu %[synthBuf],%[synthBuf], 8 \n\t"
711 " addiu %[iters], %[iters], -1 \n\t"
713 "blez %[after], 6f \n\t"
715 "lh %[r0], 0(%[window]) \n\t"
716 "lh %[r1], 0(%[real]) \n\t"
717 "mul %[r0], %[r0], %[r1] \n\t"
718 "addiu %[window], %[window], 2 \n\t"
719 "addiu %[real], %[real], 2 \n\t"
720 "addiu %[r0], %[r0], 0x2000 \n\t"
721 "sra %[r0], %[r0], 14 \n\t"
722 "mul %[r0], %[r0], %[gain_factor] \n\t"
723 "addiu %[r0], %[r0], 0x1000 \n\t"
724 "sra %[r0], %[r0], 13 \n\t"
725 "slt %[r1], %[r0], %[sat_pos] \n\t"
726 "movz %[r0], %[sat_pos], %[r1] \n\t"
727 "lh %[r1], 0(%[synthBuf]) \n\t"
728 "addu %[r0], %[r0], %[r1] \n\t"
729 "slt %[r1], %[r0], %[sat_pos] \n\t"
730 "movz %[r0], %[sat_pos], %[r1] \n\t"
731 "slt %[r1], %[r0], %[sat_neg] \n\t"
732 "movn %[r0], %[sat_neg], %[r1] \n\t"
733 "sh %[r0], 0(%[synthBuf]) \n\t"
734 "addiu %[synthBuf],%[synthBuf], 2 \n\t"
736 " addiu %[after], %[after], -1 \n\t"
739 : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
740 [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
741 [r6] "=&r" (r6), [r7] "=&r" (r7), [iters] "+r" (iters),
742 [after] "+r" (after), [block10] "+r" (block10),
743 [window] "+r" (window), [real] "+r" (real),
744 [synthBuf] "+r" (synthBuf), [out] "+r" (out)
745 : [gain_factor] "r" (gain_factor), [sat_pos] "r" (sat_pos),
746 [sat_neg] "r" (sat_neg), [anaLen] "r" (anaLen)
747 : "memory", "hi", "lo"
750 // update synthesis buffer
751 WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer,
752 inst->synthesisBuffer + inst->blockLen10ms,
753 inst->anaLen - inst->blockLen10ms);
754 WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
755 + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
758 // Filter the data in the frequency domain, and create spectrum.
759 void WebRtcNsx_PrepareSpectrum_mips(NsxInst_t* inst, int16_t* freq_buf) {
761 uint16_t *noiseSupFilter = inst->noiseSupFilter;
762 int16_t *real = inst->real;
763 int16_t *imag = inst->imag;
764 int32_t loop_count = 2;
765 int16_t tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp_6;
766 int16_t tmp16 = (inst->anaLen << 1) - 4;
767 int16_t* freq_buf_f = freq_buf;
768 int16_t* freq_buf_s = &freq_buf[tmp16];
772 ".set noreorder \n\t"
774 "lh %[tmp_1], 0(%[noiseSupFilter]) \n\t"
775 "lh %[tmp_2], 0(%[real]) \n\t"
776 "lh %[tmp_3], 0(%[imag]) \n\t"
777 "mul %[tmp_2], %[tmp_2], %[tmp_1] \n\t"
778 "mul %[tmp_3], %[tmp_3], %[tmp_1] \n\t"
779 "sra %[tmp_2], %[tmp_2], 14 \n\t"
780 "sra %[tmp_3], %[tmp_3], 14 \n\t"
781 "sh %[tmp_2], 0(%[real]) \n\t"
782 "sh %[tmp_3], 0(%[imag]) \n\t"
783 "negu %[tmp_3], %[tmp_3] \n\t"
784 "sh %[tmp_2], 0(%[freq_buf_f]) \n\t"
785 "sh %[tmp_3], 2(%[freq_buf_f]) \n\t"
786 "addiu %[real], %[real], 2 \n\t"
787 "addiu %[imag], %[imag], 2 \n\t"
788 "addiu %[noiseSupFilter], %[noiseSupFilter], 2 \n\t"
789 "addiu %[freq_buf_f], %[freq_buf_f], 4 \n\t"
791 "lh %[tmp_1], 0(%[noiseSupFilter]) \n\t"
792 "lh %[tmp_2], 0(%[real]) \n\t"
793 "lh %[tmp_3], 0(%[imag]) \n\t"
794 "lh %[tmp_4], 2(%[noiseSupFilter]) \n\t"
795 "lh %[tmp_5], 2(%[real]) \n\t"
796 "lh %[tmp_6], 2(%[imag]) \n\t"
797 "mul %[tmp_2], %[tmp_2], %[tmp_1] \n\t"
798 "mul %[tmp_3], %[tmp_3], %[tmp_1] \n\t"
799 "mul %[tmp_5], %[tmp_5], %[tmp_4] \n\t"
800 "mul %[tmp_6], %[tmp_6], %[tmp_4] \n\t"
801 "addiu %[loop_count], %[loop_count], 2 \n\t"
802 "sra %[tmp_2], %[tmp_2], 14 \n\t"
803 "sra %[tmp_3], %[tmp_3], 14 \n\t"
804 "sra %[tmp_5], %[tmp_5], 14 \n\t"
805 "sra %[tmp_6], %[tmp_6], 14 \n\t"
806 "addiu %[noiseSupFilter], %[noiseSupFilter], 4 \n\t"
807 "sh %[tmp_2], 0(%[real]) \n\t"
808 "sh %[tmp_2], 4(%[freq_buf_s]) \n\t"
809 "sh %[tmp_3], 0(%[imag]) \n\t"
810 "sh %[tmp_3], 6(%[freq_buf_s]) \n\t"
811 "negu %[tmp_3], %[tmp_3] \n\t"
812 "sh %[tmp_5], 2(%[real]) \n\t"
813 "sh %[tmp_5], 0(%[freq_buf_s]) \n\t"
814 "sh %[tmp_6], 2(%[imag]) \n\t"
815 "sh %[tmp_6], 2(%[freq_buf_s]) \n\t"
816 "negu %[tmp_6], %[tmp_6] \n\t"
817 "addiu %[freq_buf_s], %[freq_buf_s], -8 \n\t"
818 "addiu %[real], %[real], 4 \n\t"
819 "addiu %[imag], %[imag], 4 \n\t"
820 "sh %[tmp_2], 0(%[freq_buf_f]) \n\t"
821 "sh %[tmp_3], 2(%[freq_buf_f]) \n\t"
822 "sh %[tmp_5], 4(%[freq_buf_f]) \n\t"
823 "sh %[tmp_6], 6(%[freq_buf_f]) \n\t"
824 "blt %[loop_count], %[loop_size], 1b \n\t"
825 " addiu %[freq_buf_f], %[freq_buf_f], 8 \n\t"
827 "lh %[tmp_1], 0(%[noiseSupFilter]) \n\t"
828 "lh %[tmp_2], 0(%[real]) \n\t"
829 "lh %[tmp_3], 0(%[imag]) \n\t"
830 "lh %[tmp_4], 2(%[noiseSupFilter]) \n\t"
831 "lh %[tmp_5], 2(%[real]) \n\t"
832 "lh %[tmp_6], 2(%[imag]) \n\t"
833 "mul %[tmp_2], %[tmp_2], %[tmp_1] \n\t"
834 "mul %[tmp_3], %[tmp_3], %[tmp_1] \n\t"
835 "mul %[tmp_5], %[tmp_5], %[tmp_4] \n\t"
836 "mul %[tmp_6], %[tmp_6], %[tmp_4] \n\t"
837 "sra %[tmp_2], %[tmp_2], 14 \n\t"
838 "sra %[tmp_3], %[tmp_3], 14 \n\t"
839 "sra %[tmp_5], %[tmp_5], 14 \n\t"
840 "sra %[tmp_6], %[tmp_6], 14 \n\t"
841 "sh %[tmp_2], 0(%[real]) \n\t"
842 "sh %[tmp_2], 4(%[freq_buf_s]) \n\t"
843 "sh %[tmp_3], 0(%[imag]) \n\t"
844 "sh %[tmp_3], 6(%[freq_buf_s]) \n\t"
845 "negu %[tmp_3], %[tmp_3] \n\t"
846 "sh %[tmp_2], 0(%[freq_buf_f]) \n\t"
847 "sh %[tmp_3], 2(%[freq_buf_f]) \n\t"
848 "sh %[tmp_5], 4(%[freq_buf_f]) \n\t"
849 "sh %[tmp_6], 6(%[freq_buf_f]) \n\t"
850 "sh %[tmp_5], 2(%[real]) \n\t"
851 "sh %[tmp_6], 2(%[imag]) \n\t"
853 : [real] "+r" (real), [imag] "+r" (imag),
854 [freq_buf_f] "+r" (freq_buf_f), [freq_buf_s] "+r" (freq_buf_s),
855 [loop_count] "+r" (loop_count), [noiseSupFilter] "+r" (noiseSupFilter),
856 [tmp_1] "=&r" (tmp_1), [tmp_2] "=&r" (tmp_2), [tmp_3] "=&r" (tmp_3),
857 [tmp_4] "=&r" (tmp_4), [tmp_5] "=&r" (tmp_5), [tmp_6] "=&r" (tmp_6)
858 : [loop_size] "r" (inst->anaLen2)
859 : "memory", "hi", "lo"
863 #if defined(MIPS_DSP_R1_LE)
864 // Denormalize the real-valued signal |in|, the output from inverse FFT.
865 void WebRtcNsx_Denormalize_mips(NsxInst_t* inst, int16_t* in, int factor) {
866 int32_t r0, r1, r2, r3, t0;
867 int len = inst->anaLen;
868 int16_t *out = &inst->real[0];
869 int shift = factor - inst->normData;
873 ".set noreorder \n\t"
874 "beqz %[len], 8f \n\t"
876 "bltz %[shift], 4f \n\t"
877 " sra %[t0], %[len], 2 \n\t"
878 "beqz %[t0], 2f \n\t"
879 " andi %[len], %[len], 3 \n\t"
881 "lh %[r0], 0(%[in]) \n\t"
882 "lh %[r1], 2(%[in]) \n\t"
883 "lh %[r2], 4(%[in]) \n\t"
884 "lh %[r3], 6(%[in]) \n\t"
885 "shllv_s.ph %[r0], %[r0], %[shift] \n\t"
886 "shllv_s.ph %[r1], %[r1], %[shift] \n\t"
887 "shllv_s.ph %[r2], %[r2], %[shift] \n\t"
888 "shllv_s.ph %[r3], %[r3], %[shift] \n\t"
889 "addiu %[in], %[in], 8 \n\t"
890 "addiu %[t0], %[t0], -1 \n\t"
891 "sh %[r0], 0(%[out]) \n\t"
892 "sh %[r1], 2(%[out]) \n\t"
893 "sh %[r2], 4(%[out]) \n\t"
894 "sh %[r3], 6(%[out]) \n\t"
895 "bgtz %[t0], 1b \n\t"
896 " addiu %[out], %[out], 8 \n\t"
898 "beqz %[len], 8f \n\t"
901 "lh %[r0], 0(%[in]) \n\t"
902 "addiu %[in], %[in], 2 \n\t"
903 "addiu %[len], %[len], -1 \n\t"
904 "shllv_s.ph %[r0], %[r0], %[shift] \n\t"
905 "addiu %[out], %[out], 2 \n\t"
906 "bgtz %[len], 3b \n\t"
907 " sh %[r0], -2(%[out]) \n\t"
910 "negu %[shift], %[shift] \n\t"
911 "beqz %[t0], 6f \n\t"
912 " andi %[len], %[len], 3 \n\t"
914 "lh %[r0], 0(%[in]) \n\t"
915 "lh %[r1], 2(%[in]) \n\t"
916 "lh %[r2], 4(%[in]) \n\t"
917 "lh %[r3], 6(%[in]) \n\t"
918 "srav %[r0], %[r0], %[shift] \n\t"
919 "srav %[r1], %[r1], %[shift] \n\t"
920 "srav %[r2], %[r2], %[shift] \n\t"
921 "srav %[r3], %[r3], %[shift] \n\t"
922 "addiu %[in], %[in], 8 \n\t"
923 "addiu %[t0], %[t0], -1 \n\t"
924 "sh %[r0], 0(%[out]) \n\t"
925 "sh %[r1], 2(%[out]) \n\t"
926 "sh %[r2], 4(%[out]) \n\t"
927 "sh %[r3], 6(%[out]) \n\t"
928 "bgtz %[t0], 5b \n\t"
929 " addiu %[out], %[out], 8 \n\t"
931 "beqz %[len], 8f \n\t"
934 "lh %[r0], 0(%[in]) \n\t"
935 "addiu %[in], %[in], 2 \n\t"
936 "addiu %[len], %[len], -1 \n\t"
937 "srav %[r0], %[r0], %[shift] \n\t"
938 "addiu %[out], %[out], 2 \n\t"
939 "bgtz %[len], 7b \n\t"
940 " sh %[r0], -2(%[out]) \n\t"
943 : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1),
944 [r2] "=&r" (r2), [r3] "=&r" (r3)
945 : [len] "r" (len), [shift] "r" (shift), [in] "r" (in),
952 // Normalize the real-valued signal |in|, the input to forward FFT.
953 void WebRtcNsx_NormalizeRealBuffer_mips(NsxInst_t* inst,
956 int32_t r0, r1, r2, r3, t0;
957 int len = inst->anaLen;
958 int shift = inst->normData;
962 ".set noreorder \n\t"
963 "beqz %[len], 4f \n\t"
964 " sra %[t0], %[len], 2 \n\t"
965 "beqz %[t0], 2f \n\t"
966 " andi %[len], %[len], 3 \n\t"
968 "lh %[r0], 0(%[in]) \n\t"
969 "lh %[r1], 2(%[in]) \n\t"
970 "lh %[r2], 4(%[in]) \n\t"
971 "lh %[r3], 6(%[in]) \n\t"
972 "sllv %[r0], %[r0], %[shift] \n\t"
973 "sllv %[r1], %[r1], %[shift] \n\t"
974 "sllv %[r2], %[r2], %[shift] \n\t"
975 "sllv %[r3], %[r3], %[shift] \n\t"
976 "addiu %[in], %[in], 8 \n\t"
977 "addiu %[t0], %[t0], -1 \n\t"
978 "sh %[r0], 0(%[out]) \n\t"
979 "sh %[r1], 2(%[out]) \n\t"
980 "sh %[r2], 4(%[out]) \n\t"
981 "sh %[r3], 6(%[out]) \n\t"
982 "bgtz %[t0], 1b \n\t"
983 " addiu %[out], %[out], 8 \n\t"
985 "beqz %[len], 4f \n\t"
988 "lh %[r0], 0(%[in]) \n\t"
989 "addiu %[in], %[in], 2 \n\t"
990 "addiu %[len], %[len], -1 \n\t"
991 "sllv %[r0], %[r0], %[shift] \n\t"
992 "addiu %[out], %[out], 2 \n\t"
993 "bgtz %[len], 3b \n\t"
994 " sh %[r0], -2(%[out]) \n\t"
997 : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1),
998 [r2] "=&r" (r2), [r3] "=&r" (r3)
999 : [len] "r" (len), [shift] "r" (shift), [in] "r" (in),