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

Side by Side Diff: celt/celt_decoder.c

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « celt/celt.h ('k') | 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return OPUS_OK; 168 return OPUS_OK;
169 } 169 }
170 170
171 #ifdef CUSTOM_MODES 171 #ifdef CUSTOM_MODES
172 void opus_custom_decoder_destroy(CELTDecoder *st) 172 void opus_custom_decoder_destroy(CELTDecoder *st)
173 { 173 {
174 opus_free(st); 174 opus_free(st);
175 } 175 }
176 #endif /* CUSTOM_MODES */ 176 #endif /* CUSTOM_MODES */
177 177
178 static inline opus_val16 SIG2WORD16(celt_sig x) 178 static OPUS_INLINE opus_val16 SIG2WORD16(celt_sig x)
179 { 179 {
180 #ifdef FIXED_POINT 180 #ifdef FIXED_POINT
181 x = PSHR32(x, SIG_SHIFT); 181 x = PSHR32(x, SIG_SHIFT);
182 x = MAX32(x, -32768); 182 x = MAX32(x, -32768);
183 x = MIN32(x, 32767); 183 x = MIN32(x, 32767);
184 return EXTRACT16(x); 184 return EXTRACT16(x);
185 #else 185 #else
186 return (opus_val16)x; 186 return (opus_val16)x;
187 #endif 187 #endif
188 } 188 }
(...skipping 17 matching lines...) Expand all
206 celt_sig m = mem[c]; 206 celt_sig m = mem[c];
207 x =in[c]; 207 x =in[c];
208 y = pcm+c; 208 y = pcm+c;
209 #ifdef CUSTOM_MODES 209 #ifdef CUSTOM_MODES
210 if (coef[1] != 0) 210 if (coef[1] != 0)
211 { 211 {
212 opus_val16 coef1 = coef[1]; 212 opus_val16 coef1 = coef[1];
213 opus_val16 coef3 = coef[3]; 213 opus_val16 coef3 = coef[3];
214 for (j=0;j<N;j++) 214 for (j=0;j<N;j++)
215 { 215 {
216 celt_sig tmp = x[j] + m; 216 celt_sig tmp = x[j] + m + VERY_SMALL;
217 m = MULT16_32_Q15(coef0, tmp) 217 m = MULT16_32_Q15(coef0, tmp)
218 - MULT16_32_Q15(coef1, x[j]); 218 - MULT16_32_Q15(coef1, x[j]);
219 tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2); 219 tmp = SHL32(MULT16_32_Q15(coef3, tmp), 2);
220 scratch[j] = tmp; 220 scratch[j] = tmp;
221 } 221 }
222 apply_downsampling=1; 222 apply_downsampling=1;
223 } else 223 } else
224 #endif 224 #endif
225 if (downsample>1) 225 if (downsample>1)
226 { 226 {
227 /* Shortcut for the standard (non-custom modes) case */ 227 /* Shortcut for the standard (non-custom modes) case */
228 for (j=0;j<N;j++) 228 for (j=0;j<N;j++)
229 { 229 {
230 celt_sig tmp = x[j] + m; 230 celt_sig tmp = x[j] + m + VERY_SMALL;
231 m = MULT16_32_Q15(coef0, tmp); 231 m = MULT16_32_Q15(coef0, tmp);
232 scratch[j] = tmp; 232 scratch[j] = tmp;
233 } 233 }
234 apply_downsampling=1; 234 apply_downsampling=1;
235 } else { 235 } else {
236 /* Shortcut for the standard (non-custom modes) case */ 236 /* Shortcut for the standard (non-custom modes) case */
237 for (j=0;j<N;j++) 237 for (j=0;j<N;j++)
238 { 238 {
239 celt_sig tmp = x[j] + m + VERY_SMALL; 239 celt_sig tmp = x[j] + m + VERY_SMALL;
240 m = MULT16_32_Q15(coef0, tmp); 240 m = MULT16_32_Q15(coef0, tmp);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 const opus_val16 *window; 440 const opus_val16 *window;
441 opus_val16 fade = Q15ONE; 441 opus_val16 fade = Q15ONE;
442 int pitch_index; 442 int pitch_index;
443 VARDECL(opus_val32, etmp); 443 VARDECL(opus_val32, etmp);
444 VARDECL(opus_val16, exc); 444 VARDECL(opus_val16, exc);
445 445
446 if (loss_count == 0) 446 if (loss_count == 0)
447 { 447 {
448 VARDECL( opus_val16, lp_pitch_buf ); 448 VARDECL( opus_val16, lp_pitch_buf );
449 ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); 449 ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 );
450 pitch_downsample(decode_mem, lp_pitch_buf, DECODE_BUFFER_SIZE, C); 450 pitch_downsample(decode_mem, lp_pitch_buf,
451 DECODE_BUFFER_SIZE, C, st->arch);
451 pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, 452 pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf,
452 DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX, 453 DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX,
453 PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index); 454 PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index, st->arch);
454 pitch_index = PLC_PITCH_LAG_MAX-pitch_index; 455 pitch_index = PLC_PITCH_LAG_MAX-pitch_index;
455 st->last_pitch_index = pitch_index; 456 st->last_pitch_index = pitch_index;
456 } else { 457 } else {
457 pitch_index = st->last_pitch_index; 458 pitch_index = st->last_pitch_index;
458 fade = QCONST16(.8f,15); 459 fade = QCONST16(.8f,15);
459 } 460 }
460 461
461 ALLOC(etmp, overlap, opus_val32); 462 ALLOC(etmp, overlap, opus_val32);
462 ALLOC(exc, MAX_PERIOD, opus_val16); 463 ALLOC(exc, MAX_PERIOD, opus_val16);
463 window = mode->window; 464 window = mode->window;
(...skipping 10 matching lines...) Expand all
474 buf = decode_mem[c]; 475 buf = decode_mem[c];
475 for (i=0;i<MAX_PERIOD;i++) { 476 for (i=0;i<MAX_PERIOD;i++) {
476 exc[i] = ROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD+i], SIG_SHIFT); 477 exc[i] = ROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD+i], SIG_SHIFT);
477 } 478 }
478 479
479 if (loss_count == 0) 480 if (loss_count == 0)
480 { 481 {
481 opus_val32 ac[LPC_ORDER+1]; 482 opus_val32 ac[LPC_ORDER+1];
482 /* Compute LPC coefficients for the last MAX_PERIOD samples before 483 /* Compute LPC coefficients for the last MAX_PERIOD samples before
483 the first loss so we can work in the excitation-filter domain. */ 484 the first loss so we can work in the excitation-filter domain. */
484 _celt_autocorr(exc, ac, window, overlap, LPC_ORDER, MAX_PERIOD); 485 _celt_autocorr(exc, ac, window, overlap,
486 LPC_ORDER, MAX_PERIOD, st->arch);
485 /* Add a noise floor of -40 dB. */ 487 /* Add a noise floor of -40 dB. */
486 #ifdef FIXED_POINT 488 #ifdef FIXED_POINT
487 ac[0] += SHR32(ac[0],13); 489 ac[0] += SHR32(ac[0],13);
488 #else 490 #else
489 ac[0] *= 1.0001f; 491 ac[0] *= 1.0001f;
490 #endif 492 #endif
491 /* Use lag windowing to stabilize the Levinson-Durbin recursion. */ 493 /* Use lag windowing to stabilize the Levinson-Durbin recursion. */
492 for (i=1;i<=LPC_ORDER;i++) 494 for (i=1;i<=LPC_ORDER;i++)
493 { 495 {
494 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/ 496 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 ec_dec _dec; 660 ec_dec _dec;
659 VARDECL(celt_sig, freq); 661 VARDECL(celt_sig, freq);
660 VARDECL(celt_norm, X); 662 VARDECL(celt_norm, X);
661 VARDECL(int, fine_quant); 663 VARDECL(int, fine_quant);
662 VARDECL(int, pulses); 664 VARDECL(int, pulses);
663 VARDECL(int, cap); 665 VARDECL(int, cap);
664 VARDECL(int, offsets); 666 VARDECL(int, offsets);
665 VARDECL(int, fine_priority); 667 VARDECL(int, fine_priority);
666 VARDECL(int, tf_res); 668 VARDECL(int, tf_res);
667 VARDECL(unsigned char, collapse_masks); 669 VARDECL(unsigned char, collapse_masks);
668 celt_sig *out_mem[2];
669 celt_sig *decode_mem[2]; 670 celt_sig *decode_mem[2];
670 celt_sig *out_syn[2]; 671 celt_sig *out_syn[2];
671 opus_val16 *lpc; 672 opus_val16 *lpc;
672 opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; 673 opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE;
673 674
674 int shortBlocks; 675 int shortBlocks;
675 int isTransient; 676 int isTransient;
676 int intra_ener; 677 int intra_ener;
677 const int CC = st->channels; 678 const int CC = st->channels;
678 int LM, M; 679 int LM, M;
(...skipping 20 matching lines...) Expand all
699 ALLOC_STACK; 700 ALLOC_STACK;
700 701
701 mode = st->mode; 702 mode = st->mode;
702 nbEBands = mode->nbEBands; 703 nbEBands = mode->nbEBands;
703 overlap = mode->overlap; 704 overlap = mode->overlap;
704 eBands = mode->eBands; 705 eBands = mode->eBands;
705 frame_size *= st->downsample; 706 frame_size *= st->downsample;
706 707
707 c=0; do { 708 c=0; do {
708 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap); 709 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+overlap);
709 out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD;
710 } while (++c<CC); 710 } while (++c<CC);
711 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC); 711 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+overlap)*CC);
712 oldBandE = lpc+CC*LPC_ORDER; 712 oldBandE = lpc+CC*LPC_ORDER;
713 oldLogE = oldBandE + 2*nbEBands; 713 oldLogE = oldBandE + 2*nbEBands;
714 oldLogE2 = oldLogE + 2*nbEBands; 714 oldLogE2 = oldLogE + 2*nbEBands;
715 backgroundLogE = oldLogE2 + 2*nbEBands; 715 backgroundLogE = oldLogE2 + 2*nbEBands;
716 716
717 #ifdef CUSTOM_MODES 717 #ifdef CUSTOM_MODES
718 if (st->signalling && data!=NULL) 718 if (st->signalling && data!=NULL)
719 { 719 {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 929
930 c=0; do { 930 c=0; do {
931 int bound = M*eBands[effEnd]; 931 int bound = M*eBands[effEnd];
932 if (st->downsample!=1) 932 if (st->downsample!=1)
933 bound = IMIN(bound, N/st->downsample); 933 bound = IMIN(bound, N/st->downsample);
934 for (i=bound;i<N;i++) 934 for (i=bound;i<N;i++)
935 freq[c*N+i] = 0; 935 freq[c*N+i] = 0;
936 } while (++c<C); 936 } while (++c<C);
937 937
938 c=0; do { 938 c=0; do {
939 out_syn[c] = out_mem[c]+MAX_PERIOD-N; 939 out_syn[c] = decode_mem[c]+DECODE_BUFFER_SIZE-N;
940 } while (++c<CC); 940 } while (++c<CC);
941 941
942 if (CC==2&&C==1) 942 if (CC==2&&C==1)
943 { 943 {
944 for (i=0;i<N;i++) 944 for (i=0;i<N;i++)
945 freq[N+i] = freq[i]; 945 freq[N+i] = freq[i];
946 } 946 }
947 if (CC==1&&C==2) 947 if (CC==1&&C==2)
948 { 948 {
949 for (i=0;i<N;i++) 949 for (i=0;i<N;i++)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1186 }
1187 va_end(ap); 1187 va_end(ap);
1188 return OPUS_OK; 1188 return OPUS_OK;
1189 bad_arg: 1189 bad_arg:
1190 va_end(ap); 1190 va_end(ap);
1191 return OPUS_BAD_ARG; 1191 return OPUS_BAD_ARG;
1192 bad_request: 1192 bad_request:
1193 va_end(ap); 1193 va_end(ap);
1194 return OPUS_UNIMPLEMENTED; 1194 return OPUS_UNIMPLEMENTED;
1195 } 1195 }
OLDNEW
« no previous file with comments | « celt/celt.h ('k') | celt/celt_encoder.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698