FFmpeg
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 "libavutil/mem.h"
30 #include "mathops.h"
31 #include "opus.h"
32 #include "rc.h"
33 #include "silk.h"
34 #include "tab.h"
35 
36 #define ROUND_MULL(a,b,s) (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
37 
38 typedef struct SilkFrame {
39  int coded;
40  int log_gain;
41  int16_t nlsf[16];
42  float lpc[16];
43 
44  float output [2 * SILK_HISTORY];
47 
49 } SilkFrame;
50 
51 struct SilkContext {
52  void *logctx;
54 
55  int midonly;
56  int subframes;
57  int sflength;
58  int flength;
60 
62  int wb;
63 
66  float stereo_weights[2];
67 
69 };
70 
71 static inline void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
72 {
73  int pass, i;
74  for (pass = 0; pass < 20; pass++) {
75  int k, min_diff = 0;
76  for (i = 0; i < order+1; i++) {
77  int low = i != 0 ? nlsf[i-1] : 0;
78  int high = i != order ? nlsf[i] : 32768;
79  int diff = (high - low) - (min_delta[i]);
80 
81  if (diff < min_diff) {
82  min_diff = diff;
83  k = i;
84 
85  if (pass == 20)
86  break;
87  }
88  }
89  if (min_diff == 0) /* no issues; stabilized */
90  return;
91 
92  /* wiggle one or two LSFs */
93  if (k == 0) {
94  /* repel away from lower bound */
95  nlsf[0] = min_delta[0];
96  } else if (k == order) {
97  /* repel away from higher bound */
98  nlsf[order-1] = 32768 - min_delta[order];
99  } else {
100  /* repel away from current position */
101  int min_center = 0, max_center = 32768, center_val;
102 
103  /* lower extent */
104  for (i = 0; i < k; i++)
105  min_center += min_delta[i];
106  min_center += min_delta[k] >> 1;
107 
108  /* upper extent */
109  for (i = order; i > k; i--)
110  max_center -= min_delta[i];
111  max_center -= min_delta[k] >> 1;
112 
113  /* move apart */
114  center_val = nlsf[k - 1] + nlsf[k];
115  center_val = (center_val >> 1) + (center_val & 1); // rounded divide by 2
116  center_val = FFMIN(max_center, FFMAX(min_center, center_val));
117 
118  nlsf[k - 1] = center_val - (min_delta[k] >> 1);
119  nlsf[k] = nlsf[k - 1] + min_delta[k];
120  }
121  }
122 
123  /* resort to the fall-back method, the standard method for LSF stabilization */
124 
125  /* sort; as the LSFs should be nearly sorted, use insertion sort */
126  for (i = 1; i < order; i++) {
127  int j, value = nlsf[i];
128  for (j = i - 1; j >= 0 && nlsf[j] > value; j--)
129  nlsf[j + 1] = nlsf[j];
130  nlsf[j + 1] = value;
131  }
132 
133  /* push forwards to increase distance */
134  if (nlsf[0] < min_delta[0])
135  nlsf[0] = min_delta[0];
136  for (i = 1; i < order; i++)
137  nlsf[i] = FFMAX(nlsf[i], FFMIN(nlsf[i - 1] + min_delta[i], 32767));
138 
139  /* push backwards to increase distance */
140  if (nlsf[order-1] > 32768 - min_delta[order])
141  nlsf[order-1] = 32768 - min_delta[order];
142  for (i = order-2; i >= 0; i--)
143  if (nlsf[i] > nlsf[i + 1] - min_delta[i+1])
144  nlsf[i] = nlsf[i + 1] - min_delta[i+1];
145 
146  return;
147 }
148 
149 static inline int silk_is_lpc_stable(const int16_t lpc[16], int order)
150 {
151  int k, j, DC_resp = 0;
152  int32_t lpc32[2][16]; // Q24
153  int totalinvgain = 1 << 30; // 1.0 in Q30
154  int32_t *row = lpc32[0], *prevrow;
155 
156  /* initialize the first row for the Levinson recursion */
157  for (k = 0; k < order; k++) {
158  DC_resp += lpc[k];
159  row[k] = lpc[k] * 4096;
160  }
161 
162  if (DC_resp >= 4096)
163  return 0;
164 
165  /* check if prediction gain pushes any coefficients too far */
166  for (k = order - 1; 1; k--) {
167  int rc; // Q31; reflection coefficient
168  int gaindiv; // Q30; inverse of the gain (the divisor)
169  int gain; // gain for this reflection coefficient
170  int fbits; // fractional bits used for the gain
171  int error; // Q29; estimate of the error of our partial estimate of 1/gaindiv
172 
173  if (FFABS(row[k]) > 16773022)
174  return 0;
175 
176  rc = -(row[k] * 128);
177  gaindiv = (1 << 30) - MULH(rc, rc);
178 
179  totalinvgain = MULH(totalinvgain, gaindiv) << 2;
180  if (k == 0)
181  return (totalinvgain >= 107374);
182 
183  /* approximate 1.0/gaindiv */
184  fbits = opus_ilog(gaindiv);
185  gain = ((1 << 29) - 1) / (gaindiv >> (fbits + 1 - 16)); // Q<fbits-16>
186  error = (1 << 29) - MULL(gaindiv << (15 + 16 - fbits), gain, 16);
187  gain = ((gain << 16) + (error * gain >> 13));
188 
189  /* switch to the next row of the LPC coefficients */
190  prevrow = row;
191  row = lpc32[k & 1];
192 
193  for (j = 0; j < k; j++) {
194  int x = av_sat_sub32(prevrow[j], ROUND_MULL(prevrow[k - j - 1], rc, 31));
195  int64_t tmp = ROUND_MULL(x, gain, fbits);
196 
197  /* per RFC 8251 section 6, if this calculation overflows, the filter
198  is considered unstable. */
199  if (tmp < INT32_MIN || tmp > INT32_MAX)
200  return 0;
201 
202  row[j] = (int32_t)tmp;
203  }
204  }
205 }
206 
207 static void silk_lsp2poly(const int32_t lsp[/* 2 * half_order - 1 */],
208  int32_t pol[/* half_order + 1 */], int half_order)
209 {
210  int i, j;
211 
212  pol[0] = 65536; // 1.0 in Q16
213  pol[1] = -lsp[0];
214 
215  for (i = 1; i < half_order; i++) {
216  pol[i + 1] = pol[i - 1] * 2 - ROUND_MULL(lsp[2 * i], pol[i], 16);
217  for (j = i; j > 1; j--)
218  pol[j] += pol[j - 2] - ROUND_MULL(lsp[2 * i], pol[j - 1], 16);
219 
220  pol[1] -= lsp[2 * i];
221  }
222 }
223 
224 static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
225 {
226  int i, k;
227  int32_t lsp[16]; // Q17; 2*cos(LSF)
228  int32_t p[9], q[9]; // Q16
229  int32_t lpc32[16]; // Q17
230  int16_t lpc[16]; // Q12
231 
232  /* convert the LSFs to LSPs, i.e. 2*cos(LSF) */
233  for (k = 0; k < order; k++) {
234  int index = nlsf[k] >> 8;
235  int offset = nlsf[k] & 255;
236  int k2 = (order == 10) ? ff_silk_lsf_ordering_nbmb[k] : ff_silk_lsf_ordering_wb[k];
237 
238  /* interpolate and round */
239  lsp[k2] = ff_silk_cosine[index] * 256;
240  lsp[k2] += (ff_silk_cosine[index + 1] - ff_silk_cosine[index]) * offset;
241  lsp[k2] = (lsp[k2] + 4) >> 3;
242  }
243 
244  silk_lsp2poly(lsp , p, order >> 1);
245  silk_lsp2poly(lsp + 1, q, order >> 1);
246 
247  /* reconstruct A(z) */
248  for (k = 0; k < order>>1; k++) {
249  int32_t p_tmp = p[k + 1] + p[k];
250  int32_t q_tmp = q[k + 1] - q[k];
251  lpc32[k] = -q_tmp - p_tmp;
252  lpc32[order-k-1] = q_tmp - p_tmp;
253  }
254 
255  /* limit the range of the LPC coefficients to each fit within an int16_t */
256  for (i = 0; i < 10; i++) {
257  int j;
258  unsigned int maxabs = 0;
259  for (j = 0, k = 0; j < order; j++) {
260  unsigned int x = FFABS(lpc32[k]);
261  if (x > maxabs) {
262  maxabs = x; // Q17
263  k = j;
264  }
265  }
266 
267  maxabs = (maxabs + 16) >> 5; // convert to Q12
268 
269  if (maxabs > 32767) {
270  /* perform bandwidth expansion */
271  unsigned int chirp, chirp_base; // Q16
272  maxabs = FFMIN(maxabs, 163838); // anything above this overflows chirp's numerator
273  chirp_base = chirp = 65470 - ((maxabs - 32767) << 14) / ((maxabs * (k+1)) >> 2);
274 
275  for (k = 0; k < order; k++) {
276  lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
277  chirp = (chirp_base * chirp + 32768) >> 16;
278  }
279  } else break;
280  }
281 
282  if (i == 10) {
283  /* time's up: just clamp */
284  for (k = 0; k < order; k++) {
285  int x = (lpc32[k] + 16) >> 5;
286  lpc[k] = av_clip_int16(x);
287  lpc32[k] = lpc[k] << 5; // shortcut mandated by the spec; drops lower 5 bits
288  }
289  } else {
290  for (k = 0; k < order; k++)
291  lpc[k] = (lpc32[k] + 16) >> 5;
292  }
293 
294  /* if the prediction gain causes the LPC filter to become unstable,
295  apply further bandwidth expansion on the Q17 coefficients */
296  for (i = 1; i <= 16 && !silk_is_lpc_stable(lpc, order); i++) {
297  unsigned int chirp, chirp_base;
298  chirp_base = chirp = 65536 - (1 << i);
299 
300  for (k = 0; k < order; k++) {
301  lpc32[k] = ROUND_MULL(lpc32[k], chirp, 16);
302  lpc[k] = (lpc32[k] + 16) >> 5;
303  chirp = (chirp_base * chirp + 32768) >> 16;
304  }
305  }
306 
307  for (i = 0; i < order; i++)
308  lpcf[i] = lpc[i] / 4096.0f;
309 }
310 
312  OpusRangeCoder *rc,
313  float lpc_leadin[16], float lpc[16],
314  int *lpc_order, int *has_lpc_leadin, int voiced)
315 {
316  int i;
317  int order; // order of the LP polynomial; 10 for NB/MB and 16 for WB
318  int8_t lsf_i1, lsf_i2[16]; // stage-1 and stage-2 codebook indices
319  int16_t lsf_res[16]; // residual as a Q10 value
320  int16_t nlsf[16]; // Q15
321 
322  *lpc_order = order = s->wb ? 16 : 10;
323 
324  /* obtain LSF stage-1 and stage-2 indices */
325  lsf_i1 = ff_opus_rc_dec_cdf(rc, ff_silk_model_lsf_s1[s->wb][voiced]);
326  for (i = 0; i < order; i++) {
327  int index = s->wb ? ff_silk_lsf_s2_model_sel_wb [lsf_i1][i] :
329  lsf_i2[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_lsf_s2[index]) - 4;
330  if (lsf_i2[i] == -4)
332  else if (lsf_i2[i] == 4)
334  }
335 
336  /* reverse the backwards-prediction step */
337  for (i = order - 1; i >= 0; i--) {
338  int qstep = s->wb ? 9830 : 11796;
339 
340  lsf_res[i] = lsf_i2[i] * 1024;
341  if (lsf_i2[i] < 0) lsf_res[i] += 102;
342  else if (lsf_i2[i] > 0) lsf_res[i] -= 102;
343  lsf_res[i] = (lsf_res[i] * qstep) >> 16;
344 
345  if (i + 1 < order) {
348  lsf_res[i] += (lsf_res[i+1] * weight) >> 8;
349  }
350  }
351 
352  /* reconstruct the NLSF coefficients from the supplied indices */
353  for (i = 0; i < order; i++) {
354  const uint8_t * codebook = s->wb ? ff_silk_lsf_codebook_wb [lsf_i1] :
356  int cur, weight, value;
357 
358  /* find the weight of the residual */
359  cur = codebook[i];
360  weight = s->wb ? ff_silk_model_lsf_weight_wb[lsf_i1][i] :
362 
363  value = cur * 128 + (lsf_res[i] * 16384) / weight;
364  nlsf[i] = av_clip_uintp2(value, 15);
365  }
366 
367  /* stabilize the NLSF coefficients */
368  silk_stabilize_lsf(nlsf, order, s->wb ? ff_silk_lsf_min_spacing_wb :
370 
371  /* produce an interpolation for the first 2 subframes, */
372  /* and then convert both sets of NLSFs to LPC coefficients */
373  *has_lpc_leadin = 0;
374  if (s->subframes == 4) {
376  if (offset != 4 && frame->coded) {
377  *has_lpc_leadin = 1;
378  if (offset != 0) {
379  int16_t nlsf_leadin[16];
380  for (i = 0; i < order; i++)
381  nlsf_leadin[i] = frame->nlsf[i] +
382  ((nlsf[i] - frame->nlsf[i]) * offset >> 2);
383  silk_lsf2lpc(nlsf_leadin, lpc_leadin, order);
384  } else /* avoid re-computation for a (roughly) 1-in-4 occurrence */
385  memcpy(lpc_leadin, frame->lpc, 16 * sizeof(float));
386  } else
387  offset = 4;
388  s->nlsf_interp_factor = offset;
389 
390  silk_lsf2lpc(nlsf, lpc, order);
391  } else {
392  s->nlsf_interp_factor = 4;
393  silk_lsf2lpc(nlsf, lpc, order);
394  }
395 
396  memcpy(frame->nlsf, nlsf, order * sizeof(nlsf[0]));
397  memcpy(frame->lpc, lpc, order * sizeof(lpc[0]));
398 }
399 
400 static inline void silk_count_children(OpusRangeCoder *rc, int model, int32_t total,
401  int32_t child[2])
402 {
403  if (total != 0) {
404  child[0] = ff_opus_rc_dec_cdf(rc,
405  ff_silk_model_pulse_location[model] + (((total - 1 + 5) * (total - 1)) >> 1));
406  child[1] = total - child[0];
407  } else {
408  child[0] = 0;
409  child[1] = 0;
410  }
411 }
412 
414  float* excitationf,
415  int qoffset_high, int active, int voiced)
416 {
417  int i;
418  uint32_t seed;
419  int shellblocks;
420  int ratelevel;
421  uint8_t pulsecount[20]; // total pulses in each shell block
422  uint8_t lsbcount[20] = {0}; // raw lsbits defined for each pulse in each shell block
423  int32_t excitation[320]; // Q23
424 
425  /* excitation parameters */
427  shellblocks = ff_silk_shell_blocks[s->bandwidth][s->subframes >> 2];
428  ratelevel = ff_opus_rc_dec_cdf(rc, ff_silk_model_exc_rate[voiced]);
429 
430  for (i = 0; i < shellblocks; i++) {
431  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[ratelevel]);
432  if (pulsecount[i] == 17) {
433  while (pulsecount[i] == 17 && ++lsbcount[i] != 10)
434  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[9]);
435  if (lsbcount[i] == 10)
436  pulsecount[i] = ff_opus_rc_dec_cdf(rc, ff_silk_model_pulse_count[10]);
437  }
438  }
439 
440  /* decode pulse locations using PVQ */
441  for (i = 0; i < shellblocks; i++) {
442  if (pulsecount[i] != 0) {
443  int a, b, c, d;
444  int32_t * location = excitation + 16*i;
445  int32_t branch[4][2];
446  branch[0][0] = pulsecount[i];
447 
448  /* unrolled tail recursion */
449  for (a = 0; a < 1; a++) {
450  silk_count_children(rc, 0, branch[0][a], branch[1]);
451  for (b = 0; b < 2; b++) {
452  silk_count_children(rc, 1, branch[1][b], branch[2]);
453  for (c = 0; c < 2; c++) {
454  silk_count_children(rc, 2, branch[2][c], branch[3]);
455  for (d = 0; d < 2; d++) {
456  silk_count_children(rc, 3, branch[3][d], location);
457  location += 2;
458  }
459  }
460  }
461  }
462  } else
463  memset(excitation + 16*i, 0, 16*sizeof(int32_t));
464  }
465 
466  /* decode least significant bits */
467  for (i = 0; i < shellblocks << 4; i++) {
468  int bit;
469  for (bit = 0; bit < lsbcount[i >> 4]; bit++)
470  excitation[i] = (excitation[i] << 1) |
472  }
473 
474  /* decode signs */
475  for (i = 0; i < shellblocks << 4; i++) {
476  if (excitation[i] != 0) {
477  int sign = ff_opus_rc_dec_cdf(rc, ff_silk_model_excitation_sign[active +
478  voiced][qoffset_high][FFMIN(pulsecount[i >> 4], 6)]);
479  if (sign == 0)
480  excitation[i] *= -1;
481  }
482  }
483 
484  /* assemble the excitation */
485  for (i = 0; i < shellblocks << 4; i++) {
486  int value = excitation[i];
487  excitation[i] = value * 256 | ff_silk_quant_offset[voiced][qoffset_high];
488  if (value < 0) excitation[i] += 20;
489  else if (value > 0) excitation[i] -= 20;
490 
491  /* invert samples pseudorandomly */
492  seed = 196314165 * seed + 907633515;
493  if (seed & 0x80000000)
494  excitation[i] *= -1;
495  seed += value;
496 
497  excitationf[i] = excitation[i] / 8388608.0f;
498  }
499 }
500 
501 /** Maximum residual history according to 4.2.7.6.1 */
502 #define SILK_MAX_LAG (288 + LTP_ORDER / 2)
503 
504 /** Order of the LTP filter */
505 #define LTP_ORDER 5
506 
508  int frame_num, int channel, int coded_channels,
509  int active, int active1, int redundant)
510 {
511  /* per frame */
512  int voiced; // combines with active to indicate inactive, active, or active+voiced
513  int qoffset_high;
514  int order; // order of the LPC coefficients
515  float lpc_leadin[16], lpc_body[16], residual[SILK_MAX_LAG + SILK_HISTORY];
516  int has_lpc_leadin;
517  float ltpscale;
518 
519  /* per subframe */
520  struct {
521  float gain;
522  int pitchlag;
523  float ltptaps[5];
524  } sf[4];
525 
526  SilkFrame * const frame = s->frame + channel;
527 
528  int i;
529 
530  /* obtain stereo weights */
531  if (coded_channels == 2 && channel == 0) {
532  int n, wi[2], ws[2], w[2];
534  wi[0] = ff_opus_rc_dec_cdf(rc, ff_silk_model_stereo_s2) + 3 * (n / 5);
536  wi[1] = ff_opus_rc_dec_cdf(rc, ff_silk_model_stereo_s2) + 3 * (n % 5);
538 
539  for (i = 0; i < 2; i++)
540  w[i] = ff_silk_stereo_weights[wi[i]] +
541  (((ff_silk_stereo_weights[wi[i] + 1] - ff_silk_stereo_weights[wi[i]]) * 6554) >> 16)
542  * (ws[i]*2 + 1);
543 
544  s->stereo_weights[0] = (w[0] - w[1]) / 8192.0;
545  s->stereo_weights[1] = w[1] / 8192.0;
546 
547  /* and read the mid-only flag */
548  s->midonly = active1 ? 0 : ff_opus_rc_dec_cdf(rc, ff_silk_model_mid_only);
549  }
550 
551  /* obtain frame type */
552  if (!active) {
554  voiced = 0;
555  } else {
557  qoffset_high = type & 1;
558  voiced = type >> 1;
559  }
560 
561  /* obtain subframe quantization gains */
562  for (i = 0; i < s->subframes; i++) {
563  int log_gain; //Q7
564  int ipart, fpart, lingain;
565 
566  if (i == 0 && (frame_num == 0 || !frame->coded)) {
567  /* gain is coded absolute */
568  int x = ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_highbits[active + voiced]);
569  log_gain = (x<<3) | ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_lowbits);
570 
571  if (frame->coded)
572  log_gain = FFMAX(log_gain, frame->log_gain - 16);
573  } else {
574  /* gain is coded relative */
575  int delta_gain = ff_opus_rc_dec_cdf(rc, ff_silk_model_gain_delta);
576  log_gain = av_clip_uintp2(FFMAX((delta_gain<<1) - 16,
577  frame->log_gain + delta_gain - 4), 6);
578  }
579 
580  frame->log_gain = log_gain;
581 
582  /* approximate 2**(x/128) with a Q7 (i.e. non-integer) input */
583  log_gain = (log_gain * 0x1D1C71 >> 16) + 2090;
584  ipart = log_gain >> 7;
585  fpart = log_gain & 127;
586  lingain = (1 << ipart) + ((-174 * fpart * (128-fpart) >>16) + fpart) * ((1<<ipart) >> 7);
587  sf[i].gain = lingain / 65536.0f;
588  }
589 
590  /* obtain LPC filter coefficients */
591  silk_decode_lpc(s, frame, rc, lpc_leadin, lpc_body, &order, &has_lpc_leadin, voiced);
592 
593  /* obtain pitch lags, if this is a voiced frame */
594  if (voiced) {
595  int lag_absolute = (!frame_num || !frame->prev_voiced);
596  int primarylag; // primary pitch lag for the entire SILK frame
597  int ltpfilter;
598  const int8_t * offsets;
599 
600  if (!lag_absolute) {
602  if (delta)
603  primarylag = frame->primarylag + delta - 9;
604  else
605  lag_absolute = 1;
606  }
607 
608  if (lag_absolute) {
609  /* primary lag is coded absolute */
610  int highbits, lowbits;
611  static const uint16_t * const model[] = {
614  };
616  lowbits = ff_opus_rc_dec_cdf(rc, model[s->bandwidth]);
617 
618  primarylag = ff_silk_pitch_min_lag[s->bandwidth] +
619  highbits*ff_silk_pitch_scale[s->bandwidth] + lowbits;
620  }
621  frame->primarylag = primarylag;
622 
623  if (s->subframes == 2)
624  offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
629  else
630  offsets = (s->bandwidth == OPUS_BANDWIDTH_NARROWBAND)
635 
636  for (i = 0; i < s->subframes; i++)
637  sf[i].pitchlag = av_clip(primarylag + offsets[i],
638  ff_silk_pitch_min_lag[s->bandwidth],
639  ff_silk_pitch_max_lag[s->bandwidth]);
640 
641  /* obtain LTP filter coefficients */
643  for (i = 0; i < s->subframes; i++) {
644  int index, j;
645  static const uint16_t * const filter_sel[] = {
648  };
649  static const int8_t (* const filter_taps[])[5] = {
651  };
652  index = ff_opus_rc_dec_cdf(rc, filter_sel[ltpfilter]);
653  for (j = 0; j < 5; j++)
654  sf[i].ltptaps[j] = filter_taps[ltpfilter][index][j] / 128.0f;
655  }
656  }
657 
658  /* obtain LTP scale factor */
659  if (voiced && frame_num == 0)
661  ff_silk_model_ltp_scale_index)] / 16384.0f;
662  else ltpscale = 15565.0f/16384.0f;
663 
664  /* generate the excitation signal for the entire frame */
665  silk_decode_excitation(s, rc, residual + SILK_MAX_LAG, qoffset_high,
666  active, voiced);
667 
668  /* skip synthesising the output if we do not need it */
669  // TODO: implement error recovery
670  if (s->output_channels == channel || redundant)
671  return;
672 
673  /* generate the output signal */
674  for (i = 0; i < s->subframes; i++) {
675  const float * lpc_coeff = (i < 2 && has_lpc_leadin) ? lpc_leadin : lpc_body;
676  float *dst = frame->output + SILK_HISTORY + i * s->sflength;
677  float *resptr = residual + SILK_MAX_LAG + i * s->sflength;
678  float *lpc = frame->lpc_history + SILK_HISTORY + i * s->sflength;
679  float sum;
680  int j, k;
681 
682  if (voiced) {
683  int out_end;
684  float scale;
685 
686  if (i < 2 || s->nlsf_interp_factor == 4) {
687  out_end = -i * s->sflength;
688  scale = ltpscale;
689  } else {
690  out_end = -(i - 2) * s->sflength;
691  scale = 1.0f;
692  }
693 
694  /* when the LPC coefficients change, a re-whitening filter is used */
695  /* to produce a residual that accounts for the change */
696  for (j = - sf[i].pitchlag - LTP_ORDER/2; j < out_end; j++) {
697  sum = dst[j];
698  for (k = 0; k < order; k++)
699  sum -= lpc_coeff[k] * dst[j - k - 1];
700  resptr[j] = av_clipf(sum, -1.0f, 1.0f) * scale / sf[i].gain;
701  }
702 
703  if (out_end) {
704  float rescale = sf[i-1].gain / sf[i].gain;
705  for (j = out_end; j < 0; j++)
706  resptr[j] *= rescale;
707  }
708 
709  /* LTP synthesis */
710  for (j = 0; j < s->sflength; j++) {
711  sum = resptr[j];
712  for (k = 0; k < LTP_ORDER; k++)
713  sum += sf[i].ltptaps[k] * resptr[j - sf[i].pitchlag + LTP_ORDER/2 - k];
714  resptr[j] = sum;
715  }
716  }
717 
718  /* LPC synthesis */
719  for (j = 0; j < s->sflength; j++) {
720  sum = resptr[j] * sf[i].gain;
721  for (k = 1; k <= order; k++)
722  sum += lpc_coeff[k - 1] * lpc[j - k];
723 
724  lpc[j] = sum;
725  dst[j] = av_clipf(sum, -1.0f, 1.0f);
726  }
727  }
728 
729  frame->prev_voiced = voiced;
730  memmove(frame->lpc_history, frame->lpc_history + s->flength, SILK_HISTORY * sizeof(float));
731  memmove(frame->output, frame->output + s->flength, SILK_HISTORY * sizeof(float));
732 
733  frame->coded = 1;
734 }
735 
736 static void silk_unmix_ms(SilkContext *s, float *l, float *r)
737 {
738  float *mid = s->frame[0].output + SILK_HISTORY - s->flength;
739  float *side = s->frame[1].output + SILK_HISTORY - s->flength;
740  float w0_prev = s->prev_stereo_weights[0];
741  float w1_prev = s->prev_stereo_weights[1];
742  float w0 = s->stereo_weights[0];
743  float w1 = s->stereo_weights[1];
744  int n1 = ff_silk_stereo_interp_len[s->bandwidth];
745  int i;
746 
747  for (i = 0; i < n1; i++) {
748  float interp0 = w0_prev + i * (w0 - w0_prev) / n1;
749  float interp1 = w1_prev + i * (w1 - w1_prev) / n1;
750  float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
751 
752  l[i] = av_clipf((1 + interp1) * mid[i - 1] + side[i - 1] + interp0 * p0, -1.0, 1.0);
753  r[i] = av_clipf((1 - interp1) * mid[i - 1] - side[i - 1] - interp0 * p0, -1.0, 1.0);
754  }
755 
756  for (; i < s->flength; i++) {
757  float p0 = 0.25 * (mid[i - 2] + 2 * mid[i - 1] + mid[i]);
758 
759  l[i] = av_clipf((1 + w1) * mid[i - 1] + side[i - 1] + w0 * p0, -1.0, 1.0);
760  r[i] = av_clipf((1 - w1) * mid[i - 1] - side[i - 1] - w0 * p0, -1.0, 1.0);
761  }
762 
763  memcpy(s->prev_stereo_weights, s->stereo_weights, sizeof(s->stereo_weights));
764 }
765 
767 {
768  if (!frame->coded)
769  return;
770 
771  memset(frame->output, 0, sizeof(frame->output));
772  memset(frame->lpc_history, 0, sizeof(frame->lpc_history));
773 
774  memset(frame->lpc, 0, sizeof(frame->lpc));
775  memset(frame->nlsf, 0, sizeof(frame->nlsf));
776 
777  frame->log_gain = 0;
778 
779  frame->primarylag = 0;
780  frame->prev_voiced = 0;
781  frame->coded = 0;
782 }
783 
785  float *output[2],
786  enum OpusBandwidth bandwidth,
787  int coded_channels,
788  int duration_ms)
789 {
790  int active[2][6], redundancy[2];
791  int nb_frames, i, j;
792 
793  if (bandwidth > OPUS_BANDWIDTH_WIDEBAND ||
794  coded_channels > 2 || duration_ms > 60) {
795  av_log(s->logctx, AV_LOG_ERROR, "Invalid parameters passed "
796  "to the SILK decoder.\n");
797  return AVERROR(EINVAL);
798  }
799 
800  nb_frames = 1 + (duration_ms > 20) + (duration_ms > 40);
801  s->subframes = duration_ms / nb_frames / 5; // 5ms subframes
802  s->sflength = 20 * (bandwidth + 2);
803  s->flength = s->sflength * s->subframes;
804  s->bandwidth = bandwidth;
805  s->wb = bandwidth == OPUS_BANDWIDTH_WIDEBAND;
806 
807  /* make sure to flush the side channel when switching from mono to stereo */
808  if (coded_channels > s->prev_coded_channels)
809  silk_flush_frame(&s->frame[1]);
810  s->prev_coded_channels = coded_channels;
811 
812  /* read the LP-layer header bits */
813  for (i = 0; i < coded_channels; i++) {
814  for (j = 0; j < nb_frames; j++)
815  active[i][j] = ff_opus_rc_dec_log(rc, 1);
816 
817  redundancy[i] = ff_opus_rc_dec_log(rc, 1);
818  }
819 
820  /* read the per-frame LBRR flags */
821  for (i = 0; i < coded_channels; i++)
822  if (redundancy[i] && duration_ms > 20) {
823  redundancy[i] = ff_opus_rc_dec_cdf(rc, duration_ms == 40 ?
825  }
826 
827  /* decode the LBRR frames */
828  for (i = 0; i < nb_frames; i++) {
829  for (j = 0; j < coded_channels; j++)
830  if (redundancy[j] & (1 << i)) {
831  int active1 = (j == 0 && !(redundancy[1] & (1 << i))) ? 0 : 1;
832  silk_decode_frame(s, rc, i, j, coded_channels, 1, active1, 1);
833  }
834 
835  s->midonly = 0;
836  }
837 
838  for (i = 0; i < nb_frames; i++) {
839  for (j = 0; j < coded_channels && !s->midonly; j++) {
840  int active1 = coded_channels > 1 ? active[1][i] : 0;
841  silk_decode_frame(s, rc, i, j, coded_channels, active[j][i], active1, 0);
842  }
843 
844  /* reset the side channel if it is not coded */
845  if (s->midonly && s->frame[1].coded)
846  silk_flush_frame(&s->frame[1]);
847 
848  if (coded_channels == 1 || s->output_channels == 1) {
849  for (j = 0; j < s->output_channels; j++) {
850  memcpy(output[j] + i * s->flength,
851  s->frame[0].output + SILK_HISTORY - s->flength - 2,
852  s->flength * sizeof(float));
853  }
854  } else {
855  silk_unmix_ms(s, output[0] + i * s->flength, output[1] + i * s->flength);
856  }
857 
858  s->midonly = 0;
859  }
860 
861  return nb_frames * s->flength;
862 }
863 
865 {
866  av_freep(ps);
867 }
868 
870 {
871  silk_flush_frame(&s->frame[0]);
872  silk_flush_frame(&s->frame[1]);
873 
874  memset(s->prev_stereo_weights, 0, sizeof(s->prev_stereo_weights));
875 }
876 
877 int ff_silk_init(void *logctx, SilkContext **ps, int output_channels)
878 {
879  SilkContext *s;
880 
881  if (output_channels != 1 && output_channels != 2) {
882  av_log(logctx, AV_LOG_ERROR, "Invalid number of output channels: %d\n",
883  output_channels);
884  return AVERROR(EINVAL);
885  }
886 
887  s = av_mallocz(sizeof(*s));
888  if (!s)
889  return AVERROR(ENOMEM);
890 
891  s->logctx = logctx;
892  s->output_channels = output_channels;
893 
894  ff_silk_flush(s);
895 
896  *ps = s;
897 
898  return 0;
899 }
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
ff_silk_lsf_codebook_wb
const uint8_t ff_silk_lsf_codebook_wb[32][16]
Definition: tab.c:507
ff_silk_model_gain_highbits
const uint16_t ff_silk_model_gain_highbits[3][9]
Definition: tab.c:49
av_clip
#define av_clip
Definition: common.h:100
SilkFrame::lpc_history
float lpc_history[2 *SILK_HISTORY]
Definition: silk.c:45
r
const char * r
Definition: vf_curves.c:127
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_cosine
const int16_t ff_silk_cosine[]
Definition: tab.c:558
OPUS_BANDWIDTH_NARROWBAND
@ OPUS_BANDWIDTH_NARROWBAND
Definition: opus.h:50
ff_silk_model_stereo_s1
const uint16_t ff_silk_model_stereo_s1[]
Definition: tab.c:34
SilkContext::prev_stereo_weights
float prev_stereo_weights[2]
Definition: silk.c:65
ff_silk_model_gain_lowbits
const uint16_t ff_silk_model_gain_lowbits[]
Definition: tab.c:55
silk_stabilize_lsf
static void silk_stabilize_lsf(int16_t nlsf[16], int order, const uint16_t min_delta[17])
Definition: silk.c:71
av_clip_uintp2
#define av_clip_uintp2
Definition: common.h:124
ROUND_MULL
#define ROUND_MULL(a, b, s)
Definition: silk.c:36
SilkContext::output_channels
int output_channels
Definition: silk.c:53
int64_t
long long int64_t
Definition: coverity.c:34
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:226
silk_is_lpc_stable
static int silk_is_lpc_stable(const int16_t lpc[16], int order)
Definition: silk.c:149
SilkContext::flength
int flength
Definition: silk.c:58
SilkContext::logctx
void * logctx
Definition: silk.c:52
ff_silk_lsf_weight_sel_nbmb
const uint8_t ff_silk_lsf_weight_sel_nbmb[32][9]
Definition: tab.c:402
silk_count_children
static void silk_count_children(OpusRangeCoder *rc, int model, int32_t total, int32_t child[2])
Definition: silk.c:400
SilkFrame::log_gain
int log_gain
Definition: silk.c:40
ff_silk_model_pitch_delta
const uint16_t ff_silk_model_pitch_delta[]
Definition: tab.c:115
SilkFrame::output
float output[2 *SILK_HISTORY]
Definition: silk.c:44
b
#define b
Definition: input.c:42
opus.h
high
int high
Definition: dovi_rpuenc.c:39
ff_silk_pitch_offset_mbwb20ms
const int8_t ff_silk_pitch_offset_mbwb20ms[34][4]
Definition: tab.c:635
SilkContext::frame
SilkFrame frame[2]
Definition: silk.c:64
silk_lsf2lpc
static void silk_lsf2lpc(const int16_t nlsf[16], float lpcf[16], int order)
Definition: silk.c:224
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_silk_lsf_weight_sel_wb
const uint8_t ff_silk_lsf_weight_sel_wb[32][15]
Definition: tab.c:437
ff_silk_model_pitch_lowbits_nb
#define ff_silk_model_pitch_lowbits_nb
Definition: tab.h:58
rc.h
bit
#define bit(string, value)
Definition: cbs_mpeg2.c:56
ff_silk_lsf_min_spacing_wb
const uint16_t ff_silk_lsf_min_spacing_wb[]
Definition: tab.c:546
SilkContext::bandwidth
enum OpusBandwidth bandwidth
Definition: silk.c:61
SilkFrame
Definition: silk.c:38
ff_silk_model_lsf_s2_ext
const uint16_t ff_silk_model_lsf_s2_ext[]
Definition: tab.c:104
MULH
#define MULH
Definition: mathops.h:42
weight
const h264_weight_func weight
Definition: h264dsp_init.c:33
ff_silk_free
void ff_silk_free(SilkContext **ps)
Definition: silk.c:864
ff_silk_model_excitation_sign
const uint16_t ff_silk_model_excitation_sign[3][2][7][3]
Definition: tab.c:259
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
ff_silk_model_pitch_lowbits_wb
#define ff_silk_model_pitch_lowbits_wb
Definition: tab.h:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
ff_silk_model_pitch_contour_mbwb20ms
const uint16_t ff_silk_model_pitch_contour_mbwb20ms[]
Definition: tab.c:130
SilkFrame::lpc
float lpc[16]
Definition: silk.c:42
ff_silk_model_lsf_interpolation_offset
const uint16_t ff_silk_model_lsf_interpolation_offset[]
Definition: tab.c:106
ff_silk_lsf_codebook_nbmb
const uint8_t ff_silk_lsf_codebook_nbmb[32][10]
Definition: tab.c:472
ff_silk_lsf_s2_model_sel_wb
const uint8_t ff_silk_lsf_s2_model_sel_wb[32][16]
Definition: tab.c:357
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_silk_lsf_s2_model_sel_nbmb
const uint8_t ff_silk_lsf_s2_model_sel_nbmb[32][10]
Definition: tab.c:322
offsets
static const int offsets[]
Definition: hevc_pel.c:34
ff_silk_lsf_pred_weights_wb
const uint8_t ff_silk_lsf_pred_weights_wb[2][15]
Definition: tab.c:397
ff_silk_model_lcg_seed
const uint16_t ff_silk_model_lcg_seed[]
Definition: tab.c:153
ff_silk_pitch_offset_nb10ms
const int8_t ff_silk_pitch_offset_nb10ms[3][2]
Definition: tab.c:600
ff_silk_model_excitation_lsb
const uint16_t ff_silk_model_excitation_lsb[]
Definition: tab.c:257
av_sat_sub32
#define av_sat_sub32
Definition: common.h:133
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
ff_silk_lsf_ordering_nbmb
const uint8_t ff_silk_lsf_ordering_nbmb[]
Definition: tab.c:550
SilkContext
Definition: silk.c:51
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
OPUS_BANDWIDTH_WIDEBAND
@ OPUS_BANDWIDTH_WIDEBAND
Definition: opus.h:52
ff_silk_pitch_offset_nb20ms
const int8_t ff_silk_pitch_offset_nb20ms[11][4]
Definition: tab.c:606
ff_silk_model_ltp_filter0_sel
const uint16_t ff_silk_model_ltp_filter0_sel[]
Definition: tab.c:138
ff_silk_stereo_weights
const int16_t ff_silk_stereo_weights[]
Definition: tab.c:317
ff_silk_model_lbrr_flags_40
const uint16_t ff_silk_model_lbrr_flags_40[]
Definition: tab.c:31
ff_silk_model_lsf_s1
const uint16_t ff_silk_model_lsf_s1[2][2][33]
Definition: tab.c:62
LTP_ORDER
#define LTP_ORDER
Order of the LTP filter.
Definition: silk.c:505
av_clip_int16
#define av_clip_int16
Definition: common.h:115
SilkFrame::nlsf
int16_t nlsf[16]
Definition: silk.c:41
ff_silk_model_pitch_highbits
const uint16_t ff_silk_model_pitch_highbits[]
Definition: tab.c:108
ff_opus_rc_dec_log
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
Definition: rc.c:114
ff_silk_model_mid_only
const uint16_t ff_silk_model_mid_only[]
Definition: tab.c:43
av_clipf
av_clipf
Definition: af_crystalizer.c:122
seed
static unsigned int seed
Definition: videogen.c:78
SilkContext::subframes
int subframes
Definition: silk.c:56
index
int index
Definition: gxfenc.c:90
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
ff_silk_init
int ff_silk_init(void *logctx, SilkContext **ps, int output_channels)
Definition: silk.c:877
ff_silk_flush
void ff_silk_flush(SilkContext *s)
Definition: silk.c:869
silk.h
ff_silk_shell_blocks
const uint8_t ff_silk_shell_blocks[3][2]
Definition: tab.c:809
ff_silk_model_gain_delta
const uint16_t ff_silk_model_gain_delta[]
Definition: tab.c:57
f
f
Definition: af_crystalizer.c:122
rescale
static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, int scale_h)
Definition: gdv.c:132
silk_unmix_ms
static void silk_unmix_ms(SilkContext *s, float *l, float *r)
Definition: silk.c:736
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
ff_silk_lsf_ordering_wb
const uint8_t ff_silk_lsf_ordering_wb[]
Definition: tab.c:554
ff_silk_model_pulse_location
const uint16_t ff_silk_model_pulse_location[4][168]
Definition: tab.c:185
OpusRangeCoder
Definition: rc.h:41
ff_silk_model_lsf_weight_wb
const uint16_t ff_silk_model_lsf_weight_wb[32][16]
Definition: tab.c:772
SILK_MAX_LAG
#define SILK_MAX_LAG
Maximum residual history according to 4.2.7.6.1.
Definition: silk.c:502
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:166
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
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_flush_frame
static void silk_flush_frame(SilkFrame *frame)
Definition: silk.c:766
ff_silk_ltp_filter2_taps
const int8_t ff_silk_ltp_filter2_taps[32][5]
Definition: tab.c:702
ff_opus_rc_dec_cdf
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
Definition: rc.c:90
ff_silk_model_pitch_contour_nb10ms
const uint16_t ff_silk_model_pitch_contour_nb10ms[]
Definition: tab.c:120
ff_silk_model_pitch_contour_nb20ms
const uint16_t ff_silk_model_pitch_contour_nb20ms[]
Definition: tab.c:122
ff_silk_model_ltp_filter1_sel
const uint16_t ff_silk_model_ltp_filter1_sel[]
Definition: tab.c:142
ff_silk_model_lsf_weight_nbmb
const uint16_t ff_silk_model_lsf_weight_nbmb[32][10]
Definition: tab.c:737
SILK_HISTORY
#define SILK_HISTORY
Definition: silk.h:29
tab.h
silk_decode_excitation
static void silk_decode_excitation(SilkContext *s, OpusRangeCoder *rc, float *excitationf, int qoffset_high, int active, int voiced)
Definition: silk.c:413
ff_silk_ltp_filter1_taps
const int8_t ff_silk_ltp_filter1_taps[16][5]
Definition: tab.c:683
SilkContext::nlsf_interp_factor
int nlsf_interp_factor
Definition: silk.c:59
SilkFrame::coded
int coded
Definition: silk.c:39
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
ff_silk_model_lbrr_flags_60
const uint16_t ff_silk_model_lbrr_flags_60[]
Definition: tab.c:32
ff_silk_model_exc_rate
const uint16_t ff_silk_model_exc_rate[2][10]
Definition: tab.c:155
ff_silk_model_frame_type_inactive
const uint16_t ff_silk_model_frame_type_inactive[]
Definition: tab.c:45
SilkContext::prev_coded_channels
int prev_coded_channels
Definition: silk.c:68
ff_silk_lsf_min_spacing_nbmb
const uint16_t ff_silk_lsf_min_spacing_nbmb[]
Definition: tab.c:542
ff_silk_pitch_offset_mbwb10ms
const int8_t ff_silk_pitch_offset_mbwb10ms[12][2]
Definition: tab.c:620
ff_silk_model_ltp_filter2_sel
const uint16_t ff_silk_model_ltp_filter2_sel[]
Definition: tab.c:146
ff_silk_model_pitch_lowbits_mb
const uint16_t ff_silk_model_pitch_lowbits_mb[]
Definition: tab.c:113
ff_silk_model_stereo_s2
const uint16_t ff_silk_model_stereo_s2[]
Definition: tab.c:39
ff_silk_pitch_scale
const uint16_t ff_silk_pitch_scale[]
Definition: tab.c:594
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
opus_ilog
#define opus_ilog(i)
Definition: rc.h:32
ff_silk_pitch_max_lag
const uint16_t ff_silk_pitch_max_lag[]
Definition: tab.c:598
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: silk.c:507
ff_silk_lsf_pred_weights_nbmb
const uint8_t ff_silk_lsf_pred_weights_nbmb[2][9]
Definition: tab.c:392
ff_silk_model_ltp_filter
const uint16_t ff_silk_model_ltp_filter[]
Definition: tab.c:136
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: silk.c:784
ff_silk_stereo_interp_len
const int ff_silk_stereo_interp_len[3]
Definition: tab.c:820
SilkFrame::primarylag
int primarylag
Definition: silk.c:46
SilkContext::stereo_weights
float stereo_weights[2]
Definition: silk.c:66
ff_silk_ltp_filter0_taps
const int8_t ff_silk_ltp_filter0_taps[8][5]
Definition: tab.c:672
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
SilkContext::sflength
int sflength
Definition: silk.c:57
ff_silk_model_frame_type_active
const uint16_t ff_silk_model_frame_type_active[]
Definition: tab.c:47
ff_silk_model_ltp_scale_index
const uint16_t ff_silk_model_ltp_scale_index[]
Definition: tab.c:151
SilkContext::midonly
int midonly
Definition: silk.c:55
mem.h
w
uint8_t w
Definition: llvidencdsp.c:39
ff_silk_model_lsf_s2
const uint16_t ff_silk_model_lsf_s2[32][10]
Definition: tab.c:82
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:278
SilkContext::wb
int wb
Definition: silk.c:62
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ff_silk_pitch_min_lag
const uint16_t ff_silk_pitch_min_lag[]
Definition: tab.c:596
int32_t
int32_t
Definition: audioconvert.c:56
silk_lsp2poly
static void silk_lsp2poly(const int32_t lsp[], int32_t pol[], int half_order)
Definition: silk.c:207
ff_silk_model_pulse_count
const uint16_t ff_silk_model_pulse_count[11][19]
Definition: tab.c:160
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
MULL
#define MULL(a, b, s)
Definition: mathops.h:60
ff_silk_quant_offset
const uint8_t ff_silk_quant_offset[2][2]
Definition: tab.c:815
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: silk.c:311
SilkFrame::prev_voiced
int prev_voiced
Definition: silk.c:48
OpusBandwidth
OpusBandwidth
Definition: opus.h:49
ff_silk_ltp_scale_factor
const uint16_t ff_silk_ltp_scale_factor[]
Definition: tab.c:807
channel
channel
Definition: ebur128.h:39
codebook
static const unsigned codebook[256][2]
Definition: cfhdenc.c:41
ff_silk_model_pitch_contour_mbwb10ms
const uint16_t ff_silk_model_pitch_contour_mbwb10ms[]
Definition: tab.c:126
ff_silk_model_stereo_s3
const uint16_t ff_silk_model_stereo_s3[]
Definition: tab.c:41