1556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org/*
2556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *
4556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  Use of this source code is governed by a BSD-style license
5556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  that can be found in the LICENSE file in the root of the source
6556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  tree. An additional intellectual property rights grant can be found
7556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  in the file PATENTS.  All contributing project authors may
8556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org */
10556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
1192e07ae02c00648f1a298eaaaa07d2407859db1ebjornv@webrtc.org#include <assert.h>
1292e07ae02c00648f1a298eaaaa07d2407859db1ebjornv@webrtc.org
13556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h"
14556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#include "webrtc/modules/audio_processing/ns/nsx_core.h"
15556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
16556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgstatic const int16_t kIndicatorTable[17] = {
17556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  0, 2017, 3809, 5227, 6258, 6963, 7424, 7718,
18556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  7901, 8014, 8084, 8126, 8152, 8168, 8177, 8183, 8187
19556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org};
20556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
21556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// Compute speech/noise probability
22556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// speech/noise probability is returned in: probSpeechFinal
23556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org//snrLocPrior is the prior SNR for each frequency (in Q11)
24556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org//snrLocPost is the post SNR for each frequency (in Q11)
25556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_SpeechNoiseProb(NsxInst_t* inst,
26556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                               uint16_t* nonSpeechProbFinal,
27556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                               uint32_t* priorLocSnr,
28556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                               uint32_t* postLocSnr) {
29556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
30556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  uint32_t tmpU32no1, tmpU32no2, tmpU32no3;
31556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t indPriorFX, tmp32no1;
32556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t logLrtTimeAvgKsumFX;
33556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t indPriorFX16;
34556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t tmp16, tmp16no1, tmp16no2, tmpIndFX, tableIndex, frac;
35556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int i, normTmp, nShifts;
36556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
37556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t r0, r1, r2, r3, r4, r5, r6, r7, r8, r9;
38556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t const_max = 0x7fffffff;
39556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t const_neg43 = -43;
40556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t const_5412 = 5412;
41556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t const_11rsh12 = (11 << 12);
42556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t const_178 = 178;
43556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
44556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
45556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // compute feature based on average LR factor
46556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // this is the average over all frequencies of the smooth log LRT
47556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  logLrtTimeAvgKsumFX = 0;
48556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  for (i = 0; i < inst->magnLen; i++) {
49556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    r0 = postLocSnr[i]; // Q11
50556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    r1 = priorLocSnr[i];
51556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    r2 = inst->logLrtTimeAvgW32[i];
52556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
53556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    __asm __volatile(
54556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      ".set       push                                    \n\t"
55556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      ".set       noreorder                               \n\t"
56556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "clz        %[r3],    %[r0]                         \n\t"
57556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "clz        %[r5],    %[r1]                         \n\t"
58556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "slti       %[r4],    %[r3],    32                  \n\t"
59556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "slti       %[r6],    %[r5],    32                  \n\t"
60556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "movz       %[r3],    $0,       %[r4]               \n\t"
61556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "movz       %[r5],    $0,       %[r6]               \n\t"
62556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "slti       %[r4],    %[r3],    11                  \n\t"
63556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addiu      %[r6],    %[r3],    -11                 \n\t"
64556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "neg        %[r7],    %[r6]                         \n\t"
65556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sllv       %[r6],    %[r1],    %[r6]               \n\t"
66556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "srav       %[r7],    %[r1],    %[r7]               \n\t"
67556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "movn       %[r6],    %[r7],    %[r4]               \n\t"
68556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sllv       %[r1],    %[r1],    %[r5]               \n\t"
69556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "and        %[r1],    %[r1],    %[const_max]        \n\t"
70556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sra        %[r1],    %[r1],    19                  \n\t"
71556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "mul        %[r7],    %[r1],    %[r1]               \n\t"
72556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sllv       %[r3],    %[r0],    %[r3]               \n\t"
73556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "divu       %[r8],    %[r3],    %[r6]               \n\t"
74556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "slti       %[r6],    %[r6],    1                   \n\t"
75556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "mul        %[r7],    %[r7],    %[const_neg43]      \n\t"
76556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sra        %[r7],    %[r7],    19                  \n\t"
77556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "movz       %[r3],    %[r8],    %[r6]               \n\t"
78556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "subu       %[r0],    %[r0],    %[r3]               \n\t"
79f81734ba586f686af4203d419cc1cfb8b8642061bjornv@webrtc.org      "movn       %[r0],    $0,       %[r6]               \n\t"
80556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "mul        %[r1],    %[r1],    %[const_5412]       \n\t"
81556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sra        %[r1],    %[r1],    12                  \n\t"
82556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addu       %[r7],    %[r7],    %[r1]               \n\t"
83556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addiu      %[r1],    %[r7],    37                  \n\t"
84556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addiu      %[r5],    %[r5],    -31                 \n\t"
85556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "neg        %[r5],    %[r5]                         \n\t"
86556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sll        %[r5],    %[r5],    12                  \n\t"
87556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addu       %[r5],    %[r5],    %[r1]               \n\t"
88556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "subu       %[r7],    %[r5],    %[const_11rsh12]    \n\t"
89556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "mul        %[r7],    %[r7],    %[const_178]        \n\t"
90556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sra        %[r7],    %[r7],    8                   \n\t"
91556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addu       %[r7],    %[r7],    %[r2]               \n\t"
92556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "sra        %[r7],    %[r7],    1                   \n\t"
93556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "subu       %[r2],    %[r2],    %[r7]               \n\t"
94556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      "addu       %[r2],    %[r2],    %[r0]               \n\t"
95556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      ".set       pop                                     \n\t"
96556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      : [r0] "+r" (r0), [r1] "+r" (r1), [r2] "+r" (r2),
97556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
98556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        [r6] "=&r" (r6), [r7] "=&r" (r7), [r8] "=&r" (r8)
99556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      : [const_max] "r" (const_max), [const_neg43] "r" (const_neg43),
100556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        [const_5412] "r" (const_5412), [const_11rsh12] "r" (const_11rsh12),
101556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        [const_178] "r" (const_178)
102556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      : "hi", "lo"
103556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    );
104556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    inst->logLrtTimeAvgW32[i] = r2;
105556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    logLrtTimeAvgKsumFX += r2;
106556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
107556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
108556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  inst->featureLogLrt = WEBRTC_SPL_RSHIFT_W32(logLrtTimeAvgKsumFX * 5,
109556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                              inst->stages + 10);
110556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                                  // 5 = BIN_SIZE_LRT / 2
111556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // done with computation of LR factor
112556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
113556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //
114556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // compute the indicator functions
115556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //
116556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
117556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // average LRT feature
118556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // FLOAT code
119556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // indicator0 = 0.5 * (tanh(widthPrior *
120556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //                      (logLrtTimeAvgKsum - threshPrior0)) + 1.0);
121556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  tmpIndFX = 16384; // Q14(1.0)
122556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  tmp32no1 = logLrtTimeAvgKsumFX - inst->thresholdLogLrt; // Q12
123556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  nShifts = 7 - inst->stages; // WIDTH_PR_MAP_SHIFT - inst->stages + 5;
124556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //use larger width in tanh map for pause regions
125556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  if (tmp32no1 < 0) {
126556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpIndFX = 0;
127556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmp32no1 = -tmp32no1;
128556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //widthPrior = widthPrior * 2.0;
129556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    nShifts++;
130556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
131556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  tmp32no1 = WEBRTC_SPL_SHIFT_W32(tmp32no1, nShifts); // Q14
132556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // compute indicator function: sigmoid map
133556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  tableIndex = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32no1, 14);
134556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  if ((tableIndex < 16) && (tableIndex >= 0)) {
135556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmp16no2 = kIndicatorTable[tableIndex];
136556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
137556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    frac = (int16_t)(tmp32no1 & 0x00003fff); // Q14
138556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, frac, 14);
139556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (tmpIndFX == 0) {
140556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpIndFX = 8192 - tmp16no2; // Q14
141556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    } else {
142556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpIndFX = 8192 + tmp16no2; // Q14
143556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
144556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
145556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  indPriorFX = WEBRTC_SPL_MUL_16_16(inst->weightLogLrt, tmpIndFX); // 6*Q14
146556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
147556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //spectral flatness feature
148556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  if (inst->weightSpecFlat) {
149556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpU32no1 = WEBRTC_SPL_UMUL(inst->featureSpecFlat, 400); // Q10
150556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpIndFX = 16384; // Q14(1.0)
151556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //use larger width in tanh map for pause regions
152556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpU32no2 = inst->thresholdSpecFlat - tmpU32no1; //Q10
153556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    nShifts = 4;
154556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (inst->thresholdSpecFlat < tmpU32no1) {
155556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpIndFX = 0;
156556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpU32no2 = tmpU32no1 - inst->thresholdSpecFlat;
157556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      //widthPrior = widthPrior * 2.0;
158556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      nShifts++;
159556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
16092e07ae02c00648f1a298eaaaa07d2407859db1ebjornv@webrtc.org    tmpU32no1 = WebRtcSpl_DivU32U16(tmpU32no2 << nShifts, 25);  //Q14
161556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    // compute indicator function: sigmoid map
162556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    // FLOAT code
163556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    // indicator1 = 0.5 * (tanh(sgnMap * widthPrior *
164556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //                          (threshPrior1 - tmpFloat1)) + 1.0);
165556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tableIndex = (int16_t)WEBRTC_SPL_RSHIFT_U32(tmpU32no1, 14);
166556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (tableIndex < 16) {
167556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no2 = kIndicatorTable[tableIndex];
168556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
169556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
170556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, frac, 14);
171556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      if (tmpIndFX) {
172556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        tmpIndFX = 8192 + tmp16no2; // Q14
173556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      } else {
174556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        tmpIndFX = 8192 - tmp16no2; // Q14
175556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      }
176556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
177556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecFlat, tmpIndFX); // 6*Q14
178556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
179556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
180556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //for template spectral-difference
181556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  if (inst->weightSpecDiff) {
182556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpU32no1 = 0;
183556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (inst->featureSpecDiff) {
184556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      normTmp = WEBRTC_SPL_MIN(20 - inst->stages,
185556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                               WebRtcSpl_NormU32(inst->featureSpecDiff));
18692e07ae02c00648f1a298eaaaa07d2407859db1ebjornv@webrtc.org      assert(normTmp >= 0);
18792e07ae02c00648f1a298eaaaa07d2407859db1ebjornv@webrtc.org      tmpU32no1 = inst->featureSpecDiff << normTmp;  // Q(normTmp-2*stages)
188556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpU32no2 = WEBRTC_SPL_RSHIFT_U32(inst->timeAvgMagnEnergy,
189556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                        20 - inst->stages - normTmp);
190556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      if (tmpU32no2 > 0) {
191556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        // Q(20 - inst->stages)
192724e3f874a820dcd272d5e1b38b00066d9442b90bjornv@webrtc.org        tmpU32no1 /= tmpU32no2;
193556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      } else {
194556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        tmpU32no1 = (uint32_t)(0x7fffffff);
195556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      }
196556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
197724e3f874a820dcd272d5e1b38b00066d9442b90bjornv@webrtc.org    tmpU32no3 = (inst->thresholdSpecDiff << 17) / 25;
198556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpU32no2 = tmpU32no1 - tmpU32no3;
199556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    nShifts = 1;
200556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpIndFX = 16384; // Q14(1.0)
201556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //use larger width in tanh map for pause regions
202556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (tmpU32no2 & 0x80000000) {
203556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpIndFX = 0;
204556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmpU32no2 = tmpU32no3 - tmpU32no1;
205556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      //widthPrior = widthPrior * 2.0;
206556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      nShifts--;
207556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
208556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tmpU32no1 = WEBRTC_SPL_RSHIFT_U32(tmpU32no2, nShifts);
209556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    // compute indicator function: sigmoid map
210556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    /* FLOAT code
211556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org     indicator2 = 0.5 * (tanh(widthPrior * (tmpFloat1 - threshPrior2)) + 1.0);
212556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org     */
213556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    tableIndex = (int16_t)WEBRTC_SPL_RSHIFT_U32(tmpU32no1, 14);
214556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    if (tableIndex < 16) {
215556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no2 = kIndicatorTable[tableIndex];
216556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no1 = kIndicatorTable[tableIndex + 1] - kIndicatorTable[tableIndex];
217556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      frac = (int16_t)(tmpU32no1 & 0x00003fff); // Q14
218556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      tmp16no2 += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
219556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                    tmp16no1, frac, 14);
220556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      if (tmpIndFX) {
221556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        tmpIndFX = 8192 + tmp16no2;
222556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      } else {
223556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        tmpIndFX = 8192 - tmp16no2;
224556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      }
225556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
226556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecDiff, tmpIndFX); // 6*Q14
227556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
228556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
229556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //combine the indicator function with the feature weights
230556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // FLOAT code
231556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // indPrior = 1 - (weightIndPrior0 * indicator0 + weightIndPrior1 *
232556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //                 indicator1 + weightIndPrior2 * indicator2);
233556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  indPriorFX16 = WebRtcSpl_DivW32W16ResW16(98307 - indPriorFX, 6); // Q14
234556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // done with computing indicator function
235556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
236556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //compute the prior probability
237556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // FLOAT code
238556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // inst->priorNonSpeechProb += PRIOR_UPDATE *
239556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //                             (indPriorNonSpeech - inst->priorNonSpeechProb);
240556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  tmp16 = indPriorFX16 - inst->priorNonSpeechProb; // Q14
241556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  inst->priorNonSpeechProb += (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(
242556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                PRIOR_UPDATE_Q14, tmp16, 14); // Q14
243556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
244556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  //final speech probability: combine prior model with LR factor:
245556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
246556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  memset(nonSpeechProbFinal, 0, sizeof(uint16_t) * inst->magnLen);
247556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
248556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  if (inst->priorNonSpeechProb > 0) {
249556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    r0 = inst->priorNonSpeechProb;
250556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    r1 = 16384 - r0;
251556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    int32_t const_23637 = 23637;
252556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    int32_t const_44 = 44;
253556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    int32_t const_84 = 84;
254556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    int32_t const_1 = 1;
255556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    int32_t const_neg8 = -8;
256556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    for (i = 0; i < inst->magnLen; i++) {
257556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      r2 = inst->logLrtTimeAvgW32[i];
258556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      if (r2 < 65300) {
259556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        __asm __volatile(
260556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          ".set         push                                      \n\t"
261556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          ".set         noreorder                                 \n\t"
262556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r2],    %[r2],          %[const_23637]  \n\t"
263556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sll          %[r6],    %[r1],          16              \n\t"
264556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "clz          %[r7],    %[r6]                           \n\t"
265556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "clo          %[r8],    %[r6]                           \n\t"
266556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r9],    %[r6],          $0              \n\t"
267556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movn         %[r7],    %[r8],          %[r9]           \n\t"
268556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sra          %[r2],    %[r2],          14              \n\t"
269556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "andi         %[r3],    %[r2],          0xfff           \n\t"
270556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r4],    %[r3],          %[r3]           \n\t"
271556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r3],    %[r3],          %[const_84]     \n\t"
272556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sra          %[r2],    %[r2],          12              \n\t"
273556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r5],    %[r2],          %[const_neg8]   \n\t"
274556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movn         %[r2],    %[const_neg8],  %[r5]           \n\t"
275556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r4],    %[r4],          %[const_44]     \n\t"
276556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sra          %[r3],    %[r3],          7               \n\t"
277556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r7],    %[r7],          -1              \n\t"
278556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slti         %[r9],    %[r7],          31              \n\t"
279556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movz         %[r7],    $0,             %[r9]           \n\t"
280556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sra          %[r4],    %[r4],          19              \n\t"
281556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addu         %[r4],    %[r4],          %[r3]           \n\t"
282556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r3],    %[r2],          8               \n\t"
283556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r2],    %[r2],          -4              \n\t"
284556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "neg          %[r5],    %[r2]                           \n\t"
285556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sllv         %[r6],    %[r4],          %[r2]           \n\t"
286556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "srav         %[r5],    %[r4],          %[r5]           \n\t"
287556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r2],    %[r2],          $0              \n\t"
288556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movn         %[r6],    %[r5],          %[r2]           \n\t"
289556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sllv         %[r3],    %[const_1],     %[r3]           \n\t"
290556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addu         %[r2],    %[r3],          %[r6]           \n\t"
291556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "clz          %[r4],    %[r2]                           \n\t"
292556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "clo          %[r5],    %[r2]                           \n\t"
293556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r8],    %[r2],          $0              \n\t"
294556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movn         %[r4],    %[r5],          %[r8]           \n\t"
295556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r4],    %[r4],          -1              \n\t"
296556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r5],    $0,             %[r2]           \n\t"
297556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "or           %[r5],    %[r5],          %[r7]           \n\t"
298556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movz         %[r4],    $0,             %[r5]           \n\t"
299556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r6],    %[r7],          -7              \n\t"
300556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addu         %[r6],    %[r6],          %[r4]           \n\t"
301556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "bltz         %[r6],    1f                              \n\t"
302556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          " nop                                                   \n\t"
303556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addiu        %[r4],    %[r6],          -8              \n\t"
304556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "neg          %[r3],    %[r4]                           \n\t"
305556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "srav         %[r5],    %[r2],          %[r3]           \n\t"
306556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r5],    %[r5],          %[r1]           \n\t"
307556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "mul          %[r2],    %[r2],          %[r1]           \n\t"
308556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "slt          %[r4],    %[r4],          $0              \n\t"
309556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "srav         %[r5],    %[r5],          %[r6]           \n\t"
310556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sra          %[r2],    %[r2],          8               \n\t"
311556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "movn         %[r2],    %[r5],          %[r4]           \n\t"
312556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "sll          %[r3],    %[r0],          8               \n\t"
313556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "addu         %[r2],    %[r0],          %[r2]           \n\t"
314556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          "divu         %[r3],    %[r3],          %[r2]           \n\t"
315556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org         "1:                                                      \n\t"
316556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          ".set         pop                                       \n\t"
317556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          : [r2] "+r" (r2), [r3] "=&r" (r3), [r4] "=&r" (r4),
318556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org            [r5] "=&r" (r5), [r6] "=&r" (r6), [r7] "=&r" (r7),
319556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org            [r8] "=&r" (r8), [r9] "=&r" (r9)
320556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          : [r0] "r" (r0), [r1] "r" (r1), [const_23637] "r" (const_23637),
321556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org            [const_neg8] "r" (const_neg8), [const_84] "r" (const_84),
322556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org            [const_1] "r" (const_1), [const_44] "r" (const_44)
323556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org          : "hi", "lo"
324556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        );
325556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org        nonSpeechProbFinal[i] = r3;
326556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      }
327556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    }
328556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  }
329556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
330556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
331556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// Update analysis buffer for lower band, and window data before FFT.
332556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_AnalysisUpdate_mips(NsxInst_t* inst,
333556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                   int16_t* out,
334556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                   int16_t* new_speech) {
335556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
336556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int iters, after;
337556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int anaLen = inst->anaLen;
338556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int *window = (int*)inst->window;
339556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int *anaBuf = (int*)inst->analysisBuffer;
340556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int *outBuf = (int*)out;
341556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int r0, r1, r2, r3, r4, r5, r6, r7;
342556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#if defined(MIPS_DSP_R1_LE)
343556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int r8;
344556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#endif
345556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
346556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // For lower band update analysis buffer.
347556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer,
348556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                        inst->analysisBuffer + inst->blockLen10ms,
349556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                        inst->anaLen - inst->blockLen10ms);
350556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer
351556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
352556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
353556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // Window data before FFT.
354556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#if defined(MIPS_DSP_R1_LE)
355556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm __volatile(
356556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set              push                                \n\t"
357556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set              noreorder                           \n\t"
358556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra               %[iters],   %[anaLen],    3         \n\t"
359556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                     \n\t"
360556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez              %[iters],   2f                      \n\t"
361556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                  \n\t"
362556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r0],      0(%[window])            \n\t"
363556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r1],      0(%[anaBuf])            \n\t"
364556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r2],      4(%[window])            \n\t"
365556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r3],      4(%[anaBuf])            \n\t"
366556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r4],      8(%[window])            \n\t"
367556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r5],      8(%[anaBuf])            \n\t"
368556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r6],      12(%[window])           \n\t"
369556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lw                %[r7],      12(%[anaBuf])           \n\t"
370556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phl     %[r8],      %[r0],        %[r1]     \n\t"
371556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phr     %[r0],      %[r0],        %[r1]     \n\t"
372556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phl     %[r1],      %[r2],        %[r3]     \n\t"
373556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phr     %[r2],      %[r2],        %[r3]     \n\t"
374556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phl     %[r3],      %[r4],        %[r5]     \n\t"
375556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phr     %[r4],      %[r4],        %[r5]     \n\t"
376556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phl     %[r5],      %[r6],        %[r7]     \n\t"
377556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "muleq_s.w.phr     %[r6],      %[r6],        %[r7]     \n\t"
378556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#if defined(MIPS_DSP_R2_LE)
379556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "precr_sra_r.ph.w  %[r8],      %[r0],        15        \n\t"
380556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "precr_sra_r.ph.w  %[r1],      %[r2],        15        \n\t"
381556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "precr_sra_r.ph.w  %[r3],      %[r4],        15        \n\t"
382556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "precr_sra_r.ph.w  %[r5],      %[r6],        15        \n\t"
383556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r8],      0(%[outBuf])            \n\t"
384556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r1],      4(%[outBuf])            \n\t"
385556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r3],      8(%[outBuf])            \n\t"
386556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r5],      12(%[outBuf])           \n\t"
387556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#else
388556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r8],      %[r8],        15        \n\t"
389556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r0],      %[r0],        15        \n\t"
390556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r1],      %[r1],        15        \n\t"
391556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r2],      %[r2],        15        \n\t"
392556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r3],      %[r3],        15        \n\t"
393556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r4],      %[r4],        15        \n\t"
394556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r5],      %[r5],        15        \n\t"
395556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r6],      %[r6],        15        \n\t"
396556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sll               %[r0],      %[r0],        16        \n\t"
397556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sll               %[r2],      %[r2],        16        \n\t"
398556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sll               %[r4],      %[r4],        16        \n\t"
399556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sll               %[r6],      %[r6],        16        \n\t"
400556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "packrl.ph         %[r0],      %[r8],        %[r0]     \n\t"
401556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "packrl.ph         %[r2],      %[r1],        %[r2]     \n\t"
402556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "packrl.ph         %[r4],      %[r3],        %[r4]     \n\t"
403556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "packrl.ph         %[r6],      %[r5],        %[r6]     \n\t"
404556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r0],      0(%[outBuf])            \n\t"
405556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r2],      4(%[outBuf])            \n\t"
406556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r4],      8(%[outBuf])            \n\t"
407556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sw                %[r6],      12(%[outBuf])           \n\t"
408556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#endif
409556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[window],  %[window],    16        \n\t"
410556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[anaBuf],  %[anaBuf],    16        \n\t"
411556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[outBuf],  %[outBuf],    16        \n\t"
412556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b                 1b                                  \n\t"
413556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu            %[iters],   %[iters],     -1        \n\t"
414556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "2:                                                     \n\t"
415556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "andi              %[after],   %[anaLen],    7         \n\t"
416556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "3:                                                     \n\t"
417556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez              %[after],   4f                      \n\t"
418556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                  \n\t"
419556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh                %[r0],      0(%[window])            \n\t"
420556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh                %[r1],      0(%[anaBuf])            \n\t"
421556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul               %[r0],      %[r0],        %[r1]     \n\t"
422556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[window],  %[window],    2         \n\t"
423556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[anaBuf],  %[anaBuf],    2         \n\t"
424556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu             %[outBuf],  %[outBuf],    2         \n\t"
425556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shra_r.w          %[r0],      %[r0],        14        \n\t"
426556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh                %[r0],      -2(%[outBuf])           \n\t"
427556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b                 3b                                  \n\t"
428556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu            %[after],   %[after],     -1        \n\t"
429556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "4:                                                     \n\t"
430556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set              pop                                 \n\t"
431556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
432556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
433556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r6] "=&r" (r6), [r7] "=&r" (r7), [r8] "=&r" (r8),
434556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [iters] "=&r" (iters), [after] "=&r" (after),
435556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [window] "+r" (window),[anaBuf] "+r" (anaBuf),
436556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [outBuf] "+r" (outBuf)
437556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [anaLen] "r" (anaLen)
438556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory", "hi", "lo"
439556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
440556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#else
441556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm  __volatile(
442556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set           push                                    \n\t"
443556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set           noreorder                               \n\t"
444556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[iters],   %[anaLen],      2           \n\t"
445556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                      \n\t"
446556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez           %[iters],   2f                          \n\t"
447556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                   \n\t"
448556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r0],      0(%[window])                \n\t"
449556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r1],      0(%[anaBuf])                \n\t"
450556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r2],      2(%[window])                \n\t"
451556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r3],      2(%[anaBuf])                \n\t"
452556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r4],      4(%[window])                \n\t"
453556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r5],      4(%[anaBuf])                \n\t"
454556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r6],      6(%[window])                \n\t"
455556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r7],      6(%[anaBuf])                \n\t"
456556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul            %[r0],      %[r0],          %[r1]       \n\t"
457556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul            %[r2],      %[r2],          %[r3]       \n\t"
458556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul            %[r4],      %[r4],          %[r5]       \n\t"
459556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul            %[r6],      %[r6],          %[r7]       \n\t"
460556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[window],  %[window],      8           \n\t"
461556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[anaBuf],  %[anaBuf],      8           \n\t"
462556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[r0],      %[r0],          0x2000      \n\t"
463556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[r2],      %[r2],          0x2000      \n\t"
464556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[r4],      %[r4],          0x2000      \n\t"
465556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[r6],      %[r6],          0x2000      \n\t"
466556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[r0],      %[r0],          14          \n\t"
467556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[r2],      %[r2],          14          \n\t"
468556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[r4],      %[r4],          14          \n\t"
469556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[r6],      %[r6],          14          \n\t"
470556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh             %[r0],      0(%[outBuf])                \n\t"
471556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh             %[r2],      2(%[outBuf])                \n\t"
472556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh             %[r4],      4(%[outBuf])                \n\t"
473556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh             %[r6],      6(%[outBuf])                \n\t"
474556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[outBuf],  %[outBuf],      8           \n\t"
475556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b              1b                                      \n\t"
476556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu         %[iters],   %[iters],       -1          \n\t"
477556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "2:                                                      \n\t"
478556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "andi           %[after],   %[anaLen],      3           \n\t"
479556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "3:                                                      \n\t"
480556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez           %[after],   4f                          \n\t"
481556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                   \n\t"
482556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r0],      0(%[window])                \n\t"
483556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh             %[r1],      0(%[anaBuf])                \n\t"
484556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul            %[r0],      %[r0],          %[r1]       \n\t"
485556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[window],  %[window],      2           \n\t"
486556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[anaBuf],  %[anaBuf],      2           \n\t"
487556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[outBuf],  %[outBuf],      2           \n\t"
488556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu          %[r0],      %[r0],          0x2000      \n\t"
489556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra            %[r0],      %[r0],          14          \n\t"
490556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh             %[r0],      -2(%[outBuf])               \n\t"
491556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b              3b                                      \n\t"
492556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu         %[after],   %[after],       -1          \n\t"
493556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "4:                                                      \n\t"
494556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set           pop                                     \n\t"
495556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
496556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
497556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r6] "=&r" (r6), [r7] "=&r" (r7), [iters] "=&r" (iters),
498556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [after] "=&r" (after), [window] "+r" (window),
499556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [anaBuf] "+r" (anaBuf), [outBuf] "+r" (outBuf)
500556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [anaLen] "r" (anaLen)
501556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory", "hi", "lo"
502556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
503556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#endif
504556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
505556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
506556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// For the noise supression process, synthesis, read out fully processed
507556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// segment, and update synthesis buffer.
508556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_SynthesisUpdate_mips(NsxInst_t* inst,
509556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                    int16_t* out_frame,
510556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                    int16_t gain_factor) {
511556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
512556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int iters = inst->blockLen10ms >> 2;
513556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int after = inst->blockLen10ms & 3;
514556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int r0, r1, r2, r3, r4, r5, r6, r7;
515556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *window = (int16_t*)inst->window;
516556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *real = inst->real;
517556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *synthBuf = inst->synthesisBuffer;
518556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *out = out_frame;
519556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int sat_pos = 0x7fff;
520556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int sat_neg = 0xffff8000;
521556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int block10 = (int)inst->blockLen10ms;
522556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int anaLen = (int)inst->anaLen;
523556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
524556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm __volatile(
525556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       push                                        \n\t"
526556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       noreorder                                   \n\t"
527556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                      \n\t"
528556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez       %[iters],   2f                              \n\t"
529556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                   \n\t"
530556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r0],      0(%[window])                    \n\t"
531556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[real])                      \n\t"
532556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r2],      2(%[window])                    \n\t"
533556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r3],      2(%[real])                      \n\t"
534556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r4],      4(%[window])                    \n\t"
535556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r5],      4(%[real])                      \n\t"
536556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r6],      6(%[window])                    \n\t"
537556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r7],      6(%[real])                      \n\t"
538556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[r1]           \n\t"
539556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r2],      %[r2],          %[r3]           \n\t"
540556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r4],      %[r4],          %[r5]           \n\t"
541556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r6],      %[r6],          %[r7]           \n\t"
542556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x2000          \n\t"
543556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r2],      %[r2],          0x2000          \n\t"
544556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r4],      %[r4],          0x2000          \n\t"
545556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r6],      %[r6],          0x2000          \n\t"
546556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          14              \n\t"
547556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r2],      %[r2],          14              \n\t"
548556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r4],      %[r4],          14              \n\t"
549556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r6],      %[r6],          14              \n\t"
550556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[gain_factor]  \n\t"
551556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r2],      %[r2],          %[gain_factor]  \n\t"
552556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r4],      %[r4],          %[gain_factor]  \n\t"
553556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r6],      %[r6],          %[gain_factor]  \n\t"
554556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x1000          \n\t"
555556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r2],      %[r2],          0x1000          \n\t"
556556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r4],      %[r4],          0x1000          \n\t"
557556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r6],      %[r6],          0x1000          \n\t"
558556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          13              \n\t"
559556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r2],      %[r2],          13              \n\t"
560556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r4],      %[r4],          13              \n\t"
561556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r6],      %[r6],          13              \n\t"
562556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
563556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_pos]      \n\t"
564556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_pos]      \n\t"
565556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_pos]      \n\t"
566556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
567556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r2],      %[sat_pos],     %[r3]           \n\t"
568556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r4],      %[sat_pos],     %[r5]           \n\t"
569556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r6],      %[sat_pos],     %[r7]           \n\t"
570556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[synthBuf])                  \n\t"
571556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r3],      2(%[synthBuf])                  \n\t"
572556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r5],      4(%[synthBuf])                  \n\t"
573556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r7],      6(%[synthBuf])                  \n\t"
574556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r0],      %[r0],          %[r1]           \n\t"
575556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r2],      %[r2],          %[r3]           \n\t"
576556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r4],      %[r4],          %[r5]           \n\t"
577556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r6],      %[r6],          %[r7]           \n\t"
578556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
579556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_pos]      \n\t"
580556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_pos]      \n\t"
581556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_pos]      \n\t"
582556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
583556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r2],      %[sat_pos],     %[r3]           \n\t"
584556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r4],      %[sat_pos],     %[r5]           \n\t"
585556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r6],      %[sat_pos],     %[r7]           \n\t"
586556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_neg]      \n\t"
587556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_neg]      \n\t"
588556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_neg]      \n\t"
589556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_neg]      \n\t"
590556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r0],      %[sat_neg],     %[r1]           \n\t"
591556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r2],      %[sat_neg],     %[r3]           \n\t"
592556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r4],      %[sat_neg],     %[r5]           \n\t"
593556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r6],      %[sat_neg],     %[r7]           \n\t"
594556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[synthBuf])                  \n\t"
595556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r2],      2(%[synthBuf])                  \n\t"
596556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r4],      4(%[synthBuf])                  \n\t"
597556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r6],      6(%[synthBuf])                  \n\t"
598556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[out])                       \n\t"
599556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r2],      2(%[out])                       \n\t"
600556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r4],      4(%[out])                       \n\t"
601556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r6],      6(%[out])                       \n\t"
602556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[window],  %[window],      8               \n\t"
603556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],    %[real],        8               \n\t"
604556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[synthBuf],%[synthBuf],    8               \n\t"
605556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[out],     %[out],         8               \n\t"
606556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b          1b                                          \n\t"
607556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu     %[iters],   %[iters],       -1              \n\t"
608556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "2:                                                      \n\t"
609556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez       %[after],   3f                              \n\t"
610556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " subu      %[block10], %[anaLen],      %[block10]      \n\t"
611556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r0],      0(%[window])                    \n\t"
612556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[real])                      \n\t"
613556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[r1]           \n\t"
614556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[window],  %[window],      2               \n\t"
615556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],    %[real],        2               \n\t"
616556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x2000          \n\t"
617556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          14              \n\t"
618556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[gain_factor]  \n\t"
619556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x1000          \n\t"
620556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          13              \n\t"
621556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
622556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
623556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[synthBuf])                  \n\t"
624556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r0],      %[r0],          %[r1]           \n\t"
625556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
626556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
627556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_neg]      \n\t"
628556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r0],      %[sat_neg],     %[r1]           \n\t"
629556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[synthBuf])                  \n\t"
630556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[out])                       \n\t"
631556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[synthBuf],%[synthBuf],    2               \n\t"
632556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[out],     %[out],         2               \n\t"
633556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b          2b                                          \n\t"
634556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu     %[after],   %[after],       -1              \n\t"
635556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "3:                                                      \n\t"
636556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[iters],   %[block10],     2               \n\t"
637556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "4:                                                      \n\t"
638556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez       %[iters],   5f                              \n\t"
639556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " andi      %[after],   %[block10],     3               \n\t"
640556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r0],      0(%[window])                    \n\t"
641556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[real])                      \n\t"
642556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r2],      2(%[window])                    \n\t"
643556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r3],      2(%[real])                      \n\t"
644556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r4],      4(%[window])                    \n\t"
645556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r5],      4(%[real])                      \n\t"
646556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r6],      6(%[window])                    \n\t"
647556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r7],      6(%[real])                      \n\t"
648556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[r1]           \n\t"
649556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r2],      %[r2],          %[r3]           \n\t"
650556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r4],      %[r4],          %[r5]           \n\t"
651556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r6],      %[r6],          %[r7]           \n\t"
652556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x2000          \n\t"
653556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r2],      %[r2],          0x2000          \n\t"
654556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r4],      %[r4],          0x2000          \n\t"
655556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r6],      %[r6],          0x2000          \n\t"
656556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          14              \n\t"
657556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r2],      %[r2],          14              \n\t"
658556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r4],      %[r4],          14              \n\t"
659556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r6],      %[r6],          14              \n\t"
660556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[gain_factor]  \n\t"
661556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r2],      %[r2],          %[gain_factor]  \n\t"
662556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r4],      %[r4],          %[gain_factor]  \n\t"
663556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r6],      %[r6],          %[gain_factor]  \n\t"
664556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x1000          \n\t"
665556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r2],      %[r2],          0x1000          \n\t"
666556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r4],      %[r4],          0x1000          \n\t"
667556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r6],      %[r6],          0x1000          \n\t"
668556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          13              \n\t"
669556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r2],      %[r2],          13              \n\t"
670556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r4],      %[r4],          13              \n\t"
671556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r6],      %[r6],          13              \n\t"
672556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
673556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_pos]      \n\t"
674556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_pos]      \n\t"
675556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_pos]      \n\t"
676556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
677556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r2],      %[sat_pos],     %[r3]           \n\t"
678556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r4],      %[sat_pos],     %[r5]           \n\t"
679556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r6],      %[sat_pos],     %[r7]           \n\t"
680556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[synthBuf])                  \n\t"
681556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r3],      2(%[synthBuf])                  \n\t"
682556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r5],      4(%[synthBuf])                  \n\t"
683556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r7],      6(%[synthBuf])                  \n\t"
684556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r0],      %[r0],          %[r1]           \n\t"
685556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r2],      %[r2],          %[r3]           \n\t"
686556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r4],      %[r4],          %[r5]           \n\t"
687556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r6],      %[r6],          %[r7]           \n\t"
688556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
689556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_pos]      \n\t"
690556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_pos]      \n\t"
691556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_pos]      \n\t"
692556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
693556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r2],      %[sat_pos],     %[r3]           \n\t"
694556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r4],      %[sat_pos],     %[r5]           \n\t"
695556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r6],      %[sat_pos],     %[r7]           \n\t"
696556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_neg]      \n\t"
697556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r3],      %[r2],          %[sat_neg]      \n\t"
698556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r5],      %[r4],          %[sat_neg]      \n\t"
699556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r7],      %[r6],          %[sat_neg]      \n\t"
700556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r0],      %[sat_neg],     %[r1]           \n\t"
701556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r2],      %[sat_neg],     %[r3]           \n\t"
702556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r4],      %[sat_neg],     %[r5]           \n\t"
703556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r6],      %[sat_neg],     %[r7]           \n\t"
704556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[synthBuf])                  \n\t"
705556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r2],      2(%[synthBuf])                  \n\t"
706556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r4],      4(%[synthBuf])                  \n\t"
707556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r6],      6(%[synthBuf])                  \n\t"
708556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[window],  %[window],      8               \n\t"
709556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],    %[real],        8               \n\t"
710556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[synthBuf],%[synthBuf],    8               \n\t"
711556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b          4b                                          \n\t"
712556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu     %[iters],   %[iters],       -1              \n\t"
713556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "5:                                                      \n\t"
714556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blez       %[after],   6f                              \n\t"
715556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                                   \n\t"
716556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r0],      0(%[window])                    \n\t"
717556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[real])                      \n\t"
718556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[r1]           \n\t"
719556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[window],  %[window],      2               \n\t"
720556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],    %[real],        2               \n\t"
721556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x2000          \n\t"
722556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          14              \n\t"
723556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[r0],      %[r0],          %[gain_factor]  \n\t"
724556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[r0],      %[r0],          0x1000          \n\t"
725556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[r0],      %[r0],          13              \n\t"
726556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
727556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
728556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[r1],      0(%[synthBuf])                  \n\t"
729556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addu       %[r0],      %[r0],          %[r1]           \n\t"
730556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_pos]      \n\t"
731556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movz       %[r0],      %[sat_pos],     %[r1]           \n\t"
732556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "slt        %[r1],      %[r0],          %[sat_neg]      \n\t"
733556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "movn       %[r0],      %[sat_neg],     %[r1]           \n\t"
734556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[r0],      0(%[synthBuf])                  \n\t"
735556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[synthBuf],%[synthBuf],    2               \n\t"
736556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b          2b                                          \n\t"
737556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu     %[after],   %[after],       -1              \n\t"
738556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "6:                                                      \n\t"
739556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       pop                                         \n\t"
740556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [r0] "=&r" (r0), [r1] "=&r" (r1), [r2] "=&r" (r2),
741556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r3] "=&r" (r3), [r4] "=&r" (r4), [r5] "=&r" (r5),
742556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r6] "=&r" (r6), [r7] "=&r" (r7), [iters] "+r" (iters),
743556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [after] "+r" (after), [block10] "+r" (block10),
744556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [window] "+r" (window), [real] "+r" (real),
745556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [synthBuf] "+r" (synthBuf), [out] "+r" (out)
746556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [gain_factor] "r" (gain_factor), [sat_pos] "r" (sat_pos),
747556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [sat_neg] "r" (sat_neg), [anaLen] "r" (anaLen)
748556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory", "hi", "lo"
749556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
750556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
751556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  // update synthesis buffer
752556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer,
753556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                        inst->synthesisBuffer + inst->blockLen10ms,
754556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                        inst->anaLen - inst->blockLen10ms);
755556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
756556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
757556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
758556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
759556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// Filter the data in the frequency domain, and create spectrum.
760556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_PrepareSpectrum_mips(NsxInst_t* inst, int16_t* freq_buf) {
761556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
762556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  uint16_t *noiseSupFilter = inst->noiseSupFilter;
763556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *real = inst->real;
764556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *imag = inst->imag;
765556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t loop_count = 2;
766556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp_6;
767556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t tmp16 = (inst->anaLen << 1) - 4;
768556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t* freq_buf_f = freq_buf;
769556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t* freq_buf_s = &freq_buf[tmp16];
770556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
771556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm __volatile (
772556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       push                                                 \n\t"
773556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       noreorder                                            \n\t"
774556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //first sample
775556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_1],           0(%[noiseSupFilter])             \n\t"
776556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_2],           0(%[real])                       \n\t"
777556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_3],           0(%[imag])                       \n\t"
778556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_2],           %[tmp_2],             %[tmp_1]   \n\t"
779556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_3],           %[tmp_3],             %[tmp_1]   \n\t"
780556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_2],           %[tmp_2],             14         \n\t"
781556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_3],           %[tmp_3],             14         \n\t"
782556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[real])                       \n\t"
783556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           0(%[imag])                       \n\t"
784556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "negu       %[tmp_3],           %[tmp_3]                         \n\t"
785556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[freq_buf_f])                 \n\t"
786556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           2(%[freq_buf_f])                 \n\t"
787556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],            %[real],              2          \n\t"
788556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[imag],            %[imag],              2          \n\t"
789556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[noiseSupFilter],  %[noiseSupFilter],    2          \n\t"
790556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[freq_buf_f],      %[freq_buf_f],        4          \n\t"
791556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                               \n\t"
792556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_1],           0(%[noiseSupFilter])             \n\t"
793556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_2],           0(%[real])                       \n\t"
794556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_3],           0(%[imag])                       \n\t"
795556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_4],           2(%[noiseSupFilter])             \n\t"
796556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_5],           2(%[real])                       \n\t"
797556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_6],           2(%[imag])                       \n\t"
798556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_2],           %[tmp_2],             %[tmp_1]   \n\t"
799556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_3],           %[tmp_3],             %[tmp_1]   \n\t"
800556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_5],           %[tmp_5],             %[tmp_4]   \n\t"
801556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_6],           %[tmp_6],             %[tmp_4]   \n\t"
802556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[loop_count],      %[loop_count],        2          \n\t"
803556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_2],           %[tmp_2],             14         \n\t"
804556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_3],           %[tmp_3],             14         \n\t"
805556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_5],           %[tmp_5],             14         \n\t"
806556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_6],           %[tmp_6],             14         \n\t"
807556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[noiseSupFilter],  %[noiseSupFilter],    4          \n\t"
808556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[real])                       \n\t"
809556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           4(%[freq_buf_s])                 \n\t"
810556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           0(%[imag])                       \n\t"
811556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           6(%[freq_buf_s])                 \n\t"
812556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "negu       %[tmp_3],           %[tmp_3]                         \n\t"
813556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_5],           2(%[real])                       \n\t"
814556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_5],           0(%[freq_buf_s])                 \n\t"
815556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_6],           2(%[imag])                       \n\t"
816556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_6],           2(%[freq_buf_s])                 \n\t"
817556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "negu       %[tmp_6],           %[tmp_6]                         \n\t"
818556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[freq_buf_s],      %[freq_buf_s],        -8         \n\t"
819556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[real],            %[real],              4          \n\t"
820556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu      %[imag],            %[imag],              4          \n\t"
821556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[freq_buf_f])                 \n\t"
822556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           2(%[freq_buf_f])                 \n\t"
823556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_5],           4(%[freq_buf_f])                 \n\t"
824556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_6],           6(%[freq_buf_f])                 \n\t"
825556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "blt        %[loop_count],      %[loop_size],         1b         \n\t"
826556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu     %[freq_buf_f],      %[freq_buf_f],        8          \n\t"
827556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    //last two samples:
828556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_1],           0(%[noiseSupFilter])             \n\t"
829556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_2],           0(%[real])                       \n\t"
830556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_3],           0(%[imag])                       \n\t"
831556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_4],           2(%[noiseSupFilter])             \n\t"
832556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_5],           2(%[real])                       \n\t"
833556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh         %[tmp_6],           2(%[imag])                       \n\t"
834556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_2],           %[tmp_2],             %[tmp_1]   \n\t"
835556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_3],           %[tmp_3],             %[tmp_1]   \n\t"
836556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_5],           %[tmp_5],             %[tmp_4]   \n\t"
837556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "mul        %[tmp_6],           %[tmp_6],             %[tmp_4]   \n\t"
838556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_2],           %[tmp_2],             14         \n\t"
839556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_3],           %[tmp_3],             14         \n\t"
840556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_5],           %[tmp_5],             14         \n\t"
841556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sra        %[tmp_6],           %[tmp_6],             14         \n\t"
842556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[real])                       \n\t"
843556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           4(%[freq_buf_s])                 \n\t"
844556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           0(%[imag])                       \n\t"
845556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           6(%[freq_buf_s])                 \n\t"
846556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "negu       %[tmp_3],           %[tmp_3]                         \n\t"
847556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_2],           0(%[freq_buf_f])                 \n\t"
848556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_3],           2(%[freq_buf_f])                 \n\t"
849556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_5],           4(%[freq_buf_f])                 \n\t"
850556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_6],           6(%[freq_buf_f])                 \n\t"
851556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_5],           2(%[real])                       \n\t"
852556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh         %[tmp_6],           2(%[imag])                       \n\t"
853556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set       pop                                                  \n\t"
854556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [real] "+r" (real), [imag] "+r" (imag),
855556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [freq_buf_f] "+r" (freq_buf_f), [freq_buf_s] "+r" (freq_buf_s),
856556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [loop_count] "+r" (loop_count), [noiseSupFilter] "+r" (noiseSupFilter),
857556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [tmp_1] "=&r" (tmp_1), [tmp_2] "=&r" (tmp_2), [tmp_3] "=&r" (tmp_3),
858556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [tmp_4] "=&r" (tmp_4), [tmp_5] "=&r" (tmp_5), [tmp_6] "=&r" (tmp_6)
859556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [loop_size] "r" (inst->anaLen2)
860556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory", "hi", "lo"
861556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
862556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
863556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
864556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#if defined(MIPS_DSP_R1_LE)
865556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// Denormalize the real-valued signal |in|, the output from inverse FFT.
866556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_Denormalize_mips(NsxInst_t* inst, int16_t* in, int factor) {
867556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t r0, r1, r2, r3, t0;
868556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int len = inst->anaLen;
869556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int16_t *out = &inst->real[0];
870556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int shift = factor - inst->normData;
871556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
872556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm __volatile (
873556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          push                                \n\t"
874556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          noreorder                           \n\t"
875556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[len],     8f                      \n\t"
876556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                              \n\t"
877556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bltz          %[shift],   4f                      \n\t"
878556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " sra          %[t0],      %[len],      2          \n\t"
879556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[t0],      2f                      \n\t"
880556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " andi         %[len],     %[len],      3          \n\t"
881556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                 \n\t"
882556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
883556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r1],      2(%[in])                \n\t"
884556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r2],      4(%[in])                \n\t"
885556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r3],      6(%[in])                \n\t"
886556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shllv_s.ph    %[r0],      %[r0],       %[shift]   \n\t"
887556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shllv_s.ph    %[r1],      %[r1],       %[shift]   \n\t"
888556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shllv_s.ph    %[r2],      %[r2],       %[shift]   \n\t"
889556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shllv_s.ph    %[r3],      %[r3],       %[shift]   \n\t"
890556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       8          \n\t"
891556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[t0],      %[t0],       -1         \n\t"
892556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r0],      0(%[out])               \n\t"
893556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r1],      2(%[out])               \n\t"
894556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r2],      4(%[out])               \n\t"
895556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r3],      6(%[out])               \n\t"
896556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[t0],      1b                      \n\t"
897556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu        %[out],     %[out],      8          \n\t"
898556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "2:                                                 \n\t"
899556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[len],     8f                      \n\t"
900556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                              \n\t"
901556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "3:                                                 \n\t"
902556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
903556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       2          \n\t"
904556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[len],     %[len],      -1         \n\t"
905556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "shllv_s.ph    %[r0],      %[r0],       %[shift]   \n\t"
906556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[out],     %[out],      2          \n\t"
907556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[len],     3b                      \n\t"
908556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " sh           %[r0],      -2(%[out])              \n\t"
909556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "b             8f                                  \n\t"
910556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "4:                                                 \n\t"
911556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "negu          %[shift],   %[shift]                \n\t"
912556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[t0],      6f                      \n\t"
913556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " andi         %[len],     %[len],      3          \n\t"
914556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "5:                                                 \n\t"
915556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
916556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r1],      2(%[in])                \n\t"
917556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r2],      4(%[in])                \n\t"
918556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r3],      6(%[in])                \n\t"
919556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "srav          %[r0],      %[r0],       %[shift]   \n\t"
920556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "srav          %[r1],      %[r1],       %[shift]   \n\t"
921556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "srav          %[r2],      %[r2],       %[shift]   \n\t"
922556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "srav          %[r3],      %[r3],       %[shift]   \n\t"
923556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       8          \n\t"
924556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[t0],      %[t0],       -1         \n\t"
925556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r0],      0(%[out])               \n\t"
926556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r1],      2(%[out])               \n\t"
927556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r2],      4(%[out])               \n\t"
928556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r3],      6(%[out])               \n\t"
929556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[t0],      5b                      \n\t"
930556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu        %[out],     %[out],      8          \n\t"
931556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "6:                                                 \n\t"
932556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[len],     8f                      \n\t"
933556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                              \n\t"
934556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "7:                                                 \n\t"
935556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
936556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       2          \n\t"
937556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[len],     %[len],      -1         \n\t"
938556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "srav          %[r0],      %[r0],       %[shift]   \n\t"
939556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[out],     %[out],      2          \n\t"
940556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[len],     7b                      \n\t"
941556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " sh           %[r0],      -2(%[out])              \n\t"
942556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "8:                                                 \n\t"
943556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          pop                                 \n\t"
944556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1),
945556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r2] "=&r" (r2), [r3] "=&r" (r3)
946556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [len] "r" (len), [shift] "r" (shift), [in] "r" (in),
947556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [out] "r" (out)
948556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory"
949556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
950556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
951556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org#endif
952556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
953556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org// Normalize the real-valued signal |in|, the input to forward FFT.
954556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.orgvoid WebRtcNsx_NormalizeRealBuffer_mips(NsxInst_t* inst,
955556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                        const int16_t* in,
956556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org                                        int16_t* out) {
957556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int32_t r0, r1, r2, r3, t0;
958556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int len = inst->anaLen;
959556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  int shift = inst->normData;
960556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
961556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  __asm __volatile (
962556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          push                                \n\t"
963556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          noreorder                           \n\t"
964556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[len],     4f                      \n\t"
965556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " sra          %[t0],      %[len],      2          \n\t"
966556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[t0],      2f                      \n\t"
967556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " andi         %[len],     %[len],      3          \n\t"
968556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "1:                                                 \n\t"
969556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
970556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r1],      2(%[in])                \n\t"
971556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r2],      4(%[in])                \n\t"
972556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r3],      6(%[in])                \n\t"
973556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sllv          %[r0],      %[r0],       %[shift]   \n\t"
974556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sllv          %[r1],      %[r1],       %[shift]   \n\t"
975556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sllv          %[r2],      %[r2],       %[shift]   \n\t"
976556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sllv          %[r3],      %[r3],       %[shift]   \n\t"
977556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       8          \n\t"
978556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[t0],      %[t0],       -1         \n\t"
979556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r0],      0(%[out])               \n\t"
980556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r1],      2(%[out])               \n\t"
981556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r2],      4(%[out])               \n\t"
982556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sh            %[r3],      6(%[out])               \n\t"
983556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[t0],      1b                      \n\t"
984556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " addiu        %[out],     %[out],      8          \n\t"
985556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "2:                                                 \n\t"
986556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "beqz          %[len],     4f                      \n\t"
987556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " nop                                              \n\t"
988556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "3:                                                 \n\t"
989556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "lh            %[r0],      0(%[in])                \n\t"
990556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[in],      %[in],       2          \n\t"
991556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[len],     %[len],      -1         \n\t"
992556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "sllv          %[r0],      %[r0],       %[shift]   \n\t"
993556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "addiu         %[out],     %[out],      2          \n\t"
994556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    "bgtz          %[len],     3b                      \n\t"
995556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    " sh           %[r0],      -2(%[out])              \n\t"
996556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org   "4:                                                 \n\t"
997556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    ".set          pop                                 \n\t"
998556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [t0] "=&r" (t0), [r0] "=&r" (r0), [r1] "=&r" (r1),
999556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [r2] "=&r" (r2), [r3] "=&r" (r3)
1000556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : [len] "r" (len), [shift] "r" (shift), [in] "r" (in),
1001556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org      [out] "r" (out)
1002556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org    : "memory"
1003556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org  );
1004556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org}
1005556423fc442dd37b8140a86b87f818ba2de4931bandrew@webrtc.org
1006