37 float prev[2] = { 0 };
45 beta = 1.0f - (4915.0f/32768.0f);
55 if (i < f->start_band || i >= f->
end_band) {
61 if (available >= 15) {
63 int k =
FFMIN(i, 20) << 1;
65 }
else if (available >= 2) {
67 value = (x>>1) ^ -(x&1);
68 }
else if (available >= 1) {
73 prev[j] += beta *
value;
81 for (i = f->
start_band; i < f->end_band; i++) {
91 offset = (q2 + 0.5f) * (1 << (14 - f->
fine_bits[i])) / 16384.0f - 0.5f;
102 for (priority = 0; priority < 2; priority++) {
111 offset = (q2 - 0.5f) * (1 << (14 - f->
fine_bits[i] - 1)) / 16384.0f;
121 int i,
diff = 0, tf_select = 0, tf_changed = 0, tf_select_bit;
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) {
141 for (i = f->
start_band; i < f->end_band; i++) {
150 for (i = f->
start_band; i < f->end_band; i++) {
168 float x0, x1, x2, x3, x4;
190 x0 = data[i - T1 + 2];
192 data[
i] += (1.0 -
w) * g00 * data[i - T0] +
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) +
218 if (len > CELT_OVERLAP) {
221 if (block->
pf_gains[0] > FLT_EPSILON && filter_len > 0)
230 memmove(block->
buf, block->
buf + len, (1024 + CELT_OVERLAP / 2) *
sizeof(
float));
242 if (has_postfilter) {
244 int tapset, octave,
period;
252 for (i = 0; i < 2; i++) {
257 block->
pf_gains_new[1] = gain * ff_celt_postfilter_taps[tapset][1];
258 block->
pf_gains_new[2] = gain * ff_celt_postfilter_taps[tapset][2];
272 for (i = f->
start_band; i < f->end_band; i++) {
277 float thresh, sqrt_1;
282 thresh =
exp2f(-1.0 - 0.125f * depth);
296 Ediff =
FFMAX(0, Ediff);
300 r =
exp2f(1 - Ediff);
303 r =
FFMIN(thresh, r) * sqrt_1;
304 for (k = 0; k < 1 << f->
size; 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;
328 if (channels != 1 && channels != 2) {
333 if (start_band < 0 || start_band > end_band || end_band >
CELT_MAX_BANDS) {
335 start_band, end_band);
369 else if (consumed == 1)
425 for (i = 0; i < 2; i++) {
440 for (j = 0; j < f->
blocks; j++) {
457 &block->
buf[1024 - frame_size],
464 for (i = 0; i < 2; i++ ) {
497 for (i = 0; i < 2; i++) {
504 memset(block->
buf, 0,
sizeof(block->
buf));
544 if (output_channels != 1 && output_channels != 2) {
int ff_celt_decode_frame(CeltFrame *f, OpusRangeCoder *rc, float **output, int channels, int frame_size, int start_band, int end_band)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
ptrdiff_t const GLvoid * data
static void celt_postfilter(CeltFrame *f, CeltBlock *block)
const uint8_t ff_celt_coarse_energy_dist[4][2][42]
float coeffs[CELT_MAX_FRAME_SIZE]
const uint8_t ff_celt_freq_bands[]
uint32_t ff_opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
const float ff_celt_postfilter_taps[3][3]
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
int fine_priority[CELT_MAX_BANDS]
void(* vector_fmac_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float and add to destination vector.
float(* deemphasis)(float *out, float *in, float coeff, int len)
The exact code depends on how similar the blocks are and how related they are to the block
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
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
GLsizei GLboolean const GLfloat * value
static void process_anticollapse(CeltFrame *f, CeltBlock *block, float *X)
av_cold int ff_mdct15_init(MDCT15Context **ps, int inverse, int N, double scale)
#define CELT_POSTFILTER_MINPERIOD
#define CELT_MAX_LOG_BLOCKS
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
void ff_celt_flush(CeltFrame *f)
int flags
AV_CODEC_FLAG_*.
static void celt_decode_tf_changes(CeltFrame *f, OpusRangeCoder *rc)
int tf_change[CELT_MAX_BANDS]
int pulses[CELT_MAX_BANDS]
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
int fine_bits[CELT_MAX_BANDS]
uint32_t ff_opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
const int8_t ff_celt_tf_select[4][2][2][2]
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define CELT_SHORT_BLOCKSIZE
void ff_celt_free(CeltFrame **f)
int ff_opus_rc_dec_laplace(OpusRangeCoder *rc, uint32_t symbol, int decay)
const uint8_t ff_celt_freq_range[]
static void celt_decode_coarse_energy(CeltFrame *f, OpusRangeCoder *rc)
static void celt_postfilter_apply_transition(CeltBlock *block, float *data)
#define FF_ARRAY_ELEMS(a)
static void celt_decode_fine_energy(CeltFrame *f, OpusRangeCoder *rc)
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
static const int16_t alpha[]
main external API structure.
const float ff_celt_window2[120]
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...
#define CELT_MAX_FINE_BITS
#define CELT_ENERGY_SILENCE
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.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, int encode)
static av_always_inline void celt_renormalize_vector(float *X, int N, float gain)
const uint16_t ff_celt_model_energy_small[]
float energy[CELT_MAX_BANDS]
const float ff_celt_beta_coef[]
static av_always_inline uint32_t celt_rng(CeltFrame *f)
const float *const ff_celt_window
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
av_cold void ff_opus_dsp_init(OpusDSP *ctx)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static void celt_decode_final_energy(CeltFrame *f, OpusRangeCoder *rc)
const float ff_celt_alpha_coef[]
static int16_t block1[64]
uint32_t ff_opus_rc_dec_uint(OpusRangeCoder *rc, uint32_t size)
CELT: read a uniform distribution.
const float ff_celt_mean_energy[]
void(* postfilter)(float *data, int period, float *gains, int len)
static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
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
float prev_energy[2][CELT_MAX_BANDS]
uint8_t collapse_masks[CELT_MAX_BANDS]
const uint16_t ff_celt_model_tapset[]
int ff_celt_init(AVCodecContext *avctx, CeltFrame **f, int output_channels, int apply_phase_inv)
void av_cold ff_celt_pvq_uninit(CeltPVQ **pvq)
void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)