Go to the documentation of this file.
43 #define LPC_FILTERORDER 10
47 #define ST_MEM_L_TBL 85
48 #define MEM_LF_TBL 147
49 #define STATE_SHORT_LEN_20MS 57
50 #define STATE_SHORT_LEN_30MS 58
52 #define BLOCKL_MAX 240
55 #define CB_HALFFILTERLEN 4
56 #define CB_FILTERLEN 8
58 #define ENH_NBLOCKS_TOT 8
60 #define ENH_BUFL (ENH_NBLOCKS_TOT)*ENH_BLOCKL
61 #define ENH_BUFL_FILTEROVERHEAD 3
62 #define BLOCKL_MAX 240
70 #define STATE_SHORT_LEN_30MS 58
71 #define STATE_SHORT_LEN_20MS 57
73 #define SPL_MUL_16_16(a, b) ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
74 #define SPL_MUL_16_16_RSFT(a, b, c) (SPL_MUL_16_16(a, b) >> (c))
164 for (j = 0; j < 48; j++)
199 for (j = 0; j < 56; j++)
272 for (k = 4; k < 6; k++) {
275 }
else if (
index[k] >= 108 &&
index[k] < 128) {
283 int i, j, pos = 0, cb_pos = 0;
311 for (
int n = 0;
n < 2;
n++) {
312 for (
int m = 0; m < nb_vectors; m++) {
313 for (
int k = 0; k <
dim - 1; k++) {
316 if ((lsf[
i + 1] - lsf[
i]) < 319) {
317 if (lsf[
i + 1] < lsf[
i]) {
318 lsf[
i + 1] = lsf[
i] + 160;
319 lsf[
i] = lsf[
i + 1] - 160;
326 lsf[
i] = av_clip(lsf[
i], 82, 25723);
333 int16_t *in2, int16_t coef,
336 int invcoef = 16384 - coef,
i;
339 out[
i] = (coef * in1[
i] + invcoef * in2[
i] + 8192) >> 14;
342 static void lsf2lsp(int16_t *lsf, int16_t *lsp,
int order)
348 for (
i = 0;
i < order;
i++) {
349 freq = (lsf[
i] * 20861) >> 15;
356 k =
FFMIN(freq >> 8, 63);
372 f[1] = lsp[0] * -1024;
374 for (
i = 2, k = 2, l = 2;
i <= 5;
i++, k += 2) {
377 for (j =
i; j > 1; j--, l--) {
378 high =
f[l - 1] >> 16;
379 low = (
f[l - 1] - (high * (1 << 16))) >> 1;
381 tmp = ((high * lsp[k]) * 4) + (((low * lsp[k]) >> 15) * 4);
384 f[l] -= (unsigned)
tmp;
387 f[l] -= lsp[k] * (1 << 10);
404 for (
i = 5;
i > 0;
i--) {
405 f[0][
i] += (unsigned)
f[0][
i - 1];
406 f[1][
i] -= (unsigned)
f[1][
i - 1];
410 for (
i = 5;
i > 0;
i--) {
411 tmp =
f[0][6 -
i] + (unsigned)
f[1][6 -
i] + 4096;
412 a[6 -
i] =
tmp >> 13;
414 tmp =
f[0][6 -
i] - (unsigned)
f[1][6 -
i] + 4096;
415 a[5 +
i] =
tmp >> 13;
420 int16_t *lsf2,
int coef,
int length)
434 out[
i] = (coef[
i] *
in[
i] + 16384) >> 15;
438 int16_t *lsfdeq, int16_t
length,
442 int i, pos, lp_length;
444 lsfdeq2 = lsfdeq +
length;
449 memcpy(syntdenum, lp, lp_length * 2);
453 for (
i = 1;
i < 6;
i++) {
457 memcpy(syntdenum + pos, lp, lp_length * 2);
463 for (
i = 0;
i <
s->nsub;
i++) {
466 memcpy(syntdenum + pos, lp, lp_length * 2);
473 memcpy(
s->lsfdeqold, lsfdeq2,
length * 2);
475 memcpy(
s->lsfdeqold, lsfdeq,
length * 2);
480 int16_t *
B, int16_t B_length,
486 const int16_t *b_ptr = &
B[0];
487 const int16_t *x_ptr = &in_ptr[
i];
490 for (j = 0; j < B_length; j++)
491 o += b_ptr[j] * *x_ptr--;
493 o = av_clip(o, -134217728, 134215679);
495 out_ptr[
i] = ((o + 2048) >> 12);
502 int coefficients_length,
507 for (
i = 0;
i < data_length;
i++) {
510 for (j = coefficients_length - 1; j > 0; j--) {
517 data_out[
i] = (
output + 2048) >> 12;
522 int16_t *synt_denum, int16_t *Out_fix,
527 int16_t *tmp1, *tmp2, *tmp3;
548 tmp2 = &idx[
len - 1];
551 for (k = 0; k <
len; k++) {
558 }
else if (ifm < 59) {
559 for (k = 0; k <
len; k++) {
567 for (k = 0; k <
len; k++) {
577 memset(&sampleVal[
len], 0,
len * 2);
589 tmp1 = &sampleAr[
len - 1];
590 tmp2 = &sampleAr[2 *
len - 1];
592 for (k = 0; k <
len; k++) {
593 (*tmp3) = (*tmp1) + (*tmp2);
624 const int16_t *in2,
int length,
635 int16_t ilow =
index - interpolation_length;
653 int16_t k, base_size;
656 int16_t tempbuff2[
SUBL + 5];
659 base_size = lMem - cbveclen + 1;
661 if (cbveclen ==
SUBL) {
662 base_size += cbveclen / 2;
666 if (
index < lMem - cbveclen + 1) {
669 k =
index + cbveclen;
671 memcpy(cbvec,
mem + lMem - k, cbveclen * 2);
672 }
else if (
index < base_size) {
686 if (
index - base_size < lMem - cbveclen + 1) {
690 memIndTest = lMem - (
index - base_size + cbveclen);
708 lag = (cbveclen << 1) - 20 +
index - base_size - lMem - 1;
724 int16_t cbvec0[
SUBL];
725 int16_t cbvec1[
SUBL];
726 int16_t cbvec2[
SUBL];
745 for (j = 0; j < veclen; j++) {
750 decvector[j] = (
int)(a32 + 8192) >> 14;
756 int16_t* destPtr = dest;
757 int16_t* sourcePtr =
source;
760 for (j = 0; j <
length; j++)
761 *destPtr-- = *sourcePtr++;
766 int16_t *decresidual,
769 int16_t meml_gotten, Nfor, Nback,
diff, start_pos;
770 int16_t subcount, subframe;
771 int16_t *reverseDecresidual =
s->enh_buf;
772 int16_t *memVec =
s->prevResidual;
789 memset(
mem, 0, (int16_t) (
CB_MEML -
s->state_short_len) * 2);
790 memcpy(
mem +
CB_MEML -
s->state_short_len, decresidual + start_pos,
s->state_short_len * 2);
798 meml_gotten =
s->state_short_len;
800 memset(
mem, 0, (int16_t) (
CB_MEML - meml_gotten) * 2);
813 Nfor =
s->nsub - encbits->
start - 1;
821 for (subframe = 0; subframe < Nfor; subframe++) {
835 Nback = encbits->
start - 1;
839 meml_gotten =
SUBL * (
s->nsub + 1 - encbits->
start);
845 memset(
mem, 0, (int16_t) (
CB_MEML - meml_gotten) * 2);
848 for (subframe = 0; subframe < Nback; subframe++) {
867 int i = 0, absolute = 0, maximum = 0;
874 absolute =
FFABS(vector[
i]);
875 if (absolute > maximum)
880 return FFMIN(maximum, INT16_MAX);
887 if (0xFFFF0000 &
n) {
907 sum += (v1[
i] * v2[
i]) >> scaling;
909 return av_clipl_int32(sum);
913 int16_t lag, int16_t blen, int16_t srange, int16_t scale)
917 w16ptr = &
buffer[blen - srange - lag];
928 #define SPL_SHIFT_W32(x, c) (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
949 static void do_plc(int16_t *plc_residual,
953 int16_t *decresidual,
959 int32_t cross, ener, cross_comp, ener_comp = 0;
960 int32_t measure, max_measure, energy;
961 int16_t
max, cross_square_max, cross_square;
962 int16_t j, lag, tmp1, tmp2, randlag;
969 int16_t max_perSquare;
970 int16_t scale1, scale2;
982 s->consPLICount += 1;
987 if (
s->prevPLI != 1) {
999 s->prevScale = scale3;
1006 corrLen =
FFMIN(60,
s->block_samples - (inlag + 3));
1008 correlation(&cross, &ener,
s->prevResidual, lag,
s->block_samples, corrLen, scale3);
1014 for (j = inlag - 2; j <= inlag + 3; j++) {
1015 correlation(&cross_comp, &ener_comp,
s->prevResidual, j,
s->block_samples, corrLen, scale3);
1031 if (((shift_max << 1) + shift3) > ((
shift1 << 1) +
shift2)) {
1039 if ((measure >> tmp1) > (max_measure >> tmp2)) {
1042 cross_square_max = cross_square;
1057 tmp2W32 =
scale_dot_product(&
s->prevResidual[
s->block_samples - corrLen], &
s->prevResidual[
s->block_samples - corrLen], corrLen, scale3);
1059 if ((tmp2W32 > 0) && (ener_comp > 0)) {
1073 totscale = scale1 + scale2 - 1;
1085 max_perSquare =
s->per_square;
1093 if (
s->consPLICount *
s->block_samples > 320) {
1095 }
else if (
s->consPLICount *
s->block_samples > 640) {
1097 }
else if (
s->consPLICount *
s->block_samples > 960) {
1099 }
else if (
s->consPLICount *
s->block_samples > 1280) {
1109 if (max_perSquare > 7868) {
1111 }
else if (max_perSquare > 839) {
1114 while ((max_perSquare <
kPlcPerSqr[ind]) && (ind > 0)) {
1120 pitchfact =
FFMIN(tmpW32, 32767);
1135 for (
i = 0;
i <
s->block_samples;
i++) {
1138 randlag = 53 + (
s->seed & 63);
1143 randvec[
i] =
s->prevResidual[
s->block_samples + pick];
1145 randvec[
i] =
s->prevResidual[pick];
1152 plc_residual[
i] =
s->prevResidual[
s->block_samples + pick];
1154 plc_residual[
i] = plc_residual[pick];
1159 tot_gain = use_gain;
1160 }
else if (
i < 160) {
1167 plc_residual[
i] =
SPL_MUL_16_16_RSFT(tot_gain, (pitchfact * plc_residual[
i] + (32767 - pitchfact) * randvec[
i] + 16384) >> 15, 15);
1176 if (energy <
SPL_SHIFT_W32(
s->block_samples * 900, -
s->prevScale - 1)) {
1178 for (
i = 0;
i <
s->block_samples;
i++) {
1179 plc_residual[
i] = randvec[
i];
1188 s->per_square = max_perSquare;
1190 memcpy(plc_residual, decresidual,
s->block_samples * 2);
1192 s->consPLICount = 0;
1198 memcpy(
s->prevResidual, plc_residual,
s->block_samples * 2);
1204 int16_t subl, int16_t searchLen,
1210 int16_t cross_corr_scale, energy_scale;
1211 int16_t cross_corr_sg_mod, cross_corr_sg_mod_max;
1213 int16_t cross_corr_mod, energy_mod, enery_mod_max;
1215 int16_t *rp_beg, *rp_end;
1216 int16_t totscale, totscale_max;
1223 cross_corr_sg_mod_max = 0;
1224 enery_mod_max = INT16_MAX;
1225 totscale_max = -500;
1233 rp_end = ®ressor[subl];
1236 rp_beg = ®ressor[-1];
1237 rp_end = ®ressor[subl - 1];
1253 for (k = 0; k < searchLen; k++) {
1255 rp = ®ressor[pos];
1259 if ((energy > 0) && (cross_corr > 0)) {
1261 cross_corr_scale =
norm_w32(cross_corr) - 16;
1262 cross_corr_mod = (int16_t)
SPL_SHIFT_W32(cross_corr, cross_corr_scale);
1263 energy_scale =
norm_w32(energy) - 16;
1267 cross_corr_sg_mod = (int16_t)
SPL_MUL_16_16_RSFT(cross_corr_mod, cross_corr_mod, 16);
1272 totscale = energy_scale - (cross_corr_scale * 2);
1277 scalediff = totscale - totscale_max;
1278 scalediff =
FFMIN(scalediff, 31);
1279 scalediff =
FFMAX(scalediff, -31);
1285 if (scalediff < 0) {
1286 new_crit = ((
int32_t) cross_corr_sg_mod * enery_mod_max) >> (-scalediff);
1287 max_crit = ((
int32_t) cross_corr_sg_mod_max * energy_mod);
1289 new_crit = ((
int32_t) cross_corr_sg_mod * enery_mod_max);
1290 max_crit = ((
int32_t) cross_corr_sg_mod_max * energy_mod) >> scalediff;
1296 if (new_crit > max_crit) {
1297 cross_corr_sg_mod_max = cross_corr_sg_mod;
1298 enery_mod_max = energy_mod;
1299 totscale_max = totscale;
1306 energy += (unsigned)
step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >>
shifts);
1315 static void hp_output(int16_t *signal,
const int16_t *ba, int16_t *y,
1316 int16_t *x, int16_t
len)
1320 for (
int i = 0;
i <
len;
i++) {
1337 signal[
i] = av_clip_intp2(
tmp + 1024, 26) >> 11;
1344 if (
tmp > 268435455) {
1346 }
else if (
tmp < -268435456) {
1353 y[1] = (
tmp - (y[0] * (1 << 16))) >> 1;
1358 int *got_frame_ptr,
AVPacket *avpkt)
1370 frame->nb_samples =
s->block_samples;
1376 if (
s->frame.start < 1 ||
s->frame.start > 5)
1388 do_plc(
s->plc_residual,
s->plc_lpc, 0,
1392 memcpy(
s->decresidual,
s->plc_residual,
s->block_samples * 2);
1401 if (
s->mode == 20) {
1402 lag =
xcorr_coeff(&
s->decresidual[
s->block_samples-60], &
s->decresidual[
s->block_samples-80],
1414 memcpy(plc_data,
s->decresidual,
s->block_samples * 2);
1419 for (
i = 0;
i <
s->nsub;
i++) {
1429 memcpy(
frame->data[0], plc_data,
s->block_samples * 2);
1432 s->hpimemy,
s->hpimemx,
s->block_samples);
1454 s->mode = avctx->
bit_rate <= 14000 ? 30 : 20;
1463 if (
s->mode == 30) {
1464 s->block_samples = 240;
1470 s->block_samples = 160;
static const int16_t kPlcPerSqr[]
static const uint8_t lsf_dim_codebook[]
uint64_t channel_layout
Audio channel layout.
int sample_rate
samples per second
int16_t plc_residual[BLOCKL_MAX+LPC_FILTERORDER]
int16_t enh_buf[ENH_BUFL+ENH_BUFL_FILTEROVERHEAD]
int16_t weightdenum[(LPC_FILTERORDER+1) *NSUB_MAX]
static void decode_residual(ILBCContext *s, ILBCFrame *encbits, int16_t *decresidual, int16_t *syntdenum)
#define AV_CH_LAYOUT_MONO
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 filter_arfq12(const int16_t *data_in, int16_t *data_out, const int16_t *coefficients, int coefficients_length, int data_length)
static void lsf_dequantization(int16_t *lsfdeq, int16_t *index, int16_t lpc_n)
This structure describes decoded (raw) audio or video data.
static void index_conv(int16_t *index)
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
static int ilbc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static int unpack_frame(ILBCContext *s)
static const int16_t cos_derivative_tbl[64]
int16_t lsfdeqold[LPC_FILTERORDER]
#define SPL_MUL_16_16(a, b)
static float win(SuperEqualizerContext *s, float n, int N)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int16_t lsfdeq[LPC_FILTERORDER *LPC_N_MAX]
int16_t decresidual[BLOCKL_MAX]
int16_t gain_index[CB_NSTAGES *(NASUB_MAX+1)]
#define SPL_SHIFT_W32(x, c)
static int16_t get_size_in_bits(uint32_t n)
static void vector_rmultiplication(int16_t *out, const int16_t *in, const int16_t *win, int length, int shift)
static void vector_multiplication(int16_t *out, const int16_t *in, const int16_t *win, int length, int shift)
static void construct_vector(int16_t *decvector, int16_t *index, int16_t *gain_index, int16_t *mem, int16_t lMem, int16_t veclen)
#define STATE_SHORT_LEN_30MS
static void state_construct(int16_t ifm, int16_t *idx, int16_t *synt_denum, int16_t *Out_fix, int16_t len)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int32_t scale_dot_product(const int16_t *v1, const int16_t *v2, int length, int scaling)
#define SPL_MUL_16_16_RSFT(a, b, c)
int16_t idx[STATE_SHORT_LEN_30MS]
static const int16_t lsf_weight_30ms[]
int16_t prev_lpc[LPC_FILTERORDER+1]
static const int16_t kPlcPfSlope[]
static void create_augmented_vector(int index, int16_t *buffer, int16_t *cbVec)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int16_t cb_index[CB_NSTAGES *(NASUB_MAX+1)]
static const int16_t cos_tbl[64]
Describe the class of an AVClass context structure.
static void add_vector_and_shift(int16_t *out, const int16_t *in1, const int16_t *in2, int length, int shift)
int16_t lsfold[LPC_FILTERORDER]
static double coefficients[8 *8]
int64_t bit_rate
the average bitrate
static void lsf_check_stability(int16_t *lsf, int dim, int nb_vectors)
static const int16_t hp_out_coeffs[]
static unsigned int get_bits1(GetBitContext *s)
static int32_t div_w32_w16(int32_t num, int16_t den)
static void correlation(int32_t *corr, int32_t *ener, int16_t *buffer, int16_t lag, int16_t blen, int16_t srange, int16_t scale)
static const uint8_t lsf_size_codebook[]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a source
static const int shift1[6]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum AVSampleFormat sample_fmt
audio sample format
static const int16_t kCbFiltersRev[]
static void lsf2lsp(int16_t *lsf, int16_t *lsp, int order)
#define STATE_SHORT_LEN_20MS
static int16_t gain_dequantization(int index, int max_in, int stage)
int16_t prevResidual[NSUB_MAX *SUBL]
static const int16_t ilbc_state[8]
static const int16_t *const ilbc_gain[]
static int16_t norm_w32(int32_t a)
static const int16_t kLpcChirpSyntDenum[]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
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
static const int shift2[6]
int16_t lsf[LSF_NSPLIT *LPC_N_MAX]
int channels
number of audio channels
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
static int16_t max_abs_value_w16(const int16_t *vector, int length)
#define i(width, name, range_min, range_max)
static void do_plc(int16_t *plc_residual, int16_t *plc_lpc, int16_t PLI, int16_t *decresidual, int16_t *lpc, int16_t inlag, ILBCContext *s)
static void lsf_interpolate(int16_t *out, int16_t *in1, int16_t *in2, int16_t coef, int size)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
static void bw_expand(int16_t *out, const int16_t *in, const int16_t *coef, int length)
static void lsp_interpolate2polydec(int16_t *a, int16_t *lsf1, int16_t *lsf2, int coef, int length)
#define ENH_BUFL_FILTEROVERHEAD
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
static void get_codebook(int16_t *cbvec, int16_t *mem, int16_t index, int16_t lMem, int16_t cbveclen)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static av_cold int ilbc_decode_init(AVCodecContext *avctx)
static void hp_output(int16_t *signal, const int16_t *ba, int16_t *y, int16_t *x, int16_t len)
main external API structure.
static void reverse_memcpy(int16_t *dest, int16_t *source, int length)
int16_t enh_period[ENH_NBLOCKS_TOT]
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static void lsf2poly(int16_t *a, int16_t *lsf)
static const int16_t frg_quant_mod[64]
int16_t syntMem[LPC_FILTERORDER]
static void lsp_interpolate(int16_t *syntdenum, int16_t *weightdenum, int16_t *lsfdeq, int16_t length, ILBCContext *s)
int16_t plc_lpc[LPC_FILTERORDER+1]
static const int16_t lsf_codebook[64 *3+128 *3+128 *4]
static int shift(int a, int b)
static const int16_t kPlcPitchFact[]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const int16_t lsf_weight_20ms[]
static const int16_t alpha[]
This structure stores compressed data.
static void get_lsp_poly(int16_t *lsp, int32_t *f)
static void filter_mafq12(int16_t *in_ptr, int16_t *out_ptr, int16_t *B, int16_t B_length, int16_t length)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int16_t old_syntdenum[NSUB_MAX *(LPC_FILTERORDER+1)]
int16_t syntdenum[NSUB_MAX *(LPC_FILTERORDER+1)]
static int xcorr_coeff(int16_t *target, int16_t *regressor, int16_t subl, int16_t searchLen, int16_t offset, int16_t step)
static const uint8_t shifts[2][12]