| 1 | /* Copyright (c) 2007-2008 CSIRO |
| 2 | Copyright (c) 2007-2009 Xiph.Org Foundation |
| 3 | Written by Jean-Marc Valin */ |
| 4 | /* |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions |
| 7 | are met: |
| 8 | |
| 9 | - Redistributions of source code must retain the above copyright |
| 10 | notice, this list of conditions and the following disclaimer. |
| 11 | |
| 12 | - Redistributions in binary form must reproduce the above copyright |
| 13 | notice, this list of conditions and the following disclaimer in the |
| 14 | documentation and/or other materials provided with the distribution. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER |
| 20 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 21 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | //#ifdef HAVE_CONFIG_H |
| 30 | #include "opus__config.h"cxx . . $ `<file>/external/opusfile/opus/opus__config.h`/ |
| 31 | //#endif |
| 32 | |
| 33 | #include "mathops.h"cxx . . $ `<file>/external/opusfile/opus/celt/mathops.h`/ |
| 34 | #include "cwrs.h"cxx . . $ `<file>/external/opusfile/opus/celt/cwrs.h`/ |
| 35 | #include "vq.h"cxx . . $ `<file>/external/opusfile/opus/celt/vq.h`/ |
| 36 | #include "arch.h"cxx . . $ `<file>/external/opusfile/opus/celt/arch.h`/ |
| 37 | #include "os_support.h"cxx . . $ `<file>/external/opusfile/opus/celt/os_support.h`/ |
| 38 | #include "bands.h"cxx . . $ `<file>/external/opusfile/opus/celt/bands.h`/ |
| 39 | #include "rate.h"cxx . . $ `<file>/external/opusfile/opus/celt/rate.h`/ |
| 40 | #include "pitch_.h"cxx . . $ `<file>/external/opusfile/opus/celt/pitch_.h`/ |
| 41 | |
| 42 | #if defined(MIPSr1_ASM) |
| 43 | #include "mips/vq_mipsr1.h" |
| 44 | #endif |
| 45 | |
| 46 | #ifndef OVERRIDE_vq_exp_rotation1 |
| 47 | static void exp_rotation1cxx . . $ exp_rotation1(f75bf12e7728a7b1).(celt_normcxx . . $ celt_norm# *X, int len, int stride, opus_val16cxx . . $ opus_val16# c, opus_val16cxx . . $ opus_val16# s) |
| 48 | { |
| 49 | int i; |
| 50 | opus_val16cxx . . $ opus_val16# ms; |
| 51 | celt_normcxx . . $ celt_norm# *Xptr; |
| 52 | Xptr = X; |
| 53 | ms = NEG16cxx . . $ `external/opusfile/opus/celt/arch.h:219:9`!(s); |
| 54 | for (i=0;i<len-stride;i++) |
| 55 | { |
| 56 | celt_normcxx . . $ celt_norm# x1, x2; |
| 57 | x1 = Xptr[0]; |
| 58 | x2 = Xptr[stride]; |
| 59 | Xptr[stride] = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(c, x2), s, x1), 15)); |
| 60 | *Xptr++ = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(c, x1), ms, x2), 15)); |
| 61 | } |
| 62 | Xptr = &X[len-2*stride-1]; |
| 63 | for (i=len-2*stride-1;i>=0;i--) |
| 64 | { |
| 65 | celt_normcxx . . $ celt_norm# x1, x2; |
| 66 | x1 = Xptr[0]; |
| 67 | x2 = Xptr[stride]; |
| 68 | Xptr[stride] = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(c, x2), s, x1), 15)); |
| 69 | *Xptr-- = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(c, x1), ms, x2), 15)); |
| 70 | } |
| 71 | } |
| 72 | #endif /* OVERRIDE_vq_exp_rotation1 */ |
| 73 | |
| 74 | void exp_rotationcxx . . $ exp_rotation(a3bfd2881e196488).(celt_normcxx . . $ celt_norm# *X, int len, int dir, int stride, int K, int spread) |
| 75 | { |
| 76 | static const int SPREAD_FACTOR[3]={15,10,5}; |
| 77 | int i; |
| 78 | opus_val16cxx . . $ opus_val16# c, s; |
| 79 | opus_val16cxx . . $ opus_val16# gain, theta; |
| 80 | int stride2=0; |
| 81 | int factor; |
| 82 | |
| 83 | if (2*K>=len || spread==SPREAD_NONEcxx . . $ `external/opusfile/opus/celt/bands.h:68:9`!) |
| 84 | return; |
| 85 | factor = SPREAD_FACTOR[spread-1]; |
| 86 | |
| 87 | gain = celt_divcxx . . $ `external/opusfile/opus/celt/mathops.h:121:9`!((opus_val32)MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(Q15_ONEcxx . . $ `external/opusfile/opus/celt/arch.h:210:9`!,len),(opus_val32)(len+factor*K)); |
| 88 | theta = HALF16cxx . . $ `external/opusfile/opus/celt/arch.h:239:9`!(MULT16_16_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:264:9`!(gain,gain)); |
| 89 | |
| 90 | c = celt_cos_normcxx . . $ `external/opusfile/opus/celt/mathops.h:119:9`!(EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(theta)); |
| 91 | s = celt_cos_normcxx . . $ `external/opusfile/opus/celt/mathops.h:119:9`!(EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(SUB16cxx . . $ `external/opusfile/opus/celt/arch.h:243:9`!(Q15ONEcxx . . $ `external/opusfile/opus/celt/arch.h:203:9`!,theta))); /* sin(theta) */ |
| 92 | |
| 93 | if (len>=8*stride) |
| 94 | { |
| 95 | stride2 = 1; |
| 96 | /* This is just a simple (equivalent) way of computing sqrt(len/stride) with rounding. |
| 97 | It's basically incrementing long as (stride2+0.5)^2 < len/stride. */ |
| 98 | while ((stride2*stride2+stride2)*stride + (stride>>2) < len) |
| 99 | stride2++; |
| 100 | } |
| 101 | /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for |
| 102 | extract_collapse_mask().*/ |
| 103 | len = celt_udivcxx . . $ celt_udiv(83f10ac8959d5577).(len, stride); |
| 104 | for (i=0;i<stride;i++) |
| 105 | { |
| 106 | if (dir < 0) |
| 107 | { |
| 108 | if (stride2) |
| 109 | exp_rotation1cxx . . $ exp_rotation1(f75bf12e7728a7b1).(X+i*len, len, stride2, s, c); |
| 110 | exp_rotation1cxx . . $ exp_rotation1(f75bf12e7728a7b1).(X+i*len, len, 1, c, s); |
| 111 | } else { |
| 112 | exp_rotation1cxx . . $ exp_rotation1(f75bf12e7728a7b1).(X+i*len, len, 1, c, -s); |
| 113 | if (stride2) |
| 114 | exp_rotation1cxx . . $ exp_rotation1(f75bf12e7728a7b1).(X+i*len, len, stride2, s, -c); |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** Takes the pitch vector and the decoded residual vector, computes the gain |
| 120 | that will give ||p+g*y||=1 and mixes the residual with the pitch. */ |
| 121 | static void normalise_residualcxx . . $ normalise_residual(1ad9038b8afe56aa).(int * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! iy, celt_normcxx . . $ celt_norm# * OPUS_RESTRICTcxx . . $ `external/opusfile/opus/opus_defines.h:98:10`! X, |
| 122 | int N, opus_val32cxx . . $ opus_val32# Ryy, opus_val16cxx . . $ opus_val16# gain) |
| 123 | { |
| 124 | int i; |
| 125 | #ifdef FIXED_POINT |
| 126 | int k; |
| 127 | #endif |
| 128 | opus_val32cxx . . $ opus_val32# t; |
| 129 | opus_val16cxx . . $ opus_val16# g; |
| 130 | |
| 131 | #ifdef FIXED_POINT |
| 132 | k = celt_ilog2(Ryy)>>1; |
| 133 | #endif |
| 134 | t = VSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:229:9`!(Ryy, 2*(k-7)); |
| 135 | g = MULT16_16_P15cxx . . $ `external/opusfile/opus/celt/arch.h:265:9`!(celt_rsqrt_normcxx . . $ `external/opusfile/opus/celt/mathops.h:118:9`!(t),gain); |
| 136 | |
| 137 | i=0; |
| 138 | do |
| 139 | X[i] = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(g, iy[i]), k+1)); |
| 140 | while (++i < N); |
| 141 | } |
| 142 | |
| 143 | static unsigned extract_collapse_maskcxx . . $ extract_collapse_mask(c90a6f5de13a44dd).(int *iy, int N, int B) |
| 144 | { |
| 145 | unsigned collapse_mask; |
| 146 | int N0; |
| 147 | int i; |
| 148 | if (B<=1) |
| 149 | return 1; |
| 150 | /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for |
| 151 | exp_rotation().*/ |
| 152 | N0 = celt_udivcxx . . $ celt_udiv(83f10ac8959d5577).(N, B); |
| 153 | collapse_mask = 0; |
| 154 | i=0; do { |
| 155 | int j; |
| 156 | unsigned tmp=0; |
| 157 | j=0; do { |
| 158 | tmp |= iy[i*N0+j]; |
| 159 | } while (++j<N0); |
| 160 | collapse_mask |= (tmp!=0)<<i; |
| 161 | } while (++i<B); |
| 162 | return collapse_mask; |
| 163 | } |
| 164 | |
| 165 | opus_val16cxx . . $ opus_val16# op_pvq_search_ccxx . . $ op_pvq_search_c(b1fb9815d9997d87).(celt_normcxx . . $ celt_norm# *X, int *iy, int K, int N, int arch) |
| 166 | { |
| 167 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!(celt_norm, y); |
| 168 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!(int, signx); |
| 169 | int i, j; |
| 170 | int pulsesLeft; |
| 171 | opus_val32cxx . . $ opus_val32# sum; |
| 172 | opus_val32cxx . . $ opus_val32# xy; |
| 173 | opus_val16cxx . . $ opus_val16# yy; |
| 174 | SAVE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:96:9`!; |
| 175 | |
| 176 | (void)arch; |
| 177 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!(y, N, celt_norm); |
| 178 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!(signx, N, int); |
| 179 | |
| 180 | /* Get rid of the sign */ |
| 181 | sum = 0; |
| 182 | j=0; do { |
| 183 | signx[j] = X[j]<0; |
| 184 | /* OPT: Make sure the compiler doesn't use a branch on ABS16(). */ |
| 185 | X[j] = ABS16cxx . . $ `external/opusfile/opus/celt/arch.h:213:9`!(X[j]); |
| 186 | iy[j] = 0; |
| 187 | y[j] = 0; |
| 188 | } while (++j<N); |
| 189 | |
| 190 | xy = yy = 0; |
| 191 | |
| 192 | pulsesLeft = K; |
| 193 | |
| 194 | /* Do a pre-search by projecting on the pyramid */ |
| 195 | if (K > (N>>1)) |
| 196 | { |
| 197 | opus_val16cxx . . $ opus_val16# rcp; |
| 198 | j=0; do { |
| 199 | sum += X[j]; |
| 200 | } while (++j<N); |
| 201 | |
| 202 | /* If X is too small, just replace it with a pulse at 0 */ |
| 203 | #ifdef FIXED_POINT |
| 204 | if (sum <= K) |
| 205 | #else |
| 206 | /* Prevents infinities and NaNs from causing too many pulses |
| 207 | to be allocated. 64 is an approximation of infinity here. */ |
| 208 | if (!(sum > EPSILONcxx . . $ `external/opusfile/opus/celt/arch.h:207:9`! && sum < 64)) |
| 209 | #endif |
| 210 | { |
| 211 | X[0] = QCONST16cxx . . $ `external/opusfile/opus/celt/arch.h:216:9`!(1.f,14); |
| 212 | j=1; do |
| 213 | X[j]=0; |
| 214 | while (++j<N); |
| 215 | sum = QCONST16cxx . . $ `external/opusfile/opus/celt/arch.h:216:9`!(1.f,14); |
| 216 | } |
| 217 | #ifdef FIXED_POINT |
| 218 | rcp = EXTRACT16(MULT16_32_Q16(K, celt_rcp(sum))); |
| 219 | #else |
| 220 | /* Using K+e with e < 1 guarantees we cannot get more than K pulses. */ |
| 221 | rcp = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(MULT16_32_Q16cxx . . $ `external/opusfile/opus/celt/arch.h:253:9`!(K+0.8f, celt_rcpcxx . . $ `external/opusfile/opus/celt/mathops.h:120:9`!(sum))); |
| 222 | #endif |
| 223 | j=0; do { |
| 224 | #ifdef FIXED_POINT |
| 225 | /* It's really important to round *towards zero* here */ |
| 226 | iy[j] = MULT16_16_Q15(X[j],rcp); |
| 227 | #else |
| 228 | iy[j] = (int)floorcxx . . $ floor(447c67c6676f75c3).(rcp*X[j]); |
| 229 | #endif |
| 230 | y[j] = (celt_normcxx . . $ celt_norm#)iy[j]; |
| 231 | yy = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(yy, y[j],y[j]); |
| 232 | xy = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(xy, X[j],y[j]); |
| 233 | y[j] *= 2; |
| 234 | pulsesLeft -= iy[j]; |
| 235 | } while (++j<N); |
| 236 | } |
| 237 | celt_sig_assertcxx . . $ `external/opusfile/opus/celt/arch.h:92:9`!(pulsesLeft>=0); |
| 238 | |
| 239 | /* This should never happen, but just in case it does (e.g. on silence) |
| 240 | we fill the first bin with pulses. */ |
| 241 | #ifdef FIXED_POINT_DEBUG |
| 242 | celt_sig_assert(pulsesLeft<=N+3); |
| 243 | #endif |
| 244 | if (pulsesLeft > N+3) |
| 245 | { |
| 246 | opus_val16cxx . . $ opus_val16# tmp = (opus_val16cxx . . $ opus_val16#)pulsesLeft; |
| 247 | yy = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(yy, tmp, tmp); |
| 248 | yy = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(yy, tmp, y[0]); |
| 249 | iy[0] += pulsesLeft; |
| 250 | pulsesLeft=0; |
| 251 | } |
| 252 | |
| 253 | for (i=0;i<pulsesLeft;i++) |
| 254 | { |
| 255 | opus_val16cxx . . $ opus_val16# Rxy, Ryy; |
| 256 | int best_id; |
| 257 | opus_val32cxx . . $ opus_val32# best_num; |
| 258 | opus_val16cxx . . $ opus_val16# best_den; |
| 259 | #ifdef FIXED_POINT |
| 260 | int rshift; |
| 261 | #endif |
| 262 | #ifdef FIXED_POINT |
| 263 | rshift = 1+celt_ilog2(K-pulsesLeft+i+1); |
| 264 | #endif |
| 265 | best_id = 0; |
| 266 | /* The squared magnitude term gets added anyway, so we might as well |
| 267 | add it outside the loop */ |
| 268 | yy = ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(yy, 1); |
| 269 | |
| 270 | /* Calculations for position 0 are out of the loop, in part to reduce |
| 271 | mispredicted branches (since the if condition is usually false) |
| 272 | in the loop. */ |
| 273 | /* Temporary sums of the new pulse(s) */ |
| 274 | Rxy = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(SHR32cxx . . $ `external/opusfile/opus/celt/arch.h:226:9`!(ADD32cxx . . $ `external/opusfile/opus/celt/arch.h:244:9`!(xy, EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(X[0])),rshift)); |
| 275 | /* We're multiplying y[j] by two so we don't have to do it here */ |
| 276 | Ryy = ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(yy, y[0]); |
| 277 | |
| 278 | /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that |
| 279 | Rxy is positive because the sign is pre-computed) */ |
| 280 | Rxy = MULT16_16_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:264:9`!(Rxy,Rxy); |
| 281 | best_den = Ryy; |
| 282 | best_num = Rxy; |
| 283 | j=1; |
| 284 | do { |
| 285 | /* Temporary sums of the new pulse(s) */ |
| 286 | Rxy = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(SHR32cxx . . $ `external/opusfile/opus/celt/arch.h:226:9`!(ADD32cxx . . $ `external/opusfile/opus/celt/arch.h:244:9`!(xy, EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(X[j])),rshift)); |
| 287 | /* We're multiplying y[j] by two so we don't have to do it here */ |
| 288 | Ryy = ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(yy, y[j]); |
| 289 | |
| 290 | /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that |
| 291 | Rxy is positive because the sign is pre-computed) */ |
| 292 | Rxy = MULT16_16_Q15cxx . . $ `external/opusfile/opus/celt/arch.h:264:9`!(Rxy,Rxy); |
| 293 | /* The idea is to check for num/den >= best_num/best_den, but that way |
| 294 | we can do it without any division */ |
| 295 | /* OPT: It's not clear whether a cmov is faster than a branch here |
| 296 | since the condition is more often false than true and using |
| 297 | a cmov introduces data dependencies across iterations. The optimal |
| 298 | choice may be architecture-dependent. */ |
| 299 | if (opus_unlikelycxx . . $ `external/opusfile/opus/celt/arch.h:51:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(best_den, Rxy) > MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(Ryy, best_num))) |
| 300 | { |
| 301 | best_den = Ryy; |
| 302 | best_num = Rxy; |
| 303 | best_id = j; |
| 304 | } |
| 305 | } while (++j<N); |
| 306 | |
| 307 | /* Updating the sums of the new pulse(s) */ |
| 308 | xy = ADD32cxx . . $ `external/opusfile/opus/celt/arch.h:244:9`!(xy, EXTEND32cxx . . $ `external/opusfile/opus/celt/arch.h:223:9`!(X[best_id])); |
| 309 | /* We're multiplying y[j] by two so we don't have to do it here */ |
| 310 | yy = ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(yy, y[best_id]); |
| 311 | |
| 312 | /* Only now that we've made the final choice, update y/iy */ |
| 313 | /* Multiplying y[j] by 2 so we don't have to do it everywhere else */ |
| 314 | y[best_id] += 2; |
| 315 | iy[best_id]++; |
| 316 | } |
| 317 | |
| 318 | /* Put the original sign back */ |
| 319 | j=0; |
| 320 | do { |
| 321 | /*iy[j] = signx[j] ? -iy[j] : iy[j];*/ |
| 322 | /* OPT: The is more likely to be compiled without a branch than the code above |
| 323 | but has the same performance otherwise. */ |
| 324 | iy[j] = (iy[j]^-signx[j]) + signx[j]; |
| 325 | } while (++j<N); |
| 326 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 327 | return yy; |
| 328 | } |
| 329 | |
| 330 | unsigned alg_quantcxx . . $ alg_quant(ad26fae2e831c95d).(celt_normcxx . . $ celt_norm# *X, int N, int K, int spread, int B, ec_enccxx . . $ ec_enc# *enc, |
| 331 | opus_val16cxx . . $ opus_val16# gain, int resynth, int arch) |
| 332 | { |
| 333 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!(int, iy); |
| 334 | opus_val16cxx . . $ opus_val16# yy; |
| 335 | unsigned collapse_mask; |
| 336 | SAVE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:96:9`!; |
| 337 | |
| 338 | celt_assert2cxx . . $ `external/opusfile/opus/celt/arch.h:81:9`!(K>0, "alg_quant() needs at least one pulse"); |
| 339 | celt_assert2cxx . . $ `external/opusfile/opus/celt/arch.h:81:9`!(N>1, "alg_quant() needs at least two dimensions"); |
| 340 | |
| 341 | /* Covers vectorization by up to 4. */ |
| 342 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!(iy, N+3, int); |
| 343 | |
| 344 | exp_rotationcxx . . $ exp_rotation(a3bfd2881e196488).(X, N, 1, B, K, spread); |
| 345 | |
| 346 | yy = op_pvq_searchcxx . . $ `external/opusfile/opus/celt/vq.h:49:9`!(X, iy, K, N, arch); |
| 347 | |
| 348 | encode_pulsescxx . . $ encode_pulses(fbc6def8d19aa698).(iy, N, K, enc); |
| 349 | |
| 350 | if (resynth) |
| 351 | { |
| 352 | normalise_residualcxx . . $ normalise_residual(1ad9038b8afe56aa).(iy, X, N, yy, gain); |
| 353 | exp_rotationcxx . . $ exp_rotation(a3bfd2881e196488).(X, N, -1, B, K, spread); |
| 354 | } |
| 355 | |
| 356 | collapse_mask = extract_collapse_maskcxx . . $ extract_collapse_mask(c90a6f5de13a44dd).(iy, N, B); |
| 357 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 358 | return collapse_mask; |
| 359 | } |
| 360 | |
| 361 | /** Decode pulse vector and combine the result with the pitch vector to produce |
| 362 | the final normalised signal in the current band. */ |
| 363 | unsigned alg_unquantcxx . . $ alg_unquant(caee9bcece0d5836).(celt_normcxx . . $ celt_norm# *X, int N, int K, int spread, int B, |
| 364 | ec_deccxx . . $ ec_dec# *dec, opus_val16cxx . . $ opus_val16# gain) |
| 365 | { |
| 366 | opus_val32cxx . . $ opus_val32# Ryy; |
| 367 | unsigned collapse_mask; |
| 368 | VARDECLcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:94:9`!(int, iy); |
| 369 | SAVE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:96:9`!; |
| 370 | |
| 371 | celt_assert2cxx . . $ `external/opusfile/opus/celt/arch.h:81:9`!(K>0, "alg_unquant() needs at least one pulse"); |
| 372 | celt_assert2cxx . . $ `external/opusfile/opus/celt/arch.h:81:9`!(N>1, "alg_unquant() needs at least two dimensions"); |
| 373 | ALLOCcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:95:9`!(iy, N, int); |
| 374 | Ryy = decode_pulsescxx . . $ decode_pulses(c13bf38a729c7866).(iy, N, K, dec); |
| 375 | normalise_residualcxx . . $ normalise_residual(1ad9038b8afe56aa).(iy, X, N, Ryy, gain); |
| 376 | exp_rotationcxx . . $ exp_rotation(a3bfd2881e196488).(X, N, -1, B, K, spread); |
| 377 | collapse_mask = extract_collapse_maskcxx . . $ extract_collapse_mask(c90a6f5de13a44dd).(iy, N, B); |
| 378 | RESTORE_STACKcxx . . $ `external/opusfile/opus/celt/stack_alloc.h:97:9`!; |
| 379 | return collapse_mask; |
| 380 | } |
| 381 | |
| 382 | #ifndef OVERRIDE_renormalise_vector |
| 383 | void renormalise_vectorcxx . . $ renormalise_vector(dd5ad41dfc502241).(celt_normcxx . . $ celt_norm# *X, int N, opus_val16cxx . . $ opus_val16# gain, int arch) |
| 384 | { |
| 385 | int i; |
| 386 | #ifdef FIXED_POINT |
| 387 | int k; |
| 388 | #endif |
| 389 | opus_val32cxx . . $ opus_val32# E; |
| 390 | opus_val16cxx . . $ opus_val16# g; |
| 391 | opus_val32cxx . . $ opus_val32# t; |
| 392 | celt_normcxx . . $ celt_norm# *xptr; |
| 393 | E = EPSILONcxx . . $ `external/opusfile/opus/celt/arch.h:207:9`! + celt_inner_prodcxx . . $ `external/opusfile/opus/celt/pitch_.h:170:10`!(X, X, N, arch); |
| 394 | #ifdef FIXED_POINT |
| 395 | k = celt_ilog2(E)>>1; |
| 396 | #endif |
| 397 | t = VSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:229:9`!(E, 2*(k-7)); |
| 398 | g = MULT16_16_P15cxx . . $ `external/opusfile/opus/celt/arch.h:265:9`!(celt_rsqrt_normcxx . . $ `external/opusfile/opus/celt/mathops.h:118:9`!(t),gain); |
| 399 | |
| 400 | xptr = X; |
| 401 | for (i=0;i<N;i++) |
| 402 | { |
| 403 | *xptr = EXTRACT16cxx . . $ `external/opusfile/opus/celt/arch.h:222:9`!(PSHR32cxx . . $ `external/opusfile/opus/celt/arch.h:228:9`!(MULT16_16cxx . . $ `external/opusfile/opus/celt/arch.h:249:9`!(g, *xptr), k+1)); |
| 404 | xptr++; |
| 405 | } |
| 406 | /*return celt_sqrt(E);*/ |
| 407 | } |
| 408 | #endif /* OVERRIDE_renormalise_vector */ |
| 409 | |
| 410 | int stereo_ithetacxx . . $ stereo_itheta(f371d3bd2af06f3b).(const celt_normcxx . . $ celt_norm# *X, const celt_normcxx . . $ celt_norm# *Y, int stereo, int N, int arch) |
| 411 | { |
| 412 | int i; |
| 413 | int itheta; |
| 414 | opus_val16cxx . . $ opus_val16# mid, side; |
| 415 | opus_val32cxx . . $ opus_val32# Emid, Eside; |
| 416 | |
| 417 | Emid = Eside = EPSILONcxx . . $ `external/opusfile/opus/celt/arch.h:207:9`!; |
| 418 | if (stereo) |
| 419 | { |
| 420 | for (i=0;i<N;i++) |
| 421 | { |
| 422 | celt_normcxx . . $ celt_norm# m, s; |
| 423 | m = ADD16cxx . . $ `external/opusfile/opus/celt/arch.h:242:9`!(SHR16cxx . . $ `external/opusfile/opus/celt/arch.h:224:9`!(X[i],1),SHR16cxx . . $ `external/opusfile/opus/celt/arch.h:224:9`!(Y[i],1)); |
| 424 | s = SUB16cxx . . $ `external/opusfile/opus/celt/arch.h:243:9`!(SHR16cxx . . $ `external/opusfile/opus/celt/arch.h:224:9`!(X[i],1),SHR16cxx . . $ `external/opusfile/opus/celt/arch.h:224:9`!(Y[i],1)); |
| 425 | Emid = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(Emid, m, m); |
| 426 | Eside = MAC16_16cxx . . $ `external/opusfile/opus/celt/arch.h:250:9`!(Eside, s, s); |
| 427 | } |
| 428 | } else { |
| 429 | Emid += celt_inner_prodcxx . . $ `external/opusfile/opus/celt/pitch_.h:170:10`!(X, X, N, arch); |
| 430 | Eside += celt_inner_prodcxx . . $ `external/opusfile/opus/celt/pitch_.h:170:10`!(Y, Y, N, arch); |
| 431 | } |
| 432 | mid = celt_sqrtcxx . . $ `external/opusfile/opus/celt/mathops.h:116:9`!(Emid); |
| 433 | side = celt_sqrtcxx . . $ `external/opusfile/opus/celt/mathops.h:116:9`!(Eside); |
| 434 | #ifdef FIXED_POINT |
| 435 | /* 0.63662 = 2/pi */ |
| 436 | itheta = MULT16_16_Q15(QCONST16(0.63662f,15),celt_atan2p(side, mid)); |
| 437 | #else |
| 438 | itheta = (int)floorcxx . . $ floor(447c67c6676f75c3).(.5f+16384*0.63662f*fast_atan2fcxx . . $ fast_atan2f(d59a45cd3bfd2eda).(side,mid)); |
| 439 | #endif |
| 440 | |
| 441 | return itheta; |
| 442 | } |