FFmpeg
dec_celt.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Andrew D'Addesio
3  * Copyright (c) 2013-2014 Mozilla Corporation
4  * Copyright (c) 2016 Rostislav Pehlivanov <atomnuker@gmail.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * Opus CELT decoder
26  */
27 
28 #include <float.h>
29 
30 #include "libavutil/mem.h"
31 #include "celt.h"
32 #include "tab.h"
33 #include "pvq.h"
34 
35 /* Use the 2D z-transform to apply prediction in both the time domain (alpha)
36  * and the frequency domain (beta) */
38 {
39  int i, j;
40  float prev[2] = { 0 };
41  float alpha = ff_celt_alpha_coef[f->size];
42  float beta = ff_celt_beta_coef[f->size];
43  const uint8_t *model = ff_celt_coarse_energy_dist[f->size][0];
44 
45  /* intra frame */
46  if (opus_rc_tell(rc) + 3 <= f->framebits && ff_opus_rc_dec_log(rc, 3)) {
47  alpha = 0.0f;
48  beta = 1.0f - (4915.0f/32768.0f);
49  model = ff_celt_coarse_energy_dist[f->size][1];
50  }
51 
52  for (i = 0; i < CELT_MAX_BANDS; i++) {
53  for (j = 0; j < f->channels; j++) {
54  CeltBlock *block = &f->block[j];
55  float value;
56  int available;
57 
58  if (i < f->start_band || i >= f->end_band) {
59  block->energy[i] = 0.0;
60  continue;
61  }
62 
63  available = f->framebits - opus_rc_tell(rc);
64  if (available >= 15) {
65  /* decode using a Laplace distribution */
66  int k = FFMIN(i, 20) << 1;
67  value = ff_opus_rc_dec_laplace(rc, model[k] << 7, model[k+1] << 6);
68  } else if (available >= 2) {
70  value = (x>>1) ^ -(x&1);
71  } else if (available >= 1) {
72  value = -(float)ff_opus_rc_dec_log(rc, 1);
73  } else value = -1;
74 
75  block->energy[i] = FFMAX(-9.0f, block->energy[i]) * alpha + prev[j] + value;
76  prev[j] += beta * value;
77  }
78  }
79 }
80 
82 {
83  int i;
84  for (i = f->start_band; i < f->end_band; i++) {
85  int j;
86  if (!f->fine_bits[i])
87  continue;
88 
89  for (j = 0; j < f->channels; j++) {
90  CeltBlock *block = &f->block[j];
91  int q2;
92  float offset;
93  q2 = ff_opus_rc_get_raw(rc, f->fine_bits[i]);
94  offset = (q2 + 0.5f) * (1 << (14 - f->fine_bits[i])) / 16384.0f - 0.5f;
95  block->energy[i] += offset;
96  }
97  }
98 }
99 
101 {
102  int priority, i, j;
103  int bits_left = f->framebits - opus_rc_tell(rc);
104 
105  for (priority = 0; priority < 2; priority++) {
106  for (i = f->start_band; i < f->end_band && bits_left >= f->channels; i++) {
107  if (f->fine_priority[i] != priority || f->fine_bits[i] >= CELT_MAX_FINE_BITS)
108  continue;
109 
110  for (j = 0; j < f->channels; j++) {
111  int q2;
112  float offset;
113  q2 = ff_opus_rc_get_raw(rc, 1);
114  offset = (q2 - 0.5f) * (1 << (14 - f->fine_bits[i] - 1)) / 16384.0f;
115  f->block[j].energy[i] += offset;
116  bits_left--;
117  }
118  }
119  }
120 }
121 
123 {
124  int i, diff = 0, tf_select = 0, tf_changed = 0, tf_select_bit;
125  int consumed, bits = f->transient ? 2 : 4;
126 
127  consumed = opus_rc_tell(rc);
128  tf_select_bit = (f->size != 0 && consumed+bits+1 <= f->framebits);
129 
130  for (i = f->start_band; i < f->end_band; i++) {
131  if (consumed+bits+tf_select_bit <= f->framebits) {
132  diff ^= ff_opus_rc_dec_log(rc, bits);
133  consumed = opus_rc_tell(rc);
134  tf_changed |= diff;
135  }
136  f->tf_change[i] = diff;
137  bits = f->transient ? 4 : 5;
138  }
139 
140  if (tf_select_bit && ff_celt_tf_select[f->size][f->transient][0][tf_changed] !=
141  ff_celt_tf_select[f->size][f->transient][1][tf_changed])
142  tf_select = ff_opus_rc_dec_log(rc, 1);
143 
144  for (i = f->start_band; i < f->end_band; i++) {
145  f->tf_change[i] = ff_celt_tf_select[f->size][f->transient][tf_select][f->tf_change[i]];
146  }
147 }
148 
150 {
151  int i, j;
152 
153  for (i = f->start_band; i < f->end_band; i++) {
154  float *dst = data + (ff_celt_freq_bands[i] << f->size);
155  float log_norm = block->energy[i] + ff_celt_mean_energy[i];
156  float norm = exp2f(FFMIN(log_norm, 32.0f));
157 
158  for (j = 0; j < ff_celt_freq_range[i] << f->size; j++)
159  dst[j] *= norm;
160  }
161 }
162 
164 {
165  const int T0 = block->pf_period_old;
166  const int T1 = block->pf_period;
167 
168  float g00, g01, g02;
169  float g10, g11, g12;
170 
171  float x0, x1, x2, x3, x4;
172 
173  int i;
174 
175  if (block->pf_gains[0] == 0.0 &&
176  block->pf_gains_old[0] == 0.0)
177  return;
178 
179  g00 = block->pf_gains_old[0];
180  g01 = block->pf_gains_old[1];
181  g02 = block->pf_gains_old[2];
182  g10 = block->pf_gains[0];
183  g11 = block->pf_gains[1];
184  g12 = block->pf_gains[2];
185 
186  x1 = data[-T1 + 1];
187  x2 = data[-T1];
188  x3 = data[-T1 - 1];
189  x4 = data[-T1 - 2];
190 
191  for (i = 0; i < CELT_OVERLAP; i++) {
192  float w = ff_celt_window2[i];
193  x0 = data[i - T1 + 2];
194 
195  data[i] += (1.0 - w) * g00 * data[i - T0] +
196  (1.0 - w) * g01 * (data[i - T0 - 1] + data[i - T0 + 1]) +
197  (1.0 - w) * g02 * (data[i - T0 - 2] + data[i - T0 + 2]) +
198  w * g10 * x2 +
199  w * g11 * (x1 + x3) +
200  w * g12 * (x0 + x4);
201  x4 = x3;
202  x3 = x2;
203  x2 = x1;
204  x1 = x0;
205  }
206 }
207 
209 {
210  int len = f->blocksize * f->blocks;
211  const int filter_len = len - 2 * CELT_OVERLAP;
212 
214 
215  block->pf_period_old = block->pf_period;
216  memcpy(block->pf_gains_old, block->pf_gains, sizeof(block->pf_gains));
217 
218  block->pf_period = block->pf_period_new;
219  memcpy(block->pf_gains, block->pf_gains_new, sizeof(block->pf_gains));
220 
221  if (len > CELT_OVERLAP) {
223 
224  if (block->pf_gains[0] > FLT_EPSILON && filter_len > 0)
225  f->opusdsp.postfilter(block->buf + 1024 + 2 * CELT_OVERLAP,
226  block->pf_period, block->pf_gains,
227  filter_len);
228 
229  block->pf_period_old = block->pf_period;
230  memcpy(block->pf_gains_old, block->pf_gains, sizeof(block->pf_gains));
231  }
232 
233  memmove(block->buf, block->buf + len, (1024 + CELT_OVERLAP / 2) * sizeof(float));
234 }
235 
236 static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
237 {
238  int i;
239 
240  memset(f->block[0].pf_gains_new, 0, sizeof(f->block[0].pf_gains_new));
241  memset(f->block[1].pf_gains_new, 0, sizeof(f->block[1].pf_gains_new));
242 
243  if (f->start_band == 0 && consumed + 16 <= f->framebits) {
244  int has_postfilter = ff_opus_rc_dec_log(rc, 1);
245  if (has_postfilter) {
246  float gain;
247  int tapset, octave, period;
248 
249  octave = ff_opus_rc_dec_uint(rc, 6);
250  period = (16 << octave) + ff_opus_rc_get_raw(rc, 4 + octave) - 1;
251  gain = 0.09375f * (ff_opus_rc_get_raw(rc, 3) + 1);
252  tapset = (opus_rc_tell(rc) + 2 <= f->framebits) ?
254 
255  for (i = 0; i < 2; i++) {
256  CeltBlock *block = &f->block[i];
257 
258  block->pf_period_new = FFMAX(period, CELT_POSTFILTER_MINPERIOD);
259  block->pf_gains_new[0] = gain * ff_celt_postfilter_taps[tapset][0];
260  block->pf_gains_new[1] = gain * ff_celt_postfilter_taps[tapset][1];
261  block->pf_gains_new[2] = gain * ff_celt_postfilter_taps[tapset][2];
262  }
263  }
264 
265  consumed = opus_rc_tell(rc);
266  }
267 
268  return consumed;
269 }
270 
272 {
273  int i, j, k;
274 
275  for (i = f->start_band; i < f->end_band; i++) {
276  int renormalize = 0;
277  float *xptr;
278  float prev[2];
279  float Ediff, r;
280  float thresh, sqrt_1;
281  int depth;
282 
283  /* depth in 1/8 bits */
284  depth = (1 + f->pulses[i]) / (ff_celt_freq_range[i] << f->size);
285  thresh = exp2f(-1.0 - 0.125f * depth);
286  sqrt_1 = 1.0f / sqrtf(ff_celt_freq_range[i] << f->size);
287 
288  xptr = X + (ff_celt_freq_bands[i] << f->size);
289 
290  prev[0] = block->prev_energy[0][i];
291  prev[1] = block->prev_energy[1][i];
292  if (f->channels == 1) {
293  CeltBlock *block1 = &f->block[1];
294 
295  prev[0] = FFMAX(prev[0], block1->prev_energy[0][i]);
296  prev[1] = FFMAX(prev[1], block1->prev_energy[1][i]);
297  }
298  Ediff = block->energy[i] - FFMIN(prev[0], prev[1]);
299  Ediff = FFMAX(0, Ediff);
300 
301  /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM because
302  short blocks don't have the same energy as long */
303  r = exp2f(1 - Ediff);
304  if (f->size == 3)
305  r *= M_SQRT2;
306  r = FFMIN(thresh, r) * sqrt_1;
307  for (k = 0; k < 1 << f->size; k++) {
308  /* Detect collapse */
309  if (!(block->collapse_masks[i] & 1 << k)) {
310  /* Fill with noise */
311  for (j = 0; j < ff_celt_freq_range[i]; j++)
312  xptr[(j << f->size) + k] = (celt_rng(f) & 0x8000) ? r : -r;
313  renormalize = 1;
314  }
315  }
316 
317  /* We just added some energy, so we need to renormalize */
318  if (renormalize)
319  celt_renormalize_vector(xptr, ff_celt_freq_range[i] << f->size, 1.0f);
320  }
321 }
322 
324  float **output, int channels, int frame_size,
325  int start_band, int end_band)
326 {
327  int i, j, downmix = 0;
328  int consumed; // bits of entropy consumed thus far for this frame
329  AVTXContext *imdct;
330  av_tx_fn imdct_fn;
331 
332  if (channels != 1 && channels != 2) {
333  av_log(f->avctx, AV_LOG_ERROR, "Invalid number of coded channels: %d\n",
334  channels);
335  return AVERROR_INVALIDDATA;
336  }
337  if (start_band < 0 || start_band > end_band || end_band > CELT_MAX_BANDS) {
338  av_log(f->avctx, AV_LOG_ERROR, "Invalid start/end band: %d %d\n",
339  start_band, end_band);
340  return AVERROR_INVALIDDATA;
341  }
342 
343  f->silence = 0;
344  f->transient = 0;
345  f->anticollapse = 0;
346  f->flushed = 0;
347  f->channels = channels;
348  f->start_band = start_band;
349  f->end_band = end_band;
350  f->framebits = rc->rb.bytes * 8;
351 
353  if (f->size > CELT_MAX_LOG_BLOCKS ||
354  frame_size != CELT_SHORT_BLOCKSIZE * (1 << f->size)) {
355  av_log(f->avctx, AV_LOG_ERROR, "Invalid CELT frame size: %d\n",
356  frame_size);
357  return AVERROR_INVALIDDATA;
358  }
359 
360  if (!f->output_channels)
361  f->output_channels = channels;
362 
363  for (i = 0; i < f->channels; i++) {
364  memset(f->block[i].coeffs, 0, sizeof(f->block[i].coeffs));
365  memset(f->block[i].collapse_masks, 0, sizeof(f->block[i].collapse_masks));
366  }
367 
368  consumed = opus_rc_tell(rc);
369 
370  /* obtain silence flag */
371  if (consumed >= f->framebits)
372  f->silence = 1;
373  else if (consumed == 1)
374  f->silence = ff_opus_rc_dec_log(rc, 15);
375 
376 
377  if (f->silence) {
378  consumed = f->framebits;
379  rc->total_bits += f->framebits - opus_rc_tell(rc);
380  }
381 
382  /* obtain post-filter options */
383  consumed = parse_postfilter(f, rc, consumed);
384 
385  /* obtain transient flag */
386  if (f->size != 0 && consumed+3 <= f->framebits)
387  f->transient = ff_opus_rc_dec_log(rc, 3);
388 
389  f->blocks = f->transient ? 1 << f->size : 1;
390  f->blocksize = frame_size / f->blocks;
391 
392  imdct = f->tx[f->transient ? 0 : f->size];
393  imdct_fn = f->tx_fn[f->transient ? 0 : f->size];
394 
395  if (channels == 1) {
396  for (i = 0; i < CELT_MAX_BANDS; i++)
397  f->block[0].energy[i] = FFMAX(f->block[0].energy[i], f->block[1].energy[i]);
398  }
399 
402  ff_celt_bitalloc (f, rc, 0);
404  ff_celt_quant_bands (f, rc);
405 
406  if (f->anticollapse_needed)
407  f->anticollapse = ff_opus_rc_get_raw(rc, 1);
408 
410 
411  /* apply anti-collapse processing and denormalization to
412  * each coded channel */
413  for (i = 0; i < f->channels; i++) {
414  CeltBlock *block = &f->block[i];
415 
416  if (f->anticollapse)
417  process_anticollapse(f, block, f->block[i].coeffs);
418 
419  celt_denormalize(f, block, f->block[i].coeffs);
420  }
421 
422  /* stereo -> mono downmix */
423  if (f->output_channels < f->channels) {
424  f->dsp->vector_fmac_scalar(f->block[0].coeffs, f->block[1].coeffs, 1.0, FFALIGN(frame_size, 16));
425  downmix = 1;
426  } else if (f->output_channels > f->channels)
427  memcpy(f->block[1].coeffs, f->block[0].coeffs, frame_size * sizeof(float));
428 
429  if (f->silence) {
430  for (i = 0; i < 2; i++) {
431  CeltBlock *block = &f->block[i];
432 
433  for (j = 0; j < FF_ARRAY_ELEMS(block->energy); j++)
434  block->energy[j] = CELT_ENERGY_SILENCE;
435  }
436  memset(f->block[0].coeffs, 0, sizeof(f->block[0].coeffs));
437  memset(f->block[1].coeffs, 0, sizeof(f->block[1].coeffs));
438  }
439 
440  /* transform and output for each output channel */
441  for (i = 0; i < f->output_channels; i++) {
442  CeltBlock *block = &f->block[i];
443 
444  /* iMDCT and overlap-add */
445  for (j = 0; j < f->blocks; j++) {
446  float *dst = block->buf + 1024 + j * f->blocksize;
447 
448  imdct_fn(imdct, dst + CELT_OVERLAP / 2, f->block[i].coeffs + j,
449  sizeof(float)*f->blocks);
450  f->dsp->vector_fmul_window(dst, dst, dst + CELT_OVERLAP / 2,
452  }
453 
454  if (downmix)
455  f->dsp->vector_fmul_scalar(&block->buf[1024], &block->buf[1024], 0.5f, frame_size);
456 
457  /* postfilter */
459 
460  /* deemphasis */
461  block->emph_coeff = f->opusdsp.deemphasis(output[i],
462  &block->buf[1024 - frame_size],
463  block->emph_coeff,
465  frame_size);
466  }
467 
468  if (channels == 1)
469  memcpy(f->block[1].energy, f->block[0].energy, sizeof(f->block[0].energy));
470 
471  for (i = 0; i < 2; i++ ) {
472  CeltBlock *block = &f->block[i];
473 
474  if (!f->transient) {
475  memcpy(block->prev_energy[1], block->prev_energy[0], sizeof(block->prev_energy[0]));
476  memcpy(block->prev_energy[0], block->energy, sizeof(block->prev_energy[0]));
477  } else {
478  for (j = 0; j < CELT_MAX_BANDS; j++)
479  block->prev_energy[0][j] = FFMIN(block->prev_energy[0][j], block->energy[j]);
480  }
481 
482  for (j = 0; j < f->start_band; j++) {
483  block->prev_energy[0][j] = CELT_ENERGY_SILENCE;
484  block->energy[j] = 0.0;
485  }
486  for (j = f->end_band; j < CELT_MAX_BANDS; j++) {
487  block->prev_energy[0][j] = CELT_ENERGY_SILENCE;
488  block->energy[j] = 0.0;
489  }
490  }
491 
492  f->seed = rc->range;
493 
494  return 0;
495 }
496 
498 {
499  int i, j;
500 
501  if (f->flushed)
502  return;
503 
504  for (i = 0; i < 2; i++) {
505  CeltBlock *block = &f->block[i];
506 
507  for (j = 0; j < CELT_MAX_BANDS; j++)
508  block->prev_energy[0][j] = block->prev_energy[1][j] = CELT_ENERGY_SILENCE;
509 
510  memset(block->energy, 0, sizeof(block->energy));
511  memset(block->buf, 0, sizeof(block->buf));
512 
513  memset(block->pf_gains, 0, sizeof(block->pf_gains));
514  memset(block->pf_gains_old, 0, sizeof(block->pf_gains_old));
515  memset(block->pf_gains_new, 0, sizeof(block->pf_gains_new));
516 
517  /* libopus uses CELT_EMPH_COEFF on init, but 0 is better since there's
518  * a lesser discontinuity when seeking.
519  * The deemphasis functions differ from libopus in that they require
520  * an initial state divided by the coefficient. */
521  block->emph_coeff = 0.0f / ff_opus_deemph_weights[0];
522  }
523  f->seed = 0;
524 
525  f->flushed = 1;
526 }
527 
529 {
530  CeltFrame *frm = *f;
531  int i;
532 
533  if (!frm)
534  return;
535 
536  for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++)
537  av_tx_uninit(&frm->tx[i]);
538 
539  ff_celt_pvq_uninit(&frm->pvq);
540 
541  av_freep(&frm->dsp);
542  av_freep(f);
543 }
544 
545 int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels,
546  int apply_phase_inv)
547 {
548  CeltFrame *frm;
549  int i, ret;
550 
551  if (output_channels != 1 && output_channels != 2) {
552  av_log(avctx, AV_LOG_ERROR, "Invalid number of output channels: %d\n",
553  output_channels);
554  return AVERROR(EINVAL);
555  }
556 
557  frm = av_mallocz(sizeof(*frm));
558  if (!frm)
559  return AVERROR(ENOMEM);
560 
561  frm->avctx = avctx;
562  frm->output_channels = output_channels;
563  frm->apply_phase_inv = apply_phase_inv;
564 
565  for (i = 0; i < FF_ARRAY_ELEMS(frm->tx); i++) {
566  const float scale = -1.0f/32768;
567  if ((ret = av_tx_init(&frm->tx[i], &frm->tx_fn[i], AV_TX_FLOAT_MDCT, 1, 15 << (i + 3), &scale, 0)) < 0)
568  goto fail;
569  }
570 
571  if ((ret = ff_celt_pvq_init(&frm->pvq, 0)) < 0)
572  goto fail;
573 
575  if (!frm->dsp) {
576  ret = AVERROR(ENOMEM);
577  goto fail;
578  }
579 
580  ff_opus_dsp_init(&frm->opusdsp);
581  ff_celt_flush(frm);
582 
583  *f = frm;
584 
585  return 0;
586 fail:
587  ff_celt_free(&frm);
588  return ret;
589 }
ff_opus_rc_get_raw
uint32_t ff_opus_rc_get_raw(OpusRangeCoder *rc, uint32_t count)
CELT: read 1-25 raw bits at the end of the frame, backwards byte-wise.
Definition: rc.c:140
CELT_MAX_BANDS
#define CELT_MAX_BANDS
Definition: celt.h:43
CeltFrame::dsp
AVFloatDSPContext * dsp
Definition: celt.h:103
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
CeltFrame::tx_fn
av_tx_fn tx_fn[4]
Definition: celt.h:102
CELT_ENERGY_SILENCE
#define CELT_ENERGY_SILENCE
Definition: celt.h:53
opus_rc_tell
static av_always_inline uint32_t opus_rc_tell(const OpusRangeCoder *rc)
CELT: estimate bits of entropy that have thus far been consumed for the current CELT frame,...
Definition: rc.h:62
AVTXContext
Definition: tx_priv.h:235
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
w
uint8_t w
Definition: llviddspenc.c:38
CeltFrame::avctx
AVCodecContext * avctx
Definition: celt.h:100
CELT_MAX_FINE_BITS
#define CELT_MAX_FINE_BITS
Definition: celt.h:48
data
const char data[16]
Definition: mxf.c:149
celt_renormalize_vector
static av_always_inline void celt_renormalize_vector(float *X, int N, float gain)
Definition: celt.h:156
ff_celt_free
void ff_celt_free(CeltFrame **f)
Definition: dec_celt.c:528
float.h
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ff_opus_deemph_weights
const float ff_opus_deemph_weights[]
Definition: tab.c:1169
av_tx_init
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
Definition: tx.c:903
CeltBlock
Definition: celt.h:71
CeltFrame::output_channels
int output_channels
Definition: celt.h:108
fail
#define fail()
Definition: checkasm.h:189
ff_opus_rc_dec_uint
uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
CELT: read a uniform distribution.
Definition: rc.c:182
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
ff_celt_model_tapset
const uint16_t ff_celt_model_tapset[]
Definition: tab.c:758
celt_rng
static av_always_inline uint32_t celt_rng(CeltFrame *f)
Definition: celt.h:150
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ff_celt_postfilter_taps
const float ff_celt_postfilter_taps[3][3]
Definition: tab.c:1098
CeltFrame::apply_phase_inv
int apply_phase_inv
Definition: celt.h:109
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:151
float
float
Definition: af_crystalizer.c:122
AV_TX_FLOAT_MDCT
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
Definition: tx.h:68
frame_size
int frame_size
Definition: mxfenc.c:2429
pvq.h
celt_postfilter
static void celt_postfilter(CeltFrame *f, CeltBlock *block)
Definition: dec_celt.c:208
bits
uint8_t bits
Definition: vp3data.h:128
exp2f
#define exp2f(x)
Definition: libm.h:293
channels
channels
Definition: aptx.h:31
ff_celt_pvq_uninit
void av_cold ff_celt_pvq_uninit(CeltPVQ **pvq)
Definition: pvq.c:927
ff_celt_tf_select
const int8_t ff_celt_tf_select[4][2][2][2]
Definition: tab.c:782
OpusRangeCoder::range
uint32_t range
Definition: rc.h:44
bits_left
#define bits_left
Definition: bitstream.h:114
ff_celt_freq_range
const uint8_t ff_celt_freq_range[]
Definition: tab.c:772
ff_celt_flush
void ff_celt_flush(CeltFrame *f)
Definition: dec_celt.c:497
celt_decode_final_energy
static void celt_decode_final_energy(CeltFrame *f, OpusRangeCoder *rc)
Definition: dec_celt.c:100
period
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 minimum maximum flags name is the option keep it simple and lowercase description are in without period
Definition: writing_filters.txt:89
ff_opus_rc_dec_log
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
Definition: rc.c:114
RawBitsContext::bytes
uint32_t bytes
Definition: rc.h:36
sqrtf
static __device__ float sqrtf(float a)
Definition: cuda_runtime.h:184
CELT_POSTFILTER_MINPERIOD
#define CELT_POSTFILTER_MINPERIOD
Definition: celt.h:52
ff_celt_coarse_energy_dist
const uint8_t ff_celt_coarse_energy_dist[4][2][42]
Definition: tab.c:808
CeltFrame::tx
AVTXContext * tx[4]
Definition: celt.h:101
ff_celt_beta_coef
const float ff_celt_beta_coef[]
Definition: tab.c:804
f
f
Definition: af_crystalizer.c:122
CELT_MAX_LOG_BLOCKS
#define CELT_MAX_LOG_BLOCKS
Definition: celt.h:41
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
ff_celt_window
static const float *const ff_celt_window
Definition: tab.h:162
OpusRangeCoder
Definition: rc.h:41
ff_opus_dsp_init
av_cold void ff_opus_dsp_init(OpusDSP *ctx)
Definition: dsp.c:56
ff_celt_init
int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, int apply_phase_inv)
Definition: dec_celt.c:545
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
block1
static int16_t block1[64]
Definition: dct.c:120
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
ff_celt_quant_bands
void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
Definition: celt.c:28
ff_opus_rc_dec_cdf
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
Definition: rc.c:90
av_tx_uninit
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
Definition: tx.c:295
celt_decode_tf_changes
static void celt_decode_tf_changes(CeltFrame *f, OpusRangeCoder *rc)
Definition: dec_celt.c:122
tab.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
CeltFrame::pvq
struct CeltPVQ * pvq
Definition: celt.h:105
celt_decode_fine_energy
static void celt_decode_fine_energy(CeltFrame *f, OpusRangeCoder *rc)
Definition: dec_celt.c:81
available
if no frame is available
Definition: filter_design.txt:166
CELT_SHORT_BLOCKSIZE
#define CELT_SHORT_BLOCKSIZE
Definition: celt.h:39
ff_opus_rc_dec_laplace
int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
Definition: rc.c:275
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:256
celt_decode_coarse_energy
static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
Definition: dec_celt.c:37
len
int len
Definition: vorbis_enc_data.h:426
ff_celt_model_energy_small
const uint16_t ff_celt_model_energy_small[]
Definition: tab.c:766
celt.h
ret
ret
Definition: filter_design.txt:187
ff_celt_bitalloc
void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
Definition: celt.c:137
CELT_OVERLAP
#define CELT_OVERLAP
Definition: celt.h:40
celt_denormalize
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
Definition: dec_celt.c:149
AVCodecContext
main external API structure.
Definition: avcodec.h:451
ff_celt_alpha_coef
const float ff_celt_alpha_coef[]
Definition: tab.c:800
CeltFrame::opusdsp
OpusDSP opusdsp
Definition: celt.h:106
celt_postfilter_apply_transition
static void celt_postfilter_apply_transition(CeltBlock *block, float *data)
Definition: dec_celt.c:163
ff_celt_decode_frame
int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band)
Definition: dec_celt.c:323
ff_celt_mean_energy
const float ff_celt_mean_energy[]
Definition: tab.c:792
X
@ X
Definition: vf_addroi.c:27
mem.h
AV_CODEC_FLAG_BITEXACT
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:342
OpusRangeCoder::rb
RawBitsContext rb
Definition: rc.h:43
M_SQRT2
#define M_SQRT2
Definition: mathematics.h:109
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
avpriv_float_dsp_alloc
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:146
ff_celt_pvq_init
int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
Definition: pvq.c:907
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
process_anticollapse
static void process_anticollapse(CeltFrame *f, CeltBlock *block, float *X)
Definition: dec_celt.c:271
ff_celt_freq_bands
const uint8_t ff_celt_freq_bands[]
Definition: tab.c:768
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
OpusRangeCoder::total_bits
uint32_t total_bits
Definition: rc.h:46
parse_postfilter
static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
Definition: dec_celt.c:236
CeltFrame
Definition: celt.h:98
ff_celt_window2
const float ff_celt_window2[120]
Definition: tab.c:1136