Go to the documentation of this file.
   39     float prev[2] = { 0 };
 
   47         beta  = 1.0f - (4915.0f/32768.0f);
 
   52         for (j = 0; j < 
f->channels; j++) {
 
   57             if (i < f->start_band || 
i >= 
f->end_band) {
 
   69                 value = (x>>1) ^ -(x&1);
 
   75             prev[j] += beta * 
value;
 
   83     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
   88         for (j = 0; j < 
f->channels; j++) {
 
   93             offset = (q2 + 0.5f) * (1 << (14 - 
f->fine_bits[
i])) / 16384.0
f - 0.5
f;
 
  104     for (priority = 0; priority < 2; priority++) {
 
  105         for (
i = 
f->start_band; i < f->end_band && 
bits_left >= 
f->channels; 
i++) {
 
  109             for (j = 0; j < 
f->channels; j++) {
 
  113                 offset = (q2 - 0.5f) * (1 << (14 - 
f->fine_bits[
i] - 1)) / 16384.0
f;
 
  123     int i, 
diff = 0, tf_select = 0, tf_changed = 0, tf_select_bit;
 
  124     int consumed, 
bits = 
f->transient ? 2 : 4;
 
  127     tf_select_bit = (
f->size != 0 && consumed+
bits+1 <= 
f->framebits);
 
  129     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  130         if (consumed+
bits+tf_select_bit <= f->framebits) {
 
  136         bits = 
f->transient ? 4 : 5;
 
  143     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  152     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  164     const int T0 = 
block->pf_period_old;
 
  165     const int T1 = 
block->pf_period;
 
  170     float x0, x1, x2, x3, x4;
 
  174     if (
block->pf_gains[0]     == 0.0 &&
 
  175         block->pf_gains_old[0] == 0.0)
 
  178     g00 = 
block->pf_gains_old[0];
 
  179     g01 = 
block->pf_gains_old[1];
 
  180     g02 = 
block->pf_gains_old[2];
 
  181     g10 = 
block->pf_gains[0];
 
  182     g11 = 
block->pf_gains[1];
 
  183     g12 = 
block->pf_gains[2];
 
  192         x0 = 
data[
i - T1 + 2];
 
  195                     (1.0 - 
w) * g01 * (
data[
i - T0 - 1] + 
data[
i - T0 + 1]) +
 
  196                     (1.0 - 
w) * g02 * (
data[
i - T0 - 2] + 
data[
i - T0 + 2]) +
 
  198                     w         * g11 * (x1 + x3)                             +
 
  209     int len = 
f->blocksize * 
f->blocks;
 
  223         if (
block->pf_gains[0] > FLT_EPSILON && filter_len > 0)
 
  239     memset(
f->block[0].pf_gains_new, 0, 
sizeof(
f->block[0].pf_gains_new));
 
  240     memset(
f->block[1].pf_gains_new, 0, 
sizeof(
f->block[1].pf_gains_new));
 
  242     if (
f->start_band == 0 && consumed + 16 <= 
f->framebits) {
 
  244         if (has_postfilter) {
 
  246             int tapset, octave, 
period;
 
  254             for (
i = 0; 
i < 2; 
i++) {
 
  274     for (
i = 
f->start_band; i < f->end_band; 
i++) {
 
  279         float thresh, sqrt_1;
 
  284         thresh = 
exp2f(-1.0 - 0.125
f * depth);
 
  289         prev[0] = 
block->prev_energy[0][
i];
 
  290         prev[1] = 
block->prev_energy[1][
i];
 
  291         if (
f->channels == 1) {
 
  297         Ediff = 
block->energy[
i] - 
FFMIN(prev[0], prev[1]);
 
  298         Ediff = 
FFMAX(0, Ediff);
 
  306         for (k = 0; k < 1 << 
f->size; k++) {
 
  308             if (!(
block->collapse_masks[
i] & 1 << k)) {
 
  311                     xptr[(j << 
f->size) + k] = (
celt_rng(
f) & 0x8000) ? 
r : -
r;
 
  324                          int start_band,  
int end_band)
 
  326     int i, j, downmix = 0;
 
  336     if (start_band < 0 || start_band > end_band || end_band > 
CELT_MAX_BANDS) {
 
  338                start_band, end_band);
 
  347     f->start_band     = start_band;
 
  348     f->end_band       = end_band;
 
  359     if (!
f->output_channels)
 
  362     for (
i = 0; 
i < 
f->channels; 
i++) {
 
  363         memset(
f->block[
i].coeffs,         0, 
sizeof(
f->block[
i].coeffs));
 
  364         memset(
f->block[
i].collapse_masks, 0, 
sizeof(
f->block[
i].collapse_masks));
 
  370     if (consumed >= 
f->framebits)
 
  372     else if (consumed == 1)
 
  377         consumed = 
f->framebits;
 
  385     if (
f->size != 0 && consumed+3 <= 
f->framebits)
 
  388     f->blocks    = 
f->transient ? 1 << 
f->size : 1;
 
  391     imdct = 
f->tx[
f->transient ? 0 : 
f->size];
 
  392     imdct_fn = 
f->tx_fn[
f->transient ? 0 : 
f->size];
 
  396             f->block[0].energy[
i] = 
FFMAX(
f->block[0].energy[
i], 
f->block[1].energy[
i]);
 
  405     if (
f->anticollapse_needed)
 
  412     for (
i = 0; 
i < 
f->channels; 
i++) {
 
  422     if (
f->output_channels < 
f->channels) {
 
  423         f->dsp->vector_fmac_scalar(
f->block[0].coeffs, 
f->block[1].coeffs, 1.0, 
FFALIGN(
frame_size, 16));
 
  425     } 
else if (
f->output_channels > 
f->channels)
 
  426         memcpy(
f->block[1].coeffs, 
f->block[0].coeffs, 
frame_size * 
sizeof(
float));
 
  429         for (
i = 0; 
i < 2; 
i++) {
 
  435         memset(
f->block[0].coeffs, 0, 
sizeof(
f->block[0].coeffs));
 
  436         memset(
f->block[1].coeffs, 0, 
sizeof(
f->block[1].coeffs));
 
  440     for (
i = 0; 
i < 
f->output_channels; 
i++) {
 
  444         for (j = 0; j < 
f->blocks; j++) {
 
  445             float *dst  = 
block->buf + 1024 + j * 
f->blocksize;
 
  448                      sizeof(
float)*
f->blocks);
 
  466         memcpy(
f->block[1].energy, 
f->block[0].energy, 
sizeof(
f->block[0].energy));
 
  468     for (
i = 0; 
i < 2; 
i++ ) {
 
  472             memcpy(
block->prev_energy[1], 
block->prev_energy[0], 
sizeof(
block->prev_energy[0]));
 
  473             memcpy(
block->prev_energy[0], 
block->energy,         
sizeof(
block->prev_energy[0]));
 
  479         for (j = 0; j < 
f->start_band; j++) {
 
  481             block->energy[j]         = 0.0;
 
  485             block->energy[j]         = 0.0;
 
  501     for (
i = 0; 
i < 2; 
i++) {
 
  507         memset(
block->energy, 0, 
sizeof(
block->energy));
 
  510         memset(
block->pf_gains,     0, 
sizeof(
block->pf_gains));
 
  511         memset(
block->pf_gains_old, 0, 
sizeof(
block->pf_gains_old));
 
  512         memset(
block->pf_gains_new, 0, 
sizeof(
block->pf_gains_new));
 
  563         const float scale = -1.0f/32768;
 
  
const float ff_celt_postfilter_taps[3][3]
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.
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
static void celt_postfilter(CeltFrame *f, CeltBlock *block)
const uint16_t ff_celt_model_tapset[]
void ff_celt_free(CeltFrame **f)
int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, int apply_phase_inv)
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...
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]
int flags
AV_CODEC_FLAG_*.
static void celt_decode_fine_energy(CeltFrame *f, OpusRangeCoder *rc)
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.
#define FF_ARRAY_ELEMS(a)
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
@ AV_TX_FLOAT_MDCT
Standard MDCT with a sample data type of float, double or int32_t, respecively.
uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
CELT: read a uniform distribution.
#define CELT_MAX_FINE_BITS
int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band)
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
#define CELT_SHORT_BLOCKSIZE
static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
static const float *const ff_celt_window
static __device__ float sqrtf(float a)
const uint8_t ff_celt_freq_range[]
#define CELT_ENERGY_SILENCE
static void scale(int *out, const int *in, const int w, const int h, const int shift)
const float ff_celt_window2[120]
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
static av_always_inline uint32_t celt_rng(CeltFrame *f)
static int16_t block1[64]
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[]
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
void ff_celt_flush(CeltFrame *f)
int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
#define i(width, name, range_min, range_max)
static void celt_postfilter_apply_transition(CeltBlock *block, float *data)
#define CELT_MAX_LOG_BLOCKS
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
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define CELT_POSTFILTER_MINPERIOD
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
static void process_anticollapse(CeltFrame *f, CeltBlock *block, float *X)
void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
static void celt_decode_final_energy(CeltFrame *f, OpusRangeCoder *rc)
main external API structure.
const uint16_t ff_celt_model_energy_small[]
av_cold void ff_opus_dsp_init(OpusDSP *ctx)
static void celt_decode_tf_changes(CeltFrame *f, OpusRangeCoder *rc)
const float ff_celt_alpha_coef[]
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
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 int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)