Go to the documentation of this file.
   37     float prev[2] = { 0 };
 
   45         beta  = 1.0f - (4915.0f/32768.0f);
 
   50         for (j = 0; j < 
f->channels; j++) {
 
   55             if (i < f->start_band || 
i >= 
f->end_band) {
 
   67                 value = (x>>1) ^ -(x&1);
 
   73             prev[j] += beta * 
value;
 
   81     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
   86         for (j = 0; j < 
f->channels; j++) {
 
   91             offset = (q2 + 0.5f) * (1 << (14 - 
f->fine_bits[
i])) / 16384.0
f - 0.5
f;
 
  102     for (priority = 0; priority < 2; priority++) {
 
  103         for (
i = 
f->start_band; i < f->end_band && bits_left >= 
f->channels; 
i++) {
 
  107             for (j = 0; j < 
f->channels; j++) {
 
  111                 offset = (q2 - 0.5f) * (1 << (14 - 
f->fine_bits[
i] - 1)) / 16384.0
f;
 
  121     int i, 
diff = 0, tf_select = 0, tf_changed = 0, tf_select_bit;
 
  122     int consumed, 
bits = 
f->transient ? 2 : 4;
 
  125     tf_select_bit = (
f->size != 0 && consumed+
bits+1 <= 
f->framebits);
 
  127     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  128         if (consumed+
bits+tf_select_bit <= f->framebits) {
 
  134         bits = 
f->transient ? 4 : 5;
 
  141     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  150     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  162     const int T0 = 
block->pf_period_old;
 
  163     const int T1 = 
block->pf_period;
 
  168     float x0, x1, x2, x3, x4;
 
  172     if (
block->pf_gains[0]     == 0.0 &&
 
  173         block->pf_gains_old[0] == 0.0)
 
  176     g00 = 
block->pf_gains_old[0];
 
  177     g01 = 
block->pf_gains_old[1];
 
  178     g02 = 
block->pf_gains_old[2];
 
  179     g10 = 
block->pf_gains[0];
 
  180     g11 = 
block->pf_gains[1];
 
  181     g12 = 
block->pf_gains[2];
 
  190         x0 = 
data[
i - T1 + 2];
 
  193                     (1.0 - 
w) * g01 * (
data[
i - T0 - 1] + 
data[
i - T0 + 1]) +
 
  194                     (1.0 - 
w) * g02 * (
data[
i - T0 - 2] + 
data[
i - T0 + 2]) +
 
  196                     w         * g11 * (x1 + x3)                             +
 
  207     int len = 
f->blocksize * 
f->blocks;
 
  221         if (
block->pf_gains[0] > FLT_EPSILON && filter_len > 0)
 
  237     memset(
f->block[0].pf_gains_new, 0, 
sizeof(
f->block[0].pf_gains_new));
 
  238     memset(
f->block[1].pf_gains_new, 0, 
sizeof(
f->block[1].pf_gains_new));
 
  240     if (
f->start_band == 0 && consumed + 16 <= 
f->framebits) {
 
  242         if (has_postfilter) {
 
  244             int tapset, octave, 
period;
 
  252             for (
i = 0; 
i < 2; 
i++) {
 
  272     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  277         float thresh, sqrt_1;
 
  282         thresh = 
exp2f(-1.0 - 0.125
f * depth);
 
  287         prev[0] = 
block->prev_energy[0][
i];
 
  288         prev[1] = 
block->prev_energy[1][
i];
 
  289         if (
f->channels == 1) {
 
  295         Ediff = 
block->energy[
i] - 
FFMIN(prev[0], prev[1]);
 
  296         Ediff = 
FFMAX(0, Ediff);
 
  304         for (k = 0; k < 1 << 
f->size; k++) {
 
  306             if (!(
block->collapse_masks[
i] & 1 << k)) {
 
  309                     xptr[(j << 
f->size) + k] = (
celt_rng(
f) & 0x8000) ? 
r : -
r;
 
  322                          int start_band,  
int end_band)
 
  324     int i, j, downmix = 0;
 
  333     if (start_band < 0 || start_band > end_band || end_band > 
CELT_MAX_BANDS) {
 
  335                start_band, end_band);
 
  344     f->start_band     = start_band;
 
  345     f->end_band       = end_band;
 
  356     if (!
f->output_channels)
 
  359     for (
i = 0; 
i < 
f->channels; 
i++) {
 
  360         memset(
f->block[
i].coeffs,         0, 
sizeof(
f->block[
i].coeffs));
 
  361         memset(
f->block[
i].collapse_masks, 0, 
sizeof(
f->block[
i].collapse_masks));
 
  367     if (consumed >= 
f->framebits)
 
  369     else if (consumed == 1)
 
  374         consumed = 
f->framebits;
 
  382     if (
f->size != 0 && consumed+3 <= 
f->framebits)
 
  385     f->blocks    = 
f->transient ? 1 << 
f->size : 1;
 
  388     imdct = 
f->imdct[
f->transient ? 0 : 
f->size];
 
  392             f->block[0].energy[
i] = 
FFMAX(
f->block[0].energy[
i], 
f->block[1].energy[
i]);
 
  401     if (
f->anticollapse_needed)
 
  408     for (
i = 0; 
i < 
f->channels; 
i++) {
 
  418     if (
f->output_channels < 
f->channels) {
 
  419         f->dsp->vector_fmac_scalar(
f->block[0].coeffs, 
f->block[1].coeffs, 1.0, 
FFALIGN(
frame_size, 16));
 
  421     } 
else if (
f->output_channels > 
f->channels)
 
  422         memcpy(
f->block[1].coeffs, 
f->block[0].coeffs, 
frame_size * 
sizeof(
float));
 
  425         for (
i = 0; 
i < 2; 
i++) {
 
  431         memset(
f->block[0].coeffs, 0, 
sizeof(
f->block[0].coeffs));
 
  432         memset(
f->block[1].coeffs, 0, 
sizeof(
f->block[1].coeffs));
 
  436     for (
i = 0; 
i < 
f->output_channels; 
i++) {
 
  440         for (j = 0; j < 
f->blocks; j++) {
 
  441             float *dst  = 
block->buf + 1024 + j * 
f->blocksize;
 
  462         memcpy(
f->block[1].energy, 
f->block[0].energy, 
sizeof(
f->block[0].energy));
 
  464     for (
i = 0; 
i < 2; 
i++ ) {
 
  468             memcpy(
block->prev_energy[1], 
block->prev_energy[0], 
sizeof(
block->prev_energy[0]));
 
  469             memcpy(
block->prev_energy[0], 
block->energy,         
sizeof(
block->prev_energy[0]));
 
  475         for (j = 0; j < 
f->start_band; j++) {
 
  477             block->energy[j]         = 0.0;
 
  481             block->energy[j]         = 0.0;
 
  497     for (
i = 0; 
i < 2; 
i++) {
 
  503         memset(
block->energy, 0, 
sizeof(
block->energy));
 
  506         memset(
block->pf_gains,     0, 
sizeof(
block->pf_gains));
 
  507         memset(
block->pf_gains_old, 0, 
sizeof(
block->pf_gains_old));
 
  508         memset(
block->pf_gains_new, 0, 
sizeof(
block->pf_gains_new));
 
  544     if (output_channels != 1 && output_channels != 2) {
 
  
const float ff_celt_postfilter_taps[3][3]
static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
static void celt_postfilter_apply_transition(CeltBlock *block, float *data)
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
const uint8_t ff_celt_freq_bands[]
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.
const float * ff_celt_window
void ff_celt_flush(CeltFrame *f)
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
const uint16_t ff_celt_model_tapset[]
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
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,...
const uint8_t ff_celt_coarse_energy_dist[4][2][42]
static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
int flags
AV_CODEC_FLAG_*.
static void celt_postfilter(CeltFrame *f, CeltBlock *block)
int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, int apply_phase_inv)
static av_always_inline void celt_renormalize_vector(float *X, int N, float gain)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
CELT: read a uniform distribution.
#define CELT_SHORT_BLOCKSIZE
#define CELT_MAX_FINE_BITS
void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
void av_cold ff_celt_pvq_uninit(CeltPVQ **pvq)
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
static void celt_decode_tf_changes(CeltFrame *f, OpusRangeCoder *rc)
const uint8_t ff_celt_freq_range[]
#define CELT_ENERGY_SILENCE
static void celt_decode_fine_energy(CeltFrame *f, OpusRangeCoder *rc)
void ff_celt_free(CeltFrame **f)
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
const float ff_celt_window2[120]
static av_always_inline uint32_t celt_rng(CeltFrame *f)
const int8_t ff_celt_tf_select[4][2][2][2]
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
const float ff_celt_beta_coef[]
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
#define CELT_MAX_LOG_BLOCKS
#define i(width, name, range_min, range_max)
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
static void celt_decode_final_energy(CeltFrame *f, OpusRangeCoder *rc)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
#define CELT_POSTFILTER_MINPERIOD
int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band)
#define FF_ARRAY_ELEMS(a)
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
main external API structure.
const uint16_t ff_celt_model_energy_small[]
av_cold void ff_opus_dsp_init(OpusDSP *ctx)
void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
const float ff_celt_alpha_coef[]
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
static void process_anticollapse(CeltFrame *f, CeltBlock *block, float *X)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const int16_t alpha[]
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
The exact code depends on how similar the blocks are and how related they are to the block
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
const float ff_celt_mean_energy[]
static int16_t block1[64]