avcodec/ilbcdec: Fix const correctness

Also constify everything that can be constified.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-07-25 22:37:21 +02:00
parent e86b8ca7f1
commit 86460b366c
1 changed files with 32 additions and 34 deletions

View File

@ -331,8 +331,8 @@ static void lsf_check_stability(int16_t *lsf, int dim, int nb_vectors)
} }
} }
static void lsf_interpolate(int16_t *out, int16_t *in1, static void lsf_interpolate(int16_t *out, const int16_t *in1,
int16_t *in2, int16_t coef, const int16_t *in2, int16_t coef,
int size) int size)
{ {
int invcoef = 16384 - coef, i; int invcoef = 16384 - coef, i;
@ -341,7 +341,7 @@ static void lsf_interpolate(int16_t *out, int16_t *in1,
out[i] = (coef * in1[i] + invcoef * in2[i] + 8192) >> 14; out[i] = (coef * in1[i] + invcoef * in2[i] + 8192) >> 14;
} }
static void lsf2lsp(int16_t *lsf, int16_t *lsp, int order) static void lsf2lsp(const int16_t *lsf, int16_t *lsp, int order)
{ {
int16_t diff, freq; int16_t diff, freq;
int32_t tmp; int32_t tmp;
@ -364,7 +364,7 @@ static void lsf2lsp(int16_t *lsf, int16_t *lsp, int order)
} }
} }
static void get_lsp_poly(int16_t *lsp, int32_t *f) static void get_lsp_poly(const int16_t *lsp, int32_t *f)
{ {
int16_t high, low; int16_t high, low;
int i, j, k, l; int i, j, k, l;
@ -391,7 +391,7 @@ static void get_lsp_poly(int16_t *lsp, int32_t *f)
} }
} }
static void lsf2poly(int16_t *a, int16_t *lsf) static void lsf2poly(int16_t *a, const int16_t *lsf)
{ {
int32_t f[2][6]; int32_t f[2][6];
int16_t lsp[10]; int16_t lsp[10];
@ -418,8 +418,8 @@ static void lsf2poly(int16_t *a, int16_t *lsf)
} }
} }
static void lsp_interpolate2polydec(int16_t *a, int16_t *lsf1, static void lsp_interpolate2polydec(int16_t *a, const int16_t *lsf1,
int16_t *lsf2, int coef, int length) const int16_t *lsf2, int coef, int length)
{ {
int16_t lsftmp[LPC_FILTERORDER]; int16_t lsftmp[LPC_FILTERORDER];
@ -437,13 +437,13 @@ static void bw_expand(int16_t *out, const int16_t *in, const int16_t *coef, int
} }
static void lsp_interpolate(int16_t *syntdenum, int16_t *weightdenum, static void lsp_interpolate(int16_t *syntdenum, int16_t *weightdenum,
int16_t *lsfdeq, int16_t length, const int16_t *lsfdeq, int16_t length,
ILBCContext *s) ILBCContext *s)
{ {
int16_t lp[LPC_FILTERORDER + 1], *lsfdeq2; int16_t lp[LPC_FILTERORDER + 1];
const int16_t *const lsfdeq2 = lsfdeq + length;
int i, pos, lp_length; int i, pos, lp_length;
lsfdeq2 = lsfdeq + length;
lp_length = length + 1; lp_length = length + 1;
if (s->mode == 30) { if (s->mode == 30) {
@ -478,8 +478,8 @@ static void lsp_interpolate(int16_t *syntdenum, int16_t *weightdenum,
} }
} }
static void filter_mafq12(int16_t *in_ptr, int16_t *out_ptr, static void filter_mafq12(const int16_t *in_ptr, int16_t *out_ptr,
int16_t *B, int16_t B_length, const int16_t *B, int16_t B_length,
int16_t length) int16_t length)
{ {
int o, i, j; int o, i, j;
@ -520,13 +520,14 @@ static void filter_arfq12(const int16_t *data_in,
} }
} }
static void state_construct(int16_t ifm, int16_t *idx, static void state_construct(int16_t ifm, const int16_t *idx,
int16_t *synt_denum, int16_t *Out_fix, const int16_t *synt_denum, int16_t *Out_fix,
int16_t len) int16_t len)
{ {
int k; int k;
int16_t maxVal; int16_t maxVal;
int16_t *tmp1, *tmp2, *tmp3; int16_t *tmp1, *tmp3;
const int16_t *tmp2;
/* Stack based */ /* Stack based */
int16_t numerator[1 + LPC_FILTERORDER]; int16_t numerator[1 + LPC_FILTERORDER];
int16_t sampleValVec[2 * STATE_SHORT_LEN_30MS + LPC_FILTERORDER]; int16_t sampleValVec[2 * STATE_SHORT_LEN_30MS + LPC_FILTERORDER];
@ -630,7 +631,7 @@ static void add_vector_and_shift(int16_t *out, const int16_t *in1,
out[i] = (in1[i] + in2[i]) >> shift; out[i] = (in1[i] + in2[i]) >> shift;
} }
static void create_augmented_vector(int index, int16_t *buffer, int16_t *cbVec) static void create_augmented_vector(int index, const int16_t *buffer, int16_t *cbVec)
{ {
int16_t cbVecTmp[4]; int16_t cbVecTmp[4];
int interpolation_length = FFMIN(4, index); int interpolation_length = FFMIN(4, index);
@ -696,7 +697,7 @@ static void get_codebook(int16_t * cbvec, /* (o) Constructed codebook vector *
/* do filtering to get the codebook vector */ /* do filtering to get the codebook vector */
filter_mafq12(&mem[memIndTest + 4], cbvec, (int16_t *) kCbFiltersRev, CB_FILTERLEN, cbveclen); filter_mafq12(&mem[memIndTest + 4], cbvec, kCbFiltersRev, CB_FILTERLEN, cbveclen);
} else { } else {
/* interpolated vectors */ /* interpolated vectors */
/* Stuff zeros outside memory buffer */ /* Stuff zeros outside memory buffer */
@ -704,7 +705,7 @@ static void get_codebook(int16_t * cbvec, /* (o) Constructed codebook vector *
memset(mem + lMem, 0, CB_HALFFILTERLEN * 2); memset(mem + lMem, 0, CB_HALFFILTERLEN * 2);
/* do filtering */ /* do filtering */
filter_mafq12(&mem[memIndTest + 7], tempbuff2, (int16_t *) kCbFiltersRev, CB_FILTERLEN, (int16_t) (cbveclen + 5)); filter_mafq12(&mem[memIndTest + 7], tempbuff2, kCbFiltersRev, CB_FILTERLEN, (int16_t) (cbveclen + 5));
/* Calculate lag index */ /* Calculate lag index */
lag = (cbveclen << 1) - 20 + index - base_size - lMem - 1; lag = (cbveclen << 1) - 20 + index - base_size - lMem - 1;
@ -716,8 +717,8 @@ static void get_codebook(int16_t * cbvec, /* (o) Constructed codebook vector *
static void construct_vector ( static void construct_vector (
int16_t *decvector, /* (o) Decoded vector */ int16_t *decvector, /* (o) Decoded vector */
int16_t *index, /* (i) Codebook indices */ const int16_t *index, /* (i) Codebook indices */
int16_t *gain_index, /* (i) Gain quantization indices */ const int16_t *gain_index, /* (i) Gain quantization indices */
int16_t *mem, /* (i) Buffer for codevector construction */ int16_t *mem, /* (i) Buffer for codevector construction */
int16_t lMem, /* (i) Length of buffer */ int16_t lMem, /* (i) Length of buffer */
int16_t veclen) int16_t veclen)
@ -753,10 +754,10 @@ static void construct_vector (
} }
} }
static void reverse_memcpy(int16_t *dest, int16_t *source, int length) static void reverse_memcpy(int16_t *dest, const int16_t *source, int length)
{ {
int16_t* destPtr = dest; int16_t* destPtr = dest;
int16_t* sourcePtr = source; const int16_t *sourcePtr = source;
int j; int j;
for (j = 0; j < length; j++) for (j = 0; j < length; j++)
@ -766,7 +767,7 @@ static void reverse_memcpy(int16_t *dest, int16_t *source, int length)
static void decode_residual(ILBCContext *s, static void decode_residual(ILBCContext *s,
ILBCFrame *encbits, ILBCFrame *encbits,
int16_t *decresidual, int16_t *decresidual,
int16_t *syntdenum) const int16_t *syntdenum)
{ {
int16_t meml_gotten, Nfor, Nback, diff, start_pos; int16_t meml_gotten, Nfor, Nback, diff, start_pos;
int16_t subcount, subframe; int16_t subcount, subframe;
@ -911,12 +912,10 @@ static int32_t scale_dot_product(const int16_t *v1, const int16_t *v2, int lengt
return av_clipl_int32(sum); return av_clipl_int32(sum);
} }
static void correlation(int32_t *corr, int32_t *ener, int16_t *buffer, static void correlation(int32_t *corr, int32_t *ener, const int16_t *buffer,
int16_t lag, int16_t blen, int16_t srange, int16_t scale) int16_t lag, int16_t blen, int16_t srange, int16_t scale)
{ {
int16_t *w16ptr; const int16_t *w16ptr = &buffer[blen - srange - lag];
w16ptr = &buffer[blen - srange - lag];
*corr = scale_dot_product(&buffer[blen - srange], w16ptr, srange, scale); *corr = scale_dot_product(&buffer[blen - srange], w16ptr, srange, scale);
*ener = scale_dot_product(w16ptr, w16ptr, srange, scale); *ener = scale_dot_product(w16ptr, w16ptr, srange, scale);
@ -952,8 +951,8 @@ static void do_plc(int16_t *plc_residual, /* (o) concealed residual */
int16_t *plc_lpc, /* (o) concealed LP parameters */ int16_t *plc_lpc, /* (o) concealed LP parameters */
int16_t PLI, /* (i) packet loss indicator int16_t PLI, /* (i) packet loss indicator
0 - no PL, 1 = PL */ 0 - no PL, 1 = PL */
int16_t *decresidual, /* (i) decoded residual */ const int16_t *decresidual, /* (i) decoded residual */
int16_t *lpc, /* (i) decoded LPC (only used for no PL) */ const int16_t *lpc, /* (i) decoded LPC (only used for no PL) */
int16_t inlag, /* (i) pitch lag */ int16_t inlag, /* (i) pitch lag */
ILBCContext *s) /* (i/o) decoder instance */ ILBCContext *s) /* (i/o) decoder instance */
{ {
@ -1202,7 +1201,7 @@ static void do_plc(int16_t *plc_residual, /* (o) concealed residual */
return; return;
} }
static int xcorr_coeff(int16_t *target, int16_t *regressor, static int xcorr_coeff(const int16_t *target, const int16_t *regressor,
int16_t subl, int16_t searchLen, int16_t subl, int16_t searchLen,
int16_t offset, int16_t step) int16_t offset, int16_t step)
{ {
@ -1213,8 +1212,8 @@ static int xcorr_coeff(int16_t *target, int16_t *regressor,
int16_t cross_corr_sg_mod, cross_corr_sg_mod_max; int16_t cross_corr_sg_mod, cross_corr_sg_mod_max;
int32_t cross_corr, energy; int32_t cross_corr, energy;
int16_t cross_corr_mod, energy_mod, enery_mod_max; int16_t cross_corr_mod, energy_mod, enery_mod_max;
int16_t *tp, *rp; const int16_t *rp;
int16_t *rp_beg, *rp_end; const int16_t *rp_beg, *rp_end;
int16_t totscale, totscale_max; int16_t totscale, totscale_max;
int16_t scalediff; int16_t scalediff;
int32_t new_crit, max_crit; int32_t new_crit, max_crit;
@ -1253,10 +1252,9 @@ static int xcorr_coeff(int16_t *target, int16_t *regressor,
energy = scale_dot_product(regressor, regressor, subl, shifts); energy = scale_dot_product(regressor, regressor, subl, shifts);
for (k = 0; k < searchLen; k++) { for (k = 0; k < searchLen; k++) {
tp = target;
rp = &regressor[pos]; rp = &regressor[pos];
cross_corr = scale_dot_product(tp, rp, subl, shifts); cross_corr = scale_dot_product(target, rp, subl, shifts);
if ((energy > 0) && (cross_corr > 0)) { if ((energy > 0) && (cross_corr > 0)) {
/* Put cross correlation and energy on 16 bit word */ /* Put cross correlation and energy on 16 bit word */