Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: third_party/opus/src/celt/celt_decoder.c

Issue 2962373002: [Opus] Update to v1.2.1 (Closed)
Patch Set: Pre-increment instead of post-increment Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/opus/src/celt/celt.c ('k') | third_party/opus/src/celt/celt_encoder.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2007-2008 CSIRO 1 /* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2010 Xiph.Org Foundation 2 Copyright (c) 2007-2010 Xiph.Org Foundation
3 Copyright (c) 2008 Gregory Maxwell 3 Copyright (c) 2008 Gregory Maxwell
4 Written by Jean-Marc Valin and Gregory Maxwell */ 4 Written by Jean-Marc Valin and Gregory Maxwell */
5 /* 5 /*
6 Redistribution and use in source and binary forms, with or without 6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions 7 modification, are permitted provided that the following conditions
8 are met: 8 are met:
9 9
10 - Redistributions of source code must retain the above copyright 10 - Redistributions of source code must retain the above copyright
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 */ 66 */
67 struct OpusCustomDecoder { 67 struct OpusCustomDecoder {
68 const OpusCustomMode *mode; 68 const OpusCustomMode *mode;
69 int overlap; 69 int overlap;
70 int channels; 70 int channels;
71 int stream_channels; 71 int stream_channels;
72 72
73 int downsample; 73 int downsample;
74 int start, end; 74 int start, end;
75 int signalling; 75 int signalling;
76 int disable_inv;
76 int arch; 77 int arch;
77 78
78 /* Everything beyond this point gets cleared on a reset */ 79 /* Everything beyond this point gets cleared on a reset */
79 #define DECODER_RESET_START rng 80 #define DECODER_RESET_START rng
80 81
81 opus_uint32 rng; 82 opus_uint32 rng;
82 int error; 83 int error;
83 int last_pitch_index; 84 int last_pitch_index;
84 int loss_count; 85 int loss_count;
85 int skip_plc; 86 int skip_plc;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 OPUS_CLEAR((char*)st, opus_custom_decoder_get_size(mode, channels)); 157 OPUS_CLEAR((char*)st, opus_custom_decoder_get_size(mode, channels));
157 158
158 st->mode = mode; 159 st->mode = mode;
159 st->overlap = mode->overlap; 160 st->overlap = mode->overlap;
160 st->stream_channels = st->channels = channels; 161 st->stream_channels = st->channels = channels;
161 162
162 st->downsample = 1; 163 st->downsample = 1;
163 st->start = 0; 164 st->start = 0;
164 st->end = st->mode->effEBands; 165 st->end = st->mode->effEBands;
165 st->signalling = 1; 166 st->signalling = 1;
167 #ifdef ENABLE_UPDATE_DRAFT
168 st->disable_inv = channels == 1;
169 #else
170 st->disable_inv = 0;
171 #endif
166 st->arch = opus_select_arch(); 172 st->arch = opus_select_arch();
167 173
168 opus_custom_decoder_ctl(st, OPUS_RESET_STATE); 174 opus_custom_decoder_ctl(st, OPUS_RESET_STATE);
169 175
170 return OPUS_OK; 176 return OPUS_OK;
171 } 177 }
172 178
173 #ifdef CUSTOM_MODES 179 #ifdef CUSTOM_MODES
174 void opus_custom_decoder_destroy(CELTDecoder *st) 180 void opus_custom_decoder_destroy(CELTDecoder *st)
175 { 181 {
176 opus_free(st); 182 opus_free(st);
177 } 183 }
178 #endif /* CUSTOM_MODES */ 184 #endif /* CUSTOM_MODES */
179 185
186 #ifndef CUSTOM_MODES
187 /* Special case for stereo with no downsampling and no accumulation. This is
188 quite common and we can make it faster by processing both channels in the
189 same loop, reducing overhead due to the dependency loop in the IIR filter. */
190 static void deemphasis_stereo_simple(celt_sig *in[], opus_val16 *pcm, int N, con st opus_val16 coef0,
191 celt_sig *mem)
192 {
193 celt_sig * OPUS_RESTRICT x0;
194 celt_sig * OPUS_RESTRICT x1;
195 celt_sig m0, m1;
196 int j;
197 x0=in[0];
198 x1=in[1];
199 m0 = mem[0];
200 m1 = mem[1];
201 for (j=0;j<N;j++)
202 {
203 celt_sig tmp0, tmp1;
204 /* Add VERY_SMALL to x[] first to reduce dependency chain. */
205 tmp0 = x0[j] + VERY_SMALL + m0;
206 tmp1 = x1[j] + VERY_SMALL + m1;
207 m0 = MULT16_32_Q15(coef0, tmp0);
208 m1 = MULT16_32_Q15(coef0, tmp1);
209 pcm[2*j ] = SCALEOUT(SIG2WORD16(tmp0));
210 pcm[2*j+1] = SCALEOUT(SIG2WORD16(tmp1));
211 }
212 mem[0] = m0;
213 mem[1] = m1;
214 }
215 #endif
180 216
181 #ifndef RESYNTH 217 #ifndef RESYNTH
182 static 218 static
183 #endif 219 #endif
184 void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c onst opus_val16 *coef, 220 void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int C, int downsample, c onst opus_val16 *coef,
185 celt_sig *mem, int accum) 221 celt_sig *mem, int accum)
186 { 222 {
187 int c; 223 int c;
188 int Nd; 224 int Nd;
189 int apply_downsampling=0; 225 int apply_downsampling=0;
190 opus_val16 coef0; 226 opus_val16 coef0;
191 VARDECL(celt_sig, scratch); 227 VARDECL(celt_sig, scratch);
192 SAVE_STACK; 228 SAVE_STACK;
229 #ifndef CUSTOM_MODES
230 /* Short version for common case. */
231 if (downsample == 1 && C == 2 && !accum)
232 {
233 deemphasis_stereo_simple(in, pcm, N, coef[0], mem);
234 return;
235 }
236 #endif
193 #ifndef FIXED_POINT 237 #ifndef FIXED_POINT
194 (void)accum; 238 (void)accum;
195 celt_assert(accum==0); 239 celt_assert(accum==0);
196 #endif 240 #endif
197 ALLOC(scratch, N, celt_sig); 241 ALLOC(scratch, N, celt_sig);
198 coef0 = coef[0]; 242 coef0 = coef[0];
199 Nd = N/downsample; 243 Nd = N/downsample;
200 c=0; do { 244 c=0; do {
201 int j; 245 int j;
202 celt_sig * OPUS_RESTRICT x; 246 celt_sig * OPUS_RESTRICT x;
(...skipping 15 matching lines...) Expand all
218 scratch[j] = tmp; 262 scratch[j] = tmp;
219 } 263 }
220 apply_downsampling=1; 264 apply_downsampling=1;
221 } else 265 } else
222 #endif 266 #endif
223 if (downsample>1) 267 if (downsample>1)
224 { 268 {
225 /* Shortcut for the standard (non-custom modes) case */ 269 /* Shortcut for the standard (non-custom modes) case */
226 for (j=0;j<N;j++) 270 for (j=0;j<N;j++)
227 { 271 {
228 celt_sig tmp = x[j] + m + VERY_SMALL; 272 celt_sig tmp = x[j] + VERY_SMALL + m;
229 m = MULT16_32_Q15(coef0, tmp); 273 m = MULT16_32_Q15(coef0, tmp);
230 scratch[j] = tmp; 274 scratch[j] = tmp;
231 } 275 }
232 apply_downsampling=1; 276 apply_downsampling=1;
233 } else { 277 } else {
234 /* Shortcut for the standard (non-custom modes) case */ 278 /* Shortcut for the standard (non-custom modes) case */
235 #ifdef FIXED_POINT 279 #ifdef FIXED_POINT
236 if (accum) 280 if (accum)
237 { 281 {
238 for (j=0;j<N;j++) 282 for (j=0;j<N;j++)
239 { 283 {
240 celt_sig tmp = x[j] + m + VERY_SMALL; 284 celt_sig tmp = x[j] + m + VERY_SMALL;
241 m = MULT16_32_Q15(coef0, tmp); 285 m = MULT16_32_Q15(coef0, tmp);
242 y[j*C] = SAT16(ADD32(y[j*C], SCALEOUT(SIG2WORD16(tmp)))); 286 y[j*C] = SAT16(ADD32(y[j*C], SCALEOUT(SIG2WORD16(tmp))));
243 } 287 }
244 } else 288 } else
245 #endif 289 #endif
246 { 290 {
247 for (j=0;j<N;j++) 291 for (j=0;j<N;j++)
248 { 292 {
249 celt_sig tmp = x[j] + m + VERY_SMALL; 293 celt_sig tmp = x[j] + VERY_SMALL + m;
250 m = MULT16_32_Q15(coef0, tmp); 294 m = MULT16_32_Q15(coef0, tmp);
251 y[j*C] = SCALEOUT(SIG2WORD16(tmp)); 295 y[j*C] = SCALEOUT(SIG2WORD16(tmp));
252 } 296 }
253 } 297 }
254 } 298 }
255 mem[c] = m; 299 mem[c] = m;
256 300
257 if (apply_downsampling) 301 if (apply_downsampling)
258 { 302 {
259 /* Perform down-sampling */ 303 /* Perform down-sampling */
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 { 370 {
327 /* Downmixing a stereo stream to mono */ 371 /* Downmixing a stereo stream to mono */
328 celt_sig *freq2; 372 celt_sig *freq2;
329 freq2 = out_syn[0]+overlap/2; 373 freq2 = out_syn[0]+overlap/2;
330 denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, 374 denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M,
331 downsample, silence); 375 downsample, silence);
332 /* Use the output buffer as temp array before downmixing. */ 376 /* Use the output buffer as temp array before downmixing. */
333 denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M, 377 denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M,
334 downsample, silence); 378 downsample, silence);
335 for (i=0;i<N;i++) 379 for (i=0;i<N;i++)
336 freq[i] = HALF32(ADD32(freq[i],freq2[i])); 380 freq[i] = ADD32(HALF32(freq[i]), HALF32(freq2[i]));
337 for (b=0;b<B;b++) 381 for (b=0;b<B;b++)
338 clt_mdct_backward(&mode->mdct, &freq[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); 382 clt_mdct_backward(&mode->mdct, &freq[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch);
339 } else { 383 } else {
340 /* Normal case (mono or stereo) */ 384 /* Normal case (mono or stereo) */
341 c=0; do { 385 c=0; do {
342 denormalise_bands(mode, X+c*N, freq, oldBandE+c*nbEBands, start, effEnd , M, 386 denormalise_bands(mode, X+c*N, freq, oldBandE+c*nbEBands, start, effEnd , M,
343 downsample, silence); 387 downsample, silence);
344 for (b=0;b<B;b++) 388 for (b=0;b<B;b++)
345 clt_mdct_backward(&mode->mdct, &freq[b], out_syn[c]+NB*b, mode->wind ow, overlap, shift, B, arch); 389 clt_mdct_backward(&mode->mdct, &freq[b], out_syn[c]+NB*b, mode->wind ow, overlap, shift, B, arch);
346 } while (++c<CC); 390 } while (++c<CC);
347 } 391 }
392 /* Saturate IMDCT output so that we can't overflow in the pitch postfilter
393 or in the */
394 c=0; do {
395 for (i=0;i<N;i++)
396 out_syn[c][i] = SATURATE(out_syn[c][i], SIG_SAT);
397 } while (++c<CC);
348 RESTORE_STACK; 398 RESTORE_STACK;
349 } 399 }
350 400
351 static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ec_dec *dec) 401 static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ec_dec *dec)
352 { 402 {
353 int i, curr, tf_select; 403 int i, curr, tf_select;
354 int tf_select_rsv; 404 int tf_select_rsv;
355 int tf_changed; 405 int tf_changed;
356 int logp; 406 int logp;
357 opus_uint32 budget; 407 opus_uint32 budget;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 549
500 c=0; do { 550 c=0; do {
501 OPUS_MOVE(decode_mem[c], decode_mem[c]+N, 551 OPUS_MOVE(decode_mem[c], decode_mem[c]+N,
502 DECODE_BUFFER_SIZE-N+(overlap>>1)); 552 DECODE_BUFFER_SIZE-N+(overlap>>1));
503 } while (++c<C); 553 } while (++c<C);
504 554
505 celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st- >downsample, 0, st->arch); 555 celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st- >downsample, 0, st->arch);
506 } else { 556 } else {
507 /* Pitch-based PLC */ 557 /* Pitch-based PLC */
508 const opus_val16 *window; 558 const opus_val16 *window;
559 opus_val16 *exc;
509 opus_val16 fade = Q15ONE; 560 opus_val16 fade = Q15ONE;
510 int pitch_index; 561 int pitch_index;
511 VARDECL(opus_val32, etmp); 562 VARDECL(opus_val32, etmp);
512 VARDECL(opus_val16, exc); 563 VARDECL(opus_val16, _exc);
513 564
514 if (loss_count == 0) 565 if (loss_count == 0)
515 { 566 {
516 st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch); 567 st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch);
517 } else { 568 } else {
518 pitch_index = st->last_pitch_index; 569 pitch_index = st->last_pitch_index;
519 fade = QCONST16(.8f,15); 570 fade = QCONST16(.8f,15);
520 } 571 }
521 572
522 ALLOC(etmp, overlap, opus_val32); 573 ALLOC(etmp, overlap, opus_val32);
523 ALLOC(exc, MAX_PERIOD, opus_val16); 574 ALLOC(_exc, MAX_PERIOD+LPC_ORDER, opus_val16);
575 exc = _exc+LPC_ORDER;
524 window = mode->window; 576 window = mode->window;
525 c=0; do { 577 c=0; do {
526 opus_val16 decay; 578 opus_val16 decay;
527 opus_val16 attenuation; 579 opus_val16 attenuation;
528 opus_val32 S1=0; 580 opus_val32 S1=0;
529 celt_sig *buf; 581 celt_sig *buf;
530 int extrapolation_offset; 582 int extrapolation_offset;
531 int extrapolation_len; 583 int extrapolation_len;
532 int exc_length; 584 int exc_length;
533 int j; 585 int j;
(...skipping 20 matching lines...) Expand all
554 for (i=1;i<=LPC_ORDER;i++) 606 for (i=1;i<=LPC_ORDER;i++)
555 { 607 {
556 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/ 608 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/
557 #ifdef FIXED_POINT 609 #ifdef FIXED_POINT
558 ac[i] -= MULT16_32_Q15(2*i*i, ac[i]); 610 ac[i] -= MULT16_32_Q15(2*i*i, ac[i]);
559 #else 611 #else
560 ac[i] -= ac[i]*(0.008f*0.008f)*i*i; 612 ac[i] -= ac[i]*(0.008f*0.008f)*i*i;
561 #endif 613 #endif
562 } 614 }
563 _celt_lpc(lpc+c*LPC_ORDER, ac, LPC_ORDER); 615 _celt_lpc(lpc+c*LPC_ORDER, ac, LPC_ORDER);
616 #ifdef FIXED_POINT
617 /* For fixed-point, apply bandwidth expansion until we can guarantee th at
618 no overflow can happen in the IIR filter. This means:
619 32768*sum(abs(filter)) < 2^31 */
620 while (1) {
621 opus_val16 tmp=Q15ONE;
622 opus_val32 sum=QCONST16(1., SIG_SHIFT);
623 for (i=0;i<LPC_ORDER;i++)
624 sum += ABS16(lpc[c*LPC_ORDER+i]);
625 if (sum < 65535) break;
626 for (i=0;i<LPC_ORDER;i++)
627 {
628 tmp = MULT16_16_Q15(QCONST16(.99f,15), tmp);
629 lpc[c*LPC_ORDER+i] = MULT16_16_Q15(lpc[c*LPC_ORDER+i], tmp);
630 }
631 }
632 #endif
564 } 633 }
565 /* We want the excitation for 2 pitch periods in order to look for a 634 /* We want the excitation for 2 pitch periods in order to look for a
566 decaying signal, but we can't get more than MAX_PERIOD. */ 635 decaying signal, but we can't get more than MAX_PERIOD. */
567 exc_length = IMIN(2*pitch_index, MAX_PERIOD); 636 exc_length = IMIN(2*pitch_index, MAX_PERIOD);
568 /* Initialize the LPC history with the samples just before the start 637 /* Initialize the LPC history with the samples just before the start
569 of the region for which we're computing the excitation. */ 638 of the region for which we're computing the excitation. */
570 { 639 {
571 opus_val16 lpc_mem[LPC_ORDER];
572 for (i=0;i<LPC_ORDER;i++) 640 for (i=0;i<LPC_ORDER;i++)
573 { 641 {
574 lpc_mem[i] = 642 exc[MAX_PERIOD-exc_length-LPC_ORDER+i] =
575 ROUND16(buf[DECODE_BUFFER_SIZE-exc_length-1-i], SIG_SHIFT); 643 ROUND16(buf[DECODE_BUFFER_SIZE-exc_length-LPC_ORDER+i], SIG _SHIFT);
576 } 644 }
577 /* Compute the excitation for exc_length samples before the loss. */ 645 /* Compute the excitation for exc_length samples before the loss. */
578 celt_fir(exc+MAX_PERIOD-exc_length, lpc+c*LPC_ORDER, 646 celt_fir(exc+MAX_PERIOD-exc_length, lpc+c*LPC_ORDER,
579 exc+MAX_PERIOD-exc_length, exc_length, LPC_ORDER, lpc_mem, st- >arch); 647 exc+MAX_PERIOD-exc_length, exc_length, LPC_ORDER, st->arch);
580 } 648 }
581 649
582 /* Check if the waveform is decaying, and if so how fast. 650 /* Check if the waveform is decaying, and if so how fast.
583 We do this to avoid adding energy when concealing in a segment 651 We do this to avoid adding energy when concealing in a segment
584 with decaying energy. */ 652 with decaying energy. */
585 { 653 {
586 opus_val32 E1=1, E2=1; 654 opus_val32 E1=1, E2=1;
587 int decay_length; 655 int decay_length;
588 #ifdef FIXED_POINT 656 #ifdef FIXED_POINT
589 int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[MAX_PERIOD-exc_le ngth], exc_length))-20); 657 int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[MAX_PERIOD-exc_le ngth], exc_length))-20);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 attenuation = MULT16_16_Q15(attenuation, decay); 691 attenuation = MULT16_16_Q15(attenuation, decay);
624 } 692 }
625 buf[DECODE_BUFFER_SIZE-N+i] = 693 buf[DECODE_BUFFER_SIZE-N+i] =
626 SHL32(EXTEND32(MULT16_16_Q15(attenuation, 694 SHL32(EXTEND32(MULT16_16_Q15(attenuation,
627 exc[extrapolation_offset+j])), SIG_SHIFT); 695 exc[extrapolation_offset+j])), SIG_SHIFT);
628 /* Compute the energy of the previously decoded signal whose 696 /* Compute the energy of the previously decoded signal whose
629 excitation we're copying. */ 697 excitation we're copying. */
630 tmp = ROUND16( 698 tmp = ROUND16(
631 buf[DECODE_BUFFER_SIZE-MAX_PERIOD-N+extrapolation_offset+j], 699 buf[DECODE_BUFFER_SIZE-MAX_PERIOD-N+extrapolation_offset+j],
632 SIG_SHIFT); 700 SIG_SHIFT);
633 S1 += SHR32(MULT16_16(tmp, tmp), 8); 701 S1 += SHR32(MULT16_16(tmp, tmp), 10);
634 } 702 }
635
636 { 703 {
637 opus_val16 lpc_mem[LPC_ORDER]; 704 opus_val16 lpc_mem[LPC_ORDER];
638 /* Copy the last decoded samples (prior to the overlap region) to 705 /* Copy the last decoded samples (prior to the overlap region) to
639 synthesis filter memory so we can have a continuous signal. */ 706 synthesis filter memory so we can have a continuous signal. */
640 for (i=0;i<LPC_ORDER;i++) 707 for (i=0;i<LPC_ORDER;i++)
641 lpc_mem[i] = ROUND16(buf[DECODE_BUFFER_SIZE-N-1-i], SIG_SHIFT); 708 lpc_mem[i] = ROUND16(buf[DECODE_BUFFER_SIZE-N-1-i], SIG_SHIFT);
642 /* Apply the synthesis filter to convert the excitation back into 709 /* Apply the synthesis filter to convert the excitation back into
643 the signal domain. */ 710 the signal domain. */
644 celt_iir(buf+DECODE_BUFFER_SIZE-N, lpc+c*LPC_ORDER, 711 celt_iir(buf+DECODE_BUFFER_SIZE-N, lpc+c*LPC_ORDER,
645 buf+DECODE_BUFFER_SIZE-N, extrapolation_len, LPC_ORDER, 712 buf+DECODE_BUFFER_SIZE-N, extrapolation_len, LPC_ORDER,
646 lpc_mem, st->arch); 713 lpc_mem, st->arch);
714 #ifdef FIXED_POINT
715 for (i=0; i < extrapolation_len; i++)
716 buf[DECODE_BUFFER_SIZE-N+i] = SATURATE(buf[DECODE_BUFFER_SIZE-N+i ], SIG_SAT);
717 #endif
647 } 718 }
648 719
649 /* Check if the synthesis energy is higher than expected, which can 720 /* Check if the synthesis energy is higher than expected, which can
650 happen with the signal changes during our window. If so, 721 happen with the signal changes during our window. If so,
651 attenuate. */ 722 attenuate. */
652 { 723 {
653 opus_val32 S2=0; 724 opus_val32 S2=0;
654 for (i=0;i<extrapolation_len;i++) 725 for (i=0;i<extrapolation_len;i++)
655 { 726 {
656 opus_val16 tmp = ROUND16(buf[DECODE_BUFFER_SIZE-N+i], SIG_SHIFT); 727 opus_val16 tmp = ROUND16(buf[DECODE_BUFFER_SIZE-N+i], SIG_SHIFT);
657 S2 += SHR32(MULT16_16(tmp, tmp), 8); 728 S2 += SHR32(MULT16_16(tmp, tmp), 10);
658 } 729 }
659 /* This checks for an "explosion" in the synthesis. */ 730 /* This checks for an "explosion" in the synthesis. */
660 #ifdef FIXED_POINT 731 #ifdef FIXED_POINT
661 if (!(S1 > SHR32(S2,2))) 732 if (!(S1 > SHR32(S2,2)))
662 #else 733 #else
663 /* The float test is written this way to catch NaNs in the output 734 /* The float test is written this way to catch NaNs in the output
664 of the IIR filter at the same time. */ 735 of the IIR filter at the same time. */
665 if (!(S1 > 0.2f*S2)) 736 if (!(S1 > 0.2f*S2))
666 #endif 737 #endif
667 { 738 {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 #ifdef NORM_ALIASING_HACK 1043 #ifdef NORM_ALIASING_HACK
973 /* This is an ugly hack that breaks aliasing rules and would be easily broken , 1044 /* This is an ugly hack that breaks aliasing rules and would be easily broken ,
974 but it saves almost 4kB of stack. */ 1045 but it saves almost 4kB of stack. */
975 X = (celt_norm*)(out_syn[CC-1]+overlap/2); 1046 X = (celt_norm*)(out_syn[CC-1]+overlap/2);
976 #else 1047 #else
977 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ 1048 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
978 #endif 1049 #endif
979 1050
980 quant_all_bands(0, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, 1051 quant_all_bands(0, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks,
981 NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_ res, 1052 NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_ res,
982 len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->r ng, st->arch); 1053 len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->r ng, 0,
1054 st->arch, st->disable_inv);
983 1055
984 if (anti_collapse_rsv > 0) 1056 if (anti_collapse_rsv > 0)
985 { 1057 {
986 anti_collapse_on = ec_dec_bits(dec, 1); 1058 anti_collapse_on = ec_dec_bits(dec, 1);
987 } 1059 }
988 1060
989 unquant_energy_finalise(mode, start, end, oldBandE, 1061 unquant_energy_finalise(mode, start, end, oldBandE,
990 fine_quant, fine_priority, len*8-ec_tell(dec), dec, C); 1062 fine_quant, fine_priority, len*8-ec_tell(dec), dec, C);
991 1063
992 if (anti_collapse_on) 1064 if (anti_collapse_on)
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 } 1299 }
1228 break; 1300 break;
1229 case OPUS_GET_FINAL_RANGE_REQUEST: 1301 case OPUS_GET_FINAL_RANGE_REQUEST:
1230 { 1302 {
1231 opus_uint32 * value = va_arg(ap, opus_uint32 *); 1303 opus_uint32 * value = va_arg(ap, opus_uint32 *);
1232 if (value==0) 1304 if (value==0)
1233 goto bad_arg; 1305 goto bad_arg;
1234 *value=st->rng; 1306 *value=st->rng;
1235 } 1307 }
1236 break; 1308 break;
1309 case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST:
1310 {
1311 opus_int32 value = va_arg(ap, opus_int32);
1312 if(value<0 || value>1)
1313 {
1314 goto bad_arg;
1315 }
1316 st->disable_inv = value;
1317 }
1318 break;
1319 case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST:
1320 {
1321 opus_int32 *value = va_arg(ap, opus_int32*);
1322 if (!value)
1323 {
1324 goto bad_arg;
1325 }
1326 *value = st->disable_inv;
1327 }
1328 break;
1237 default: 1329 default:
1238 goto bad_request; 1330 goto bad_request;
1239 } 1331 }
1240 va_end(ap); 1332 va_end(ap);
1241 return OPUS_OK; 1333 return OPUS_OK;
1242 bad_arg: 1334 bad_arg:
1243 va_end(ap); 1335 va_end(ap);
1244 return OPUS_BAD_ARG; 1336 return OPUS_BAD_ARG;
1245 bad_request: 1337 bad_request:
1246 va_end(ap); 1338 va_end(ap);
1247 return OPUS_UNIMPLEMENTED; 1339 return OPUS_UNIMPLEMENTED;
1248 } 1340 }
OLDNEW
« no previous file with comments | « third_party/opus/src/celt/celt.c ('k') | third_party/opus/src/celt/celt_encoder.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698