FFmpeg
opus_silk.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Andrew D'Addesio
3  * Copyright (c) 2013-2014 Mozilla Corporation
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Opus SILK decoder
25  */
26 
27 #include <stdint.h>
28 
29 #include "mathops.h"
30 #include "opus.h"
31 #include "opus_rc.h"
32 #include "opus_silk.h"
33 #include "opustab.h"
34 
35 #define ROUND_MULL(a,b,s) (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
36 
37 typedef struct SilkFrame {
38  int coded;
39  int log_gain;
40  int16_t nlsf[16];
41  float lpc[16];
42 
43  float output [2 * SILK_HISTORY];
46 
48 } SilkFrame;
49 
50 struct SilkContext {
51  void *logctx;
53 
54  int midonly;
55  int subframes;
56  int sflength;
57  int flength;
59 
61  int wb;
62 
65  float stereo_weights[2];
66 
68 };
69 
70 static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
71 {
72  int pass, i;
73  for (pass = 0; pass < 20; pass++) {
74  int k, min_diff = 0;
75  for (i = 0; i < order+1; i++) {
76  int low = i != 0 ? nlsf[i-1] : 0;
77  int high = i != order ? nlsf[i] : 32768;
78  int diff = (high - low) - (min_delta[i]);
79 
80  if (diff < min_diff) {
81  min_diff = diff;
82  k = i;
83 
84  if (pass == 20)
85  break;
86  }
87  }
88  if (min_diff == 0) /* no issues; stabilized */
89  return;
90 
91  /* wiggle one or two LSFs */
92  if (k == 0) {
93  /* repel away from lower bound */
94  nlsf[0] = min_delta[0];
95  } else if (k == order) {
96  /* repel away from higher bound */
97  nlsf[order-1] = 32768 - min_delta[order];
98  } else {
99  /* repel away from current position */
100  int min_center = 0, max_center = 32768, center_val;
101 
102  /* lower extent */
103  for (i = 0; i < k; i++)
104  min_center += min_delta[i];
105  min_center += min_delta[k] >> 1;
106 
107  /* upper extent */
108  for (i = order; i > k; i--)
109  max_center -= min_delta[i];
110  max_center -= min_delta[k] >> 1;
111 
112  /* move apart */
113  center_val = nlsf[k - 1] + nlsf[k];
114  center_val = (center_val >> 1) + (center_val & 1); // rounded divide by 2
115  center_val = FFMIN(max_center, FFMAX(min_center, center_val));
116 
117  nlsf[k - 1] = center_val - (min_delta[k] >> 1);
118  nlsf[k] = nlsf[k - 1] + min_delta[k];
119  }
120  }
121 
122  /* resort to the fall-back method, the standard method for LSF stabilization */
123 
124  /* sort; as the LSFs should be nearly sorted, use insertion sort */
125  for (i = 1; i < order; i++) {
126  int j, value = nlsf[i];
127  for (j = i - 1; j >= 0 && nlsf[j] > value; j--)
128  nlsf[j + 1] = nlsf[j];
129  nlsf[j + 1] = value;
130  }
131 
132  /* push forwards to increase distance */
133  if (nlsf[0] < min_delta[0])
134  nlsf[0] = min_delta[0];
135  for (i = 1; i < order; i++)
136  nlsf[i] = FFMAX(nlsf[i], FFMIN(nlsf[i - 1] + min_delta[i], 32767));
137 
138  /* push backwards to increase distance */
139  if (nlsf[order-1] > 32768 - min_delta[order])
140  nlsf[order-1] = 32768 - min_delta[order];
141  for (i = order-2; i >= 0; i--)
142  if (nlsf[i] > nlsf[i + 1] - min_delta[i+1])
143  nlsf[i] = nlsf[i + 1] - min_delta[i+1];
144 
145  return;
146 }
147 
148 static inline int silk_is_lpc_stable(const int16_t lpc[16], int order)
149 {
150  int k, j, DC_resp = 0;
151  int32_t lpc32[2][16]; // Q24
152  int totalinvgain = 1 << 30; // 1.0 in Q30
153  int32_t *row = lpc32[0], *prevrow;
154 
155  /* initialize the first row for the Levinson recursion */
156  for (k = 0; k < order; k++) {
157  DC_resp += lpc[k];
158  row[k] = lpc[k] * 4096;
159  }
160 
161  if (DC_resp >= 4096)
162  return 0;
163 
164  /* check if prediction gain pushes any coefficients too far */
165  for (k = order - 1; 1; k--) {
166  int rc; // Q31; reflection coefficient
167  int gaindiv; // Q30; inverse of the gain (the divisor)
168  int gain; // gain for this reflection coefficient
169  int fbits; // fractional bits used for the gain
170  int error; // Q29; estimate of the error of our partial estimate of 1/gaindiv
171 
172  if (FFABS(row[k]) > 16773022)
173  return 0;
174 
175  rc = -(row[k] * 128);
176  gaindiv = (1 << 30) - MULH(rc, rc);
177 
178  totalinvgain = MULH(totalinvgain, gaindiv) << 2;
179  if (k == 0)
180  return (totalinvgain >= 107374);
181 
182  /* approximate 1.0/gaindiv */
183  fbits = opus_ilog(gaindiv);
184  gain = ((1 << 29) - 1) / (gaindiv >> (fbits + 1 - 16)); // Q<fbits-16>
185  error = (1 << 29) - MULL(gaindiv << (15 + 16 - fbits), gain, 16);
186  gain = ((gain << 16) + (error * gain >> 13));
187 
188  /* switch to the next row of the LPC coefficients */
189  prevrow = row;
190  row = lpc32[k & 1];
191 
192  for (j = 0; j < k; j++) {
193  int x = av_sat_sub32(prevrow[j], ROUND_MULL(prevrow[k - j - 1], rc, 31));
194  int64_t tmp = ROUND_MULL(x, gain, fbits);
195 
196  /* per RFC 8251 section 6, if this calculation overflows, the filter
197  is considered unstable. */
198  if (tmp < INT32_MIN || tmp > INT32_MAX)
199  return 0;
200 
201  row[j] = (int32_t)tmp;
202  }
203  }
204 }
205 
206 static void silk_lsp2poly(const int32_t lsp[/* 2 * half_order - 1 */],
207  int32_t pol[/* half_order + 1 */], int half_order)
208 {
209  int i, j;
210 
211  pol[0] = 65536; // 1.0 in Q16
212  pol[1] = -lsp[0];
213 
214  for (i = 1; i < half_order; i++) {
215  pol[i + 1] = pol[i - 1] * 2 - ROUND_MULL(lsp[2 * i], pol[i], 16);
216  for (j = i; j > 1; j--)
217  pol[j] += pol[j - 2] - ROUND_MULL(lsp[2 * i], pol[j - 1], 16);
218 
219  pol[1] -= lsp[2 * i];
220  }
221 }
222 
223 static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
224 {
225  int i, k;
226  int32_t lsp[16]; // Q17; 2*cos(LSF)
227  int32_t p[9], q[9]; // Q16
228  int32_t lpc32[16]; // Q17
229  int16_t lpc[16]; // Q12
230 
231  /* convert the LSFs to LSPs, i.e. 2*cos(LSF) */
232  for (k = 0; k < order; k++) {
233  int index = nlsf[k] >> 8;
234  int offset = nlsf[k] & 255;
235  int k2 = (order == 10) ? ff_silk_lsf_ordering_nbmb[k] : ff_silk_lsf_ordering_wb[k];
236 
237  /* interpolate and round */
238  lsp[k2] = ff_silk_cosine[index] * 256;
239  lsp[k2] += (ff_silk_cosine[index + 1] - ff_silk_cosine[index]) * offset;
240  lsp[k2] = (lsp[k2] + 4) >> 3;
241  }
242 
243  silk_lsp2poly(lsp , p, order >> 1);
244  silk_lsp2poly(lsp + 1, q, order >> 1);
245 
246  /* reconstruct A(z) */
247  for (k = 0; k < order>>1; k++) {
248  int32_t p_tmp = p[k + 1] + p[k];
249  int32_t q_tmp = q[k + 1] - q[k];
250  lpc32[k] = -q_tmp - p_tmp;
251  lpc32[order-k-1] = q_tmp - p_tmp;
252  }
253 
254  /* limit the range of the LPC coefficients to each fit within an int16_t */
255  for (i = 0; i < 10; i++) {
256  int j;
257  unsigned int maxabs = 0;
258  for (j = 0, k = 0; j < order; j++) {
259  unsigned int x = FFABS(lpc32[k]);
260  if (x > maxabs) {
261  maxabs = x; // Q17
262  k = j;
263  }
264  }
265 
266  maxabs = (maxabs + 16) >> 5; // convert to Q12
267 
268  if (maxabs > 32767) {
269  /* perform bandwidth expansion */
270  unsigned int chirp, chirp_base; // Q16
271  maxabs = FFMIN(maxabs, 163838); // anything above this overflows chirp's numerator
272  chirp_base = chirp = 65470 - ((maxabs - 32767) << 14) / ((maxabs * (k+1)) >> 2);
273 
274  for (k = 0; k < order; k++) {
275  lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
276  chirp = (chirp_base * chirp + 32768) >> 16;
277  }
278  } else break;
279  }
280 
281  if (i == 10) {
282  /* time's up: just clamp */
283  for (k = 0; k < order; k++) {
284  int x = (lpc32[k] + 16) >> 5;
285  lpc[k] = av_clip_int16(x);
286  lpc32[k] = lpc[k] << 5; // shortcut mandated by the spec; drops lower 5 bits
287  }
288  } else {
289  for (k = 0; k < order; k++)
290  lpc[k] = (lpc32[k] + 16) >> 5;
291  }
292 
293  /* if the prediction gain causes the LPC filter to become unstable,
294  apply further bandwidth expansion on the Q17 coefficients */
295  for (i = 1; i <= 16 && !silk_is_lpc_stable(lpc, order); i++) {
296  unsigned int chirp, chirp_base;
297  chirp_base = chirp = 65536 - (1 << i);
298 
299  for (k = 0; k < order; k++) {
300  lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
301  lpc[k] = (lpc32[k] + 16) >> 5;
302  chirp = (chirp_base * chirp + 32768) >> 16;
303  }
304  }
305 
306  for (i = 0; i < order; i++)
307  lpcf[i] = lpc[i] / 4096.0f;
308 }
309 
311  OpusRangeCoder *rc,
312  float lpc_leadin[16], float lpc[16],
313  int *lpc_order, int *has_lpc_leadin, int voiced)
314 {
315  int i;
316  int order; // order of the LP polynomial; 10 for NB/MB and 16 for WB
317  int8_t lsf_i1, lsf_i2[16]; // stage-1 and stage-2 codebook indices
318  int16_t lsf_res[16]; // residual as a Q10 value
319  int16_t nlsf[16]; // Q15
320 
321  *lpc_order = order = s->wb ? 16 : 10;
322 
323  /* obtain LSF stage-1 and stage-2 indices */
324  lsf_i1 = ff_opus_rc_dec_cdf(rc, ff_silk_model_lsf_s1[s->wb][voiced]);
325  for (i = 0; i < order; i++) {
326  int index = s->wb ? ff_silk_lsf_s2_model_sel_wb [lsf_i1][i] :
328  lsf_i2[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_lsf_s2[index]) - 4;
329  if (lsf_i2[i] == -4)
331  else if (lsf_i2[i] == 4)
333  }
334 
335  /* reverse the backwards-prediction step */
336  for (i = order - 1; i >= 0; i--) {
337  int qstep = s->wb ? 9830 : 11796;
338 
339  lsf_res[i] = lsf_i2[i] * 1024;
340  if (lsf_i2[i] < 0) lsf_res[i] += 102;
341  else if (lsf_i2[i] > 0) lsf_res[i] -= 102;
342  lsf_res[i] = (lsf_res[i] * qstep) >> 16;
343 
344  if (i + 1 < order) {
347  lsf_res[i] += (lsf_res[i+1] * weight) >> 8;
348  }
349  }
350 
351  /* reconstruct the NLSF coefficients from the supplied indices */
352  for (i = 0; i < order; i++) {
353  const uint8_t * codebook = s->wb ? ff_silk_lsf_codebook_wb [lsf_i1] :
355  int cur, prev, next, weight_sq, weight, ipart, fpart, y, value;
356 
357  /* find the weight of the residual */
358  /* TODO: precompute */
359  cur = codebook[i];
360  prev = i ? codebook[i - 1] : 0;
361  next = i + 1 < order ? codebook[i + 1] : 256;
362  weight_sq = (1024 / (cur - prev) + 1024 / (next - cur)) << 16;
363 
364  /* approximate square-root with mandated fixed-point arithmetic */
365  ipart = opus_ilog(weight_sq);
366  fpart = (weight_sq >> (ipart-8)) & 127;
367  y = ((ipart & 1) ? 32768 : 46214) >> ((32 - ipart)>>1);
368  weight = y + ((213 * fpart * y) >> 16);
369 
370  value = cur * 128 + (lsf_res[i] * 16384) / weight;
371  nlsf[i] = av_clip_uintp2(value, 15);
372  }
373 
374  /* stabilize the NLSF coefficients */
375  silk_stabilize_lsf(nlsf, order, s->wb ? ff_silk_lsf_min_spacing_wb :
377 
378  /* produce an interpolation for the first 2 subframes, */
379  /* and then convert both sets of NLSFs to LPC coefficients */
380  *has_lpc_leadin = 0;
381  if (s->subframes == 4) {
383  if (offset != 4 && frame->coded) {
384  *has_lpc_leadin = 1;
385  if (offset != 0) {
386  int16_t nlsf_leadin[16];
387  for (i = 0; i < order; i++)
388  nlsf_leadin[i] = frame->nlsf[i] +
389  ((nlsf[i] - frame->nlsf[i]) * offset >> 2);
390  silk_lsf2lpc(nlsf_leadin, lpc_leadin, order);
391  } else /* avoid re-computation for a (roughly) 1-in-4 occurrence */
392  memcpy(lpc_leadin, frame->lpc, 16 * sizeof(float));
393  } else
394  offset = 4;
395  s->nlsf_interp_factor = offset;
396 
397  silk_lsf2lpc(nlsf, lpc, order);
398  } else {
399  s->nlsf_interp_factor = 4;
400  silk_lsf2lpc(nlsf, lpc, order);
401  }
402 
403  memcpy(frame->nlsf, nlsf, order * sizeof(nlsf[0]));
404  memcpy(frame->lpc, lpc, order * sizeof(lpc[0]));
405 }
406 
407 static inline void silk_count_children(OpusRangeCoder *rc, int model, int32_t total,
408  int32_t child[2])
409 {
410  if (total != 0) {
411  child[0] = ff_opus_rc_dec_cdf(rc,
412  ff_silk_model_pulse_location[model] + (((total - 1 + 5) * (total - 1)) >> 1));
413  child[1] = total - child[0];
414  } else {
415  child[0] = 0;
416  child[1] = 0;
417  }
418 }
419 
421  float* excitationf,
422  int qoffset_high, int active, int voiced)
423 {
424  int i;
425  uint32_t seed;
426  int shellblocks;
427  int ratelevel;
428  uint8_t pulsecount[20]; // total pulses in each shell block
429  uint8_t lsbcount[20] = {0}; // raw lsbits defined for each pulse in each shell block
430  int32_t excitation[320]; // Q23
431 
432  /* excitation parameters */
434  shellblocks = ff_silk_shell_blocks[s->bandwidth][s->subframes >> 2];
435  ratelevel = ff_opus_rc_dec_cdf(rc, ff_silk_model_exc_rate[voiced]);
436 
437  for (i = 0; i < shellblocks; i++) {
438  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[ratelevel]);
439  if (pulsecount[i] == 17) {
440  while (pulsecount[i] == 17 && ++lsbcount[i] != 10)
441  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[9]);
442  if (lsbcount[i] == 10)
443  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[10]);
444  }
445  }
446 
447  /* decode pulse locations using PVQ */
448  for (i = 0; i < shellblocks; i++) {
449  if (pulsecount[i] != 0) {
450  int a, b, c, d;
451  int32_t * location = excitation + 16*i;
452  int32_t branch[4][2];
453  branch[0][0] = pulsecount[i];
454 
455  /* unrolled tail recursion */
456  for (a = 0; a < 1; a++) {
457  silk_count_children(rc, 0, branch[0][a], branch[1]);
458  for (b = 0; b < 2; b++) {
459  silk_count_children(rc, 1, branch[1][b], branch[2]);
460  for (c = 0; c < 2; c++) {
461  silk_count_children(rc, 2, branch[2][c], branch[3]);
462  for (d = 0; d < 2; d++) {
463  silk_count_children(rc, 3, branch[3][d], location);
464  location += 2;
465  }
466  }
467  }
468  }
469  } else
470  memset(excitation + 16*i, 0, 16*sizeof(int32_t));
471  }
472 
473  /* decode least significant bits */
474  for (i = 0; i < shellblocks << 4; i++) {
475  int bit;
476  for (bit = 0; bit < lsbcount[i >> 4]; bit++)
477  excitation[i] = (excitation[i] << 1) |
479  }
480 
481  /* decode signs */
482  for (i = 0; i < shellblocks << 4; i++) {
483  if (excitation[i] != 0) {
484  int sign = ff_opus_rc_dec_cdf(rc, ff_silk_model_excitation_sign[active +
485  voiced][qoffset_high][FFMIN(pulsecount[i >> 4], 6)]);
486  if (sign == 0)
487  excitation[i] *= -1;
488  }
489  }
490 
491  /* assemble the excitation */
492  for (i = 0; i < shellblocks << 4; i++) {
493  int value = excitation[i];
494  excitation[i] = value * 256 | ff_silk_quant_offset[voiced][qoffset_high];
495  if (value < 0) excitation[i] += 20;
496  else if (value > 0) excitation[i] -= 20;
497 
498  /* invert samples pseudorandomly */
499  seed = 196314165 * seed + 907633515;
500  if (seed & 0x80000000)
501  excitation[i] *= -1;
502  seed += value;
503 
504  excitationf[i] = excitation[i] / 8388608.0f;
505  }
506 }
507 
508 /** Maximum residual history according to 4.2.7.6.1 */
509 #define SILK_MAX_LAG (288 + LTP_ORDER / 2)
510 
511 /** Order of the LTP filter */
512 #define LTP_ORDER 5
513 
515  int frame_num, int channel, int coded_channels,
516  int active, int active1, int redundant)
517 {
518  /* per frame */
519  int voiced; // combines with active to indicate inactive, active, or active+voiced
520  int qoffset_high;
521  int order; // order of the LPC coefficients
522  float lpc_leadin[16], lpc_body[16], residual[SILK_MAX_LAG + SILK_HISTORY];
523  int has_lpc_leadin;
524  float ltpscale;
525 
526  /* per subframe */
527  struct {
528  float gain;
529  int pitchlag;
530  float ltptaps[5];
531  } sf[4];
532 
533  SilkFrame * const frame = s->frame + channel;
534 
535  int i;
536 
537  /* obtain stereo weights */
538  if (coded_channels == 2 && channel == 0) {
539  int n, wi[2], ws[2], w[2];
541  wi[0] = ff_opus_rc_dec_cdf(rc, ff_silk_model_stereo_s2) + 3 * (n / 5);
543  wi[1] = ff_opus_rc_dec_cdf(rc, ff_silk_model_stereo_s2) + 3 * (n % 5);
545 
546  for (i = 0; i < 2; i++)
547  w[i] = ff_silk_stereo_weights[wi[i]] +
548  (((ff_silk_stereo_weights[wi[i] + 1] - ff_silk_stereo_weights[wi[i]]) * 6554) >> 16)
549  * (ws[i]*2 + 1);
550 
551  s->stereo_weights[0] = (w[0] - w[1]) / 8192.0;
552  s->stereo_weights[1] = w[1] / 8192.0;
553 
554  /* and read the mid-only flag */
555  s->midonly = active1 ? 0 : ff_opus_rc_dec_cdf(rc, ff_silk_model_mid_only);
556  }
557 
558  /* obtain frame type */
559  if (!active) {
561  voiced = 0;
562  } else {
564  qoffset_high = type & 1;
565  voiced = type >> 1;
566  }
567 
568  /* obtain subframe quantization gains */
569  for (i = 0; i < s->subframes; i++) {
570  int log_gain; //Q7
571  int ipart, fpart, lingain;
572 
573  if (i == 0 && (frame_num == 0 || !frame->coded)) {
574  /* gain is coded absolute */
575  int x = ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_highbits[active + voiced]);
576  log_gain = (x<<3) | ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_lowbits);
577 
578  if (frame->coded)
579  log_gain = FFMAX(log_gain, frame->log_gain - 16);
580  } else {
581  /* gain is coded relative */
582  int delta_gain = ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_delta);
583  log_gain = av_clip_uintp2(FFMAX((delta_gain<<1) - 16,
584  frame->log_gain + delta_gain - 4), 6);
585  }
586 
587  frame->log_gain = log_gain;
588 
589  /* approximate 2**(x/128) with a Q7 (i.e. non-integer) input */
590  log_gain = (log_gain * 0x1D1C71 >> 16) + 2090;
591  ipart = log_gain >> 7;
592  fpart = log_gain & 127;
593  lingain = (1 << ipart) + ((-174 * fpart * (128-fpart) >>16) + fpart) * ((1<<ipart) >> 7);
594  sf[i].gain = lingain / 65536.0f;
595  }
596 
597  /* obtain LPC filter coefficients */
598  silk_decode_lpc(s, frame, rc, lpc_leadin, lpc_body, &order, &has_lpc_leadin, voiced);
599 
600  /* obtain pitch lags, if this is a voiced frame */
601  if (voiced) {
602  int lag_absolute = (!frame_num || !frame->prev_voiced);
603  int primarylag; // primary pitch lag for the entire SILK frame
604  int ltpfilter;
605  const int8_t * offsets;
606 
607  if (!lag_absolute) {
609  if (delta)
610  primarylag = frame->primarylag + delta - 9;
611  else
612  lag_absolute = 1;
613  }
614 
615  if (lag_absolute) {
616  /* primary lag is coded absolute */
617  int highbits, lowbits;
618  static const uint16_t * const model[] = {
621  };
623  lowbits = ff_opus_rc_dec_cdf(rc, model[s->bandwidth]);
624 
625  primarylag = ff_silk_pitch_min_lag[s->bandwidth] +
626  highbits*ff_silk_pitch_scale[s->bandwidth] + lowbits;
627  }
628  frame->primarylag = primarylag;
629 
630  if (s->subframes == 2)
631  offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
636  else
637  offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
642 
643  for (i = 0; i < s->subframes; i++)
644  sf[i].pitchlag = av_clip(primarylag + offsets[i],
645  ff_silk_pitch_min_lag[s->bandwidth],
646  ff_silk_pitch_max_lag[s->bandwidth]);
647 
648  /* obtain LTP filter coefficients */
650  for (i = 0; i < s->subframes; i++) {
651  int index, j;
652  static const uint16_t * const filter_sel[] = {
655  };
656  static const int8_t (* const filter_taps[])[5] = {
658  };
659  index = ff_opus_rc_dec_cdf(rc, filter_sel[ltpfilter]);
660  for (j = 0; j < 5; j++)
661  sf[i].ltptaps[j] = filter_taps[ltpfilter][index][j] / 128.0f;
662  }
663  }
664 
665  /* obtain LTP scale factor */
666  if (voiced && frame_num == 0)
668  ff_silk_model_ltp_scale_index)] / 16384.0f;
669  else ltpscale = 15565.0f/16384.0f;
670 
671  /* generate the excitation signal for the entire frame */
672  silk_decode_excitation(s, rc, residual + SILK_MAX_LAG, qoffset_high,
673  active, voiced);
674 
675  /* skip synthesising the output if we do not need it */
676  // TODO: implement error recovery
677  if (s->output_channels == channel || redundant)
678  return;
679 
680  /* generate the output signal */
681  for (i = 0; i < s->subframes; i++) {
682  const float * lpc_coeff = (i < 2 && has_lpc_leadin) ? lpc_leadin : lpc_body;
683  float *dst = frame->output + SILK_HISTORY + i * s->sflength;
684  float *resptr = residual + SILK_MAX_LAG + i * s->sflength;
685  float *lpc = frame->lpc_history + SILK_HISTORY + i * s->sflength;
686  float sum;
687  int j, k;
688 
689  if (voiced) {
690  int out_end;
691  float scale;
692 
693  if (i < 2 || s->nlsf_interp_factor == 4) {
694  out_end = -i * s->sflength;
695  scale = ltpscale;
696  } else {
697  out_end = -(i - 2) * s->sflength;
698  scale = 1.0f;
699  }
700 
701  /* when the LPC coefficients change, a re-whitening filter is used */
702  /* to produce a residual that accounts for the change */
703  for (j = - sf[i].pitchlag - LTP_ORDER/2; j < out_end; j++) {
704  sum = dst[j];
705  for (k = 0; k < order; k++)
706  sum -= lpc_coeff[k] * dst[j - k - 1];
707  resptr[j] = av_clipf(sum, -1.0f, 1.0f) * scale / sf[i].gain;
708  }
709 
710  if (out_end) {
711  float rescale = sf[i-1].gain / sf[i].gain;
712  for (j = out_end; j < 0; j++)
713  resptr[j] *= rescale;
714  }
715 
716  /* LTP synthesis */
717  for (j = 0; j < s->sflength; j++) {
718  sum = resptr[j];
719  for (k = 0; k < LTP_ORDER; k++)
720  sum += sf[i].ltptaps[k] * resptr[j - sf[i].pitchlag + LTP_ORDER/2 - k];
721  resptr[j] = sum;
722  }
723  }
724 
725  /* LPC synthesis */
726  for (j = 0; j < s->sflength; j++) {
727  sum = resptr[j] * sf[i].gain;
728  for (k = 1; k <= order; k++)
729  sum += lpc_coeff[k - 1] * lpc[j - k];
730 
731  lpc[j] = sum;
732  dst[j] = av_clipf(sum, -1.0f, 1.0f);
733  }
734  }
735 
736  frame->prev_voiced = voiced;
737  memmove(frame->lpc_history, frame->lpc_history + s->flength, SILK_HISTORY * sizeof(float));
738  memmove(frame->output, frame->output + s->flength, SILK_HISTORY * sizeof(float));
739 
740  frame->coded = 1;
741 }
742 
743 static void silk_unmix_ms(SilkContext *s, float *l, float *r)
744 {
745  float *mid = s->frame[0].output + SILK_HISTORY - s->flength;
746  float *side = s->frame[1].output + SILK_HISTORY - s->flength;
747  float w0_prev = s->prev_stereo_weights[0];
748  float w1_prev = s->prev_stereo_weights[1];
749  float w0 = s->stereo_weights[0];
750  float w1 = s->stereo_weights[1];
751  int n1 = ff_silk_stereo_interp_len[s->bandwidth];
752  int i;
753 
754  for (i = 0; i < n1; i++) {
755  float interp0 = w0_prev + i * (w0 - w0_prev) / n1;
756  float interp1 = w1_prev + i * (w1 - w1_prev) / n1;
757  float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
758 
759  l[i] = av_clipf((1 + interp1) * mid[i - 1] + side[i - 1] + interp0 * p0, -1.0, 1.0);
760  r[i] = av_clipf((1 - interp1) * mid[i - 1] - side[i - 1] - interp0 * p0, -1.0, 1.0);
761  }
762 
763  for (; i < s->flength; i++) {
764  float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
765 
766  l[i] = av_clipf((1 + w1) * mid[i - 1] + side[i - 1] + w0 * p0, -1.0, 1.0);
767  r[i] = av_clipf((1 - w1) * mid[i - 1] - side[i - 1] - w0 * p0, -1.0, 1.0);
768  }
769 
770  memcpy(s->prev_stereo_weights, s->stereo_weights, sizeof(s->stereo_weights));
771 }
772 
774 {
775  if (!frame->coded)
776  return;
777 
778  memset(frame->output, 0, sizeof(frame->output));
779  memset(frame->lpc_history, 0, sizeof(frame->lpc_history));
780 
781  memset(frame->lpc, 0, sizeof(frame->lpc));
782  memset(frame->nlsf, 0, sizeof(frame->nlsf));
783 
784  frame->log_gain = 0;
785 
786  frame->primarylag = 0;
787  frame->prev_voiced = 0;
788  frame->coded = 0;
789 }
790 
792  float *output[2],
793  enum OpusBandwidth bandwidth,
794  int coded_channels,
795  int duration_ms)
796 {
797  int active[2][6], redundancy[2];
798  int nb_frames, i, j;
799 
800  if (bandwidth > OPUS_BANDWIDTH_WIDEBAND ||
801  coded_channels > 2 || duration_ms > 60) {
802  av_log(s->logctx, AV_LOG_ERROR, "Invalid parameters passed "
803  "to the SILK decoder.\n");
804  return AVERROR(EINVAL);
805  }
806 
807  nb_frames = 1 + (duration_ms > 20) + (duration_ms > 40);
808  s->subframes = duration_ms / nb_frames / 5; // 5ms subframes
809  s->sflength = 20 * (bandwidth + 2);
810  s->flength = s->sflength * s->subframes;
811  s->bandwidth = bandwidth;
812  s->wb = bandwidth == OPUS_BANDWIDTH_WIDEBAND;
813 
814  /* make sure to flush the side channel when switching from mono to stereo */
815  if (coded_channels > s->prev_coded_channels)
816  silk_flush_frame(&s->frame[1]);
817  s->prev_coded_channels = coded_channels;
818 
819  /* read the LP-layer header bits */
820  for (i = 0; i < coded_channels; i++) {
821  for (j = 0; j < nb_frames; j++)
822  active[i][j] = ff_opus_rc_dec_log(rc, 1);
823 
824  redundancy[i] = ff_opus_rc_dec_log(rc, 1);
825  }
826 
827  /* read the per-frame LBRR flags */
828  for (i = 0; i < coded_channels; i++)
829  if (redundancy[i] && duration_ms > 20) {
830  redundancy[i] = ff_opus_rc_dec_cdf(rc, duration_ms == 40 ?
832  }
833 
834  /* decode the LBRR frames */
835  for (i = 0; i < nb_frames; i++) {
836  for (j = 0; j < coded_channels; j++)
837  if (redundancy[j] & (1 << i)) {
838  int active1 = (j == 0 && !(redundancy[1] & (1 << i))) ? 0 : 1;
839  silk_decode_frame(s, rc, i, j, coded_channels, 1, active1, 1);
840  }
841 
842  s->midonly = 0;
843  }
844 
845  for (i = 0; i < nb_frames; i++) {
846  for (j = 0; j < coded_channels && !s->midonly; j++)
847  silk_decode_frame(s, rc, i, j, coded_channels, active[j][i], active[1][i], 0);
848 
849  /* reset the side channel if it is not coded */
850  if (s->midonly && s->frame[1].coded)
851  silk_flush_frame(&s->frame[1]);
852 
853  if (coded_channels == 1 || s->output_channels == 1) {
854  for (j = 0; j < s->output_channels; j++) {
855  memcpy(output[j] + i * s->flength,
856  s->frame[0].output + SILK_HISTORY - s->flength - 2,
857  s->flength * sizeof(float));
858  }
859  } else {
860  silk_unmix_ms(s, output[0] + i * s->flength, output[1] + i * s->flength);
861  }
862 
863  s->midonly = 0;
864  }
865 
866  return nb_frames * s->flength;
867 }
868 
870 {
871  av_freep(ps);
872 }
873 
875 {
876  silk_flush_frame(&s->frame[0]);
877  silk_flush_frame(&s->frame[1]);
878 
879  memset(s->prev_stereo_weights, 0, sizeof(s->prev_stereo_weights));
880 }
881 
882 int ff_silk_init(void *logctx, SilkContext **ps, int output_channels)
883 {
884  SilkContext *s;
885 
886  if (output_channels != 1 && output_channels != 2) {
887  av_log(logctx, AV_LOG_ERROR, "Invalid number of output channels: %d\n",
888  output_channels);
889  return AVERROR(EINVAL);
890  }
891 
892  s = av_mallocz(sizeof(*s));
893  if (!s)
894  return AVERROR(ENOMEM);
895 
896  s->logctx = logctx;
897  s->output_channels = output_channels;
898 
899  ff_silk_flush(s);
900 
901  *ps = s;
902 
903  return 0;
904 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:31
ff_silk_model_ltp_filter1_sel
const uint16_t ff_silk_model_ltp_filter1_sel[]
Definition: opustab.c:146
ff_silk_model_lbrr_flags_40
const uint16_t ff_silk_model_lbrr_flags_40[]
Definition: opustab.c:31
ff_silk_model_mid_only
const uint16_t ff_silk_model_mid_only[]
Definition: opustab.c:43
silk_flush_frame
static void silk_flush_frame(SilkFrame *frame)
Definition: opus_silk.c:773
ff_silk_model_exc_rate
const uint16_t ff_silk_model_exc_rate[2][10]
Definition: opustab.c:159
ff_silk_model_lsf_interpolation_offset
const uint16_t ff_silk_model_lsf_interpolation_offset[]
Definition: opustab.c:106
av_clip
#define av_clip
Definition: common.h:96
SilkFrame::lpc_history
float lpc_history[2 *SILK_HISTORY]
Definition: opus_silk.c:44
r
const char * r
Definition: vf_curves.c:126
LTP_ORDER
#define LTP_ORDER
Order of the LTP filter.
Definition: opus_silk.c:512
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
ff_silk_model_lsf_s2
const uint16_t ff_silk_model_lsf_s2[32][10]
Definition: opustab.c:82
OPUS_BANDWIDTH_NARROWBAND
@ OPUS_BANDWIDTH_NARROWBAND
Definition: opus.h:50
opus_ilog
#define opus_ilog(i)
Definition: opus_rc.h:30
SilkContext::prev_stereo_weights
float prev_stereo_weights[2]
Definition: opus_silk.c:64
ff_silk_model_pitch_contour_mbwb10ms
const uint16_t ff_silk_model_pitch_contour_mbwb10ms[]
Definition: opustab.c:130
ff_silk_lsf_ordering_nbmb
const uint8_t ff_silk_lsf_ordering_nbmb[]
Definition: opustab.c:554
av_clip_uintp2
#define av_clip_uintp2
Definition: common.h:120
SilkContext::output_channels
int output_channels
Definition: opus_silk.c:52
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
ff_silk_pitch_max_lag
const uint16_t ff_silk_pitch_max_lag[]
Definition: opustab.c:602
SilkContext::flength
int flength
Definition: opus_silk.c:57
SilkContext::logctx
void * logctx
Definition: opus_silk.c:51
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
w
uint8_t w
Definition: llviddspenc.c:38
SilkFrame::log_gain
int log_gain
Definition: opus_silk.c:39
SilkFrame::output
float output[2 *SILK_HISTORY]
Definition: opus_silk.c:43
b
#define b
Definition: input.c:41
ff_silk_model_frame_type_active
const uint16_t ff_silk_model_frame_type_active[]
Definition: opustab.c:47
opus.h
ff_silk_pitch_offset_nb20ms
const int8_t ff_silk_pitch_offset_nb20ms[11][4]
Definition: opustab.c:610
SilkContext::frame
SilkFrame frame[2]
Definition: opus_silk.c:63
ff_silk_model_gain_delta
const uint16_t ff_silk_model_gain_delta[]
Definition: opustab.c:57
silk_stabilize_lsf
static void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
Definition: opus_silk.c:70
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_silk_model_lsf_s1
const uint16_t ff_silk_model_lsf_s1[2][2][33]
Definition: opustab.c:62
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:56
ff_silk_shell_blocks
const uint8_t ff_silk_shell_blocks[3][2]
Definition: opustab.c:743
ff_silk_flush
void ff_silk_flush(SilkContext *s)
Definition: opus_silk.c:874
ff_silk_stereo_weights
const int16_t ff_silk_stereo_weights[]
Definition: opustab.c:321
ff_silk_model_ltp_scale_index
const uint16_t ff_silk_model_ltp_scale_index[]
Definition: opustab.c:155
SilkContext::bandwidth
enum OpusBandwidth bandwidth
Definition: opus_silk.c:60
ff_silk_lsf_codebook_wb
const uint8_t ff_silk_lsf_codebook_wb[32][16]
Definition: opustab.c:511
SilkFrame
Definition: opus_silk.c:37
ff_silk_model_pitch_contour_nb10ms
const uint16_t ff_silk_model_pitch_contour_nb10ms[]
Definition: opustab.c:124
ff_silk_model_pulse_location
const uint16_t ff_silk_model_pulse_location[4][168]
Definition: opustab.c:189
MULH
#define MULH
Definition: mathops.h:42
ff_silk_pitch_offset_mbwb20ms
const int8_t ff_silk_pitch_offset_mbwb20ms[34][4]
Definition: opustab.c:639
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
silk_lsp2poly
static void silk_lsp2poly(const int32_t lsp[], int32_t pol[], int half_order)
Definition: opus_silk.c:206
ff_silk_model_excitation_lsb
const uint16_t ff_silk_model_excitation_lsb[]
Definition: opustab.c:261
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ff_silk_lsf_s2_model_sel_wb
const uint8_t ff_silk_lsf_s2_model_sel_wb[32][16]
Definition: opustab.c:361
SilkFrame::lpc
float lpc[16]
Definition: opus_silk.c:41
s
#define s(width, name)
Definition: cbs_vp9.c:198
offsets
static const int offsets[]
Definition: hevc_pel.c:34
SILK_HISTORY
#define SILK_HISTORY
Definition: opus_silk.h:29
ff_silk_pitch_offset_mbwb10ms
const int8_t ff_silk_pitch_offset_mbwb10ms[12][2]
Definition: opustab.c:624
av_sat_sub32
#define av_sat_sub32
Definition: common.h:132
ff_silk_lsf_s2_model_sel_nbmb
const uint8_t ff_silk_lsf_s2_model_sel_nbmb[32][10]
Definition: opustab.c:326
frame
static AVFrame * frame
Definition: demux_decode.c:54
SilkContext
Definition: opus_silk.c:50
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:65
OPUS_BANDWIDTH_WIDEBAND
@ OPUS_BANDWIDTH_WIDEBAND
Definition: opus.h:52
silk_decode_lpc
static void silk_decode_lpc(SilkContext *s, SilkFrame *frame, OpusRangeCoder *rc, float lpc_leadin[16], float lpc[16], int *lpc_order, int *has_lpc_leadin, int voiced)
Definition: opus_silk.c:310
SILK_MAX_LAG
#define SILK_MAX_LAG
Maximum residual history according to 4.2.7.6.1.
Definition: opus_silk.c:509
ff_silk_model_gain_lowbits
const uint16_t ff_silk_model_gain_lowbits[]
Definition: opustab.c:55
av_clip_int16
#define av_clip_int16
Definition: common.h:111
SilkFrame::nlsf
int16_t nlsf[16]
Definition: opus_silk.c:40
ff_silk_model_stereo_s3
const uint16_t ff_silk_model_stereo_s3[]
Definition: opustab.c:41
mathops.h
ff_silk_quant_offset
const uint8_t ff_silk_quant_offset[2][2]
Definition: opustab.c:749
av_clipf
av_clipf
Definition: af_crystalizer.c:121
ff_silk_pitch_offset_nb10ms
const int8_t ff_silk_pitch_offset_nb10ms[3][2]
Definition: opustab.c:604
seed
static unsigned int seed
Definition: videogen.c:78
ff_silk_model_ltp_filter2_sel
const uint16_t ff_silk_model_ltp_filter2_sel[]
Definition: opustab.c:150
ff_silk_model_excitation_sign
const uint16_t ff_silk_model_excitation_sign[3][2][7][3]
Definition: opustab.c:263
ff_silk_init
int ff_silk_init(void *logctx, SilkContext **ps, int output_channels)
Definition: opus_silk.c:882
ff_silk_lsf_min_spacing_nbmb
const uint16_t ff_silk_lsf_min_spacing_nbmb[]
Definition: opustab.c:546
SilkContext::subframes
int subframes
Definition: opus_silk.c:55
index
int index
Definition: gxfenc.c:89
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
weight
static int weight(int i, int blen, int offset)
Definition: diracdec.c:1562
ff_silk_pitch_min_lag
const uint16_t ff_silk_pitch_min_lag[]
Definition: opustab.c:600
silk_unmix_ms
static void silk_unmix_ms(SilkContext *s, float *l, float *r)
Definition: opus_silk.c:743
ff_silk_lsf_codebook_nbmb
const uint8_t ff_silk_lsf_codebook_nbmb[32][10]
Definition: opustab.c:476
ff_silk_model_pitch_lowbits_nb
const uint16_t ff_silk_model_pitch_lowbits_nb[]
Definition: opustab.c:113
ff_silk_model_pitch_delta
const uint16_t ff_silk_model_pitch_delta[]
Definition: opustab.c:119
ff_silk_model_ltp_filter0_sel
const uint16_t ff_silk_model_ltp_filter0_sel[]
Definition: opustab.c:142
opustab.h
f
f
Definition: af_crystalizer.c:121
ff_silk_lsf_weight_sel_wb
const uint8_t ff_silk_lsf_weight_sel_wb[32][15]
Definition: opustab.c:441
ff_silk_model_pitch_contour_mbwb20ms
const uint16_t ff_silk_model_pitch_contour_mbwb20ms[]
Definition: opustab.c:134
rescale
static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, int scale_h)
Definition: gdv.c:131
ff_silk_lsf_ordering_wb
const uint8_t ff_silk_lsf_ordering_wb[]
Definition: opustab.c:558
ff_silk_lsf_pred_weights_wb
const uint8_t ff_silk_lsf_pred_weights_wb[2][15]
Definition: opustab.c:401
OpusRangeCoder
Definition: opus_rc.h:39
silk_lsf2lpc
static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
Definition: opus_silk.c:223
silk_decode_frame
static void silk_decode_frame(SilkContext *s, OpusRangeCoder *rc, int frame_num, int channel, int coded_channels, int active, int active1, int redundant)
Definition: opus_silk.c:514
ff_silk_model_pitch_highbits
const uint16_t ff_silk_model_pitch_highbits[]
Definition: opustab.c:108
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:164
ff_silk_ltp_filter2_taps
const int8_t ff_silk_ltp_filter2_taps[32][5]
Definition: opustab.c:706
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
silk_count_children
static void silk_count_children(OpusRangeCoder *rc, int model, int32_t total, int32_t child[2])
Definition: opus_silk.c:407
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
silk_is_lpc_stable
static int silk_is_lpc_stable(const int16_t lpc[16], int order)
Definition: opus_silk.c:148
ff_opus_rc_dec_cdf
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
Definition: opus_rc.c:90
ff_silk_cosine
const int16_t ff_silk_cosine[]
Definition: opustab.c:562
ff_silk_model_stereo_s1
const uint16_t ff_silk_model_stereo_s1[]
Definition: opustab.c:34
ff_silk_model_pitch_contour_nb20ms
const uint16_t ff_silk_model_pitch_contour_nb20ms[]
Definition: opustab.c:126
ff_silk_ltp_filter0_taps
const int8_t ff_silk_ltp_filter0_taps[8][5]
Definition: opustab.c:676
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
ff_silk_stereo_interp_len
const int ff_silk_stereo_interp_len[3]
Definition: opustab.c:754
ff_silk_model_pulse_count
const uint16_t ff_silk_model_pulse_count[11][19]
Definition: opustab.c:164
ff_silk_free
void ff_silk_free(SilkContext **ps)
Definition: opus_silk.c:869
SilkContext::nlsf_interp_factor
int nlsf_interp_factor
Definition: opus_silk.c:58
SilkFrame::coded
int coded
Definition: opus_silk.c:38
delta
float delta
Definition: vorbis_enc_data.h:430
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
SilkContext::prev_coded_channels
int prev_coded_channels
Definition: opus_silk.c:67
ff_silk_model_pitch_lowbits_mb
const uint16_t ff_silk_model_pitch_lowbits_mb[]
Definition: opustab.c:115
ff_silk_lsf_weight_sel_nbmb
const uint8_t ff_silk_lsf_weight_sel_nbmb[32][9]
Definition: opustab.c:406
silk_decode_excitation
static void silk_decode_excitation(SilkContext *s, OpusRangeCoder *rc, float *excitationf, int qoffset_high, int active, int voiced)
Definition: opus_silk.c:420
ff_silk_model_frame_type_inactive
const uint16_t ff_silk_model_frame_type_inactive[]
Definition: opustab.c:45
ff_silk_model_lsf_s2_ext
const uint16_t ff_silk_model_lsf_s2_ext[]
Definition: opustab.c:104
SilkFrame::primarylag
int primarylag
Definition: opus_silk.c:45
ff_silk_model_gain_highbits
const uint16_t ff_silk_model_gain_highbits[3][9]
Definition: opustab.c:49
SilkContext::stereo_weights
float stereo_weights[2]
Definition: opus_silk.c:65
SilkContext::sflength
int sflength
Definition: opus_silk.c:56
ff_silk_lsf_min_spacing_wb
const uint16_t ff_silk_lsf_min_spacing_wb[]
Definition: opustab.c:550
ROUND_MULL
#define ROUND_MULL(a, b, s)
Definition: opus_silk.c:35
SilkContext::midonly
int midonly
Definition: opus_silk.c:54
ff_silk_pitch_scale
const uint16_t ff_silk_pitch_scale[]
Definition: opustab.c:598
ff_silk_ltp_scale_factor
const uint16_t ff_silk_ltp_scale_factor[]
Definition: opustab.c:741
ff_silk_ltp_filter1_taps
const int8_t ff_silk_ltp_filter1_taps[16][5]
Definition: opustab.c:687
SilkContext::wb
int wb
Definition: opus_silk.c:61
ff_silk_lsf_pred_weights_nbmb
const uint8_t ff_silk_lsf_pred_weights_nbmb[2][9]
Definition: opustab.c:396
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
ff_silk_model_ltp_filter
const uint16_t ff_silk_model_ltp_filter[]
Definition: opustab.c:140
d
d
Definition: ffmpeg_filter.c:368
int32_t
int32_t
Definition: audioconvert.c:56
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
ff_silk_model_stereo_s2
const uint16_t ff_silk_model_stereo_s2[]
Definition: opustab.c:39
ff_opus_rc_dec_log
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
Definition: opus_rc.c:114
ff_silk_decode_superframe
int ff_silk_decode_superframe(SilkContext *s, OpusRangeCoder *rc, float *output[2], enum OpusBandwidth bandwidth, int coded_channels, int duration_ms)
Decode the LP layer of one Opus frame (which may correspond to several SILK frames).
Definition: opus_silk.c:791
MULL
#define MULL(a, b, s)
Definition: mathops.h:59
opus_rc.h
ff_silk_model_lcg_seed
const uint16_t ff_silk_model_lcg_seed[]
Definition: opustab.c:157
SilkFrame::prev_voiced
int prev_voiced
Definition: opus_silk.c:47
ff_silk_model_lbrr_flags_60
const uint16_t ff_silk_model_lbrr_flags_60[]
Definition: opustab.c:32
opus_silk.h
OpusBandwidth
OpusBandwidth
Definition: opus.h:49
channel
channel
Definition: ebur128.h:39
codebook
static const unsigned codebook[256][2]
Definition: cfhdenc.c:42
ff_silk_model_pitch_lowbits_wb
const uint16_t ff_silk_model_pitch_lowbits_wb[]
Definition: opustab.c:117