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;
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) {
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) +
209 float x0, x1, x2, x3, x4;
212 if (block->
pf_gains[0] == 0.0 || len <= 0)
224 for (i = 0; i <
len; i++) {
225 x0 = data[i - T + 2];
269 if (has_postfilter) {
271 int tapset, octave, period;
279 for (i = 0; i < 2; i++) {
284 block->
pf_gains_new[1] = gain * ff_celt_postfilter_taps[tapset][1];
285 block->
pf_gains_new[2] = gain * ff_celt_postfilter_taps[tapset][2];
299 for (i = f->
start_band; i < f->end_band; i++) {
304 float thresh, sqrt_1;
309 thresh =
exp2f(-1.0 - 0.125f * depth);
322 Ediff = block->
energy[i] -
FFMIN(prev[0], prev[1]);
323 Ediff =
FFMAX(0, Ediff);
327 r =
exp2f(1 - Ediff);
330 r =
FFMIN(thresh, r) * sqrt_1;
331 for (k = 0; k < 1 << f->
size; k++) {
336 xptr[(j << f->
size) + k] = (
celt_rng(f) & 0x8000) ? r : -r;
349 int start_band,
int end_band)
351 int i, j, downmix = 0;
355 if (channels != 1 && channels != 2) {
360 if (start_band < 0 || start_band > end_band || end_band >
CELT_MAX_BANDS) {
362 start_band, end_band);
396 else if (consumed == 1)
452 for (i = 0; i < 2; i++) {
468 for (j = 0; j < f->
blocks; j++) {
485 const float tmp = block->
buf[1024 - frame_size + j] + m;
496 for (i = 0; i < 2; i++ ) {
529 for (i = 0; i < 2; i++) {
536 memset(block->
buf, 0,
sizeof(block->
buf));
572 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.
static float alpha(float a)
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_postfilter_apply(CeltBlock *block, float *data, int len)
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.
static void celt_denormalize(CeltFrame *f, CeltBlock *block, float *data)
int fine_priority[CELT_MAX_BANDS]
void(* vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, int len)
Overlap/add with window function.
const float * ff_celt_window
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
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* imdct_half)(struct MDCT15Context *s, float *dst, const float *src, ptrdiff_t stride)
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]
static const uint8_t offset[127][2]
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
GLsizei GLboolean const GLfloat * value
void ff_celt_free(CeltFrame **f)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
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)
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 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)
av_cold void ff_mdct15_uninit(MDCT15Context **ps)
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[]
static int parse_postfilter(CeltFrame *f, OpusRangeCoder *rc, int consumed)
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)