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

Side by Side Diff: third_party/opus/src/celt/celt_encoder.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_decoder.c ('k') | third_party/opus/src/celt/celt_lpc.h » ('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 int complexity; 66 int complexity;
67 int upsample; 67 int upsample;
68 int start, end; 68 int start, end;
69 69
70 opus_int32 bitrate; 70 opus_int32 bitrate;
71 int vbr; 71 int vbr;
72 int signalling; 72 int signalling;
73 int constrained_vbr; /* If zero, VBR can do whatever it likes with the r ate */ 73 int constrained_vbr; /* If zero, VBR can do whatever it likes with the r ate */
74 int loss_rate; 74 int loss_rate;
75 int lsb_depth; 75 int lsb_depth;
76 int variable_duration;
77 int lfe; 76 int lfe;
77 int disable_inv;
78 int arch; 78 int arch;
79 79
80 /* Everything beyond this point gets cleared on a reset */ 80 /* Everything beyond this point gets cleared on a reset */
81 #define ENCODER_RESET_START rng 81 #define ENCODER_RESET_START rng
82 82
83 opus_uint32 rng; 83 opus_uint32 rng;
84 int spread_decision; 84 int spread_decision;
85 opus_val32 delayedIntra; 85 opus_val32 delayedIntra;
86 int tonal_average; 86 int tonal_average;
87 int lastCodedBands; 87 int lastCodedBands;
88 int hf_average; 88 int hf_average;
89 int tapset_decision; 89 int tapset_decision;
90 90
91 int prefilter_period; 91 int prefilter_period;
92 opus_val16 prefilter_gain; 92 opus_val16 prefilter_gain;
93 int prefilter_tapset; 93 int prefilter_tapset;
94 #ifdef RESYNTH 94 #ifdef RESYNTH
95 int prefilter_period_old; 95 int prefilter_period_old;
96 opus_val16 prefilter_gain_old; 96 opus_val16 prefilter_gain_old;
97 int prefilter_tapset_old; 97 int prefilter_tapset_old;
98 #endif 98 #endif
99 int consec_transient; 99 int consec_transient;
100 AnalysisInfo analysis; 100 AnalysisInfo analysis;
101 SILKInfo silk_info;
101 102
102 opus_val32 preemph_memE[2]; 103 opus_val32 preemph_memE[2];
103 opus_val32 preemph_memD[2]; 104 opus_val32 preemph_memD[2];
104 105
105 /* VBR-related parameters */ 106 /* VBR-related parameters */
106 opus_int32 vbr_reservoir; 107 opus_int32 vbr_reservoir;
107 opus_int32 vbr_drift; 108 opus_int32 vbr_drift;
108 opus_int32 vbr_offset; 109 opus_int32 vbr_offset;
109 opus_int32 vbr_count; 110 opus_int32 vbr_count;
110 opus_val32 overlap_max; 111 opus_val32 overlap_max;
111 opus_val16 stereo_saving; 112 opus_val16 stereo_saving;
112 int intensity; 113 int intensity;
113 opus_val16 *energy_mask; 114 opus_val16 *energy_mask;
114 opus_val16 spec_avg; 115 opus_val16 spec_avg;
115 116
116 #ifdef RESYNTH 117 #ifdef RESYNTH
117 /* +MAX_PERIOD/2 to make space for overlap */ 118 /* +MAX_PERIOD/2 to make space for overlap */
118 celt_sig syn_mem[2][2*MAX_PERIOD+MAX_PERIOD/2]; 119 celt_sig syn_mem[2][2*MAX_PERIOD+MAX_PERIOD/2];
119 #endif 120 #endif
120 121
121 celt_sig in_mem[1]; /* Size = channels*mode->overlap */ 122 celt_sig in_mem[1]; /* Size = channels*mode->overlap */
122 /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */ 123 /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */
123 /* opus_val16 oldBandE[], Size = channels*mode->nbEBands */ 124 /* opus_val16 oldBandE[], Size = channels*mode->nbEBands */
124 /* opus_val16 oldLogE[], Size = channels*mode->nbEBands */ 125 /* opus_val16 oldLogE[], Size = channels*mode->nbEBands */
125 /* opus_val16 oldLogE2[], Size = channels*mode->nbEBands */ 126 /* opus_val16 oldLogE2[], Size = channels*mode->nbEBands */
127 /* opus_val16 energyError[], Size = channels*mode->nbEBands */
126 }; 128 };
127 129
128 int celt_encoder_get_size(int channels) 130 int celt_encoder_get_size(int channels)
129 { 131 {
130 CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); 132 CELTMode *mode = opus_custom_mode_create(48000, 960, NULL);
131 return opus_custom_encoder_get_size(mode, channels); 133 return opus_custom_encoder_get_size(mode, channels);
132 } 134 }
133 135
134 OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) 136 OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels)
135 { 137 {
136 int size = sizeof(struct CELTEncoder) 138 int size = sizeof(struct CELTEncoder)
137 + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[cha nnels*mode->overlap]; */ 139 + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[cha nnels*mode->overlap]; */
138 + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) /* celt_sig prefilter_ mem[channels*COMBFILTER_MAXPERIOD]; */ 140 + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) /* celt_sig prefilter_ mem[channels*COMBFILTER_MAXPERIOD]; */
139 + 3*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE [channels*mode->nbEBands]; */ 141 + 4*channels*mode->nbEBands*sizeof(opus_val16); /* opus_val16 oldBandE [channels*mode->nbEBands]; */
140 /* opus_val16 oldLogE[ channels*mode->nbEBands]; */ 142 /* opus_val16 oldLogE[ channels*mode->nbEBands]; */
141 /* opus_val16 oldLogE2 [channels*mode->nbEBands]; */ 143 /* opus_val16 oldLogE2 [channels*mode->nbEBands]; */
144 /* opus_val16 energyEr ror[channels*mode->nbEBands]; */
142 return size; 145 return size;
143 } 146 }
144 147
145 #ifdef CUSTOM_MODES 148 #ifdef CUSTOM_MODES
146 CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error) 149 CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error)
147 { 150 {
148 int ret; 151 int ret;
149 CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode , channels)); 152 CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode , channels));
150 /* init will handle the NULL case */ 153 /* init will handle the NULL case */
151 ret = opus_custom_encoder_init(st, mode, channels); 154 ret = opus_custom_encoder_init(st, mode, channels);
(...skipping 19 matching lines...) Expand all
171 174
172 OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, channels)); 175 OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, channels));
173 176
174 st->mode = mode; 177 st->mode = mode;
175 st->stream_channels = st->channels = channels; 178 st->stream_channels = st->channels = channels;
176 179
177 st->upsample = 1; 180 st->upsample = 1;
178 st->start = 0; 181 st->start = 0;
179 st->end = st->mode->effEBands; 182 st->end = st->mode->effEBands;
180 st->signalling = 1; 183 st->signalling = 1;
181
182 st->arch = arch; 184 st->arch = arch;
183 185
184 st->constrained_vbr = 1; 186 st->constrained_vbr = 1;
185 st->clip = 1; 187 st->clip = 1;
186 188
187 st->bitrate = OPUS_BITRATE_MAX; 189 st->bitrate = OPUS_BITRATE_MAX;
188 st->vbr = 0; 190 st->vbr = 0;
189 st->force_intra = 0; 191 st->force_intra = 0;
190 st->complexity = 5; 192 st->complexity = 5;
191 st->lsb_depth=24; 193 st->lsb_depth=24;
(...skipping 24 matching lines...) Expand all
216 218
217 #ifdef CUSTOM_MODES 219 #ifdef CUSTOM_MODES
218 void opus_custom_encoder_destroy(CELTEncoder *st) 220 void opus_custom_encoder_destroy(CELTEncoder *st)
219 { 221 {
220 opus_free(st); 222 opus_free(st);
221 } 223 }
222 #endif /* CUSTOM_MODES */ 224 #endif /* CUSTOM_MODES */
223 225
224 226
225 static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int C, 227 static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int C,
226 opus_val16 *tf_estimate, int *tf_chan) 228 opus_val16 *tf_estimate, int *tf_chan, int allow_w eak_transients,
229 int *weak_transient)
227 { 230 {
228 int i; 231 int i;
229 VARDECL(opus_val16, tmp); 232 VARDECL(opus_val16, tmp);
230 opus_val32 mem0,mem1; 233 opus_val32 mem0,mem1;
231 int is_transient = 0; 234 int is_transient = 0;
232 opus_int32 mask_metric = 0; 235 opus_int32 mask_metric = 0;
233 int c; 236 int c;
234 opus_val16 tf_max; 237 opus_val16 tf_max;
235 int len2; 238 int len2;
239 /* Forward masking: 6.7 dB/ms. */
240 #ifdef FIXED_POINT
241 int forward_shift = 4;
242 #else
243 opus_val16 forward_decay = QCONST16(.0625f,15);
244 #endif
236 /* Table of 6*64/x, trained on real data to minimize the average error */ 245 /* Table of 6*64/x, trained on real data to minimize the average error */
237 static const unsigned char inv_table[128] = { 246 static const unsigned char inv_table[128] = {
238 255,255,156,110, 86, 70, 59, 51, 45, 40, 37, 33, 31, 28, 26, 25, 247 255,255,156,110, 86, 70, 59, 51, 45, 40, 37, 33, 31, 28, 26, 25,
239 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, 248 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12,
240 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 249 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8,
241 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 250 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6,
242 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 251 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5,
243 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 252 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
244 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 253 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3,
245 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 254 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2,
246 }; 255 };
247 SAVE_STACK; 256 SAVE_STACK;
248 ALLOC(tmp, len, opus_val16); 257 ALLOC(tmp, len, opus_val16);
249 258
259 *weak_transient = 0;
260 /* For lower bitrates, let's be more conservative and have a forward masking
261 decay of 3.3 dB/ms. This avoids having to code transients at very low
262 bitrate (mostly for hybrid), which can result in unstable energy and/or
263 partial collapse. */
264 if (allow_weak_transients)
265 {
266 #ifdef FIXED_POINT
267 forward_shift = 5;
268 #else
269 forward_decay = QCONST16(.03125f,15);
270 #endif
271 }
250 len2=len/2; 272 len2=len/2;
251 for (c=0;c<C;c++) 273 for (c=0;c<C;c++)
252 { 274 {
253 opus_val32 mean; 275 opus_val32 mean;
254 opus_int32 unmask=0; 276 opus_int32 unmask=0;
255 opus_val32 norm; 277 opus_val32 norm;
256 opus_val16 maxE; 278 opus_val16 maxE;
257 mem0=0; 279 mem0=0;
258 mem1=0; 280 mem1=0;
259 /* High-pass filter: (1 - 2*z^-1 + z^-2) / (1 - z^-1 + .5*z^-2) */ 281 /* High-pass filter: (1 - 2*z^-1 + z^-2) / (1 - z^-1 + .5*z^-2) */
260 for (i=0;i<len;i++) 282 for (i=0;i<len;i++)
261 { 283 {
262 opus_val32 x,y; 284 opus_val32 x,y;
263 x = SHR32(in[i+c*len],SIG_SHIFT); 285 x = SHR32(in[i+c*len],SIG_SHIFT);
264 y = ADD32(mem0, x); 286 y = ADD32(mem0, x);
265 #ifdef FIXED_POINT 287 #ifdef FIXED_POINT
266 mem0 = mem1 + y - SHL32(x,1); 288 mem0 = mem1 + y - SHL32(x,1);
267 mem1 = x - SHR32(y,1); 289 mem1 = x - SHR32(y,1);
268 #else 290 #else
269 mem0 = mem1 + y - 2*x; 291 mem0 = mem1 + y - 2*x;
270 mem1 = x - .5f*y; 292 mem1 = x - .5f*y;
271 #endif 293 #endif
272 tmp[i] = EXTRACT16(SHR32(y,2)); 294 tmp[i] = SROUND16(y, 2);
273 /*printf("%f ", tmp[i]);*/ 295 /*printf("%f ", tmp[i]);*/
274 } 296 }
275 /*printf("\n");*/ 297 /*printf("\n");*/
276 /* First few samples are bad because we don't propagate the memory */ 298 /* First few samples are bad because we don't propagate the memory */
277 OPUS_CLEAR(tmp, 12); 299 OPUS_CLEAR(tmp, 12);
278 300
279 #ifdef FIXED_POINT 301 #ifdef FIXED_POINT
280 /* Normalize tmp to max range */ 302 /* Normalize tmp to max range */
281 { 303 {
282 int shift=0; 304 int shift=0;
283 shift = 14-celt_ilog2(1+celt_maxabs16(tmp, len)); 305 shift = 14-celt_ilog2(MAX16(1, celt_maxabs16(tmp, len)));
284 if (shift!=0) 306 if (shift!=0)
285 { 307 {
286 for (i=0;i<len;i++) 308 for (i=0;i<len;i++)
287 tmp[i] = SHL16(tmp[i], shift); 309 tmp[i] = SHL16(tmp[i], shift);
288 } 310 }
289 } 311 }
290 #endif 312 #endif
291 313
292 mean=0; 314 mean=0;
293 mem0=0; 315 mem0=0;
294 /* Grouping by two to reduce complexity */ 316 /* Grouping by two to reduce complexity */
295 /* Forward pass to compute the post-echo threshold*/ 317 /* Forward pass to compute the post-echo threshold*/
296 for (i=0;i<len2;i++) 318 for (i=0;i<len2;i++)
297 { 319 {
298 opus_val16 x2 = PSHR32(MULT16_16(tmp[2*i],tmp[2*i]) + MULT16_16(tmp[2*i +1],tmp[2*i+1]),16); 320 opus_val16 x2 = PSHR32(MULT16_16(tmp[2*i],tmp[2*i]) + MULT16_16(tmp[2*i +1],tmp[2*i+1]),16);
299 mean += x2; 321 mean += x2;
300 #ifdef FIXED_POINT 322 #ifdef FIXED_POINT
301 /* FIXME: Use PSHR16() instead */ 323 /* FIXME: Use PSHR16() instead */
302 tmp[i] = mem0 + PSHR32(x2-mem0,4); 324 tmp[i] = mem0 + PSHR32(x2-mem0,forward_shift);
303 #else 325 #else
304 tmp[i] = mem0 + MULT16_16_P15(QCONST16(.0625f,15),x2-mem0); 326 tmp[i] = mem0 + MULT16_16_P15(forward_decay,x2-mem0);
305 #endif 327 #endif
306 mem0 = tmp[i]; 328 mem0 = tmp[i];
307 } 329 }
308 330
309 mem0=0; 331 mem0=0;
310 maxE=0; 332 maxE=0;
311 /* Backward pass to compute the pre-echo threshold */ 333 /* Backward pass to compute the pre-echo threshold */
312 for (i=len2-1;i>=0;i--) 334 for (i=len2-1;i>=0;i--)
313 { 335 {
336 /* Backward masking: 13.9 dB/ms. */
314 #ifdef FIXED_POINT 337 #ifdef FIXED_POINT
315 /* FIXME: Use PSHR16() instead */ 338 /* FIXME: Use PSHR16() instead */
316 tmp[i] = mem0 + PSHR32(tmp[i]-mem0,3); 339 tmp[i] = mem0 + PSHR32(tmp[i]-mem0,3);
317 #else 340 #else
318 tmp[i] = mem0 + MULT16_16_P15(QCONST16(0.125f,15),tmp[i]-mem0); 341 tmp[i] = mem0 + MULT16_16_P15(QCONST16(0.125f,15),tmp[i]-mem0);
319 #endif 342 #endif
320 mem0 = tmp[i]; 343 mem0 = tmp[i];
321 maxE = MAX16(maxE, mem0); 344 maxE = MAX16(maxE, mem0);
322 } 345 }
323 /*for (i=0;i<len2;i++)printf("%f ", tmp[i]/mean);printf("\n");*/ 346 /*for (i=0;i<len2;i++)printf("%f ", tmp[i]/mean);printf("\n");*/
(...skipping 28 matching lines...) Expand all
352 /*printf("%d\n", unmask);*/ 375 /*printf("%d\n", unmask);*/
353 /* Normalize, compensate for the 1/4th of the sample and the factor of 6 i n the inverse table */ 376 /* Normalize, compensate for the 1/4th of the sample and the factor of 6 i n the inverse table */
354 unmask = 64*unmask*4/(6*(len2-17)); 377 unmask = 64*unmask*4/(6*(len2-17));
355 if (unmask>mask_metric) 378 if (unmask>mask_metric)
356 { 379 {
357 *tf_chan = c; 380 *tf_chan = c;
358 mask_metric = unmask; 381 mask_metric = unmask;
359 } 382 }
360 } 383 }
361 is_transient = mask_metric>200; 384 is_transient = mask_metric>200;
362 385 /* For low bitrates, define "weak transients" that need to be
386 handled differently to avoid partial collapse. */
387 if (allow_weak_transients && is_transient && mask_metric<600) {
388 is_transient = 0;
389 *weak_transient = 1;
390 }
363 /* Arbitrary metric for VBR boost */ 391 /* Arbitrary metric for VBR boost */
364 tf_max = MAX16(0,celt_sqrt(27*mask_metric)-42); 392 tf_max = MAX16(0,celt_sqrt(27*mask_metric)-42);
365 /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */ 393 /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */
366 *tf_estimate = celt_sqrt(MAX32(0, SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(1 63,tf_max)),14)-QCONST32(0.139,28))); 394 *tf_estimate = celt_sqrt(MAX32(0, SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(1 63,tf_max)),14)-QCONST32(0.139,28)));
367 /*printf("%d %f\n", tf_max, mask_metric);*/ 395 /*printf("%d %f\n", tf_max, mask_metric);*/
368 RESTORE_STACK; 396 RESTORE_STACK;
369 #ifdef FUZZING 397 #ifdef FUZZING
370 is_transient = rand()&0x1; 398 is_transient = rand()&0x1;
371 #endif 399 #endif
372 /*printf("%d %f %d\n", is_transient, (float)*tf_estimate, tf_max);*/ 400 /*printf("%d %f %d\n", is_transient, (float)*tf_estimate, tf_max);*/
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 for (i=0;i<N;i++) 570 for (i=0;i<N;i++)
543 L1 += EXTEND32(ABS16(tmp[i])); 571 L1 += EXTEND32(ABS16(tmp[i]));
544 /* When in doubt, prefer good freq resolution */ 572 /* When in doubt, prefer good freq resolution */
545 L1 = MAC16_32_Q15(L1, LM*bias, L1); 573 L1 = MAC16_32_Q15(L1, LM*bias, L1);
546 return L1; 574 return L1;
547 575
548 } 576 }
549 577
550 static int tf_analysis(const CELTMode *m, int len, int isTransient, 578 static int tf_analysis(const CELTMode *m, int len, int isTransient,
551 int *tf_res, int lambda, celt_norm *X, int N0, int LM, 579 int *tf_res, int lambda, celt_norm *X, int N0, int LM,
552 int *tf_sum, opus_val16 tf_estimate, int tf_chan) 580 opus_val16 tf_estimate, int tf_chan)
553 { 581 {
554 int i; 582 int i;
555 VARDECL(int, metric); 583 VARDECL(int, metric);
556 int cost0; 584 int cost0;
557 int cost1; 585 int cost1;
558 VARDECL(int, path0); 586 VARDECL(int, path0);
559 VARDECL(int, path1); 587 VARDECL(int, path1);
560 VARDECL(celt_norm, tmp); 588 VARDECL(celt_norm, tmp);
561 VARDECL(celt_norm, tmp_1); 589 VARDECL(celt_norm, tmp_1);
562 int sel; 590 int sel;
563 int selcost[2]; 591 int selcost[2];
564 int tf_select=0; 592 int tf_select=0;
565 opus_val16 bias; 593 opus_val16 bias;
566 594
567 SAVE_STACK; 595 SAVE_STACK;
568 bias = MULT16_16_Q14(QCONST16(.04f,15), MAX16(-QCONST16(.25f,14), QCONST16(.5 f,14)-tf_estimate)); 596 bias = MULT16_16_Q14(QCONST16(.04f,15), MAX16(-QCONST16(.25f,14), QCONST16(.5 f,14)-tf_estimate));
569 /*printf("%f ", bias);*/ 597 /*printf("%f ", bias);*/
570 598
571 ALLOC(metric, len, int); 599 ALLOC(metric, len, int);
572 ALLOC(tmp, (m->eBands[len]-m->eBands[len-1])<<LM, celt_norm); 600 ALLOC(tmp, (m->eBands[len]-m->eBands[len-1])<<LM, celt_norm);
573 ALLOC(tmp_1, (m->eBands[len]-m->eBands[len-1])<<LM, celt_norm); 601 ALLOC(tmp_1, (m->eBands[len]-m->eBands[len-1])<<LM, celt_norm);
574 ALLOC(path0, len, int); 602 ALLOC(path0, len, int);
575 ALLOC(path1, len, int); 603 ALLOC(path1, len, int);
576 604
577 *tf_sum = 0;
578 for (i=0;i<len;i++) 605 for (i=0;i<len;i++)
579 { 606 {
580 int k, N; 607 int k, N;
581 int narrow; 608 int narrow;
582 opus_val32 L1, best_L1; 609 opus_val32 L1, best_L1;
583 int best_level=0; 610 int best_level=0;
584 N = (m->eBands[i+1]-m->eBands[i])<<LM; 611 N = (m->eBands[i+1]-m->eBands[i])<<LM;
585 /* band is too narrow to be split down to LM=-1 */ 612 /* band is too narrow to be split down to LM=-1 */
586 narrow = (m->eBands[i+1]-m->eBands[i])==1; 613 narrow = (m->eBands[i+1]-m->eBands[i])==1;
587 OPUS_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<<LM)], N); 614 OPUS_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<<LM)], N);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 best_L1 = L1; 649 best_L1 = L1;
623 best_level = k+1; 650 best_level = k+1;
624 } 651 }
625 } 652 }
626 /*printf ("%d ", isTransient ? LM-best_level : best_level);*/ 653 /*printf ("%d ", isTransient ? LM-best_level : best_level);*/
627 /* metric is in Q1 to be able to select the mid-point (-0.5) for narrower bands */ 654 /* metric is in Q1 to be able to select the mid-point (-0.5) for narrower bands */
628 if (isTransient) 655 if (isTransient)
629 metric[i] = 2*best_level; 656 metric[i] = 2*best_level;
630 else 657 else
631 metric[i] = -2*best_level; 658 metric[i] = -2*best_level;
632 *tf_sum += (isTransient ? LM : 0) - metric[i]/2;
633 /* For bands that can't be split to -1, set the metric to the half-way poi nt to avoid 659 /* For bands that can't be split to -1, set the metric to the half-way poi nt to avoid
634 biasing the decision */ 660 biasing the decision */
635 if (narrow && (metric[i]==0 || metric[i]==-2*LM)) 661 if (narrow && (metric[i]==0 || metric[i]==-2*LM))
636 metric[i]-=1; 662 metric[i]-=1;
637 /*printf("%d ", metric[i]);*/ 663 /*printf("%d ", metric[i]);*/
638 } 664 }
639 /*printf("\n");*/ 665 /*printf("\n");*/
640 /* Search for the optimal tf resolution, including tf_select */ 666 /* Search for the optimal tf resolution, including tf_select */
641 tf_select = 0; 667 tf_select = 0;
642 for (sel=0;sel<2;sel++) 668 for (sel=0;sel<2;sel++)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 tf_select = 0; 773 tf_select = 0;
748 for (i=start;i<end;i++) 774 for (i=start;i<end;i++)
749 tf_res[i] = tf_select_table[LM][4*isTransient+2*tf_select+tf_res[i]]; 775 tf_res[i] = tf_select_table[LM][4*isTransient+2*tf_select+tf_res[i]];
750 /*for(i=0;i<end;i++)printf("%d ", isTransient ? tf_res[i] : LM+tf_res[i]);pri ntf("\n");*/ 776 /*for(i=0;i<end;i++)printf("%d ", isTransient ? tf_res[i] : LM+tf_res[i]);pri ntf("\n");*/
751 } 777 }
752 778
753 779
754 static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, 780 static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
755 const opus_val16 *bandLogE, int end, int LM, int C, int N0, 781 const opus_val16 *bandLogE, int end, int LM, int C, int N0,
756 AnalysisInfo *analysis, opus_val16 *stereo_saving, opus_val16 tf_estimate, 782 AnalysisInfo *analysis, opus_val16 *stereo_saving, opus_val16 tf_estimate,
757 int intensity, opus_val16 surround_trim, int arch) 783 int intensity, opus_val16 surround_trim, opus_int32 equiv_rate, int arch)
758 { 784 {
759 int i; 785 int i;
760 opus_val32 diff=0; 786 opus_val32 diff=0;
761 int c; 787 int c;
762 int trim_index; 788 int trim_index;
763 opus_val16 trim = QCONST16(5.f, 8); 789 opus_val16 trim = QCONST16(5.f, 8);
764 opus_val16 logXC, logXC2; 790 opus_val16 logXC, logXC2;
791 /* At low bitrate, reducing the trim seems to help. At higher bitrates, it's less
792 clear what's best, so we're keeping it as it was before, at least for now. */
793 if (equiv_rate < 64000) {
794 trim = QCONST16(4.f, 8);
795 } else if (equiv_rate < 80000) {
796 opus_int32 frac = (equiv_rate-64000) >> 10;
797 trim = QCONST16(4.f, 8) + QCONST16(1.f/16.f, 8)*frac;
798 }
765 if (C==2) 799 if (C==2)
766 { 800 {
767 opus_val16 sum = 0; /* Q10 */ 801 opus_val16 sum = 0; /* Q10 */
768 opus_val16 minXC; /* Q10 */ 802 opus_val16 minXC; /* Q10 */
769 /* Compute inter-channel correlation for low frequencies */ 803 /* Compute inter-channel correlation for low frequencies */
770 for (i=0;i<8;i++) 804 for (i=0;i<8;i++)
771 { 805 {
772 opus_val32 partial; 806 opus_val32 partial;
773 partial = celt_inner_prod(&X[m->eBands[i]<<LM], &X[N0+(m->eBands[i]<<LM )], 807 partial = celt_inner_prod(&X[m->eBands[i]<<LM], &X[N0+(m->eBands[i]<<LM )],
774 (m->eBands[i+1]-m->eBands[i])<<LM, arch); 808 (m->eBands[i+1]-m->eBands[i])<<LM, arch);
(...skipping 27 matching lines...) Expand all
802 836
803 /* Estimate spectral tilt */ 837 /* Estimate spectral tilt */
804 c=0; do { 838 c=0; do {
805 for (i=0;i<end-1;i++) 839 for (i=0;i<end-1;i++)
806 { 840 {
807 diff += bandLogE[i+c*m->nbEBands]*(opus_int32)(2+2*i-end); 841 diff += bandLogE[i+c*m->nbEBands]*(opus_int32)(2+2*i-end);
808 } 842 }
809 } while (++c<C); 843 } while (++c<C);
810 diff /= C*(end-1); 844 diff /= C*(end-1);
811 /*printf("%f\n", diff);*/ 845 /*printf("%f\n", diff);*/
812 trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), SHR16(diff+QCONST16( 1.f, DB_SHIFT),DB_SHIFT-8)/6 )); 846 trim -= MAX32(-QCONST16(2.f, 8), MIN32(QCONST16(2.f, 8), SHR32(diff+QCONST16( 1.f, DB_SHIFT),DB_SHIFT-8)/6 ));
813 trim -= SHR16(surround_trim, DB_SHIFT-8); 847 trim -= SHR16(surround_trim, DB_SHIFT-8);
814 trim -= 2*SHR16(tf_estimate, 14-8); 848 trim -= 2*SHR16(tf_estimate, 14-8);
815 #ifndef DISABLE_FLOAT_API 849 #ifndef DISABLE_FLOAT_API
816 if (analysis->valid) 850 if (analysis->valid)
817 { 851 {
818 trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), 852 trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8),
819 (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); 853 (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f))));
820 } 854 }
821 #else 855 #else
822 (void)analysis; 856 (void)analysis;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 return t1; 957 return t1;
924 else if (t0 < t2) 958 else if (t0 < t2)
925 return t2; 959 return t2;
926 else 960 else
927 return t0; 961 return t0;
928 } 962 }
929 963
930 static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 *bandLogE2, 964 static opus_val16 dynalloc_analysis(const opus_val16 *bandLogE, const opus_val16 *bandLogE2,
931 int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, cons t opus_int16 *logN, 965 int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, cons t opus_int16 *logN,
932 int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, i nt LM, 966 int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, i nt LM,
933 int effectiveBytes, opus_int32 *tot_boost_, int lfe, opus_val16 *surround_ dynalloc) 967 int effectiveBytes, opus_int32 *tot_boost_, int lfe, opus_val16 *surround_ dynalloc, AnalysisInfo *analysis)
934 { 968 {
935 int i, c; 969 int i, c;
936 opus_int32 tot_boost=0; 970 opus_int32 tot_boost=0;
937 opus_val16 maxDepth; 971 opus_val16 maxDepth;
938 VARDECL(opus_val16, follower); 972 VARDECL(opus_val16, follower);
939 VARDECL(opus_val16, noise_floor); 973 VARDECL(opus_val16, noise_floor);
940 SAVE_STACK; 974 SAVE_STACK;
941 ALLOC(follower, C*nbEBands, opus_val16); 975 ALLOC(follower, C*nbEBands, opus_val16);
942 ALLOC(noise_floor, C*nbEBands, opus_val16); 976 ALLOC(noise_floor, C*nbEBands, opus_val16);
943 OPUS_CLEAR(offsets, nbEBands); 977 OPUS_CLEAR(offsets, nbEBands);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 for (i=start;i<end;i++) 1047 for (i=start;i<end;i++)
1014 follower[i] = MAX16(follower[i], surround_dynalloc[i]); 1048 follower[i] = MAX16(follower[i], surround_dynalloc[i]);
1015 /* For non-transient CBR/CVBR frames, halve the dynalloc contribution */ 1049 /* For non-transient CBR/CVBR frames, halve the dynalloc contribution */
1016 if ((!vbr || constrained_vbr)&&!isTransient) 1050 if ((!vbr || constrained_vbr)&&!isTransient)
1017 { 1051 {
1018 for (i=start;i<end;i++) 1052 for (i=start;i<end;i++)
1019 follower[i] = HALF16(follower[i]); 1053 follower[i] = HALF16(follower[i]);
1020 } 1054 }
1021 for (i=start;i<end;i++) 1055 for (i=start;i<end;i++)
1022 { 1056 {
1057 if (i<8)
1058 follower[i] *= 2;
1059 if (i>=12)
1060 follower[i] = HALF16(follower[i]);
1061 }
1062 #ifdef DISABLE_FLOAT_API
1063 (void)analysis;
1064 #else
1065 if (analysis->valid)
1066 {
1067 for (i=start;i<IMIN(LEAK_BANDS, end);i++)
1068 follower[i] = follower[i] + QCONST16(1.f/64.f, DB_SHIFT)*analysis-> leak_boost[i];
1069 }
1070 #endif
1071 for (i=start;i<end;i++)
1072 {
1023 int width; 1073 int width;
1024 int boost; 1074 int boost;
1025 int boost_bits; 1075 int boost_bits;
1026 1076
1027 if (i<8)
1028 follower[i] *= 2;
1029 if (i>=12)
1030 follower[i] = HALF16(follower[i]);
1031 follower[i] = MIN16(follower[i], QCONST16(4, DB_SHIFT)); 1077 follower[i] = MIN16(follower[i], QCONST16(4, DB_SHIFT));
1032 1078
1033 width = C*(eBands[i+1]-eBands[i])<<LM; 1079 width = C*(eBands[i+1]-eBands[i])<<LM;
1034 if (width<6) 1080 if (width<6)
1035 { 1081 {
1036 boost = (int)SHR32(EXTEND32(follower[i]),DB_SHIFT); 1082 boost = (int)SHR32(EXTEND32(follower[i]),DB_SHIFT);
1037 boost_bits = boost*width<<BITRES; 1083 boost_bits = boost*width<<BITRES;
1038 } else if (width > 48) { 1084 } else if (width > 48) {
1039 boost = (int)SHR32(EXTEND32(follower[i])*8,DB_SHIFT); 1085 boost = (int)SHR32(EXTEND32(follower[i])*8,DB_SHIFT);
1040 boost_bits = (boost*width<<BITRES)/8; 1086 boost_bits = (boost*width<<BITRES)/8;
1041 } else { 1087 } else {
1042 boost = (int)SHR32(EXTEND32(follower[i])*width/6,DB_SHIFT); 1088 boost = (int)SHR32(EXTEND32(follower[i])*width/6,DB_SHIFT);
1043 boost_bits = boost*6<<BITRES; 1089 boost_bits = boost*6<<BITRES;
1044 } 1090 }
1045 /* For CBR and non-transient CVBR frames, limit dynalloc to 1/4 of the bits */ 1091 /* For CBR and non-transient CVBR frames, limit dynalloc to 2/3 of the bits */
1046 if ((!vbr || (constrained_vbr&&!isTransient)) 1092 if ((!vbr || (constrained_vbr&&!isTransient))
1047 && (tot_boost+boost_bits)>>BITRES>>3 > effectiveBytes/4) 1093 && (tot_boost+boost_bits)>>BITRES>>3 > 2*effectiveBytes/3)
1048 { 1094 {
1049 opus_int32 cap = ((effectiveBytes/4)<<BITRES<<3); 1095 opus_int32 cap = ((2*effectiveBytes/3)<<BITRES<<3);
1050 offsets[i] = cap-tot_boost; 1096 offsets[i] = cap-tot_boost;
1051 tot_boost = cap; 1097 tot_boost = cap;
1052 break; 1098 break;
1053 } else { 1099 } else {
1054 offsets[i] = boost; 1100 offsets[i] = boost;
1055 tot_boost += boost_bits; 1101 tot_boost += boost_bits;
1056 } 1102 }
1057 } 1103 }
1058 } 1104 }
1059 *tot_boost_ = tot_boost; 1105 *tot_boost_ = tot_boost;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 *gain = gain1; 1232 *gain = gain1;
1187 *pitch = pitch_index; 1233 *pitch = pitch_index;
1188 *qgain = qg; 1234 *qgain = qg;
1189 return pf_on; 1235 return pf_on;
1190 } 1236 }
1191 1237
1192 static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 base_target, 1238 static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 base_target,
1193 int LM, opus_int32 bitrate, int lastCodedBands, int C, int intensity, 1239 int LM, opus_int32 bitrate, int lastCodedBands, int C, int intensity,
1194 int constrained_vbr, opus_val16 stereo_saving, int tot_boost, 1240 int constrained_vbr, opus_val16 stereo_saving, int tot_boost,
1195 opus_val16 tf_estimate, int pitch_change, opus_val16 maxDepth, 1241 opus_val16 tf_estimate, int pitch_change, opus_val16 maxDepth,
1196 int variable_duration, int lfe, int has_surround_mask, opus_val16 surround _masking, 1242 int lfe, int has_surround_mask, opus_val16 surround_masking,
1197 opus_val16 temporal_vbr) 1243 opus_val16 temporal_vbr)
1198 { 1244 {
1199 /* The target rate in 8th bits per frame */ 1245 /* The target rate in 8th bits per frame */
1200 opus_int32 target; 1246 opus_int32 target;
1201 int coded_bins; 1247 int coded_bins;
1202 int coded_bands; 1248 int coded_bands;
1203 opus_val16 tf_calibration; 1249 opus_val16 tf_calibration;
1204 int nbEBands; 1250 int nbEBands;
1205 const opus_int16 *eBands; 1251 const opus_int16 *eBands;
1206 1252
(...skipping 21 matching lines...) Expand all
1228 coded_stereo_bands = IMIN(intensity, coded_bands); 1274 coded_stereo_bands = IMIN(intensity, coded_bands);
1229 coded_stereo_dof = (eBands[coded_stereo_bands]<<LM)-coded_stereo_bands; 1275 coded_stereo_dof = (eBands[coded_stereo_bands]<<LM)-coded_stereo_bands;
1230 /* Maximum fraction of the bits we can save if the signal is mono. */ 1276 /* Maximum fraction of the bits we can save if the signal is mono. */
1231 max_frac = DIV32_16(MULT16_16(QCONST16(0.8f, 15), coded_stereo_dof), coded _bins); 1277 max_frac = DIV32_16(MULT16_16(QCONST16(0.8f, 15), coded_stereo_dof), coded _bins);
1232 stereo_saving = MIN16(stereo_saving, QCONST16(1.f, 8)); 1278 stereo_saving = MIN16(stereo_saving, QCONST16(1.f, 8));
1233 /*printf("%d %d %d ", coded_stereo_dof, coded_bins, tot_boost);*/ 1279 /*printf("%d %d %d ", coded_stereo_dof, coded_bins, tot_boost);*/
1234 target -= (opus_int32)MIN32(MULT16_32_Q15(max_frac,target), 1280 target -= (opus_int32)MIN32(MULT16_32_Q15(max_frac,target),
1235 SHR32(MULT16_16(stereo_saving-QCONST16(0.1f,8),(coded_ster eo_dof<<BITRES)),8)); 1281 SHR32(MULT16_16(stereo_saving-QCONST16(0.1f,8),(coded_ster eo_dof<<BITRES)),8));
1236 } 1282 }
1237 /* Boost the rate according to dynalloc (minus the dynalloc average for calib ration). */ 1283 /* Boost the rate according to dynalloc (minus the dynalloc average for calib ration). */
1238 target += tot_boost-(16<<LM); 1284 target += tot_boost-(19<<LM);
1239 /* Apply transient boost, compensating for average boost. */ 1285 /* Apply transient boost, compensating for average boost. */
1240 tf_calibration = variable_duration==OPUS_FRAMESIZE_VARIABLE ? 1286 tf_calibration = QCONST16(0.044f,14);
1241 QCONST16(0.02f,14) : QCONST16(0.04f,14);
1242 target += (opus_int32)SHL32(MULT16_32_Q15(tf_estimate-tf_calibration, target) ,1); 1287 target += (opus_int32)SHL32(MULT16_32_Q15(tf_estimate-tf_calibration, target) ,1);
1243 1288
1244 #ifndef DISABLE_FLOAT_API 1289 #ifndef DISABLE_FLOAT_API
1245 /* Apply tonality boost */ 1290 /* Apply tonality boost */
1246 if (analysis->valid && !lfe) 1291 if (analysis->valid && !lfe)
1247 { 1292 {
1248 opus_int32 tonal_target; 1293 opus_int32 tonal_target;
1249 float tonal; 1294 float tonal;
1250 1295
1251 /* Tonality boost (compensating for the average). */ 1296 /* Tonality boost (compensating for the average). */
1252 tonal = MAX16(0.f,analysis->tonality-.15f)-0.09f; 1297 tonal = MAX16(0.f,analysis->tonality-.15f)-0.12f;
1253 tonal_target = target + (opus_int32)((coded_bins<<BITRES)*1.2f*tonal); 1298 tonal_target = target + (opus_int32)((coded_bins<<BITRES)*1.2f*tonal);
1254 if (pitch_change) 1299 if (pitch_change)
1255 tonal_target += (opus_int32)((coded_bins<<BITRES)*.8f); 1300 tonal_target += (opus_int32)((coded_bins<<BITRES)*.8f);
1256 /*printf("%f %f ", analysis->tonality, tonal);*/ 1301 /*printf("%f %f ", analysis->tonality, tonal);*/
1257 target = tonal_target; 1302 target = tonal_target;
1258 } 1303 }
1259 #else 1304 #else
1260 (void)analysis; 1305 (void)analysis;
1261 (void)pitch_change; 1306 (void)pitch_change;
1262 #endif 1307 #endif
1263 1308
1264 if (has_surround_mask&&!lfe) 1309 if (has_surround_mask&&!lfe)
1265 { 1310 {
1266 opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(surround _masking,coded_bins<<BITRES), DB_SHIFT); 1311 opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(surround _masking,coded_bins<<BITRES), DB_SHIFT);
1267 /*printf("%f %d %d %d %d %d %d ", surround_masking, coded_bins, st->end, s t->intensity, surround_target, target, st->bitrate);*/ 1312 /*printf("%f %d %d %d %d %d %d ", surround_masking, coded_bins, st->end, s t->intensity, surround_target, target, st->bitrate);*/
1268 target = IMAX(target/4, surround_target); 1313 target = IMAX(target/4, surround_target);
1269 } 1314 }
1270 1315
1271 { 1316 {
1272 opus_int32 floor_depth; 1317 opus_int32 floor_depth;
1273 int bins; 1318 int bins;
1274 bins = eBands[nbEBands-2]<<LM; 1319 bins = eBands[nbEBands-2]<<LM;
1275 /*floor_depth = SHR32(MULT16_16((C*bins<<BITRES),celt_log2(SHL32(MAX16(1,s ample_max),13))), DB_SHIFT);*/ 1320 /*floor_depth = SHR32(MULT16_16((C*bins<<BITRES),celt_log2(SHL32(MAX16(1,s ample_max),13))), DB_SHIFT);*/
1276 floor_depth = (opus_int32)SHR32(MULT16_16((C*bins<<BITRES),maxDepth), DB_S HIFT); 1321 floor_depth = (opus_int32)SHR32(MULT16_16((C*bins<<BITRES),maxDepth), DB_S HIFT);
1277 floor_depth = IMAX(floor_depth, target>>2); 1322 floor_depth = IMAX(floor_depth, target>>2);
1278 target = IMIN(target, floor_depth); 1323 target = IMIN(target, floor_depth);
1279 /*printf("%f %d\n", maxDepth, floor_depth);*/ 1324 /*printf("%f %d\n", maxDepth, floor_depth);*/
1280 } 1325 }
1281 1326
1282 if ((!has_surround_mask||lfe) && (constrained_vbr || bitrate<64000)) 1327 /* Make VBR less aggressive for constrained VBR because we can't keep a highe r bitrate
1328 for long. Needs tuning. */
1329 if ((!has_surround_mask||lfe) && constrained_vbr)
1283 { 1330 {
1284 opus_val16 rate_factor = Q15ONE; 1331 target = base_target + (opus_int32)MULT16_32_Q15(QCONST16(0.67f, 15), targ et-base_target);
1285 if (bitrate < 64000)
1286 {
1287 #ifdef FIXED_POINT
1288 rate_factor = MAX16(0,(bitrate-32000));
1289 #else
1290 rate_factor = MAX16(0,(1.f/32768)*(bitrate-32000));
1291 #endif
1292 }
1293 if (constrained_vbr)
1294 rate_factor = MIN16(rate_factor, QCONST16(0.67f, 15));
1295 target = base_target + (opus_int32)MULT16_32_Q15(rate_factor, target-base_ target);
1296
1297 } 1332 }
1298 1333
1299 if (!has_surround_mask && tf_estimate < QCONST16(.2f, 14)) 1334 if (!has_surround_mask && tf_estimate < QCONST16(.2f, 14))
1300 { 1335 {
1301 opus_val16 amount; 1336 opus_val16 amount;
1302 opus_val16 tvbr_factor; 1337 opus_val16 tvbr_factor;
1303 amount = MULT16_16_Q15(QCONST16(.0000031f, 30), IMAX(0, IMIN(32000, 96000- bitrate))); 1338 amount = MULT16_16_Q15(QCONST16(.0000031f, 30), IMAX(0, IMIN(32000, 96000- bitrate)));
1304 tvbr_factor = SHR32(MULT16_16(temporal_vbr, amount), DB_SHIFT); 1339 tvbr_factor = SHR32(MULT16_16(temporal_vbr, amount), DB_SHIFT);
1305 target += (opus_int32)MULT16_32_Q15(tvbr_factor, target); 1340 target += (opus_int32)MULT16_32_Q15(tvbr_factor, target);
1306 } 1341 }
(...skipping 17 matching lines...) Expand all
1324 VARDECL(opus_val16, bandLogE2); 1359 VARDECL(opus_val16, bandLogE2);
1325 VARDECL(int, fine_quant); 1360 VARDECL(int, fine_quant);
1326 VARDECL(opus_val16, error); 1361 VARDECL(opus_val16, error);
1327 VARDECL(int, pulses); 1362 VARDECL(int, pulses);
1328 VARDECL(int, cap); 1363 VARDECL(int, cap);
1329 VARDECL(int, offsets); 1364 VARDECL(int, offsets);
1330 VARDECL(int, fine_priority); 1365 VARDECL(int, fine_priority);
1331 VARDECL(int, tf_res); 1366 VARDECL(int, tf_res);
1332 VARDECL(unsigned char, collapse_masks); 1367 VARDECL(unsigned char, collapse_masks);
1333 celt_sig *prefilter_mem; 1368 celt_sig *prefilter_mem;
1334 opus_val16 *oldBandE, *oldLogE, *oldLogE2; 1369 opus_val16 *oldBandE, *oldLogE, *oldLogE2, *energyError;
1335 int shortBlocks=0; 1370 int shortBlocks=0;
1336 int isTransient=0; 1371 int isTransient=0;
1337 const int CC = st->channels; 1372 const int CC = st->channels;
1338 const int C = st->stream_channels; 1373 const int C = st->stream_channels;
1339 int LM, M; 1374 int LM, M;
1340 int tf_select; 1375 int tf_select;
1341 int nbFilledBytes, nbAvailableBytes; 1376 int nbFilledBytes, nbAvailableBytes;
1342 int start; 1377 int start;
1343 int end; 1378 int end;
1344 int effEnd; 1379 int effEnd;
1345 int codedBands; 1380 int codedBands;
1346 int tf_sum;
1347 int alloc_trim; 1381 int alloc_trim;
1348 int pitch_index=COMBFILTER_MINPERIOD; 1382 int pitch_index=COMBFILTER_MINPERIOD;
1349 opus_val16 gain1 = 0; 1383 opus_val16 gain1 = 0;
1350 int dual_stereo=0; 1384 int dual_stereo=0;
1351 int effectiveBytes; 1385 int effectiveBytes;
1352 int dynalloc_logp; 1386 int dynalloc_logp;
1353 opus_int32 vbr_rate; 1387 opus_int32 vbr_rate;
1354 opus_int32 total_bits; 1388 opus_int32 total_bits;
1355 opus_int32 total_boost; 1389 opus_int32 total_boost;
1356 opus_int32 balance; 1390 opus_int32 balance;
1357 opus_int32 tell; 1391 opus_int32 tell;
1392 opus_int32 tell0_frac;
1358 int prefilter_tapset=0; 1393 int prefilter_tapset=0;
1359 int pf_on; 1394 int pf_on;
1360 int anti_collapse_rsv; 1395 int anti_collapse_rsv;
1361 int anti_collapse_on=0; 1396 int anti_collapse_on=0;
1362 int silence=0; 1397 int silence=0;
1363 int tf_chan = 0; 1398 int tf_chan = 0;
1364 opus_val16 tf_estimate; 1399 opus_val16 tf_estimate;
1365 int pitch_change=0; 1400 int pitch_change=0;
1366 opus_int32 tot_boost; 1401 opus_int32 tot_boost;
1367 opus_val32 sample_max; 1402 opus_val32 sample_max;
1368 opus_val16 maxDepth; 1403 opus_val16 maxDepth;
1369 const OpusCustomMode *mode; 1404 const OpusCustomMode *mode;
1370 int nbEBands; 1405 int nbEBands;
1371 int overlap; 1406 int overlap;
1372 const opus_int16 *eBands; 1407 const opus_int16 *eBands;
1373 int secondMdct; 1408 int secondMdct;
1374 int signalBandwidth; 1409 int signalBandwidth;
1375 int transient_got_disabled=0; 1410 int transient_got_disabled=0;
1376 opus_val16 surround_masking=0; 1411 opus_val16 surround_masking=0;
1377 opus_val16 temporal_vbr=0; 1412 opus_val16 temporal_vbr=0;
1378 opus_val16 surround_trim = 0; 1413 opus_val16 surround_trim = 0;
1379 opus_int32 equiv_rate = 510000; 1414 opus_int32 equiv_rate;
1415 int hybrid;
1416 int weak_transient = 0;
1380 VARDECL(opus_val16, surround_dynalloc); 1417 VARDECL(opus_val16, surround_dynalloc);
1381 ALLOC_STACK; 1418 ALLOC_STACK;
1382 1419
1383 mode = st->mode; 1420 mode = st->mode;
1384 nbEBands = mode->nbEBands; 1421 nbEBands = mode->nbEBands;
1385 overlap = mode->overlap; 1422 overlap = mode->overlap;
1386 eBands = mode->eBands; 1423 eBands = mode->eBands;
1387 start = st->start; 1424 start = st->start;
1388 end = st->end; 1425 end = st->end;
1426 hybrid = start != 0;
1389 tf_estimate = 0; 1427 tf_estimate = 0;
1390 if (nbCompressedBytes<2 || pcm==NULL) 1428 if (nbCompressedBytes<2 || pcm==NULL)
1391 { 1429 {
1392 RESTORE_STACK; 1430 RESTORE_STACK;
1393 return OPUS_BAD_ARG; 1431 return OPUS_BAD_ARG;
1394 } 1432 }
1395 1433
1396 frame_size *= st->upsample; 1434 frame_size *= st->upsample;
1397 for (LM=0;LM<=mode->maxLM;LM++) 1435 for (LM=0;LM<=mode->maxLM;LM++)
1398 if (mode->shortMdctSize<<LM==frame_size) 1436 if (mode->shortMdctSize<<LM==frame_size)
1399 break; 1437 break;
1400 if (LM>mode->maxLM) 1438 if (LM>mode->maxLM)
1401 { 1439 {
1402 RESTORE_STACK; 1440 RESTORE_STACK;
1403 return OPUS_BAD_ARG; 1441 return OPUS_BAD_ARG;
1404 } 1442 }
1405 M=1<<LM; 1443 M=1<<LM;
1406 N = M*mode->shortMdctSize; 1444 N = M*mode->shortMdctSize;
1407 1445
1408 prefilter_mem = st->in_mem+CC*(overlap); 1446 prefilter_mem = st->in_mem+CC*(overlap);
1409 oldBandE = (opus_val16*)(st->in_mem+CC*(overlap+COMBFILTER_MAXPERIOD)); 1447 oldBandE = (opus_val16*)(st->in_mem+CC*(overlap+COMBFILTER_MAXPERIOD));
1410 oldLogE = oldBandE + CC*nbEBands; 1448 oldLogE = oldBandE + CC*nbEBands;
1411 oldLogE2 = oldLogE + CC*nbEBands; 1449 oldLogE2 = oldLogE + CC*nbEBands;
1450 energyError = oldLogE2 + CC*nbEBands;
1412 1451
1413 if (enc==NULL) 1452 if (enc==NULL)
1414 { 1453 {
1415 tell=1; 1454 tell0_frac=tell=1;
1416 nbFilledBytes=0; 1455 nbFilledBytes=0;
1417 } else { 1456 } else {
1457 tell0_frac=tell=ec_tell_frac(enc);
1418 tell=ec_tell(enc); 1458 tell=ec_tell(enc);
1419 nbFilledBytes=(tell+4)>>3; 1459 nbFilledBytes=(tell+4)>>3;
1420 } 1460 }
1421 1461
1422 #ifdef CUSTOM_MODES 1462 #ifdef CUSTOM_MODES
1423 if (st->signalling && enc==NULL) 1463 if (st->signalling && enc==NULL)
1424 { 1464 {
1425 int tmp = (mode->effEBands-end)>>1; 1465 int tmp = (mode->effEBands-end)>>1;
1426 end = st->end = IMAX(1, mode->effEBands-tmp); 1466 end = st->end = IMAX(1, mode->effEBands-tmp);
1427 compressed[0] = tmp<<5; 1467 compressed[0] = tmp<<5;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 effectiveBytes = vbr_rate>>(3+BITRES); 1500 effectiveBytes = vbr_rate>>(3+BITRES);
1461 } else { 1501 } else {
1462 opus_int32 tmp; 1502 opus_int32 tmp;
1463 vbr_rate = 0; 1503 vbr_rate = 0;
1464 tmp = st->bitrate*frame_size; 1504 tmp = st->bitrate*frame_size;
1465 if (tell>1) 1505 if (tell>1)
1466 tmp += tell; 1506 tmp += tell;
1467 if (st->bitrate!=OPUS_BITRATE_MAX) 1507 if (st->bitrate!=OPUS_BITRATE_MAX)
1468 nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes, 1508 nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes,
1469 (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling)); 1509 (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling));
1470 effectiveBytes = nbCompressedBytes; 1510 effectiveBytes = nbCompressedBytes - nbFilledBytes;
1471 } 1511 }
1512 equiv_rate = ((opus_int32)nbCompressedBytes*8*50 >> (3-LM)) - (40*C+20)*((400 >>LM) - 50);
1472 if (st->bitrate != OPUS_BITRATE_MAX) 1513 if (st->bitrate != OPUS_BITRATE_MAX)
1473 equiv_rate = st->bitrate - (40*C+20)*((400>>LM) - 50); 1514 equiv_rate = IMIN(equiv_rate, st->bitrate - (40*C+20)*((400>>LM) - 50));
1474 1515
1475 if (enc==NULL) 1516 if (enc==NULL)
1476 { 1517 {
1477 ec_enc_init(&_enc, compressed, nbCompressedBytes); 1518 ec_enc_init(&_enc, compressed, nbCompressedBytes);
1478 enc = &_enc; 1519 enc = &_enc;
1479 } 1520 }
1480 1521
1481 if (vbr_rate>0) 1522 if (vbr_rate>0)
1482 { 1523 {
1483 /* Computes the max bit-rate allowed in VBR mode to avoid violating the 1524 /* Computes the max bit-rate allowed in VBR mode to avoid violating the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample, 1592 celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample,
1552 mode->preemph, st->preemph_memE+c, need_clip); 1593 mode->preemph, st->preemph_memE+c, need_clip);
1553 } while (++c<CC); 1594 } while (++c<CC);
1554 1595
1555 1596
1556 1597
1557 /* Find pitch period and gain */ 1598 /* Find pitch period and gain */
1558 { 1599 {
1559 int enabled; 1600 int enabled;
1560 int qg; 1601 int qg;
1561 enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && star t==0 && !silence && !st->disable_pf 1602 enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && !hyb rid && !silence && !st->disable_pf
1562 && st->complexity >= 5 && !(st->consec_transient && LM!=3 && st->var iable_duration==OPUS_FRAMESIZE_VARIABLE); 1603 && st->complexity >= 5;
1563 1604
1564 prefilter_tapset = st->tapset_decision; 1605 prefilter_tapset = st->tapset_decision;
1565 pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pit ch_index, &gain1, &qg, enabled, nbAvailableBytes); 1606 pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pit ch_index, &gain1, &qg, enabled, nbAvailableBytes);
1566 if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3) 1607 if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3)
1567 && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st- >prefilter_period)) 1608 && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st- >prefilter_period))
1568 pitch_change = 1; 1609 pitch_change = 1;
1569 if (pf_on==0) 1610 if (pf_on==0)
1570 { 1611 {
1571 if(start==0 && tell+16<=total_bits) 1612 if(!hybrid && tell+16<=total_bits)
1572 ec_enc_bit_logp(enc, 0, 1); 1613 ec_enc_bit_logp(enc, 0, 1);
1573 } else { 1614 } else {
1574 /*This block is not gated by a total bits check only because 1615 /*This block is not gated by a total bits check only because
1575 of the nbAvailableBytes check above.*/ 1616 of the nbAvailableBytes check above.*/
1576 int octave; 1617 int octave;
1577 ec_enc_bit_logp(enc, 1, 1); 1618 ec_enc_bit_logp(enc, 1, 1);
1578 pitch_index += 1; 1619 pitch_index += 1;
1579 octave = EC_ILOG(pitch_index)-5; 1620 octave = EC_ILOG(pitch_index)-5;
1580 ec_enc_uint(enc, octave, 6); 1621 ec_enc_uint(enc, octave, 6);
1581 ec_enc_bits(enc, pitch_index-(16<<octave), 4+octave); 1622 ec_enc_bits(enc, pitch_index-(16<<octave), 4+octave);
1582 pitch_index -= 1; 1623 pitch_index -= 1;
1583 ec_enc_bits(enc, qg, 3); 1624 ec_enc_bits(enc, qg, 3);
1584 ec_enc_icdf(enc, prefilter_tapset, tapset_icdf, 2); 1625 ec_enc_icdf(enc, prefilter_tapset, tapset_icdf, 2);
1585 } 1626 }
1586 } 1627 }
1587 1628
1588 isTransient = 0; 1629 isTransient = 0;
1589 shortBlocks = 0; 1630 shortBlocks = 0;
1590 if (st->complexity >= 1 && !st->lfe) 1631 if (st->complexity >= 1 && !st->lfe)
1591 { 1632 {
1633 /* Reduces the likelihood of energy instability on fricatives at low bitra te
1634 in hybrid mode. It seems like we still want to have real transients on vowels
1635 though (small SILK quantization offset value). */
1636 int allow_weak_transients = hybrid && effectiveBytes<15 && st->silk_info.o ffset >= 100;
1592 isTransient = transient_analysis(in, N+overlap, CC, 1637 isTransient = transient_analysis(in, N+overlap, CC,
1593 &tf_estimate, &tf_chan); 1638 &tf_estimate, &tf_chan, allow_weak_transients, &weak_transient);
1594 } 1639 }
1595 if (LM>0 && ec_tell(enc)+3<=total_bits) 1640 if (LM>0 && ec_tell(enc)+3<=total_bits)
1596 { 1641 {
1597 if (isTransient) 1642 if (isTransient)
1598 shortBlocks = M; 1643 shortBlocks = M;
1599 } else { 1644 } else {
1600 isTransient = 0; 1645 isTransient = 0;
1601 transient_got_disabled=1; 1646 transient_got_disabled=1;
1602 } 1647 }
1603 1648
1604 ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */ 1649 ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */
1605 ALLOC(bandE,nbEBands*CC, celt_ener); 1650 ALLOC(bandE,nbEBands*CC, celt_ener);
1606 ALLOC(bandLogE,nbEBands*CC, opus_val16); 1651 ALLOC(bandLogE,nbEBands*CC, opus_val16);
1607 1652
1608 secondMdct = shortBlocks && st->complexity>=8; 1653 secondMdct = shortBlocks && st->complexity>=8;
1609 ALLOC(bandLogE2, C*nbEBands, opus_val16); 1654 ALLOC(bandLogE2, C*nbEBands, opus_val16);
1610 if (secondMdct) 1655 if (secondMdct)
1611 { 1656 {
1612 compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample, st->arch); 1657 compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample, st->arch);
1613 compute_band_energies(mode, freq, bandE, effEnd, C, LM); 1658 compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch);
1614 amp2Log2(mode, effEnd, end, bandE, bandLogE2, C); 1659 amp2Log2(mode, effEnd, end, bandE, bandLogE2, C);
1615 for (i=0;i<C*nbEBands;i++) 1660 for (i=0;i<C*nbEBands;i++)
1616 bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT)); 1661 bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT));
1617 } 1662 }
1618 1663
1619 compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch) ; 1664 compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch) ;
1620 if (CC==2&&C==1) 1665 if (CC==2&&C==1)
1621 tf_chan = 0; 1666 tf_chan = 0;
1622 compute_band_energies(mode, freq, bandE, effEnd, C, LM); 1667 compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch);
1623 1668
1624 if (st->lfe) 1669 if (st->lfe)
1625 { 1670 {
1626 for (i=2;i<end;i++) 1671 for (i=2;i<end;i++)
1627 { 1672 {
1628 bandE[i] = IMIN(bandE[i], MULT16_32_Q15(QCONST16(1e-4f,15),bandE[0])); 1673 bandE[i] = IMIN(bandE[i], MULT16_32_Q15(QCONST16(1e-4f,15),bandE[0]));
1629 bandE[i] = MAX32(bandE[i], EPSILON); 1674 bandE[i] = MAX32(bandE[i], EPSILON);
1630 } 1675 }
1631 } 1676 }
1632 amp2Log2(mode, effEnd, end, bandE, bandLogE, C); 1677 amp2Log2(mode, effEnd, end, bandE, bandLogE, C);
1633 1678
1634 ALLOC(surround_dynalloc, C*nbEBands, opus_val16); 1679 ALLOC(surround_dynalloc, C*nbEBands, opus_val16);
1635 OPUS_CLEAR(surround_dynalloc, end); 1680 OPUS_CLEAR(surround_dynalloc, end);
1636 /* This computes how much masking takes place between surround channels */ 1681 /* This computes how much masking takes place between surround channels */
1637 if (start==0&&st->energy_mask&&!st->lfe) 1682 if (!hybrid&&st->energy_mask&&!st->lfe)
1638 { 1683 {
1639 int mask_end; 1684 int mask_end;
1640 int midband; 1685 int midband;
1641 int count_dynalloc; 1686 int count_dynalloc;
1642 opus_val32 mask_avg=0; 1687 opus_val32 mask_avg=0;
1643 opus_val32 diff=0; 1688 opus_val32 diff=0;
1644 int count=0; 1689 int count=0;
1645 mask_end = IMAX(2,st->lastCodedBands); 1690 mask_end = IMAX(2,st->lastCodedBands);
1646 for (c=0;c<C;c++) 1691 for (c=0;c<C;c++)
1647 { 1692 {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 printf("%f ", bandLogE[i]); 1774 printf("%f ", bandLogE[i]);
1730 printf("\n");*/ 1775 printf("\n");*/
1731 1776
1732 if (!secondMdct) 1777 if (!secondMdct)
1733 { 1778 {
1734 OPUS_COPY(bandLogE2, bandLogE, C*nbEBands); 1779 OPUS_COPY(bandLogE2, bandLogE, C*nbEBands);
1735 } 1780 }
1736 1781
1737 /* Last chance to catch any transient we might have missed in the 1782 /* Last chance to catch any transient we might have missed in the
1738 time-domain analysis */ 1783 time-domain analysis */
1739 if (LM>0 && ec_tell(enc)+3<=total_bits && !isTransient && st->complexity>=5 & & !st->lfe) 1784 if (LM>0 && ec_tell(enc)+3<=total_bits && !isTransient && st->complexity>=5 & & !st->lfe && !hybrid)
1740 { 1785 {
1741 if (patch_transient_decision(bandLogE, oldBandE, nbEBands, start, end, C)) 1786 if (patch_transient_decision(bandLogE, oldBandE, nbEBands, start, end, C))
1742 { 1787 {
1743 isTransient = 1; 1788 isTransient = 1;
1744 shortBlocks = M; 1789 shortBlocks = M;
1745 compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st- >arch); 1790 compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st- >arch);
1746 compute_band_energies(mode, freq, bandE, effEnd, C, LM); 1791 compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch);
1747 amp2Log2(mode, effEnd, end, bandE, bandLogE, C); 1792 amp2Log2(mode, effEnd, end, bandE, bandLogE, C);
1748 /* Compensate for the scaling of short vs long mdcts */ 1793 /* Compensate for the scaling of short vs long mdcts */
1749 for (i=0;i<C*nbEBands;i++) 1794 for (i=0;i<C*nbEBands;i++)
1750 bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT)); 1795 bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT));
1751 tf_estimate = QCONST16(.2f,14); 1796 tf_estimate = QCONST16(.2f,14);
1752 } 1797 }
1753 } 1798 }
1754 1799
1755 if (LM>0 && ec_tell(enc)+3<=total_bits) 1800 if (LM>0 && ec_tell(enc)+3<=total_bits)
1756 ec_enc_bit_logp(enc, isTransient, 3); 1801 ec_enc_bit_logp(enc, isTransient, 3);
1757 1802
1758 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ 1803 ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
1759 1804
1760 /* Band normalisation */ 1805 /* Band normalisation */
1761 normalise_bands(mode, freq, X, bandE, effEnd, C, M); 1806 normalise_bands(mode, freq, X, bandE, effEnd, C, M);
1762 1807
1763 ALLOC(tf_res, nbEBands, int); 1808 ALLOC(tf_res, nbEBands, int);
1764 /* Disable variable tf resolution for hybrid and at very low bitrate */ 1809 /* Disable variable tf resolution for hybrid and at very low bitrate */
1765 if (effectiveBytes>=15*C && start==0 && st->complexity>=2 && !st->lfe) 1810 if (effectiveBytes>=15*C && !hybrid && st->complexity>=2 && !st->lfe)
1766 { 1811 {
1767 int lambda; 1812 int lambda;
1768 if (effectiveBytes<40) 1813 lambda = IMAX(5, 1280/effectiveBytes + 2);
1769 lambda = 12; 1814 tf_select = tf_analysis(mode, effEnd, isTransient, tf_res, lambda, X, N, L M, tf_estimate, tf_chan);
1770 else if (effectiveBytes<60)
1771 lambda = 6;
1772 else if (effectiveBytes<100)
1773 lambda = 4;
1774 else
1775 lambda = 3;
1776 lambda*=2;
1777 tf_select = tf_analysis(mode, effEnd, isTransient, tf_res, lambda, X, N, L M, &tf_sum, tf_estimate, tf_chan);
1778 for (i=effEnd;i<end;i++) 1815 for (i=effEnd;i<end;i++)
1779 tf_res[i] = tf_res[effEnd-1]; 1816 tf_res[i] = tf_res[effEnd-1];
1817 } else if (hybrid && weak_transient)
1818 {
1819 /* For weak transients, we rely on the fact that improving time resolution using
1820 TF on a long window is imperfect and will not result in an energy colla pse at
1821 low bitrate. */
1822 for (i=0;i<end;i++)
1823 tf_res[i] = 1;
1824 tf_select=0;
1825 } else if (hybrid && effectiveBytes<15)
1826 {
1827 /* For low bitrate hybrid, we force temporal resolution to 5 ms rather tha n 2.5 ms. */
1828 for (i=0;i<end;i++)
1829 tf_res[i] = 0;
1830 tf_select=isTransient;
1780 } else { 1831 } else {
1781 tf_sum = 0;
1782 for (i=0;i<end;i++) 1832 for (i=0;i<end;i++)
1783 tf_res[i] = isTransient; 1833 tf_res[i] = isTransient;
1784 tf_select=0; 1834 tf_select=0;
1785 } 1835 }
1786 1836
1787 ALLOC(error, C*nbEBands, opus_val16); 1837 ALLOC(error, C*nbEBands, opus_val16);
1838 c=0;
1839 do {
1840 for (i=start;i<end;i++)
1841 {
1842 /* When the energy is stable, slightly bias energy quantization towards
1843 the previous error to make the gain more stable (a constant offset i s
1844 better than fluctuations). */
1845 if (ABS32(SUB32(bandLogE[i+c*nbEBands], oldBandE[i+c*nbEBands])) < QCON ST16(2.f, DB_SHIFT))
1846 {
1847 bandLogE[i+c*nbEBands] -= MULT16_16_Q15(energyError[i+c*nbEBands], Q CONST16(0.25f, 15));
1848 }
1849 }
1850 } while (++c < C);
1788 quant_coarse_energy(mode, start, end, effEnd, bandLogE, 1851 quant_coarse_energy(mode, start, end, effEnd, bandLogE,
1789 oldBandE, total_bits, error, enc, 1852 oldBandE, total_bits, error, enc,
1790 C, LM, nbAvailableBytes, st->force_intra, 1853 C, LM, nbAvailableBytes, st->force_intra,
1791 &st->delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe); 1854 &st->delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe);
1792 1855
1793 tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc); 1856 tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc);
1794 1857
1795 if (ec_tell(enc)+4<=total_bits) 1858 if (ec_tell(enc)+4<=total_bits)
1796 { 1859 {
1797 if (st->lfe) 1860 if (st->lfe)
1798 { 1861 {
1799 st->tapset_decision = 0; 1862 st->tapset_decision = 0;
1800 st->spread_decision = SPREAD_NORMAL; 1863 st->spread_decision = SPREAD_NORMAL;
1801 } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C || start != 0) 1864 } else if (hybrid)
1802 { 1865 {
1803 if (st->complexity == 0) 1866 if (st->complexity == 0)
1804 st->spread_decision = SPREAD_NONE; 1867 st->spread_decision = SPREAD_NONE;
1868 else if (isTransient)
1869 st->spread_decision = SPREAD_NORMAL;
1870 else
1871 st->spread_decision = SPREAD_AGGRESSIVE;
1872 } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C)
1873 {
1874 if (st->complexity == 0)
1875 st->spread_decision = SPREAD_NONE;
1805 else 1876 else
1806 st->spread_decision = SPREAD_NORMAL; 1877 st->spread_decision = SPREAD_NORMAL;
1807 } else { 1878 } else {
1808 /* Disable new spreading+tapset estimator until we can show it works 1879 /* Disable new spreading+tapset estimator until we can show it works
1809 better than the old one. So far it seems like spreading_decision() 1880 better than the old one. So far it seems like spreading_decision()
1810 works best. */ 1881 works best. */
1811 #if 0 1882 #if 0
1812 if (st->analysis.valid) 1883 if (st->analysis.valid)
1813 { 1884 {
1814 static const opus_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), -QCONST16(.07f, 15)}; 1885 static const opus_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), -QCONST16(.07f, 15)};
(...skipping 12 matching lines...) Expand all
1827 /*printf("%d %d\n", st->tapset_decision, st->spread_decision);*/ 1898 /*printf("%d %d\n", st->tapset_decision, st->spread_decision);*/
1828 /*printf("%f %d %f %d\n\n", st->analysis.tonality, st->spread_decision, st->analysis.tonality_slope, st->tapset_decision);*/ 1899 /*printf("%f %d %f %d\n\n", st->analysis.tonality, st->spread_decision, st->analysis.tonality_slope, st->tapset_decision);*/
1829 } 1900 }
1830 ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5); 1901 ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5);
1831 } 1902 }
1832 1903
1833 ALLOC(offsets, nbEBands, int); 1904 ALLOC(offsets, nbEBands, int);
1834 1905
1835 maxDepth = dynalloc_analysis(bandLogE, bandLogE2, nbEBands, start, end, C, of fsets, 1906 maxDepth = dynalloc_analysis(bandLogE, bandLogE2, nbEBands, start, end, C, of fsets,
1836 st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr, 1907 st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr,
1837 eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc); 1908 eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc, &st ->analysis);
1838 /* For LFE, everything interesting is in the first band */ 1909 /* For LFE, everything interesting is in the first band */
1839 if (st->lfe) 1910 if (st->lfe)
1840 offsets[0] = IMIN(8, effectiveBytes/3); 1911 offsets[0] = IMIN(8, effectiveBytes/3);
1841 ALLOC(cap, nbEBands, int); 1912 ALLOC(cap, nbEBands, int);
1842 init_caps(mode,cap,LM,C); 1913 init_caps(mode,cap,LM,C);
1843 1914
1844 dynalloc_logp = 6; 1915 dynalloc_logp = 6;
1845 total_bits<<=BITRES; 1916 total_bits<<=BITRES;
1846 total_boost = 0; 1917 total_boost = 0;
1847 tell = ec_tell_frac(enc); 1918 tell = ec_tell_frac(enc);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 dual_stereo = stereo_analysis(mode, X, LM, N); 1960 dual_stereo = stereo_analysis(mode, X, LM, N);
1890 1961
1891 st->intensity = hysteresis_decision((opus_val16)(equiv_rate/1000), 1962 st->intensity = hysteresis_decision((opus_val16)(equiv_rate/1000),
1892 intensity_thresholds, intensity_histeresis, 21, st->intensity); 1963 intensity_thresholds, intensity_histeresis, 21, st->intensity);
1893 st->intensity = IMIN(end,IMAX(start, st->intensity)); 1964 st->intensity = IMIN(end,IMAX(start, st->intensity));
1894 } 1965 }
1895 1966
1896 alloc_trim = 5; 1967 alloc_trim = 5;
1897 if (tell+(6<<BITRES) <= total_bits - total_boost) 1968 if (tell+(6<<BITRES) <= total_bits - total_boost)
1898 { 1969 {
1899 if (st->lfe) 1970 if (start > 0 || st->lfe)
1971 {
1972 st->stereo_saving = 0;
1900 alloc_trim = 5; 1973 alloc_trim = 5;
1901 else 1974 } else {
1902 alloc_trim = alloc_trim_analysis(mode, X, bandLogE, 1975 alloc_trim = alloc_trim_analysis(mode, X, bandLogE,
1903 end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate, 1976 end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate,
1904 st->intensity, surround_trim, st->arch); 1977 st->intensity, surround_trim, equiv_rate, st->arch);
1978 }
1905 ec_enc_icdf(enc, alloc_trim, trim_icdf, 7); 1979 ec_enc_icdf(enc, alloc_trim, trim_icdf, 7);
1906 tell = ec_tell_frac(enc); 1980 tell = ec_tell_frac(enc);
1907 } 1981 }
1908 1982
1909 /* Variable bitrate */ 1983 /* Variable bitrate */
1910 if (vbr_rate>0) 1984 if (vbr_rate>0)
1911 { 1985 {
1912 opus_val16 alpha; 1986 opus_val16 alpha;
1913 opus_int32 delta; 1987 opus_int32 delta;
1914 /* The target rate in 8th bits per frame */ 1988 /* The target rate in 8th bits per frame */
1915 opus_int32 target, base_target; 1989 opus_int32 target, base_target;
1916 opus_int32 min_allowed; 1990 opus_int32 min_allowed;
1917 int lm_diff = mode->maxLM - LM; 1991 int lm_diff = mode->maxLM - LM;
1918 1992
1919 /* Don't attempt to use more than 510 kb/s, even for frames smaller than 20 ms. 1993 /* Don't attempt to use more than 510 kb/s, even for frames smaller than 20 ms.
1920 The CELT allocator will just not be able to use more than that anyway. * / 1994 The CELT allocator will just not be able to use more than that anyway. * /
1921 nbCompressedBytes = IMIN(nbCompressedBytes,1275>>(3-LM)); 1995 nbCompressedBytes = IMIN(nbCompressedBytes,1275>>(3-LM));
1922 base_target = vbr_rate - ((40*C+20)<<BITRES); 1996 if (!hybrid)
1997 {
1998 base_target = vbr_rate - ((40*C+20)<<BITRES);
1999 } else {
2000 base_target = IMAX(0, vbr_rate - ((9*C+4)<<BITRES));
2001 }
1923 2002
1924 if (st->constrained_vbr) 2003 if (st->constrained_vbr)
1925 base_target += (st->vbr_offset>>lm_diff); 2004 base_target += (st->vbr_offset>>lm_diff);
1926 2005
1927 target = compute_vbr(mode, &st->analysis, base_target, LM, equiv_rate, 2006 if (!hybrid)
2007 {
2008 target = compute_vbr(mode, &st->analysis, base_target, LM, equiv_rate,
1928 st->lastCodedBands, C, st->intensity, st->constrained_vbr, 2009 st->lastCodedBands, C, st->intensity, st->constrained_vbr,
1929 st->stereo_saving, tot_boost, tf_estimate, pitch_change, maxDepth, 2010 st->stereo_saving, tot_boost, tf_estimate, pitch_change, maxDepth,
1930 st->variable_duration, st->lfe, st->energy_mask!=NULL, surround_maski ng, 2011 st->lfe, st->energy_mask!=NULL, surround_masking,
1931 temporal_vbr); 2012 temporal_vbr);
1932 2013 } else {
2014 target = base_target;
2015 /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones . */
2016 if (st->silk_info.offset < 100) target += 12 << BITRES >> (3-LM);
2017 if (st->silk_info.offset > 100) target -= 18 << BITRES >> (3-LM);
2018 /* Boosting bitrate on transients and vowels with significant temporal
2019 spikes. */
2020 target += (opus_int32)MULT16_16_Q14(tf_estimate-QCONST16(.25f,14), (50<< BITRES));
2021 /* If we have a strong transient, let's make sure it has enough bits to code
2022 the first two bands, so that it can use folding rather than noise. */
2023 if (tf_estimate > QCONST16(.7f,14))
2024 target = IMAX(target, 50<<BITRES);
2025 }
1933 /* The current offset is removed from the target and the space used 2026 /* The current offset is removed from the target and the space used
1934 so far is added*/ 2027 so far is added*/
1935 target=target+tell; 2028 target=target+tell;
1936 /* In VBR mode the frame size must not be reduced so much that it would 2029 /* In VBR mode the frame size must not be reduced so much that it would
1937 result in the encoder running out of bits. 2030 result in the encoder running out of bits.
1938 The margin of 2 bytes ensures that none of the bust-prevention logic 2031 The margin of 2 bytes ensures that none of the bust-prevention logic
1939 in the decoder will have triggered so far. */ 2032 in the decoder will have triggered so far. */
1940 min_allowed = ((tell+total_boost+(1<<(BITRES+3))-1)>>(BITRES+3)) + 2 - nbFi lledBytes; 2033 min_allowed = ((tell+total_boost+(1<<(BITRES+3))-1)>>(BITRES+3)) + 2;
2034 /* Take into account the 37 bits we need to have left in the packet to
2035 signal a redundant frame in hybrid mode. Creating a shorter packet would
2036 create an entropy coder desync. */
2037 if (hybrid)
2038 min_allowed = IMAX(min_allowed, (tell0_frac+(37<<BITRES)+total_boost+(1< <(BITRES+3))-1)>>(BITRES+3));
1941 2039
1942 nbAvailableBytes = (target+(1<<(BITRES+2)))>>(BITRES+3); 2040 nbAvailableBytes = (target+(1<<(BITRES+2)))>>(BITRES+3);
1943 nbAvailableBytes = IMAX(min_allowed,nbAvailableBytes); 2041 nbAvailableBytes = IMAX(min_allowed,nbAvailableBytes);
1944 nbAvailableBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes) - nbFilledBytes; 2042 nbAvailableBytes = IMIN(nbCompressedBytes,nbAvailableBytes);
1945 2043
1946 /* By how much did we "miss" the target on that frame */ 2044 /* By how much did we "miss" the target on that frame */
1947 delta = target - vbr_rate; 2045 delta = target - vbr_rate;
1948 2046
1949 target=nbAvailableBytes<<(BITRES+3); 2047 target=nbAvailableBytes<<(BITRES+3);
1950 2048
1951 /*If the frame is silent we don't adjust our drift, otherwise 2049 /*If the frame is silent we don't adjust our drift, otherwise
1952 the encoder will shoot to very high rates after hitting a 2050 the encoder will shoot to very high rates after hitting a
1953 span of silence, but we do allow the bitres to refill. 2051 span of silence, but we do allow the bitres to refill.
1954 This means that we'll undershoot our target in CVBR/VBR modes 2052 This means that we'll undershoot our target in CVBR/VBR modes
(...skipping 26 matching lines...) Expand all
1981 2079
1982 if (st->constrained_vbr && st->vbr_reservoir < 0) 2080 if (st->constrained_vbr && st->vbr_reservoir < 0)
1983 { 2081 {
1984 /* We're under the min value -- increase rate */ 2082 /* We're under the min value -- increase rate */
1985 int adjust = (-st->vbr_reservoir)/(8<<BITRES); 2083 int adjust = (-st->vbr_reservoir)/(8<<BITRES);
1986 /* Unless we're just coding silence */ 2084 /* Unless we're just coding silence */
1987 nbAvailableBytes += silence?0:adjust; 2085 nbAvailableBytes += silence?0:adjust;
1988 st->vbr_reservoir = 0; 2086 st->vbr_reservoir = 0;
1989 /*printf ("+%d\n", adjust);*/ 2087 /*printf ("+%d\n", adjust);*/
1990 } 2088 }
1991 nbCompressedBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes); 2089 nbCompressedBytes = IMIN(nbCompressedBytes,nbAvailableBytes);
1992 /*printf("%d\n", nbCompressedBytes*50*8);*/ 2090 /*printf("%d\n", nbCompressedBytes*50*8);*/
1993 /* This moves the raw bits to take into account the new compressed size */ 2091 /* This moves the raw bits to take into account the new compressed size */
1994 ec_enc_shrink(enc, nbCompressedBytes); 2092 ec_enc_shrink(enc, nbCompressedBytes);
1995 } 2093 }
1996 2094
1997 /* Bit allocation */ 2095 /* Bit allocation */
1998 ALLOC(fine_quant, nbEBands, int); 2096 ALLOC(fine_quant, nbEBands, int);
1999 ALLOC(pulses, nbEBands, int); 2097 ALLOC(pulses, nbEBands, int);
2000 ALLOC(fine_priority, nbEBands, int); 2098 ALLOC(fine_priority, nbEBands, int);
2001 2099
(...skipping 29 matching lines...) Expand all
2031 else 2129 else
2032 st->lastCodedBands = codedBands; 2130 st->lastCodedBands = codedBands;
2033 2131
2034 quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, enc, C); 2132 quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, enc, C);
2035 2133
2036 /* Residual quantisation */ 2134 /* Residual quantisation */
2037 ALLOC(collapse_masks, C*nbEBands, unsigned char); 2135 ALLOC(collapse_masks, C*nbEBands, unsigned char);
2038 quant_all_bands(1, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, 2136 quant_all_bands(1, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks,
2039 bandE, pulses, shortBlocks, st->spread_decision, 2137 bandE, pulses, shortBlocks, st->spread_decision,
2040 dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<<BITRES)-anti_ collapse_rsv, 2138 dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<<BITRES)-anti_ collapse_rsv,
2041 balance, enc, LM, codedBands, &st->rng, st->arch); 2139 balance, enc, LM, codedBands, &st->rng, st->complexity, st->arch, st->d isable_inv);
2042 2140
2043 if (anti_collapse_rsv > 0) 2141 if (anti_collapse_rsv > 0)
2044 { 2142 {
2045 anti_collapse_on = st->consec_transient<2; 2143 anti_collapse_on = st->consec_transient<2;
2046 #ifdef FUZZING 2144 #ifdef FUZZING
2047 anti_collapse_on = rand()&0x1; 2145 anti_collapse_on = rand()&0x1;
2048 #endif 2146 #endif
2049 ec_enc_bits(enc, anti_collapse_on, 1); 2147 ec_enc_bits(enc, anti_collapse_on, 1);
2050 } 2148 }
2051 quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_pri ority, nbCompressedBytes*8-ec_tell(enc), enc, C); 2149 quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_pri ority, nbCompressedBytes*8-ec_tell(enc), enc, C);
2150 OPUS_CLEAR(energyError, nbEBands*CC);
2151 c=0;
2152 do {
2153 for (i=start;i<end;i++)
2154 {
2155 energyError[i+c*nbEBands] = MAX16(-QCONST16(0.5f, 15), MIN16(QCONST16(0 .5f, 15), error[i+c*nbEBands]));
2156 }
2157 } while (++c < C);
2052 2158
2053 if (silence) 2159 if (silence)
2054 { 2160 {
2055 for (i=0;i<C*nbEBands;i++) 2161 for (i=0;i<C*nbEBands;i++)
2056 oldBandE[i] = -QCONST16(28.f,DB_SHIFT); 2162 oldBandE[i] = -QCONST16(28.f,DB_SHIFT);
2057 } 2163 }
2058 2164
2059 #ifdef RESYNTH 2165 #ifdef RESYNTH
2060 /* Re-synthesis of the coded audio if required */ 2166 /* Re-synthesis of the coded audio if required */
2061 { 2167 {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 goto bad_arg; 2420 goto bad_arg;
2315 st->lsb_depth=value; 2421 st->lsb_depth=value;
2316 } 2422 }
2317 break; 2423 break;
2318 case OPUS_GET_LSB_DEPTH_REQUEST: 2424 case OPUS_GET_LSB_DEPTH_REQUEST:
2319 { 2425 {
2320 opus_int32 *value = va_arg(ap, opus_int32*); 2426 opus_int32 *value = va_arg(ap, opus_int32*);
2321 *value=st->lsb_depth; 2427 *value=st->lsb_depth;
2322 } 2428 }
2323 break; 2429 break;
2324 case OPUS_SET_EXPERT_FRAME_DURATION_REQUEST: 2430 case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST:
2325 { 2431 {
2326 opus_int32 value = va_arg(ap, opus_int32); 2432 opus_int32 value = va_arg(ap, opus_int32);
2327 st->variable_duration = value; 2433 if(value<0 || value>1)
2434 {
2435 goto bad_arg;
2436 }
2437 st->disable_inv = value;
2438 }
2439 break;
2440 case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST:
2441 {
2442 opus_int32 *value = va_arg(ap, opus_int32*);
2443 if (!value)
2444 {
2445 goto bad_arg;
2446 }
2447 *value = st->disable_inv;
2328 } 2448 }
2329 break; 2449 break;
2330 case OPUS_RESET_STATE: 2450 case OPUS_RESET_STATE:
2331 { 2451 {
2332 int i; 2452 int i;
2333 opus_val16 *oldBandE, *oldLogE, *oldLogE2; 2453 opus_val16 *oldBandE, *oldLogE, *oldLogE2;
2334 oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->mode->overlap+COM BFILTER_MAXPERIOD)); 2454 oldBandE = (opus_val16*)(st->in_mem+st->channels*(st->mode->overlap+COM BFILTER_MAXPERIOD));
2335 oldLogE = oldBandE + st->channels*st->mode->nbEBands; 2455 oldLogE = oldBandE + st->channels*st->mode->nbEBands;
2336 oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; 2456 oldLogE2 = oldLogE + st->channels*st->mode->nbEBands;
2337 OPUS_CLEAR((char*)&st->ENCODER_RESET_START, 2457 OPUS_CLEAR((char*)&st->ENCODER_RESET_START,
(...skipping 23 matching lines...) Expand all
2361 st->signalling = value; 2481 st->signalling = value;
2362 } 2482 }
2363 break; 2483 break;
2364 case CELT_SET_ANALYSIS_REQUEST: 2484 case CELT_SET_ANALYSIS_REQUEST:
2365 { 2485 {
2366 AnalysisInfo *info = va_arg(ap, AnalysisInfo *); 2486 AnalysisInfo *info = va_arg(ap, AnalysisInfo *);
2367 if (info) 2487 if (info)
2368 OPUS_COPY(&st->analysis, info, 1); 2488 OPUS_COPY(&st->analysis, info, 1);
2369 } 2489 }
2370 break; 2490 break;
2491 case CELT_SET_SILK_INFO_REQUEST:
2492 {
2493 SILKInfo *info = va_arg(ap, SILKInfo *);
2494 if (info)
2495 OPUS_COPY(&st->silk_info, info, 1);
2496 }
2497 break;
2371 case CELT_GET_MODE_REQUEST: 2498 case CELT_GET_MODE_REQUEST:
2372 { 2499 {
2373 const CELTMode ** value = va_arg(ap, const CELTMode**); 2500 const CELTMode ** value = va_arg(ap, const CELTMode**);
2374 if (value==0) 2501 if (value==0)
2375 goto bad_arg; 2502 goto bad_arg;
2376 *value=st->mode; 2503 *value=st->mode;
2377 } 2504 }
2378 break; 2505 break;
2379 case OPUS_GET_FINAL_RANGE_REQUEST: 2506 case OPUS_GET_FINAL_RANGE_REQUEST:
2380 { 2507 {
(...skipping 20 matching lines...) Expand all
2401 } 2528 }
2402 va_end(ap); 2529 va_end(ap);
2403 return OPUS_OK; 2530 return OPUS_OK;
2404 bad_arg: 2531 bad_arg:
2405 va_end(ap); 2532 va_end(ap);
2406 return OPUS_BAD_ARG; 2533 return OPUS_BAD_ARG;
2407 bad_request: 2534 bad_request:
2408 va_end(ap); 2535 va_end(ap);
2409 return OPUS_UNIMPLEMENTED; 2536 return OPUS_UNIMPLEMENTED;
2410 } 2537 }
OLDNEW
« no previous file with comments | « third_party/opus/src/celt/celt_decoder.c ('k') | third_party/opus/src/celt/celt_lpc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698