Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness
Date: Wed, 27 Jul 2022 00:07:58 +0200
Message-ID: <DB6PR0101MB2214B3170ACD2A8A9FC7A45D8F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com> (raw)
In-Reply-To: <DB6PR0101MB22140CEE765FDFAB596653698F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com>

Also constify everything that can be constified.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ilbcdec.c | 66 +++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 34 deletions(-)

diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 4c82631c34..4905ee4145 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -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,
-                            int16_t *in2, int16_t coef,
+static void lsf_interpolate(int16_t *out, const int16_t *in1,
+                            const int16_t *in2, int16_t coef,
                             int size)
 {
     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;
 }
 
-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;
     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;
     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];
     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,
-                                   int16_t *lsf2, int coef, int length)
+static void lsp_interpolate2polydec(int16_t *a, const int16_t *lsf1,
+                                    const int16_t *lsf2, int coef, int length)
 {
     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,
-                            int16_t *lsfdeq, int16_t length,
+                            const int16_t *lsfdeq, int16_t length,
                             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;
 
-    lsfdeq2 = lsfdeq + length;
     lp_length = length + 1;
 
     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,
-                          int16_t *B, int16_t B_length,
+static void filter_mafq12(const int16_t *in_ptr, int16_t *out_ptr,
+                          const int16_t *B, int16_t B_length,
                           int16_t length)
 {
     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,
-                           int16_t *synt_denum, int16_t *Out_fix,
+static void state_construct(int16_t ifm, const int16_t *idx,
+                            const int16_t *synt_denum, int16_t *Out_fix,
                            int16_t len)
 {
     int k;
     int16_t maxVal;
-    int16_t *tmp1, *tmp2, *tmp3;
+    int16_t *tmp1, *tmp3;
+    const int16_t *tmp2;
     /* Stack based */
     int16_t numerator[1 + 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;
 }
 
-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];
     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 */
 
-            filter_mafq12(&mem[memIndTest + 4], cbvec, (int16_t *) kCbFiltersRev, CB_FILTERLEN, cbveclen);
+            filter_mafq12(&mem[memIndTest + 4], cbvec, kCbFiltersRev, CB_FILTERLEN, cbveclen);
         } else {
             /* interpolated vectors */
             /* 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);
 
             /* 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 */
             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 (
     int16_t *decvector,   /* (o) Decoded vector */
-    int16_t *index,       /* (i) Codebook indices */
-    int16_t *gain_index,  /* (i) Gain quantization indices */
+    const int16_t *index,       /* (i) Codebook indices */
+    const int16_t *gain_index,  /* (i) Gain quantization indices */
     int16_t *mem,         /* (i) Buffer for codevector construction */
     int16_t lMem,         /* (i) Length of buffer */
     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* sourcePtr = source;
+    const int16_t *sourcePtr = source;
     int 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,
                             ILBCFrame *encbits,
                             int16_t *decresidual,
-                            int16_t *syntdenum)
+                            const int16_t *syntdenum)
 {
     int16_t meml_gotten, Nfor, Nback, diff, start_pos;
     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);
 }
 
-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 *w16ptr;
-
-    w16ptr = &buffer[blen - srange - lag];
+    const int16_t *w16ptr = &buffer[blen - srange - lag];
 
     *corr = scale_dot_product(&buffer[blen - srange], 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 PLI,                /* (i) packet loss indicator
                                                       0 - no PL, 1 = PL */
-                   int16_t *decresidual,       /* (i) decoded residual */
-                   int16_t *lpc,               /* (i) decoded LPC (only used for no PL) */
+                   const int16_t *decresidual, /* (i) decoded residual */
+                   const int16_t *lpc,         /* (i) decoded LPC (only used for no PL) */
                    int16_t inlag,              /* (i) pitch lag */
                    ILBCContext *s)             /* (i/o) decoder instance */
 {
@@ -1202,7 +1201,7 @@ static void do_plc(int16_t *plc_residual,      /* (o) concealed residual */
     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 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;
     int32_t cross_corr, energy;
     int16_t cross_corr_mod, energy_mod, enery_mod_max;
-    int16_t *tp, *rp;
-    int16_t *rp_beg, *rp_end;
+    const int16_t *rp;
+    const int16_t *rp_beg, *rp_end;
     int16_t totscale, totscale_max;
     int16_t scalediff;
     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);
 
     for (k = 0; k < searchLen; k++) {
-        tp = target;
         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)) {
             /* Put cross correlation and energy on 16 bit word */
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-07-27  9:35 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 02/39] avcodec/hevcdec: Constify src pointers of HEVC DSP functions Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 03/39] avcodec/threadframe: Constify the frame in ff_thread_await_progress Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 04/39] avcodec: Constify ThreadFrames if possible Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target Andreas Rheinhardt
2022-07-27 10:25   ` Ronald S. Bultje
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 06/39] avcodec/wavpack: Constify slice threads' ptr to main context Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: " Andreas Rheinhardt
2022-07-27 10:24   ` Ronald S. Bultje
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 08/39] avcodec/proresdec2: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 09/39] avcodec/magicyuv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 10/39] avcodec/jpeg2000dec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 11/39] avcodec/dxv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 12/39] avcodec/dvdec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 13/39] avcodec/diracdec: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 14/39] avcodec/half2float: Constify arrays in half2float() Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 15/39] avcodec/exr: Constify slice threads' ptr to main context Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 16/39] avcodec/xwdenc: Don't modify input frame Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 17/39] swscale/rgb2rgb: Don't cast const away Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 18/39] avcodec/gif: Remove redundant cast Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 19/39] avcodec/fitsenc: Don't cast const away unnecessarily Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 20/39] avcodec/diracdsp: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 21/39] avcodec/dxv: " Andreas Rheinhardt
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 22/39] avcodec/cinepakenc: Avoid casting const away Andreas Rheinhardt
2022-07-26 22:07 ` Andreas Rheinhardt [this message]
2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 24/39] avcodec/ilbcdec: Move transient GetBitContext from ctx to stack Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 26/39] avcodec/pnmdec: Fix indentation Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 27/39] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 28/39] avcodec/snow: Remove unused halfpel_plane Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 29/39] avcodec/pngenc: Don't cast const away unnecessarily Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 30/39] avcodec/lossless_videoencdsp: Constify src sub_left_predict Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 31/39] avcodec/me_cmp: Constify me_cmp_func buffer parameters Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 32/39] avcodec/h264chroma: Constify src in h264_chroma_mc_func Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 33/39] avcodec/cfhdencdsp: Constify input pointers Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible Andreas Rheinhardt
2022-07-28 22:05   ` Michael Niedermayer
2022-07-30  9:55     ` Andreas Rheinhardt
2022-07-30 17:12       ` Michael Niedermayer
2022-08-02  9:30         ` Anton Khirnov
2022-08-03 15:28           ` Michael Niedermayer
2022-08-03 15:48             ` Michael Niedermayer
2022-08-06 13:07             ` Anton Khirnov
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 35/39] avcodec/mpegvideodsp: Constify src pointers Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data Andreas Rheinhardt
2022-07-28 22:04   ` Michael Niedermayer
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion Andreas Rheinhardt
2022-07-28 22:03   ` Michael Niedermayer
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 38/39] avcodec: Constify frame->data pointers for encoders where possible Andreas Rheinhardt
2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index() Andreas Rheinhardt
2022-07-28 22:02   ` Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DB6PR0101MB2214B3170ACD2A8A9FC7A45D8F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git