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

Side by Side Diff: celt/celt.c

Issue 12388030: Update Opus to 1.0.2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « celt/bands.c ('k') | celt/cwrs.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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 opus_int32 vbr_reservoir; 186 opus_int32 vbr_reservoir;
187 opus_int32 vbr_drift; 187 opus_int32 vbr_drift;
188 opus_int32 vbr_offset; 188 opus_int32 vbr_offset;
189 opus_int32 vbr_count; 189 opus_int32 vbr_count;
190 190
191 #ifdef RESYNTH 191 #ifdef RESYNTH
192 celt_sig syn_mem[2][2*MAX_PERIOD]; 192 celt_sig syn_mem[2][2*MAX_PERIOD];
193 #endif 193 #endif
194 194
195 celt_sig in_mem[1]; /* Size = channels*mode->overlap */ 195 celt_sig in_mem[1]; /* Size = channels*mode->overlap */
196 /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_PERIOD */ 196 /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */
197 /* celt_sig overlap_mem[], Size = channels*mode->overlap */ 197 /* opus_val16 oldBandE[], Size = channels*mode->nbEBands */
198 /* opus_val16 oldEBands[], Size = 2*channels*mode->nbEBands */ 198 /* opus_val16 oldLogE[], Size = channels*mode->nbEBands */
199 /* opus_val16 oldLogE2[], Size = channels*mode->nbEBands */
200 #ifdef RESYNTH
201 /* opus_val16 overlap_mem[], Size = channels*overlap */
202 #endif
199 }; 203 };
200 204
201 int celt_encoder_get_size(int channels) 205 int celt_encoder_get_size(int channels)
202 { 206 {
203 CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); 207 CELTMode *mode = opus_custom_mode_create(48000, 960, NULL);
204 return opus_custom_encoder_get_size(mode, channels); 208 return opus_custom_encoder_get_size(mode, channels);
205 } 209 }
206 210
207 OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) 211 OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels)
208 { 212 {
209 int size = sizeof(struct CELTEncoder) 213 int size = sizeof(struct CELTEncoder)
210 + (2*channels*mode->overlap-1)*sizeof(celt_sig) 214 + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[cha nnels*mode->overlap]; */
211 + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) 215 + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) /* celt_sig prefilter_ mem[channels*COMBFILTER_MAXPERIOD]; */
212 + 3*channels*mode->nbEBands*sizeof(opus_val16); 216 + 3*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE [channels*mode->nbEBands]; */
217 /* opus_val16 oldLogE[ channels*mode->nbEBands]; */
218 /* opus_val16 oldLogE2 [channels*mode->nbEBands]; */
219 #ifdef RESYNTH
220 size += channels*mode->overlap*sizeof(celt_sig); /* celt_sig overlap_me m[channels*mode->nbEBands]; */
221 #endif
213 return size; 222 return size;
214 } 223 }
215 224
216 #ifdef CUSTOM_MODES 225 #ifdef CUSTOM_MODES
217 CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error) 226 CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error)
218 { 227 {
219 int ret; 228 int ret;
220 CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode , channels)); 229 CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode , channels));
221 /* init will handle the NULL case */ 230 /* init will handle the NULL case */
222 ret = opus_custom_encoder_init(st, mode, channels); 231 ret = opus_custom_encoder_init(st, mode, channels);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 else if (width==2) 565 else if (width==2)
557 bias = QCONST16(.05f,15)*LM; 566 bias = QCONST16(.05f,15)*LM;
558 else 567 else
559 bias = QCONST16(.02f,15)*LM; 568 bias = QCONST16(.02f,15)*LM;
560 L1 = MAC16_32_Q15(L1, bias, L1); 569 L1 = MAC16_32_Q15(L1, bias, L1);
561 return L1; 570 return L1;
562 } 571 }
563 572
564 static int tf_analysis(const CELTMode *m, int len, int C, int isTransient, 573 static int tf_analysis(const CELTMode *m, int len, int C, int isTransient,
565 int *tf_res, int nbCompressedBytes, celt_norm *X, int N0, int LM, 574 int *tf_res, int nbCompressedBytes, celt_norm *X, int N0, int LM,
566 int *tf_sum) 575 int start, int *tf_sum)
567 { 576 {
568 int i; 577 int i;
569 VARDECL(int, metric); 578 VARDECL(int, metric);
570 int cost0; 579 int cost0;
571 int cost1; 580 int cost1;
572 VARDECL(int, path0); 581 VARDECL(int, path0);
573 VARDECL(int, path1); 582 VARDECL(int, path1);
574 VARDECL(celt_norm, tmp); 583 VARDECL(celt_norm, tmp);
575 int lambda; 584 int lambda;
576 int tf_select=0; 585 int tf_select=0;
577 SAVE_STACK; 586 SAVE_STACK;
578 587
579 if (nbCompressedBytes<15*C) 588 if (nbCompressedBytes<15*C || start!=0)
580 { 589 {
581 *tf_sum = 0; 590 *tf_sum = 0;
582 for (i=0;i<len;i++) 591 for (i=0;i<len;i++)
583 tf_res[i] = isTransient; 592 tf_res[i] = isTransient;
584 return 0; 593 return 0;
585 } 594 }
586 if (nbCompressedBytes<40) 595 if (nbCompressedBytes<40)
587 lambda = 12; 596 lambda = 12;
588 else if (nbCompressedBytes<60) 597 else if (nbCompressedBytes<60)
589 lambda = 6; 598 lambda = 6;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 frame_size *= st->upsample; 946 frame_size *= st->upsample;
938 for (LM=0;LM<=st->mode->maxLM;LM++) 947 for (LM=0;LM<=st->mode->maxLM;LM++)
939 if (st->mode->shortMdctSize<<LM==frame_size) 948 if (st->mode->shortMdctSize<<LM==frame_size)
940 break; 949 break;
941 if (LM>st->mode->maxLM) 950 if (LM>st->mode->maxLM)
942 return OPUS_BAD_ARG; 951 return OPUS_BAD_ARG;
943 M=1<<LM; 952 M=1<<LM;
944 N = M*st->mode->shortMdctSize; 953 N = M*st->mode->shortMdctSize;
945 954
946 prefilter_mem = st->in_mem+CC*(st->overlap); 955 prefilter_mem = st->in_mem+CC*(st->overlap);
947 oldBandE = (opus_val16*)(st->in_mem+CC*(2*st->overlap+COMBFILTER_MAXPERIOD)); 956 oldBandE = (opus_val16*)(st->in_mem+CC*(st->overlap+COMBFILTER_MAXPERIOD));
948 oldLogE = oldBandE + CC*st->mode->nbEBands; 957 oldLogE = oldBandE + CC*st->mode->nbEBands;
949 oldLogE2 = oldLogE + CC*st->mode->nbEBands; 958 oldLogE2 = oldLogE + CC*st->mode->nbEBands;
950 959
951 if (enc==NULL) 960 if (enc==NULL)
952 { 961 {
953 tell=1; 962 tell=1;
954 nbFilledBytes=0; 963 nbFilledBytes=0;
955 } else { 964 } else {
956 tell=ec_tell(enc); 965 tell=ec_tell(enc);
957 nbFilledBytes=(tell+4)>>3; 966 nbFilledBytes=(tell+4)>>3;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ 1268 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
1260 1269
1261 compute_band_energies(st->mode, freq, bandE, effEnd, C, M); 1270 compute_band_energies(st->mode, freq, bandE, effEnd, C, M);
1262 1271
1263 amp2Log2(st->mode, effEnd, st->end, bandE, bandLogE, C); 1272 amp2Log2(st->mode, effEnd, st->end, bandE, bandLogE, C);
1264 1273
1265 /* Band normalisation */ 1274 /* Band normalisation */
1266 normalise_bands(st->mode, freq, X, bandE, effEnd, C, M); 1275 normalise_bands(st->mode, freq, X, bandE, effEnd, C, M);
1267 1276
1268 ALLOC(tf_res, st->mode->nbEBands, int); 1277 ALLOC(tf_res, st->mode->nbEBands, int);
1269 tf_select = tf_analysis(st->mode, effEnd, C, isTransient, tf_res, effectiveBy tes, X, N, LM, &tf_sum); 1278 tf_select = tf_analysis(st->mode, effEnd, C, isTransient, tf_res, effectiveBy tes, X, N, LM, st->start, &tf_sum);
1270 for (i=effEnd;i<st->end;i++) 1279 for (i=effEnd;i<st->end;i++)
1271 tf_res[i] = tf_res[effEnd-1]; 1280 tf_res[i] = tf_res[effEnd-1];
1272 1281
1273 ALLOC(error, C*st->mode->nbEBands, opus_val16); 1282 ALLOC(error, C*st->mode->nbEBands, opus_val16);
1274 quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE, 1283 quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE,
1275 oldBandE, total_bits, error, enc, 1284 oldBandE, total_bits, error, enc,
1276 C, LM, nbAvailableBytes, st->force_intra, 1285 C, LM, nbAvailableBytes, st->force_intra,
1277 &st->delayedIntra, st->complexity >= 4, st->loss_rate); 1286 &st->delayedIntra, st->complexity >= 4, st->loss_rate);
1278 1287
1279 tf_encode(st->start, st->end, isTransient, tf_res, LM, tf_select, enc); 1288 tf_encode(st->start, st->end, isTransient, tf_res, LM, tf_select, enc);
1280 1289
1281 st->spread_decision = SPREAD_NORMAL;
1282 if (ec_tell(enc)+4<=total_bits) 1290 if (ec_tell(enc)+4<=total_bits)
1283 { 1291 {
1284 if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C) 1292 if (shortBlocks || st->complexity < 3
1293 || nbAvailableBytes < 10*C || st->start!=0)
1285 { 1294 {
1286 if (st->complexity == 0) 1295 if (st->complexity == 0)
1287 st->spread_decision = SPREAD_NONE; 1296 st->spread_decision = SPREAD_NONE;
1297 else
1298 st->spread_decision = SPREAD_NORMAL;
1288 } else { 1299 } else {
1289 st->spread_decision = spreading_decision(st->mode, X, 1300 st->spread_decision = spreading_decision(st->mode, X,
1290 &st->tonal_average, st->spread_decision, &st->hf_average, 1301 &st->tonal_average, st->spread_decision, &st->hf_average,
1291 &st->tapset_decision, pf_on&&!shortBlocks, effEnd, C, M); 1302 &st->tapset_decision, pf_on&&!shortBlocks, effEnd, C, M);
1292 } 1303 }
1293 ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5); 1304 ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5);
1294 } 1305 }
1295 1306
1296 ALLOC(cap, st->mode->nbEBands, int); 1307 ALLOC(cap, st->mode->nbEBands, int);
1297 ALLOC(offsets, st->mode->nbEBands, int); 1308 ALLOC(offsets, st->mode->nbEBands, int);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 if (CC==2&&C==1) 1592 if (CC==2&&C==1)
1582 { 1593 {
1583 for (i=0;i<N;i++) 1594 for (i=0;i<N;i++)
1584 freq[N+i] = freq[i]; 1595 freq[N+i] = freq[i];
1585 } 1596 }
1586 1597
1587 out_mem[0] = st->syn_mem[0]+MAX_PERIOD; 1598 out_mem[0] = st->syn_mem[0]+MAX_PERIOD;
1588 if (CC==2) 1599 if (CC==2)
1589 out_mem[1] = st->syn_mem[1]+MAX_PERIOD; 1600 out_mem[1] = st->syn_mem[1]+MAX_PERIOD;
1590 1601
1591 overlap_mem[0] = prefilter_mem+CC*COMBFILTER_MAXPERIOD; 1602 overlap_mem[0] = (celt_sig*)(oldLogE2 + CC*st->mode->nbEBands);
1592 if (CC==2) 1603 if (CC==2)
1593 overlap_mem[1] = overlap_mem[0] + st->overlap; 1604 overlap_mem[1] = overlap_mem[0] + st->overlap;
1594 1605
1595 compute_inv_mdcts(st->mode, shortBlocks, freq, out_mem, overlap_mem, CC, L M); 1606 compute_inv_mdcts(st->mode, shortBlocks, freq, out_mem, overlap_mem, CC, L M);
1596 1607
1597 c=0; do { 1608 c=0; do {
1598 st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); 1609 st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD);
1599 st->prefilter_period_old=IMAX(st->prefilter_period_old, COMBFILTER_MINP ERIOD); 1610 st->prefilter_period_old=IMAX(st->prefilter_period_old, COMBFILTER_MINP ERIOD);
1600 comb_filter(out_mem[c], out_mem[c], st->prefilter_period_old, st->prefi lter_period, st->mode->shortMdctSize, 1611 comb_filter(out_mem[c], out_mem[c], st->prefilter_period_old, st->prefi lter_period, st->mode->shortMdctSize,
1601 st->prefilter_gain_old, st->prefilter_gain, st->prefilter_tapset_ old, st->prefilter_tapset, 1612 st->prefilter_gain_old, st->prefilter_gain, st->prefilter_tapset_ old, st->prefilter_tapset,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 case OPUS_GET_LSB_DEPTH_REQUEST: 1847 case OPUS_GET_LSB_DEPTH_REQUEST:
1837 { 1848 {
1838 opus_int32 *value = va_arg(ap, opus_int32*); 1849 opus_int32 *value = va_arg(ap, opus_int32*);
1839 *value=st->lsb_depth; 1850 *value=st->lsb_depth;
1840 } 1851 }
1841 break; 1852 break;
1842 case OPUS_RESET_STATE: 1853 case OPUS_RESET_STATE:
1843 { 1854 {
1844 int i; 1855 int i;
1845 opus_val16 *oldBandE, *oldLogE, *oldLogE2; 1856 opus_val16 *oldBandE, *oldLogE, *oldLogE2;
1846 oldBandE = (opus_val16*)(st->in_mem+st->channels*(2*st->overlap+COMBFIL TER_MAXPERIOD)); 1857 oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->overlap+COMBFILTE R_MAXPERIOD));
1847 oldLogE = oldBandE + st->channels*st->mode->nbEBands; 1858 oldLogE = oldBandE + st->channels*st->mode->nbEBands;
1848 oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; 1859 oldLogE2 = oldLogE + st->channels*st->mode->nbEBands;
1849 OPUS_CLEAR((char*)&st->ENCODER_RESET_START, 1860 OPUS_CLEAR((char*)&st->ENCODER_RESET_START,
1850 opus_custom_encoder_get_size(st->mode, st->channels)- 1861 opus_custom_encoder_get_size(st->mode, st->channels)-
1851 ((char*)&st->ENCODER_RESET_START - (char*)st)); 1862 ((char*)&st->ENCODER_RESET_START - (char*)st));
1852 for (i=0;i<st->channels*st->mode->nbEBands;i++) 1863 for (i=0;i<st->channels*st->mode->nbEBands;i++)
1853 oldLogE[i]=oldLogE2[i]=-QCONST16(28.f,DB_SHIFT); 1864 oldLogE[i]=oldLogE2[i]=-QCONST16(28.f,DB_SHIFT);
1854 st->vbr_offset = 0; 1865 st->vbr_offset = 0;
1855 st->delayedIntra = 1; 1866 st->delayedIntra = 1;
1856 st->spread_decision = SPREAD_NORMAL; 1867 st->spread_decision = SPREAD_NORMAL;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 void opus_custom_decoder_destroy(CELTDecoder *st) 2032 void opus_custom_decoder_destroy(CELTDecoder *st)
2022 { 2033 {
2023 opus_free(st); 2034 opus_free(st);
2024 } 2035 }
2025 #endif /* CUSTOM_MODES */ 2036 #endif /* CUSTOM_MODES */
2026 2037
2027 static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R ESTRICT pcm, int N, int LM) 2038 static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R ESTRICT pcm, int N, int LM)
2028 { 2039 {
2029 int c; 2040 int c;
2030 int pitch_index; 2041 int pitch_index;
2031 int overlap = st->mode->overlap;
2032 opus_val16 fade = Q15ONE; 2042 opus_val16 fade = Q15ONE;
2033 int i, len; 2043 int i, len;
2034 const int C = st->channels; 2044 const int C = st->channels;
2035 int offset; 2045 int offset;
2036 celt_sig *out_mem[2]; 2046 celt_sig *out_mem[2];
2037 celt_sig *decode_mem[2]; 2047 celt_sig *decode_mem[2];
2038 celt_sig *overlap_mem[2]; 2048 celt_sig *overlap_mem[2];
2039 opus_val16 *lpc; 2049 opus_val16 *lpc;
2040 opus_val32 *out_syn[2]; 2050 opus_val32 *out_syn[2];
2041 opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; 2051 opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE;
2052 const OpusCustomMode *mode;
2053 int nbEBands;
2054 int overlap;
2055 const opus_int16 *eBands;
2042 SAVE_STACK; 2056 SAVE_STACK;
2043 2057
2058 mode = st->mode;
2059 nbEBands = mode->nbEBands;
2060 overlap = mode->overlap;
2061 eBands = mode->eBands;
2062
2044 c=0; do { 2063 c=0; do {
2045 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+st->overlap); 2064 decode_mem[c] = st->_decode_mem + c*(DECODE_BUFFER_SIZE+st->overlap);
2046 out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD; 2065 out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD;
2047 overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE; 2066 overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE;
2048 } while (++c<C); 2067 } while (++c<C);
2049 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C); 2068 lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C);
2050 oldBandE = lpc+C*LPC_ORDER; 2069 oldBandE = lpc+C*LPC_ORDER;
2051 oldLogE = oldBandE + 2*st->mode->nbEBands; 2070 oldLogE = oldBandE + 2*nbEBands;
2052 oldLogE2 = oldLogE + 2*st->mode->nbEBands; 2071 oldLogE2 = oldLogE + 2*nbEBands;
2053 backgroundLogE = oldLogE2 + 2*st->mode->nbEBands; 2072 backgroundLogE = oldLogE2 + 2*nbEBands;
2054 2073
2055 out_syn[0] = out_mem[0]+MAX_PERIOD-N; 2074 c=0; do {
2056 if (C==2) 2075 out_syn[c] = out_mem[c]+MAX_PERIOD-N;
2057 out_syn[1] = out_mem[1]+MAX_PERIOD-N; 2076 } while (++c<C);
2058 2077
2059 len = N+st->mode->overlap; 2078 len = N+overlap;
2060 2079
2061 if (st->loss_count >= 5 || st->start!=0) 2080 if (st->loss_count >= 5 || st->start!=0)
2062 { 2081 {
2063 /* Noise-based PLC/CNG */ 2082 /* Noise-based PLC/CNG */
2064 VARDECL(celt_sig, freq); 2083 VARDECL(celt_sig, freq);
2065 VARDECL(celt_norm, X); 2084 VARDECL(celt_norm, X);
2066 VARDECL(celt_ener, bandE); 2085 VARDECL(celt_ener, bandE);
2067 opus_uint32 seed; 2086 opus_uint32 seed;
2068 int effEnd; 2087 int effEnd;
2069 2088
2070 effEnd = st->end; 2089 effEnd = st->end;
2071 if (effEnd > st->mode->effEBands) 2090 if (effEnd > mode->effEBands)
2072 effEnd = st->mode->effEBands; 2091 effEnd = mode->effEBands;
2073 2092
2074 ALLOC(freq, C*N, celt_sig); /**< Interleaved signal MDCTs */ 2093 ALLOC(freq, C*N, celt_sig); /**< Interleaved signal MDCTs */
2075 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ 2094 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
2076 ALLOC(bandE, st->mode->nbEBands*C, celt_ener); 2095 ALLOC(bandE, nbEBands*C, celt_ener);
2077 2096
2078 if (st->loss_count >= 5) 2097 if (st->loss_count >= 5)
2079 log2Amp(st->mode, st->start, st->end, bandE, backgroundLogE, C); 2098 log2Amp(mode, st->start, st->end, bandE, backgroundLogE, C);
2080 else { 2099 else {
2081 /* Energy decay */ 2100 /* Energy decay */
2082 opus_val16 decay = st->loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONS T16(.5f, DB_SHIFT); 2101 opus_val16 decay = st->loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONS T16(.5f, DB_SHIFT);
2083 c=0; do 2102 c=0; do
2084 { 2103 {
2085 for (i=st->start;i<st->end;i++) 2104 for (i=st->start;i<st->end;i++)
2086 oldBandE[c*st->mode->nbEBands+i] -= decay; 2105 oldBandE[c*nbEBands+i] -= decay;
2087 } while (++c<C); 2106 } while (++c<C);
2088 log2Amp(st->mode, st->start, st->end, bandE, oldBandE, C); 2107 log2Amp(mode, st->start, st->end, bandE, oldBandE, C);
2089 } 2108 }
2090 seed = st->rng; 2109 seed = st->rng;
2091 for (c=0;c<C;c++) 2110 for (c=0;c<C;c++)
2092 { 2111 {
2093 for (i=0;i<(st->mode->eBands[st->start]<<LM);i++) 2112 for (i=0;i<(st->mode->eBands[st->start]<<LM);i++)
2094 X[c*N+i] = 0; 2113 X[c*N+i] = 0;
2095 for (i=st->start;i<st->mode->effEBands;i++) 2114 for (i=st->start;i<mode->effEBands;i++)
2096 { 2115 {
2097 int j; 2116 int j;
2098 int boffs; 2117 int boffs;
2099 int blen; 2118 int blen;
2100 boffs = N*c+(st->mode->eBands[i]<<LM); 2119 boffs = N*c+(eBands[i]<<LM);
2101 blen = (st->mode->eBands[i+1]-st->mode->eBands[i])<<LM; 2120 blen = (eBands[i+1]-eBands[i])<<LM;
2102 for (j=0;j<blen;j++) 2121 for (j=0;j<blen;j++)
2103 { 2122 {
2104 seed = celt_lcg_rand(seed); 2123 seed = celt_lcg_rand(seed);
2105 X[boffs+j] = (celt_norm)((opus_int32)seed>>20); 2124 X[boffs+j] = (celt_norm)((opus_int32)seed>>20);
2106 } 2125 }
2107 renormalise_vector(X+boffs, blen, Q15ONE); 2126 renormalise_vector(X+boffs, blen, Q15ONE);
2108 } 2127 }
2109 for (i=(st->mode->eBands[st->end]<<LM);i<N;i++) 2128 for (i=(st->mode->eBands[st->end]<<LM);i<N;i++)
2110 X[c*N+i] = 0; 2129 X[c*N+i] = 0;
2111 } 2130 }
2112 st->rng = seed; 2131 st->rng = seed;
2113 2132
2114 denormalise_bands(st->mode, X, freq, bandE, st->mode->effEBands, C, 1<<LM) ; 2133 denormalise_bands(mode, X, freq, bandE, mode->effEBands, C, 1<<LM);
2115 2134
2116 c=0; do 2135 c=0; do
2117 for (i=0;i<st->mode->eBands[st->start]<<LM;i++) 2136 for (i=0;i<st->mode->eBands[st->start]<<LM;i++)
2118 freq[c*N+i] = 0; 2137 freq[c*N+i] = 0;
2119 while (++c<C); 2138 while (++c<C);
2120 c=0; do { 2139 c=0; do {
2121 int bound = st->mode->eBands[effEnd]<<LM; 2140 int bound = eBands[effEnd]<<LM;
2122 if (st->downsample!=1) 2141 if (st->downsample!=1)
2123 bound = IMIN(bound, N/st->downsample); 2142 bound = IMIN(bound, N/st->downsample);
2124 for (i=bound;i<N;i++) 2143 for (i=bound;i<N;i++)
2125 freq[c*N+i] = 0; 2144 freq[c*N+i] = 0;
2126 } while (++c<C); 2145 } while (++c<C);
2127 compute_inv_mdcts(st->mode, 0, freq, out_syn, overlap_mem, C, LM); 2146 c=0; do {
2147 OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap) ;
2148 } while (++c<C);
2149 compute_inv_mdcts(mode, 0, freq, out_syn, overlap_mem, C, LM);
2128 } else { 2150 } else {
2129 /* Pitch-based PLC */ 2151 /* Pitch-based PLC */
2152 VARDECL(opus_val32, etmp);
2153
2130 if (st->loss_count == 0) 2154 if (st->loss_count == 0)
2131 { 2155 {
2132 opus_val16 pitch_buf[DECODE_BUFFER_SIZE>>1]; 2156 opus_val16 pitch_buf[DECODE_BUFFER_SIZE>>1];
2133 /* Corresponds to a min pitch of 67 Hz. It's possible to save CPU in th is 2157 /* Corresponds to a min pitch of 67 Hz. It's possible to save CPU in th is
2134 search by using only part of the decode buffer */ 2158 search by using only part of the decode buffer */
2135 int poffset = 720; 2159 int poffset = 720;
2136 pitch_downsample(decode_mem, pitch_buf, DECODE_BUFFER_SIZE, C); 2160 pitch_downsample(decode_mem, pitch_buf, DECODE_BUFFER_SIZE, C);
2137 /* Max pitch is 100 samples (480 Hz) */ 2161 /* Max pitch is 100 samples (480 Hz) */
2138 pitch_search(pitch_buf+((poffset)>>1), pitch_buf, DECODE_BUFFER_SIZE-po ffset, 2162 pitch_search(pitch_buf+((poffset)>>1), pitch_buf, DECODE_BUFFER_SIZE-po ffset,
2139 poffset-100, &pitch_index); 2163 poffset-100, &pitch_index);
2140 pitch_index = poffset-pitch_index; 2164 pitch_index = poffset-pitch_index;
2141 st->last_pitch_index = pitch_index; 2165 st->last_pitch_index = pitch_index;
2142 } else { 2166 } else {
2143 pitch_index = st->last_pitch_index; 2167 pitch_index = st->last_pitch_index;
2144 fade = QCONST16(.8f,15); 2168 fade = QCONST16(.8f,15);
2145 } 2169 }
2146 2170
2171 ALLOC(etmp, overlap, opus_val32);
2147 c=0; do { 2172 c=0; do {
2148 VARDECL(opus_val32, e);
2149 opus_val16 exc[MAX_PERIOD]; 2173 opus_val16 exc[MAX_PERIOD];
2150 opus_val32 ac[LPC_ORDER+1]; 2174 opus_val32 ac[LPC_ORDER+1];
2151 opus_val16 decay = 1; 2175 opus_val16 decay;
2176 opus_val16 attenuation;
2152 opus_val32 S1=0; 2177 opus_val32 S1=0;
2153 opus_val16 mem[LPC_ORDER]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0}; 2178 opus_val16 mem[LPC_ORDER]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0};
2179 opus_val32 *e = out_syn[c];
2154 2180
2155 ALLOC(e, MAX_PERIOD+2*st->mode->overlap, opus_val32);
2156 2181
2157 offset = MAX_PERIOD-pitch_index; 2182 offset = MAX_PERIOD-pitch_index;
2158 for (i=0;i<MAX_PERIOD;i++) 2183 for (i=0;i<MAX_PERIOD;i++)
2159 exc[i] = ROUND16(out_mem[c][i], SIG_SHIFT); 2184 exc[i] = ROUND16(out_mem[c][i], SIG_SHIFT);
2160 2185
2186 /* Compute LPC coefficients for the last MAX_PERIOD samples before the loss so we can
2187 work in the excitation-filter domain */
2161 if (st->loss_count == 0) 2188 if (st->loss_count == 0)
2162 { 2189 {
2163 _celt_autocorr(exc, ac, st->mode->window, st->mode->overlap, 2190 _celt_autocorr(exc, ac, mode->window, overlap,
2164 LPC_ORDER, MAX_PERIOD); 2191 LPC_ORDER, MAX_PERIOD);
2165 2192
2166 /* Noise floor -40 dB */ 2193 /* Noise floor -40 dB */
2167 #ifdef FIXED_POINT 2194 #ifdef FIXED_POINT
2168 ac[0] += SHR32(ac[0],13); 2195 ac[0] += SHR32(ac[0],13);
2169 #else 2196 #else
2170 ac[0] *= 1.0001f; 2197 ac[0] *= 1.0001f;
2171 #endif 2198 #endif
2172 /* Lag windowing */ 2199 /* Lag windowing */
2173 for (i=1;i<=LPC_ORDER;i++) 2200 for (i=1;i<=LPC_ORDER;i++)
2174 { 2201 {
2175 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/ 2202 /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/
2176 #ifdef FIXED_POINT 2203 #ifdef FIXED_POINT
2177 ac[i] -= MULT16_32_Q15(2*i*i, ac[i]); 2204 ac[i] -= MULT16_32_Q15(2*i*i, ac[i]);
2178 #else 2205 #else
2179 ac[i] -= ac[i]*(.008f*i)*(.008f*i); 2206 ac[i] -= ac[i]*(.008f*i)*(.008f*i);
2180 #endif 2207 #endif
2181 } 2208 }
2182 2209
2183 _celt_lpc(lpc+c*LPC_ORDER, ac, LPC_ORDER); 2210 _celt_lpc(lpc+c*LPC_ORDER, ac, LPC_ORDER);
2184 } 2211 }
2212 /* Samples just before the beginning of exc */
2185 for (i=0;i<LPC_ORDER;i++) 2213 for (i=0;i<LPC_ORDER;i++)
2186 mem[i] = ROUND16(out_mem[c][MAX_PERIOD-1-i], SIG_SHIFT); 2214 mem[i] = ROUND16(out_mem[c][-1-i], SIG_SHIFT);
2215 /* Compute the excitation for MAX_PERIOD samples before the loss */
2187 celt_fir(exc, lpc+c*LPC_ORDER, exc, MAX_PERIOD, LPC_ORDER, mem); 2216 celt_fir(exc, lpc+c*LPC_ORDER, exc, MAX_PERIOD, LPC_ORDER, mem);
2188 /*for (i=0;i<MAX_PERIOD;i++)printf("%d ", exc[i]); printf("\n");*/ 2217
2189 /* Check if the waveform is decaying (and if so how fast) */ 2218 /* Check if the waveform is decaying (and if so how fast)
2219 We do this to avoid adding energy when concealing in a segment
2220 with decaying energy */
2190 { 2221 {
2191 opus_val32 E1=1, E2=1; 2222 opus_val32 E1=1, E2=1;
2192 int period; 2223 int period;
2193 if (pitch_index <= MAX_PERIOD/2) 2224 if (pitch_index <= MAX_PERIOD/2)
2194 period = pitch_index; 2225 period = pitch_index;
2195 else 2226 else
2196 period = MAX_PERIOD/2; 2227 period = MAX_PERIOD/2;
2197 for (i=0;i<period;i++) 2228 for (i=0;i<period;i++)
2198 { 2229 {
2199 E1 += SHR32(MULT16_16(exc[MAX_PERIOD-period+i],exc[MAX_PERIOD-per iod+i]),8); 2230 E1 += SHR32(MULT16_16(exc[MAX_PERIOD-period+i],exc[MAX_PERIOD-per iod+i]),8);
2200 E2 += SHR32(MULT16_16(exc[MAX_PERIOD-2*period+i],exc[MAX_PERIOD-2 *period+i]),8); 2231 E2 += SHR32(MULT16_16(exc[MAX_PERIOD-2*period+i],exc[MAX_PERIOD-2 *period+i]),8);
2201 } 2232 }
2202 if (E1 > E2) 2233 if (E1 > E2)
2203 E1 = E2; 2234 E1 = E2;
2204 decay = celt_sqrt(frac_div32(SHR32(E1,1),E2)); 2235 decay = celt_sqrt(frac_div32(SHR32(E1,1),E2));
2236 attenuation = decay;
2205 } 2237 }
2206 2238
2207 /* Copy excitation, taking decay into account */ 2239 /* Move memory one frame to the left */
2208 for (i=0;i<len+st->mode->overlap;i++) 2240 OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap) ;
2241
2242 /* Extrapolate excitation with the right period, taking decay into acco unt */
2243 for (i=0;i<len;i++)
2209 { 2244 {
2210 opus_val16 tmp; 2245 opus_val16 tmp;
2211 if (offset+i >= MAX_PERIOD) 2246 if (offset+i >= MAX_PERIOD)
2212 { 2247 {
2213 offset -= pitch_index; 2248 offset -= pitch_index;
2214 decay = MULT16_16_Q15(decay, decay); 2249 attenuation = MULT16_16_Q15(attenuation, decay);
2215 } 2250 }
2216 e[i] = SHL32(EXTEND32(MULT16_16_Q15(decay, exc[offset+i])), SIG_SHIF T); 2251 e[i] = SHL32(EXTEND32(MULT16_16_Q15(attenuation, exc[offset+i])), SI G_SHIFT);
2217 tmp = ROUND16(out_mem[c][offset+i],SIG_SHIFT); 2252 /* Compute the energy of the previously decoded signal whose
2253 excitation we're copying */
2254 tmp = ROUND16(out_mem[c][-N+offset+i],SIG_SHIFT);
2218 S1 += SHR32(MULT16_16(tmp,tmp),8); 2255 S1 += SHR32(MULT16_16(tmp,tmp),8);
2219 } 2256 }
2257
2258 /* Copy the last decoded samples (prior to the overlap region) to
2259 synthesis filter memory so we can have a continuous signal. */
2220 for (i=0;i<LPC_ORDER;i++) 2260 for (i=0;i<LPC_ORDER;i++)
2221 mem[i] = ROUND16(out_mem[c][MAX_PERIOD-1-i], SIG_SHIFT); 2261 mem[i] = ROUND16(out_mem[c][MAX_PERIOD-N-1-i], SIG_SHIFT);
2222 for (i=0;i<len+st->mode->overlap;i++) 2262 /* Apply the fading if not the first loss */
2263 for (i=0;i<len;i++)
2223 e[i] = MULT16_32_Q15(fade, e[i]); 2264 e[i] = MULT16_32_Q15(fade, e[i]);
2224 celt_iir(e, lpc+c*LPC_ORDER, e, len+st->mode->overlap, LPC_ORDER, mem); 2265 /* Synthesis filter -- back in the signal domain */
2266 celt_iir(e, lpc+c*LPC_ORDER, e, len, LPC_ORDER, mem);
2225 2267
2268 /* Check if the synthesis energy is higher than expected, which can
2269 happen with the signal changes during our window. If so, attenuate. */
2226 { 2270 {
2227 opus_val32 S2=0; 2271 opus_val32 S2=0;
2228 for (i=0;i<len+overlap;i++) 2272 for (i=0;i<len;i++)
2229 { 2273 {
2230 opus_val16 tmp = ROUND16(e[i],SIG_SHIFT); 2274 opus_val16 tmp = ROUND16(e[i],SIG_SHIFT);
2231 S2 += SHR32(MULT16_16(tmp,tmp),8); 2275 S2 += SHR32(MULT16_16(tmp,tmp),8);
2232 } 2276 }
2233 /* This checks for an "explosion" in the synthesis */ 2277 /* This checks for an "explosion" in the synthesis */
2234 #ifdef FIXED_POINT 2278 #ifdef FIXED_POINT
2235 if (!(S1 > SHR32(S2,2))) 2279 if (!(S1 > SHR32(S2,2)))
2236 #else 2280 #else
2237 /* Float test is written this way to catch NaNs at the same time */ 2281 /* Float test is written this way to catch NaNs at the same time */
2238 if (!(S1 > 0.2f*S2)) 2282 if (!(S1 > 0.2f*S2))
2239 #endif 2283 #endif
2284 {
2285 for (i=0;i<len;i++)
2286 e[i] = 0;
2287 } else if (S1 < S2)
2288 {
2289 opus_val16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1));
2290 for (i=0;i<overlap;i++)
2240 { 2291 {
2241 for (i=0;i<len+overlap;i++) 2292 opus_val16 tmp_g = Q15ONE - MULT16_16_Q15(mode->window[i], Q15 ONE-ratio);
2242 e[i] = 0; 2293 e[i] = MULT16_32_Q15(tmp_g, e[i]);
2243 } else if (S1 < S2)
2244 {
2245 opus_val16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1));
2246 for (i=0;i<len+overlap;i++)
2247 e[i] = MULT16_32_Q15(ratio, e[i]);
2248 } 2294 }
2295 for (i=overlap;i<len;i++)
2296 e[i] = MULT16_32_Q15(ratio, e[i]);
2297 }
2249 } 2298 }
2250 2299
2251 /* Apply post-filter to the MDCT overlap of the previous frame */ 2300 /* Apply pre-filter to the MDCT overlap for the next frame because the
2252 comb_filter(out_mem[c]+MAX_PERIOD, out_mem[c]+MAX_PERIOD, st->postfilte r_period, st->postfilter_period, st->overlap, 2301 post-filter will be re-applied in the decoder after the MDCT overlap */
2253 st->postfilter_gain, st->postfilter_gain, st->postfilter_tapset, st->postfilter_tapset, 2302 comb_filter(etmp, out_mem[c]+MAX_PERIOD, st->postfilter_period, st->pos tfilter_period, st->overlap,
2303 -st->postfilter_gain, -st->postfilter_gain, st->postfilter_tapset , st->postfilter_tapset,
2254 NULL, 0); 2304 NULL, 0);
2255 2305
2256 for (i=0;i<MAX_PERIOD+st->mode->overlap-N;i++) 2306 /* Simulate TDAC on the concealed audio so that it blends with the
2257 out_mem[c][i] = out_mem[c][N+i]; 2307 MDCT of next frames. */
2258
2259 /* Apply TDAC to the concealed audio so that it blends with the
2260 previous and next frames */
2261 for (i=0;i<overlap/2;i++) 2308 for (i=0;i<overlap/2;i++)
2262 { 2309 {
2263 opus_val32 tmp; 2310 opus_val32 tmp;
2264 tmp = MULT16_32_Q15(st->mode->window[i], e[N+overlap-1-i]) + 2311 tmp = MULT16_32_Q15(mode->window[i], etmp[overlap-1-i]) +
2265 MULT16_32_Q15(st->mode->window[overlap-i-1], e[N+i ]) ; 2312 MULT16_32_Q15(mode->window[overlap-i-1], etmp[i ]);
2266 out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(st->mode->window[overlap-i- 1], tmp); 2313 out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(mode->window[overlap-i-1], tmp);
2267 out_mem[c][MAX_PERIOD+overlap-i-1] = MULT16_32_Q15(st->mode->window[ i], tmp); 2314 out_mem[c][MAX_PERIOD+overlap-i-1] = MULT16_32_Q15(mode->window[i], tmp);
2268 } 2315 }
2269 for (i=0;i<N;i++)
2270 out_mem[c][MAX_PERIOD-N+i] = e[i];
2271
2272 /* Apply pre-filter to the MDCT overlap for the next frame (post-filter will be applied then) */
2273 comb_filter(e, out_mem[c]+MAX_PERIOD, st->postfilter_period, st->postfi lter_period, st->overlap,
2274 -st->postfilter_gain, -st->postfilter_gain, st->postfilter_tapset , st->postfilter_tapset,
2275 NULL, 0);
2276 for (i=0;i<overlap;i++)
2277 out_mem[c][MAX_PERIOD+i] = e[i];
2278 } while (++c<C); 2316 } while (++c<C);
2279 } 2317 }
2280 2318
2281 deemphasis(out_syn, pcm, N, C, st->downsample, st->mode->preemph, st->preemph _memD); 2319 deemphasis(out_syn, pcm, N, C, st->downsample, mode->preemph, st->preemph_mem D);
2282 2320
2283 st->loss_count++; 2321 st->loss_count++;
2284 2322
2285 RESTORE_STACK; 2323 RESTORE_STACK;
2286 } 2324 }
2287 2325
2288 int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat a, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec) 2326 int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat a, int len, opus_val16 * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec)
2289 { 2327 {
2290 int c, i, N; 2328 int c, i, N;
2291 int spread_decision; 2329 int spread_decision;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 2418
2381 if (len<0 || len>1275 || pcm==NULL) 2419 if (len<0 || len>1275 || pcm==NULL)
2382 return OPUS_BAD_ARG; 2420 return OPUS_BAD_ARG;
2383 2421
2384 N = M*st->mode->shortMdctSize; 2422 N = M*st->mode->shortMdctSize;
2385 2423
2386 effEnd = st->end; 2424 effEnd = st->end;
2387 if (effEnd > st->mode->effEBands) 2425 if (effEnd > st->mode->effEBands)
2388 effEnd = st->mode->effEBands; 2426 effEnd = st->mode->effEBands;
2389 2427
2428 if (data == NULL || len<=1)
2429 {
2430 celt_decode_lost(st, pcm, N, LM);
2431 RESTORE_STACK;
2432 return frame_size/st->downsample;
2433 }
2434
2390 ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */ 2435 ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */
2391 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ 2436 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
2392 ALLOC(bandE, st->mode->nbEBands*C, celt_ener); 2437 ALLOC(bandE, st->mode->nbEBands*C, celt_ener);
2393 c=0; do 2438 c=0; do
2394 for (i=0;i<M*st->mode->eBands[st->start];i++) 2439 for (i=0;i<M*st->mode->eBands[st->start];i++)
2395 X[c*N+i] = 0; 2440 X[c*N+i] = 0;
2396 while (++c<C); 2441 while (++c<C);
2397 c=0; do 2442 c=0; do
2398 for (i=M*st->mode->eBands[effEnd];i<N;i++) 2443 for (i=M*st->mode->eBands[effEnd];i<N;i++)
2399 X[c*N+i] = 0; 2444 X[c*N+i] = 0;
2400 while (++c<C); 2445 while (++c<C);
2401 2446
2402 if (data == NULL || len<=1)
2403 {
2404 celt_decode_lost(st, pcm, N, LM);
2405 RESTORE_STACK;
2406 return frame_size/st->downsample;
2407 }
2408
2409 if (dec == NULL) 2447 if (dec == NULL)
2410 { 2448 {
2411 ec_dec_init(&_dec,(unsigned char*)data,len); 2449 ec_dec_init(&_dec,(unsigned char*)data,len);
2412 dec = &_dec; 2450 dec = &_dec;
2413 } 2451 }
2414 2452
2415 if (C==1) 2453 if (C==1)
2416 { 2454 {
2417 for (i=0;i<st->mode->nbEBands;i++) 2455 for (i=0;i<st->mode->nbEBands;i++)
2418 oldBandE[i]=MAX16(oldBandE[i],oldBandE[st->mode->nbEBands+i]); 2456 oldBandE[i]=MAX16(oldBandE[i],oldBandE[st->mode->nbEBands+i]);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 } 2831 }
2794 break; 2832 break;
2795 case OPUS_GET_PITCH_REQUEST: 2833 case OPUS_GET_PITCH_REQUEST:
2796 { 2834 {
2797 opus_int32 *value = va_arg(ap, opus_int32*); 2835 opus_int32 *value = va_arg(ap, opus_int32*);
2798 if (value==NULL) 2836 if (value==NULL)
2799 goto bad_arg; 2837 goto bad_arg;
2800 *value = st->postfilter_period; 2838 *value = st->postfilter_period;
2801 } 2839 }
2802 break; 2840 break;
2803 #ifdef OPUS_BUILD
2804 case CELT_GET_MODE_REQUEST: 2841 case CELT_GET_MODE_REQUEST:
2805 { 2842 {
2806 const CELTMode ** value = va_arg(ap, const CELTMode**); 2843 const CELTMode ** value = va_arg(ap, const CELTMode**);
2807 if (value==0) 2844 if (value==0)
2808 goto bad_arg; 2845 goto bad_arg;
2809 *value=st->mode; 2846 *value=st->mode;
2810 } 2847 }
2811 break; 2848 break;
2812 case CELT_SET_SIGNALLING_REQUEST: 2849 case CELT_SET_SIGNALLING_REQUEST:
2813 { 2850 {
2814 opus_int32 value = va_arg(ap, opus_int32); 2851 opus_int32 value = va_arg(ap, opus_int32);
2815 st->signalling = value; 2852 st->signalling = value;
2816 } 2853 }
2817 break; 2854 break;
2818 case OPUS_GET_FINAL_RANGE_REQUEST: 2855 case OPUS_GET_FINAL_RANGE_REQUEST:
2819 { 2856 {
2820 opus_uint32 * value = va_arg(ap, opus_uint32 *); 2857 opus_uint32 * value = va_arg(ap, opus_uint32 *);
2821 if (value==0) 2858 if (value==0)
2822 goto bad_arg; 2859 goto bad_arg;
2823 *value=st->rng; 2860 *value=st->rng;
2824 } 2861 }
2825 break; 2862 break;
2826 #endif
2827 default: 2863 default:
2828 goto bad_request; 2864 goto bad_request;
2829 } 2865 }
2830 va_end(ap); 2866 va_end(ap);
2831 return OPUS_OK; 2867 return OPUS_OK;
2832 bad_arg: 2868 bad_arg:
2833 va_end(ap); 2869 va_end(ap);
2834 return OPUS_BAD_ARG; 2870 return OPUS_BAD_ARG;
2835 bad_request: 2871 bad_request:
2836 va_end(ap); 2872 va_end(ap);
(...skipping 24 matching lines...) Expand all
2861 { 2897 {
2862 return "libopus " OPUS_VERSION 2898 return "libopus " OPUS_VERSION
2863 #ifdef FIXED_POINT 2899 #ifdef FIXED_POINT
2864 "-fixed" 2900 "-fixed"
2865 #endif 2901 #endif
2866 #ifdef FUZZING 2902 #ifdef FUZZING
2867 "-fuzzing" 2903 "-fuzzing"
2868 #endif 2904 #endif
2869 ; 2905 ;
2870 } 2906 }
OLDNEW
« no previous file with comments | « celt/bands.c ('k') | celt/cwrs.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698