Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers
@ 2022-07-26 21:47 Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 02/39] avcodec/hevcdec: Constify src pointers of HEVC DSP functions Andreas Rheinhardt
                   ` (37 more replies)
  0 siblings, 38 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 21:47 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aarch64/hevcdsp_init_aarch64.c |  28 +-
 libavcodec/arm/hevcdsp_init_neon.c        |  78 ++---
 libavcodec/hevcdsp.h                      |  72 ++---
 libavcodec/hevcdsp_template.c             | 240 +++++++--------
 libavcodec/loongarch/hevcdsp_lsx.h        |  30 +-
 libavcodec/mips/hevc_idct_msa.c           |  16 +-
 libavcodec/mips/hevc_lpf_sao_msa.c        | 118 ++++----
 libavcodec/mips/hevc_mc_bi_msa.c          | 336 ++++++++++-----------
 libavcodec/mips/hevc_mc_biw_msa.c         | 338 +++++++++++-----------
 libavcodec/mips/hevc_mc_uni_msa.c         | 168 +++++------
 libavcodec/mips/hevc_mc_uniw_msa.c        | 174 +++++------
 libavcodec/mips/hevcdsp_mips.h            |  54 ++--
 libavcodec/mips/hevcdsp_mmi.c             |  28 +-
 libavcodec/mips/hevcdsp_msa.c             | 166 +++++------
 libavcodec/x86/hevc_add_res.asm           |  12 +-
 libavcodec/x86/hevc_mc.asm                |  14 +-
 libavcodec/x86/hevc_sao.asm               |   2 +-
 libavcodec/x86/hevc_sao_10bit.asm         |   2 +-
 libavcodec/x86/hevcdsp.h                  | 104 +++----
 libavcodec/x86/hevcdsp_init.c             | 111 ++++---
 20 files changed, 1047 insertions(+), 1044 deletions(-)

diff --git a/libavcodec/aarch64/hevcdsp_init_aarch64.c b/libavcodec/aarch64/hevcdsp_init_aarch64.c
index 2002530266..9cbe983870 100644
--- a/libavcodec/aarch64/hevcdsp_init_aarch64.c
+++ b/libavcodec/aarch64/hevcdsp_init_aarch64.c
@@ -25,21 +25,21 @@
 #include "libavutil/aarch64/cpu.h"
 #include "libavcodec/hevcdsp.h"
 
-void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                      ptrdiff_t stride);
-void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                       ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                      ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                       ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                        ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                         ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                        ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                         ptrdiff_t stride);
 void ff_hevc_idct_8x8_8_neon(int16_t *coeffs, int col_limit);
 void ff_hevc_idct_8x8_10_neon(int16_t *coeffs, int col_limit);
@@ -53,14 +53,14 @@ void ff_hevc_idct_4x4_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_8x8_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_16x16_dc_10_neon(int16_t *coeffs);
 void ff_hevc_idct_32x32_dc_10_neon(int16_t *coeffs);
-void ff_hevc_sao_band_filter_8x8_8_neon(uint8_t *_dst, uint8_t *_src,
+void ff_hevc_sao_band_filter_8x8_8_neon(uint8_t *_dst, const uint8_t *_src,
                                   ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                  int16_t *sao_offset_val, int sao_left_class,
+                                  const int16_t *sao_offset_val, int sao_left_class,
                                   int width, int height);
-void ff_hevc_sao_edge_filter_16x16_8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride_dst,
-                                          int16_t *sao_offset_val, int eo, int width, int height);
-void ff_hevc_sao_edge_filter_8x8_8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride_dst,
-                                          int16_t *sao_offset_val, int eo, int width, int height);
+void ff_hevc_sao_edge_filter_16x16_8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst,
+                                          const int16_t *sao_offset_val, int eo, int width, int height);
+void ff_hevc_sao_edge_filter_8x8_8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst,
+                                        const int16_t *sao_offset_val, int eo, int width, int height);
 
 av_cold void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth)
 {
diff --git a/libavcodec/arm/hevcdsp_init_neon.c b/libavcodec/arm/hevcdsp_init_neon.c
index 112edb5edd..8094e6c62e 100644
--- a/libavcodec/arm/hevcdsp_init_neon.c
+++ b/libavcodec/arm/hevcdsp_init_neon.c
@@ -24,32 +24,32 @@
 #include "libavcodec/avcodec.h"
 #include "hevcdsp_arm.h"
 
-void ff_hevc_sao_band_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src,
+void ff_hevc_sao_band_filter_neon_8_wrapper(uint8_t *_dst, const uint8_t *_src,
                                   ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                  int16_t *sao_offset_val, int sao_left_class,
+                                  const int16_t *sao_offset_val, int sao_left_class,
                                   int width, int height);
-void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val,
+void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val,
                                   int eo, int width, int height);
 
-void ff_hevc_v_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
-void ff_hevc_h_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
-void ff_hevc_v_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
-void ff_hevc_h_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, int *_tc, uint8_t *_no_p, uint8_t *_no_q);
-void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_v_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q);
+void ff_hevc_h_loop_filter_luma_neon(uint8_t *_pix, ptrdiff_t _stride, int _beta, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q);
+void ff_hevc_v_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q);
+void ff_hevc_h_loop_filter_chroma_neon(uint8_t *_pix, ptrdiff_t _stride, const int *_tc, const uint8_t *_no_p, const uint8_t *_no_q);
+void ff_hevc_add_residual_4x4_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                      ptrdiff_t stride);
-void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_4x4_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                       ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_8x8_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                      ptrdiff_t stride);
-void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_8x8_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                       ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_16x16_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                        ptrdiff_t stride);
-void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_16x16_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                         ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_32x32_8_neon(uint8_t *_dst, const int16_t *coeffs,
                                        ptrdiff_t stride);
-void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, int16_t *coeffs,
+void ff_hevc_add_residual_32x32_10_neon(uint8_t *_dst, const int16_t *coeffs,
                                         ptrdiff_t stride);
 void ff_hevc_idct_4x4_dc_8_neon(int16_t *coeffs);
 void ff_hevc_idct_8x8_dc_8_neon(int16_t *coeffs);
@@ -70,7 +70,7 @@ void ff_hevc_idct_32x32_10_neon(int16_t *coeffs, int col_limit);
 void ff_hevc_transform_luma_4x4_neon_8(int16_t *coeffs);
 
 #define PUT_PIXELS(name) \
-    void name(int16_t *dst, uint8_t *src, \
+    void name(int16_t *dst, const uint8_t *src, \
                                 ptrdiff_t srcstride, int height, \
                                 intptr_t mx, intptr_t my, int width)
 PUT_PIXELS(ff_hevc_put_pixels_w2_neon_8);
@@ -85,19 +85,19 @@ PUT_PIXELS(ff_hevc_put_pixels_w48_neon_8);
 PUT_PIXELS(ff_hevc_put_pixels_w64_neon_8);
 #undef PUT_PIXELS
 
-static void (*put_hevc_qpel_neon[4][4])(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+static void (*put_hevc_qpel_neon[4][4])(int16_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride,
                                    int height, int width);
-static void (*put_hevc_qpel_uw_neon[4][4])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                   int width, int height, int16_t* src2, ptrdiff_t src2stride);
-void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
+static void (*put_hevc_qpel_uw_neon[4][4])(uint8_t *dst, ptrdiff_t dststride, const uint8_t *_src, ptrdiff_t _srcstride,
+                                   int width, int height, const int16_t *src2, ptrdiff_t src2stride);
+void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride,
                                    int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride,
                                    int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                       int16_t *src2,
+void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride,
+                                      const uint8_t *src, ptrdiff_t srcstride, const int16_t *src2,
                                        int height, intptr_t mx, intptr_t my, int width);
 #define QPEL_FUNC(name) \
-    void name(int16_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, \
+    void name(int16_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride, \
                                    int height, int width)
 
 QPEL_FUNC(ff_hevc_put_qpel_v1_neon_8);
@@ -118,7 +118,7 @@ QPEL_FUNC(ff_hevc_put_qpel_h3v3_neon_8);
 #undef QPEL_FUNC
 
 #define QPEL_FUNC_UW_PIX(name) \
-    void name(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, \
+    void name(uint8_t *dst, ptrdiff_t dststride, const uint8_t *_src, ptrdiff_t _srcstride, \
                                    int height, intptr_t mx, intptr_t my, int width);
 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w4_neon_8);
 QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w8_neon_8);
@@ -130,8 +130,8 @@ QPEL_FUNC_UW_PIX(ff_hevc_put_qpel_uw_pixels_w64_neon_8);
 #undef QPEL_FUNC_UW_PIX
 
 #define QPEL_FUNC_UW(name) \
-    void name(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride, \
-                                   int width, int height, int16_t* src2, ptrdiff_t src2stride);
+    void name(uint8_t *dst, ptrdiff_t dststride, const uint8_t *_src, ptrdiff_t _srcstride, \
+              int width, int height, const int16_t* src2, ptrdiff_t src2stride);
 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_pixels_neon_8);
 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_v1_neon_8);
 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_v2_neon_8);
@@ -150,14 +150,14 @@ QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3v2_neon_8);
 QPEL_FUNC_UW(ff_hevc_put_qpel_uw_h3v3_neon_8);
 #undef QPEL_FUNC_UW
 
-void ff_hevc_sao_band_filter_neon_8(uint8_t *dst, uint8_t *src, ptrdiff_t stride_dst, ptrdiff_t stride_src, int width, int height, int16_t *offset_table);
+void ff_hevc_sao_band_filter_neon_8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, ptrdiff_t stride_src, int width, int height, int16_t *offset_table);
 
-void ff_hevc_sao_band_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src,
+void ff_hevc_sao_band_filter_neon_8_wrapper(uint8_t *_dst, const uint8_t *_src,
                                   ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                  int16_t *sao_offset_val, int sao_left_class,
+                                  const int16_t *sao_offset_val, int sao_left_class,
                                   int width, int height) {
     uint8_t *dst = _dst;
-    uint8_t *src = _src;
+    const uint8_t *src = _src;
     int16_t offset_table[32] = {0};
     int k;
 
@@ -168,10 +168,10 @@ void ff_hevc_sao_band_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src,
     ff_hevc_sao_band_filter_neon_8(dst, src, stride_dst, stride_src, width, height, offset_table);
 }
 
-void ff_hevc_sao_edge_filter_neon_8(uint8_t *dst, uint8_t *src, ptrdiff_t stride_dst, ptrdiff_t stride_src, int width, int height,
-                                    int a_stride, int b_stride, int16_t *sao_offset_val, uint8_t *edge_idx);
+void ff_hevc_sao_edge_filter_neon_8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, ptrdiff_t stride_src, int width, int height,
+                                    int a_stride, int b_stride, const int16_t *sao_offset_val, const uint8_t *edge_idx);
 
-void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val,
+void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val,
                                   int eo, int width, int height) {
     static uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
     static const int8_t pos[4][2][2] = {
@@ -181,7 +181,7 @@ void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src, ptrdif
         { {  1, -1 }, { -1, 1 } }, // 135 degree
     };
     uint8_t *dst = _dst;
-    uint8_t *src = _src;
+    const uint8_t *src = _src;
     int a_stride, b_stride;
     ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
 
@@ -191,20 +191,20 @@ void ff_hevc_sao_edge_filter_neon_8_wrapper(uint8_t *_dst, uint8_t *_src, ptrdif
     ff_hevc_sao_edge_filter_neon_8(dst, src, stride_dst, stride_src, width, height, a_stride, b_stride, sao_offset_val, edge_idx);
 }
 
-void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
+void ff_hevc_put_qpel_neon_wrapper(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride,
                                    int height, intptr_t mx, intptr_t my, int width) {
 
     put_hevc_qpel_neon[my][mx](dst, MAX_PB_SIZE, src, srcstride, height, width);
 }
 
-void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+void ff_hevc_put_qpel_uni_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride,
                                    int height, intptr_t mx, intptr_t my, int width) {
 
     put_hevc_qpel_uw_neon[my][mx](dst, dststride, src, srcstride, width, height, NULL, 0);
 }
 
-void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
-                                       int16_t *src2,
+void ff_hevc_put_qpel_bi_neon_wrapper(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride,
+                                       const int16_t *src2,
                                        int height, intptr_t mx, intptr_t my, int width) {
     put_hevc_qpel_uw_neon[my][mx](dst, dststride, src, srcstride, width, height, src2, MAX_PB_SIZE);
 }
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevcdsp.h
index d642ecf9c6..1b9c5bb6bc 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevcdsp.h
@@ -48,7 +48,7 @@ typedef struct HEVCDSPContext {
     void (*put_pcm)(uint8_t *_dst, ptrdiff_t _stride, int width, int height,
                     struct GetBitContext *gb, int pcm_bit_depth);
 
-    void (*add_residual[4])(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+    void (*add_residual[4])(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
     void (*dequant)(int16_t *coeffs, int16_t log2_size);
 
@@ -60,68 +60,68 @@ typedef struct HEVCDSPContext {
 
     void (*idct_dc[4])(int16_t *coeffs);
 
-    void (*sao_band_filter[5])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
-                               int16_t *sao_offset_val, int sao_left_class, int width, int height);
+    void (*sao_band_filter[5])(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
+                               const int16_t *sao_offset_val, int sao_left_class, int width, int height);
 
     /* implicit stride_src parameter has value of 2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE */
-    void (*sao_edge_filter[5])(uint8_t *_dst /* align 16 */, uint8_t *_src /* align 32 */, ptrdiff_t stride_dst,
-                               int16_t *sao_offset_val, int sao_eo_class, int width, int height);
+    void (*sao_edge_filter[5])(uint8_t *_dst /* align 16 */, const uint8_t *_src /* align 32 */, ptrdiff_t stride_dst,
+                               const int16_t *sao_offset_val, int sao_eo_class, int width, int height);
 
-    void (*sao_edge_restore[2])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
-                                struct SAOParams *sao, int *borders, int _width, int _height, int c_idx,
-                                uint8_t *vert_edge, uint8_t *horiz_edge, uint8_t *diag_edge);
+    void (*sao_edge_restore[2])(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
+                                const struct SAOParams *sao, const int *borders, int _width, int _height, int c_idx,
+                                const uint8_t *vert_edge, const uint8_t *horiz_edge, const uint8_t *diag_edge);
 
-    void (*put_hevc_qpel[10][2][2])(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
+    void (*put_hevc_qpel[10][2][2])(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride,
                                     int height, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_qpel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride,
+    void (*put_hevc_qpel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, ptrdiff_t srcstride,
                                         int height, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_qpel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+    void (*put_hevc_qpel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                           int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
 
-    void (*put_hevc_qpel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+    void (*put_hevc_qpel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                        int height, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_qpel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                         int16_t *src2,
+    void (*put_hevc_qpel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride,
+                                         const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                          int height, int denom, int wx0, int wx1,
                                          int ox0, int ox1, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_epel[10][2][2])(int16_t *dst, uint8_t *src, ptrdiff_t srcstride,
+    void (*put_hevc_epel[10][2][2])(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride,
                                     int height, intptr_t mx, intptr_t my, int width);
 
-    void (*put_hevc_epel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
+    void (*put_hevc_epel_uni[10][2][2])(uint8_t *dst, ptrdiff_t dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                         int height, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_epel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+    void (*put_hevc_epel_uni_w[10][2][2])(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                           int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_epel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+    void (*put_hevc_epel_bi[10][2][2])(uint8_t *dst, ptrdiff_t dststride, const uint8_t *_src, ptrdiff_t _srcstride,
+                                       const int16_t *src2,
                                        int height, intptr_t mx, intptr_t my, int width);
-    void (*put_hevc_epel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                         int16_t *src2,
+    void (*put_hevc_epel_bi_w[10][2][2])(uint8_t *dst, ptrdiff_t dststride,
+                                         const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                          int height, int denom, int wx0, int ox0, int wx1,
                                          int ox1, intptr_t mx, intptr_t my, int width);
 
     void (*hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
-                                    int beta, int32_t *tc,
-                                    uint8_t *no_p, uint8_t *no_q);
+                                    int beta, const int32_t *tc,
+                                    const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
-                                    int beta, int32_t *tc,
-                                    uint8_t *no_p, uint8_t *no_q);
+                                    int beta, const int32_t *tc,
+                                    const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
-                                      int32_t *tc, uint8_t *no_p, uint8_t *no_q);
+                                      const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
-                                      int32_t *tc, uint8_t *no_p, uint8_t *no_q);
+                                      const int32_t *tc, const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_h_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride,
-                                      int beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q);
+                                      int beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_v_loop_filter_luma_c)(uint8_t *pix, ptrdiff_t stride,
-                                      int beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q);
+                                      int beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q);
     void (*hevc_h_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q);
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q);
     void (*hevc_v_loop_filter_chroma_c)(uint8_t *pix, ptrdiff_t stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q);
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q);
 } HEVCDSPContext;
 
 void ff_hevc_dsp_init(HEVCDSPContext *hpc, int bit_depth);
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index 61425975cd..725fab99ed 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -41,7 +41,7 @@ static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height
     }
 }
 
-static av_always_inline void FUNC(add_residual)(uint8_t *_dst, int16_t *res,
+static av_always_inline void FUNC(add_residual)(uint8_t *_dst, const int16_t *res,
                                                 ptrdiff_t stride, int size)
 {
     int x, y;
@@ -58,25 +58,25 @@ static av_always_inline void FUNC(add_residual)(uint8_t *_dst, int16_t *res,
     }
 }
 
-static void FUNC(add_residual4x4)(uint8_t *_dst, int16_t *res,
+static void FUNC(add_residual4x4)(uint8_t *_dst, const int16_t *res,
                                   ptrdiff_t stride)
 {
     FUNC(add_residual)(_dst, res, stride, 4);
 }
 
-static void FUNC(add_residual8x8)(uint8_t *_dst, int16_t *res,
+static void FUNC(add_residual8x8)(uint8_t *_dst, const int16_t *res,
                                   ptrdiff_t stride)
 {
     FUNC(add_residual)(_dst, res, stride, 8);
 }
 
-static void FUNC(add_residual16x16)(uint8_t *_dst, int16_t *res,
+static void FUNC(add_residual16x16)(uint8_t *_dst, const int16_t *res,
                                     ptrdiff_t stride)
 {
     FUNC(add_residual)(_dst, res, stride, 16);
 }
 
-static void FUNC(add_residual32x32)(uint8_t *_dst, int16_t *res,
+static void FUNC(add_residual32x32)(uint8_t *_dst, const int16_t *res,
                                     ptrdiff_t stride)
 {
     FUNC(add_residual)(_dst, res, stride, 32);
@@ -295,13 +295,13 @@ IDCT_DC(32)
 #undef SET
 #undef SCALE
 
-static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
+static void FUNC(sao_band_filter)(uint8_t *_dst, const uint8_t *_src,
                                   ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                  int16_t *sao_offset_val, int sao_left_class,
+                                  const int16_t *sao_offset_val, int sao_left_class,
                                   int width, int height)
 {
     pixel *dst = (pixel *)_dst;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     int offset_table[32] = { 0 };
     int k, y, x;
     int shift  = BIT_DEPTH - 5;
@@ -321,7 +321,7 @@ static void FUNC(sao_band_filter)(uint8_t *_dst, uint8_t *_src,
 
 #define CMP(a, b) (((a) > (b)) - ((a) < (b)))
 
-static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val,
+static void FUNC(sao_edge_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val,
                                   int eo, int width, int height) {
 
     static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
@@ -332,7 +332,7 @@ static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride
         { {  1, -1 }, { -1, 1 } }, // 135 degree
     };
     pixel *dst = (pixel *)_dst;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     int a_stride, b_stride;
     int x, y;
     ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel);
@@ -352,16 +352,16 @@ static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride
     }
 }
 
-static void FUNC(sao_edge_restore_0)(uint8_t *_dst, uint8_t *_src,
-                                    ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
-                                    int *borders, int _width, int _height,
-                                    int c_idx, uint8_t *vert_edge,
-                                    uint8_t *horiz_edge, uint8_t *diag_edge)
+static void FUNC(sao_edge_restore_0)(uint8_t *_dst, const uint8_t *_src,
+                                    ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao,
+                                    const int *borders, int _width, int _height,
+                                    int c_idx, const uint8_t *vert_edge,
+                                    const uint8_t *horiz_edge, const uint8_t *diag_edge)
 {
     int x, y;
     pixel *dst = (pixel *)_dst;
-    pixel *src = (pixel *)_src;
-    int16_t *sao_offset_val = sao->offset_val[c_idx];
+    const pixel *src = (const pixel *)_src;
+    const int16_t *sao_offset_val = sao->offset_val[c_idx];
     int sao_eo_class    = sao->eo_class[c_idx];
     int init_x = 0, width = _width, height = _height;
 
@@ -402,16 +402,16 @@ static void FUNC(sao_edge_restore_0)(uint8_t *_dst, uint8_t *_src,
     }
 }
 
-static void FUNC(sao_edge_restore_1)(uint8_t *_dst, uint8_t *_src,
-                                    ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
-                                    int *borders, int _width, int _height,
-                                    int c_idx, uint8_t *vert_edge,
-                                    uint8_t *horiz_edge, uint8_t *diag_edge)
+static void FUNC(sao_edge_restore_1)(uint8_t *_dst, const uint8_t *_src,
+                                    ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao,
+                                    const int *borders, int _width, int _height,
+                                    int c_idx, const uint8_t *vert_edge,
+                                    const uint8_t *horiz_edge, const uint8_t *diag_edge)
 {
     int x, y;
     pixel *dst = (pixel *)_dst;
-    pixel *src = (pixel *)_src;
-    int16_t *sao_offset_val = sao->offset_val[c_idx];
+    const pixel *src = (const pixel *)_src;
+    const int16_t *sao_offset_val = sao->offset_val[c_idx];
     int sao_eo_class    = sao->eo_class[c_idx];
     int init_x = 0, init_y = 0, width = _width, height = _height;
 
@@ -494,11 +494,11 @@ static void FUNC(sao_edge_restore_1)(uint8_t *_dst, uint8_t *_src,
 //
 ////////////////////////////////////////////////////////////////////////////////
 static void FUNC(put_hevc_pel_pixels)(int16_t *dst,
-                                      uint8_t *_src, ptrdiff_t _srcstride,
+                                      const uint8_t *_src, ptrdiff_t _srcstride,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src          = (pixel *)_src;
+    const pixel *src    = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
 
     for (y = 0; y < height; y++) {
@@ -509,11 +509,11 @@ static void FUNC(put_hevc_pel_pixels)(int16_t *dst,
     }
 }
 
-static void FUNC(put_hevc_pel_uni_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_pel_uni_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                           int height, intptr_t mx, intptr_t my, int width)
 {
     int y;
-    pixel *src          = (pixel *)_src;
+    const pixel *src    = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -525,12 +525,12 @@ static void FUNC(put_hevc_pel_uni_pixels)(uint8_t *_dst, ptrdiff_t _dststride, u
     }
 }
 
-static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                         int16_t *src2,
+static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
+                                         const int16_t *src2,
                                          int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src          = (pixel *)_src;
+    const pixel *src    = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -551,11 +551,11 @@ static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, ui
     }
 }
 
-static void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                             int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src          = (pixel *)_src;
+    const pixel *src    = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -575,13 +575,13 @@ static void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                           int16_t *src2,
+static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
+                                           const int16_t *src2,
                                            int height, int denom, int wx0, int wx1,
                                            int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src          = (pixel *)_src;
+    const pixel *src    = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -615,11 +615,11 @@ static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride,
      filter[7] * src[x + 4 * stride])
 
 static void FUNC(put_hevc_qpel_h)(int16_t *dst,
-                                  uint8_t *_src, ptrdiff_t _srcstride,
+                                  const uint8_t *_src, ptrdiff_t _srcstride,
                                   int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     const int8_t *filter    = ff_hevc_qpel_filters[mx - 1];
     for (y = 0; y < height; y++) {
@@ -631,11 +631,11 @@ static void FUNC(put_hevc_qpel_h)(int16_t *dst,
 }
 
 static void FUNC(put_hevc_qpel_v)(int16_t *dst,
-                                  uint8_t *_src, ptrdiff_t _srcstride,
+                                  const uint8_t *_src, ptrdiff_t _srcstride,
                                   int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     const int8_t *filter    = ff_hevc_qpel_filters[my - 1];
     for (y = 0; y < height; y++)  {
@@ -647,14 +647,14 @@ static void FUNC(put_hevc_qpel_v)(int16_t *dst,
 }
 
 static void FUNC(put_hevc_qpel_hv)(int16_t *dst,
-                                   uint8_t *_src,
+                                   const uint8_t *_src,
                                    ptrdiff_t _srcstride,
                                    int height, intptr_t mx,
                                    intptr_t my, int width)
 {
     int x, y;
     const int8_t *filter;
-    pixel *src = (pixel*)_src;
+    const pixel *src = (const pixel*)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
     int16_t *tmp = tmp_array;
@@ -679,11 +679,11 @@ static void FUNC(put_hevc_qpel_hv)(int16_t *dst,
 }
 
 static void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                      uint8_t *_src, ptrdiff_t _srcstride,
+                                      const uint8_t *_src, ptrdiff_t _srcstride,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -704,12 +704,12 @@ static void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst,  ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                     int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
+                                     const int16_t *src2,
                                      int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -733,11 +733,11 @@ static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_
 }
 
 static void FUNC(put_hevc_qpel_uni_v)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                     uint8_t *_src, ptrdiff_t _srcstride,
+                                      const uint8_t *_src, ptrdiff_t _srcstride,
                                      int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -759,12 +759,12 @@ static void FUNC(put_hevc_qpel_uni_v)(uint8_t *_dst,  ptrdiff_t _dststride,
 }
 
 
-static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                     int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
+                                     const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                      int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -788,12 +788,12 @@ static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_
 }
 
 static void FUNC(put_hevc_qpel_uni_hv)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                       uint8_t *_src, ptrdiff_t _srcstride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride,
                                        int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
     const int8_t *filter;
-    pixel *src = (pixel*)_src;
+    const pixel *src = (const pixel*)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -827,13 +827,13 @@ static void FUNC(put_hevc_qpel_uni_hv)(uint8_t *_dst,  ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                      int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+                                      const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
     const int8_t *filter;
-    pixel *src = (pixel*)_src;
+    const pixel *src = (const pixel*)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -868,12 +868,12 @@ static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8
 }
 
 static void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                        uint8_t *_src, ptrdiff_t _srcstride,
+                                        const uint8_t *_src, ptrdiff_t _srcstride,
                                         int height, int denom, int wx, int ox,
                                         intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -894,13 +894,13 @@ static void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst,  ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                        int height, int denom, int wx0, int wx1,
                                        int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -923,12 +923,12 @@ static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint
 }
 
 static void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                        uint8_t *_src, ptrdiff_t _srcstride,
+                                        const uint8_t *_src, ptrdiff_t _srcstride,
                                         int height, int denom, int wx, int ox,
                                         intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -949,13 +949,13 @@ static void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst,  ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                        int height, int denom, int wx0, int wx1,
                                        int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel        *src       = (pixel*)_src;
+    const pixel  *src       = (const pixel*)_src;
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -978,13 +978,13 @@ static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint
 }
 
 static void FUNC(put_hevc_qpel_uni_w_hv)(uint8_t *_dst,  ptrdiff_t _dststride,
-                                         uint8_t *_src, ptrdiff_t _srcstride,
+                                         const uint8_t *_src, ptrdiff_t _srcstride,
                                          int height, int denom, int wx, int ox,
                                          intptr_t mx, intptr_t my, int width)
 {
     int x, y;
     const int8_t *filter;
-    pixel *src = (pixel*)_src;
+    const pixel *src = (const pixel*)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1018,14 +1018,14 @@ static void FUNC(put_hevc_qpel_uni_w_hv)(uint8_t *_dst,  ptrdiff_t _dststride,
     }
 }
 
-static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                        int16_t *src2,
+static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+                                        const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                         int height, int denom, int wx0, int wx1,
                                         int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
     const int8_t *filter;
-    pixel *src = (pixel*)_src;
+    const pixel *src = (const pixel*)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1068,11 +1068,11 @@ static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uin
      filter[3] * src[x + 2 * stride])
 
 static void FUNC(put_hevc_epel_h)(int16_t *dst,
-                                  uint8_t *_src, ptrdiff_t _srcstride,
+                                  const uint8_t *_src, ptrdiff_t _srcstride,
                                   int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     const int8_t *filter = ff_hevc_epel_filters[mx - 1];
     for (y = 0; y < height; y++) {
@@ -1084,11 +1084,11 @@ static void FUNC(put_hevc_epel_h)(int16_t *dst,
 }
 
 static void FUNC(put_hevc_epel_v)(int16_t *dst,
-                                  uint8_t *_src, ptrdiff_t _srcstride,
+                                  const uint8_t *_src, ptrdiff_t _srcstride,
                                   int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     const int8_t *filter = ff_hevc_epel_filters[my - 1];
 
@@ -1101,11 +1101,11 @@ static void FUNC(put_hevc_epel_v)(int16_t *dst,
 }
 
 static void FUNC(put_hevc_epel_hv)(int16_t *dst,
-                                   uint8_t *_src, ptrdiff_t _srcstride,
+                                   const uint8_t *_src, ptrdiff_t _srcstride,
                                    int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     const int8_t *filter = ff_hevc_epel_filters[mx - 1];
     int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
@@ -1131,11 +1131,11 @@ static void FUNC(put_hevc_epel_hv)(int16_t *dst,
     }
 }
 
-static void FUNC(put_hevc_epel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1155,12 +1155,12 @@ static void FUNC(put_hevc_epel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8
     }
 }
 
-static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                     int16_t *src2,
+static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride,
+                                     const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                      int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1182,11 +1182,11 @@ static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_
     }
 }
 
-static void FUNC(put_hevc_epel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1206,12 +1206,12 @@ static void FUNC(put_hevc_epel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8
     }
 }
 
-static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                     int16_t *src2,
+static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
+                                     const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                      int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     const int8_t *filter = ff_hevc_epel_filters[my - 1];
     pixel *dst          = (pixel *)_dst;
@@ -1232,11 +1232,11 @@ static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_
     }
 }
 
-static void FUNC(put_hevc_epel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                        int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1270,12 +1270,12 @@ static void FUNC(put_hevc_epel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint
     }
 }
 
-static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                      int16_t *src2,
+static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+                                      const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                       int height, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1310,11 +1310,11 @@ static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8
     }
 }
 
-static void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                         int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1336,13 +1336,13 @@ static void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uin
     }
 }
 
-static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                        int height, int denom, int wx0, int wx1,
                                        int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1362,11 +1362,11 @@ static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint
     }
 }
 
-static void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                         int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1388,13 +1388,13 @@ static void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uin
     }
 }
 
-static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                       int16_t *src2,
+static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
+                                       const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                        int height, int denom, int wx0, int wx1,
                                        int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride  = _srcstride / sizeof(pixel);
     const int8_t *filter = ff_hevc_epel_filters[my - 1];
     pixel *dst          = (pixel *)_dst;
@@ -1414,11 +1414,11 @@ static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint
     }
 }
 
-static void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
+static void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
                                          int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1453,13 +1453,13 @@ static void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, ui
     }
 }
 
-static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride,
-                                        int16_t *src2,
+static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
+                                        const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
                                         int height, int denom, int wx0, int wx1,
                                         int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 {
     int x, y;
-    pixel *src = (pixel *)_src;
+    const pixel *src = (const pixel *)_src;
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);
     pixel *dst          = (pixel *)_dst;
     ptrdiff_t dststride = _dststride / sizeof(pixel);
@@ -1515,8 +1515,8 @@ static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, uin
 
 static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
                                         ptrdiff_t _xstride, ptrdiff_t _ystride,
-                                        int beta, int *_tc,
-                                        uint8_t *_no_p, uint8_t *_no_q)
+                                        int beta, const int *_tc,
+                                        const uint8_t *_no_p, const uint8_t *_no_q)
 {
     int d, j;
     pixel *pix        = (pixel *)_pix;
@@ -1610,8 +1610,8 @@ static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
 }
 
 static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
-                                          ptrdiff_t _ystride, int *_tc,
-                                          uint8_t *_no_p, uint8_t *_no_q)
+                                          ptrdiff_t _ystride, const int *_tc,
+                                          const uint8_t *_no_p, const uint8_t *_no_q)
 {
     int d, j, no_p, no_q;
     pixel *pix        = (pixel *)_pix;
@@ -1644,30 +1644,30 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
 }
 
 static void FUNC(hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
-                                            int32_t *tc, uint8_t *no_p,
-                                            uint8_t *no_q)
+                                            const int32_t *tc, const uint8_t *no_p,
+                                            const uint8_t *no_q)
 {
     FUNC(hevc_loop_filter_chroma)(pix, stride, sizeof(pixel), tc, no_p, no_q);
 }
 
 static void FUNC(hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
-                                            int32_t *tc, uint8_t *no_p,
-                                            uint8_t *no_q)
+                                            const int32_t *tc, const uint8_t *no_p,
+                                            const uint8_t *no_q)
 {
     FUNC(hevc_loop_filter_chroma)(pix, sizeof(pixel), stride, tc, no_p, no_q);
 }
 
 static void FUNC(hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
-                                          int beta, int32_t *tc, uint8_t *no_p,
-                                          uint8_t *no_q)
+                                          int beta, const int32_t *tc, const uint8_t *no_p,
+                                          const uint8_t *no_q)
 {
     FUNC(hevc_loop_filter_luma)(pix, stride, sizeof(pixel),
                                 beta, tc, no_p, no_q);
 }
 
 static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
-                                          int beta, int32_t *tc, uint8_t *no_p,
-                                          uint8_t *no_q)
+                                          int beta, const int32_t *tc, const uint8_t *no_p,
+                                          const uint8_t *no_q)
 {
     FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
                                 beta, tc, no_p, no_q);
diff --git a/libavcodec/loongarch/hevcdsp_lsx.h b/libavcodec/loongarch/hevcdsp_lsx.h
index 0c517af887..0d54196caf 100644
--- a/libavcodec/loongarch/hevcdsp_lsx.h
+++ b/libavcodec/loongarch/hevcdsp_lsx.h
@@ -27,7 +27,7 @@
 
 #define MC(PEL, DIR, WIDTH)                                               \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_lsx(int16_t *dst,          \
-                                                   uint8_t *src,          \
+                                                   const uint8_t *src,    \
                                                    ptrdiff_t src_stride,  \
                                                    int height,            \
                                                    intptr_t mx,           \
@@ -88,9 +88,9 @@ MC(epel, hv, 32);
 #define BI_MC(PEL, DIR, WIDTH)                                               \
 void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,          \
                                                       ptrdiff_t dst_stride,  \
-                                                      uint8_t *src,          \
+                                                      const uint8_t *src,    \
                                                       ptrdiff_t src_stride,  \
-                                                      int16_t *src_16bit,    \
+                                                      const int16_t *src_16bit, \
                                                       int height,            \
                                                       intptr_t mx,           \
                                                       intptr_t my,           \
@@ -145,7 +145,7 @@ BI_MC(epel, hv, 32);
 #define UNI_MC(PEL, DIR, WIDTH)                                              \
 void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,         \
                                                        ptrdiff_t dst_stride, \
-                                                       uint8_t *src,         \
+                                                       const uint8_t *src,   \
                                                        ptrdiff_t src_stride, \
                                                        int height,           \
                                                        intptr_t mx,          \
@@ -181,7 +181,7 @@ UNI_MC(epel, hv, 32);
 void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,  \
                                                          ptrdiff_t      \
                                                          dst_stride,    \
-                                                         uint8_t *src,  \
+                                                         const uint8_t *src,  \
                                                          ptrdiff_t      \
                                                          src_stride,    \
                                                          int height,    \
@@ -202,24 +202,24 @@ UNI_W_MC(qpel, hv, 64);
 #undef UNI_W_MC
 
 void ff_hevc_loop_filter_luma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *p_is_pcm, uint8_t *q_is_pcm);
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *p_is_pcm, const uint8_t *q_is_pcm);
 
 void ff_hevc_loop_filter_luma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *p_is_pcm, uint8_t *q_is_pcm);
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *p_is_pcm, const uint8_t *q_is_pcm);
 
 void ff_hevc_loop_filter_chroma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
-                                        int32_t *tc, uint8_t *p_is_pcm,
-                                        uint8_t *q_is_pcm);
+                                        const int32_t *tc, const uint8_t *p_is_pcm,
+                                        const uint8_t *q_is_pcm);
 
 void ff_hevc_loop_filter_chroma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
-                                        int32_t *tc, uint8_t *p_is_pcm,
-                                        uint8_t *q_is_pcm);
+                                        const int32_t *tc, const uint8_t *p_is_pcm,
+                                        const uint8_t *q_is_pcm);
 
-void ff_hevc_sao_edge_filter_8_lsx(uint8_t *dst, uint8_t *src,
+void ff_hevc_sao_edge_filter_8_lsx(uint8_t *dst, const uint8_t *src,
                                    ptrdiff_t stride_dst,
-                                   int16_t *sao_offset_val,
+                                   const int16_t *sao_offset_val,
                                    int eo, int width, int height);
 
 void ff_hevc_idct_4x4_lsx(int16_t *coeffs, int col_limit);
diff --git a/libavcodec/mips/hevc_idct_msa.c b/libavcodec/mips/hevc_idct_msa.c
index 5ab6acd1df..5f34fd8fa7 100644
--- a/libavcodec/mips/hevc_idct_msa.c
+++ b/libavcodec/mips/hevc_idct_msa.c
@@ -713,7 +713,7 @@ static void hevc_idct_dc_32x32_msa(int16_t *coeffs)
     }
 }
 
-static void hevc_addblk_4x4_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
+static void hevc_addblk_4x4_msa(const int16_t *coeffs, uint8_t *dst, int32_t stride)
 {
     uint32_t dst0, dst1, dst2, dst3;
     v8i16 dst_r0, dst_l0, in0, in1;
@@ -730,7 +730,7 @@ static void hevc_addblk_4x4_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
     ST_W4(dst_vec, 0, 1, 2, 3, dst, stride);
 }
 
-static void hevc_addblk_8x8_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
+static void hevc_addblk_8x8_msa(const int16_t *coeffs, uint8_t *dst, int32_t stride)
 {
     uint8_t *temp_dst = dst;
     uint64_t dst0, dst1, dst2, dst3;
@@ -766,7 +766,7 @@ static void hevc_addblk_8x8_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
     ST_D4(dst_r0, dst_r1, 0, 1, 0, 1, dst + 4 * stride, stride);
 }
 
-static void hevc_addblk_16x16_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
+static void hevc_addblk_16x16_msa(const int16_t *coeffs, uint8_t *dst, int32_t stride)
 {
     uint8_t loop_cnt;
     uint8_t *temp_dst = dst;
@@ -833,7 +833,7 @@ static void hevc_addblk_16x16_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
     ST_UB4(dst0, dst1, dst2, dst3, dst, stride);
 }
 
-static void hevc_addblk_32x32_msa(int16_t *coeffs, uint8_t *dst, int32_t stride)
+static void hevc_addblk_32x32_msa(const int16_t *coeffs, uint8_t *dst, int32_t stride)
 {
     uint8_t loop_cnt;
     uint8_t *temp_dst = dst;
@@ -980,22 +980,22 @@ void ff_hevc_idct_32x32_msa(int16_t *coeffs, int col_limit)
     hevc_idct_32x32_msa(coeffs);
 }
 
-void ff_hevc_addblk_4x4_msa(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
+void ff_hevc_addblk_4x4_msa(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
 {
     hevc_addblk_4x4_msa(coeffs, dst, stride);
 }
 
-void ff_hevc_addblk_8x8_msa(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
+void ff_hevc_addblk_8x8_msa(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
 {
     hevc_addblk_8x8_msa(coeffs, dst, stride);
 }
 
-void ff_hevc_addblk_16x16_msa(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
+void ff_hevc_addblk_16x16_msa(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
 {
     hevc_addblk_16x16_msa(coeffs, dst, stride);
 }
 
-void ff_hevc_addblk_32x32_msa(uint8_t *dst, int16_t *coeffs, ptrdiff_t stride)
+void ff_hevc_addblk_32x32_msa(uint8_t *dst, const int16_t *coeffs, ptrdiff_t stride)
 {
     hevc_addblk_32x32_msa(coeffs, dst, stride);
 }
diff --git a/libavcodec/mips/hevc_lpf_sao_msa.c b/libavcodec/mips/hevc_lpf_sao_msa.c
index 26663dd89b..cd94460f97 100644
--- a/libavcodec/mips/hevc_lpf_sao_msa.c
+++ b/libavcodec/mips/hevc_lpf_sao_msa.c
@@ -22,8 +22,8 @@
 #include "libavcodec/mips/hevcdsp_mips.h"
 
 static void hevc_loopfilter_luma_hor_msa(uint8_t *src, int32_t stride,
-                                         int32_t beta, int32_t *tc,
-                                         uint8_t *p_is_pcm, uint8_t *q_is_pcm)
+                                         int32_t beta, const int32_t *tc,
+                                         const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
 {
     uint8_t *p3 = src - (stride << 2);
     uint8_t *p2 = src - ((stride << 1) + stride);
@@ -448,8 +448,8 @@ static void hevc_loopfilter_luma_hor_msa(uint8_t *src, int32_t stride,
 }
 
 static void hevc_loopfilter_luma_ver_msa(uint8_t *src, int32_t stride,
-                                         int32_t beta, int32_t *tc,
-                                         uint8_t *p_is_pcm, uint8_t *q_is_pcm)
+                                         int32_t beta, const int32_t *tc,
+                                         const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
 {
     uint8_t *p3 = src;
     uint8_t *p2 = src + 3 * stride;
@@ -914,8 +914,8 @@ static void hevc_loopfilter_luma_ver_msa(uint8_t *src, int32_t stride,
 }
 
 static void hevc_loopfilter_chroma_hor_msa(uint8_t *src, int32_t stride,
-                                           int32_t *tc, uint8_t *p_is_pcm,
-                                           uint8_t *q_is_pcm)
+                                           const int32_t *tc, const uint8_t *p_is_pcm,
+                                           const uint8_t *q_is_pcm)
 {
     uint8_t *p1_ptr = src - (stride << 1);
     uint8_t *p0_ptr = src - stride;
@@ -977,8 +977,8 @@ static void hevc_loopfilter_chroma_hor_msa(uint8_t *src, int32_t stride,
 }
 
 static void hevc_loopfilter_chroma_ver_msa(uint8_t *src, int32_t stride,
-                                           int32_t *tc, uint8_t *p_is_pcm,
-                                           uint8_t *q_is_pcm)
+                                           const int32_t *tc, const uint8_t *p_is_pcm,
+                                           const uint8_t *q_is_pcm)
 {
     v2i64 cmp0, cmp1, p_is_pcm_vec, q_is_pcm_vec;
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
@@ -1038,9 +1038,9 @@ static void hevc_loopfilter_chroma_ver_msa(uint8_t *src, int32_t stride,
 }
 
 static void hevc_sao_band_filter_4width_msa(uint8_t *dst, int32_t dst_stride,
-                                            uint8_t *src, int32_t src_stride,
+                                            const uint8_t *src, int32_t src_stride,
                                             int32_t sao_left_class,
-                                            int16_t *sao_offset_val,
+                                            const int16_t *sao_offset_val,
                                             int32_t height)
 {
     v16u8 src0, src1, src2, src3;
@@ -1100,9 +1100,9 @@ static void hevc_sao_band_filter_4width_msa(uint8_t *dst, int32_t dst_stride,
 }
 
 static void hevc_sao_band_filter_8width_msa(uint8_t *dst, int32_t dst_stride,
-                                            uint8_t *src, int32_t src_stride,
+                                            const uint8_t *src, int32_t src_stride,
                                             int32_t sao_left_class,
-                                            int16_t *sao_offset_val,
+                                            const int16_t *sao_offset_val,
                                             int32_t height)
 {
     v16u8 src0, src1, src2, src3;
@@ -1172,10 +1172,10 @@ static void hevc_sao_band_filter_8width_msa(uint8_t *dst, int32_t dst_stride,
 
 static void hevc_sao_band_filter_16multiple_msa(uint8_t *dst,
                                                 int32_t dst_stride,
-                                                uint8_t *src,
+                                                const uint8_t *src,
                                                 int32_t src_stride,
                                                 int32_t sao_left_class,
-                                                int16_t *sao_offset_val,
+                                                const int16_t *sao_offset_val,
                                                 int32_t width, int32_t height)
 {
     int32_t w_cnt;
@@ -1254,9 +1254,9 @@ static void hevc_sao_band_filter_16multiple_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_0degree_4width_msa(uint8_t *dst,
                                                     int32_t dst_stride,
-                                                    uint8_t *src,
+                                                    const uint8_t *src,
                                                     int32_t src_stride,
-                                                    int16_t *sao_offset_val,
+                                                    const int16_t *sao_offset_val,
                                                     int32_t height)
 {
     uint32_t dst_val0, dst_val1;
@@ -1346,9 +1346,9 @@ static void hevc_sao_edge_filter_0degree_4width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_0degree_8width_msa(uint8_t *dst,
                                                     int32_t dst_stride,
-                                                    uint8_t *src,
+                                                    const uint8_t *src,
                                                     int32_t src_stride,
-                                                    int16_t *sao_offset_val,
+                                                    const int16_t *sao_offset_val,
                                                     int32_t height)
 {
     uint64_t dst_val0, dst_val1;
@@ -1440,13 +1440,14 @@ static void hevc_sao_edge_filter_0degree_8width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_0degree_16multiple_msa(uint8_t *dst,
                                                         int32_t dst_stride,
-                                                        uint8_t *src,
+                                                        const uint8_t *src,
                                                         int32_t src_stride,
-                                                        int16_t *sao_offset_val,
+                                                        const int16_t *sao_offset_val,
                                                         int32_t width,
                                                         int32_t height)
 {
-    uint8_t *dst_ptr, *src_minus1;
+    const uint8_t *src_minus1;
+    uint8_t *dst_ptr;
     int32_t v_cnt;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -1556,9 +1557,9 @@ static void hevc_sao_edge_filter_0degree_16multiple_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst,
                                                      int32_t dst_stride,
-                                                     uint8_t *src,
+                                                     const uint8_t *src,
                                                      int32_t src_stride,
-                                                     int16_t *sao_offset_val,
+                                                     const int16_t *sao_offset_val,
                                                      int32_t height)
 {
     uint32_t dst_val0, dst_val1;
@@ -1661,9 +1662,9 @@ static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst,
                                                      int32_t dst_stride,
-                                                     uint8_t *src,
+                                                     const uint8_t *src,
                                                      int32_t src_stride,
-                                                     int16_t *sao_offset_val,
+                                                     const int16_t *sao_offset_val,
                                                      int32_t height)
 {
     uint64_t dst_val0, dst_val1;
@@ -1763,14 +1764,14 @@ static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst,
                                                          int32_t dst_stride,
-                                                         uint8_t *src,
+                                                         const uint8_t *src,
                                                          int32_t src_stride,
-                                                         int16_t *
+                                                         const int16_t *
                                                          sao_offset_val,
                                                          int32_t width,
                                                          int32_t height)
 {
-    uint8_t *src_orig = src;
+    const uint8_t *src_orig = src;
     uint8_t *dst_orig = dst;
     int32_t h_cnt, v_cnt;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -1865,12 +1866,12 @@ static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_45degree_4width_msa(uint8_t *dst,
                                                      int32_t dst_stride,
-                                                     uint8_t *src,
+                                                     const uint8_t *src,
                                                      int32_t src_stride,
-                                                     int16_t *sao_offset_val,
+                                                     const int16_t *sao_offset_val,
                                                      int32_t height)
 {
-    uint8_t *src_orig;
+    const uint8_t *src_orig;
     uint32_t dst_val0, dst_val1;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -1978,12 +1979,12 @@ static void hevc_sao_edge_filter_45degree_4width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_45degree_8width_msa(uint8_t *dst,
                                                      int32_t dst_stride,
-                                                     uint8_t *src,
+                                                     const uint8_t *src,
                                                      int32_t src_stride,
-                                                     int16_t *sao_offset_val,
+                                                     const int16_t *sao_offset_val,
                                                      int32_t height)
 {
-    uint8_t *src_orig;
+    const uint8_t *src_orig;
     uint64_t dst_val0, dst_val1;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -2094,14 +2095,14 @@ static void hevc_sao_edge_filter_45degree_8width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_45degree_16multiple_msa(uint8_t *dst,
                                                          int32_t dst_stride,
-                                                         uint8_t *src,
+                                                         const uint8_t *src,
                                                          int32_t src_stride,
-                                                         int16_t *
+                                                         const int16_t *
                                                          sao_offset_val,
                                                          int32_t width,
                                                          int32_t height)
 {
-    uint8_t *src_orig = src;
+    const uint8_t *src_orig = src;
     uint8_t *dst_orig = dst;
     int32_t v_cnt;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -2214,12 +2215,12 @@ static void hevc_sao_edge_filter_45degree_16multiple_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_135degree_4width_msa(uint8_t *dst,
                                                       int32_t dst_stride,
-                                                      uint8_t *src,
+                                                      const uint8_t *src,
                                                       int32_t src_stride,
-                                                      int16_t *sao_offset_val,
+                                                      const int16_t *sao_offset_val,
                                                       int32_t height)
 {
-    uint8_t *src_orig;
+    const uint8_t *src_orig;
     uint32_t dst_val0, dst_val1;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -2329,12 +2330,12 @@ static void hevc_sao_edge_filter_135degree_4width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_135degree_8width_msa(uint8_t *dst,
                                                       int32_t dst_stride,
-                                                      uint8_t *src,
+                                                      const uint8_t *src,
                                                       int32_t src_stride,
-                                                      int16_t *sao_offset_val,
+                                                      const int16_t *sao_offset_val,
                                                       int32_t height)
 {
-    uint8_t *src_orig;
+    const uint8_t *src_orig;
     uint64_t dst_val0, dst_val1;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -2441,14 +2442,15 @@ static void hevc_sao_edge_filter_135degree_8width_msa(uint8_t *dst,
 
 static void hevc_sao_edge_filter_135degree_16multiple_msa(uint8_t *dst,
                                                           int32_t dst_stride,
-                                                          uint8_t *src,
+                                                          const uint8_t *src,
                                                           int32_t src_stride,
-                                                          int16_t *
+                                                          const int16_t *
                                                           sao_offset_val,
                                                           int32_t width,
                                                           int32_t height)
 {
-    uint8_t *src_orig, *dst_orig;
+    const uint8_t *src_orig;
+    uint8_t *dst_orig;
     int32_t v_cnt;
     v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
     v16u8 const1 = (v16u8) __msa_ldi_b(1);
@@ -2563,39 +2565,39 @@ static void hevc_sao_edge_filter_135degree_16multiple_msa(uint8_t *dst,
 
 void ff_hevc_loop_filter_luma_h_8_msa(uint8_t *src,
                                       ptrdiff_t src_stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q)
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q)
 {
     hevc_loopfilter_luma_hor_msa(src, src_stride, beta, tc, no_p, no_q);
 }
 
 void ff_hevc_loop_filter_luma_v_8_msa(uint8_t *src,
                                       ptrdiff_t src_stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q)
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q)
 {
     hevc_loopfilter_luma_ver_msa(src, src_stride, beta, tc, no_p, no_q);
 }
 
 void ff_hevc_loop_filter_chroma_h_8_msa(uint8_t *src,
                                         ptrdiff_t src_stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q)
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q)
 {
     hevc_loopfilter_chroma_hor_msa(src, src_stride, tc, no_p, no_q);
 }
 
 void ff_hevc_loop_filter_chroma_v_8_msa(uint8_t *src,
                                         ptrdiff_t src_stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q)
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q)
 {
     hevc_loopfilter_chroma_ver_msa(src, src_stride, tc, no_p, no_q);
 }
 
-void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, uint8_t *src,
+void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, const uint8_t *src,
                                      ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                     int16_t *sao_offset_val, int sao_left_class,
+                                     const int16_t *sao_offset_val, int sao_left_class,
                                      int width, int height)
 {
     if (width >> 4) {
@@ -2621,9 +2623,9 @@ void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src,
+void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, const uint8_t *src,
                                    ptrdiff_t stride_dst,
-                                   int16_t *sao_offset_val,
+                                   const int16_t *sao_offset_val,
                                    int eo, int width, int height)
 {
     ptrdiff_t stride_src = (2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(uint8_t);
diff --git a/libavcodec/mips/hevc_mc_bi_msa.c b/libavcodec/mips/hevc_mc_bi_msa.c
index c6c8d2705d..701e12ab86 100644
--- a/libavcodec/mips/hevc_mc_bi_msa.c
+++ b/libavcodec/mips/hevc_mc_bi_msa.c
@@ -58,9 +58,9 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = {
     HEVC_BI_RND_CLIP2_MAX_SATU(in2, in3, vec2, vec3, rnd_val, out2, out3);  \
 }
 
-static void hevc_bi_copy_4w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_4w_msa(const uint8_t *src0_ptr,
                                 int32_t src_stride,
-                                int16_t *src1_ptr,
+                                const int16_t *src1_ptr,
                                 int32_t src2_stride,
                                 uint8_t *dst,
                                 int32_t dst_stride,
@@ -126,9 +126,9 @@ static void hevc_bi_copy_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_6w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_6w_msa(const uint8_t *src0_ptr,
                                 int32_t src_stride,
-                                int16_t *src1_ptr,
+                                const int16_t *src1_ptr,
                                 int32_t src2_stride,
                                 uint8_t *dst,
                                 int32_t dst_stride,
@@ -178,9 +178,9 @@ static void hevc_bi_copy_6w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_8w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_8w_msa(const uint8_t *src0_ptr,
                                 int32_t src_stride,
-                                int16_t *src1_ptr,
+                                const int16_t *src1_ptr,
                                 int32_t src2_stride,
                                 uint8_t *dst,
                                 int32_t dst_stride,
@@ -266,9 +266,9 @@ static void hevc_bi_copy_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_12w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_12w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -305,9 +305,9 @@ static void hevc_bi_copy_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_16w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_16w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -343,9 +343,9 @@ static void hevc_bi_copy_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_24w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_24w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -389,9 +389,9 @@ static void hevc_bi_copy_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_32w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_32w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -433,9 +433,9 @@ static void hevc_bi_copy_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_48w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_48w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -487,9 +487,9 @@ static void hevc_bi_copy_48w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_bi_copy_64w_msa(uint8_t *src0_ptr,
+static void hevc_bi_copy_64w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -526,9 +526,9 @@ static void hevc_bi_copy_64w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -599,9 +599,9 @@ static void hevc_hz_bi_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -667,9 +667,9 @@ static void hevc_hz_bi_8t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -755,9 +755,9 @@ static void hevc_hz_bi_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -826,9 +826,9 @@ static void hevc_hz_bi_8t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -898,9 +898,9 @@ static void hevc_hz_bi_8t_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -970,9 +970,9 @@ static void hevc_hz_bi_8t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_48w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1062,9 +1062,9 @@ static void hevc_hz_bi_8t_48w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_8t_64w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1172,9 +1172,9 @@ static void hevc_hz_bi_8t_64w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -1258,9 +1258,9 @@ static void hevc_vt_bi_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -1336,9 +1336,9 @@ static void hevc_vt_bi_8t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1443,17 +1443,17 @@ static void hevc_vt_bi_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_8t_16multx2mult_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_16multx2mult_msa(const uint8_t *src0_ptr,
                                            int32_t src_stride,
-                                           int16_t *src1_ptr,
+                                           const int16_t *src1_ptr,
                                            int32_t src2_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
                                            const int8_t *filter,
                                            int32_t height, int32_t width)
 {
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     uint32_t loop_cnt;
     uint32_t cnt;
@@ -1549,9 +1549,9 @@ static void hevc_vt_bi_8t_16multx2mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1562,9 +1562,9 @@ static void hevc_vt_bi_8t_16w_msa(uint8_t *src0_ptr,
                                    dst, dst_stride, filter, height, 16);
 }
 
-static void hevc_vt_bi_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1577,9 +1577,9 @@ static void hevc_vt_bi_8t_24w_msa(uint8_t *src0_ptr,
                          dst + 16, dst_stride, filter, height);
 }
 
-static void hevc_vt_bi_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1590,9 +1590,9 @@ static void hevc_vt_bi_8t_32w_msa(uint8_t *src0_ptr,
                                    dst, dst_stride, filter, height, 32);
 }
 
-static void hevc_vt_bi_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_48w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1603,9 +1603,9 @@ static void hevc_vt_bi_8t_48w_msa(uint8_t *src0_ptr,
                                    dst, dst_stride, filter, height, 48);
 }
 
-static void hevc_vt_bi_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_8t_64w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1616,9 +1616,9 @@ static void hevc_vt_bi_8t_64w_msa(uint8_t *src0_ptr,
                                    dst, dst_stride, filter, height, 64);
 }
 
-static void hevc_hv_bi_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -1741,9 +1741,9 @@ static void hevc_hv_bi_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_8t_8multx1mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_8multx1mult_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -1753,8 +1753,8 @@ static void hevc_hv_bi_8t_8multx1mult_msa(uint8_t *src0_ptr,
 {
     uint32_t loop_cnt;
     uint32_t cnt;
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     v16u8 out;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
@@ -1874,9 +1874,9 @@ static void hevc_hv_bi_8t_8multx1mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -1889,9 +1889,9 @@ static void hevc_hv_bi_8t_8w_msa(uint8_t *src0_ptr,
                                   height, 8);
 }
 
-static void hevc_hv_bi_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1900,8 +1900,9 @@ static void hevc_hv_bi_8t_12w_msa(uint8_t *src0_ptr,
                                   int32_t height)
 {
     uint32_t loop_cnt;
-    uint8_t *src0_ptr_tmp, *dst_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    uint8_t *dst_tmp;
+    const int16_t *src1_ptr_tmp;
     uint64_t tp0, tp1;
     v16u8 out;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
@@ -2103,9 +2104,9 @@ static void hevc_hv_bi_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2118,9 +2119,9 @@ static void hevc_hv_bi_8t_16w_msa(uint8_t *src0_ptr,
                                   height, 16);
 }
 
-static void hevc_hv_bi_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2133,9 +2134,9 @@ static void hevc_hv_bi_8t_24w_msa(uint8_t *src0_ptr,
                                   height, 24);
 }
 
-static void hevc_hv_bi_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2148,9 +2149,9 @@ static void hevc_hv_bi_8t_32w_msa(uint8_t *src0_ptr,
                                   height, 32);
 }
 
-static void hevc_hv_bi_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_48w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2163,9 +2164,9 @@ static void hevc_hv_bi_8t_48w_msa(uint8_t *src0_ptr,
                                   height, 48);
 }
 
-static void hevc_hv_bi_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_8t_64w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2178,9 +2179,9 @@ static void hevc_hv_bi_8t_64w_msa(uint8_t *src0_ptr,
                                   height, 64);
 }
 
-static void hevc_hz_bi_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_4x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2221,9 +2222,9 @@ static void hevc_hz_bi_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(dst0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_bi_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_4x4_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2267,9 +2268,9 @@ static void hevc_hz_bi_4t_4x4_msa(uint8_t *src0_ptr,
     ST_W4(dst0, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hz_bi_4t_4x8multiple_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_4x8multiple_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -2330,9 +2331,9 @@ static void hevc_hz_bi_4t_4x8multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -2352,9 +2353,9 @@ static void hevc_hz_bi_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_6w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -2413,9 +2414,9 @@ static void hevc_hz_bi_4t_6w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_8x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2456,9 +2457,9 @@ static void hevc_hz_bi_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(dst0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_bi_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_8x6_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2520,9 +2521,9 @@ static void hevc_hz_bi_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(dst2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hz_bi_4t_8x4multiple_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_8x4multiple_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -2578,9 +2579,9 @@ static void hevc_hz_bi_4t_8x4multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -2600,9 +2601,9 @@ static void hevc_hz_bi_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2674,9 +2675,9 @@ static void hevc_hz_bi_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2734,16 +2735,16 @@ static void hevc_hz_bi_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
                                   const int8_t *filter,
                                   int32_t height)
 {
-    int16_t *src1_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     uint32_t loop_cnt;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
@@ -2840,9 +2841,9 @@ static void hevc_hz_bi_4t_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_bi_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hz_bi_4t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2901,9 +2902,9 @@ static void hevc_hz_bi_4t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_4x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2949,9 +2950,9 @@ static void hevc_vt_bi_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(dst10, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_bi_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_4x4_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -2998,9 +2999,9 @@ static void hevc_vt_bi_4t_4x4_msa(uint8_t *src0_ptr,
     ST_W4(dst10, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_vt_bi_4t_4x8multiple_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_4x8multiple_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -3071,9 +3072,9 @@ static void hevc_vt_bi_4t_4x8multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -3093,9 +3094,9 @@ static void hevc_vt_bi_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_6w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -3191,9 +3192,9 @@ static void hevc_vt_bi_4t_6w_msa(uint8_t *src0_ptr,
     dst += (4 * dst_stride);
 }
 
-static void hevc_vt_bi_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_8x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3235,9 +3236,9 @@ static void hevc_vt_bi_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(dst0_r, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_bi_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_8x6_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3295,9 +3296,9 @@ static void hevc_vt_bi_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(dst2_r, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_vt_bi_4t_8x4multiple_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_8x4multiple_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -3357,9 +3358,9 @@ static void hevc_vt_bi_4t_8x4multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -3379,9 +3380,9 @@ static void hevc_vt_bi_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3462,9 +3463,9 @@ static void hevc_vt_bi_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3547,9 +3548,9 @@ static void hevc_vt_bi_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3671,9 +3672,9 @@ static void hevc_vt_bi_4t_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_bi_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_vt_bi_4t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3781,9 +3782,9 @@ static void hevc_vt_bi_4t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_4x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3848,9 +3849,9 @@ static void hevc_hv_bi_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_bi_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_4x4_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3924,9 +3925,9 @@ static void hevc_hv_bi_4t_4x4_msa(uint8_t *src0_ptr,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hv_bi_4t_4multx8mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_4multx8mult_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -4043,9 +4044,9 @@ static void hevc_hv_bi_4t_4multx8mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_4w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -4067,9 +4068,9 @@ static void hevc_hv_bi_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_6w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -4217,9 +4218,9 @@ static void hevc_hv_bi_4t_6w_msa(uint8_t *src0_ptr,
     ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride);
 }
 
-static void hevc_hv_bi_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_8x2_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4291,9 +4292,9 @@ static void hevc_hv_bi_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_bi_4t_8multx4_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_8multx4_msa(const uint8_t *src0_ptr,
                                       int32_t src_stride,
-                                      int16_t *src1_ptr,
+                                      const int16_t *src1_ptr,
                                       int32_t src2_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4387,9 +4388,9 @@ static void hevc_hv_bi_4t_8multx4_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_8x6_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4503,9 +4504,9 @@ static void hevc_hv_bi_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hv_bi_4t_8multx4mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_8multx4mult_msa(const uint8_t *src0_ptr,
                                           int32_t src_stride,
-                                          int16_t *src1_ptr,
+                                          const int16_t *src1_ptr,
                                           int32_t src2_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -4515,8 +4516,8 @@ static void hevc_hv_bi_4t_8multx4mult_msa(uint8_t *src0_ptr,
                                           int32_t width)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6;
@@ -4628,9 +4629,9 @@ static void hevc_hv_bi_4t_8multx4mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_8w_msa(const uint8_t *src0_ptr,
                                  int32_t src_stride,
-                                 int16_t *src1_ptr,
+                                 const int16_t *src1_ptr,
                                  int32_t src2_stride,
                                  uint8_t *dst,
                                  int32_t dst_stride,
@@ -4655,9 +4656,9 @@ static void hevc_hv_bi_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_12w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4667,8 +4668,9 @@ static void hevc_hv_bi_4t_12w_msa(uint8_t *src0_ptr,
 {
     uint32_t loop_cnt;
     uint64_t tp0, tp1;
-    uint8_t *src0_ptr_tmp, *dst_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    uint8_t *dst_tmp;
+    const int16_t *src1_ptr_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
@@ -4857,9 +4859,9 @@ static void hevc_hv_bi_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_16w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4877,9 +4879,9 @@ static void hevc_hv_bi_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_bi_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_24w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4892,9 +4894,9 @@ static void hevc_hv_bi_4t_24w_msa(uint8_t *src0_ptr,
                                   height, 24);
 }
 
-static void hevc_hv_bi_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hv_bi_4t_32w_msa(const uint8_t *src0_ptr,
                                   int32_t src_stride,
-                                  int16_t *src1_ptr,
+                                  const int16_t *src1_ptr,
                                   int32_t src2_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -4910,9 +4912,9 @@ static void hevc_hv_bi_4t_32w_msa(uint8_t *src0_ptr,
 #define BI_MC_COPY(WIDTH)                                                 \
 void ff_hevc_put_hevc_bi_pel_pixels##WIDTH##_8_msa(uint8_t *dst,          \
                                                    ptrdiff_t dst_stride,  \
-                                                   uint8_t *src,          \
+                                                   const uint8_t *src,    \
                                                    ptrdiff_t src_stride,  \
-                                                   int16_t *src_16bit,    \
+                                                   const int16_t *src_16bit, \
                                                    int height,            \
                                                    intptr_t mx,           \
                                                    intptr_t my,           \
@@ -4937,9 +4939,9 @@ BI_MC_COPY(64);
 #define BI_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR)                          \
 void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,          \
                                                       ptrdiff_t dst_stride,  \
-                                                      uint8_t *src,          \
+                                                      const uint8_t *src,    \
                                                       ptrdiff_t src_stride,  \
-                                                      int16_t *src_16bit,    \
+                                                      const int16_t *src_16bit, \
                                                       int height,            \
                                                       intptr_t mx,           \
                                                       intptr_t my,           \
@@ -4991,9 +4993,9 @@ BI_MC(epel, v, 32, 4, vt, my);
 #define BI_MC_HV(PEL, WIDTH, TAP)                                         \
 void ff_hevc_put_hevc_bi_##PEL##_hv##WIDTH##_8_msa(uint8_t *dst,          \
                                                    ptrdiff_t dst_stride,  \
-                                                   uint8_t *src,          \
+                                                   const uint8_t *src,    \
                                                    ptrdiff_t src_stride,  \
-                                                   int16_t *src_16bit,    \
+                                                   const int16_t *src_16bit, \
                                                    int height,            \
                                                    intptr_t mx,           \
                                                    intptr_t my,           \
diff --git a/libavcodec/mips/hevc_mc_biw_msa.c b/libavcodec/mips/hevc_mc_biw_msa.c
index f775ea8592..981c37d7e8 100644
--- a/libavcodec/mips/hevc_mc_biw_msa.c
+++ b/libavcodec/mips/hevc_mc_biw_msa.c
@@ -79,9 +79,9 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = {
                                 out2, out3);                               \
 }
 
-static void hevc_biwgt_copy_4w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_4w_msa(const uint8_t *src0_ptr,
                                    int32_t src_stride,
-                                   int16_t *src1_ptr,
+                                   const int16_t *src1_ptr,
                                    int32_t src2_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -168,9 +168,9 @@ static void hevc_biwgt_copy_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_6w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_6w_msa(const uint8_t *src0_ptr,
                                    int32_t src_stride,
-                                   int16_t *src1_ptr,
+                                   const int16_t *src1_ptr,
                                    int32_t src2_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -222,9 +222,9 @@ static void hevc_biwgt_copy_6w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_8w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_8w_msa(const uint8_t *src0_ptr,
                                    int32_t src_stride,
-                                   int16_t *src1_ptr,
+                                   const int16_t *src1_ptr,
                                    int32_t src2_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -310,9 +310,9 @@ static void hevc_biwgt_copy_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_12w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_12w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -369,9 +369,9 @@ static void hevc_biwgt_copy_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_16w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_16w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -424,9 +424,9 @@ static void hevc_biwgt_copy_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_24w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_24w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -488,9 +488,9 @@ static void hevc_biwgt_copy_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_32w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_32w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -549,9 +549,9 @@ static void hevc_biwgt_copy_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_48w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_48w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -601,9 +601,9 @@ static void hevc_biwgt_copy_48w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_biwgt_copy_64w_msa(uint8_t *src0_ptr,
+static void hevc_biwgt_copy_64w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -656,9 +656,9 @@ static void hevc_biwgt_copy_64w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -728,9 +728,9 @@ static void hevc_hz_biwgt_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -808,9 +808,9 @@ static void hevc_hz_biwgt_8t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -903,9 +903,9 @@ static void hevc_hz_biwgt_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -987,9 +987,9 @@ static void hevc_hz_biwgt_8t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1109,9 +1109,9 @@ static void hevc_hz_biwgt_8t_24w_msa(uint8_t *src0_ptr,
     dst += dst_stride;
 }
 
-static void hevc_hz_biwgt_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1195,9 +1195,9 @@ static void hevc_hz_biwgt_8t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_48w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1299,9 +1299,9 @@ static void hevc_hz_biwgt_8t_48w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_8t_64w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1313,9 +1313,9 @@ static void hevc_hz_biwgt_8t_64w_msa(uint8_t *src0_ptr,
                                      int32_t offset1,
                                      int32_t rnd_val)
 {
-    uint8_t *src0_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
     uint8_t *dst_tmp;
-    int16_t *src1_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint32_t loop_cnt, cnt;
     int32_t offset, weight, constant;
     v16i8 src0, src1, src2;
@@ -1398,9 +1398,9 @@ static void hevc_hz_biwgt_8t_64w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -1496,9 +1496,9 @@ static void hevc_vt_biwgt_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -1584,9 +1584,9 @@ static void hevc_vt_biwgt_8t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1694,9 +1694,9 @@ static void hevc_vt_biwgt_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_8t_16multx2mult_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_16multx2mult_msa(const uint8_t *src0_ptr,
                                               int32_t src_stride,
-                                              int16_t *src1_ptr,
+                                              const int16_t *src1_ptr,
                                               int32_t src2_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -1709,8 +1709,8 @@ static void hevc_vt_biwgt_8t_16multx2mult_msa(uint8_t *src0_ptr,
                                               int32_t rnd_val,
                                               int32_t width)
 {
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     uint32_t loop_cnt, cnt;
     int32_t offset, weight;
@@ -1810,9 +1810,9 @@ static void hevc_vt_biwgt_8t_16multx2mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1831,9 +1831,9 @@ static void hevc_vt_biwgt_8t_16w_msa(uint8_t *src0_ptr,
                                       rnd_val, 16);
 }
 
-static void hevc_vt_biwgt_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1856,9 +1856,9 @@ static void hevc_vt_biwgt_8t_24w_msa(uint8_t *src0_ptr,
                             weight0, weight1, offset0, offset1, rnd_val);
 }
 
-static void hevc_vt_biwgt_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1877,9 +1877,9 @@ static void hevc_vt_biwgt_8t_32w_msa(uint8_t *src0_ptr,
                                       rnd_val, 32);
 }
 
-static void hevc_vt_biwgt_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_48w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1898,9 +1898,9 @@ static void hevc_vt_biwgt_8t_48w_msa(uint8_t *src0_ptr,
                                       rnd_val, 48);
 }
 
-static void hevc_vt_biwgt_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_8t_64w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1919,9 +1919,9 @@ static void hevc_vt_biwgt_8t_64w_msa(uint8_t *src0_ptr,
                                       rnd_val, 64);
 }
 
-static void hevc_hv_biwgt_8t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -2064,9 +2064,9 @@ static void hevc_hv_biwgt_8t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_8t_8multx2mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_8multx2mult_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -2082,8 +2082,8 @@ static void hevc_hv_biwgt_8t_8multx2mult_msa(uint8_t *src0_ptr,
 {
     uint32_t loop_cnt, cnt;
     int32_t offset, weight;
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     v16u8 out;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
@@ -2247,9 +2247,9 @@ static void hevc_hv_biwgt_8t_8multx2mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_8t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -2269,9 +2269,9 @@ static void hevc_hv_biwgt_8t_8w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 1);
 }
 
-static void hevc_hv_biwgt_8t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2285,8 +2285,9 @@ static void hevc_hv_biwgt_8t_12w_msa(uint8_t *src0_ptr,
                                      int32_t rnd_val)
 {
     uint32_t loop_cnt;
-    uint8_t *src0_ptr_tmp, *dst_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    uint8_t *dst_tmp;
+    const int16_t *src1_ptr_tmp;
     int32_t offset, weight;
     uint64_t tp0, tp1;
     v16u8 out;
@@ -2519,9 +2520,9 @@ static void hevc_hv_biwgt_8t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_8t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2541,9 +2542,9 @@ static void hevc_hv_biwgt_8t_16w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 2);
 }
 
-static void hevc_hv_biwgt_8t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2563,9 +2564,9 @@ static void hevc_hv_biwgt_8t_24w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 3);
 }
 
-static void hevc_hv_biwgt_8t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2585,9 +2586,9 @@ static void hevc_hv_biwgt_8t_32w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 4);
 }
 
-static void hevc_hv_biwgt_8t_48w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_48w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2607,9 +2608,9 @@ static void hevc_hv_biwgt_8t_48w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 6);
 }
 
-static void hevc_hv_biwgt_8t_64w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_8t_64w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2629,9 +2630,9 @@ static void hevc_hv_biwgt_8t_64w_msa(uint8_t *src0_ptr,
                                      offset1, rnd_val, 8);
 }
 
-static void hevc_hz_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_4x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2689,9 +2690,9 @@ static void hevc_hz_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(out0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_4x4_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2749,9 +2750,9 @@ static void hevc_hz_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
     ST_W4(dst0, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hz_biwgt_4t_4x8multiple_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_4x8multiple_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -2824,9 +2825,9 @@ static void hevc_hz_biwgt_4t_4x8multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -2855,9 +2856,9 @@ static void hevc_hz_biwgt_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_6w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -2929,9 +2930,9 @@ static void hevc_hz_biwgt_4t_6w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_8x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2985,9 +2986,9 @@ static void hevc_hz_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(dst0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_8x6_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3059,9 +3060,9 @@ static void hevc_hz_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(dst3, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hz_biwgt_4t_8x4multiple_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_8x4multiple_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -3129,9 +3130,9 @@ static void hevc_hz_biwgt_4t_8x4multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -3160,9 +3161,9 @@ static void hevc_hz_biwgt_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3246,9 +3247,9 @@ static void hevc_hz_biwgt_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3335,9 +3336,9 @@ static void hevc_hz_biwgt_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3422,9 +3423,9 @@ static void hevc_hz_biwgt_4t_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hz_biwgt_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hz_biwgt_4t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3495,9 +3496,9 @@ static void hevc_hz_biwgt_4t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_4x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3560,9 +3561,9 @@ static void hevc_vt_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_4x4_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3627,9 +3628,9 @@ static void hevc_vt_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
     dst += (4 * dst_stride);
 }
 
-static void hevc_vt_biwgt_4t_4x8multiple_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_4x8multiple_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -3713,9 +3714,9 @@ static void hevc_vt_biwgt_4t_4x8multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -3744,9 +3745,9 @@ static void hevc_vt_biwgt_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_6w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -3821,9 +3822,9 @@ static void hevc_vt_biwgt_4t_6w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_8x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3878,9 +3879,9 @@ static void hevc_vt_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(tmp0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_8x6_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3949,9 +3950,9 @@ static void hevc_vt_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(tmp3, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_vt_biwgt_4t_8x4multiple_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_8x4multiple_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -4023,9 +4024,9 @@ static void hevc_vt_biwgt_4t_8x4multiple_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -4054,9 +4055,9 @@ static void hevc_vt_biwgt_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4146,9 +4147,9 @@ static void hevc_vt_biwgt_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4240,9 +4241,9 @@ static void hevc_vt_biwgt_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4377,9 +4378,9 @@ static void hevc_vt_biwgt_4t_24w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_vt_biwgt_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_vt_biwgt_4t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4496,9 +4497,9 @@ static void hevc_vt_biwgt_4t_32w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_4x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4580,9 +4581,9 @@ static void hevc_hv_biwgt_4t_4x2_msa(uint8_t *src0_ptr,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_4x4_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4677,9 +4678,9 @@ static void hevc_hv_biwgt_4t_4x4_msa(uint8_t *src0_ptr,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hv_biwgt_4t_4multx8mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_4multx8mult_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -4821,9 +4822,9 @@ static void hevc_hv_biwgt_4t_4multx8mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_4w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_4w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -4853,9 +4854,9 @@ static void hevc_hv_biwgt_4t_4w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_6w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_6w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -5035,9 +5036,9 @@ static void hevc_hv_biwgt_4t_6w_msa(uint8_t *src0_ptr,
     ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride);
 }
 
-static void hevc_hv_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_8x2_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5131,9 +5132,9 @@ static void hevc_hv_biwgt_4t_8x2_msa(uint8_t *src0_ptr,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_biwgt_4t_8multx4_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_8multx4_msa(const uint8_t *src0_ptr,
                                          int32_t src_stride,
-                                         int16_t *src1_ptr,
+                                         const int16_t *src1_ptr,
                                          int32_t src2_stride,
                                          uint8_t *dst,
                                          int32_t dst_stride,
@@ -5255,9 +5256,9 @@ static void hevc_hv_biwgt_4t_8multx4_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_8x6_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5405,9 +5406,9 @@ static void hevc_hv_biwgt_4t_8x6_msa(uint8_t *src0_ptr,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hv_biwgt_4t_8multx4mult_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_8multx4mult_msa(const uint8_t *src0_ptr,
                                              int32_t src_stride,
-                                             int16_t *src1_ptr,
+                                             const int16_t *src1_ptr,
                                              int32_t src2_stride,
                                              uint8_t *dst,
                                              int32_t dst_stride,
@@ -5424,8 +5425,8 @@ static void hevc_hv_biwgt_4t_8multx4mult_msa(uint8_t *src0_ptr,
     uint32_t loop_cnt;
     uint32_t cnt;
     int32_t offset, weight;
-    uint8_t *src0_ptr_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
     uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6;
@@ -5555,9 +5556,9 @@ static void hevc_hv_biwgt_4t_8multx4mult_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_8w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_8w_msa(const uint8_t *src0_ptr,
                                     int32_t src_stride,
-                                    int16_t *src1_ptr,
+                                    const int16_t *src1_ptr,
                                     int32_t src2_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -5592,9 +5593,9 @@ static void hevc_hv_biwgt_4t_8w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_12w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_12w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5610,8 +5611,9 @@ static void hevc_hv_biwgt_4t_12w_msa(uint8_t *src0_ptr,
     uint32_t loop_cnt;
     uint64_t tp0, tp1;
     int32_t offset, weight;
-    uint8_t *src0_ptr_tmp, *dst_tmp;
-    int16_t *src1_ptr_tmp;
+    const uint8_t *src0_ptr_tmp;
+    const int16_t *src1_ptr_tmp;
+    uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
@@ -5831,9 +5833,9 @@ static void hevc_hv_biwgt_4t_12w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_16w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_16w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5859,9 +5861,9 @@ static void hevc_hv_biwgt_4t_16w_msa(uint8_t *src0_ptr,
     }
 }
 
-static void hevc_hv_biwgt_4t_24w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_24w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5881,9 +5883,9 @@ static void hevc_hv_biwgt_4t_24w_msa(uint8_t *src0_ptr,
                                      weight1, offset0, offset1, rnd_val, 24);
 }
 
-static void hevc_hv_biwgt_4t_32w_msa(uint8_t *src0_ptr,
+static void hevc_hv_biwgt_4t_32w_msa(const uint8_t *src0_ptr,
                                      int32_t src_stride,
-                                     int16_t *src1_ptr,
+                                     const int16_t *src1_ptr,
                                      int32_t src2_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5906,9 +5908,9 @@ static void hevc_hv_biwgt_4t_32w_msa(uint8_t *src0_ptr,
 #define BI_W_MC_COPY(WIDTH)                                                  \
 void ff_hevc_put_hevc_bi_w_pel_pixels##WIDTH##_8_msa(uint8_t *dst,           \
                                                      ptrdiff_t dst_stride,   \
-                                                     uint8_t *src,           \
+                                                     const uint8_t *src,     \
                                                      ptrdiff_t src_stride,   \
-                                                     int16_t *src_16bit,     \
+                                                     const int16_t *src_16bit, \
                                                      int height,             \
                                                      int denom,              \
                                                      int weight0,            \
@@ -5944,10 +5946,10 @@ BI_W_MC_COPY(64);
 void ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,         \
                                                         ptrdiff_t             \
                                                         dst_stride,           \
-                                                        uint8_t *src,         \
+                                                        const uint8_t *src,   \
                                                         ptrdiff_t             \
                                                         src_stride,           \
-                                                        int16_t *src_16bit,   \
+                                                        const int16_t *src_16bit, \
                                                         int height,           \
                                                         int denom,            \
                                                         int weight0,          \
@@ -6007,9 +6009,9 @@ BI_W_MC(epel, v, 32, 4, vt, my);
 #define BI_W_MC_HV(PEL, WIDTH, TAP)                                         \
 void ff_hevc_put_hevc_bi_w_##PEL##_hv##WIDTH##_8_msa(uint8_t *dst,          \
                                                      ptrdiff_t dst_stride,  \
-                                                     uint8_t *src,          \
+                                                     const uint8_t *src,    \
                                                      ptrdiff_t src_stride,  \
-                                                     int16_t *src_16bit,    \
+                                                     const int16_t *src_16bit, \
                                                      int height,            \
                                                      int denom,             \
                                                      int weight0,           \
diff --git a/libavcodec/mips/hevc_mc_uni_msa.c b/libavcodec/mips/hevc_mc_uni_msa.c
index 36e65527af..c0571e1231 100644
--- a/libavcodec/mips/hevc_mc_uni_msa.c
+++ b/libavcodec/mips/hevc_mc_uni_msa.c
@@ -101,7 +101,7 @@ static const uint8_t ff_hevc_mask_arr[16 * 3] __attribute__((aligned(0x40))) = {
                  out0, out1, out2, out3);                                     \
 }
 
-static void copy_width8_msa(uint8_t *src, int32_t src_stride,
+static void copy_width8_msa(const uint8_t *src, int32_t src_stride,
                             uint8_t *dst, int32_t dst_stride,
                             int32_t height)
 {
@@ -143,7 +143,7 @@ static void copy_width8_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void copy_width12_msa(uint8_t *src, int32_t src_stride,
+static void copy_width12_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -157,7 +157,7 @@ static void copy_width12_msa(uint8_t *src, int32_t src_stride,
     ST12x8_UB(src0, src1, src2, src3, src4, src5, src6, src7, dst, dst_stride);
 }
 
-static void copy_width16_msa(uint8_t *src, int32_t src_stride,
+static void copy_width16_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -193,7 +193,7 @@ static void copy_width16_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void copy_width24_msa(uint8_t *src, int32_t src_stride,
+static void copy_width24_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -216,7 +216,7 @@ static void copy_width24_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void copy_width32_msa(uint8_t *src, int32_t src_stride,
+static void copy_width32_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -233,7 +233,7 @@ static void copy_width32_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void copy_width48_msa(uint8_t *src, int32_t src_stride,
+static void copy_width48_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -254,7 +254,7 @@ static void copy_width48_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void copy_width64_msa(uint8_t *src, int32_t src_stride,
+static void copy_width64_msa(const uint8_t *src, int32_t src_stride,
                              uint8_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -283,7 +283,7 @@ static void copy_width64_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_4x4_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_4x4_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -312,7 +312,7 @@ static void common_hz_8t_4x4_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void common_hz_8t_4x8_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_4x8_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -349,7 +349,7 @@ static void common_hz_8t_4x8_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
 }
 
-static void common_hz_8t_4x16_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_4x16_msa(const uint8_t *src, int32_t src_stride,
                                   uint8_t *dst, int32_t dst_stride,
                                   const int8_t *filter)
 {
@@ -405,7 +405,7 @@ static void common_hz_8t_4x16_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
 }
 
-static void common_hz_8t_4w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_4w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -418,7 +418,7 @@ static void common_hz_8t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_8w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_8w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -470,7 +470,7 @@ static void common_hz_8t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_12w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_12w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -549,7 +549,7 @@ static void common_hz_8t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_16w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_16w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -607,7 +607,7 @@ static void common_hz_8t_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_24w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_24w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -677,7 +677,7 @@ static void common_hz_8t_24w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_32w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_32w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -738,7 +738,7 @@ static void common_hz_8t_32w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_48w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_48w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -824,7 +824,7 @@ static void common_hz_8t_48w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_8t_64w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_8t_64w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -903,7 +903,7 @@ static void common_hz_8t_64w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_4w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -972,7 +972,7 @@ static void common_vt_8t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_8w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -1027,7 +1027,7 @@ static void common_vt_8t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_12w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_12w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1129,7 +1129,7 @@ static void common_vt_8t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_16w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_16w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1208,12 +1208,12 @@ static void common_vt_8t_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_16w_mult_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_16w_mult_msa(const uint8_t *src, int32_t src_stride,
                                       uint8_t *dst, int32_t dst_stride,
                                       const int8_t *filter, int32_t height,
                                       int32_t width)
 {
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     uint32_t loop_cnt, cnt;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
@@ -1297,7 +1297,7 @@ static void common_vt_8t_16w_mult_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_8t_24w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_24w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1308,7 +1308,7 @@ static void common_vt_8t_24w_msa(uint8_t *src, int32_t src_stride,
                         height);
 }
 
-static void common_vt_8t_32w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_32w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1316,7 +1316,7 @@ static void common_vt_8t_32w_msa(uint8_t *src, int32_t src_stride,
                               32);
 }
 
-static void common_vt_8t_48w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_48w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1324,7 +1324,7 @@ static void common_vt_8t_48w_msa(uint8_t *src, int32_t src_stride,
                               48);
 }
 
-static void common_vt_8t_64w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_8t_64w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -1332,7 +1332,7 @@ static void common_vt_8t_64w_msa(uint8_t *src, int32_t src_stride,
                               64);
 }
 
-static void hevc_hv_uni_8t_4w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_4w_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1466,7 +1466,7 @@ static void hevc_hv_uni_8t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_8t_8multx2mult_msa(uint8_t *src,
+static void hevc_hv_uni_8t_8multx2mult_msa(const uint8_t *src,
                                            int32_t src_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
@@ -1475,7 +1475,7 @@ static void hevc_hv_uni_8t_8multx2mult_msa(uint8_t *src,
                                            int32_t height, int32_t width)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     v16u8 out;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
@@ -1605,7 +1605,7 @@ static void hevc_hv_uni_8t_8multx2mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_8t_8w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_8w_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -1617,7 +1617,7 @@ static void hevc_hv_uni_8t_8w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 8);
 }
 
-static void hevc_hv_uni_8t_12w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_12w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1626,7 +1626,8 @@ static void hevc_hv_uni_8t_12w_msa(uint8_t *src,
                                    int32_t height)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp, *dst_tmp;
+    const uint8_t *src_tmp;
+    uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 src11, src12, src13, src14;
@@ -1851,7 +1852,7 @@ static void hevc_hv_uni_8t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_8t_16w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_16w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1863,7 +1864,7 @@ static void hevc_hv_uni_8t_16w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 16);
 }
 
-static void hevc_hv_uni_8t_24w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_24w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1875,7 +1876,7 @@ static void hevc_hv_uni_8t_24w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 24);
 }
 
-static void hevc_hv_uni_8t_32w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_32w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1887,7 +1888,7 @@ static void hevc_hv_uni_8t_32w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 32);
 }
 
-static void hevc_hv_uni_8t_48w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_48w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1899,7 +1900,7 @@ static void hevc_hv_uni_8t_48w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 48);
 }
 
-static void hevc_hv_uni_8t_64w_msa(uint8_t *src,
+static void hevc_hv_uni_8t_64w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -1911,7 +1912,7 @@ static void hevc_hv_uni_8t_64w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 64);
 }
 
-static void common_hz_4t_4x2_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_4x2_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -1938,7 +1939,7 @@ static void common_hz_4t_4x2_msa(uint8_t *src, int32_t src_stride,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_4x4_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -1965,7 +1966,7 @@ static void common_hz_4t_4x4_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_4x8_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -2000,7 +2001,7 @@ static void common_hz_4t_4x8_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
 }
 
-static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_4x16_msa(const uint8_t *src, int32_t src_stride,
                                   uint8_t *dst, int32_t dst_stride,
                                   const int8_t *filter)
 {
@@ -2048,7 +2049,7 @@ static void common_hz_4t_4x16_msa(uint8_t *src, int32_t src_stride,
     ST_W4(out, 0, 1, 2, 3, dst + 4 * dst_stride, dst_stride);
 }
 
-static void common_hz_4t_4w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_4w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2063,7 +2064,7 @@ static void common_hz_4t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_6w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_6w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2112,7 +2113,7 @@ static void common_hz_4t_6w_msa(uint8_t *src, int32_t src_stride,
     ST_H2(out5, 2, 6, dst + 2 * dst_stride + 4, dst_stride);
 }
 
-static void common_hz_4t_8x2mult_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_8x2mult_msa(const uint8_t *src, int32_t src_stride,
                                      uint8_t *dst, int32_t dst_stride,
                                      const int8_t *filter, int32_t height)
 {
@@ -2146,7 +2147,7 @@ static void common_hz_4t_8x2mult_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_8x4mult_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_8x4mult_msa(const uint8_t *src, int32_t src_stride,
                                      uint8_t *dst, int32_t dst_stride,
                                      const int8_t *filter, int32_t height)
 {
@@ -2180,7 +2181,7 @@ static void common_hz_4t_8x4mult_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_8w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_8w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2193,7 +2194,7 @@ static void common_hz_4t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_12w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_12w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2247,7 +2248,7 @@ static void common_hz_4t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_16w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_16w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2310,7 +2311,7 @@ static void common_hz_4t_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_24w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_24w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2393,7 +2394,7 @@ static void common_hz_4t_24w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_hz_4t_32w_msa(uint8_t *src, int32_t src_stride,
+static void common_hz_4t_32w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2461,7 +2462,7 @@ static void common_hz_4t_32w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_4x2_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_4x2_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -2492,7 +2493,7 @@ static void common_vt_4t_4x2_msa(uint8_t *src, int32_t src_stride,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void common_vt_4t_4x4multiple_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_4x4multiple_msa(const uint8_t *src, int32_t src_stride,
                                          uint8_t *dst, int32_t dst_stride,
                                          const int8_t *filter, int32_t height)
 {
@@ -2538,7 +2539,7 @@ static void common_vt_4t_4x4multiple_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_4w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_4w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2550,7 +2551,7 @@ static void common_vt_4t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_6w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_6w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2621,7 +2622,7 @@ static void common_vt_4t_6w_msa(uint8_t *src, int32_t src_stride,
     ST_H2(out1, 2, 6, dst + 2 * dst_stride + 4, dst_stride);
 }
 
-static void common_vt_4t_8x2_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_8x2_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -2647,7 +2648,7 @@ static void common_vt_4t_8x2_msa(uint8_t *src, int32_t src_stride,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void common_vt_4t_8x6_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_8x6_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter)
 {
@@ -2700,7 +2701,7 @@ static void common_vt_4t_8x6_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_8x4mult_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_8x4mult_msa(const uint8_t *src, int32_t src_stride,
                                      uint8_t *dst, int32_t dst_stride,
                                      const int8_t *filter, int32_t height)
 {
@@ -2745,7 +2746,7 @@ static void common_vt_4t_8x4mult_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_8w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_8w_msa(const uint8_t *src, int32_t src_stride,
                                 uint8_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2759,7 +2760,7 @@ static void common_vt_4t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_12w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_12w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2822,7 +2823,7 @@ static void common_vt_4t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_16w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_16w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2880,7 +2881,7 @@ static void common_vt_4t_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_24w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_24w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -2991,7 +2992,7 @@ static void common_vt_4t_24w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void common_vt_4t_32w_msa(uint8_t *src, int32_t src_stride,
+static void common_vt_4t_32w_msa(const uint8_t *src, int32_t src_stride,
                                  uint8_t *dst, int32_t dst_stride,
                                  const int8_t *filter, int32_t height)
 {
@@ -3084,7 +3085,7 @@ static void common_vt_4t_32w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hv_uni_4t_4x2_msa(uint8_t *src,
+static void hevc_hv_uni_4t_4x2_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -3139,7 +3140,7 @@ static void hevc_hv_uni_4t_4x2_msa(uint8_t *src,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_uni_4t_4x4_msa(uint8_t *src,
+static void hevc_hv_uni_4t_4x4_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -3198,7 +3199,7 @@ static void hevc_hv_uni_4t_4x4_msa(uint8_t *src,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hv_uni_4t_4multx8mult_msa(uint8_t *src,
+static void hevc_hv_uni_4t_4multx8mult_msa(const uint8_t *src,
                                            int32_t src_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
@@ -3296,7 +3297,7 @@ static void hevc_hv_uni_4t_4multx8mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_4w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_4w_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3316,7 +3317,7 @@ static void hevc_hv_uni_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_6w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_6w_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3435,7 +3436,7 @@ static void hevc_hv_uni_4t_6w_msa(uint8_t *src,
     ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride);
 }
 
-static void hevc_hv_uni_4t_8x2_msa(uint8_t *src,
+static void hevc_hv_uni_4t_8x2_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -3497,7 +3498,7 @@ static void hevc_hv_uni_4t_8x2_msa(uint8_t *src,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_uni_4t_8multx4_msa(uint8_t *src,
+static void hevc_hv_uni_4t_8multx4_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        uint8_t *dst,
                                        int32_t dst_stride,
@@ -3582,7 +3583,7 @@ static void hevc_hv_uni_4t_8multx4_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_8x6_msa(uint8_t *src,
+static void hevc_hv_uni_4t_8x6_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -3685,7 +3686,7 @@ static void hevc_hv_uni_4t_8x6_msa(uint8_t *src,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hv_uni_4t_8multx4mult_msa(uint8_t *src,
+static void hevc_hv_uni_4t_8multx4mult_msa(const uint8_t *src,
                                            int32_t src_stride,
                                            uint8_t *dst,
                                            int32_t dst_stride,
@@ -3695,7 +3696,7 @@ static void hevc_hv_uni_4t_8multx4mult_msa(uint8_t *src,
                                            int32_t width8mult)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6;
@@ -3799,7 +3800,7 @@ static void hevc_hv_uni_4t_8multx4mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_8w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_8w_msa(const uint8_t *src,
                                   int32_t src_stride,
                                   uint8_t *dst,
                                   int32_t dst_stride,
@@ -3822,7 +3823,7 @@ static void hevc_hv_uni_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_12w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_12w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -3831,7 +3832,8 @@ static void hevc_hv_uni_4t_12w_msa(uint8_t *src,
                                    int32_t height)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp, *dst_tmp;
+    const uint8_t *src_tmp;
+    uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
@@ -3990,7 +3992,7 @@ static void hevc_hv_uni_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_16w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_16w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -4007,7 +4009,7 @@ static void hevc_hv_uni_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uni_4t_24w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_24w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -4019,7 +4021,7 @@ static void hevc_hv_uni_4t_24w_msa(uint8_t *src,
                                    filter_x, filter_y, height, 3);
 }
 
-static void hevc_hv_uni_4t_32w_msa(uint8_t *src,
+static void hevc_hv_uni_4t_32w_msa(const uint8_t *src,
                                    int32_t src_stride,
                                    uint8_t *dst,
                                    int32_t dst_stride,
@@ -4034,7 +4036,7 @@ static void hevc_hv_uni_4t_32w_msa(uint8_t *src,
 #define UNI_MC_COPY(WIDTH)                                                 \
 void ff_hevc_put_hevc_uni_pel_pixels##WIDTH##_8_msa(uint8_t *dst,          \
                                                     ptrdiff_t dst_stride,  \
-                                                    uint8_t *src,          \
+                                                    const uint8_t *src,    \
                                                     ptrdiff_t src_stride,  \
                                                     int height,            \
                                                     intptr_t mx,           \
@@ -4057,7 +4059,7 @@ UNI_MC_COPY(64);
 #define UNI_MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR)                           \
 void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,           \
                                                        ptrdiff_t dst_stride,   \
-                                                       uint8_t *src,           \
+                                                       const uint8_t *src,     \
                                                        ptrdiff_t src_stride,   \
                                                        int height,             \
                                                        intptr_t mx,            \
@@ -4109,7 +4111,7 @@ UNI_MC(epel, v, 32, 4, vt, my);
 #define UNI_MC_HV(PEL, WIDTH, TAP)                                         \
 void ff_hevc_put_hevc_uni_##PEL##_hv##WIDTH##_8_msa(uint8_t *dst,          \
                                                     ptrdiff_t dst_stride,  \
-                                                    uint8_t *src,          \
+                                                    const uint8_t *src,    \
                                                     ptrdiff_t src_stride,  \
                                                     int height,            \
                                                     intptr_t mx,           \
diff --git a/libavcodec/mips/hevc_mc_uniw_msa.c b/libavcodec/mips/hevc_mc_uniw_msa.c
index 1a8c251534..3c3d7a0da2 100644
--- a/libavcodec/mips/hevc_mc_uniw_msa.c
+++ b/libavcodec/mips/hevc_mc_uniw_msa.c
@@ -54,7 +54,7 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = {
                                    out2_h, out3_h);                        \
 }
 
-static void hevc_uniwgt_copy_4w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_4w_msa(const uint8_t *src,
                                     int32_t src_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -121,7 +121,7 @@ static void hevc_uniwgt_copy_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_6w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_6w_msa(const uint8_t *src,
                                     int32_t src_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -183,7 +183,7 @@ static void hevc_uniwgt_copy_6w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_8w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_8w_msa(const uint8_t *src,
                                     int32_t src_stride,
                                     uint8_t *dst,
                                     int32_t dst_stride,
@@ -278,7 +278,7 @@ static void hevc_uniwgt_copy_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_12w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_12w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -323,7 +323,7 @@ static void hevc_uniwgt_copy_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_16w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_16w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -366,7 +366,7 @@ static void hevc_uniwgt_copy_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_24w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_24w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -419,7 +419,7 @@ static void hevc_uniwgt_copy_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_32w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_32w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -465,7 +465,7 @@ static void hevc_uniwgt_copy_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_48w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_48w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -522,7 +522,7 @@ static void hevc_uniwgt_copy_48w_msa(uint8_t *src,
     }
 }
 
-static void hevc_uniwgt_copy_64w_msa(uint8_t *src,
+static void hevc_uniwgt_copy_64w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -585,7 +585,7 @@ static void hevc_uniwgt_copy_64w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_4w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -661,7 +661,7 @@ static void hevc_hz_uniwgt_8t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_8w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -739,7 +739,7 @@ static void hevc_hz_uniwgt_8t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_12w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -833,7 +833,7 @@ static void hevc_hz_uniwgt_8t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_16w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -911,7 +911,7 @@ static void hevc_hz_uniwgt_8t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_24w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1004,7 +1004,7 @@ static void hevc_hz_uniwgt_8t_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_32w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1106,7 +1106,7 @@ static void hevc_hz_uniwgt_8t_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_48w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_48w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1200,7 +1200,7 @@ static void hevc_hz_uniwgt_8t_48w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_8t_64w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_8t_64w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1210,7 +1210,7 @@ static void hevc_hz_uniwgt_8t_64w_msa(uint8_t *src,
                                       int32_t offset,
                                       int32_t rnd_val)
 {
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     uint32_t loop_cnt, cnt;
     v16u8 out0, out1;
@@ -1291,7 +1291,7 @@ static void hevc_hz_uniwgt_8t_64w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_8t_4w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1383,7 +1383,7 @@ static void hevc_vt_uniwgt_8t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_8t_8w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1462,7 +1462,7 @@ static void hevc_vt_uniwgt_8t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_8t_12w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1565,7 +1565,7 @@ static void hevc_vt_uniwgt_8t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_8t_16multx4mult_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_16multx4mult_msa(const uint8_t *src,
                                                int32_t src_stride,
                                                uint8_t *dst,
                                                int32_t dst_stride,
@@ -1576,7 +1576,7 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(uint8_t *src,
                                                int32_t rnd_val,
                                                int32_t weightmul16)
 {
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     int32_t loop_cnt, cnt;
     v16u8 out0, out1, out2, out3;
@@ -1676,7 +1676,7 @@ static void hevc_vt_uniwgt_8t_16multx4mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_8t_16w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1691,7 +1691,7 @@ static void hevc_vt_uniwgt_8t_16w_msa(uint8_t *src,
                                        offset, rnd_val, 1);
 }
 
-static void hevc_vt_uniwgt_8t_24w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1709,7 +1709,7 @@ static void hevc_vt_uniwgt_8t_24w_msa(uint8_t *src,
                              filter, 32, weight, offset, rnd_val);
 }
 
-static void hevc_vt_uniwgt_8t_32w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1724,7 +1724,7 @@ static void hevc_vt_uniwgt_8t_32w_msa(uint8_t *src,
                                        offset, rnd_val, 2);
 }
 
-static void hevc_vt_uniwgt_8t_48w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_48w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1739,7 +1739,7 @@ static void hevc_vt_uniwgt_8t_48w_msa(uint8_t *src,
                                        offset, rnd_val, 3);
 }
 
-static void hevc_vt_uniwgt_8t_64w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_8t_64w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -1754,7 +1754,7 @@ static void hevc_vt_uniwgt_8t_64w_msa(uint8_t *src,
                                        offset, rnd_val, 4);
 }
 
-static void hevc_hv_uniwgt_8t_4w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -1879,7 +1879,7 @@ static void hevc_hv_uniwgt_8t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_8t_8multx2mult_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_8multx2mult_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -1892,7 +1892,7 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(uint8_t *src,
                                               int32_t width)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
     v8i16 filt0, filt1, filt2, filt3;
@@ -2041,7 +2041,7 @@ static void hevc_hv_uniwgt_8t_8multx2mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_8t_8w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2057,7 +2057,7 @@ static void hevc_hv_uniwgt_8t_8w_msa(uint8_t *src,
                                       offset, rnd_val, 8);
 }
 
-static void hevc_hv_uniwgt_8t_12w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2069,7 +2069,8 @@ static void hevc_hv_uniwgt_8t_12w_msa(uint8_t *src,
                                       int32_t rnd_val)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp, *dst_tmp;
+    const uint8_t *src_tmp;
+    uint8_t *dst_tmp;
     v16u8 out;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7;
@@ -2262,7 +2263,7 @@ static void hevc_hv_uniwgt_8t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_8t_16w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2278,7 +2279,7 @@ static void hevc_hv_uniwgt_8t_16w_msa(uint8_t *src,
                                       offset, rnd_val, 16);
 }
 
-static void hevc_hv_uniwgt_8t_24w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2294,7 +2295,7 @@ static void hevc_hv_uniwgt_8t_24w_msa(uint8_t *src,
                                       offset, rnd_val, 24);
 }
 
-static void hevc_hv_uniwgt_8t_32w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2310,7 +2311,7 @@ static void hevc_hv_uniwgt_8t_32w_msa(uint8_t *src,
                                       offset, rnd_val, 32);
 }
 
-static void hevc_hv_uniwgt_8t_48w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_48w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2326,7 +2327,7 @@ static void hevc_hv_uniwgt_8t_48w_msa(uint8_t *src,
                                       offset, rnd_val, 48);
 }
 
-static void hevc_hv_uniwgt_8t_64w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_8t_64w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2342,7 +2343,7 @@ static void hevc_hv_uniwgt_8t_64w_msa(uint8_t *src,
                                       offset, rnd_val, 64);
 }
 
-static void hevc_hz_uniwgt_4t_4x2_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_4x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2400,7 +2401,7 @@ static void hevc_hz_uniwgt_4t_4x2_msa(uint8_t *src,
     dst += (4 * dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_4x4_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_4x4_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2457,7 +2458,7 @@ static void hevc_hz_uniwgt_4t_4x4_msa(uint8_t *src,
     dst += (4 * dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_4x8multiple_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_4x8multiple_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -2525,7 +2526,7 @@ static void hevc_hz_uniwgt_4t_4x8multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_4w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2548,7 +2549,7 @@ static void hevc_hz_uniwgt_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_6w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_6w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2629,7 +2630,7 @@ static void hevc_hz_uniwgt_4t_6w_msa(uint8_t *src,
     ST_H2(out3, 2, 6, dst + 2 * dst_stride + 4, dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_8x2_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_8x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2684,7 +2685,7 @@ static void hevc_hz_uniwgt_4t_8x2_msa(uint8_t *src,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_8x4_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_8x4_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2741,7 +2742,7 @@ static void hevc_hz_uniwgt_4t_8x4_msa(uint8_t *src,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_8x6_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_8x6_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2811,7 +2812,7 @@ static void hevc_hz_uniwgt_4t_8x6_msa(uint8_t *src,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hz_uniwgt_4t_8x8multiple_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_8x8multiple_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -2891,7 +2892,7 @@ static void hevc_hz_uniwgt_4t_8x8multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_8w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -2917,7 +2918,7 @@ static void hevc_hz_uniwgt_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_12w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -2997,7 +2998,7 @@ static void hevc_hz_uniwgt_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_16w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3080,7 +3081,7 @@ static void hevc_hz_uniwgt_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_24w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3158,7 +3159,7 @@ static void hevc_hz_uniwgt_4t_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_uniwgt_4t_32w_msa(uint8_t *src,
+static void hevc_hz_uniwgt_4t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3245,7 +3246,7 @@ static void hevc_hz_uniwgt_4t_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_4x2_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_4x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3300,7 +3301,7 @@ static void hevc_vt_uniwgt_4t_4x2_msa(uint8_t *src,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_4x4_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_4x4_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3354,7 +3355,7 @@ static void hevc_vt_uniwgt_4t_4x4_msa(uint8_t *src,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_4x8multiple_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_4x8multiple_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -3430,7 +3431,7 @@ static void hevc_vt_uniwgt_4t_4x8multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_4w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3453,7 +3454,7 @@ static void hevc_vt_uniwgt_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_6w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_6w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3531,7 +3532,7 @@ static void hevc_vt_uniwgt_4t_6w_msa(uint8_t *src,
     ST_H2(out3, 2, 6, dst + 2 * dst_stride + 4, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_8x2_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_8x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3582,7 +3583,7 @@ static void hevc_vt_uniwgt_4t_8x2_msa(uint8_t *src,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_8x4_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_8x4_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3637,7 +3638,7 @@ static void hevc_vt_uniwgt_4t_8x4_msa(uint8_t *src,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_8x6_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_8x6_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3700,7 +3701,7 @@ static void hevc_vt_uniwgt_4t_8x6_msa(uint8_t *src,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_vt_uniwgt_4t_8x8mult_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_8x8mult_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -3779,7 +3780,7 @@ static void hevc_vt_uniwgt_4t_8x8mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_8w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -3805,7 +3806,7 @@ static void hevc_vt_uniwgt_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_12w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3910,7 +3911,7 @@ static void hevc_vt_uniwgt_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_16w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -3992,7 +3993,7 @@ static void hevc_vt_uniwgt_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_24w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4094,7 +4095,7 @@ static void hevc_vt_uniwgt_4t_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_uniwgt_4t_32w_msa(uint8_t *src,
+static void hevc_vt_uniwgt_4t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4188,7 +4189,7 @@ static void hevc_vt_uniwgt_4t_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_4x2_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_4x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4252,7 +4253,7 @@ static void hevc_hv_uniwgt_4t_4x2_msa(uint8_t *src,
     ST_W2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_uniwgt_4t_4x4_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_4x4_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4321,7 +4322,7 @@ static void hevc_hv_uniwgt_4t_4x4_msa(uint8_t *src,
     ST_W4(out, 0, 1, 2, 3, dst, dst_stride);
 }
 
-static void hevc_hv_uniwgt_4t_4multx8mult_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_4multx8mult_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -4428,7 +4429,7 @@ static void hevc_hv_uniwgt_4t_4multx8mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_4w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_4w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4454,7 +4455,7 @@ static void hevc_hv_uniwgt_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_6w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_6w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -4581,7 +4582,7 @@ static void hevc_hv_uniwgt_4t_6w_msa(uint8_t *src,
     ST_H8(out2, 0, 1, 2, 3, 4, 5, 6, 7, dst + 4, dst_stride);
 }
 
-static void hevc_hv_uniwgt_4t_8x2_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_8x2_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4657,7 +4658,7 @@ static void hevc_hv_uniwgt_4t_8x2_msa(uint8_t *src,
     ST_D2(out, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_uniwgt_4t_8multx4_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_8multx4_msa(const uint8_t *src,
                                           int32_t src_stride,
                                           uint8_t *dst,
                                           int32_t dst_stride,
@@ -4752,7 +4753,7 @@ static void hevc_hv_uniwgt_4t_8multx4_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_8x6_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_8x6_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -4868,7 +4869,7 @@ static void hevc_hv_uniwgt_4t_8x6_msa(uint8_t *src,
     ST_D2(out2, 0, 1, dst + 4 * dst_stride, dst_stride);
 }
 
-static void hevc_hv_uniwgt_4t_8multx4mult_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_8multx4mult_msa(const uint8_t *src,
                                               int32_t src_stride,
                                               uint8_t *dst,
                                               int32_t dst_stride,
@@ -4881,7 +4882,7 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(uint8_t *src,
                                               int32_t width8mult)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6;
@@ -4990,7 +4991,7 @@ static void hevc_hv_uniwgt_4t_8multx4mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_8w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_8w_msa(const uint8_t *src,
                                      int32_t src_stride,
                                      uint8_t *dst,
                                      int32_t dst_stride,
@@ -5021,7 +5022,7 @@ static void hevc_hv_uniwgt_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_12w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_12w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -5033,7 +5034,8 @@ static void hevc_hv_uniwgt_4t_12w_msa(uint8_t *src,
                                       int32_t rnd_val)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp, *dst_tmp;
+    const uint8_t *src_tmp;
+    uint8_t *dst_tmp;
     v16u8 out0, out1;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
@@ -5198,7 +5200,7 @@ static void hevc_hv_uniwgt_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_16w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_16w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -5220,7 +5222,7 @@ static void hevc_hv_uniwgt_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_uniwgt_4t_24w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_24w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -5236,7 +5238,7 @@ static void hevc_hv_uniwgt_4t_24w_msa(uint8_t *src,
                                       offset, rnd_val, 3);
 }
 
-static void hevc_hv_uniwgt_4t_32w_msa(uint8_t *src,
+static void hevc_hv_uniwgt_4t_32w_msa(const uint8_t *src,
                                       int32_t src_stride,
                                       uint8_t *dst,
                                       int32_t dst_stride,
@@ -5255,7 +5257,7 @@ static void hevc_hv_uniwgt_4t_32w_msa(uint8_t *src,
 #define UNIWGT_MC_COPY(WIDTH)                                                \
 void ff_hevc_put_hevc_uni_w_pel_pixels##WIDTH##_8_msa(uint8_t *dst,          \
                                                       ptrdiff_t dst_stride,  \
-                                                      uint8_t *src,          \
+                                                      const uint8_t *src,    \
                                                       ptrdiff_t src_stride,  \
                                                       int height,            \
                                                       int denom,             \
@@ -5286,7 +5288,7 @@ UNIWGT_MC_COPY(64);
 void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,        \
                                                          ptrdiff_t            \
                                                          dst_stride,          \
-                                                         uint8_t *src,        \
+                                                         const uint8_t *src,  \
                                                          ptrdiff_t            \
                                                          src_stride,          \
                                                          int height,          \
@@ -5344,7 +5346,7 @@ UNI_W_MC(epel, v, 32, 4, vt, my);
 #define UNI_W_MC_HV(PEL, WIDTH, TAP)                                          \
 void ff_hevc_put_hevc_uni_w_##PEL##_hv##WIDTH##_8_msa(uint8_t *dst,           \
                                                       ptrdiff_t dst_stride,   \
-                                                      uint8_t *src,           \
+                                                      const uint8_t *src,     \
                                                       ptrdiff_t src_stride,   \
                                                       int height,             \
                                                       int denom,              \
diff --git a/libavcodec/mips/hevcdsp_mips.h b/libavcodec/mips/hevcdsp_mips.h
index c84e08d160..a8f78ff73a 100644
--- a/libavcodec/mips/hevcdsp_mips.h
+++ b/libavcodec/mips/hevcdsp_mips.h
@@ -25,7 +25,7 @@
 
 #define MC(PEL, DIR, WIDTH)                                                 \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst,            \
-                                                     uint8_t *src,          \
+                                                   const uint8_t *src,      \
                                                      ptrdiff_t src_stride,  \
                                                      int height,            \
                                                      intptr_t mx,           \
@@ -104,7 +104,7 @@ MC(epel, hv, 64);
 #define UNI_MC(PEL, DIR, WIDTH)                                                \
 void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,           \
                                                          ptrdiff_t dst_stride, \
-                                                         uint8_t *src,         \
+                                                         const uint8_t *src,   \
                                                          ptrdiff_t src_stride, \
                                                          int height,           \
                                                          intptr_t mx,          \
@@ -184,7 +184,7 @@ UNI_MC(epel, hv, 64);
 void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,    \
                                                            ptrdiff_t      \
                                                            dst_stride,    \
-                                                           uint8_t *src,  \
+                                                           const uint8_t *src,  \
                                                            ptrdiff_t      \
                                                            src_stride,    \
                                                            int height,    \
@@ -267,9 +267,9 @@ UNI_W_MC(epel, hv, 64);
 #define BI_MC(PEL, DIR, WIDTH)                                                 \
 void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,            \
                                                         ptrdiff_t dst_stride,  \
-                                                        uint8_t *src,          \
+                                                        const uint8_t *src,    \
                                                         ptrdiff_t src_stride,  \
-                                                        int16_t *src_16bit,    \
+                                                        const int16_t *src_16bit,    \
                                                         int height,            \
                                                         intptr_t mx,           \
                                                         intptr_t my,           \
@@ -348,10 +348,10 @@ BI_MC(epel, hv, 64);
 void ff_hevc_put_hevc_bi_w_##PEL##_##DIR##WIDTH##_8_msa(uint8_t *dst,          \
                                                           ptrdiff_t            \
                                                           dst_stride,          \
-                                                          uint8_t *src,        \
+                                                          const uint8_t *src,  \
                                                           ptrdiff_t            \
                                                           src_stride,          \
-                                                          int16_t *src_16bit,  \
+                                                          const int16_t *src_16bit, \
                                                           int height,          \
                                                           int denom,           \
                                                           int weight0,         \
@@ -433,32 +433,32 @@ BI_W_MC(epel, hv, 64);
 
 void ff_hevc_loop_filter_luma_h_8_msa(uint8_t *src,
                                       ptrdiff_t src_stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q);
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q);
 
 void ff_hevc_loop_filter_luma_v_8_msa(uint8_t *src,
                                       ptrdiff_t src_stride,
-                                      int32_t beta, int32_t *tc,
-                                      uint8_t *no_p, uint8_t *no_q);
+                                      int32_t beta, const int32_t *tc,
+                                      const uint8_t *no_p, const uint8_t *no_q);
 
 void ff_hevc_loop_filter_chroma_h_8_msa(uint8_t *src,
                                         ptrdiff_t src_stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q);
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q);
 
 void ff_hevc_loop_filter_chroma_v_8_msa(uint8_t *src,
                                         ptrdiff_t src_stride,
-                                        int32_t *tc, uint8_t *no_p,
-                                        uint8_t *no_q);
+                                        const int32_t *tc, const uint8_t *no_p,
+                                        const uint8_t *no_q);
 
-void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, uint8_t *src,
+void ff_hevc_sao_band_filter_0_8_msa(uint8_t *dst, const uint8_t *src,
                                      ptrdiff_t stride_dst, ptrdiff_t stride_src,
-                                     int16_t *sao_offset_val, int sao_left_class,
+                                     const int16_t *sao_offset_val, int sao_left_class,
                                      int width, int height);
 
-void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, uint8_t *src,
+void ff_hevc_sao_edge_filter_8_msa(uint8_t *dst, const uint8_t *src,
                                    ptrdiff_t stride_dst,
-                                   int16_t *sao_offset_val,
+                                   const int16_t *sao_offset_val,
                                    int eo, int width, int height);
 
 void ff_hevc_idct_4x4_msa(int16_t *coeffs, int col_limit);
@@ -469,20 +469,20 @@ void ff_hevc_idct_dc_4x4_msa(int16_t *coeffs);
 void ff_hevc_idct_dc_8x8_msa(int16_t *coeffs);
 void ff_hevc_idct_dc_16x16_msa(int16_t *coeffs);
 void ff_hevc_idct_dc_32x32_msa(int16_t *coeffs);
-void ff_hevc_addblk_4x4_msa(uint8_t *dst, int16_t *pi16Coeffs,
+void ff_hevc_addblk_4x4_msa(uint8_t *dst, const int16_t *pi16Coeffs,
                             ptrdiff_t stride);
-void ff_hevc_addblk_8x8_msa(uint8_t *dst, int16_t *pi16Coeffs,
+void ff_hevc_addblk_8x8_msa(uint8_t *dst, const int16_t *pi16Coeffs,
                             ptrdiff_t stride);
-void ff_hevc_addblk_16x16_msa(uint8_t *dst, int16_t *pi16Coeffs,
+void ff_hevc_addblk_16x16_msa(uint8_t *dst, const int16_t *pi16Coeffs,
                               ptrdiff_t stride);
-void ff_hevc_addblk_32x32_msa(uint8_t *dst, int16_t *pi16Coeffs,
+void ff_hevc_addblk_32x32_msa(uint8_t *dst, const int16_t *pi16Coeffs,
                               ptrdiff_t stride);
 void ff_hevc_idct_luma_4x4_msa(int16_t *pi16Coeffs);
 
 /* Loongson optimization */
 #define L_MC(PEL, DIR, WIDTH, TYPE)                                          \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_##TYPE(int16_t *dst,          \
-                                                      uint8_t *src,          \
+                                                      const uint8_t *src,    \
                                                       ptrdiff_t src_stride,  \
                                                       int height,            \
                                                       intptr_t mx,           \
@@ -509,9 +509,9 @@ L_MC(qpel, hv, 64, mmi);
 #define L_BI_MC(PEL, DIR, WIDTH, TYPE)                                          \
 void ff_hevc_put_hevc_##PEL##_bi_##DIR##WIDTH##_8_##TYPE(uint8_t *dst,          \
                                                          ptrdiff_t dst_stride,  \
-                                                         uint8_t *src,          \
+                                                         const uint8_t *src,    \
                                                          ptrdiff_t src_stride,  \
-                                                         int16_t *src2,         \
+                                                         const int16_t *src2,   \
                                                          int height,            \
                                                          intptr_t mx,           \
                                                          intptr_t my,           \
@@ -553,7 +553,7 @@ L_BI_MC(epel, hv, 32, mmi);
 #define L_UNI_MC(PEL, DIR, WIDTH, TYPE)                                         \
 void ff_hevc_put_hevc_##PEL##_uni_##DIR##WIDTH##_8_##TYPE(uint8_t *dst,         \
                                                           ptrdiff_t dst_stride, \
-                                                          uint8_t *src,         \
+                                                          const uint8_t *src,   \
                                                           ptrdiff_t src_stride, \
                                                           int height,           \
                                                           intptr_t mx,          \
diff --git a/libavcodec/mips/hevcdsp_mmi.c b/libavcodec/mips/hevcdsp_mmi.c
index 6583bef5da..0ea88a7c08 100644
--- a/libavcodec/mips/hevcdsp_mmi.c
+++ b/libavcodec/mips/hevcdsp_mmi.c
@@ -24,13 +24,13 @@
 #include "libavutil/mips/mmiutils.h"
 
 #define PUT_HEVC_QPEL_H(w, x_step, src_step, dst_step)                   \
-void ff_hevc_put_hevc_qpel_h##w##_8_mmi(int16_t *dst, uint8_t *_src,     \
+void ff_hevc_put_hevc_qpel_h##w##_8_mmi(int16_t *dst, const uint8_t *_src, \
                                         ptrdiff_t _srcstride,            \
                                         int height, intptr_t mx,         \
                                         intptr_t my, int width)          \
 {                                                                        \
     int x, y;                                                            \
-    pixel *src = (pixel*)_src - 3;                                       \
+    const pixel *src = (const pixel*)_src - 3;                           \
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);                    \
     double ftmp[15];                                                     \
     uint64_t rtmp[1];                                                    \
@@ -118,14 +118,14 @@ PUT_HEVC_QPEL_H(48, 12, -48, -96);
 PUT_HEVC_QPEL_H(64, 16, -64, -128);
 
 #define PUT_HEVC_QPEL_HV(w, x_step, src_step, dst_step)                  \
-void ff_hevc_put_hevc_qpel_hv##w##_8_mmi(int16_t *dst, uint8_t *_src,    \
+void ff_hevc_put_hevc_qpel_hv##w##_8_mmi(int16_t *dst, const uint8_t *_src,\
                                      ptrdiff_t _srcstride,               \
                                      int height, intptr_t mx,            \
                                      intptr_t my, int width)             \
 {                                                                        \
     int x, y;                                                            \
     const int8_t *filter;                                                \
-    pixel *src = (pixel*)_src;                                           \
+    const pixel *src = (const pixel*)_src;                               \
     ptrdiff_t srcstride = _srcstride / sizeof(pixel);                    \
     int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];         \
     int16_t *tmp = tmp_array;                                            \
@@ -303,14 +303,14 @@ PUT_HEVC_QPEL_HV(64, 16, -64, -128);
 #define PUT_HEVC_QPEL_BI_H(w, x_step, src_step, src2_step, dst_step)    \
 void ff_hevc_put_hevc_qpel_bi_h##w##_8_mmi(uint8_t *_dst,               \
                                            ptrdiff_t _dststride,        \
-                                           uint8_t *_src,               \
+                                           const uint8_t *_src,         \
                                            ptrdiff_t _srcstride,        \
-                                           int16_t *src2, int height,   \
+                                           const int16_t *src2, int height, \
                                            intptr_t mx, intptr_t my,    \
                                            int width)                   \
 {                                                                       \
     int x, y;                                                           \
-    pixel        *src       = (pixel*)_src - 3;                         \
+    const pixel  *src       = (const pixel*)_src - 3;                   \
     ptrdiff_t     srcstride = _srcstride / sizeof(pixel);               \
     pixel *dst          = (pixel *)_dst;                                \
     ptrdiff_t dststride = _dststride / sizeof(pixel);                   \
@@ -434,9 +434,9 @@ PUT_HEVC_QPEL_BI_H(64, 16, -64, -128, -64);
 #define PUT_HEVC_QPEL_BI_HV(w, x_step, src_step, src2_step, dst_step)   \
 void ff_hevc_put_hevc_qpel_bi_hv##w##_8_mmi(uint8_t *_dst,              \
                                             ptrdiff_t _dststride,       \
-                                            uint8_t *_src,              \
+                                            const uint8_t *_src,        \
                                             ptrdiff_t _srcstride,       \
-                                            int16_t *src2, int height,  \
+                                            const int16_t *src2, int height, \
                                             intptr_t mx, intptr_t my,   \
                                             int width)                  \
 {                                                                       \
@@ -654,9 +654,9 @@ PUT_HEVC_QPEL_BI_HV(64, 16, -64, -128, -64);
 #define PUT_HEVC_EPEL_BI_HV(w, x_step, src_step, src2_step, dst_step)   \
 void ff_hevc_put_hevc_epel_bi_hv##w##_8_mmi(uint8_t *_dst,              \
                                             ptrdiff_t _dststride,       \
-                                            uint8_t *_src,              \
+                                            const uint8_t *_src,        \
                                             ptrdiff_t _srcstride,       \
-                                            int16_t *src2, int height,  \
+                                            const int16_t *src2, int height, \
                                             intptr_t mx, intptr_t my,   \
                                             int width)                  \
 {                                                                       \
@@ -835,9 +835,9 @@ PUT_HEVC_EPEL_BI_HV(32, 8, -32, -64, -32);
 #define PUT_HEVC_PEL_BI_PIXELS(w, x_step, src_step, dst_step, src2_step)  \
 void ff_hevc_put_hevc_pel_bi_pixels##w##_8_mmi(uint8_t *_dst,             \
                                                ptrdiff_t _dststride,      \
-                                               uint8_t *_src,             \
+                                               const uint8_t *_src,       \
                                                ptrdiff_t _srcstride,      \
-                                               int16_t *src2, int height, \
+                                               const int16_t *src2, int height, \
                                                intptr_t mx, intptr_t my,  \
                                                int width)                 \
 {                                                                         \
@@ -945,7 +945,7 @@ PUT_HEVC_PEL_BI_PIXELS(64, 8, -64, -64, -128);
 #define PUT_HEVC_QPEL_UNI_HV(w, x_step, src_step, dst_step, tmp_step)   \
 void ff_hevc_put_hevc_qpel_uni_hv##w##_8_mmi(uint8_t *_dst,             \
                                              ptrdiff_t _dststride,      \
-                                             uint8_t *_src,             \
+                                             const uint8_t *_src,       \
                                              ptrdiff_t _srcstride,      \
                                              int height,                \
                                              intptr_t mx, intptr_t my,  \
diff --git a/libavcodec/mips/hevcdsp_msa.c b/libavcodec/mips/hevcdsp_msa.c
index 2c57ec857a..8841a31369 100644
--- a/libavcodec/mips/hevcdsp_msa.c
+++ b/libavcodec/mips/hevcdsp_msa.c
@@ -29,7 +29,7 @@ static const uint8_t ff_hevc_mask_arr[16 * 2] __attribute__((aligned(0x40))) = {
     0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20
 };
 
-static void hevc_copy_4w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_4w_msa(const uint8_t *src, int32_t src_stride,
                              int16_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -77,7 +77,7 @@ static void hevc_copy_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_6w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_6w_msa(const uint8_t *src, int32_t src_stride,
                              int16_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -101,7 +101,7 @@ static void hevc_copy_6w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_8w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_8w_msa(const uint8_t *src, int32_t src_stride,
                              int16_t *dst, int32_t dst_stride,
                              int32_t height)
 {
@@ -162,7 +162,7 @@ static void hevc_copy_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_12w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_12w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -199,7 +199,7 @@ static void hevc_copy_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_16w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_16w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -290,7 +290,7 @@ static void hevc_copy_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_24w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_24w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -319,7 +319,7 @@ static void hevc_copy_24w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_32w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_32w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -357,7 +357,7 @@ static void hevc_copy_32w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_48w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_48w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -408,7 +408,7 @@ static void hevc_copy_48w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_copy_64w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_copy_64w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               int32_t height)
 {
@@ -445,7 +445,7 @@ static void hevc_copy_64w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_4w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_4w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter, int32_t height)
 {
@@ -500,7 +500,7 @@ static void hevc_hz_8t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_8w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_8w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter, int32_t height)
 {
@@ -555,7 +555,7 @@ static void hevc_hz_8t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_12w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_12w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -630,7 +630,7 @@ static void hevc_hz_8t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_16w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_16w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -687,7 +687,7 @@ static void hevc_hz_8t_16w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_24w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_24w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -762,7 +762,7 @@ static void hevc_hz_8t_24w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_32w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_32w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -822,7 +822,7 @@ static void hevc_hz_8t_32w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_48w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_48w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -893,7 +893,7 @@ static void hevc_hz_8t_48w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hz_8t_64w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hz_8t_64w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -987,7 +987,7 @@ static void hevc_hz_8t_64w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_vt_8t_4w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_4w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter, int32_t height)
 {
@@ -1057,7 +1057,7 @@ static void hevc_vt_8t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_vt_8t_8w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_8w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter, int32_t height)
 {
@@ -1120,7 +1120,7 @@ static void hevc_vt_8t_8w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_vt_8t_12w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_12w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1207,7 +1207,7 @@ static void hevc_vt_8t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_vt_8t_16multx4mult_msa(uint8_t *src,
+static void hevc_vt_8t_16multx4mult_msa(const uint8_t *src,
                                         int32_t src_stride,
                                         int16_t *dst,
                                         int32_t dst_stride,
@@ -1215,7 +1215,7 @@ static void hevc_vt_8t_16multx4mult_msa(uint8_t *src,
                                         int32_t height,
                                         int32_t width)
 {
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     int16_t *dst_tmp;
     int32_t loop_cnt, cnt;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
@@ -1315,7 +1315,7 @@ static void hevc_vt_8t_16multx4mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_8t_16w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_16w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1323,7 +1323,7 @@ static void hevc_vt_8t_16w_msa(uint8_t *src, int32_t src_stride,
                                 filter, height, 16);
 }
 
-static void hevc_vt_8t_24w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_24w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1333,7 +1333,7 @@ static void hevc_vt_8t_24w_msa(uint8_t *src, int32_t src_stride,
                       filter, height);
 }
 
-static void hevc_vt_8t_32w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_32w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1341,7 +1341,7 @@ static void hevc_vt_8t_32w_msa(uint8_t *src, int32_t src_stride,
                                 filter, height, 32);
 }
 
-static void hevc_vt_8t_48w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_48w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1349,7 +1349,7 @@ static void hevc_vt_8t_48w_msa(uint8_t *src, int32_t src_stride,
                                 filter, height, 48);
 }
 
-static void hevc_vt_8t_64w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_8t_64w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter, int32_t height)
 {
@@ -1357,7 +1357,7 @@ static void hevc_vt_8t_64w_msa(uint8_t *src, int32_t src_stride,
                                 filter, height, 64);
 }
 
-static void hevc_hv_8t_4w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_4w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter_x, const int8_t *filter_y,
                               int32_t height)
@@ -1464,7 +1464,7 @@ static void hevc_hv_8t_4w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hv_8t_8multx1mult_msa(uint8_t *src,
+static void hevc_hv_8t_8multx1mult_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -1473,7 +1473,7 @@ static void hevc_hv_8t_8multx1mult_msa(uint8_t *src,
                                        int32_t height, int32_t width)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     int16_t *dst_tmp;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7;
     v8i16 filt0, filt1, filt2, filt3;
@@ -1591,7 +1591,7 @@ static void hevc_hv_8t_8multx1mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_8t_8w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_8w_msa(const uint8_t *src, int32_t src_stride,
                               int16_t *dst, int32_t dst_stride,
                               const int8_t *filter_x, const int8_t *filter_y,
                               int32_t height)
@@ -1600,13 +1600,13 @@ static void hevc_hv_8t_8w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 8);
 }
 
-static void hevc_hv_8t_12w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_12w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     int16_t *dst_tmp;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 mask0, mask1, mask2, mask3, mask4, mask5, mask6, mask7;
@@ -1795,7 +1795,7 @@ static void hevc_hv_8t_12w_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hv_8t_16w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_16w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
@@ -1804,7 +1804,7 @@ static void hevc_hv_8t_16w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 16);
 }
 
-static void hevc_hv_8t_24w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_24w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
@@ -1813,7 +1813,7 @@ static void hevc_hv_8t_24w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 24);
 }
 
-static void hevc_hv_8t_32w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_32w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
@@ -1822,7 +1822,7 @@ static void hevc_hv_8t_32w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 32);
 }
 
-static void hevc_hv_8t_48w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_48w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
@@ -1831,7 +1831,7 @@ static void hevc_hv_8t_48w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 48);
 }
 
-static void hevc_hv_8t_64w_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_8t_64w_msa(const uint8_t *src, int32_t src_stride,
                                int16_t *dst, int32_t dst_stride,
                                const int8_t *filter_x, const int8_t *filter_y,
                                int32_t height)
@@ -1840,7 +1840,7 @@ static void hevc_hv_8t_64w_msa(uint8_t *src, int32_t src_stride,
                                filter_x, filter_y, height, 64);
 }
 
-static void hevc_hz_4t_4x2_msa(uint8_t *src,
+static void hevc_hz_4t_4x2_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -1873,7 +1873,7 @@ static void hevc_hz_4t_4x2_msa(uint8_t *src,
     ST_D2(dst0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_4t_4x4_msa(uint8_t *src,
+static void hevc_hz_4t_4x4_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -1910,7 +1910,7 @@ static void hevc_hz_4t_4x4_msa(uint8_t *src,
     ST_D4(dst0, dst1, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hz_4t_4x8multiple_msa(uint8_t *src,
+static void hevc_hz_4t_4x8multiple_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -1959,7 +1959,7 @@ static void hevc_hz_4t_4x8multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_4w_msa(uint8_t *src,
+static void hevc_hz_4t_4w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -1976,7 +1976,7 @@ static void hevc_hz_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_6w_msa(uint8_t *src,
+static void hevc_hz_4t_6w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -2047,7 +2047,7 @@ static void hevc_hz_4t_6w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_8x2multiple_msa(uint8_t *src,
+static void hevc_hz_4t_8x2multiple_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -2091,7 +2091,7 @@ static void hevc_hz_4t_8x2multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_8x4multiple_msa(uint8_t *src,
+static void hevc_hz_4t_8x4multiple_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -2144,7 +2144,7 @@ static void hevc_hz_4t_8x4multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_8w_msa(uint8_t *src,
+static void hevc_hz_4t_8w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -2160,7 +2160,7 @@ static void hevc_hz_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_12w_msa(uint8_t *src,
+static void hevc_hz_4t_12w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2221,7 +2221,7 @@ static void hevc_hz_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_16w_msa(uint8_t *src,
+static void hevc_hz_4t_16w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2293,7 +2293,7 @@ static void hevc_hz_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_24w_msa(uint8_t *src,
+static void hevc_hz_4t_24w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2394,7 +2394,7 @@ static void hevc_hz_4t_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hz_4t_32w_msa(uint8_t *src,
+static void hevc_hz_4t_32w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2446,7 +2446,7 @@ static void hevc_hz_4t_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_4x2_msa(uint8_t *src,
+static void hevc_vt_4t_4x2_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2479,7 +2479,7 @@ static void hevc_vt_4t_4x2_msa(uint8_t *src,
     ST_D2(dst10, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_4t_4x4_msa(uint8_t *src,
+static void hevc_vt_4t_4x4_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2516,7 +2516,7 @@ static void hevc_vt_4t_4x4_msa(uint8_t *src,
     ST_D4(dst10, dst32, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_4t_4x8_msa(uint8_t *src,
+static void hevc_vt_4t_4x8_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2565,7 +2565,7 @@ static void hevc_vt_4t_4x8_msa(uint8_t *src,
     ST_D8(dst10, dst32, dst54, dst76, 0, 1, 0, 1, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_4t_4x16_msa(uint8_t *src, int32_t src_stride,
+static void hevc_vt_4t_4x16_msa(const uint8_t *src, int32_t src_stride,
                                 int16_t *dst, int32_t dst_stride,
                                 const int8_t *filter, int32_t height)
 {
@@ -2635,7 +2635,7 @@ static void hevc_vt_4t_4x16_msa(uint8_t *src, int32_t src_stride,
     ST_D8(dst10, dst32, dst54, dst76, 0, 1, 0, 1, 0, 1, 0, 1, dst, dst_stride);
 }
 
-static void hevc_vt_4t_4w_msa(uint8_t *src,
+static void hevc_vt_4t_4w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -2653,7 +2653,7 @@ static void hevc_vt_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_6w_msa(uint8_t *src,
+static void hevc_vt_4t_6w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -2727,7 +2727,7 @@ static void hevc_vt_4t_6w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_8x2_msa(uint8_t *src,
+static void hevc_vt_4t_8x2_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2762,7 +2762,7 @@ static void hevc_vt_4t_8x2_msa(uint8_t *src,
     ST_SH2(dst0_r, dst1_r, dst, dst_stride);
 }
 
-static void hevc_vt_4t_8x6_msa(uint8_t *src,
+static void hevc_vt_4t_8x6_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2824,7 +2824,7 @@ static void hevc_vt_4t_8x6_msa(uint8_t *src,
     ST_SH2(dst0_r, dst1_r, dst, dst_stride);
 }
 
-static void hevc_vt_4t_8x4multiple_msa(uint8_t *src,
+static void hevc_vt_4t_8x4multiple_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -2873,7 +2873,7 @@ static void hevc_vt_4t_8x4multiple_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_8w_msa(uint8_t *src,
+static void hevc_vt_4t_8w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -2890,7 +2890,7 @@ static void hevc_vt_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_12w_msa(uint8_t *src,
+static void hevc_vt_4t_12w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -2961,7 +2961,7 @@ static void hevc_vt_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_16w_msa(uint8_t *src,
+static void hevc_vt_4t_16w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3028,7 +3028,7 @@ static void hevc_vt_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_24w_msa(uint8_t *src,
+static void hevc_vt_4t_24w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3126,7 +3126,7 @@ static void hevc_vt_4t_24w_msa(uint8_t *src,
     }
 }
 
-static void hevc_vt_4t_32w_msa(uint8_t *src,
+static void hevc_vt_4t_32w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3232,7 +3232,7 @@ static void hevc_vt_4t_32w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_4x2_msa(uint8_t *src,
+static void hevc_hv_4t_4x2_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3286,7 +3286,7 @@ static void hevc_hv_4t_4x2_msa(uint8_t *src,
     ST_D2(dst0, 0, 1, dst, dst_stride);
 }
 
-static void hevc_hv_4t_4x4_msa(uint8_t *src,
+static void hevc_hv_4t_4x4_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3349,7 +3349,7 @@ static void hevc_hv_4t_4x4_msa(uint8_t *src,
 }
 
 
-static void hevc_hv_4t_4multx8mult_msa(uint8_t *src,
+static void hevc_hv_4t_4multx8mult_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -3445,7 +3445,7 @@ static void hevc_hv_4t_4multx8mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_4w_msa(uint8_t *src,
+static void hevc_hv_4t_4w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -3465,7 +3465,7 @@ static void hevc_hv_4t_4w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_6w_msa(uint8_t *src,
+static void hevc_hv_4t_6w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -3590,7 +3590,7 @@ static void hevc_hv_4t_6w_msa(uint8_t *src,
     ST_W4(tmp5, 0, 1, 2, 3, dst + 4, dst_stride);
 }
 
-static void hevc_hv_4t_8x2_msa(uint8_t *src,
+static void hevc_hv_4t_8x2_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3657,7 +3657,7 @@ static void hevc_hv_4t_8x2_msa(uint8_t *src,
     ST_SW2(dst0_r, dst1_r, dst, dst_stride);
 }
 
-static void hevc_hv_4t_8multx4_msa(uint8_t *src, int32_t src_stride,
+static void hevc_hv_4t_8multx4_msa(const uint8_t *src, int32_t src_stride,
                                    int16_t *dst, int32_t dst_stride,
                                    const int8_t *filter_x,
                                    const int8_t *filter_y, int32_t width8mult)
@@ -3741,7 +3741,7 @@ static void hevc_hv_4t_8multx4_msa(uint8_t *src, int32_t src_stride,
     }
 }
 
-static void hevc_hv_4t_8x6_msa(uint8_t *src,
+static void hevc_hv_4t_8x6_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -3852,7 +3852,7 @@ static void hevc_hv_4t_8x6_msa(uint8_t *src,
     ST_SW2(dst4_r, dst5_r, dst, dst_stride);
 }
 
-static void hevc_hv_4t_8multx4mult_msa(uint8_t *src,
+static void hevc_hv_4t_8multx4mult_msa(const uint8_t *src,
                                        int32_t src_stride,
                                        int16_t *dst,
                                        int32_t dst_stride,
@@ -3862,7 +3862,7 @@ static void hevc_hv_4t_8multx4mult_msa(uint8_t *src,
                                        int32_t width8mult)
 {
     uint32_t loop_cnt, cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     int16_t *dst_tmp;
     v16i8 src0, src1, src2, src3, src4, src5, src6;
     v8i16 filt0, filt1;
@@ -3969,7 +3969,7 @@ static void hevc_hv_4t_8multx4mult_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_8w_msa(uint8_t *src,
+static void hevc_hv_4t_8w_msa(const uint8_t *src,
                               int32_t src_stride,
                               int16_t *dst,
                               int32_t dst_stride,
@@ -3993,7 +3993,7 @@ static void hevc_hv_4t_8w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_12w_msa(uint8_t *src,
+static void hevc_hv_4t_12w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -4002,7 +4002,7 @@ static void hevc_hv_4t_12w_msa(uint8_t *src,
                                int32_t height)
 {
     uint32_t loop_cnt;
-    uint8_t *src_tmp;
+    const uint8_t *src_tmp;
     int16_t *dst_tmp;
     v16i8 src0, src1, src2, src3, src4, src5, src6, src7, src8, src9, src10;
     v16i8 vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7;
@@ -4166,7 +4166,7 @@ static void hevc_hv_4t_12w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_16w_msa(uint8_t *src,
+static void hevc_hv_4t_16w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -4183,7 +4183,7 @@ static void hevc_hv_4t_16w_msa(uint8_t *src,
     }
 }
 
-static void hevc_hv_4t_24w_msa(uint8_t *src,
+static void hevc_hv_4t_24w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -4195,7 +4195,7 @@ static void hevc_hv_4t_24w_msa(uint8_t *src,
                                filter_x, filter_y, height, 3);
 }
 
-static void hevc_hv_4t_32w_msa(uint8_t *src,
+static void hevc_hv_4t_32w_msa(const uint8_t *src,
                                int32_t src_stride,
                                int16_t *dst,
                                int32_t dst_stride,
@@ -4209,7 +4209,7 @@ static void hevc_hv_4t_32w_msa(uint8_t *src,
 
 #define MC_COPY(WIDTH)                                                    \
 void ff_hevc_put_hevc_pel_pixels##WIDTH##_8_msa(int16_t *dst,             \
-                                                uint8_t *src,             \
+                                                const uint8_t *src,       \
                                                 ptrdiff_t src_stride,     \
                                                 int height,               \
                                                 intptr_t mx,              \
@@ -4233,7 +4233,7 @@ MC_COPY(64);
 
 #define MC(PEL, DIR, WIDTH, TAP, DIR1, FILT_DIR)                          \
 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_msa(int16_t *dst,          \
-                                                   uint8_t *src,          \
+                                                   const uint8_t *src,    \
                                                    ptrdiff_t src_stride,  \
                                                    int height,            \
                                                    intptr_t mx,           \
@@ -4284,7 +4284,7 @@ MC(epel, v, 32, 4, vt, my);
 
 #define MC_HV(PEL, WIDTH, TAP)                                          \
 void ff_hevc_put_hevc_##PEL##_hv##WIDTH##_8_msa(int16_t *dst,           \
-                                                uint8_t *src,           \
+                                                const uint8_t *src,     \
                                                 ptrdiff_t src_stride,   \
                                                 int height,             \
                                                 intptr_t mx,            \
diff --git a/libavcodec/x86/hevc_add_res.asm b/libavcodec/x86/hevc_add_res.asm
index c6c40078a0..3ecbd4269c 100644
--- a/libavcodec/x86/hevc_add_res.asm
+++ b/libavcodec/x86/hevc_add_res.asm
@@ -47,7 +47,7 @@ cextern pw_1023
 
 
 INIT_MMX mmxext
-; void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride)
+; void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_4_8, 3, 3, 6
     pxor              m4, m4
     ADD_RES_MMX_4_8
@@ -118,7 +118,7 @@ cglobal hevc_add_residual_4_8, 3, 3, 6
 
 
 %macro TRANSFORM_ADD_8 0
-; void ff_hevc_add_residual_8_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride)
+; void ff_hevc_add_residual_8_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_8_8, 3, 4, 8
     pxor              m4, m4
     lea               r3, [r2*3]
@@ -128,7 +128,7 @@ cglobal hevc_add_residual_8_8, 3, 4, 8
     ADD_RES_SSE_8_8
     RET
 
-; void ff_hevc_add_residual_16_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride)
+; void ff_hevc_add_residual_16_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_16_8, 3, 5, 7
     pxor                m0, m0
     lea                 r3, [r2*3]
@@ -142,7 +142,7 @@ cglobal hevc_add_residual_16_8, 3, 5, 7
     jg .loop
     RET
 
-; void ff_hevc_add_residual_32_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride)
+; void ff_hevc_add_residual_32_8_<opt>(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_32_8, 3, 5, 7
     pxor                m0, m0
     mov                r4d, 16
@@ -163,7 +163,7 @@ TRANSFORM_ADD_8
 
 %if HAVE_AVX2_EXTERNAL
 INIT_YMM avx2
-; void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride)
+; void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
 cglobal hevc_add_residual_32_8, 3, 5, 7
     pxor                 m0, m0
     lea                  r3, [r2*3]
@@ -289,7 +289,7 @@ cglobal hevc_add_residual_32_8, 3, 5, 7
     mova      [%1+%2+32], m3
 %endmacro
 
-; void ff_hevc_add_residual_<4|8|16|32>_10(pixel *dst, int16_t *block, ptrdiff_t stride)
+; void ff_hevc_add_residual_<4|8|16|32>_10(pixel *dst, const int16_t *block, ptrdiff_t stride)
 INIT_MMX mmxext
 cglobal hevc_add_residual_4_10, 3, 3, 6
     pxor              m2, m2
diff --git a/libavcodec/x86/hevc_mc.asm b/libavcodec/x86/hevc_mc.asm
index e159adccc7..eb267453fe 100644
--- a/libavcodec/x86/hevc_mc.asm
+++ b/libavcodec/x86/hevc_mc.asm
@@ -711,7 +711,7 @@ SECTION .text
 
 ; ******************************
 ; void put_hevc_mc_pixels(int16_t *dst, ptrdiff_t dststride,
-;                         uint8_t *_src, ptrdiff_t _srcstride,
+;                         const uint8_t *_src, ptrdiff_t _srcstride,
 ;                         int height, int mx, int my)
 ; ******************************
 
@@ -765,7 +765,7 @@ cglobal hevc_put_hevc_bi_pel_pixels%1_%2, 6, 6, 6, dst, dststride, src, srcstrid
 
 ; ******************************
 ; void put_hevc_epel_hX(int16_t *dst, ptrdiff_t dststride,
-;                       uint8_t *_src, ptrdiff_t _srcstride,
+;                       const uint8_t *_src, ptrdiff_t _srcstride,
 ;                       int height, int mx, int my, int width);
 ; ******************************
 
@@ -820,7 +820,7 @@ cglobal hevc_put_hevc_bi_epel_h%1_%2, 7, 8, XMM_REGS, dst, dststride, src, srcst
 
 ; ******************************
 ; void put_hevc_epel_v(int16_t *dst, ptrdiff_t dststride,
-;                      uint8_t *_src, ptrdiff_t _srcstride,
+;                      const uint8_t *_src, ptrdiff_t _srcstride,
 ;                      int height, int mx, int my, int width)
 ; ******************************
 
@@ -877,7 +877,7 @@ cglobal hevc_put_hevc_bi_epel_v%1_%2, 6, 8, XMM_REGS, dst, dststride, src, srcst
 
 ; ******************************
 ; void put_hevc_epel_hv(int16_t *dst, ptrdiff_t dststride,
-;                       uint8_t *_src, ptrdiff_t _srcstride,
+;                       const uint8_t *_src, ptrdiff_t _srcstride,
 ;                       int height, int mx, int my, int width)
 ; ******************************
 
@@ -1088,7 +1088,7 @@ cglobal hevc_put_hevc_bi_epel_hv%1_%2, 8, 9, 16, dst, dststride, src, srcstride,
 
 ; ******************************
 ; void put_hevc_qpel_hX_X_X(int16_t *dst, ptrdiff_t dststride,
-;                       uint8_t *_src, ptrdiff_t _srcstride,
+;                           const uint8_t *_src, ptrdiff_t _srcstride,
 ;                       int height, int mx, int my, int width)
 ; ******************************
 
@@ -1144,7 +1144,7 @@ cglobal hevc_put_hevc_bi_qpel_h%1_%2, 7, 8, 16 , dst, dststride, src, srcstride,
 
 ; ******************************
 ; void put_hevc_qpel_vX_X_X(int16_t *dst, ptrdiff_t dststride,
-;                       uint8_t *_src, ptrdiff_t _srcstride,
+;                           const uint8_t *_src, ptrdiff_t _srcstride,
 ;                       int height, int mx, int my, int width)
 ; ******************************
 
@@ -1206,7 +1206,7 @@ cglobal hevc_put_hevc_bi_qpel_v%1_%2, 6, 10, 16, dst, dststride, src, srcstride,
 
 ; ******************************
 ; void put_hevc_qpel_hvX_X(int16_t *dst, ptrdiff_t dststride,
-;                       uint8_t *_src, ptrdiff_t _srcstride,
+;                          const uint8_t *_src, ptrdiff_t _srcstride,
 ;                       int height, int mx, int my)
 ; ******************************
 %macro HEVC_PUT_HEVC_QPEL_HV 2
diff --git a/libavcodec/x86/hevc_sao.asm b/libavcodec/x86/hevc_sao.asm
index 756adfee57..2eb8924da8 100644
--- a/libavcodec/x86/hevc_sao.asm
+++ b/libavcodec/x86/hevc_sao.asm
@@ -119,7 +119,7 @@ DEFINE_ARGS dst, src, dststride, srcstride, offset, height
 %endif ; ARCH
 %endmacro
 
-;void ff_hevc_sao_band_filter_<width>_8_<opt>(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
+;void ff_hevc_sao_band_filter_<width>_8_<opt>(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
 ;                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);
 %macro HEVC_SAO_BAND_FILTER 2
 cglobal hevc_sao_band_filter_%1_8, 6, 6, 15, 7*mmsize*ARCH_X86_32, dst, src, dststride, srcstride, offset, left
diff --git a/libavcodec/x86/hevc_sao_10bit.asm b/libavcodec/x86/hevc_sao_10bit.asm
index b30583dd2f..38005740e5 100644
--- a/libavcodec/x86/hevc_sao_10bit.asm
+++ b/libavcodec/x86/hevc_sao_10bit.asm
@@ -92,7 +92,7 @@ DEFINE_ARGS dst, src, dststride, srcstride, offset, height
     mov          heightd, r7m
 %endmacro
 
-;void ff_hevc_sao_band_filter_<width>_<depth>_<opt>(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
+;void ff_hevc_sao_band_filter_<width>_<depth>_<opt>(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
 ;                                                   int16_t *sao_offset_val, int sao_left_class, int width, int height);
 %macro HEVC_SAO_BAND_FILTER 3
 cglobal hevc_sao_band_filter_%2_%1, 6, 6, 15, 7*mmsize*ARCH_X86_32, dst, src, dststride, srcstride, offset, left
diff --git a/libavcodec/x86/hevcdsp.h b/libavcodec/x86/hevcdsp.h
index 24e35bc032..037519fad4 100644
--- a/libavcodec/x86/hevcdsp.h
+++ b/libavcodec/x86/hevcdsp.h
@@ -38,11 +38,11 @@ dst ## _bi_w[idx1][idx2][idx3] = ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##
 
 
 #define PEL_PROTOTYPE(name, D, opt) \
-void ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); \
-void ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width); \
-void ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width); \
-void ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width); \
-void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width)
+void ff_hevc_put_hevc_ ## name ## _ ## D ## _##opt(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); \
+void ff_hevc_put_hevc_bi_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_uni_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_uni_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width); \
+void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width)
 
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -71,8 +71,8 @@ void ff_hevc_put_hevc_bi_w_ ## name ## _ ## D ## _##opt(uint8_t *_dst, ptrdiff_t
         PEL_PROTOTYPE(fname##64, bitd, opt)
 
 #define WEIGHTING_PROTOTYPE(width, bitd, opt) \
-void ff_hevc_put_hevc_uni_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int height, int denom,  int _wx, int _ox); \
-void ff_hevc_put_hevc_bi_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, int16_t *_src, int16_t *_src2, int height, int denom,  int _wx0,  int _wx1, int _ox0, int _ox1)
+void ff_hevc_put_hevc_uni_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, const int16_t *_src, int height, int denom,  int _wx, int _ox); \
+void ff_hevc_put_hevc_bi_w##width##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, const int16_t *_src, const int16_t *_src2, int height, int denom,  int _wx0,  int _wx1, int _ox0, int _ox1)
 
 #define WEIGHTING_PROTOTYPES(bitd, opt) \
         WEIGHTING_PROTOTYPE(2, bitd, opt); \
@@ -94,38 +94,38 @@ EPEL_PROTOTYPES(pel_pixels ,  8, sse4);
 EPEL_PROTOTYPES(pel_pixels , 10, sse4);
 EPEL_PROTOTYPES(pel_pixels , 12, sse4);
 
-void ff_hevc_put_hevc_pel_pixels16_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels24_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels32_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels48_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels64_8_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels16_8_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels24_8_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels32_8_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels48_8_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels64_8_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
 
-void ff_hevc_put_hevc_pel_pixels16_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels24_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels32_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels48_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_pel_pixels64_10_avx2(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels16_10_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels24_10_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels32_10_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels48_10_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_pel_pixels64_10_avx2(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
 
 
 
-void ff_hevc_put_hevc_uni_pel_pixels32_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_uni_pel_pixels48_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_uni_pel_pixels64_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
-void ff_hevc_put_hevc_uni_pel_pixels96_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); //used for 10bit
-void ff_hevc_put_hevc_uni_pel_pixels128_8_avx2(uint8_t *dst, ptrdiff_t dststride,uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);//used for 10bit
+void ff_hevc_put_hevc_uni_pel_pixels32_8_avx2(uint8_t *dst, ptrdiff_t dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_uni_pel_pixels48_8_avx2(uint8_t *dst, ptrdiff_t dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_uni_pel_pixels64_8_avx2(uint8_t *dst, ptrdiff_t dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);
+void ff_hevc_put_hevc_uni_pel_pixels96_8_avx2(uint8_t *dst, ptrdiff_t dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width); //used for 10bit
+void ff_hevc_put_hevc_uni_pel_pixels128_8_avx2(uint8_t *dst, ptrdiff_t dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my,int width);//used for 10bit
 
 
-void ff_hevc_put_hevc_bi_pel_pixels16_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels24_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels32_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels48_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels64_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels16_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels24_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels32_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels48_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels64_8_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
 
-void ff_hevc_put_hevc_bi_pel_pixels16_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels24_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels32_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels48_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_bi_pel_pixels64_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels16_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels24_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels32_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels48_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_bi_pel_pixels64_10_avx2(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2, int height, intptr_t mx, intptr_t my, int width);
 
 ///////////////////////////////////////////////////////////////////////////////
 // EPEL
@@ -233,34 +233,34 @@ WEIGHTING_PROTOTYPES(8, sse4);
 WEIGHTING_PROTOTYPES(10, sse4);
 WEIGHTING_PROTOTYPES(12, sse4);
 
-void ff_hevc_put_hevc_qpel_h4_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h8_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h16_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h32_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_h64_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
-void ff_hevc_put_hevc_qpel_hv8_8_avx512icl(int16_t *dst, uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h4_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h8_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h16_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h32_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_h64_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
+void ff_hevc_put_hevc_qpel_hv8_8_avx512icl(int16_t *dst, const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t mx, intptr_t my, int width);
 
 ///////////////////////////////////////////////////////////////////////////////
 // TRANSFORM_ADD
 ///////////////////////////////////////////////////////////////////////////////
 
-void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_8_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_16_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_32_8_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_8_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_16_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_32_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
-void ff_hevc_add_residual_8_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_16_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_32_8_avx(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_8_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_16_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_32_8_avx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
-void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
-void ff_hevc_add_residual_4_10_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_8_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_16_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_32_10_sse2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_4_10_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_8_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_16_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_32_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
-void ff_hevc_add_residual_16_10_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
-void ff_hevc_add_residual_32_10_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_16_10_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
+void ff_hevc_add_residual_32_10_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
 
 #endif // AVCODEC_X86_HEVCDSP_H
diff --git a/libavcodec/x86/hevcdsp_init.c b/libavcodec/x86/hevcdsp_init.c
index f7a5b28bec..6f45e5e0db 100644
--- a/libavcodec/x86/hevcdsp_init.c
+++ b/libavcodec/x86/hevcdsp_init.c
@@ -29,10 +29,10 @@
 #include "libavcodec/x86/hevcdsp.h"
 
 #define LFC_FUNC(DIR, DEPTH, OPT) \
-void ff_hevc_ ## DIR ## _loop_filter_chroma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, int *tc, uint8_t *no_p, uint8_t *no_q);
+void ff_hevc_ ## DIR ## _loop_filter_chroma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, const int *tc, const uint8_t *no_p, const uint8_t *no_q);
 
 #define LFL_FUNC(DIR, DEPTH, OPT) \
-void ff_hevc_ ## DIR ## _loop_filter_luma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, int beta, int *tc, uint8_t *no_p, uint8_t *no_q);
+void ff_hevc_ ## DIR ## _loop_filter_luma_ ## DEPTH ## _ ## OPT(uint8_t *pix, ptrdiff_t stride, int beta, const int *tc, const uint8_t *no_p, const uint8_t *no_q);
 
 #define LFC_FUNCS(type, depth, opt) \
     LFC_FUNC(h, depth, opt)  \
@@ -85,46 +85,42 @@ IDCT_FUNCS(avx)
 
 #define mc_rep_func(name, bitd, step, W, opt) \
 void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *_dst,                                                 \
-                                                uint8_t *_src, ptrdiff_t _srcstride, int height,                \
+                                                 const uint8_t *_src, ptrdiff_t _srcstride, int height,         \
                                                 intptr_t mx, intptr_t my, int width)                            \
 {                                                                                                               \
     int i;                                                                                                      \
-    uint8_t *src;                                                                                               \
     int16_t *dst;                                                                                               \
     for (i = 0; i < W; i += step) {                                                                             \
-        src  = _src + (i * ((bitd + 7) / 8));                                                                   \
+        const uint8_t *src  = _src + (i * ((bitd + 7) / 8));                                                    \
         dst = _dst + i;                                                                                         \
         ff_hevc_put_hevc_##name##step##_##bitd##_##opt(dst, src, _srcstride, height, mx, my, width);            \
     }                                                                                                           \
 }
 #define mc_rep_uni_func(name, bitd, step, W, opt) \
 void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride,                        \
-                                                    uint8_t *_src, ptrdiff_t _srcstride, int height,            \
+                                                     const uint8_t *_src, ptrdiff_t _srcstride, int height,     \
                                                     intptr_t mx, intptr_t my, int width)                        \
 {                                                                                                               \
     int i;                                                                                                      \
-    uint8_t *src;                                                                                               \
     uint8_t *dst;                                                                                               \
     for (i = 0; i < W; i += step) {                                                                             \
-        src = _src + (i * ((bitd + 7) / 8));                                                                    \
+        const uint8_t *src = _src + (i * ((bitd + 7) / 8));                                                     \
         dst = _dst + (i * ((bitd + 7) / 8));                                                                    \
         ff_hevc_put_hevc_uni_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride,                     \
                                                           height, mx, my, width);                               \
     }                                                                                                           \
 }
 #define mc_rep_bi_func(name, bitd, step, W, opt) \
-void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, uint8_t *_src,          \
-                                                   ptrdiff_t _srcstride, int16_t* _src2,                        \
+void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, const uint8_t *_src,    \
+                                                    ptrdiff_t _srcstride, const int16_t *_src2,                 \
                                                    int height, intptr_t mx, intptr_t my, int width)             \
 {                                                                                                               \
     int i;                                                                                                      \
-    uint8_t  *src;                                                                                              \
     uint8_t  *dst;                                                                                              \
-    int16_t  *src2;                                                                                             \
     for (i = 0; i < W ; i += step) {                                                                            \
-        src  = _src + (i * ((bitd + 7) / 8));                                                                   \
+        const uint8_t *src  = _src + (i * ((bitd + 7) / 8));                                                    \
+        const int16_t *src2 = _src2 + i;                                                                        \
         dst  = _dst + (i * ((bitd + 7) / 8));                                                                   \
-        src2 = _src2 + i;                                                                                       \
         ff_hevc_put_hevc_bi_##name##step##_##bitd##_##opt(dst, dststride, src, _srcstride, src2,                \
                                                           height, mx, my, width);                               \
     }                                                                                                           \
@@ -137,7 +133,7 @@ void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dst
 
 #define mc_rep_func2(name, bitd, step1, step2, W, opt) \
 void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *dst,                                                  \
-                                                 uint8_t *src, ptrdiff_t _srcstride, int height,                \
+                                                 const uint8_t *src, ptrdiff_t _srcstride, int height,          \
                                                  intptr_t mx, intptr_t my, int width)                           \
 {                                                                                                               \
     ff_hevc_put_hevc_##name##step1##_##bitd##_##opt(dst, src, _srcstride, height, mx, my, width);               \
@@ -146,7 +142,7 @@ void ff_hevc_put_hevc_##name##W##_##bitd##_##opt(int16_t *dst,
 }
 #define mc_rep_uni_func2(name, bitd, step1, step2, W, opt) \
 void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride,                         \
-                                                     uint8_t *src, ptrdiff_t _srcstride, int height,            \
+                                                     const uint8_t *src, ptrdiff_t _srcstride, int height,      \
                                                      intptr_t mx, intptr_t my, int width)                       \
 {                                                                                                               \
     ff_hevc_put_hevc_uni_##name##step1##_##bitd##_##opt(dst, dststride, src, _srcstride, height, mx, my, width);\
@@ -155,8 +151,8 @@ void ff_hevc_put_hevc_uni_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dst
                                                         height, mx, my, width);                                 \
 }
 #define mc_rep_bi_func2(name, bitd, step1, step2, W, opt) \
-void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, uint8_t *src,            \
-                                                    ptrdiff_t _srcstride, int16_t* src2,                        \
+void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src,      \
+                                                    ptrdiff_t _srcstride, const int16_t *src2,                  \
                                                     int height, intptr_t mx, intptr_t my, int width)            \
 {                                                                                                               \
     ff_hevc_put_hevc_bi_##name##step1##_##bitd##_##opt(dst, dststride, src, _srcstride, src2, height, mx, my, width);\
@@ -173,7 +169,7 @@ void ff_hevc_put_hevc_bi_##name##W##_##bitd##_##opt(uint8_t *dst, ptrdiff_t dsts
 #if ARCH_X86_64 && HAVE_SSE4_EXTERNAL
 
 #define mc_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                       \
-void ff_hevc_put_hevc_##name##width1##_10_##opt1(int16_t *dst, uint8_t *src, ptrdiff_t _srcstride,            \
+void ff_hevc_put_hevc_##name##width1##_10_##opt1(int16_t *dst, const uint8_t *src, ptrdiff_t _srcstride,      \
                                                  int height, intptr_t mx, intptr_t my, int width)             \
                                                                                                               \
 {                                                                                                             \
@@ -182,8 +178,8 @@ void ff_hevc_put_hevc_##name##width1##_10_##opt1(int16_t *dst, uint8_t *src, ptr
 }
 
 #define mc_bi_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                    \
-void ff_hevc_put_hevc_bi_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dststride, uint8_t *src,          \
-                                                    ptrdiff_t _srcstride, int16_t *src2,                      \
+void ff_hevc_put_hevc_bi_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src,    \
+                                                    ptrdiff_t _srcstride, const int16_t *src2,                \
                                                     int height, intptr_t mx, intptr_t my, int width)          \
 {                                                                                                             \
     ff_hevc_put_hevc_bi_##name##width2##_10_##opt1(dst, dststride, src, _srcstride, src2,                     \
@@ -194,7 +190,7 @@ void ff_hevc_put_hevc_bi_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dsts
 
 #define mc_uni_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)                                   \
 void ff_hevc_put_hevc_uni_##name##width1##_10_##opt1(uint8_t *dst, ptrdiff_t dststride,                       \
-                                                     uint8_t *src, ptrdiff_t _srcstride, int height,          \
+                                                     const uint8_t *src, ptrdiff_t _srcstride, int height,    \
                                                      intptr_t mx, intptr_t my, int width)                     \
 {                                                                                                             \
     ff_hevc_put_hevc_uni_##name##width2##_10_##opt1(dst, dststride, src, _srcstride,                          \
@@ -209,7 +205,7 @@ mc_bi_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)         \
 mc_uni_rep_mix_10(name, width1, width2, width3, opt1, opt2, width4)
 
 #define mc_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                                \
-void ff_hevc_put_hevc_##name##width1##_8_##opt1(int16_t *dst, uint8_t *src, ptrdiff_t _srcstride,             \
+void ff_hevc_put_hevc_##name##width1##_8_##opt1(int16_t *dst, const uint8_t *src, ptrdiff_t _srcstride,       \
                                                 int height, intptr_t mx, intptr_t my, int width)              \
                                                                                                               \
 {                                                                                                             \
@@ -218,8 +214,8 @@ void ff_hevc_put_hevc_##name##width1##_8_##opt1(int16_t *dst, uint8_t *src, ptrd
 }
 
 #define mc_bi_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                             \
-void ff_hevc_put_hevc_bi_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dststride, uint8_t *src,           \
-                                                   ptrdiff_t _srcstride, int16_t* src2,                       \
+void ff_hevc_put_hevc_bi_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src,     \
+                                                   ptrdiff_t _srcstride, const int16_t *src2,                 \
                                                    int height, intptr_t mx, intptr_t my, int width)           \
 {                                                                                                             \
     ff_hevc_put_hevc_bi_##name##width2##_8_##opt1(dst, dststride, src, _srcstride,                            \
@@ -230,7 +226,7 @@ void ff_hevc_put_hevc_bi_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dstst
 
 #define mc_uni_rep_mix_8(name, width1, width2, width3, opt1, opt2)                                            \
 void ff_hevc_put_hevc_uni_##name##width1##_8_##opt1(uint8_t *dst, ptrdiff_t dststride,                        \
-                                                    uint8_t *src, ptrdiff_t _srcstride, int height,           \
+                                                    const uint8_t *src, ptrdiff_t _srcstride, int height,     \
                                                     intptr_t mx, intptr_t my, int width)                      \
 {                                                                                                             \
     ff_hevc_put_hevc_uni_##name##width2##_8_##opt1(dst, dststride, src, _srcstride,                           \
@@ -434,14 +430,13 @@ mc_rep_funcs(qpel_hv,12,  8, 16, sse4)
 mc_rep_funcs(qpel_hv,12,  4, 12, sse4)
 
 #define mc_rep_uni_w(bitd, step, W, opt) \
-void ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, \
+void ff_hevc_put_hevc_uni_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, const int16_t *_src, \
                                                int height, int denom,  int _wx, int _ox)                                \
 {                                                                                                                       \
     int i;                                                                                                              \
-    int16_t *src;                                                                                                       \
     uint8_t *dst;                                                                                                       \
     for (i = 0; i < W; i += step) {                                                                                     \
-        src= _src + i;                                                                                                  \
+        const int16_t *src = _src + i;                                                                                  \
         dst= _dst + (i * ((bitd + 7) / 8));                                                                             \
         ff_hevc_put_hevc_uni_w##step##_##bitd##_##opt(dst, dststride, src,                                   \
                                                      height, denom, _wx, _ox);                                          \
@@ -470,17 +465,15 @@ mc_rep_uni_w(12, 8, 48, sse4)
 mc_rep_uni_w(12, 8, 64, sse4)
 
 #define mc_rep_bi_w(bitd, step, W, opt) \
-void ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, int16_t *_src, \
-                                              int16_t *_src2, int height,                                               \
+void ff_hevc_put_hevc_bi_w##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t dststride, const int16_t *_src, \
+                                               const int16_t *_src2, int height,                                        \
                                               int denom,  int _wx0,  int _wx1, int _ox0, int _ox1)                      \
 {                                                                                                                       \
     int i;                                                                                                              \
-    int16_t *src;                                                                                                       \
-    int16_t *src2;                                                                                                      \
     uint8_t *dst;                                                                                                       \
     for (i = 0; i < W; i += step) {                                                                                     \
-        src  = _src  + i;                                                                                               \
-        src2 = _src2 + i;                                                                                               \
+        const int16_t *src  = _src  + i;                                                                                \
+        const int16_t *src2 = _src2 + i;                                                                                \
         dst  = _dst  + (i * ((bitd + 7) / 8));                                                                          \
         ff_hevc_put_hevc_bi_w##step##_##bitd##_##opt(dst, dststride, src, src2,                             \
                                                      height, denom, _wx0, _wx1, _ox0, _ox1);                             \
@@ -510,7 +503,7 @@ mc_rep_bi_w(12, 8, 64, sse4)
 
 #define mc_uni_w_func(name, bitd, W, opt) \
 void ff_hevc_put_hevc_uni_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride,         \
-                                                      uint8_t *_src, ptrdiff_t _srcstride,          \
+                                                       const uint8_t *_src, ptrdiff_t _srcstride,   \
                                                       int height, int denom,                        \
                                                       int _wx, int _ox,                             \
                                                       intptr_t mx, intptr_t my, int width)          \
@@ -568,8 +561,8 @@ mc_uni_w_funcs(qpel_hv, 12, sse4)
 
 #define mc_bi_w_func(name, bitd, W, opt) \
 void ff_hevc_put_hevc_bi_w_##name##W##_##bitd##_##opt(uint8_t *_dst, ptrdiff_t _dststride,           \
-                                                     uint8_t *_src, ptrdiff_t _srcstride,            \
-                                                     int16_t *_src2,                                 \
+                                                      const uint8_t *_src, ptrdiff_t _srcstride,     \
+                                                      const int16_t *_src2,                          \
                                                      int height, int denom,                          \
                                                      int _wx0, int _wx1, int _ox0, int _ox1,         \
                                                      intptr_t mx, intptr_t my, int width)            \
@@ -628,16 +621,16 @@ mc_bi_w_funcs(qpel_hv, 12, sse4)
 #endif //ARCH_X86_64 && HAVE_SSE4_EXTERNAL
 
 #define SAO_BAND_FILTER_FUNCS(bitd, opt)                                                                                   \
-void ff_hevc_sao_band_filter_8_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,  \
-                                            int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
-void ff_hevc_sao_band_filter_16_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
-                                            int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
-void ff_hevc_sao_band_filter_32_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
-                                            int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
-void ff_hevc_sao_band_filter_48_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
-                                            int16_t *sao_offset_val, int sao_left_class, int width, int height);           \
-void ff_hevc_sao_band_filter_64_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
-                                             int16_t *sao_offset_val, int sao_left_class, int width, int height);
+void ff_hevc_sao_band_filter_8_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,  \
+                                              const int16_t *sao_offset_val, int sao_left_class, int width, int height);         \
+void ff_hevc_sao_band_filter_16_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
+                                               const int16_t *sao_offset_val, int sao_left_class, int width, int height);        \
+void ff_hevc_sao_band_filter_32_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
+                                               const int16_t *sao_offset_val, int sao_left_class, int width, int height);        \
+void ff_hevc_sao_band_filter_48_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
+                                               const int16_t *sao_offset_val, int sao_left_class, int width, int height);        \
+void ff_hevc_sao_band_filter_64_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \
+                                               const int16_t *sao_offset_val, int sao_left_class, int width, int height);
 
 SAO_BAND_FILTER_FUNCS(8,  sse2)
 SAO_BAND_FILTER_FUNCS(10, sse2)
@@ -657,17 +650,17 @@ SAO_BAND_FILTER_FUNCS(12, avx2)
     c->sao_band_filter[4]      = ff_hevc_sao_band_filter_64_##bitd##_##opt; \
 } while (0)
 
-#define SAO_EDGE_FILTER_FUNCS(bitd, opt)                                                                                    \
-void ff_hevc_sao_edge_filter_8_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val,  \
-                                              int eo, int width, int height);                                               \
-void ff_hevc_sao_edge_filter_16_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
-                                               int eo, int width, int height);                                              \
-void ff_hevc_sao_edge_filter_32_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
-                                               int eo, int width, int height);                                              \
-void ff_hevc_sao_edge_filter_48_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
-                                               int eo, int width, int height);                                              \
-void ff_hevc_sao_edge_filter_64_##bitd##_##opt(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst, int16_t *sao_offset_val, \
-                                               int eo, int width, int height);                                              \
+#define SAO_EDGE_FILTER_FUNCS(bitd, opt)                                                                      \
+void ff_hevc_sao_edge_filter_8_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst,       \
+                                              const int16_t *sao_offset_val, int eo, int width, int height);  \
+void ff_hevc_sao_edge_filter_16_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst,      \
+                                               const int16_t *sao_offset_val, int eo, int width, int height); \
+void ff_hevc_sao_edge_filter_32_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst,      \
+                                               const int16_t *sao_offset_val, int eo, int width, int height); \
+void ff_hevc_sao_edge_filter_48_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst,      \
+                                               const int16_t *sao_offset_val, int eo, int width, int height); \
+void ff_hevc_sao_edge_filter_64_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst,      \
+                                               const int16_t *sao_offset_val, int eo, int width, int height); \
 
 SAO_EDGE_FILTER_FUNCS(8, ssse3)
 SAO_EDGE_FILTER_FUNCS(8, avx2)
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 02/39] avcodec/hevcdec: Constify src pointers of HEVC DSP functions
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 03/39] avcodec/threadframe: Constify the frame in ff_thread_await_progress Andreas Rheinhardt
                   ` (36 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is possible now that the HEVC DSP API treats them as const.
Also constify the AVFrames whose data is used as source in such
cases.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/hevcdec.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0421db201e..ea196b39a9 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1205,7 +1205,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                         ptrdiff_t stride = s->frame->linesize[1];
                         int hshift = s->ps.sps->hshift[1];
                         int vshift = s->ps.sps->vshift[1];
-                        int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
+                        const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
                         int16_t *coeffs   = (int16_t*)lc->edge_emu_buffer2;
                         int size = 1 << log2_trafo_size_c;
 
@@ -1235,7 +1235,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
                         ptrdiff_t stride = s->frame->linesize[2];
                         int hshift = s->ps.sps->hshift[2];
                         int vshift = s->ps.sps->vshift[2];
-                        int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
+                        const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer;
                         int16_t *coeffs   = (int16_t*)lc->edge_emu_buffer2;
                         int size = 1 << log2_trafo_size_c;
 
@@ -1499,11 +1499,11 @@ static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size
  */
 
 static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
-                        AVFrame *ref, const Mv *mv, int x_off, int y_off,
+                        const AVFrame *ref, const Mv *mv, int x_off, int y_off,
                         int block_w, int block_h, int luma_weight, int luma_offset)
 {
     const HEVCContext *const s = lc->parent;
-    uint8_t *src         = ref->data[0];
+    const uint8_t *src   = ref->data[0];
     ptrdiff_t srcstride  = ref->linesize[0];
     int pic_width        = s->ps.sps->width;
     int pic_height       = s->ps.sps->height;
@@ -1560,8 +1560,9 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
  * @param current_mv current motion vector structure
  */
  static void luma_mc_bi(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
-                       AVFrame *ref0, const Mv *mv0, int x_off, int y_off,
-                       int block_w, int block_h, AVFrame *ref1, const Mv *mv1, struct MvField *current_mv)
+                        const AVFrame *ref0, const Mv *mv0, int x_off, int y_off,
+                        int block_w, int block_h, const AVFrame *ref1,
+                        const Mv *mv1, struct MvField *current_mv)
 {
     const HEVCContext *const s = lc->parent;
     ptrdiff_t src0stride  = ref0->linesize[0];
@@ -1580,8 +1581,8 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
     int y_off1           = y_off + (mv1->y >> 2);
     int idx              = hevc_pel_weight[block_w];
 
-    uint8_t *src0  = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift);
-    uint8_t *src1  = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift);
+    const uint8_t *src0  = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift);
+    const uint8_t *src1  = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift);
 
     if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER ||
         x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER ||
@@ -1651,7 +1652,7 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride,
  */
 
 static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
-                          ptrdiff_t dststride, uint8_t *src0, ptrdiff_t srcstride, int reflist,
+                          ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist,
                           int x_off, int y_off, int block_w, int block_h,
                           const struct MvField *current_mv, int chroma_weight, int chroma_offset)
 {
@@ -1716,12 +1717,13 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0,
  * @param current_mv current motion vector structure
  * @param cidx chroma component(cb, cr)
  */
-static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststride, AVFrame *ref0, AVFrame *ref1,
+static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststride,
+                         const AVFrame *ref0, const AVFrame *ref1,
                          int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx)
 {
     const HEVCContext *const s = lc->parent;
-    uint8_t *src1        = ref0->data[cidx+1];
-    uint8_t *src2        = ref1->data[cidx+1];
+    const uint8_t *src1  = ref0->data[cidx+1];
+    const uint8_t *src2  = ref1->data[cidx+1];
     ptrdiff_t src1stride = ref0->linesize[cidx+1];
     ptrdiff_t src2stride = ref1->linesize[cidx+1];
     int weight_flag      = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) ||
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 03/39] avcodec/threadframe: Constify the frame in ff_thread_await_progress
  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 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 04/39] avcodec: Constify ThreadFrames if possible Andreas Rheinhardt
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

It is safe to call it on a const ThreadFrame*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pthread_frame.c | 2 +-
 libavcodec/threadframe.h   | 2 +-
 libavcodec/utils.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 8faea75a49..a54d16fee4 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -615,7 +615,7 @@ void ff_thread_report_progress(ThreadFrame *f, int n, int field)
     pthread_mutex_unlock(&p->progress_mutex);
 }
 
-void ff_thread_await_progress(ThreadFrame *f, int n, int field)
+void ff_thread_await_progress(const ThreadFrame *f, int n, int field)
 {
     PerThreadContext *p;
     atomic_int *progress = f->progress ? (atomic_int*)f->progress->data : NULL;
diff --git a/libavcodec/threadframe.h b/libavcodec/threadframe.h
index dea4dadc6d..100e068e06 100644
--- a/libavcodec/threadframe.h
+++ b/libavcodec/threadframe.h
@@ -56,7 +56,7 @@ void ff_thread_report_progress(ThreadFrame *f, int progress, int field);
  * @param field The field being referenced, for field-picture codecs.
  * 0 for top field or frame pictures, 1 for bottom field.
  */
-void ff_thread_await_progress(ThreadFrame *f, int progress, int field);
+void ff_thread_await_progress(const ThreadFrame *f, int progress, int field);
 
 /**
  * Wrapper around ff_get_buffer() for frame-multithreaded codecs.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index cae61d80ff..e73e3a7d08 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -949,7 +949,7 @@ void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
 {
 }
 
-void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
+void ff_thread_await_progress(const ThreadFrame *f, int progress, int field)
 {
 }
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 04/39] avcodec: Constify ThreadFrames if possible
  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 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target Andreas Rheinhardt
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is possible now that ff_thread_await_progress() accepts
a const ThreadFrame*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_slice.c      | 2 +-
 libavcodec/hevc_mvs.c        | 2 +-
 libavcodec/hevcdec.c         | 4 ++--
 libavcodec/rv34.c            | 2 +-
 libavcodec/vp3.c             | 2 +-
 libavcodec/vp8.c             | 9 +++++----
 libavcodec/vp9_mc_template.c | 4 ++--
 libavcodec/vp9recon.c        | 8 ++++----
 8 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index d56722a5c2..8f9d0a6231 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1649,7 +1649,7 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
 
     while (h->poc.frame_num != h->poc.prev_frame_num && !h->first_field &&
            h->poc.frame_num != (h->poc.prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) {
-        H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
+        const H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
         av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n",
                h->poc.frame_num, h->poc.prev_frame_num);
         if (!sps->gaps_in_frame_num_allowed_flag)
diff --git a/libavcodec/hevc_mvs.c b/libavcodec/hevc_mvs.c
index bcf6ec3abc..c231797a57 100644
--- a/libavcodec/hevc_mvs.c
+++ b/libavcodec/hevc_mvs.c
@@ -227,7 +227,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, int x0, int y0,
     int availableFlagLXCol = 0;
     int colPic;
 
-    HEVCFrame *ref = s->ref->collocated_ref;
+    const HEVCFrame *ref = s->ref->collocated_ref;
 
     if (!ref) {
         memset(mvLXCol, 0, sizeof(*mvLXCol));
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ea196b39a9..24da690e94 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1808,7 +1808,7 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid
                                                          _mx1, _my1, block_w);
 }
 
-static void hevc_await_progress(const HEVCContext *s, HEVCFrame *ref,
+static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref,
                                 const Mv *mv, int y0, int height)
 {
     if (s->threads_type == FF_THREAD_FRAME ) {
@@ -1878,7 +1878,7 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0,
 
     MvField *tab_mvf = s->ref->tab_mvf;
     const RefPicList *refPicList = s->ref->refPicList;
-    HEVCFrame *ref0 = NULL, *ref1 = NULL;
+    const HEVCFrame *ref0 = NULL, *ref1 = NULL;
     uint8_t *dst0 = POS(0, x0, y0);
     uint8_t *dst1 = POS(1, x0, y0);
     uint8_t *dst2 = POS(2, x0, y0);
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 5f3b7d31cd..2ac3f2c7b2 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -703,7 +703,7 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type,
     if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) {
         /* wait for the referenced mb row to be finished */
         int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4);
-        ThreadFrame *f = dir ? &s->next_picture_ptr->tf : &s->last_picture_ptr->tf;
+        const ThreadFrame *f = dir ? &s->next_picture_ptr->tf : &s->last_picture_ptr->tf;
         ff_thread_await_progress(f, mb_row, 0);
     }
 
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 53fc514788..3f6b0100d9 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -1950,7 +1950,7 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
 static void await_reference_row(Vp3DecodeContext *s, Vp3Fragment *fragment,
                                 int motion_y, int y)
 {
-    ThreadFrame *ref_frame;
+    const ThreadFrame *ref_frame;
     int ref_row;
     int border = motion_y & 1;
 
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index 10de962118..e474fc5de5 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -1247,7 +1247,7 @@ void decode_intra4x4_modes(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
 static av_always_inline
 void decode_mb_mode(VP8Context *s, VP8mvbounds *mv_bounds,
                     VP8Macroblock *mb, int mb_x, int mb_y,
-                    uint8_t *segment, uint8_t *ref, int layout, int is_vp7)
+                    uint8_t *segment, const uint8_t *ref, int layout, int is_vp7)
 {
     VP56RangeCoder *c = &s->c;
     static const char * const vp7_feature_name[] = { "q-index",
@@ -1811,7 +1811,7 @@ static const uint8_t subpel_idx[3][8] = {
  */
 static av_always_inline
 void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
-                 ThreadFrame *ref, const VP56mv *mv,
+                 const ThreadFrame *ref, const VP56mv *mv,
                  int x_off, int y_off, int block_w, int block_h,
                  int width, int height, ptrdiff_t linesize,
                  vp8_mc_func mc_func[3][3])
@@ -1869,7 +1869,7 @@ void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
  */
 static av_always_inline
 void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1,
-                   uint8_t *dst2, ThreadFrame *ref, const VP56mv *mv,
+                   uint8_t *dst2, const ThreadFrame *ref, const VP56mv *mv,
                    int x_off, int y_off, int block_w, int block_h,
                    int width, int height, ptrdiff_t linesize,
                    vp8_mc_func mc_func[3][3])
@@ -2374,7 +2374,8 @@ static av_always_inline int decode_mb_row_no_filter(AVCodecContext *avctx, void
     int mb_y = atomic_load(&td->thread_mb_pos) >> 16;
     int mb_x, mb_xy = mb_y * s->mb_width;
     int num_jobs = s->num_jobs;
-    VP8Frame *curframe = s->curframe, *prev_frame = s->prev_frame;
+    const VP8Frame *prev_frame = s->prev_frame;
+    VP8Frame *curframe = s->curframe;
     VP56RangeCoder *c  = &s->coeff_partition[mb_y & (s->num_coeff_partitions - 1)];
     VP8Macroblock *mb;
     uint8_t *dst[3] = {
diff --git a/libavcodec/vp9_mc_template.c b/libavcodec/vp9_mc_template.c
index 31e692f362..d0c12e81f1 100644
--- a/libavcodec/vp9_mc_template.c
+++ b/libavcodec/vp9_mc_template.c
@@ -36,8 +36,8 @@ static void FN(inter_pred)(VP9TileData *td)
     VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col;
-    ThreadFrame *tref1 = &s->s.refs[s->s.h.refidx[b->ref[0]]], *tref2;
-    AVFrame *ref1 = tref1->f, *ref2;
+    const ThreadFrame *tref1 = &s->s.refs[s->s.h.refidx[b->ref[0]]], *tref2;
+    const AVFrame *ref1 = tref1->f, *ref2;
     int w1 = ref1->width, h1 = ref1->height, w2, h2;
     ptrdiff_t ls_y = td->y_stride, ls_uv = td->uv_stride;
     int bytesperpixel = BYTES_PER_PIXEL;
diff --git a/libavcodec/vp9recon.c b/libavcodec/vp9recon.c
index bfafde8c9c..1cdbc6a71d 100644
--- a/libavcodec/vp9recon.c
+++ b/libavcodec/vp9recon.c
@@ -298,7 +298,7 @@ void ff_vp9_intra_recon_16bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off
 static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func (*mc)[2],
                                               uint8_t *dst, ptrdiff_t dst_stride,
                                               const uint8_t *ref, ptrdiff_t ref_stride,
-                                              ThreadFrame *ref_frame,
+                                              const ThreadFrame *ref_frame,
                                               ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
                                               int bw, int bh, int w, int h, int bytesperpixel)
 {
@@ -336,7 +336,7 @@ static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*m
                                                 ptrdiff_t dst_stride,
                                                 const uint8_t *ref_u, ptrdiff_t src_stride_u,
                                                 const uint8_t *ref_v, ptrdiff_t src_stride_v,
-                                                ThreadFrame *ref_frame,
+                                                const ThreadFrame *ref_frame,
                                                 ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
                                                 int bw, int bh, int w, int h, int bytesperpixel)
 {
@@ -407,7 +407,7 @@ static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func
                                             vp9_mc_func (*mc)[2],
                                             uint8_t *dst, ptrdiff_t dst_stride,
                                             const uint8_t *ref, ptrdiff_t ref_stride,
-                                            ThreadFrame *ref_frame,
+                                            const ThreadFrame *ref_frame,
                                             ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
                                             int px, int py, int pw, int ph,
                                             int bw, int bh, int w, int h, int bytesperpixel,
@@ -467,7 +467,7 @@ static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_fun
                                               ptrdiff_t dst_stride,
                                               const uint8_t *ref_u, ptrdiff_t src_stride_u,
                                               const uint8_t *ref_v, ptrdiff_t src_stride_v,
-                                              ThreadFrame *ref_frame,
+                                              const ThreadFrame *ref_frame,
                                               ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv,
                                               int px, int py, int pw, int ph,
                                               int bw, int bh, int w, int h, int bytesperpixel,
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (2 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 04/39] avcodec: Constify ThreadFrames if possible Andreas Rheinhardt
@ 2022-07-26 22:07 ` 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
                   ` (33 subsequent siblings)
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is possible now that ff_thread_await_progress() accepts
a const ThreadFrame*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp9_mc_template.c |  2 +-
 libavcodec/vp9block.c        | 30 +++++++++++++++---------------
 libavcodec/vp9dec.h          |  4 +---
 libavcodec/vp9mvs.c          |  6 +++---
 libavcodec/vp9recon.c        | 22 +++++++++++-----------
 5 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/libavcodec/vp9_mc_template.c b/libavcodec/vp9_mc_template.c
index d0c12e81f1..9337edcbdb 100644
--- a/libavcodec/vp9_mc_template.c
+++ b/libavcodec/vp9_mc_template.c
@@ -33,7 +33,7 @@ static void FN(inter_pred)(VP9TileData *td)
         { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
         { 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
     };
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col;
     const ThreadFrame *tref1 = &s->s.refs[s->s.h.refidx[b->ref[0]]], *tref2;
diff --git a/libavcodec/vp9block.c b/libavcodec/vp9block.c
index 5fdda63545..5d498f0a95 100644
--- a/libavcodec/vp9block.c
+++ b/libavcodec/vp9block.c
@@ -87,7 +87,7 @@ static void decode_mode(VP9TileData *td)
         TX_32X32, TX_32X32, TX_32X32, TX_32X32, TX_16X16, TX_16X16,
         TX_16X16, TX_8X8,   TX_8X8,   TX_8X8,   TX_4X4,   TX_4X4,  TX_4X4
     };
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col, row7 = td->row7;
     enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];
@@ -802,9 +802,9 @@ static void decode_mode(VP9TileData *td)
 static av_always_inline int
 decode_coeffs_b_generic(VP56RangeCoder *c, int16_t *coef, int n_coeffs,
                         int is_tx32x32, int is8bitsperpixel, int bpp, unsigned (*cnt)[6][3],
-                        unsigned (*eob)[6][2], uint8_t (*p)[6][11],
+                        unsigned (*eob)[6][2], const uint8_t (*p)[6][11],
                         int nnz, const int16_t *scan, const int16_t (*nb)[2],
-                        const int16_t *band_counts, int16_t *qmul)
+                        const int16_t *band_counts, const int16_t *qmul)
 {
     int i = 0, band = 0, band_left = band_counts[band];
     const uint8_t *tp = p[0][nnz];
@@ -921,9 +921,9 @@ skip_eob:
 
 static int decode_coeffs_b_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
                                 unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
-                                uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+                                const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
                                 const int16_t (*nb)[2], const int16_t *band_counts,
-                                int16_t *qmul)
+                                const int16_t *qmul)
 {
     return decode_coeffs_b_generic(td->c, coef, n_coeffs, 0, 1, 8, cnt, eob, p,
                                    nnz, scan, nb, band_counts, qmul);
@@ -931,9 +931,9 @@ static int decode_coeffs_b_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
 
 static int decode_coeffs_b32_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
                                   unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
-                                  uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+                                  const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
                                   const int16_t (*nb)[2], const int16_t *band_counts,
-                                  int16_t *qmul)
+                                  const int16_t *qmul)
 {
     return decode_coeffs_b_generic(td->c, coef, n_coeffs, 1, 1, 8, cnt, eob, p,
                                    nnz, scan, nb, band_counts, qmul);
@@ -941,9 +941,9 @@ static int decode_coeffs_b32_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
 
 static int decode_coeffs_b_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
                                  unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
-                                 uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+                                 const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
                                  const int16_t (*nb)[2], const int16_t *band_counts,
-                                 int16_t *qmul)
+                                 const int16_t *qmul)
 {
     return decode_coeffs_b_generic(td->c, coef, n_coeffs, 0, 0, td->s->s.h.bpp, cnt, eob, p,
                                    nnz, scan, nb, band_counts, qmul);
@@ -951,9 +951,9 @@ static int decode_coeffs_b_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
 
 static int decode_coeffs_b32_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
                                    unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
-                                   uint8_t (*p)[6][11], int nnz, const int16_t *scan,
+                                   const uint8_t (*p)[6][11], int nnz, const int16_t *scan,
                                    const int16_t (*nb)[2], const int16_t *band_counts,
-                                   int16_t *qmul)
+                                   const int16_t *qmul)
 {
     return decode_coeffs_b_generic(td->c, coef, n_coeffs, 1, 0, td->s->s.h.bpp, cnt, eob, p,
                                    nnz, scan, nb, band_counts, qmul);
@@ -961,17 +961,17 @@ static int decode_coeffs_b32_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
 
 static av_always_inline int decode_coeffs(VP9TileData *td, int is8bitsperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col;
-    uint8_t (*p)[6][11] = s->prob.coef[b->tx][0 /* y */][!b->intra];
+    const uint8_t (*p)[6][11] = s->prob.coef[b->tx][0 /* y */][!b->intra];
     unsigned (*c)[6][3] = td->counts.coef[b->tx][0 /* y */][!b->intra];
     unsigned (*e)[6][2] = td->counts.eob[b->tx][0 /* y */][!b->intra];
     int w4 = ff_vp9_bwh_tab[1][b->bs][0] << 1, h4 = ff_vp9_bwh_tab[1][b->bs][1] << 1;
     int end_x = FFMIN(2 * (s->cols - col), w4);
     int end_y = FFMIN(2 * (s->rows - row), h4);
     int n, pl, x, y, ret;
-    int16_t (*qmul)[2] = s->s.h.segmentation.feat[b->seg_id].qmul;
+    const int16_t (*qmul)[2] = s->s.h.segmentation.feat[b->seg_id].qmul;
     int tx = 4 * s->s.h.lossless + b->tx;
     const int16_t * const *yscans = ff_vp9_scans[tx];
     const int16_t (* const * ynbs)[2] = ff_vp9_scans_nb[tx];
@@ -1262,7 +1262,7 @@ void ff_vp9_decode_block(VP9TileData *td, int row, int col,
                          VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
                          enum BlockLevel bl, enum BlockPartition bp)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     enum BlockSize bs = bl * 3 + bp;
     int bytesperpixel = s->bytesperpixel;
diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h
index 9cbd5839a8..3621504fc8 100644
--- a/libavcodec/vp9dec.h
+++ b/libavcodec/vp9dec.h
@@ -163,9 +163,7 @@ typedef struct VP9Context {
 } VP9Context;
 
 struct VP9TileData {
-    //VP9Context should be const, but because of the threading API(generates
-    //a lot of warnings) it's not.
-    VP9Context *s;
+    const VP9Context *s;
     VP56RangeCoder *c_b;
     VP56RangeCoder *c;
     int row, row7, col, col7;
diff --git a/libavcodec/vp9mvs.c b/libavcodec/vp9mvs.c
index ddce9b6c84..16a2978035 100644
--- a/libavcodec/vp9mvs.c
+++ b/libavcodec/vp9mvs.c
@@ -65,7 +65,7 @@ static void find_ref_mvs(VP9TileData *td,
         [BS_4x4]   = { {  0, -1 }, { -1,  0 }, { -1, -1 }, {  0, -2 },
                        { -2,  0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
     };
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col, row7 = td->row7;
     const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
@@ -235,7 +235,7 @@ static void find_ref_mvs(VP9TileData *td,
 
 static av_always_inline int read_mv_component(VP9TileData *td, int idx, int hp)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     int bit, sign = vp56_rac_get_prob(td->c, s->prob.p.mv_comp[idx].sign);
     int n, c = vp8_rac_get_tree(td->c, ff_vp9_mv_class_tree,
                                 s->prob.p.mv_comp[idx].classes);
@@ -290,7 +290,7 @@ static av_always_inline int read_mv_component(VP9TileData *td, int idx, int hp)
 
 void ff_vp9_fill_mv(VP9TileData *td, VP56mv *mv, int mode, int sb)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
 
     if (mode == ZEROMV) {
diff --git a/libavcodec/vp9recon.c b/libavcodec/vp9recon.c
index 1cdbc6a71d..da6249f82d 100644
--- a/libavcodec/vp9recon.c
+++ b/libavcodec/vp9recon.c
@@ -36,7 +36,7 @@ static av_always_inline int check_intra_mode(VP9TileData *td, int mode, uint8_t
                                              int row, int y, enum TxfmMode tx,
                                              int p, int ss_h, int ss_v, int bytesperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     int have_top = row > 0 || y > 0;
     int have_left = col > td->tile_col_start || x > 0;
     int have_right = x < w - 1;
@@ -218,7 +218,7 @@ static av_always_inline int check_intra_mode(VP9TileData *td, int mode, uint8_t
 static av_always_inline void intra_recon(VP9TileData *td, ptrdiff_t y_off,
                                          ptrdiff_t uv_off, int bytesperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col;
     int w4 = ff_vp9_bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
@@ -295,14 +295,14 @@ void ff_vp9_intra_recon_16bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off
     intra_recon(td, y_off, uv_off, 2);
 }
 
-static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func (*mc)[2],
+static av_always_inline void mc_luma_unscaled(VP9TileData *td, const vp9_mc_func (*mc)[2],
                                               uint8_t *dst, ptrdiff_t dst_stride,
                                               const uint8_t *ref, ptrdiff_t ref_stride,
                                               const ThreadFrame *ref_frame,
                                               ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
                                               int bw, int bh, int w, int h, int bytesperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     int mx = mv->x, my = mv->y, th;
 
     y += my >> 3;
@@ -331,7 +331,7 @@ static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func (*mc)
     mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
 }
 
-static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*mc)[2],
+static av_always_inline void mc_chroma_unscaled(VP9TileData *td, const vp9_mc_func (*mc)[2],
                                                 uint8_t *dst_u, uint8_t *dst_v,
                                                 ptrdiff_t dst_stride,
                                                 const uint8_t *ref_u, ptrdiff_t src_stride_u,
@@ -340,7 +340,7 @@ static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*m
                                                 ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
                                                 int bw, int bh, int w, int h, int bytesperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     int mx = mv->x * (1 << !s->ss_h), my = mv->y * (1 << !s->ss_v), th;
 
     y += my >> 4;
@@ -404,7 +404,7 @@ static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*m
 #undef SCALED
 
 static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func smc,
-                                            vp9_mc_func (*mc)[2],
+                                            const vp9_mc_func (*mc)[2],
                                             uint8_t *dst, ptrdiff_t dst_stride,
                                             const uint8_t *ref, ptrdiff_t ref_stride,
                                             const ThreadFrame *ref_frame,
@@ -413,7 +413,7 @@ static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func
                                             int bw, int bh, int w, int h, int bytesperpixel,
                                             const uint16_t *scale, const uint8_t *step)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
         s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
         mc_luma_unscaled(td, mc, dst, dst_stride, ref, ref_stride, ref_frame,
@@ -462,7 +462,7 @@ static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func
 }
 
 static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_func smc,
-                                              vp9_mc_func (*mc)[2],
+                                              const vp9_mc_func (*mc)[2],
                                               uint8_t *dst_u, uint8_t *dst_v,
                                               ptrdiff_t dst_stride,
                                               const uint8_t *ref_u, ptrdiff_t src_stride_u,
@@ -473,7 +473,7 @@ static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_fun
                                               int bw, int bh, int w, int h, int bytesperpixel,
                                               const uint16_t *scale, const uint8_t *step)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
         s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
         mc_chroma_unscaled(td, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
@@ -568,7 +568,7 @@ static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_fun
 
 static av_always_inline void inter_recon(VP9TileData *td, int bytesperpixel)
 {
-    VP9Context *s = td->s;
+    const VP9Context *s = td->s;
     VP9Block *b = td->b;
     int row = td->row, col = td->col;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 06/39] avcodec/wavpack: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (3 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: " Andreas Rheinhardt
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually) a data race,
so it must not happen. So only use a pointer to const to access
the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/wavpack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 0e8d1286c2..c12e1d6ec6 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -1616,7 +1616,7 @@ static void wavpack_decode_flush(AVCodecContext *avctx)
 
 static int dsd_channel(AVCodecContext *avctx, void *frmptr, int jobnr, int threadnr)
 {
-    WavpackContext *s  = avctx->priv_data;
+    const WavpackContext *s  = avctx->priv_data;
     AVFrame *frame = frmptr;
 
     ff_dsd2pcm_translate (&s->dsdctx [jobnr], s->samples, 0,
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (4 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-27 10:24   ` Ronald S. Bultje
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 08/39] avcodec/proresdec2: " Andreas Rheinhardt
                   ` (31 subsequent siblings)
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index e474fc5de5..d0c26ba00d 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2582,7 +2582,7 @@ static av_always_inline
 int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int jobnr,
                               int threadnr, int is_vp7)
 {
-    VP8Context *s = avctx->priv_data;
+    const VP8Context *s = avctx->priv_data;
     VP8ThreadData *td = &s->thread_data[jobnr];
     VP8ThreadData *next_td = NULL, *prev_td = NULL;
     VP8Frame *curframe = s->curframe;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 08/39] avcodec/proresdec2: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (5 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 09/39] avcodec/magicyuv: " Andreas Rheinhardt
                   ` (30 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

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

diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c
index 01e650a650..659f9ff16b 100644
--- a/libavcodec/proresdec2.c
+++ b/libavcodec/proresdec2.c
@@ -500,7 +500,7 @@ static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28,
 static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb,
                                              int16_t *out, int blocks_per_slice)
 {
-    ProresContext *ctx = avctx->priv_data;
+    const ProresContext *ctx = avctx->priv_data;
     int block_mask, sign;
     unsigned pos, run, level;
     int max_coeffs, i, bits_left;
@@ -545,7 +545,7 @@ static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice,
                              const uint8_t *buf, unsigned buf_size,
                              const int16_t *qmat)
 {
-    ProresContext *ctx = avctx->priv_data;
+    const ProresContext *ctx = avctx->priv_data;
     LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
     int16_t *block;
     GetBitContext gb;
@@ -611,7 +611,7 @@ static int decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice,
 /**
  * Decode alpha slice plane.
  */
-static void decode_slice_alpha(ProresContext *ctx,
+static void decode_slice_alpha(const ProresContext *ctx,
                                uint16_t *dst, int dst_stride,
                                const uint8_t *buf, int buf_size,
                                int blocks_per_slice)
@@ -643,7 +643,7 @@ static void decode_slice_alpha(ProresContext *ctx,
 
 static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 {
-    ProresContext *ctx = avctx->priv_data;
+    const ProresContext *ctx = avctx->priv_data;
     SliceContext *slice = &ctx->slices[jobnr];
     const uint8_t *buf = slice->data;
     AVFrame *pic = ctx->frame;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 09/39] avcodec/magicyuv: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (6 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 08/39] avcodec/proresdec2: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 10/39] avcodec/jpeg2000dec: " Andreas Rheinhardt
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

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

diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index ae1660eaa3..65dbb6a2f1 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -115,7 +115,7 @@ static void magicyuv_median_pred16(uint16_t *dst, const uint16_t *src1,
 static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
                                int j, int threadnr)
 {
-    MagicYUVContext *s = avctx->priv_data;
+    const MagicYUVContext *s = avctx->priv_data;
     int interlaced = s->interlaced;
     const int bps = s->bps;
     const int max = s->max - 1;
@@ -247,7 +247,7 @@ static int magy_decode_slice10(AVCodecContext *avctx, void *tdata,
 static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
                              int j, int threadnr)
 {
-    MagicYUVContext *s = avctx->priv_data;
+    const MagicYUVContext *s = avctx->priv_data;
     int interlaced = s->interlaced;
     AVFrame *p = s->p;
     int i, k, x, min_width;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 10/39] avcodec/jpeg2000dec: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (7 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 09/39] avcodec/magicyuv: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 11/39] avcodec/dxv: " Andreas Rheinhardt
                   ` (28 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

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

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 4823127758..503753c4d6 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1679,7 +1679,7 @@ static void decode_refpass(Jpeg2000T1Context *t1, int width, int height,
                 }
 }
 
-static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,
+static void decode_clnpass(const Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,
                            int width, int height, int bpno, int bandno,
                            int seg_symbols, int vert_causal_ctx_csty_symbol)
 {
@@ -1745,7 +1745,7 @@ static void decode_clnpass(Jpeg2000DecoderContext *s, Jpeg2000T1Context *t1,
     }
 }
 
-static int decode_cblk(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
+static int decode_cblk(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty,
                        Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk,
                        int width, int height, int bandpos, uint8_t roi_shift)
 {
@@ -1896,7 +1896,7 @@ static void dequantization_int_97(int x, int y, Jpeg2000Cblk *cblk,
     }
 }
 
-static inline void mct_decode(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
+static inline void mct_decode(const Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
 {
     int i, csize = 1;
     void *src[3];
@@ -1937,7 +1937,7 @@ static inline void roi_scale_cblk(Jpeg2000Cblk *cblk,
     }
 }
 
-static inline void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
+static inline void tile_codeblocks(const Jpeg2000DecoderContext *s, Jpeg2000Tile *tile)
 {
     Jpeg2000T1Context t1;
 
@@ -2009,7 +2009,7 @@ static inline void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile
 }
 
 #define WRITE_FRAME(D, PIXEL)                                                                     \
-    static inline void write_frame_ ## D(Jpeg2000DecoderContext * s, Jpeg2000Tile * tile,         \
+    static inline void write_frame_ ## D(const Jpeg2000DecoderContext * s, Jpeg2000Tile * tile,   \
                                          AVFrame * picture, int precision)                        \
     {                                                                                             \
         const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt);               \
@@ -2078,7 +2078,7 @@ WRITE_FRAME(16, uint16_t)
 static int jpeg2000_decode_tile(AVCodecContext *avctx, void *td,
                                 int jobnr, int threadnr)
 {
-    Jpeg2000DecoderContext *s = avctx->priv_data;
+    const Jpeg2000DecoderContext *s = avctx->priv_data;
     AVFrame *picture = td;
     Jpeg2000Tile *tile = s->tile + jobnr;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 11/39] avcodec/dxv: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (8 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 10/39] avcodec/jpeg2000dec: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 12/39] avcodec/dvdec: " Andreas Rheinhardt
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dxv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index b3df00a5d8..2a055a3438 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -193,7 +193,7 @@ static int yao_block(uint8_t *plane0, ptrdiff_t stride0,
 static int decompress_texture_thread(AVCodecContext *avctx, void *arg,
                                      int slice, int thread_nb)
 {
-    DXVContext *ctx = avctx->priv_data;
+    const DXVContext *ctx = avctx->priv_data;
     AVFrame *frame = arg;
     const uint8_t *d = ctx->tex_data;
     int w_block = avctx->coded_width / ctx->texture_block_w;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 12/39] avcodec/dvdec: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (9 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 11/39] avcodec/dxv: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 13/39] avcodec/diracdec: " Andreas Rheinhardt
                   ` (26 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dv.h    | 4 ++--
 libavcodec/dvdec.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/dv.h b/libavcodec/dv.h
index 855afcc758..331b8e846a 100644
--- a/libavcodec/dv.h
+++ b/libavcodec/dv.h
@@ -109,8 +109,8 @@ static inline int dv_work_pool_size(const AVDVProfile *d)
     return size;
 }
 
-static inline void dv_calculate_mb_xy(DVVideoContext *s,
-                                      DVwork_chunk *work_chunk,
+static inline void dv_calculate_mb_xy(const DVVideoContext *s,
+                                      const DVwork_chunk *work_chunk,
                                       int m, int *mb_x, int *mb_y)
 {
     *mb_x = work_chunk->mb_coordinates[m] & 0xff;
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 4760618a97..f7423580aa 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -345,7 +345,7 @@ static av_always_inline void put_block_8x4(int16_t *block, uint8_t *av_restrict
     }
 }
 
-static void dv100_idct_put_last_row_field_chroma(DVVideoContext *s, uint8_t *data,
+static void dv100_idct_put_last_row_field_chroma(const DVVideoContext *s, uint8_t *data,
                                                  int stride, int16_t *blocks)
 {
     s->idsp.idct(blocks + 0*64);
@@ -357,7 +357,7 @@ static void dv100_idct_put_last_row_field_chroma(DVVideoContext *s, uint8_t *dat
     put_block_8x4(blocks+1*64 + 4*8, data + 8 + stride, stride<<1);
 }
 
-static void dv100_idct_put_last_row_field_luma(DVVideoContext *s, uint8_t *data,
+static void dv100_idct_put_last_row_field_luma(const DVVideoContext *s, uint8_t *data,
                                                int stride, int16_t *blocks)
 {
     s->idsp.idct(blocks + 0*64);
@@ -378,7 +378,7 @@ static void dv100_idct_put_last_row_field_luma(DVVideoContext *s, uint8_t *data,
 /* mb_x and mb_y are in units of 8 pixels */
 static int dv_decode_video_segment(AVCodecContext *avctx, void *arg)
 {
-    DVVideoContext *s = avctx->priv_data;
+    const DVVideoContext *s = avctx->priv_data;
     DVwork_chunk *work_chunk = arg;
     int quant, dc, dct_mode, class1, j;
     int mb_index, mb_x, mb_y, last_index;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 13/39] avcodec/diracdec: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (10 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 12/39] avcodec/dvdec: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 14/39] avcodec/half2float: Constify arrays in half2float() Andreas Rheinhardt
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/diracdec.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index d8fdc27b2c..aef6ab20a3 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -486,7 +486,7 @@ UNPACK_ARITH(10, int32_t)
  * Decode the coeffs in the rectangle defined by left, right, top, bottom
  * [DIRAC_STD] 13.4.3.2 Codeblock unpacking loop. codeblock()
  */
-static inline int codeblock(DiracContext *s, SubBand *b,
+static inline int codeblock(const DiracContext *s, SubBand *b,
                              GetBitContext *gb, DiracArith *c,
                              int left, int right, int top, int bottom,
                              int blockcnt_one, int is_arith)
@@ -596,7 +596,8 @@ INTRA_DC_PRED(10, uint32_t)
  * Dirac Specification ->
  * 13.4.2 Non-skipped subbands.  subband_coeffs()
  */
-static av_always_inline int decode_subband_internal(DiracContext *s, SubBand *b, int is_arith)
+static av_always_inline int decode_subband_internal(const DiracContext *s,
+                                                    SubBand *b, int is_arith)
 {
     int cb_x, cb_y, left, right, top, bottom;
     DiracArith c;
@@ -640,13 +641,13 @@ static av_always_inline int decode_subband_internal(DiracContext *s, SubBand *b,
 
 static int decode_subband_arith(AVCodecContext *avctx, void *b)
 {
-    DiracContext *s = avctx->priv_data;
+    const DiracContext *s = avctx->priv_data;
     return decode_subband_internal(s, b, 1);
 }
 
 static int decode_subband_golomb(AVCodecContext *avctx, void *arg)
 {
-    DiracContext *s = avctx->priv_data;
+    const DiracContext *s = avctx->priv_data;
     SubBand **b     = arg;
     return decode_subband_internal(s, *b, 0);
 }
@@ -721,9 +722,9 @@ static int decode_component(DiracContext *s, int comp)
             return; \
     } \
 
-static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
+static void decode_subband(const DiracContext *s, GetBitContext *gb, int quant,
                            int slice_x, int slice_y, int bits_end,
-                           SubBand *b1, SubBand *b2)
+                           const SubBand *b1, const SubBand *b2)
 {
     int left   = b1->width  * slice_x    / s->num_x;
     int right  = b1->width  *(slice_x+1) / s->num_x;
@@ -775,7 +776,7 @@ static void decode_subband(DiracContext *s, GetBitContext *gb, int quant,
  */
 static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg)
 {
-    DiracContext *s = avctx->priv_data;
+    const DiracContext *s = avctx->priv_data;
     DiracSlice *slice = arg;
     GetBitContext *gb = &slice->gb;
     enum dirac_subband orientation;
@@ -819,13 +820,13 @@ typedef struct SliceCoeffs {
     int tot;
 } SliceCoeffs;
 
-static int subband_coeffs(DiracContext *s, int x, int y, int p,
+static int subband_coeffs(const DiracContext *s, int x, int y, int p,
                           SliceCoeffs c[MAX_DWT_LEVELS])
 {
     int level, coef = 0;
     for (level = 0; level < s->wavelet_depth; level++) {
         SliceCoeffs *o = &c[level];
-        SubBand *b = &s->plane[p].band[level][3]; /* orientation doens't matter */
+        const SubBand *b = &s->plane[p].band[level][3]; /* orientation doens't matter */
         o->top   = b->height * y / s->num_y;
         o->left  = b->width  * x / s->num_x;
         o->tot_h = ((b->width  * (x + 1)) / s->num_x) - o->left;
@@ -840,7 +841,7 @@ static int subband_coeffs(DiracContext *s, int x, int y, int p,
  * VC-2 Specification ->
  * 13.5.3 hq_slice(sx,sy)
  */
-static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
+static int decode_hq_slice(const DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
 {
     int i, level, orientation, quant_idx;
     int qfactor[MAX_DWT_LEVELS][4], qoffset[MAX_DWT_LEVELS][4];
@@ -917,7 +918,7 @@ static int decode_hq_slice(DiracContext *s, DiracSlice *slice, uint8_t *tmp_buf)
 static int decode_hq_slice_row(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 {
     int i;
-    DiracContext *s = avctx->priv_data;
+    const DiracContext *s = avctx->priv_data;
     DiracSlice *slices = ((DiracSlice *)arg) + s->num_x*jobnr;
     uint8_t *thread_buf = &s->thread_buf[s->thread_buf_size*threadnr];
     for (i = 0; i < s->num_x; i++)
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 14/39] avcodec/half2float: Constify arrays in half2float()
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (11 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 13/39] avcodec/diracdec: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 15/39] avcodec/exr: Constify slice threads' ptr to main context Andreas Rheinhardt
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/half2float.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/half2float.h b/libavcodec/half2float.h
index fd11caffdf..7df6747e50 100644
--- a/libavcodec/half2float.h
+++ b/libavcodec/half2float.h
@@ -61,8 +61,8 @@ static void half2float_table(uint32_t *mantissatable, uint32_t *exponenttable,
     offsettable[32] = 0;
 }
 
-static uint32_t half2float(uint16_t h, uint32_t *mantissatable, uint32_t *exponenttable,
-                           uint16_t *offsettable)
+static uint32_t half2float(uint16_t h, const uint32_t *mantissatable, const uint32_t *exponenttable,
+                           const uint16_t *offsettable)
 {
     uint32_t f;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 15/39] avcodec/exr: Constify slice threads' ptr to main context
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (12 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 14/39] avcodec/half2float: Constify arrays in half2float() Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 16/39] avcodec/xwdenc: Don't modify input frame Andreas Rheinhardt
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Modifying the main context from a slice thread is (usually)
a data race, so it must not happen. So only use a pointer to const
to access the main context.

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

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index e4b66a08ac..3a6b9c3014 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -196,7 +196,7 @@ typedef struct EXRContext {
     uint16_t offsettable[64];
 } EXRContext;
 
-static int zip_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
+static int zip_uncompress(const EXRContext *s, const uint8_t *src, int compressed_size,
                           int uncompressed_size, EXRThreadData *td)
 {
     unsigned long dest_len = uncompressed_size;
@@ -255,7 +255,7 @@ static int rle(uint8_t *dst, const uint8_t *src,
     return 0;
 }
 
-static int rle_uncompress(EXRContext *ctx, const uint8_t *src, int compressed_size,
+static int rle_uncompress(const EXRContext *ctx, const uint8_t *src, int compressed_size,
                           int uncompressed_size, EXRThreadData *td)
 {
     rle(td->tmp, src, compressed_size, uncompressed_size);
@@ -365,7 +365,7 @@ static int huf_unpack_enc_table(GetByteContext *gb,
     return 0;
 }
 
-static int huf_build_dec_table(EXRContext *s,
+static int huf_build_dec_table(const EXRContext *s,
                                EXRThreadData *td, int im, int iM)
 {
     int j = 0;
@@ -440,7 +440,7 @@ static int huf_decode(VLC *vlc, GetByteContext *gb, int nbits, int run_sym,
     return 0;
 }
 
-static int huf_uncompress(EXRContext *s,
+static int huf_uncompress(const EXRContext *s,
                           EXRThreadData *td,
                           GetByteContext *gb,
                           uint16_t *dst, int dst_size)
@@ -588,7 +588,7 @@ static void wav_decode(uint16_t *in, int nx, int ox,
     }
 }
 
-static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
+static int piz_uncompress(const EXRContext *s, const uint8_t *src, int ssize,
                           int dsize, EXRThreadData *td)
 {
     GetByteContext gb;
@@ -674,7 +674,7 @@ static int piz_uncompress(EXRContext *s, const uint8_t *src, int ssize,
     return 0;
 }
 
-static int pxr24_uncompress(EXRContext *s, const uint8_t *src,
+static int pxr24_uncompress(const EXRContext *s, const uint8_t *src,
                             int compressed_size, int uncompressed_size,
                             EXRThreadData *td)
 {
@@ -809,7 +809,7 @@ static void unpack_3(const uint8_t b[3], uint16_t s[16])
 }
 
 
-static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
+static int b44_uncompress(const EXRContext *s, const uint8_t *src, int compressed_size,
                           int uncompressed_size, EXRThreadData *td) {
     const int8_t *sr = src;
     int stay_to_uncompress = compressed_size;
@@ -833,7 +833,7 @@ static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size
             for (iY = 0; iY < nb_b44_block_h; iY++) {
                 for (iX = 0; iX < nb_b44_block_w; iX++) {/* For each B44 block */
                     if (stay_to_uncompress < 3) {
-                        av_log(s, AV_LOG_ERROR, "Not enough data for B44A block: %d", stay_to_uncompress);
+                        av_log(s->avctx, AV_LOG_ERROR, "Not enough data for B44A block: %d", stay_to_uncompress);
                         return AVERROR_INVALIDDATA;
                     }
 
@@ -843,7 +843,7 @@ static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size
                         stay_to_uncompress -= 3;
                     }  else {/* B44 Block */
                         if (stay_to_uncompress < 14) {
-                            av_log(s, AV_LOG_ERROR, "Not enough data for B44 block: %d", stay_to_uncompress);
+                            av_log(s->avctx, AV_LOG_ERROR, "Not enough data for B44 block: %d", stay_to_uncompress);
                             return AVERROR_INVALIDDATA;
                         }
                         unpack_14(sr, tmp_buffer);
@@ -868,7 +868,7 @@ static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size
             target_channel_offset += 2;
         } else {/* Float or UINT 32 channel */
             if (stay_to_uncompress < td->ysize * td->xsize * 4) {
-                av_log(s, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stay_to_uncompress);
+                av_log(s->avctx, AV_LOG_ERROR, "Not enough data for uncompress channel: %d", stay_to_uncompress);
                 return AVERROR_INVALIDDATA;
             }
 
@@ -886,7 +886,7 @@ static int b44_uncompress(EXRContext *s, const uint8_t *src, int compressed_size
     return 0;
 }
 
-static int ac_uncompress(EXRContext *s, GetByteContext *gb, float *block)
+static int ac_uncompress(const EXRContext *s, GetByteContext *gb, float *block)
 {
     int ret = 0, n = 1;
 
@@ -986,7 +986,7 @@ static float to_linear(float x, float scale)
     }
 }
 
-static int dwa_uncompress(EXRContext *s, const uint8_t *src, int compressed_size,
+static int dwa_uncompress(const EXRContext *s, const uint8_t *src, int compressed_size,
                           int uncompressed_size, EXRThreadData *td)
 {
     int64_t version, lo_usize, lo_size;
@@ -1181,7 +1181,7 @@ static int dwa_uncompress(EXRContext *s, const uint8_t *src, int compressed_size
 static int decode_block(AVCodecContext *avctx, void *tdata,
                         int jobnr, int threadnr)
 {
-    EXRContext *s = avctx->priv_data;
+    const EXRContext *s = avctx->priv_data;
     AVFrame *const p = s->picture;
     EXRThreadData *td = &s->thread_data[threadnr];
     const uint8_t *channel_buffer[4] = { 0 };
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 16/39] avcodec/xwdenc: Don't modify input frame
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (13 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 17/39] swscale/rgb2rgb: Don't cast const away Andreas Rheinhardt
                   ` (22 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

These modifications were actually meant to be applied to
the coded_frame, yet 08b31a72dbcf2935e871ef7c1ffa96ae200f78aa
changed this and so this code has not been removed when coded_frame
has been removed in 11bc79089378a5ec00547d0f85bc152afdf30dfa.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/xwdenc.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c
index 0c6dfc6569..a28fca08e0 100644
--- a/libavcodec/xwdenc.c
+++ b/libavcodec/xwdenc.c
@@ -31,7 +31,7 @@
 #define WINDOW_NAME_SIZE    11
 
 static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
-                            const AVFrame *pict, int *got_packet)
+                            const AVFrame *p, int *got_packet)
 {
     enum AVPixelFormat pix_fmt = avctx->pix_fmt;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
@@ -40,7 +40,6 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint32_t header_size;
     int i, out_size, ret;
     uint8_t *ptr, *buf;
-    AVFrame * const p = (AVFrame *)pict;
     uint32_t pal[256];
 
     pixdepth = av_get_bits_per_pixel(desc);
@@ -151,9 +150,6 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         return ret;
     buf = pkt->data;
 
-    p->key_frame = 1;
-    p->pict_type = AV_PICTURE_TYPE_I;
-
     bytestream_put_be32(&buf, header_size);
     bytestream_put_be32(&buf, XWD_VERSION);   // file version
     bytestream_put_be32(&buf, XWD_Z_PIXMAP);  // pixmap format
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 17/39] swscale/rgb2rgb: Don't cast const away
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (14 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 16/39] avcodec/xwdenc: Don't modify input frame Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 18/39] avcodec/gif: Remove redundant cast Andreas Rheinhardt
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libswscale/rgb2rgb.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
index b8be76913b..4f1ac9c465 100644
--- a/libswscale/rgb2rgb.c
+++ b/libswscale/rgb2rgb.c
@@ -317,7 +317,7 @@ void rgb15tobgr15(const uint8_t *src, uint8_t *dst, int src_size)
 void rgb12tobgr12(const uint8_t *src, uint8_t *dst, int src_size)
 {
     uint16_t *d = (uint16_t *)dst;
-    uint16_t *s = (uint16_t *)src;
+    const uint16_t *s = (const uint16_t *)src;
     int i, num_pixels = src_size >> 1;
 
     for (i = 0; i < num_pixels; i++) {
@@ -331,7 +331,7 @@ void rgb48tobgr48_ ## need_bswap(const uint8_t *src,                    \
                                  uint8_t *dst, int src_size)            \
 {                                                                       \
     uint16_t *d = (uint16_t *)dst;                                      \
-    uint16_t *s = (uint16_t *)src;                                      \
+    const uint16_t *s = (const uint16_t *)src;                          \
     int i, num_pixels = src_size >> 1;                                  \
                                                                         \
     for (i = 0; i < num_pixels; i += 3) {                               \
@@ -349,7 +349,7 @@ void rgb64tobgr48_ ## need_bswap(const uint8_t *src,                    \
                                  uint8_t *dst, int src_size)            \
 {                                                                       \
     uint16_t *d = (uint16_t *)dst;                                      \
-    uint16_t *s = (uint16_t *)src;                                      \
+    const uint16_t *s = (const uint16_t *)src;                          \
     int i, num_pixels = src_size >> 3;                                  \
                                                                         \
     for (i = 0; i < num_pixels; i++) {                                  \
@@ -367,7 +367,7 @@ void rgb64to48_ ## need_bswap(const uint8_t *src,                       \
                               uint8_t *dst, int src_size)               \
 {                                                                       \
     uint16_t *d = (uint16_t *)dst;                                      \
-    uint16_t *s = (uint16_t *)src;                                      \
+    const uint16_t *s = (const uint16_t *)src;                          \
     int i, num_pixels = src_size >> 3;                                  \
                                                                         \
     for (i = 0; i < num_pixels; i++) {                                  \
@@ -385,7 +385,7 @@ void rgb48tobgr64_ ## need_bswap(const uint8_t *src,                    \
                                  uint8_t *dst, int src_size)            \
 {                                                                       \
     uint16_t *d = (uint16_t *)dst;                                      \
-    uint16_t *s = (uint16_t *)src;                                      \
+    const uint16_t *s = (const uint16_t *)src;                          \
     int i, num_pixels = src_size / 6;                                   \
                                                                         \
     for (i = 0; i < num_pixels; i++) {                                  \
@@ -404,7 +404,7 @@ void rgb48to64_ ## need_bswap(const uint8_t *src,                       \
                               uint8_t *dst, int src_size)               \
 {                                                                       \
     uint16_t *d = (uint16_t *)dst;                                      \
-    uint16_t *s = (uint16_t *)src;                                      \
+    const uint16_t *s = (const uint16_t *)src;                          \
     int i, num_pixels = src_size / 6;                                   \
                                                                         \
     for (i = 0; i < num_pixels; i++) {                                  \
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 18/39] avcodec/gif: Remove redundant cast
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (15 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 17/39] swscale/rgb2rgb: Don't cast const away Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 19/39] avcodec/fitsenc: Don't cast const away unnecessarily Andreas Rheinhardt
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Possible since 529a9893d769f381b72785c500662be2020da5fe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/gif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 4904f791ef..8e84b79b8c 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -508,7 +508,7 @@ static int gif_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     if (!s->image) {
         av_frame_unref(s->last_frame);
-        ret = av_frame_ref(s->last_frame, (AVFrame*)pict);
+        ret = av_frame_ref(s->last_frame, pict);
         if (ret < 0)
             return ret;
     }
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 19/39] avcodec/fitsenc: Don't cast const away unnecessarily
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (16 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 18/39] avcodec/gif: Remove redundant cast Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 20/39] avcodec/diracdsp: " Andreas Rheinhardt
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/fitsenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
index 5e9100be85..6e0597c8ca 100644
--- a/libavcodec/fitsenc.c
+++ b/libavcodec/fitsenc.c
@@ -36,9 +36,8 @@
 #include "encode.h"
 
 static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
-                            const AVFrame *pict, int *got_packet)
+                             const AVFrame *p, int *got_packet)
 {
-    AVFrame * const p = (AVFrame *)pict;
     uint8_t *bytestream, *ptr;
     const uint16_t flip = (1 << 15);
     uint64_t data_size = 0, padded_data_size = 0;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 20/39] avcodec/diracdsp: Don't cast const away unnecessarily
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (17 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 21/39] avcodec/dxv: " Andreas Rheinhardt
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c
index aafdddcdc3..284f914f9d 100644
--- a/libavcodec/diracdsp.c
+++ b/libavcodec/diracdsp.c
@@ -139,7 +139,7 @@ ADD_OBMC(32)
 static void put_signed_rect_clamped_8bit_c(uint8_t *dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height)
 {
     int x, y;
-    int16_t *src = (int16_t *)_src;
+    const int16_t *src = (const int16_t *)_src;
     for (y = 0; y < height; y++) {
         for (x = 0; x < width; x+=4) {
             dst[x  ] = av_clip_uint8(src[x  ] + 128);
@@ -158,7 +158,7 @@ static void put_signed_rect_clamped_ ## PX ## bit_c(uint8_t *_dst, int dst_strid
 {                                                                                                       \
     int x, y;                                                                                           \
     uint16_t *dst = (uint16_t *)_dst;                                                                   \
-    int32_t *src = (int32_t *)_src;                                                                     \
+    const int32_t *src = (const int32_t *)_src;                                                         \
     for (y = 0; y < height; y++) {                                                                      \
         for (x = 0; x < width; x+=4) {                                                                  \
             dst[x  ] = av_clip_uintp2(src[x  ] + (1U << (PX - 1)), PX);                                  \
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 21/39] avcodec/dxv: Don't cast const away unnecessarily
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (18 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 20/39] avcodec/diracdsp: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 22/39] avcodec/cinepakenc: Avoid casting const away Andreas Rheinhardt
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dxv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 2a055a3438..13c028d8ba 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -432,7 +432,7 @@ static int get_opcodes(GetByteContext *gb, uint32_t *table, uint8_t *dst, int op
     int64_t size_in_bits;
     unsigned endoffset, newoffset, offset;
     unsigned next;
-    uint8_t *src = (uint8_t *)gb->buffer;
+    const uint8_t *src = gb->buffer;
 
     ret = fill_optable(table, optable, nb_elements);
     if (ret < 0)
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 22/39] avcodec/cinepakenc: Avoid casting const away
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (19 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 21/39] avcodec/dxv: " Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness Andreas Rheinhardt
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index 95af3cc7ef..1b7c901685 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -429,7 +429,7 @@ static int encode_codebook(CinepakEncContext *s, int *codebook, int size,
 
 // sets out to the sub picture starting at (x,y) in in
 static void get_sub_picture(CinepakEncContext *s, int x, int y,
-                            uint8_t * in_data[4], int  in_linesize[4],
+                            uint8_t *const in_data[4], const int  in_linesize[4],
                             uint8_t *out_data[4], int out_linesize[4])
 {
     out_data[0]     = in_data[0] + x + y * in_linesize[0];
@@ -1097,7 +1097,7 @@ static int rd_frame(CinepakEncContext *s, const AVFrame *frame,
                                 data, linesize);
             else
                 get_sub_picture(s, 0, y,
-                                (uint8_t **)frame->data, (int *)frame->linesize,
+                                frame->data, frame->linesize,
                                 data, linesize);
             get_sub_picture(s, 0, y,
                             s->last_frame->data, s->last_frame->linesize,
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (20 preceding siblings ...)
  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
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 24/39] avcodec/ilbcdec: Move transient GetBitContext from ctx to stack Andreas Rheinhardt
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 24/39] avcodec/ilbcdec: Move transient GetBitContext from ctx to stack
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (21 preceding siblings ...)
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness Andreas Rheinhardt
@ 2022-07-26 22:07 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness Andreas Rheinhardt
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:07 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

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

diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 4905ee4145..2bc559a3e8 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -91,7 +91,6 @@ typedef struct ILBCContext {
     int              enhancer;
 
     int              mode;
-    GetBitContext    gb;
     ILBCFrame        frame;
 
     int              prev_enh_pl;
@@ -127,11 +126,14 @@ typedef struct ILBCContext {
     int16_t          hpimemy[4];
 } ILBCContext;
 
-static int unpack_frame(ILBCContext *s)
+static int unpack_frame(ILBCContext *s, const uint8_t *buf, int size)
 {
     ILBCFrame *frame = &s->frame;
-    GetBitContext *gb = &s->gb;
-    int j;
+    GetBitContext gb0, *const gb = &gb0;
+    int j, ret;
+
+    if ((ret = init_get_bits8(gb, buf, size)) < 0)
+        return ret;
 
     frame->lsf[0] = get_bits(gb, 6);
     frame->lsf[1] = get_bits(gb, 7);
@@ -1357,21 +1359,21 @@ static void hp_output(int16_t *signal, const int16_t *ba, int16_t *y,
 static int ilbc_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                              int *got_frame_ptr, AVPacket *avpkt)
 {
-    const uint8_t *buf = avpkt->data;
     ILBCContext *s     = avctx->priv_data;
     int mode = s->mode, ret;
     int16_t *plc_data = &s->plc_residual[LPC_FILTERORDER];
 
-    if ((ret = init_get_bits8(&s->gb, buf, avpkt->size)) < 0)
-        return ret;
     memset(&s->frame, 0, sizeof(ILBCFrame));
+    ret = unpack_frame(s, avpkt->data, avpkt->size);
+    if (ret < 0)
+        return ret;
+    if (ret)
+        mode = 0;
 
     frame->nb_samples = s->block_samples;
     if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
-    if (unpack_frame(s))
-        mode = 0;
     if (s->frame.start < 1 || s->frame.start > 5)
         mode = 0;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (22 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 26/39] avcodec/pnmdec: Fix indentation Andreas Rheinhardt
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pnm.c        | 2 +-
 libavcodec/pnm.h        | 6 +++---
 libavcodec/pnm_parser.c | 8 ++++----
 libavcodec/pnmdec.c     | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 605a529622..aabc788684 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -38,7 +38,7 @@ static void pnm_get(PNMContext *sc, char *str, int buf_size)
 {
     char *s;
     int c;
-    uint8_t *bs  = sc->bytestream;
+    const uint8_t *bs  = sc->bytestream;
     const uint8_t *end = sc->bytestream_end;
 
     /* skip spaces and comments */
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index f109d16239..5bf2eaa4d9 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -25,9 +25,9 @@
 #include "avcodec.h"
 
 typedef struct PNMContext {
-    uint8_t *bytestream;
-    uint8_t *bytestream_start;
-    uint8_t *bytestream_end;
+    const uint8_t *bytestream;
+    const uint8_t *bytestream_start;
+    const uint8_t *bytestream_end;
     int maxval;                 ///< maximum value of a pixel
     int type;
     int endian;
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 6607ac7e7f..74f918a94b 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -65,8 +65,8 @@ retry:
         pnmctx.bytestream_end   = pc->buffer + pc->index;
     } else {
         pnmctx.bytestream_start =
-        pnmctx.bytestream       = (uint8_t *) buf + skip; /* casts avoid warnings */
-        pnmctx.bytestream_end   = (uint8_t *) buf + buf_size - skip;
+        pnmctx.bytestream       = buf + skip;
+        pnmctx.bytestream_end   = buf + buf_size - skip;
     }
     if (ff_pnm_decode_header(avctx, &pnmctx) < 0) {
         if (pnmctx.bytestream < pnmctx.bytestream_end) {
@@ -81,9 +81,9 @@ retry:
             goto retry;
         }
     } else if (pnmctx.type < 4) {
-              uint8_t *bs  = pnmctx.bytestream;
+        const uint8_t *bs   = pnmctx.bytestream;
         const uint8_t *end = pnmctx.bytestream_end;
-        uint8_t *sync      = bs;
+        const uint8_t *sync = bs;
 
         if (pc->index) {
             av_assert0(pnmpc->ascii_scan <= end - bs);
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index bb2ce53496..7cf9886ce7 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -52,8 +52,8 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
     float scale;
 
     s->bytestream_start =
-    s->bytestream       = (uint8_t *)buf;
-    s->bytestream_end   = (uint8_t *)buf + buf_size;
+    s->bytestream       = buf;
+    s->bytestream_end   = buf + buf_size;
 
     if ((ret = ff_pnm_decode_header(avctx, s)) < 0)
         return ret;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 26/39] avcodec/pnmdec: Fix indentation
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (23 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 25/39] avcodec/pnmdec, pnm_parser: Improve const-correctness Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 27/39] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch Andreas Rheinhardt
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Forgotten after ff1450e449f848ad4b37b3cf448315ba4581364e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pnmdec.c | 139 ++++++++++++++++++++++----------------------
 1 file changed, 70 insertions(+), 69 deletions(-)

diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index 7cf9886ce7..130407df25 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -166,23 +166,23 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
                 ptr+= linesize;
             }
         }else{
-        for (i = 0; i < avctx->height; i++) {
-            if (!upgrade)
-                samplecpy(ptr, s->bytestream, n, s->maxval);
-            else if (upgrade == 1) {
-                unsigned int j, f = (255 * 128 + s->maxval / 2) / s->maxval;
-                for (j = 0; j < n; j++)
-                    ptr[j] = (s->bytestream[j] * f + 64) >> 7;
-            } else if (upgrade == 2) {
-                unsigned int j, v, f = (65535 * 32768 + s->maxval / 2) / s->maxval;
-                for (j = 0; j < n / 2; j++) {
-                    v = AV_RB16(s->bytestream + 2*j);
-                    ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
+            for (int i = 0; i < avctx->height; i++) {
+                if (!upgrade)
+                    samplecpy(ptr, s->bytestream, n, s->maxval);
+                else if (upgrade == 1) {
+                    unsigned int f = (255 * 128 + s->maxval / 2) / s->maxval;
+                    for (unsigned j = 0; j < n; j++)
+                        ptr[j] = (s->bytestream[j] * f + 64) >> 7;
+                } else if (upgrade == 2) {
+                    unsigned int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
+                    for (unsigned j = 0; j < n / 2; j++) {
+                        unsigned v = AV_RB16(s->bytestream + 2*j);
+                        ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
+                    }
                 }
+                s->bytestream += n;
+                ptr           += linesize;
             }
-            s->bytestream += n;
-            ptr           += linesize;
-        }
         }
         break;
     case AV_PIX_FMT_YUV420P:
@@ -260,46 +260,46 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
         break;
     case AV_PIX_FMT_GBRPF32:
         if (!s->half) {
-        if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
-            return AVERROR_INVALIDDATA;
-        scale = 1.f / s->scale;
-        if (s->endian) {
-            float *r, *g, *b;
+            if (avctx->width * avctx->height * 12 > s->bytestream_end - s->bytestream)
+                return AVERROR_INVALIDDATA;
+            scale = 1.f / s->scale;
+            if (s->endian) {
+                float *r, *g, *b;
 
-            r = (float *)p->data[2];
-            g = (float *)p->data[0];
-            b = (float *)p->data[1];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
-                    g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
-                    b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
-                    s->bytestream += 12;
+                r = (float *)p->data[2];
+                g = (float *)p->data[0];
+                b = (float *)p->data[1];
+                for (int i = 0; i < avctx->height; i++) {
+                    for (int j = 0; j < avctx->width; j++) {
+                        r[j] = av_int2float(AV_RL32(s->bytestream+0)) * scale;
+                        g[j] = av_int2float(AV_RL32(s->bytestream+4)) * scale;
+                        b[j] = av_int2float(AV_RL32(s->bytestream+8)) * scale;
+                        s->bytestream += 12;
+                    }
+
+                    r += p->linesize[2] / 4;
+                    g += p->linesize[0] / 4;
+                    b += p->linesize[1] / 4;
                 }
+            } else {
+                float *r, *g, *b;
 
-                r += p->linesize[2] / 4;
-                g += p->linesize[0] / 4;
-                b += p->linesize[1] / 4;
-            }
-        } else {
-            float *r, *g, *b;
+                r = (float *)p->data[2];
+                g = (float *)p->data[0];
+                b = (float *)p->data[1];
+                for (int i = 0; i < avctx->height; i++) {
+                    for (int j = 0; j < avctx->width; j++) {
+                        r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
+                        g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
+                        b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
+                        s->bytestream += 12;
+                    }
 
-            r = (float *)p->data[2];
-            g = (float *)p->data[0];
-            b = (float *)p->data[1];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    r[j] = av_int2float(AV_RB32(s->bytestream+0)) * scale;
-                    g[j] = av_int2float(AV_RB32(s->bytestream+4)) * scale;
-                    b[j] = av_int2float(AV_RB32(s->bytestream+8)) * scale;
-                    s->bytestream += 12;
+                    r += p->linesize[2] / 4;
+                    g += p->linesize[0] / 4;
+                    b += p->linesize[1] / 4;
                 }
-
-                r += p->linesize[2] / 4;
-                g += p->linesize[0] / 4;
-                b += p->linesize[1] / 4;
             }
-        }
         } else {
             if (avctx->width * avctx->height * 6 > s->bytestream_end - s->bytestream)
                 return AVERROR_INVALIDDATA;
@@ -358,32 +358,33 @@ static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p,
                     g += p->linesize[0] / 4;
                     b += p->linesize[1] / 4;
                 }
-            }        }
+            }
+        }
         break;
     case AV_PIX_FMT_GRAYF32:
         if (!s->half) {
-        if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
-            return AVERROR_INVALIDDATA;
-        scale = 1.f / s->scale;
-        if (s->endian) {
-            float *g = (float *)p->data[0];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
-                    s->bytestream += 4;
+            if (avctx->width * avctx->height * 4 > s->bytestream_end - s->bytestream)
+                return AVERROR_INVALIDDATA;
+            scale = 1.f / s->scale;
+            if (s->endian) {
+                float *g = (float *)p->data[0];
+                for (int i = 0; i < avctx->height; i++) {
+                    for (int j = 0; j < avctx->width; j++) {
+                        g[j] = av_int2float(AV_RL32(s->bytestream)) * scale;
+                        s->bytestream += 4;
+                    }
+                    g += p->linesize[0] / 4;
                 }
-                g += p->linesize[0] / 4;
-            }
-        } else {
-            float *g = (float *)p->data[0];
-            for (int i = 0; i < avctx->height; i++) {
-                for (int j = 0; j < avctx->width; j++) {
-                    g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
-                    s->bytestream += 4;
+            } else {
+                float *g = (float *)p->data[0];
+                for (int i = 0; i < avctx->height; i++) {
+                    for (int j = 0; j < avctx->width; j++) {
+                        g[j] = av_int2float(AV_RB32(s->bytestream)) * scale;
+                        s->bytestream += 4;
+                    }
+                    g += p->linesize[0] / 4;
                 }
-                g += p->linesize[0] / 4;
             }
-        }
         } else {
             if (avctx->width * avctx->height * 2 > s->bytestream_end - s->bytestream)
                 return AVERROR_INVALIDDATA;
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 27/39] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (24 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 26/39] avcodec/pnmdec: Fix indentation Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 28/39] avcodec/snow: Remove unused halfpel_plane Andreas Rheinhardt
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aarch64/videodsp_init.c     | 2 +-
 libavcodec/arm/videodsp_init_armv5te.c | 2 +-
 libavcodec/loongarch/videodsp_init.c   | 2 +-
 libavcodec/mips/videodsp_init.c        | 2 +-
 libavcodec/ppc/videodsp.c              | 2 +-
 libavcodec/videodsp.c                  | 2 +-
 libavcodec/videodsp.h                  | 2 +-
 libavcodec/x86/videodsp_init.c         | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aarch64/videodsp_init.c b/libavcodec/aarch64/videodsp_init.c
index 6f667a6d3e..1f77a918d7 100644
--- a/libavcodec/aarch64/videodsp_init.c
+++ b/libavcodec/aarch64/videodsp_init.c
@@ -21,7 +21,7 @@
 #include "libavutil/aarch64/cpu.h"
 #include "libavcodec/videodsp.h"
 
-void ff_prefetch_aarch64(uint8_t *mem, ptrdiff_t stride, int h);
+void ff_prefetch_aarch64(const uint8_t *mem, ptrdiff_t stride, int h);
 
 av_cold void ff_videodsp_init_aarch64(VideoDSPContext *ctx, int bpc)
 {
diff --git a/libavcodec/arm/videodsp_init_armv5te.c b/libavcodec/arm/videodsp_init_armv5te.c
index 1ea1f3438d..eaa8c5bbf8 100644
--- a/libavcodec/arm/videodsp_init_armv5te.c
+++ b/libavcodec/arm/videodsp_init_armv5te.c
@@ -23,7 +23,7 @@
 #include "libavcodec/videodsp.h"
 #include "videodsp_arm.h"
 
-void ff_prefetch_arm(uint8_t *mem, ptrdiff_t stride, int h);
+void ff_prefetch_arm(const uint8_t *mem, ptrdiff_t stride, int h);
 
 av_cold void ff_videodsp_init_armv5te(VideoDSPContext *ctx, int bpc)
 {
diff --git a/libavcodec/loongarch/videodsp_init.c b/libavcodec/loongarch/videodsp_init.c
index 6cbb7763ff..92ade4f846 100644
--- a/libavcodec/loongarch/videodsp_init.c
+++ b/libavcodec/loongarch/videodsp_init.c
@@ -22,7 +22,7 @@
 #include "libavcodec/videodsp.h"
 #include "libavutil/attributes.h"
 
-static void prefetch_loongarch(uint8_t *mem, ptrdiff_t stride, int h)
+static void prefetch_loongarch(const uint8_t *mem, ptrdiff_t stride, int h)
 {
     register const uint8_t *p = mem;
 
diff --git a/libavcodec/mips/videodsp_init.c b/libavcodec/mips/videodsp_init.c
index 07c23bcf7e..89409fc8fd 100644
--- a/libavcodec/mips/videodsp_init.c
+++ b/libavcodec/mips/videodsp_init.c
@@ -24,7 +24,7 @@
 #include "libavutil/mips/asmdefs.h"
 #include "libavcodec/videodsp.h"
 
-static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h)
+static void prefetch_mips(const uint8_t *mem, ptrdiff_t stride, int h)
 {
     register const uint8_t *p = mem;
 
diff --git a/libavcodec/ppc/videodsp.c b/libavcodec/ppc/videodsp.c
index 915702252e..a7ab5a6a42 100644
--- a/libavcodec/ppc/videodsp.c
+++ b/libavcodec/ppc/videodsp.c
@@ -21,7 +21,7 @@
 #include "libavutil/attributes.h"
 #include "libavcodec/videodsp.h"
 
-static void prefetch_ppc(uint8_t *mem, ptrdiff_t stride, int h)
+static void prefetch_ppc(const uint8_t *mem, ptrdiff_t stride, int h)
 {
     register const uint8_t *p = mem;
     do {
diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
index 90dc1aacbd..bdff2e76f5 100644
--- a/libavcodec/videodsp.c
+++ b/libavcodec/videodsp.c
@@ -32,7 +32,7 @@
 #include "videodsp_template.c"
 #undef BIT_DEPTH
 
-static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
+static void just_return(const uint8_t *buf, ptrdiff_t stride, int h)
 {
 }
 
diff --git a/libavcodec/videodsp.h b/libavcodec/videodsp.h
index b5219d236c..e8960b609d 100644
--- a/libavcodec/videodsp.h
+++ b/libavcodec/videodsp.h
@@ -72,7 +72,7 @@ typedef struct VideoDSPContext {
      * @param stride distance between two lines of buf (in bytes)
      * @param h      number of lines to prefetch
      */
-    void (*prefetch)(uint8_t *buf, ptrdiff_t stride, int h);
+    void (*prefetch)(const uint8_t *buf, ptrdiff_t stride, int h);
 } VideoDSPContext;
 
 void ff_videodsp_init(VideoDSPContext *ctx, int bpc);
diff --git a/libavcodec/x86/videodsp_init.c b/libavcodec/x86/videodsp_init.c
index a14c9635fb..ae9db95624 100644
--- a/libavcodec/x86/videodsp_init.c
+++ b/libavcodec/x86/videodsp_init.c
@@ -215,7 +215,7 @@ static av_noinline void emulated_edge_mc_avx2(uint8_t *buf, const uint8_t *src,
 #endif /* HAVE_AVX2_EXTERNAL */
 #endif /* HAVE_X86ASM */
 
-void ff_prefetch_mmxext(uint8_t *buf, ptrdiff_t stride, int h);
+void ff_prefetch_mmxext(const uint8_t *buf, ptrdiff_t stride, int h);
 
 av_cold void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc)
 {
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 28/39] avcodec/snow: Remove unused halfpel_plane
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (25 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 27/39] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 29/39] avcodec/pngenc: Don't cast const away unnecessarily Andreas Rheinhardt
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Committed in 5be3a818719d613e2f225cf1532fda01ba106b04 in
an unfinished state; never used or finished and always disabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/snow.c | 67 +----------------------------------------------
 libavcodec/snow.h |  1 -
 2 files changed, 1 insertion(+), 67 deletions(-)

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 293a0eb7d9..6442fb7f0d 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -359,7 +359,7 @@ void ff_snow_pred_block(SnowContext *s, uint8_t *dst, uint8_t *tmp, ptrdiff_t st
             }
         }
     }else{
-        uint8_t *src= s->last_picture[block->ref]->data[plane_index];
+        const uint8_t *src= s->last_picture[block->ref]->data[plane_index];
         const int scale= plane_index ?  (2*s->mv_scale)>>s->chroma_h_shift : 2*s->mv_scale;
         int mx= block->mx*scale;
         int my= block->my*scale;
@@ -587,72 +587,12 @@ int ff_snow_common_init_after_header(AVCodecContext *avctx) {
     return 0;
 }
 
-#define USE_HALFPEL_PLANE 0
-
-static int halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){
-    int p,x,y;
-
-    for(p=0; p < s->nb_planes; p++){
-        int is_chroma= !!p;
-        int w= is_chroma ? AV_CEIL_RSHIFT(s->avctx->width,  s->chroma_h_shift) : s->avctx->width;
-        int h= is_chroma ? AV_CEIL_RSHIFT(s->avctx->height, s->chroma_v_shift) : s->avctx->height;
-        int ls= frame->linesize[p];
-        uint8_t *src= frame->data[p];
-
-        halfpel[1][p] = av_malloc_array(ls, (h + 2 * EDGE_WIDTH));
-        halfpel[2][p] = av_malloc_array(ls, (h + 2 * EDGE_WIDTH));
-        halfpel[3][p] = av_malloc_array(ls, (h + 2 * EDGE_WIDTH));
-        if (!halfpel[1][p] || !halfpel[2][p] || !halfpel[3][p]) {
-            av_freep(&halfpel[1][p]);
-            av_freep(&halfpel[2][p]);
-            av_freep(&halfpel[3][p]);
-            return AVERROR(ENOMEM);
-        }
-        halfpel[1][p] += EDGE_WIDTH * (1 + ls);
-        halfpel[2][p] += EDGE_WIDTH * (1 + ls);
-        halfpel[3][p] += EDGE_WIDTH * (1 + ls);
-
-        halfpel[0][p]= src;
-        for(y=0; y<h; y++){
-            for(x=0; x<w; x++){
-                int i= y*ls + x;
-
-                halfpel[1][p][i]= (20*(src[i] + src[i+1]) - 5*(src[i-1] + src[i+2]) + (src[i-2] + src[i+3]) + 16 )>>5;
-            }
-        }
-        for(y=0; y<h; y++){
-            for(x=0; x<w; x++){
-                int i= y*ls + x;
-
-                halfpel[2][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
-            }
-        }
-        src= halfpel[1][p];
-        for(y=0; y<h; y++){
-            for(x=0; x<w; x++){
-                int i= y*ls + x;
-
-                halfpel[3][p][i]= (20*(src[i] + src[i+ls]) - 5*(src[i-ls] + src[i+2*ls]) + (src[i-2*ls] + src[i+3*ls]) + 16 )>>5;
-            }
-        }
-
-//FIXME border!
-    }
-    return 0;
-}
-
 void ff_snow_release_buffer(AVCodecContext *avctx)
 {
     SnowContext *s = avctx->priv_data;
-    int i;
 
     if(s->last_picture[s->max_ref_frames-1]->data[0]){
         av_frame_unref(s->last_picture[s->max_ref_frames-1]);
-        for(i=0; i<9; i++)
-            if(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3]) {
-                av_free(s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] - EDGE_WIDTH*(1+s->current_picture->linesize[i%3]));
-                s->halfpel_plane[s->max_ref_frames-1][1+i/3][i%3] = NULL;
-            }
     }
 }
 
@@ -665,11 +605,6 @@ int ff_snow_frame_start(SnowContext *s){
     tmp= s->last_picture[s->max_ref_frames-1];
     for(i=s->max_ref_frames-1; i>0; i--)
         s->last_picture[i] = s->last_picture[i-1];
-    memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4);
-    if(USE_HALFPEL_PLANE && s->current_picture->data[0]) {
-        if((ret = halfpel_interpol(s, s->halfpel_plane[0], s->current_picture)) < 0)
-            return ret;
-    }
     s->last_picture[0] = s->current_picture;
     s->current_picture = tmp;
 
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index f5beca66e9..709fef6be5 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -127,7 +127,6 @@ typedef struct SnowContext{
     AVFrame *input_picture;              ///< new_picture with the internal linesizes
     AVFrame *current_picture;
     AVFrame *last_picture[MAX_REF_FRAMES];
-    uint8_t *halfpel_plane[MAX_REF_FRAMES][4][4];
     AVFrame *mconly_picture;
 //     uint8_t q_context[16];
     uint8_t header_state[32];
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 29/39] avcodec/pngenc: Don't cast const away unnecessarily
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (26 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 28/39] avcodec/snow: Remove unused halfpel_plane Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 30/39] avcodec/lossless_videoencdsp: Constify src sub_left_predict Andreas Rheinhardt
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Possible since 529a9893d769f381b72785c500662be2020da5fe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pngenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 25cf769931..c4742e293f 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -1056,7 +1056,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
         }
 
         av_frame_unref(s->last_frame);
-        ret = av_frame_ref(s->last_frame, (AVFrame*)pict);
+        ret = av_frame_ref(s->last_frame, pict);
         if (ret < 0)
             return ret;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 30/39] avcodec/lossless_videoencdsp: Constify src sub_left_predict
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (27 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 31/39] avcodec/me_cmp: Constify me_cmp_func buffer parameters Andreas Rheinhardt
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/lossless_videoencdsp.c          | 2 +-
 libavcodec/lossless_videoencdsp.h          | 2 +-
 libavcodec/x86/lossless_videoencdsp.asm    | 2 +-
 libavcodec/x86/lossless_videoencdsp_init.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/lossless_videoencdsp.c b/libavcodec/lossless_videoencdsp.c
index e0b78bb3da..b4130ebc7b 100644
--- a/libavcodec/lossless_videoencdsp.c
+++ b/libavcodec/lossless_videoencdsp.c
@@ -74,7 +74,7 @@ static void sub_median_pred_c(uint8_t *dst, const uint8_t *src1,
     *left_top = lt;
 }
 
-static void sub_left_predict_c(uint8_t *dst, uint8_t *src,
+static void sub_left_predict_c(uint8_t *dst, const uint8_t *src,
                                ptrdiff_t stride, ptrdiff_t width, int height)
 {
     int i, j;
diff --git a/libavcodec/lossless_videoencdsp.h b/libavcodec/lossless_videoencdsp.h
index 7794f03e3f..f2c2878485 100644
--- a/libavcodec/lossless_videoencdsp.h
+++ b/libavcodec/lossless_videoencdsp.h
@@ -35,7 +35,7 @@ typedef struct LLVidEncDSPContext {
                             const uint8_t *src2, intptr_t w,
                             int *left, int *left_top);
 
-    void (*sub_left_predict)(uint8_t *dst, uint8_t *src,
+    void (*sub_left_predict)(uint8_t *dst, const uint8_t *src,
                           ptrdiff_t stride, ptrdiff_t width, int height);
 } LLVidEncDSPContext;
 
diff --git a/libavcodec/x86/lossless_videoencdsp.asm b/libavcodec/x86/lossless_videoencdsp.asm
index 2e1d01bc2c..c579891d6a 100644
--- a/libavcodec/x86/lossless_videoencdsp.asm
+++ b/libavcodec/x86/lossless_videoencdsp.asm
@@ -145,7 +145,7 @@ DIFF_BYTES_PROLOGUE
 
 
 ;--------------------------------------------------------------------------------------------------
-;void sub_left_predict(uint8_t *dst, uint8_t *src, ptrdiff_t stride, ptrdiff_t width, int height)
+;void sub_left_predict(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, ptrdiff_t width, int height)
 ;--------------------------------------------------------------------------------------------------
 
 INIT_XMM avx
diff --git a/libavcodec/x86/lossless_videoencdsp_init.c b/libavcodec/x86/lossless_videoencdsp_init.c
index b3efcfdcd7..22a4014ef1 100644
--- a/libavcodec/x86/lossless_videoencdsp_init.c
+++ b/libavcodec/x86/lossless_videoencdsp_init.c
@@ -34,7 +34,7 @@ void ff_diff_bytes_sse2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
 void ff_diff_bytes_avx2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2,
                         intptr_t w);
 
-void ff_sub_left_predict_avx(uint8_t *dst, uint8_t *src,
+void ff_sub_left_predict_avx(uint8_t *dst, const uint8_t *src,
                             ptrdiff_t stride, ptrdiff_t width, int height);
 
 #if HAVE_INLINE_ASM
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 31/39] avcodec/me_cmp: Constify me_cmp_func buffer parameters
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (28 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 32/39] avcodec/h264chroma: Constify src in h264_chroma_mc_func Andreas Rheinhardt
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aarch64/me_cmp_init_aarch64.c |  6 +-
 libavcodec/alpha/me_cmp_alpha.c          | 12 ++--
 libavcodec/alpha/me_cmp_mvi_asm.S        |  2 +-
 libavcodec/arm/me_cmp_init_arm.c         | 10 +--
 libavcodec/me_cmp.c                      | 80 ++++++++++++------------
 libavcodec/me_cmp.h                      |  6 +-
 libavcodec/mips/me_cmp_mips.h            | 32 +++++-----
 libavcodec/mips/me_cmp_msa.c             | 80 ++++++++++++------------
 libavcodec/motion_est.c                  |  2 +-
 libavcodec/ppc/me_cmp.c                  | 30 ++++-----
 libavcodec/snow_dwt.c                    | 14 ++---
 libavcodec/snow_dwt.h                    |  4 +-
 libavcodec/x86/me_cmp.asm                | 24 +++----
 libavcodec/x86/me_cmp_init.c             | 72 ++++++++++-----------
 14 files changed, 187 insertions(+), 187 deletions(-)

diff --git a/libavcodec/aarch64/me_cmp_init_aarch64.c b/libavcodec/aarch64/me_cmp_init_aarch64.c
index 136b008eb7..79c739914f 100644
--- a/libavcodec/aarch64/me_cmp_init_aarch64.c
+++ b/libavcodec/aarch64/me_cmp_init_aarch64.c
@@ -23,11 +23,11 @@
 #include "libavutil/aarch64/cpu.h"
 #include "libavcodec/mpegvideo.h"
 
-int ff_pix_abs16_neon(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_neon(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                       ptrdiff_t stride, int h);
-int ff_pix_abs16_xy2_neon(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_xy2_neon(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                       ptrdiff_t stride, int h);
-int ff_pix_abs16_x2_neon(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_x2_neon(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                       ptrdiff_t stride, int h);
 
 av_cold void ff_me_cmp_init_aarch64(MECmpContext *c, AVCodecContext *avctx)
diff --git a/libavcodec/alpha/me_cmp_alpha.c b/libavcodec/alpha/me_cmp_alpha.c
index 8f360190f4..4e9e0f88dc 100644
--- a/libavcodec/alpha/me_cmp_alpha.c
+++ b/libavcodec/alpha/me_cmp_alpha.c
@@ -23,7 +23,7 @@
 #include "libavcodec/me_cmp.h"
 #include "asm.h"
 
-int pix_abs16x16_mvi_asm(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
+int pix_abs16x16_mvi_asm(void *v, const uint8_t *pix1, const uint8_t *pix2, int line_size, int h);
 
 static inline uint64_t avg2(uint64_t a, uint64_t b)
 {
@@ -44,7 +44,7 @@ static inline uint64_t avg4(uint64_t l1, uint64_t l2, uint64_t l3, uint64_t l4)
     return r1 + r2;
 }
 
-static int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8x8_mvi(void *v, const uint8_t *pix1, const uint8_t *pix2, int line_size, int h)
 {
     int result = 0;
 
@@ -77,7 +77,7 @@ static int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
 }
 
 #if 0                           /* now done in assembly */
-int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size)
+int pix_abs16x16_mvi(const uint8_t *pix1, const uint8_t *pix2, int line_size)
 {
     int result = 0;
     int h = 16;
@@ -119,7 +119,7 @@ int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size)
 }
 #endif
 
-static int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16x16_x2_mvi(void *v, const uint8_t *pix1, const uint8_t *pix2, int line_size, int h)
 {
     int result = 0;
     uint64_t disalign = (size_t) pix2 & 0x7;
@@ -192,7 +192,7 @@ static int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_s
     return result;
 }
 
-static int pix_abs16x16_y2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16x16_y2_mvi(void *v, const uint8_t *pix1, const uint8_t *pix2, int line_size, int h)
 {
     int result = 0;
 
@@ -245,7 +245,7 @@ static int pix_abs16x16_y2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_s
     return result;
 }
 
-static int pix_abs16x16_xy2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16x16_xy2_mvi(void *v, const uint8_t *pix1, const uint8_t *pix2, int line_size, int h)
 {
     int result = 0;
 
diff --git a/libavcodec/alpha/me_cmp_mvi_asm.S b/libavcodec/alpha/me_cmp_mvi_asm.S
index 2399085bcb..183feeb40c 100644
--- a/libavcodec/alpha/me_cmp_mvi_asm.S
+++ b/libavcodec/alpha/me_cmp_mvi_asm.S
@@ -38,7 +38,7 @@
         .text
 
 /*****************************************************************************
- * int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size)
+ * int pix_abs16x16_mvi_asm(const uint8_t *pix1, const uint8_t *pix2, int line_size)
  *
  * This code is written with a pca56 in mind. For ev6, one should
  * really take the increased latency of 3 cycles for MVI instructions
diff --git a/libavcodec/arm/me_cmp_init_arm.c b/libavcodec/arm/me_cmp_init_arm.c
index 03870a2bfa..8c556f1755 100644
--- a/libavcodec/arm/me_cmp_init_arm.c
+++ b/libavcodec/arm/me_cmp_init_arm.c
@@ -25,17 +25,17 @@
 #include "libavcodec/me_cmp.h"
 #include "libavcodec/mpegvideo.h"
 
-int ff_pix_abs16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_armv6(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                        ptrdiff_t stride, int h);
-int ff_pix_abs16_x2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_x2_armv6(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                           ptrdiff_t stride, int h);
-int ff_pix_abs16_y2_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs16_y2_armv6(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                           ptrdiff_t stride, int h);
 
-int ff_pix_abs8_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_pix_abs8_armv6(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                       ptrdiff_t stride, int h);
 
-int ff_sse16_armv6(MpegEncContext *s, uint8_t *blk1, uint8_t *blk2,
+int ff_sse16_armv6(MpegEncContext *s, const uint8_t *blk1, const uint8_t *blk2,
                    ptrdiff_t stride, int h);
 
 av_cold void ff_me_cmp_init_arm(MECmpContext *c, AVCodecContext *avctx)
diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index d0cd14ad33..fa82ae54ae 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -67,7 +67,7 @@ const uint32_t ff_square_tab[512] = {
     57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025,
 };
 
-static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sse4_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                   ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -84,7 +84,7 @@ static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sse8_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                   ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -105,7 +105,7 @@ static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sse16_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                    ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -135,7 +135,7 @@ static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sum_abs_dctelem_c(int16_t *block)
+static int sum_abs_dctelem_c(const int16_t *block)
 {
     int sum = 0, i;
 
@@ -147,7 +147,7 @@ static int sum_abs_dctelem_c(int16_t *block)
 #define avg2(a, b) (((a) + (b) + 1) >> 1)
 #define avg4(a, b, c, d) (((a) + (b) + (c) + (d) + 2) >> 2)
 
-static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static inline int pix_abs16_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                               ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -175,7 +175,7 @@ static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static inline int pix_median_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static inline int pix_median_abs16_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                              ptrdiff_t stride, int h)
 {
     int s = 0, i, j;
@@ -214,7 +214,7 @@ static inline int pix_median_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *
     return s;
 }
 
-static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs16_x2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                           ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -242,11 +242,11 @@ static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs16_y2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                           ptrdiff_t stride, int h)
 {
     int s = 0, i;
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
 
     for (i = 0; i < h; i++) {
         s    += abs(pix1[0]  - avg2(pix2[0],  pix3[0]));
@@ -272,11 +272,11 @@ static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs16_xy2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                            ptrdiff_t stride, int h)
 {
     int s = 0, i;
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
 
     for (i = 0; i < h; i++) {
         s    += abs(pix1[0]  - avg4(pix2[0],  pix2[1],  pix3[0],  pix3[1]));
@@ -302,7 +302,7 @@ static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static inline int pix_abs8_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                              ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -322,7 +322,7 @@ static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static inline int pix_median_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static inline int pix_median_abs8_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                              ptrdiff_t stride, int h)
 {
     int s = 0, i, j;
@@ -353,7 +353,7 @@ static inline int pix_median_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *p
     return s;
 }
 
-static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs8_x2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h)
 {
     int s = 0, i;
@@ -373,11 +373,11 @@ static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs8_y2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h)
 {
     int s = 0, i;
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
 
     for (i = 0; i < h; i++) {
         s    += abs(pix1[0] - avg2(pix2[0], pix3[0]));
@@ -395,11 +395,11 @@ static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int pix_abs8_xy2_c(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                           ptrdiff_t stride, int h)
 {
     int s = 0, i;
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
 
     for (i = 0; i < h; i++) {
         s    += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
@@ -417,7 +417,7 @@ static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
+static int nsse16_c(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2,
                     ptrdiff_t stride, int h)
 {
     int score1 = 0, score2 = 0, x, y;
@@ -442,7 +442,7 @@ static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
         return score1 + FFABS(score2) * 8;
 }
 
-static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
+static int nsse8_c(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2,
                    ptrdiff_t stride, int h)
 {
     int score1 = 0, score2 = 0, x, y;
@@ -467,7 +467,7 @@ static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,
         return score1 + FFABS(score2) * 8;
 }
 
-static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
+static int zero_cmp(MpegEncContext *s, const uint8_t *a, const uint8_t *b,
                     ptrdiff_t stride, int h)
 {
     return 0;
@@ -553,8 +553,8 @@ void ff_set_cmp(MECmpContext *c, me_cmp_func *cmp, int type)
 
 #define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
 
-static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
-                               uint8_t *src, ptrdiff_t stride, int h)
+static int hadamard8_diff8x8_c(MpegEncContext *s, const uint8_t *dst,
+                               const uint8_t *src, ptrdiff_t stride, int h)
 {
     int i, temp[64], sum = 0;
 
@@ -605,8 +605,8 @@ static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
     return sum;
 }
 
-static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
-                                uint8_t *dummy, ptrdiff_t stride, int h)
+static int hadamard8_intra8x8_c(MpegEncContext *s, const uint8_t *src,
+                                const uint8_t *dummy, ptrdiff_t stride, int h)
 {
     int i, temp[64], sum = 0;
 
@@ -657,8 +657,8 @@ static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
     return sum;
 }
 
-static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
-                        uint8_t *src2, ptrdiff_t stride, int h)
+static int dct_sad8x8_c(MpegEncContext *s, const uint8_t *src1,
+                        const uint8_t *src2, ptrdiff_t stride, int h)
 {
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
 
@@ -698,8 +698,8 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
         DST(7, (a4 >> 2) - a7);                         \
     }
 
-static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
-                           uint8_t *src2, ptrdiff_t stride, int h)
+static int dct264_sad8x8_c(MpegEncContext *s, const uint8_t *src1,
+                           const uint8_t *src2, ptrdiff_t stride, int h)
 {
     int16_t dct[8][8];
     int i, sum = 0;
@@ -723,8 +723,8 @@ static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
 }
 #endif
 
-static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
-                        uint8_t *src2, ptrdiff_t stride, int h)
+static int dct_max8x8_c(MpegEncContext *s, const uint8_t *src1,
+                        const uint8_t *src2, ptrdiff_t stride, int h)
 {
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
     int sum = 0, i;
@@ -740,8 +740,8 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
     return sum;
 }
 
-static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
-                           uint8_t *src2, ptrdiff_t stride, int h)
+static int quant_psnr8x8_c(MpegEncContext *s, const uint8_t *src1,
+                           const uint8_t *src2, ptrdiff_t stride, int h)
 {
     LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
     int16_t *const bak = temp + 64;
@@ -765,7 +765,7 @@ static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
     return sum;
 }
 
-static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
+static int rd8x8_c(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2,
                    ptrdiff_t stride, int h)
 {
     const uint8_t *scantable = s->intra_scantable.permutated;
@@ -842,7 +842,7 @@ static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
     return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
 }
 
-static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
+static int bit8x8_c(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2,
                     ptrdiff_t stride, int h)
 {
     const uint8_t *scantable = s->intra_scantable.permutated;
@@ -905,7 +905,7 @@ static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
 
 #define VSAD_INTRA(size)                                                \
 static int vsad_intra ## size ## _c(MpegEncContext *c,                  \
-                                    uint8_t *s, uint8_t *dummy,         \
+                                    const uint8_t *s, const uint8_t *dummy, \
                                     ptrdiff_t stride, int h)            \
 {                                                                       \
     int score = 0, x, y;                                                \
@@ -927,7 +927,7 @@ VSAD_INTRA(16)
 
 #define VSAD(size)                                                             \
 static int vsad ## size ## _c(MpegEncContext *c,                               \
-                              uint8_t *s1, uint8_t *s2,                        \
+                              const uint8_t *s1, const uint8_t *s2,            \
                               ptrdiff_t stride, int h)                               \
 {                                                                              \
     int score = 0, x, y;                                                       \
@@ -947,7 +947,7 @@ VSAD(16)
 #define SQ(a) ((a) * (a))
 #define VSSE_INTRA(size)                                                \
 static int vsse_intra ## size ## _c(MpegEncContext *c,                  \
-                                    uint8_t *s, uint8_t *dummy,         \
+                                    const uint8_t *s, const uint8_t *dummy, \
                                     ptrdiff_t stride, int h)            \
 {                                                                       \
     int score = 0, x, y;                                                \
@@ -968,7 +968,7 @@ VSSE_INTRA(8)
 VSSE_INTRA(16)
 
 #define VSSE(size)                                                             \
-static int vsse ## size ## _c(MpegEncContext *c, uint8_t *s1, uint8_t *s2,     \
+static int vsse ## size ## _c(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, \
                               ptrdiff_t stride, int h)                         \
 {                                                                              \
     int score = 0, x, y;                                                       \
@@ -986,7 +986,7 @@ VSSE(8)
 VSSE(16)
 
 #define WRAPPER8_16_SQ(name8, name16)                                   \
-static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src,        \
+static int name16(MpegEncContext *s, const uint8_t *dst, const uint8_t *src, \
                   ptrdiff_t stride, int h)                              \
 {                                                                       \
     int score = 0;                                                      \
diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h
index 7b057a923b..c6de2d0061 100644
--- a/libavcodec/me_cmp.h
+++ b/libavcodec/me_cmp.h
@@ -46,12 +46,12 @@ struct MpegEncContext;
  * Although currently h < 4 is not used as functions with
  * width < 8 are neither used nor implemented. */
 typedef int (*me_cmp_func)(struct MpegEncContext *c,
-                           uint8_t *blk1 /* align width (8 or 16) */,
-                           uint8_t *blk2 /* align 1 */, ptrdiff_t stride,
+                           const uint8_t *blk1 /* align width (8 or 16) */,
+                           const uint8_t *blk2 /* align 1 */, ptrdiff_t stride,
                            int h);
 
 typedef struct MECmpContext {
-    int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
+    int (*sum_abs_dctelem)(const int16_t *block /* align 16 */);
 
     me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
     me_cmp_func sse[6];
diff --git a/libavcodec/mips/me_cmp_mips.h b/libavcodec/mips/me_cmp_mips.h
index e0d0f51af8..728640102a 100644
--- a/libavcodec/mips/me_cmp_mips.h
+++ b/libavcodec/mips/me_cmp_mips.h
@@ -24,37 +24,37 @@
 #include "../mpegvideo.h"
 #include "libavcodec/bit_depth_template.c"
 
-int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_diff8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                              ptrdiff_t stride, int h);
-int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_intra8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                               ptrdiff_t stride, int h);
-int ff_hadamard8_diff16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_diff16_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                             ptrdiff_t stride, int h);
-int ff_hadamard8_intra16_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_intra16_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                              ptrdiff_t stride, int h);
-int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                      ptrdiff_t stride, int h);
-int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_x2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h);
-int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_y2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h);
-int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_xy2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h);
-int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                     ptrdiff_t stride, int h);
-int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_x2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h);
-int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_y2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h);
-int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_xy2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h);
-int ff_sse16_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref,
+int ff_sse16_msa(MpegEncContext *v, const uint8_t *pu8Src, const uint8_t *pu8Ref,
                  ptrdiff_t stride, int i32Height);
-int ff_sse8_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref,
+int ff_sse8_msa(MpegEncContext *v, const uint8_t *pu8Src, const uint8_t *pu8Ref,
                 ptrdiff_t stride, int i32Height);
-int ff_sse4_msa(MpegEncContext *v, uint8_t *pu8Src, uint8_t *pu8Ref,
+int ff_sse4_msa(MpegEncContext *v, const uint8_t *pu8Src, const uint8_t *pu8Ref,
                 ptrdiff_t stride, int i32Height);
-void ff_add_pixels8_msa(uint8_t *av_restrict pixels, int16_t *block,
+void ff_add_pixels8_msa(const uint8_t *av_restrict pixels, int16_t *block,
                         ptrdiff_t stride);
 
 #endif  // #ifndef AVCODEC_MIPS_ME_CMP_MIPS_H
diff --git a/libavcodec/mips/me_cmp_msa.c b/libavcodec/mips/me_cmp_msa.c
index 7cb7af0047..00a3cfd53f 100644
--- a/libavcodec/mips/me_cmp_msa.c
+++ b/libavcodec/mips/me_cmp_msa.c
@@ -21,8 +21,8 @@
 #include "libavutil/mips/generic_macros_msa.h"
 #include "me_cmp_mips.h"
 
-static uint32_t sad_8width_msa(uint8_t *src, int32_t src_stride,
-                               uint8_t *ref, int32_t ref_stride,
+static uint32_t sad_8width_msa(const uint8_t *src, int32_t src_stride,
+                               const uint8_t *ref, int32_t ref_stride,
                                int32_t height)
 {
     int32_t ht_cnt;
@@ -43,8 +43,8 @@ static uint32_t sad_8width_msa(uint8_t *src, int32_t src_stride,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_16width_msa(uint8_t *src, int32_t src_stride,
-                                uint8_t *ref, int32_t ref_stride,
+static uint32_t sad_16width_msa(const uint8_t *src, int32_t src_stride,
+                                const uint8_t *ref, int32_t ref_stride,
                                 int32_t height)
 {
     int32_t ht_cnt;
@@ -68,9 +68,9 @@ static uint32_t sad_16width_msa(uint8_t *src, int32_t src_stride,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_horiz_bilinear_filter_8width_msa(uint8_t *src,
+static uint32_t sad_horiz_bilinear_filter_8width_msa(const uint8_t *src,
                                                      int32_t src_stride,
-                                                     uint8_t *ref,
+                                                     const uint8_t *ref,
                                                      int32_t ref_stride,
                                                      int32_t height)
 {
@@ -110,9 +110,9 @@ static uint32_t sad_horiz_bilinear_filter_8width_msa(uint8_t *src,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_horiz_bilinear_filter_16width_msa(uint8_t *src,
+static uint32_t sad_horiz_bilinear_filter_16width_msa(const uint8_t *src,
                                                       int32_t src_stride,
-                                                      uint8_t *ref,
+                                                      const uint8_t *ref,
                                                       int32_t ref_stride,
                                                       int32_t height)
 {
@@ -148,9 +148,9 @@ static uint32_t sad_horiz_bilinear_filter_16width_msa(uint8_t *src,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_vert_bilinear_filter_8width_msa(uint8_t *src,
+static uint32_t sad_vert_bilinear_filter_8width_msa(const uint8_t *src,
                                                     int32_t src_stride,
-                                                    uint8_t *ref,
+                                                    const uint8_t *ref,
                                                     int32_t ref_stride,
                                                     int32_t height)
 {
@@ -186,9 +186,9 @@ static uint32_t sad_vert_bilinear_filter_8width_msa(uint8_t *src,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_vert_bilinear_filter_16width_msa(uint8_t *src,
+static uint32_t sad_vert_bilinear_filter_16width_msa(const uint8_t *src,
                                                      int32_t src_stride,
-                                                     uint8_t *ref,
+                                                     const uint8_t *ref,
                                                      int32_t ref_stride,
                                                      int32_t height)
 {
@@ -224,9 +224,9 @@ static uint32_t sad_vert_bilinear_filter_16width_msa(uint8_t *src,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_hv_bilinear_filter_8width_msa(uint8_t *src,
+static uint32_t sad_hv_bilinear_filter_8width_msa(const uint8_t *src,
                                                   int32_t src_stride,
-                                                  uint8_t *ref,
+                                                  const uint8_t *ref,
                                                   int32_t ref_stride,
                                                   int32_t height)
 {
@@ -280,9 +280,9 @@ static uint32_t sad_hv_bilinear_filter_8width_msa(uint8_t *src,
     return (HADD_UH_U32(sad));
 }
 
-static uint32_t sad_hv_bilinear_filter_16width_msa(uint8_t *src,
+static uint32_t sad_hv_bilinear_filter_16width_msa(const uint8_t *src,
                                                    int32_t src_stride,
-                                                   uint8_t *ref,
+                                                   const uint8_t *ref,
                                                    int32_t ref_stride,
                                                    int32_t height)
 {
@@ -403,8 +403,8 @@ static uint32_t sad_hv_bilinear_filter_16width_msa(uint8_t *src,
     DPADD_SH2_SW(res_l0_m, res_l1_m, res_l0_m, res_l1_m, var, var);  \
 }
 
-static uint32_t sse_4width_msa(uint8_t *src_ptr, int32_t src_stride,
-                               uint8_t *ref_ptr, int32_t ref_stride,
+static uint32_t sse_4width_msa(const uint8_t *src_ptr, int32_t src_stride,
+                               const uint8_t *ref_ptr, int32_t ref_stride,
                                int32_t height)
 {
     int32_t ht_cnt;
@@ -431,8 +431,8 @@ static uint32_t sse_4width_msa(uint8_t *src_ptr, int32_t src_stride,
     return sse;
 }
 
-static uint32_t sse_8width_msa(uint8_t *src_ptr, int32_t src_stride,
-                               uint8_t *ref_ptr, int32_t ref_stride,
+static uint32_t sse_8width_msa(const uint8_t *src_ptr, int32_t src_stride,
+                               const uint8_t *ref_ptr, int32_t ref_stride,
                                int32_t height)
 {
     int32_t ht_cnt;
@@ -458,8 +458,8 @@ static uint32_t sse_8width_msa(uint8_t *src_ptr, int32_t src_stride,
     return sse;
 }
 
-static uint32_t sse_16width_msa(uint8_t *src_ptr, int32_t src_stride,
-                                uint8_t *ref_ptr, int32_t ref_stride,
+static uint32_t sse_16width_msa(const uint8_t *src_ptr, int32_t src_stride,
+                                const uint8_t *ref_ptr, int32_t ref_stride,
                                 int32_t height)
 {
     int32_t ht_cnt;
@@ -498,8 +498,8 @@ static uint32_t sse_16width_msa(uint8_t *src_ptr, int32_t src_stride,
     return sse;
 }
 
-static int32_t hadamard_diff_8x8_msa(uint8_t *src, int32_t src_stride,
-                                     uint8_t *ref, int32_t ref_stride)
+static int32_t hadamard_diff_8x8_msa(const uint8_t *src, int32_t src_stride,
+                                     const uint8_t *ref, int32_t ref_stride)
 {
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
     v16u8 ref0, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
@@ -543,8 +543,8 @@ static int32_t hadamard_diff_8x8_msa(uint8_t *src, int32_t src_stride,
     return (HADD_UH_U32(sum));
 }
 
-static int32_t hadamard_intra_8x8_msa(uint8_t *src, int32_t src_stride,
-                                      uint8_t *ref, int32_t ref_stride)
+static int32_t hadamard_intra_8x8_msa(const uint8_t *src, int32_t src_stride,
+                                      const uint8_t *ref, int32_t ref_stride)
 {
     int32_t sum_res = 0;
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
@@ -587,79 +587,79 @@ static int32_t hadamard_intra_8x8_msa(uint8_t *src, int32_t src_stride,
     return sum_res;
 }
 
-int ff_pix_abs16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref,
+int ff_pix_abs16_msa(MpegEncContext *v, const uint8_t *src, const uint8_t *ref,
                      ptrdiff_t stride, int height)
 {
     return sad_16width_msa(src, stride, ref, stride, height);
 }
 
-int ff_pix_abs8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref,
+int ff_pix_abs8_msa(MpegEncContext *v, const uint8_t *src, const uint8_t *ref,
                     ptrdiff_t stride, int height)
 {
     return sad_8width_msa(src, stride, ref, stride, height);
 }
 
-int ff_pix_abs16_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_x2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h)
 {
     return sad_horiz_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_pix_abs16_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_y2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h)
 {
     return sad_vert_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_pix_abs16_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs16_xy2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h)
 {
     return sad_hv_bilinear_filter_16width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_pix_abs8_x2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_x2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h)
 {
     return sad_horiz_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_pix_abs8_y2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_y2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h)
 {
     return sad_vert_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_pix_abs8_xy2_msa(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_pix_abs8_xy2_msa(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h)
 {
     return sad_hv_bilinear_filter_8width_msa(pix1, stride, pix2, stride, h);
 }
 
-int ff_sse16_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref,
+int ff_sse16_msa(MpegEncContext *v, const uint8_t *src, const uint8_t *ref,
                  ptrdiff_t stride, int height)
 {
     return sse_16width_msa(src, stride, ref, stride, height);
 }
 
-int ff_sse8_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref,
+int ff_sse8_msa(MpegEncContext *v, const uint8_t *src, const uint8_t *ref,
                 ptrdiff_t stride, int height)
 {
     return sse_8width_msa(src, stride, ref, stride, height);
 }
 
-int ff_sse4_msa(MpegEncContext *v, uint8_t *src, uint8_t *ref,
+int ff_sse4_msa(MpegEncContext *v, const uint8_t *src, const uint8_t *ref,
                 ptrdiff_t stride, int height)
 {
     return sse_4width_msa(src, stride, ref, stride, height);
 }
 
-int ff_hadamard8_diff8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_diff8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                              ptrdiff_t stride, int h)
 {
     return hadamard_diff_8x8_msa(src, stride, dst, stride);
 }
 
-int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
+int ff_hadamard8_intra8x8_msa(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,
                               ptrdiff_t stride, int h)
 {
     return hadamard_intra_8x8_msa(src, stride, dst, stride);
@@ -667,7 +667,7 @@ int ff_hadamard8_intra8x8_msa(MpegEncContext *s, uint8_t *dst, uint8_t *src,
 
 /* Hadamard Transform functions */
 #define WRAPPER8_16_SQ(name8, name16)                      \
-int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src,  \
+int name16(MpegEncContext *s, const uint8_t *dst, const uint8_t *src,  \
            ptrdiff_t stride, int h)                        \
 {                                                          \
     int score = 0;                                         \
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 62c5b28364..0903536697 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -293,7 +293,7 @@ static int cmp_qpel(MpegEncContext *s, const int x, const int y, const int subx,
 
 #include "motion_est_template.c"
 
-static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
+static int zero_cmp(MpegEncContext *s, const uint8_t *a, const uint8_t *b,
                     ptrdiff_t stride, int h)
 {
     return 0;
diff --git a/libavcodec/ppc/me_cmp.c b/libavcodec/ppc/me_cmp.c
index 17f9a4f016..90f21525d7 100644
--- a/libavcodec/ppc/me_cmp.c
+++ b/libavcodec/ppc/me_cmp.c
@@ -51,7 +51,7 @@
     iv = vec_vsx_ld(1,  pix);\
 }
 #endif
-static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sad16_x2_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                             ptrdiff_t stride, int h)
 {
     int i;
@@ -91,7 +91,7 @@ static int sad16_x2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sad16_y2_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                             ptrdiff_t stride, int h)
 {
     int i;
@@ -102,7 +102,7 @@ static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     vector unsigned int sad = (vector unsigned int) vec_splat_u32(0);
     vector signed int sumdiffs;
 
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
 
     /* Due to the fact that pix3 = pix2 + stride, the pix3 of one
      * iteration becomes pix2 in the next iteration. We can use this
@@ -141,12 +141,12 @@ static int sad16_y2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sad16_xy2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sad16_xy2_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                              ptrdiff_t stride, int h)
 {
     int i;
     int  __attribute__((aligned(16))) s = 0;
-    uint8_t *pix3 = pix2 + stride;
+    const uint8_t *pix3 = pix2 + stride;
     const vector unsigned char zero =
         (const vector unsigned char) vec_splat_u8(0);
     const vector unsigned short two =
@@ -230,7 +230,7 @@ static int sad16_xy2_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sad16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sad16_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h)
 {
     int i;
@@ -265,7 +265,7 @@ static int sad16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sad8_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h)
 {
     int i;
@@ -309,7 +309,7 @@ static int sad8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
 
 /* Sum of Squared Errors for an 8x8 block, AltiVec-enhanced.
  * It's the sad8_altivec code above w/ squaring added. */
-static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sse8_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                         ptrdiff_t stride, int h)
 {
     int i;
@@ -354,7 +354,7 @@ static int sse8_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
 
 /* Sum of Squared Errors for a 16x16 block, AltiVec-enhanced.
  * It's the sad16_altivec code above w/ squaring added. */
-static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+static int sse16_altivec(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h)
 {
     int i;
@@ -392,8 +392,8 @@ static int sse16_altivec(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
     return s;
 }
 
-static int hadamard8_diff8x8_altivec(MpegEncContext *s, uint8_t *dst,
-                                     uint8_t *src, ptrdiff_t stride, int h)
+static int hadamard8_diff8x8_altivec(MpegEncContext *s, const uint8_t *dst,
+                                     const uint8_t *src, ptrdiff_t stride, int h)
 {
     int __attribute__((aligned(16))) sum;
     register const vector unsigned char vzero =
@@ -518,8 +518,8 @@ static int hadamard8_diff8x8_altivec(MpegEncContext *s, uint8_t *dst,
  * On the 970, the hand-made RA is still a win (around 690 vs. around 780),
  * but xlc goes to around 660 on the regular C code...
  */
-static int hadamard8_diff16x8_altivec(MpegEncContext *s, uint8_t *dst,
-                                      uint8_t *src, ptrdiff_t stride, int h)
+static int hadamard8_diff16x8_altivec(MpegEncContext *s, const uint8_t *dst,
+                                      const uint8_t *src, ptrdiff_t stride, int h)
 {
     int __attribute__((aligned(16))) sum;
     register vector signed short
@@ -709,8 +709,8 @@ static int hadamard8_diff16x8_altivec(MpegEncContext *s, uint8_t *dst,
     return sum;
 }
 
-static int hadamard8_diff16_altivec(MpegEncContext *s, uint8_t *dst,
-                                    uint8_t *src, ptrdiff_t stride, int h)
+static int hadamard8_diff16_altivec(MpegEncContext *s, const uint8_t *dst,
+                                    const uint8_t *src, ptrdiff_t stride, int h)
 {
     int score = hadamard8_diff16x8_altivec(s, dst, src, stride, 8);
 
diff --git a/libavcodec/snow_dwt.c b/libavcodec/snow_dwt.c
index e196fefd24..18b315ef66 100644
--- a/libavcodec/snow_dwt.c
+++ b/libavcodec/snow_dwt.c
@@ -740,7 +740,7 @@ void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height,
                               decomposition_count, y);
 }
 
-static inline int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size,
+static inline int w_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size,
                       int w, int h, int type)
 {
     int s, i, j;
@@ -809,32 +809,32 @@ static inline int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, pt
     return s >> 9;
 }
 
-static int w53_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+static int w53_8_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 8, h, 1);
 }
 
-static int w97_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+static int w97_8_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 8, h, 0);
 }
 
-static int w53_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+static int w53_16_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 16, h, 1);
 }
 
-static int w97_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+static int w97_16_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 16, h, 0);
 }
 
-int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+int ff_w53_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 32, h, 1);
 }
 
-int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
+int ff_w97_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
 {
     return w_c(v, pix1, pix2, line_size, 32, h, 0);
 }
diff --git a/libavcodec/snow_dwt.h b/libavcodec/snow_dwt.h
index 390bc57130..15b8a3007b 100644
--- a/libavcodec/snow_dwt.h
+++ b/libavcodec/snow_dwt.h
@@ -104,8 +104,8 @@ void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride,
                               int src_y, int src_stride, slice_buffer *sb,
                               int add, uint8_t *dst8);
 
-int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h);
-int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h);
+int ff_w53_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h);
+int ff_w97_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h);
 
 void ff_spatial_dwt(int *buffer, int *temp, int width, int height, int stride,
                     int type, int decomposition_count);
diff --git a/libavcodec/x86/me_cmp.asm b/libavcodec/x86/me_cmp.asm
index 10809bbfb1..eb036ee4bc 100644
--- a/libavcodec/x86/me_cmp.asm
+++ b/libavcodec/x86/me_cmp.asm
@@ -38,7 +38,7 @@ SECTION .text
     psubw           %1, %2
 %endmacro
 
-; %1=uint8_t *pix1, %2=uint8_t *pix2, %3=static offset, %4=stride, %5=stride*3
+; %1=const uint8_t *pix1, %2=const uint8_t *pix2, %3=static offset, %4=stride, %5=stride*3
 ; %6=temporary storage location
 ; this macro requires $mmsize stack space (aligned) on %6 (except on SSE+x86-64)
 %macro DIFF_PIXELS_8 6
@@ -214,8 +214,8 @@ hadamard8x8_diff %+ SUFFIX:
 hadamard8_16_wrapper %1, 3
 %elif cpuflag(mmx)
 ALIGN 16
-; int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1,
-;                               uint8_t *src2, ptrdiff_t stride, int h)
+; int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, const uint8_t *src1,
+;                               const uint8_t *src2, ptrdiff_t stride, int h)
 ; r0 = void *s = unused, int h = unused (always 8)
 ; note how r1, r2 and r3 are not clobbered in this function, so 16x16
 ; can simply call this 2x2x (and that's why we access rsp+gprsize
@@ -278,7 +278,7 @@ INIT_XMM ssse3
 %define ABS_SUM_8x8 ABS_SUM_8x8_64
 HADAMARD8_DIFF 9
 
-; int ff_sse*_*(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+; int ff_sse*_*(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
 ;               ptrdiff_t line_size, int h)
 
 %macro SUM_SQUARED_ERRORS 1
@@ -357,7 +357,7 @@ INIT_XMM sse2
 SUM_SQUARED_ERRORS 16
 
 ;-----------------------------------------------
-;int ff_sum_abs_dctelem(int16_t *block)
+;int ff_sum_abs_dctelem(const int16_t *block)
 ;-----------------------------------------------
 ; %1 = number of xmm registers used
 ; %2 = number of inline loops
@@ -390,7 +390,7 @@ INIT_XMM ssse3
 SUM_ABS_DCTELEM 6, 2
 
 ;------------------------------------------------------------------------------
-; int ff_hf_noise*_mmx(uint8_t *pix1, ptrdiff_t lsize, int h)
+; int ff_hf_noise*_mmx(const uint8_t *pix1, ptrdiff_t lsize, int h)
 ;------------------------------------------------------------------------------
 ; %1 = 8/16. %2-5=m#
 %macro HF_NOISE_PART1 5
@@ -466,7 +466,7 @@ HF_NOISE 8
 HF_NOISE 16
 
 ;---------------------------------------------------------------------------------------
-;int ff_sad_<opt>(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h);
+;int ff_sad_<opt>(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h);
 ;---------------------------------------------------------------------------------------
 ;%1 = 8/16
 %macro SAD 1
@@ -521,7 +521,7 @@ INIT_XMM sse2
 SAD 16
 
 ;------------------------------------------------------------------------------------------
-;int ff_sad_x2_<opt>(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h);
+;int ff_sad_x2_<opt>(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h);
 ;------------------------------------------------------------------------------------------
 ;%1 = 8/16
 %macro SAD_X2 1
@@ -598,7 +598,7 @@ INIT_XMM sse2
 SAD_X2 16
 
 ;------------------------------------------------------------------------------------------
-;int ff_sad_y2_<opt>(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h);
+;int ff_sad_y2_<opt>(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h);
 ;------------------------------------------------------------------------------------------
 ;%1 = 8/16
 %macro SAD_Y2 1
@@ -668,7 +668,7 @@ INIT_XMM sse2
 SAD_Y2 16
 
 ;-------------------------------------------------------------------------------------------
-;int ff_sad_approx_xy2_<opt>(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t stride, int h);
+;int ff_sad_approx_xy2_<opt>(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h);
 ;-------------------------------------------------------------------------------------------
 ;%1 = 8/16
 %macro SAD_APPROX_XY2 1
@@ -769,7 +769,7 @@ INIT_XMM sse2
 SAD_APPROX_XY2 16
 
 ;--------------------------------------------------------------------
-;int ff_vsad_intra(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+;int ff_vsad_intra(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
 ;                  ptrdiff_t line_size, int h);
 ;--------------------------------------------------------------------
 ; %1 = 8/16
@@ -830,7 +830,7 @@ INIT_XMM sse2
 VSAD_INTRA 16
 
 ;---------------------------------------------------------------------
-;int ff_vsad_approx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+;int ff_vsad_approx(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
 ;                   ptrdiff_t line_size, int h);
 ;---------------------------------------------------------------------
 ; %1 = 8/16
diff --git a/libavcodec/x86/me_cmp_init.c b/libavcodec/x86/me_cmp_init.c
index 61e9396b8f..4817117360 100644
--- a/libavcodec/x86/me_cmp_init.c
+++ b/libavcodec/x86/me_cmp_init.c
@@ -30,65 +30,65 @@
 #include "libavcodec/me_cmp.h"
 #include "libavcodec/mpegvideo.h"
 
-int ff_sum_abs_dctelem_sse2(int16_t *block);
-int ff_sum_abs_dctelem_ssse3(int16_t *block);
-int ff_sse8_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sum_abs_dctelem_sse2(const int16_t *block);
+int ff_sum_abs_dctelem_ssse3(const int16_t *block);
+int ff_sse8_mmx(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                 ptrdiff_t stride, int h);
-int ff_sse16_mmx(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sse16_mmx(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                  ptrdiff_t stride, int h);
-int ff_sse16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sse16_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                   ptrdiff_t stride, int h);
-int ff_hf_noise8_mmx(uint8_t *pix1, ptrdiff_t stride, int h);
-int ff_hf_noise16_mmx(uint8_t *pix1, ptrdiff_t stride, int h);
-int ff_sad8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_hf_noise8_mmx(const uint8_t *pix1, ptrdiff_t stride, int h);
+int ff_hf_noise16_mmx(const uint8_t *pix1, ptrdiff_t stride, int h);
+int ff_sad8_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                    ptrdiff_t stride, int h);
-int ff_sad16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                     ptrdiff_t stride, int h);
-int ff_sad16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                   ptrdiff_t stride, int h);
-int ff_sad8_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad8_x2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                       ptrdiff_t stride, int h);
-int ff_sad16_x2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_x2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h);
-int ff_sad16_x2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_x2_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                      ptrdiff_t stride, int h);
-int ff_sad8_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad8_y2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                       ptrdiff_t stride, int h);
-int ff_sad16_y2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_y2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                        ptrdiff_t stride, int h);
-int ff_sad16_y2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_y2_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                      ptrdiff_t stride, int h);
-int ff_sad8_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad8_approx_xy2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                               ptrdiff_t stride, int h);
-int ff_sad16_approx_xy2_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_approx_xy2_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                                ptrdiff_t stride, int h);
-int ff_sad16_approx_xy2_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_sad16_approx_xy2_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                              ptrdiff_t stride, int h);
-int ff_vsad_intra8_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad_intra8_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                           ptrdiff_t stride, int h);
-int ff_vsad_intra16_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad_intra16_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                            ptrdiff_t stride, int h);
-int ff_vsad_intra16_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad_intra16_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                          ptrdiff_t stride, int h);
-int ff_vsad8_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad8_approx_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                     ptrdiff_t stride, int h);
-int ff_vsad16_approx_mmxext(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad16_approx_mmxext(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                      ptrdiff_t stride, int h);
-int ff_vsad16_approx_sse2(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
+int ff_vsad16_approx_sse2(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                    ptrdiff_t stride, int h);
 
 #define hadamard_func(cpu)                                                    \
-    int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, uint8_t *src1,           \
-                                  uint8_t *src2, ptrdiff_t stride, int h);    \
-    int ff_hadamard8_diff16_ ## cpu(MpegEncContext *s, uint8_t *src1,         \
-                                    uint8_t *src2, ptrdiff_t stride, int h);
+    int ff_hadamard8_diff_ ## cpu(MpegEncContext *s, const uint8_t *src1,           \
+                                  const uint8_t *src2, ptrdiff_t stride, int h);    \
+    int ff_hadamard8_diff16_ ## cpu(MpegEncContext *s, const uint8_t *src1,         \
+                                    const uint8_t *src2, ptrdiff_t stride, int h);
 
 hadamard_func(mmxext)
 hadamard_func(sse2)
 hadamard_func(ssse3)
 
 #if HAVE_X86ASM
-static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
+static int nsse16_mmx(MpegEncContext *c, const uint8_t *pix1, const uint8_t *pix2,
                       ptrdiff_t stride, int h)
 {
     int score1, score2;
@@ -106,7 +106,7 @@ static int nsse16_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
         return score1 + FFABS(score2) * 8;
 }
 
-static int nsse8_mmx(MpegEncContext *c, uint8_t *pix1, uint8_t *pix2,
+static int nsse8_mmx(MpegEncContext *c, const uint8_t *pix1, const uint8_t *pix2,
                      ptrdiff_t stride, int h)
 {
     int score1 = ff_sse8_mmx(c, pix1, pix2, stride, h);
@@ -129,7 +129,7 @@ DECLARE_ASM_CONST(8, uint64_t, round_tab)[3] = {
     0x0002000200020002ULL,
 };
 
-static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2,
+static inline void sad8_4_mmx(const uint8_t *blk1, const uint8_t *blk2,
                               ptrdiff_t stride, int h)
 {
     x86_reg len = -stride * h;
@@ -199,8 +199,8 @@ static inline int sum_mmx(void)
 }
 
 #define PIX_SADXY(suf)                                                  \
-static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,           \
-                            uint8_t *blk1, ptrdiff_t stride, int h)     \
+static int sad8_xy2_ ## suf(MpegEncContext *v, const uint8_t *blk2,           \
+                            const uint8_t *blk1, ptrdiff_t stride, int h)     \
 {                                                                       \
     av_assert2(h == 8);                                                     \
     __asm__ volatile (                                                  \
@@ -213,8 +213,8 @@ static int sad8_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,           \
     return sum_ ## suf();                                               \
 }                                                                       \
                                                                         \
-static int sad16_xy2_ ## suf(MpegEncContext *v, uint8_t *blk2,          \
-                             uint8_t *blk1, ptrdiff_t stride, int h)    \
+static int sad16_xy2_ ## suf(MpegEncContext *v, const uint8_t *blk2,          \
+                             const uint8_t *blk1, ptrdiff_t stride, int h)    \
 {                                                                       \
     __asm__ volatile (                                                  \
         "pxor %%mm7, %%mm7     \n\t"                                    \
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 32/39] avcodec/h264chroma: Constify src in h264_chroma_mc_func
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (29 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 33/39] avcodec/cfhdencdsp: Constify input pointers Andreas Rheinhardt
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/aarch64/h264chroma_init_aarch64.c |  12 +-
 libavcodec/aarch64/h264cmc_neon.S            |   4 +-
 libavcodec/aarch64/rv40dsp_init_aarch64.c    |   8 +-
 libavcodec/aarch64/vc1dsp_init_aarch64.c     |   8 +-
 libavcodec/arm/h264chroma_init_arm.c         |  12 +-
 libavcodec/arm/h264cmc_neon.S                |   4 +-
 libavcodec/arm/rv40dsp_init_arm.c            |   8 +-
 libavcodec/arm/vc1dsp_init_neon.c            |   8 +-
 libavcodec/h264chroma.h                      |   2 +-
 libavcodec/h264chroma_template.c             |  16 +--
 libavcodec/loongarch/h264chroma_lasx.c       |  82 +++++------
 libavcodec/loongarch/h264chroma_lasx.h       |   6 +-
 libavcodec/loongarch/vc1dsp_lasx.c           |   2 +-
 libavcodec/loongarch/vc1dsp_loongarch.h      |   2 +-
 libavcodec/mips/h264chroma_mips.h            |  20 +--
 libavcodec/mips/h264chroma_mmi.c             |   8 +-
 libavcodec/mips/h264chroma_msa.c             | 142 +++++++++----------
 libavcodec/mips/vc1dsp_mips.h                |   8 +-
 libavcodec/mips/vc1dsp_mmi.c                 |   8 +-
 libavcodec/ppc/h264chroma_template.c         |   4 +-
 libavcodec/rv40dsp.c                         |   4 +-
 libavcodec/vc1dsp.c                          |   8 +-
 libavcodec/x86/h264_chromamc.asm             |   2 +-
 libavcodec/x86/h264_chromamc_10bit.asm       |   4 +-
 libavcodec/x86/h264chroma_init.c             |  22 +--
 libavcodec/x86/rv40dsp_init.c                |   8 +-
 libavcodec/x86/vc1dsp_init.c                 |   8 +-
 27 files changed, 210 insertions(+), 210 deletions(-)

diff --git a/libavcodec/aarch64/h264chroma_init_aarch64.c b/libavcodec/aarch64/h264chroma_init_aarch64.c
index fa6e0eaf15..00fc7b20f1 100644
--- a/libavcodec/aarch64/h264chroma_init_aarch64.c
+++ b/libavcodec/aarch64/h264chroma_init_aarch64.c
@@ -28,18 +28,18 @@
 
 #include "config.h"
 
-void ff_put_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_put_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_put_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
-void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
 av_cold void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth)
diff --git a/libavcodec/aarch64/h264cmc_neon.S b/libavcodec/aarch64/h264cmc_neon.S
index f8e9407854..88ccd727d0 100644
--- a/libavcodec/aarch64/h264cmc_neon.S
+++ b/libavcodec/aarch64/h264cmc_neon.S
@@ -23,7 +23,7 @@
 
 #include "libavutil/aarch64/asm.S"
 
-/* chroma_mc8(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
+/* chroma_mc8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
 .macro  h264_chroma_mc8 type, codec=h264
 function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
   .ifc \type,avg
@@ -193,7 +193,7 @@ function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
 endfunc
 .endm
 
-/* chroma_mc4(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
+/* chroma_mc4(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
 .macro  h264_chroma_mc4 type, codec=h264
 function ff_\type\()_\codec\()_chroma_mc4_neon, export=1
   .ifc \type,avg
diff --git a/libavcodec/aarch64/rv40dsp_init_aarch64.c b/libavcodec/aarch64/rv40dsp_init_aarch64.c
index 142705db98..2b91d6835a 100644
--- a/libavcodec/aarch64/rv40dsp_init_aarch64.c
+++ b/libavcodec/aarch64/rv40dsp_init_aarch64.c
@@ -25,14 +25,14 @@
 
 #include "config.h"
 
-void ff_put_rv40_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_rv40_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_put_rv40_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_rv40_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
-void ff_avg_rv40_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_rv40_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_avg_rv40_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_rv40_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
 av_cold void ff_rv40dsp_init_aarch64(RV34DSPContext *c)
diff --git a/libavcodec/aarch64/vc1dsp_init_aarch64.c b/libavcodec/aarch64/vc1dsp_init_aarch64.c
index a7976fd596..3bc0bd17ee 100644
--- a/libavcodec/aarch64/vc1dsp_init_aarch64.c
+++ b/libavcodec/aarch64/vc1dsp_init_aarch64.c
@@ -43,13 +43,13 @@ void ff_vc1_h_loop_filter8_neon(uint8_t *src, ptrdiff_t stride, int pq);
 void ff_vc1_v_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq);
 void ff_vc1_h_loop_filter16_neon(uint8_t *src, ptrdiff_t stride, int pq);
 
-void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
 
 int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst);
diff --git a/libavcodec/arm/h264chroma_init_arm.c b/libavcodec/arm/h264chroma_init_arm.c
index aae804b621..5c7d523186 100644
--- a/libavcodec/arm/h264chroma_init_arm.c
+++ b/libavcodec/arm/h264chroma_init_arm.c
@@ -26,18 +26,18 @@
 #include "libavutil/arm/cpu.h"
 #include "libavcodec/h264chroma.h"
 
-void ff_put_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_put_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_put_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
-void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
-void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int h, int x, int y);
 
 av_cold void ff_h264chroma_init_arm(H264ChromaContext *c, int bit_depth)
diff --git a/libavcodec/arm/h264cmc_neon.S b/libavcodec/arm/h264cmc_neon.S
index 3687b02ede..7272b571d3 100644
--- a/libavcodec/arm/h264cmc_neon.S
+++ b/libavcodec/arm/h264cmc_neon.S
@@ -22,7 +22,7 @@
 
 #include "libavutil/arm/asm.S"
 
-/* chroma_mc8(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
+/* chroma_mc8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
 .macro  h264_chroma_mc8 type, codec=h264
 function ff_\type\()_\codec\()_chroma_mc8_neon, export=1
         push            {r4-r7, lr}
@@ -197,7 +197,7 @@ T       cmp             r7,  #0
 endfunc
 .endm
 
-/* chroma_mc4(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
+/* chroma_mc4(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */
 .macro  h264_chroma_mc4 type, codec=h264
 function ff_\type\()_\codec\()_chroma_mc4_neon, export=1
         push            {r4-r7, lr}
diff --git a/libavcodec/arm/rv40dsp_init_arm.c b/libavcodec/arm/rv40dsp_init_arm.c
index c24854d1cd..92d2867e04 100644
--- a/libavcodec/arm/rv40dsp_init_arm.c
+++ b/libavcodec/arm/rv40dsp_init_arm.c
@@ -49,11 +49,11 @@ DECL_QPEL_Y(1);
 DECL_QPEL_Y(2);
 DECL_QPEL_Y(3);
 
-void ff_put_rv40_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
-void ff_put_rv40_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
+void ff_put_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, int, int, int, int);
+void ff_put_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, int, int, int, int);
 
-void ff_avg_rv40_chroma_mc8_neon(uint8_t *, uint8_t *, int, int, int, int);
-void ff_avg_rv40_chroma_mc4_neon(uint8_t *, uint8_t *, int, int, int, int);
+void ff_avg_rv40_chroma_mc8_neon(uint8_t *, const uint8_t *, int, int, int, int);
+void ff_avg_rv40_chroma_mc4_neon(uint8_t *, const uint8_t *, int, int, int, int);
 
 void ff_rv40_weight_func_16_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t);
 void ff_rv40_weight_func_8_neon(uint8_t *, uint8_t *, uint8_t *, int, int, ptrdiff_t);
diff --git a/libavcodec/arm/vc1dsp_init_neon.c b/libavcodec/arm/vc1dsp_init_neon.c
index 48cb816b70..46fd80a837 100644
--- a/libavcodec/arm/vc1dsp_init_neon.c
+++ b/libavcodec/arm/vc1dsp_init_neon.c
@@ -76,13 +76,13 @@ DECL_PUT(3, 1)
 DECL_PUT(3, 2)
 DECL_PUT(3, 3)
 
-void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_vc1_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
-void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_vc1_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int h, int x, int y);
 
 int ff_vc1_unescape_buffer_helper_neon(const uint8_t *src, int size, uint8_t *dst);
diff --git a/libavcodec/h264chroma.h b/libavcodec/h264chroma.h
index 3259b4935f..b8f9c8f4fc 100644
--- a/libavcodec/h264chroma.h
+++ b/libavcodec/h264chroma.h
@@ -22,7 +22,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-typedef void (*h264_chroma_mc_func)(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/, ptrdiff_t srcStride, int h, int x, int y);
+typedef void (*h264_chroma_mc_func)(uint8_t *dst /*align 8*/, const uint8_t *src /*align 1*/, ptrdiff_t srcStride, int h, int x, int y);
 
 typedef struct H264ChromaContext {
     h264_chroma_mc_func put_h264_chroma_pixels_tab[4];
diff --git a/libavcodec/h264chroma_template.c b/libavcodec/h264chroma_template.c
index a3ca07b518..b9d24f5a0c 100644
--- a/libavcodec/h264chroma_template.c
+++ b/libavcodec/h264chroma_template.c
@@ -26,9 +26,9 @@
 #include "bit_depth_template.c"
 
 #define H264_CHROMA_MC(OPNAME, OP)\
-static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst /*align 8*/, uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y){\
+static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y){\
     pixel *dst = (pixel*)_dst;\
-    pixel *src = (pixel*)_src;\
+    const pixel *src = (const pixel*)_src;\
     const int A=(8-x)*(8-y);\
     const int B=(  x)*(8-y);\
     const int C=(8-x)*(  y);\
@@ -60,10 +60,10 @@ static void FUNCC(OPNAME ## h264_chroma_mc1)(uint8_t *_dst /*align 8*/, uint8_t
         }\
     }\
 }\
-static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 8*/, uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
+static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
 {\
     pixel *dst = (pixel*)_dst;\
-    pixel *src = (pixel*)_src;\
+    const pixel *src = (const pixel*)_src;\
     const int A=(8-x)*(8-y);\
     const int B=(  x)*(8-y);\
     const int C=(8-x)*(  y);\
@@ -99,10 +99,10 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst /*align 8*/, uint8_t
     }\
 }\
 \
-static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst /*align 8*/, uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
+static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
 {\
     pixel *dst = (pixel*)_dst;\
-    pixel *src = (pixel*)_src;\
+    const pixel *src = (const pixel*)_src;\
     const int A=(8-x)*(8-y);\
     const int B=(  x)*(8-y);\
     const int C=(8-x)*(  y);\
@@ -144,10 +144,10 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst /*align 8*/, uint8_t
     }\
 }\
 \
-static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst /*align 8*/, uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
+static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst /*align 8*/, const uint8_t *_src /*align 1*/, ptrdiff_t stride, int h, int x, int y)\
 {\
     pixel *dst = (pixel*)_dst;\
-    pixel *src = (pixel*)_src;\
+    const pixel *src = (const pixel*)_src;\
     const int A=(8-x)*(8-y);\
     const int B=(  x)*(8-y);\
     const int C=(8-x)*(  y);\
diff --git a/libavcodec/loongarch/h264chroma_lasx.c b/libavcodec/loongarch/h264chroma_lasx.c
index 824a78dfc8..1c0e002bdf 100644
--- a/libavcodec/loongarch/h264chroma_lasx.c
+++ b/libavcodec/loongarch/h264chroma_lasx.c
@@ -33,7 +33,7 @@ static const uint8_t chroma_mask_arr[64] = {
     0, 1, 1, 2, 2, 3, 3, 4, 16, 17, 17, 18, 18, 19, 19, 20
 };
 
-static av_always_inline void avc_chroma_hv_8x4_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_hv_8x4_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coef_hor0,
                              uint32_t coef_hor1, uint32_t coef_ver0,
                              uint32_t coef_ver1)
@@ -71,7 +71,7 @@ static av_always_inline void avc_chroma_hv_8x4_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(out, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hv_8x8_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_hv_8x8_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coef_hor0,
                              uint32_t coef_hor1, uint32_t coef_ver0,
                              uint32_t coef_ver1)
@@ -127,7 +127,7 @@ static av_always_inline void avc_chroma_hv_8x8_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hz_8x4_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_hz_8x4_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2x = stride << 1;
@@ -154,7 +154,7 @@ static av_always_inline void avc_chroma_hz_8x4_lasx(uint8_t *src, uint8_t *dst,
 
 }
 
-static av_always_inline void avc_chroma_hz_8x8_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_hz_8x8_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2x = stride << 1;
@@ -193,7 +193,7 @@ static av_always_inline void avc_chroma_hz_8x8_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hz_nonmult_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_hz_nonmult_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coeff0,
                              uint32_t coeff1, int32_t height)
 {
@@ -239,7 +239,7 @@ static av_always_inline void avc_chroma_hz_nonmult_lasx(uint8_t *src,
     }
 }
 
-static av_always_inline void avc_chroma_vt_8x4_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_vt_8x4_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2x = stride << 1;
@@ -266,7 +266,7 @@ static av_always_inline void avc_chroma_vt_8x4_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(out, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_vt_8x8_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avc_chroma_vt_8x8_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride, uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2x = stride << 1;
@@ -307,7 +307,7 @@ static av_always_inline void avc_chroma_vt_8x8_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void copy_width8x8_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void copy_width8x8_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride)
 {
     uint64_t tmp[8];
@@ -347,7 +347,7 @@ static av_always_inline void copy_width8x8_lasx(uint8_t *src, uint8_t *dst,
     );
 }
 
-static av_always_inline void copy_width8x4_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void copy_width8x4_lasx(const uint8_t *src, uint8_t *dst,
                              ptrdiff_t stride)
 {
     uint64_t tmp[4];
@@ -372,7 +372,7 @@ static av_always_inline void copy_width8x4_lasx(uint8_t *src, uint8_t *dst,
     );
 }
 
-static void avc_chroma_hv_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hv_8w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1,
                                   int32_t height)
@@ -386,7 +386,7 @@ static void avc_chroma_hv_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void avc_chroma_hv_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hv_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coef_hor0, uint32_t coef_hor1,
                                    uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -414,7 +414,7 @@ static void avc_chroma_hv_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res_vt, dst + stride, 0, 1);
 }
 
-static void avc_chroma_hv_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hv_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coef_hor0, uint32_t coef_hor1,
                                    uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -446,7 +446,7 @@ static void avc_chroma_hv_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res_hz0, dst + stride_3, 0, 5);
 }
 
-static void avc_chroma_hv_4x8_lasx(uint8_t *src, uint8_t * dst, ptrdiff_t stride,
+static void avc_chroma_hv_4x8_lasx(const uint8_t *src, uint8_t * dst, ptrdiff_t stride,
                                    uint32_t coef_hor0, uint32_t coef_hor1,
                                    uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -492,7 +492,7 @@ static void avc_chroma_hv_4x8_lasx(uint8_t *src, uint8_t * dst, ptrdiff_t stride
     __lasx_xvstelm_w(res_hz0, dst + stride_3, 0, 7);
 }
 
-static void avc_chroma_hv_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hv_4w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1,
                                   int32_t height)
@@ -509,7 +509,7 @@ static void avc_chroma_hv_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void avc_chroma_hz_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hz_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     __m256i src0, src1;
@@ -528,7 +528,7 @@ static void avc_chroma_hz_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res, dst + stride, 0, 1);
 }
 
-static void avc_chroma_hz_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hz_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2 = stride << 1;
@@ -553,7 +553,7 @@ static void avc_chroma_hz_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res, dst + stride_3, 0, 5);
 }
 
-static void avc_chroma_hz_4x8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hz_4x8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2 = stride << 1;
@@ -588,7 +588,7 @@ static void avc_chroma_hz_4x8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res0, dst + stride_3, 0, 7);
 }
 
-static void avc_chroma_hz_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hz_4w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coeff0, uint32_t coeff1,
                                   int32_t height)
 {
@@ -601,7 +601,7 @@ static void avc_chroma_hz_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void avc_chroma_hz_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_hz_8w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coeff0, uint32_t coeff1,
                                   int32_t height)
 {
@@ -614,7 +614,7 @@ static void avc_chroma_hz_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void avc_chroma_vt_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_vt_4x2_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     __m256i src0, src1, src2;
@@ -635,7 +635,7 @@ static void avc_chroma_vt_4x2_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res, dst + stride, 0, 1);
 }
 
-static void avc_chroma_vt_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_vt_4x4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2 = stride << 1;
@@ -664,7 +664,7 @@ static void avc_chroma_vt_4x4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res, dst + stride_3, 0, 5);
 }
 
-static void avc_chroma_vt_4x8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_vt_4x8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                    uint32_t coeff0, uint32_t coeff1)
 {
     ptrdiff_t stride_2 = stride << 1;
@@ -705,7 +705,7 @@ static void avc_chroma_vt_4x8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     __lasx_xvstelm_w(res0, dst + stride_3, 0, 7);
 }
 
-static void avc_chroma_vt_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_vt_4w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coeff0, uint32_t coeff1,
                                   int32_t height)
 {
@@ -718,7 +718,7 @@ static void avc_chroma_vt_4w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void avc_chroma_vt_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avc_chroma_vt_8w_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                                   uint32_t coeff0, uint32_t coeff1,
                                   int32_t height)
 {
@@ -729,7 +729,7 @@ static void avc_chroma_vt_8w_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void copy_width4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void copy_width4_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                              int32_t height)
 {
     uint32_t tp0, tp1, tp2, tp3, tp4, tp5, tp6, tp7;
@@ -799,7 +799,7 @@ static void copy_width4_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-static void copy_width8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void copy_width8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                              int32_t height)
 {
     if (8 == height) {
@@ -809,7 +809,7 @@ static void copy_width8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-void ff_put_h264_chroma_mc4_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -825,7 +825,7 @@ void ff_put_h264_chroma_mc4_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
     }
 }
 
-void ff_put_h264_chroma_mc8_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -841,7 +841,7 @@ void ff_put_h264_chroma_mc8_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
     }
 }
 
-static av_always_inline void avc_chroma_hv_and_aver_dst_8x4_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_hv_and_aver_dst_8x4_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coef_hor0,
                              uint32_t coef_hor1, uint32_t coef_ver0,
                              uint32_t coef_ver1)
@@ -885,7 +885,7 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x4_lasx(uint8_t *src,
     __lasx_xvstelm_d(out, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hv_and_aver_dst_8x8_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_hv_and_aver_dst_8x8_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coef_hor0,
                              uint32_t coef_hor1, uint32_t coef_ver0,
                              uint32_t coef_ver1)
@@ -957,7 +957,7 @@ static av_always_inline void avc_chroma_hv_and_aver_dst_8x8_lasx(uint8_t *src,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hz_and_aver_dst_8x4_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_hz_and_aver_dst_8x4_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coeff0,
                              uint32_t coeff1)
 {
@@ -990,7 +990,7 @@ static av_always_inline void avc_chroma_hz_and_aver_dst_8x4_lasx(uint8_t *src,
     __lasx_xvstelm_d(out, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_hz_and_aver_dst_8x8_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_hz_and_aver_dst_8x8_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coeff0,
                              uint32_t coeff1)
 {
@@ -1043,7 +1043,7 @@ static av_always_inline void avc_chroma_hz_and_aver_dst_8x8_lasx(uint8_t *src,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_vt_and_aver_dst_8x4_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_vt_and_aver_dst_8x4_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coeff0,
                              uint32_t coeff1)
 {
@@ -1077,7 +1077,7 @@ static av_always_inline void avc_chroma_vt_and_aver_dst_8x4_lasx(uint8_t *src,
     __lasx_xvstelm_d(out, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avc_chroma_vt_and_aver_dst_8x8_lasx(uint8_t *src,
+static av_always_inline void avc_chroma_vt_and_aver_dst_8x8_lasx(const uint8_t *src,
                              uint8_t *dst, ptrdiff_t stride, uint32_t coeff0,
                              uint32_t coeff1)
 {
@@ -1132,7 +1132,7 @@ static av_always_inline void avc_chroma_vt_and_aver_dst_8x8_lasx(uint8_t *src,
     __lasx_xvstelm_d(out1, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avg_width8x8_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avg_width8x8_lasx(const uint8_t *src, uint8_t *dst,
                                                ptrdiff_t stride)
 {
     __m256i src0, src1, src2, src3;
@@ -1184,7 +1184,7 @@ static av_always_inline void avg_width8x8_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(dst0, dst + stride_3x, 0, 3);
 }
 
-static av_always_inline void avg_width8x4_lasx(uint8_t *src, uint8_t *dst,
+static av_always_inline void avg_width8x4_lasx(const uint8_t *src, uint8_t *dst,
                                                ptrdiff_t stride)
 {
     __m256i src0, src1, src2, src3;
@@ -1213,7 +1213,7 @@ static av_always_inline void avg_width8x4_lasx(uint8_t *src, uint8_t *dst,
     __lasx_xvstelm_d(dst0, dst + stride_3x, 0, 3);
 }
 
-static void avc_chroma_hv_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_8w_lasx(const uint8_t *src, uint8_t *dst,
                                                ptrdiff_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1230,7 +1230,7 @@ static void avc_chroma_hv_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hz_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_8w_lasx(const uint8_t *src, uint8_t *dst,
                                                ptrdiff_t stride, uint32_t coeff0,
                                                uint32_t coeff1, int32_t height)
 {
@@ -1241,7 +1241,7 @@ static void avc_chroma_hz_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_vt_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_8w_lasx(const uint8_t *src, uint8_t *dst,
                                                ptrdiff_t stride, uint32_t coeff0,
                                                uint32_t coeff1, int32_t height)
 {
@@ -1252,7 +1252,7 @@ static void avc_chroma_vt_and_aver_dst_8w_lasx(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avg_width8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
+static void avg_width8_lasx(const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
                             int32_t height)
 {
     if (8 == height) {
@@ -1262,7 +1262,7 @@ static void avg_width8_lasx(uint8_t *src, uint8_t *dst, ptrdiff_t stride,
     }
 }
 
-void ff_avg_h264_chroma_mc8_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                  int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
diff --git a/libavcodec/loongarch/h264chroma_lasx.h b/libavcodec/loongarch/h264chroma_lasx.h
index 4aac8db8cb..633752035e 100644
--- a/libavcodec/loongarch/h264chroma_lasx.h
+++ b/libavcodec/loongarch/h264chroma_lasx.h
@@ -26,11 +26,11 @@
 #include <stddef.h>
 #include "libavcodec/h264.h"
 
-void ff_put_h264_chroma_mc4_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
-void ff_put_h264_chroma_mc8_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
-void ff_avg_h264_chroma_mc8_lasx(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_lasx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
 
 #endif /* AVCODEC_LOONGARCH_H264CHROMA_LASX_H */
diff --git a/libavcodec/loongarch/vc1dsp_lasx.c b/libavcodec/loongarch/vc1dsp_lasx.c
index 40b8668f2b..848fe4afb3 100644
--- a/libavcodec/loongarch/vc1dsp_lasx.c
+++ b/libavcodec/loongarch/vc1dsp_lasx.c
@@ -698,7 +698,7 @@ PUT_VC1_MSPEL_MC_LASX(3, 2);
 PUT_VC1_MSPEL_MC_LASX(3, 3);
 
 void ff_put_no_rnd_vc1_chroma_mc8_lasx(uint8_t *dst /* align 8 */,
-                                       uint8_t *src /* align 1 */,
+                                       const uint8_t *src /* align 1 */,
                                        ptrdiff_t stride, int h, int x, int y)
 {
     const int intA = (8 - x) * (8 - y);
diff --git a/libavcodec/loongarch/vc1dsp_loongarch.h b/libavcodec/loongarch/vc1dsp_loongarch.h
index 398631aecc..e5ccbcb768 100644
--- a/libavcodec/loongarch/vc1dsp_loongarch.h
+++ b/libavcodec/loongarch/vc1dsp_loongarch.h
@@ -73,7 +73,7 @@ FF_PUT_VC1_MSPEL_MC_H_LASX(2);
 FF_PUT_VC1_MSPEL_MC_H_LASX(3);
 
 void ff_put_no_rnd_vc1_chroma_mc8_lasx(uint8_t *dst /* align 8 */,
-                                       uint8_t *src /* align 1 */,
+                                       const uint8_t *src /* align 1 */,
                                        ptrdiff_t stride, int h, int x, int y);
 
 #endif /* AVCODEC_LOONGARCH_VC1DSP_LOONGARCH_H */
diff --git a/libavcodec/mips/h264chroma_mips.h b/libavcodec/mips/h264chroma_mips.h
index 996384d005..c694e34b3f 100644
--- a/libavcodec/mips/h264chroma_mips.h
+++ b/libavcodec/mips/h264chroma_mips.h
@@ -22,26 +22,26 @@
 #define AVCODEC_MIPS_H264CHROMA_MIPS_H
 
 #include "libavcodec/h264dec.h"
-void ff_put_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
-void ff_put_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
-void ff_put_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc2_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
-void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
-void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
-void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
                                 int height, int x, int y);
 
-void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
-void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
-void ff_put_h264_chroma_mc4_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
-void ff_avg_h264_chroma_mc4_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc4_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y);
 
 #endif /* AVCODEC_MIPS_H264CHROMA_MIPS_H */
diff --git a/libavcodec/mips/h264chroma_mmi.c b/libavcodec/mips/h264chroma_mmi.c
index ec35c5a72e..fe05ccd671 100644
--- a/libavcodec/mips/h264chroma_mmi.c
+++ b/libavcodec/mips/h264chroma_mmi.c
@@ -26,7 +26,7 @@
 #include "constants.h"
 #include "libavutil/mips/mmiutils.h"
 
-void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y)
 {
     double ftmp[12];
@@ -289,7 +289,7 @@ void ff_put_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
     }
 }
 
-void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y)
 {
     double ftmp[10];
@@ -497,7 +497,7 @@ void ff_avg_h264_chroma_mc8_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
     }
 }
 
-void ff_put_h264_chroma_mc4_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_put_h264_chroma_mc4_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y)
 {
     double ftmp[8];
@@ -618,7 +618,7 @@ void ff_put_h264_chroma_mc4_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
     }
 }
 
-void ff_avg_h264_chroma_mc4_mmi(uint8_t *dst, uint8_t *src, ptrdiff_t stride,
+void ff_avg_h264_chroma_mc4_mmi(uint8_t *dst, const uint8_t *src, ptrdiff_t stride,
         int h, int x, int y)
 {
     double ftmp[8];
diff --git a/libavcodec/mips/h264chroma_msa.c b/libavcodec/mips/h264chroma_msa.c
index 4a68d9e134..141f52c2be 100644
--- a/libavcodec/mips/h264chroma_msa.c
+++ b/libavcodec/mips/h264chroma_msa.c
@@ -29,7 +29,7 @@ static const uint8_t chroma_mask_arr[16 * 5] = {
     0, 1, 1, 2, 16, 17, 17, 18, 16, 17, 17, 18, 18, 19, 19, 20
 };
 
-static void avc_chroma_hz_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_2x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     uint16_t out0, out1;
@@ -60,7 +60,7 @@ static void avc_chroma_hz_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     SH(out1, dst);
 }
 
-static void avc_chroma_hz_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_2x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3;
@@ -88,7 +88,7 @@ static void avc_chroma_hz_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_H4(res, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_2w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -99,7 +99,7 @@ static void avc_chroma_hz_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hz_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_4x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16i8 src0, src1;
@@ -124,7 +124,7 @@ static void avc_chroma_hz_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W2(res, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, out;
@@ -147,7 +147,7 @@ static void avc_chroma_hz_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W4(out, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_4x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7, out0, out1;
@@ -171,7 +171,7 @@ static void avc_chroma_hz_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_4w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -184,7 +184,7 @@ static void avc_chroma_hz_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hz_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_8x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, out0, out1;
@@ -207,7 +207,7 @@ static void avc_chroma_hz_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_8x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
@@ -240,7 +240,7 @@ static void avc_chroma_hz_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_nonmult_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_nonmult_msa(const uint8_t *src, uint8_t *dst,
                                       int32_t stride, uint32_t coeff0,
                                       uint32_t coeff1, int32_t height)
 {
@@ -289,7 +289,7 @@ static void avc_chroma_hz_nonmult_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hz_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hz_8w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -302,7 +302,7 @@ static void avc_chroma_hz_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_vt_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_2x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     uint16_t out0, out1;
@@ -334,7 +334,7 @@ static void avc_chroma_vt_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     SH(out1, dst);
 }
 
-static void avc_chroma_vt_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_2x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4;
@@ -362,7 +362,7 @@ static void avc_chroma_vt_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_H4(res, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_2w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -373,7 +373,7 @@ static void avc_chroma_vt_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_vt_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_4x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2;
@@ -397,7 +397,7 @@ static void avc_chroma_vt_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W2(res, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4;
@@ -421,7 +421,7 @@ static void avc_chroma_vt_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W4(out, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_4x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
@@ -449,7 +449,7 @@ static void avc_chroma_vt_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_4w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -462,7 +462,7 @@ static void avc_chroma_vt_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_vt_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_8x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4, out0, out1;
@@ -483,7 +483,7 @@ static void avc_chroma_vt_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_8x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coeff0, uint32_t coeff1)
 {
     v16u8 src0, src1, src2, src3, src4, src5, src6, src7, src8;
@@ -515,7 +515,7 @@ static void avc_chroma_vt_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_vt_8w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coeff0, uint32_t coeff1,
                                  int32_t height)
 {
@@ -526,7 +526,7 @@ static void avc_chroma_vt_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hv_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_2x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -561,7 +561,7 @@ static void avc_chroma_hv_2x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     SH(out1, dst);
 }
 
-static void avc_chroma_hv_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_2x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -595,7 +595,7 @@ static void avc_chroma_hv_2x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_H4(res, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hv_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_2w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coef_hor0, uint32_t coef_hor1,
                                  uint32_t coef_ver0, uint32_t coef_ver1,
                                  int32_t height)
@@ -609,7 +609,7 @@ static void avc_chroma_hv_2w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hv_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_4x2_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -637,7 +637,7 @@ static void avc_chroma_hv_4x2_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W2(res, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_4x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -670,7 +670,7 @@ static void avc_chroma_hv_4x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W2(res1, 0, 1, dst + 2 * stride, stride);
 }
 
-static void avc_chroma_hv_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_4x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -710,7 +710,7 @@ static void avc_chroma_hv_4x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_W8(res0, res1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hv_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_4w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coef_hor0, uint32_t coef_hor1,
                                  uint32_t coef_ver0, uint32_t coef_ver1,
                                  int32_t height)
@@ -727,7 +727,7 @@ static void avc_chroma_hv_4w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hv_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_8x4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -770,7 +770,7 @@ static void avc_chroma_hv_8x4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_8x8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                   uint32_t coef_hor0, uint32_t coef_hor1,
                                   uint32_t coef_ver0, uint32_t coef_ver1)
 {
@@ -826,7 +826,7 @@ static void avc_chroma_hv_8x8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avc_chroma_hv_8w_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                                  uint32_t coef_hor0, uint32_t coef_hor1,
                                  uint32_t coef_ver0, uint32_t coef_ver1,
                                  int32_t height)
@@ -840,7 +840,7 @@ static void avc_chroma_hv_8w_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avc_chroma_hz_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_2x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -882,7 +882,7 @@ static void avc_chroma_hz_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
     SH(out1, dst);
 }
 
-static void avc_chroma_hz_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_2x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -922,7 +922,7 @@ static void avc_chroma_hz_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
     ST_H4(dst0, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_2w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -933,7 +933,7 @@ static void avc_chroma_hz_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hz_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_4x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -966,7 +966,7 @@ static void avc_chroma_hz_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
     ST_W2(dst_data, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_4x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -995,7 +995,7 @@ static void avc_chroma_hz_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
     ST_W4(out, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_4x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1027,7 +1027,7 @@ static void avc_chroma_hz_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
     ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_4w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -1040,7 +1040,7 @@ static void avc_chroma_hz_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hz_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_8x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1070,7 +1070,7 @@ static void avc_chroma_hz_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
     ST_D4(dst0, dst1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_8x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1114,7 +1114,7 @@ static void avc_chroma_hz_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hz_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hz_and_aver_dst_8w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -1125,7 +1125,7 @@ static void avc_chroma_hz_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_vt_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_2x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1162,7 +1162,7 @@ static void avc_chroma_vt_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
     SH(out1, dst);
 }
 
-static void avc_chroma_vt_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_2x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1204,7 +1204,7 @@ static void avc_chroma_vt_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
     ST_H4(res, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_2w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -1215,7 +1215,7 @@ static void avc_chroma_vt_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_vt_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_4x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1247,7 +1247,7 @@ static void avc_chroma_vt_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
     ST_W2(res, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_4x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1277,7 +1277,7 @@ static void avc_chroma_vt_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
     ST_W4(out, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_4x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1313,7 +1313,7 @@ static void avc_chroma_vt_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
     ST_W8(out0, out1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_4w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -1326,7 +1326,7 @@ static void avc_chroma_vt_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_vt_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_8x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1355,7 +1355,7 @@ static void avc_chroma_vt_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_8x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride, uint32_t coeff0,
                                                uint32_t coeff1)
 {
@@ -1398,7 +1398,7 @@ static void avc_chroma_vt_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_vt_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_vt_and_aver_dst_8w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride, uint32_t coeff0,
                                               uint32_t coeff1, int32_t height)
 {
@@ -1409,7 +1409,7 @@ static void avc_chroma_vt_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hv_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_2x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1451,7 +1451,7 @@ static void avc_chroma_hv_and_aver_dst_2x2_msa(uint8_t *src, uint8_t *dst,
     SH(out1, dst);
 }
 
-static void avc_chroma_hv_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_2x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1496,7 +1496,7 @@ static void avc_chroma_hv_and_aver_dst_2x4_msa(uint8_t *src, uint8_t *dst,
     ST_H4(dst0, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_2w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride,
                                               uint32_t coef_hor0,
                                               uint32_t coef_hor1,
@@ -1513,7 +1513,7 @@ static void avc_chroma_hv_and_aver_dst_2w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hv_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_4x2_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1549,7 +1549,7 @@ static void avc_chroma_hv_and_aver_dst_4x2_msa(uint8_t *src, uint8_t *dst,
     ST_W2(dst0, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_4x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1588,7 +1588,7 @@ static void avc_chroma_hv_and_aver_dst_4x4_msa(uint8_t *src, uint8_t *dst,
     ST_W4(out, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_4x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1637,7 +1637,7 @@ static void avc_chroma_hv_and_aver_dst_4x8_msa(uint8_t *src, uint8_t *dst,
     ST_W8(res0, res1, 0, 1, 2, 3, 0, 1, 2, 3, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_4w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride,
                                               uint32_t coef_hor0,
                                               uint32_t coef_hor1,
@@ -1657,7 +1657,7 @@ static void avc_chroma_hv_and_aver_dst_4w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void avc_chroma_hv_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_8x4_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1705,7 +1705,7 @@ static void avc_chroma_hv_and_aver_dst_8x4_msa(uint8_t *src, uint8_t *dst,
     ST_D4(out0, out1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_8x8_msa(const uint8_t *src, uint8_t *dst,
                                                int32_t stride,
                                                uint32_t coef_hor0,
                                                uint32_t coef_hor1,
@@ -1774,7 +1774,7 @@ static void avc_chroma_hv_and_aver_dst_8x8_msa(uint8_t *src, uint8_t *dst,
     ST_D8(out0, out1, out2, out3, 0, 1, 0, 1, 0, 1, 0, 1, dst, stride);
 }
 
-static void avc_chroma_hv_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
+static void avc_chroma_hv_and_aver_dst_8w_msa(const uint8_t *src, uint8_t *dst,
                                               int32_t stride,
                                               uint32_t coef_hor0,
                                               uint32_t coef_hor1,
@@ -1791,7 +1791,7 @@ static void avc_chroma_hv_and_aver_dst_8w_msa(uint8_t *src, uint8_t *dst,
     }
 }
 
-static void copy_width4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void copy_width4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                             int32_t height)
 {
     uint32_t tp0, tp1, tp2, tp3, tp4, tp5, tp6, tp7;
@@ -1814,7 +1814,7 @@ static void copy_width4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void copy_width8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void copy_width8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                             int32_t height)
 {
     uint64_t src0, src1, src2, src3, src4, src5, src6, src7;
@@ -1832,7 +1832,7 @@ static void copy_width8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avg_width4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avg_width4_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                            int32_t height)
 {
     uint32_t tp0, tp1, tp2, tp3;
@@ -1867,7 +1867,7 @@ static void avg_width4_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-static void avg_width8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
+static void avg_width8_msa(const uint8_t *src, uint8_t *dst, int32_t stride,
                            int32_t height)
 {
     uint64_t tp0, tp1, tp2, tp3, tp4, tp5, tp6, tp7;
@@ -1903,7 +1903,7 @@ static void avg_width8_msa(uint8_t *src, uint8_t *dst, int32_t stride,
     }
 }
 
-void ff_put_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc8_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -1919,7 +1919,7 @@ void ff_put_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_put_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc4_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -1935,7 +1935,7 @@ void ff_put_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_put_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc2_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     int32_t cnt;
@@ -1958,7 +1958,7 @@ void ff_put_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -1976,7 +1976,7 @@ void ff_avg_h264_chroma_mc8_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     av_assert2(x < 8 && y < 8 && x >= 0 && y >= 0);
@@ -1993,7 +1993,7 @@ void ff_avg_h264_chroma_mc4_msa(uint8_t *dst, uint8_t *src,
     }
 }
 
-void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc2_msa(uint8_t *dst, const uint8_t *src,
                                 ptrdiff_t stride, int height, int x, int y)
 {
     int32_t cnt;
diff --git a/libavcodec/mips/vc1dsp_mips.h b/libavcodec/mips/vc1dsp_mips.h
index 356153cab6..8fcff26b14 100644
--- a/libavcodec/mips/vc1dsp_mips.h
+++ b/libavcodec/mips/vc1dsp_mips.h
@@ -179,16 +179,16 @@ void ff_vc1_v_loop_filter16_mmi(uint8_t *src, ptrdiff_t stride, int pq);
 void ff_vc1_h_loop_filter16_mmi(uint8_t *src, ptrdiff_t stride, int pq);
 
 void ff_put_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y);
 void ff_put_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y);
 void ff_avg_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y);
 void ff_avg_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y);
 
 void ff_vc1_inv_trans_8x8_msa(int16_t block[64]);
diff --git a/libavcodec/mips/vc1dsp_mmi.c b/libavcodec/mips/vc1dsp_mmi.c
index 278aa566bc..290b47d697 100644
--- a/libavcodec/mips/vc1dsp_mmi.c
+++ b/libavcodec/mips/vc1dsp_mmi.c
@@ -2235,7 +2235,7 @@ DECLARE_FUNCTION(3, 3)
 
 
 void ff_put_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y)
 {
     union mmi_intfloat64 A, B, C, D;
@@ -2291,7 +2291,7 @@ void ff_put_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
 }
 
 void ff_put_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y)
 {
     union mmi_intfloat64 A, B, C, D;
@@ -2345,7 +2345,7 @@ void ff_put_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* align 8 */,
 }
 
 void ff_avg_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y)
 {
     union mmi_intfloat64 A, B, C, D;
@@ -2404,7 +2404,7 @@ void ff_avg_no_rnd_vc1_chroma_mc8_mmi(uint8_t *dst /* align 8 */,
 }
 
 void ff_avg_no_rnd_vc1_chroma_mc4_mmi(uint8_t *dst /* align 8 */,
-                                      uint8_t *src /* align 1 */,
+                                      const uint8_t *src /* align 1 */,
                                       ptrdiff_t stride, int h, int x, int y)
 {
     union mmi_intfloat64 A, B, C, D;
diff --git a/libavcodec/ppc/h264chroma_template.c b/libavcodec/ppc/h264chroma_template.c
index eda98c67ec..c64856bb14 100644
--- a/libavcodec/ppc/h264chroma_template.c
+++ b/libavcodec/ppc/h264chroma_template.c
@@ -109,7 +109,7 @@
 #endif /* HAVE_BIGENDIAN */
 
 #ifdef PREFIX_h264_chroma_mc8_altivec
-static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src,
+static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, const uint8_t * src,
                                            ptrdiff_t stride, int h,
                                            int x, int y)
 {
@@ -184,7 +184,7 @@ static void PREFIX_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src,
 
 /* this code assume that stride % 16 == 0 */
 #ifdef PREFIX_no_rnd_vc1_chroma_mc8_altivec
-static void PREFIX_no_rnd_vc1_chroma_mc8_altivec(uint8_t *dst, uint8_t *src,
+static void PREFIX_no_rnd_vc1_chroma_mc8_altivec(uint8_t *dst, const uint8_t *src,
                                                  ptrdiff_t stride, int h,
                                                  int x, int y)
 {
diff --git a/libavcodec/rv40dsp.c b/libavcodec/rv40dsp.c
index a09179ae85..f0208b16ea 100644
--- a/libavcodec/rv40dsp.c
+++ b/libavcodec/rv40dsp.c
@@ -292,7 +292,7 @@ static const int rv40_bias[4][4] = {
 
 #define RV40_CHROMA_MC(OPNAME, OP)\
 static void OPNAME ## rv40_chroma_mc4_c(uint8_t *dst /*align 8*/,\
-                                        uint8_t *src /*align 1*/,\
+                                        const uint8_t *src /*align 1*/,\
                                         ptrdiff_t stride, int h, int x, int y)\
 {\
     const int A = (8-x) * (8-y);\
@@ -328,7 +328,7 @@ static void OPNAME ## rv40_chroma_mc4_c(uint8_t *dst /*align 8*/,\
 }\
 \
 static void OPNAME ## rv40_chroma_mc8_c(uint8_t *dst/*align 8*/,\
-                                        uint8_t *src/*align 1*/,\
+                                        const uint8_t *src/*align 1*/,\
                                         ptrdiff_t stride, int h, int x, int y)\
 {\
     const int A = (8-x) * (8-y);\
diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c
index 62c553bc01..62c8eb21fa 100644
--- a/libavcodec/vc1dsp.c
+++ b/libavcodec/vc1dsp.c
@@ -787,7 +787,7 @@ PUT_VC1_MSPEL(3, 3)
     ((A * src[a] + B * src[a + 1] + \
       C * src[stride + a] + D * src[stride + a + 1] + 32 - 4) >> 6)
 static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
-                                        uint8_t *src /* align 1 */,
+                                        const uint8_t *src /* align 1 */,
                                         ptrdiff_t stride, int h, int x, int y)
 {
     const int A = (8 - x) * (8 - y);
@@ -812,7 +812,7 @@ static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
     }
 }
 
-static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src,
+static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, const uint8_t *src,
                                         ptrdiff_t stride, int h, int x, int y)
 {
     const int A = (8 - x) * (8 - y);
@@ -835,7 +835,7 @@ static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src,
 
 #define avg2(a, b) (((a) + (b) + 1) >> 1)
 static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
-                                        uint8_t *src /* align 1 */,
+                                        const uint8_t *src /* align 1 */,
                                         ptrdiff_t stride, int h, int x, int y)
 {
     const int A = (8 - x) * (8 - y);
@@ -861,7 +861,7 @@ static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst /* align 8 */,
 }
 
 static void avg_no_rnd_vc1_chroma_mc4_c(uint8_t *dst /* align 8 */,
-                                        uint8_t *src /* align 1 */,
+                                        const uint8_t *src /* align 1 */,
                                         ptrdiff_t stride, int h, int x, int y)
 {
     const int A = (8 - x) * (8 - y);
diff --git a/libavcodec/x86/h264_chromamc.asm b/libavcodec/x86/h264_chromamc.asm
index e562efd69d..a5c53034a2 100644
--- a/libavcodec/x86/h264_chromamc.asm
+++ b/libavcodec/x86/h264_chromamc.asm
@@ -104,7 +104,7 @@ SECTION .text
 %define extra_regs 0
 %endif ; rv40
 ; void ff_put/avg_h264_chroma_mc8_*(uint8_t *dst /* align 8 */,
-;                                   uint8_t *src /* align 1 */,
+;                                   const uint8_t *src /* align 1 */,
 ;                                   ptrdiff_t stride, int h, int mx, int my)
 cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
     mov          r6d, r5d
diff --git a/libavcodec/x86/h264_chromamc_10bit.asm b/libavcodec/x86/h264_chromamc_10bit.asm
index 34bc41969b..fdc4f407c7 100644
--- a/libavcodec/x86/h264_chromamc_10bit.asm
+++ b/libavcodec/x86/h264_chromamc_10bit.asm
@@ -57,7 +57,7 @@ SECTION .text
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void ff_put/avg_h264_chroma_mc8(pixel *dst, pixel *src, ptrdiff_t stride,
+; void ff_put/avg_h264_chroma_mc8(pixel *dst, const pixel *src, ptrdiff_t stride,
 ;                                 int h, int mx, int my)
 ;-----------------------------------------------------------------------------
 %macro CHROMA_MC8 1
@@ -198,7 +198,7 @@ cglobal %1_h264_chroma_mc4_10, 6,6,7
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void ff_put/avg_h264_chroma_mc2(pixel *dst, pixel *src, ptrdiff_t stride,
+; void ff_put/avg_h264_chroma_mc2(pixel *dst, const pixel *src, ptrdiff_t stride,
 ;                                 int h, int mx, int my)
 ;-----------------------------------------------------------------------------
 %macro CHROMA_MC2 1
diff --git a/libavcodec/x86/h264chroma_init.c b/libavcodec/x86/h264chroma_init.c
index 7c0f492178..b54afd4c08 100644
--- a/libavcodec/x86/h264chroma_init.c
+++ b/libavcodec/x86/h264chroma_init.c
@@ -24,34 +24,34 @@
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/h264chroma.h"
 
-void ff_put_h264_chroma_mc8_rnd_mmx  (uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc8_rnd_mmx  (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc8_rnd_mmxext(uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc8_rnd_mmxext(uint8_t *dst, const uint8_t *src,
                                        ptrdiff_t stride, int h, int x, int y);
 
-void ff_put_h264_chroma_mc4_mmx      (uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc4_mmx      (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc4_mmxext   (uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc4_mmxext   (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
 
-void ff_put_h264_chroma_mc2_mmxext   (uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc2_mmxext   (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc2_mmxext   (uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc2_mmxext   (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
 
-void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
-void ff_put_h264_chroma_mc4_ssse3    (uint8_t *dst, uint8_t *src,
+void ff_put_h264_chroma_mc4_ssse3    (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
 
-void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
-void ff_avg_h264_chroma_mc4_ssse3    (uint8_t *dst, uint8_t *src,
+void ff_avg_h264_chroma_mc4_ssse3    (uint8_t *dst, const uint8_t *src,
                                       ptrdiff_t stride, int h, int x, int y);
 
 #define CHROMA_MC(OP, NUM, DEPTH, OPT)                                  \
 void ff_ ## OP ## _h264_chroma_mc ## NUM ## _ ## DEPTH ## _ ## OPT      \
-                                      (uint8_t *dst, uint8_t *src,      \
+                                      (uint8_t *dst, const uint8_t *src,      \
                                        ptrdiff_t stride, int h, int x, int y);
 
 CHROMA_MC(put, 2, 10, mmxext)
diff --git a/libavcodec/x86/rv40dsp_init.c b/libavcodec/x86/rv40dsp_init.c
index a04c5a5449..ab9e644c60 100644
--- a/libavcodec/x86/rv40dsp_init.c
+++ b/libavcodec/x86/rv40dsp_init.c
@@ -40,14 +40,14 @@ static void op##_rv40_qpel##size##_mc33_##insn(uint8_t *dst, const uint8_t *src,
 }
 
 #if HAVE_X86ASM
-void ff_put_rv40_chroma_mc8_mmx  (uint8_t *dst, uint8_t *src,
+void ff_put_rv40_chroma_mc8_mmx  (uint8_t *dst, const uint8_t *src,
                                   ptrdiff_t stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc8_mmxext(uint8_t *dst, uint8_t *src,
+void ff_avg_rv40_chroma_mc8_mmxext(uint8_t *dst, const uint8_t *src,
                                    ptrdiff_t stride, int h, int x, int y);
 
-void ff_put_rv40_chroma_mc4_mmx  (uint8_t *dst, uint8_t *src,
+void ff_put_rv40_chroma_mc4_mmx  (uint8_t *dst, const uint8_t *src,
                                   ptrdiff_t stride, int h, int x, int y);
-void ff_avg_rv40_chroma_mc4_mmxext(uint8_t *dst, uint8_t *src,
+void ff_avg_rv40_chroma_mc4_mmxext(uint8_t *dst, const uint8_t *src,
                                    ptrdiff_t stride, int h, int x, int y);
 
 #define DECLARE_WEIGHT(opt) \
diff --git a/libavcodec/x86/vc1dsp_init.c b/libavcodec/x86/vc1dsp_init.c
index b1f68b098c..90b2f3624e 100644
--- a/libavcodec/x86/vc1dsp_init.c
+++ b/libavcodec/x86/vc1dsp_init.c
@@ -80,13 +80,13 @@ DECLARE_FUNCTION(avg_, 16, _sse2)
 
 #endif /* HAVE_X86ASM */
 
-void ff_put_vc1_chroma_mc8_nornd_mmx  (uint8_t *dst, uint8_t *src,
+void ff_put_vc1_chroma_mc8_nornd_mmx  (uint8_t *dst, const uint8_t *src,
                                        ptrdiff_t stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src,
+void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, const uint8_t *src,
                                         ptrdiff_t stride, int h, int x, int y);
-void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
+void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
                                        ptrdiff_t stride, int h, int x, int y);
-void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src,
+void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, const uint8_t *src,
                                        ptrdiff_t stride, int h, int x, int y);
 void ff_vc1_inv_trans_4x4_dc_mmxext(uint8_t *dest, ptrdiff_t linesize,
                                     int16_t *block);
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 33/39] avcodec/cfhdencdsp: Constify input pointers
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (30 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible Andreas Rheinhardt
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/cfhdencdsp.c          | 6 +++---
 libavcodec/cfhdencdsp.h          | 4 ++--
 libavcodec/x86/cfhdencdsp_init.c | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/cfhdencdsp.c b/libavcodec/cfhdencdsp.c
index 3a35522d69..a122bcaf19 100644
--- a/libavcodec/cfhdencdsp.c
+++ b/libavcodec/cfhdencdsp.c
@@ -23,7 +23,7 @@
 
 #include "cfhdencdsp.h"
 
-static av_always_inline void filter(int16_t *input, ptrdiff_t in_stride,
+static av_always_inline void filter(const int16_t *input, ptrdiff_t in_stride,
                           int16_t *low, ptrdiff_t low_stride,
                           int16_t *high, ptrdiff_t high_stride,
                           int len)
@@ -46,7 +46,7 @@ static av_always_inline void filter(int16_t *input, ptrdiff_t in_stride,
                                                       1 * input[((len-2)-3)*in_stride] + 1 * input[((len-2)-4)*in_stride] + 4) >> 3);
 }
 
-static void horiz_filter(int16_t *input, int16_t *low, int16_t *high,
+static void horiz_filter(const int16_t *input, int16_t *low, int16_t *high,
                          ptrdiff_t in_stride, ptrdiff_t low_stride,
                          ptrdiff_t high_stride,
                          int width, int height)
@@ -59,7 +59,7 @@ static void horiz_filter(int16_t *input, int16_t *low, int16_t *high,
     }
 }
 
-static void vert_filter(int16_t *input, int16_t *low, int16_t *high,
+static void vert_filter(const int16_t *input, int16_t *low, int16_t *high,
                         ptrdiff_t in_stride, ptrdiff_t low_stride,
                         ptrdiff_t high_stride,
                         int width, int height)
diff --git a/libavcodec/cfhdencdsp.h b/libavcodec/cfhdencdsp.h
index b3aac8d0a7..d234b93797 100644
--- a/libavcodec/cfhdencdsp.h
+++ b/libavcodec/cfhdencdsp.h
@@ -23,12 +23,12 @@
 #include <stdint.h>
 
 typedef struct CFHDEncDSPContext {
-    void (*horiz_filter)(int16_t *input, int16_t *low, int16_t *high,
+    void (*horiz_filter)(const int16_t *input, int16_t *low, int16_t *high,
                          ptrdiff_t in_stride, ptrdiff_t low_stride,
                          ptrdiff_t high_stride,
                          int width, int height);
 
-    void (*vert_filter)(int16_t *input, int16_t *low, int16_t *high,
+    void (*vert_filter)(const int16_t *input, int16_t *low, int16_t *high,
                         ptrdiff_t in_stride, ptrdiff_t low_stride,
                         ptrdiff_t high_stride,
                         int width, int height);
diff --git a/libavcodec/x86/cfhdencdsp_init.c b/libavcodec/x86/cfhdencdsp_init.c
index 1e3586e08c..5cea39a80a 100644
--- a/libavcodec/x86/cfhdencdsp_init.c
+++ b/libavcodec/x86/cfhdencdsp_init.c
@@ -27,11 +27,11 @@
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/cfhdencdsp.h"
 
-void ff_cfhdenc_horiz_filter_sse2(int16_t *input, int16_t *low, int16_t *high,
+void ff_cfhdenc_horiz_filter_sse2(const int16_t *input, int16_t *low, int16_t *high,
                                   ptrdiff_t in_stride, ptrdiff_t low_stride,
                                   ptrdiff_t high_stride,
                                   int width, int height);
-void ff_cfhdenc_vert_filter_sse2(int16_t *input, int16_t *low, int16_t *high,
+void ff_cfhdenc_vert_filter_sse2(const int16_t *input, int16_t *low, int16_t *high,
                                  ptrdiff_t in_stride, ptrdiff_t low_stride,
                                  ptrdiff_t high_stride,
                                  int width, int height);
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (31 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 33/39] avcodec/cfhdencdsp: Constify input pointers Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-28 22:05   ` Michael Niedermayer
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 35/39] avcodec/mpegvideodsp: Constify src pointers Andreas Rheinhardt
                   ` (4 subsequent siblings)
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
 libavcodec/mips/h263dsp_mips.h             |  2 +-
 libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
 libavcodec/mpegvideoencdsp.c               | 10 +++++-----
 libavcodec/mpegvideoencdsp.h               | 10 +++++-----
 libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
 libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
 libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
 libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
 9 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavcodec/arm/mpegvideoencdsp_init_arm.c b/libavcodec/arm/mpegvideoencdsp_init_arm.c
index 31d1474416..a95b5bebe9 100644
--- a/libavcodec/arm/mpegvideoencdsp_init_arm.c
+++ b/libavcodec/arm/mpegvideoencdsp_init_arm.c
@@ -24,8 +24,8 @@
 #include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideoencdsp.h"
 
-int ff_pix_norm1_armv6(uint8_t *pix, int line_size);
-int ff_pix_sum_armv6(uint8_t *pix, int line_size);
+int ff_pix_norm1_armv6(const uint8_t *pix, int line_size);
+int ff_pix_sum_armv6(const uint8_t *pix, int line_size);
 
 av_cold void ff_mpegvideoencdsp_init_arm(MpegvideoEncDSPContext *c,
                                          AVCodecContext *avctx)
diff --git a/libavcodec/mips/h263dsp_mips.h b/libavcodec/mips/h263dsp_mips.h
index 99a43cd44a..f225ee563e 100644
--- a/libavcodec/mips/h263dsp_mips.h
+++ b/libavcodec/mips/h263dsp_mips.h
@@ -31,6 +31,6 @@ void ff_dct_unquantize_h263_inter_msa(MpegEncContext *s, int16_t *block,
                                       int32_t index, int32_t q_scale);
 void ff_dct_unquantize_h263_intra_msa(MpegEncContext *s, int16_t *block,
                                       int32_t index, int32_t q_scale);
-int ff_pix_sum_msa(uint8_t *pix, int line_size);
+int ff_pix_sum_msa(const uint8_t *pix, int line_size);
 
 #endif  // #ifndef AVCODEC_MIPS_H263DSP_MIPS_H
diff --git a/libavcodec/mips/mpegvideoencdsp_msa.c b/libavcodec/mips/mpegvideoencdsp_msa.c
index 46473dafe5..9043730cd7 100644
--- a/libavcodec/mips/mpegvideoencdsp_msa.c
+++ b/libavcodec/mips/mpegvideoencdsp_msa.c
@@ -21,7 +21,7 @@
 #include "h263dsp_mips.h"
 #include "libavutil/mips/generic_macros_msa.h"
 
-static int32_t sum_u8src_16width_msa(uint8_t *src, int32_t stride)
+static int32_t sum_u8src_16width_msa(const uint8_t *src, int32_t stride)
 {
     uint32_t sum = 0;
     v16u8 in0, in1, in2, in3, in4, in5, in6, in7;
@@ -56,7 +56,7 @@ static int32_t sum_u8src_16width_msa(uint8_t *src, int32_t stride)
     return sum;
 }
 
-int ff_pix_sum_msa(uint8_t *pix, int line_size)
+int ff_pix_sum_msa(const uint8_t *pix, int line_size)
 {
     return sum_u8src_16width_msa(pix, line_size);
 }
diff --git a/libavcodec/mpegvideoencdsp.c b/libavcodec/mpegvideoencdsp.c
index adf19e69f4..997d048663 100644
--- a/libavcodec/mpegvideoencdsp.c
+++ b/libavcodec/mpegvideoencdsp.c
@@ -28,8 +28,8 @@
 #include "me_cmp.h"
 #include "mpegvideoencdsp.h"
 
-static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
-                          int16_t basis[64], int scale)
+static int try_8x8basis_c(const int16_t rem[64], const int16_t weight[64],
+                          const int16_t basis[64], int scale)
 {
     int i;
     unsigned int sum = 0;
@@ -47,7 +47,7 @@ static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
     return sum >> 2;
 }
 
-static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
+static void add_8x8basis_c(int16_t rem[64], const int16_t basis[64], int scale)
 {
     int i;
 
@@ -57,7 +57,7 @@ static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
                   (BASIS_SHIFT - RECON_SHIFT);
 }
 
-static int pix_sum_c(uint8_t *pix, int line_size)
+static int pix_sum_c(const uint8_t *pix, int line_size)
 {
     int s = 0, i, j;
 
@@ -78,7 +78,7 @@ static int pix_sum_c(uint8_t *pix, int line_size)
     return s;
 }
 
-static int pix_norm1_c(uint8_t *pix, int line_size)
+static int pix_norm1_c(const uint8_t *pix, int line_size)
 {
     int s = 0, i, j;
     const uint32_t *sq = ff_square_tab + 256;
diff --git a/libavcodec/mpegvideoencdsp.h b/libavcodec/mpegvideoencdsp.h
index 33f0282fcc..95084679d9 100644
--- a/libavcodec/mpegvideoencdsp.h
+++ b/libavcodec/mpegvideoencdsp.h
@@ -30,12 +30,12 @@
 #define EDGE_BOTTOM 2
 
 typedef struct MpegvideoEncDSPContext {
-    int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],
-                        int16_t basis[64], int scale);
-    void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
+    int (*try_8x8basis)(const int16_t rem[64], const int16_t weight[64],
+                        const int16_t basis[64], int scale);
+    void (*add_8x8basis)(int16_t rem[64], const int16_t basis[64], int scale);
 
-    int (*pix_sum)(uint8_t *pix, int line_size);
-    int (*pix_norm1)(uint8_t *pix, int line_size);
+    int (*pix_sum)(const uint8_t *pix, int line_size);
+    int (*pix_norm1)(const uint8_t *pix, int line_size);
 
     void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
                       int src_wrap, int width, int height);
diff --git a/libavcodec/ppc/mpegvideoencdsp.c b/libavcodec/ppc/mpegvideoencdsp.c
index b96487bf81..07d3e76ee0 100644
--- a/libavcodec/ppc/mpegvideoencdsp.c
+++ b/libavcodec/ppc/mpegvideoencdsp.c
@@ -30,7 +30,7 @@
 #if HAVE_ALTIVEC
 
 #if HAVE_VSX
-static int pix_norm1_altivec(uint8_t *pix, int line_size)
+static int pix_norm1_altivec(const uint8_t *pix, int line_size)
 {
     int i, s = 0;
     const vector unsigned int zero =
@@ -57,7 +57,7 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size)
     return s;
 }
 #else
-static int pix_norm1_altivec(uint8_t *pix, int line_size)
+static int pix_norm1_altivec(const uint8_t *pix, int line_size)
 {
     int i, s = 0;
     const vector unsigned int zero =
@@ -87,7 +87,7 @@ static int pix_norm1_altivec(uint8_t *pix, int line_size)
 #endif /* HAVE_VSX */
 
 #if HAVE_VSX
-static int pix_sum_altivec(uint8_t *pix, int line_size)
+static int pix_sum_altivec(const uint8_t *pix, int line_size)
 {
     int i, s;
     const vector unsigned int zero =
@@ -115,7 +115,7 @@ static int pix_sum_altivec(uint8_t *pix, int line_size)
     return s;
 }
 #else
-static int pix_sum_altivec(uint8_t *pix, int line_size)
+static int pix_sum_altivec(const uint8_t *pix, int line_size)
 {
     int i, s;
     const vector unsigned int zero =
diff --git a/libavcodec/x86/mpegvideoenc_qns_template.c b/libavcodec/x86/mpegvideoenc_qns_template.c
index 882d486205..0d6454f45f 100644
--- a/libavcodec/x86/mpegvideoenc_qns_template.c
+++ b/libavcodec/x86/mpegvideoenc_qns_template.c
@@ -32,7 +32,7 @@
 
 #define MAX_ABS (512 >> (SCALE_OFFSET>0 ? SCALE_OFFSET : 0))
 
-static int DEF(try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale)
+static int DEF(try_8x8basis)(const int16_t rem[64], const int16_t weight[64], const int16_t basis[64], int scale)
 {
     x86_reg i=0;
 
@@ -74,7 +74,7 @@ static int DEF(try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[
     return i;
 }
 
-static void DEF(add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale)
+static void DEF(add_8x8basis)(int16_t rem[64], const int16_t basis[64], int scale)
 {
     x86_reg i=0;
 
diff --git a/libavcodec/x86/mpegvideoencdsp.asm b/libavcodec/x86/mpegvideoencdsp.asm
index e3d88f01c4..3cbe7b4d4b 100644
--- a/libavcodec/x86/mpegvideoencdsp.asm
+++ b/libavcodec/x86/mpegvideoencdsp.asm
@@ -24,7 +24,7 @@
 %include "libavutil/x86/x86util.asm"
 
 SECTION .text
-; int ff_pix_sum16(uint8_t *pix, int line_size)
+; int ff_pix_sum16(const uint8_t *pix, int line_size)
 ; %1 = number of loops
 ; %2 = number of GPRs used
 %macro PIX_SUM16 3
@@ -72,7 +72,7 @@ INIT_XMM xop
 PIX_SUM16  4, 4, 4
 %endif
 
-; int ff_pix_norm1(uint8_t *pix, int line_size)
+; int ff_pix_norm1(const uint8_t *pix, int line_size)
 ; %1 = number of xmm registers used
 ; %2 = number of loops
 %macro PIX_NORM1 2
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index b9c80b5382..ec174b15aa 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -23,9 +23,9 @@
 #include "libavcodec/avcodec.h"
 #include "libavcodec/mpegvideoencdsp.h"
 
-int ff_pix_sum16_sse2(uint8_t *pix, int line_size);
-int ff_pix_sum16_xop(uint8_t *pix, int line_size);
-int ff_pix_norm1_sse2(uint8_t *pix, int line_size);
+int ff_pix_sum16_sse2(const uint8_t *pix, int line_size);
+int ff_pix_sum16_xop(const uint8_t *pix, int line_size);
+int ff_pix_norm1_sse2(const uint8_t *pix, int line_size);
 
 #if HAVE_INLINE_ASM
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 35/39] avcodec/mpegvideodsp: Constify src pointers
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (32 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data Andreas Rheinhardt
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideodsp.c     | 4 ++--
 libavcodec/mpegvideodsp.h     | 6 +++---
 libavcodec/ppc/mpegvideodsp.c | 2 +-
 libavcodec/x86/mpegvideodsp.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mpegvideodsp.c b/libavcodec/mpegvideodsp.c
index a8cf7fbe35..05893d0e01 100644
--- a/libavcodec/mpegvideodsp.c
+++ b/libavcodec/mpegvideodsp.c
@@ -21,7 +21,7 @@
 #include "libavutil/common.h"
 #include "mpegvideodsp.h"
 
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
+static void gmc1_c(uint8_t *dst, const uint8_t *src, int stride, int h,
                    int x16, int y16, int rounder)
 {
     const int A = (16 - x16) * (16 - y16);
@@ -44,7 +44,7 @@ static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
     }
 }
 
-void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+void ff_gmc_c(uint8_t *dst, const uint8_t *src, int stride, int h, int ox, int oy,
               int dxx, int dxy, int dyx, int dyy, int shift, int r,
               int width, int height)
 {
diff --git a/libavcodec/mpegvideodsp.h b/libavcodec/mpegvideodsp.h
index 293e2548d3..69e6053c68 100644
--- a/libavcodec/mpegvideodsp.h
+++ b/libavcodec/mpegvideodsp.h
@@ -21,7 +21,7 @@
 
 #include <stdint.h>
 
-void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
+void ff_gmc_c(uint8_t *dst, const uint8_t *src, int stride, int h, int ox, int oy,
               int dxx, int dxy, int dyx, int dyy, int shift, int r,
               int width, int height);
 
@@ -29,12 +29,12 @@ typedef struct MpegVideoDSPContext {
     /**
      * translational global motion compensation.
      */
-    void (*gmc1)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+    void (*gmc1)(uint8_t *dst /* align 8 */, const uint8_t *src /* align 1 */,
                  int srcStride, int h, int x16, int y16, int rounder);
     /**
      * global motion compensation.
      */
-    void (*gmc)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+    void (*gmc)(uint8_t *dst /* align 8 */, const uint8_t *src /* align 1 */,
                 int stride, int h, int ox, int oy,
                 int dxx, int dxy, int dyx, int dyy,
                 int shift, int r, int width, int height);
diff --git a/libavcodec/ppc/mpegvideodsp.c b/libavcodec/ppc/mpegvideodsp.c
index 42d65dbe3d..3e99e089ea 100644
--- a/libavcodec/ppc/mpegvideodsp.c
+++ b/libavcodec/ppc/mpegvideodsp.c
@@ -31,7 +31,7 @@
 #if HAVE_ALTIVEC
 /* AltiVec-enhanced gmc1. ATM this code assumes stride is a multiple of 8
  * to preserve proper dst alignment. */
-static void gmc1_altivec(uint8_t *dst /* align 8 */, uint8_t *src /* align1 */,
+static void gmc1_altivec(uint8_t *dst /* align 8 */, const uint8_t *src /* align1 */,
                          int stride, int h, int x16, int y16, int rounder)
 {
     int i;
diff --git a/libavcodec/x86/mpegvideodsp.c b/libavcodec/x86/mpegvideodsp.c
index 6009b64e07..ea1d941fba 100644
--- a/libavcodec/x86/mpegvideodsp.c
+++ b/libavcodec/x86/mpegvideodsp.c
@@ -25,7 +25,7 @@
 
 #if HAVE_INLINE_ASM
 
-static void gmc_mmx(uint8_t *dst, uint8_t *src,
+static void gmc_mmx(uint8_t *dst, const uint8_t *src,
                     int stride, int h, int ox, int oy,
                     int dxx, int dxy, int dyx, int dyy,
                     int shift, int r, int width, int height)
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (33 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 35/39] avcodec/mpegvideodsp: Constify src pointers Andreas Rheinhardt
@ 2022-07-26 22:08 ` 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
                   ` (2 subsequent siblings)
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/motion_est.c | 31 +++++++++++++++++--------------
 libavcodec/motion_est.h |  4 ++--
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 0903536697..29ab41dc8c 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -79,7 +79,10 @@ static int minima_cmp(const void *a, const void *b){
 #define FLAG_CHROMA 2
 #define FLAG_DIRECT 4
 
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
+static inline void init_ref(MotionEstContext *c, uint8_t *const src[3],
+                            uint8_t *const ref[3], uint8_t *const ref2[3],
+                            int x, int y, int ref_index)
+{
     const int offset[3]= {
           y*c->  stride + x,
         ((y*c->uvstride + x)>>1),
@@ -110,8 +113,8 @@ static av_always_inline int cmp_direct_inline(MpegEncContext *s, const int x, co
     const int stride= c->stride;
     const int hx = subx + x * (1 << (1 + qpel));
     const int hy = suby + y * (1 << (1 + qpel));
-    uint8_t * const * const ref= c->ref[ref_index];
-    uint8_t * const * const src= c->src[src_index];
+    const uint8_t * const * const ref = c->ref[ref_index];
+    const uint8_t * const * const src = c->src[src_index];
     int d;
     //FIXME check chroma 4mv, (no crashes ...)
         av_assert2(x >= c->xmin && hx <= c->xmax<<(qpel+1) && y >= c->ymin && hy <= c->ymax<<(qpel+1));
@@ -184,8 +187,8 @@ static av_always_inline int cmp_inline(MpegEncContext *s, const int x, const int
     const int dxy= subx + (suby<<(1+qpel)); //FIXME log2_subpel?
     const int hx= subx + x*(1<<(1+qpel));
     const int hy= suby + y*(1<<(1+qpel));
-    uint8_t * const * const ref= c->ref[ref_index];
-    uint8_t * const * const src= c->src[src_index];
+    const uint8_t * const * const ref = c->ref[ref_index];
+    const uint8_t * const * const src = c->src[src_index];
     int d;
     //FIXME check chroma 4mv, (no crashes ...)
         int uvdxy;              /* no, it might not be used uninitialized */
@@ -396,7 +399,7 @@ static int sad_hpel_motion_search(MpegEncContext * s,
     MotionEstContext * const c= &s->me;
     const int penalty_factor= c->sub_penalty_factor;
     int mx, my, dminh;
-    uint8_t *pix, *ptr;
+    const uint8_t *pix, *ptr;
     int stride= c->stride;
     LOAD_COMMON
 
@@ -641,7 +644,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
             const int offset= ((block&1) + (block>>1)*stride)*8;
             uint8_t *dest_y = c->scratchpad + offset;
             if(s->quarter_sample){
-                uint8_t *ref= c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
+                const uint8_t *ref = c->ref[block][0] + (mx4>>2) + (my4>>2)*stride;
                 dxy = ((my4 & 3) << 2) | (mx4 & 3);
 
                 if(s->no_rounding)
@@ -649,7 +652,7 @@ static inline int h263_mv4_search(MpegEncContext *s, int mx, int my, int shift)
                 else
                     s->qdsp.put_qpel_pixels_tab[1][dxy](dest_y, ref, stride);
             }else{
-                uint8_t *ref= c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
+                const uint8_t *ref = c->ref[block][0] + (mx4>>1) + (my4>>1)*stride;
                 dxy = ((my4 & 1) << 1) | (mx4 & 1);
 
                 if(s->no_rounding)
@@ -805,7 +808,7 @@ static int interlaced_search(MpegEncContext *s, int ref_index,
                 int dxy;
 
                 //FIXME chroma ME
-                uint8_t *ref= c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
+                const uint8_t *ref = c->ref[field_select+ref_index][0] + (mx_i>>1) + (my_i>>1)*stride;
                 dxy = ((my_i & 1) << 1) | (mx_i & 1);
 
                 if(s->no_rounding){
@@ -885,7 +888,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
                                 int mb_x, int mb_y)
 {
     MotionEstContext * const c= &s->me;
-    uint8_t *pix, *ppix;
+    const uint8_t *pix, *ppix;
     int sum, mx = 0, my = 0, dmin = 0;
     int varc;            ///< the variance of the block (sum of squared (p[y][x]-average))
     int vard;            ///< sum of squared differences with the estimated motion vector
@@ -1187,13 +1190,13 @@ static inline int check_bidir_mv(MpegEncContext * s,
     const uint8_t * const mv_penalty_b = c->mv_penalty[s->b_code] + MAX_DMV; // f_code of the prev frame
     int stride= c->stride;
     uint8_t *dest_y = c->scratchpad;
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int dxy;
     int src_x, src_y;
     int fbmin;
-    uint8_t **src_data= c->src[0];
-    uint8_t **ref_data= c->ref[0];
-    uint8_t **ref2_data= c->ref[2];
+    const uint8_t *const *src_data  = c->src[0];
+    const uint8_t *const *ref_data  = c->ref[0];
+    const uint8_t *const *ref2_data = c->ref[2];
 
     if(s->quarter_sample){
         dxy = ((motion_fy & 3) << 2) | (motion_fx & 3);
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index d0950bf7e6..292bdc70e9 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -77,8 +77,8 @@ typedef struct MotionEstContext {
     int ymax;
     int pred_x;
     int pred_y;
-    uint8_t *src[4][4];
-    uint8_t *ref[4][4];
+    const uint8_t *src[4][4];
+    const uint8_t *ref[4][4];
     int stride;
     int uvstride;
     /* temp variables for picture complexity calculation */
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (34 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data Andreas Rheinhardt
@ 2022-07-26 22:08 ` 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
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Also constify the corresponding code in mpegvideo.c that handles
lowres.
(Unfortunately, not everything that is const could be constified:
ref_picture could be made const uint8_t* const* if C allowed the
safe automatic conversion from uint8_t**; and pix_op, qpix_op
could be made to point to const function pointers, but C's handling
of const in pointers to arrays is broken.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo.c        | 24 ++++++++++----------
 libavcodec/mpegvideo.h        |  2 +-
 libavcodec/mpegvideo_motion.c | 41 ++++++++++++++++++-----------------
 libavcodec/wmv2.c             |  4 ++--
 libavcodec/wmv2.h             |  2 +-
 5 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 319934a114..1405176c06 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -916,12 +916,12 @@ void ff_mpv_common_end(MpegEncContext *s)
 
 
 static inline int hpel_motion_lowres(MpegEncContext *s,
-                                     uint8_t *dest, uint8_t *src,
+                                     uint8_t *dest, const uint8_t *src,
                                      int field_based, int field_select,
                                      int src_x, int src_y,
                                      int width, int height, ptrdiff_t stride,
                                      int h_edge_pos, int v_edge_pos,
-                                     int w, int h, h264_chroma_mc_func *pix_op,
+                                     int w, int h, const h264_chroma_mc_func *pix_op,
                                      int motion_x, int motion_y)
 {
     const int lowres   = s->avctx->lowres;
@@ -969,12 +969,12 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
                                                 int field_based,
                                                 int bottom_field,
                                                 int field_select,
-                                                uint8_t **ref_picture,
-                                                h264_chroma_mc_func *pix_op,
+                                                uint8_t *const *ref_picture,
+                                                const h264_chroma_mc_func *pix_op,
                                                 int motion_x, int motion_y,
                                                 int h, int mb_y)
 {
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
+    const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
     int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
     ptrdiff_t uvlinesize, linesize;
     const int lowres     = s->avctx->lowres;
@@ -1103,8 +1103,8 @@ static av_always_inline void mpeg_motion_lowres(MpegEncContext *s,
 
 static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
                                             uint8_t *dest_cb, uint8_t *dest_cr,
-                                            uint8_t **ref_picture,
-                                            h264_chroma_mc_func * pix_op,
+                                            uint8_t *const *ref_picture,
+                                            const h264_chroma_mc_func * pix_op,
                                             int mx, int my)
 {
     const int lowres     = s->avctx->lowres;
@@ -1115,7 +1115,7 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
     const int v_edge_pos = s->v_edge_pos >> lowres + 1;
     int emu = 0, src_x, src_y, sx, sy;
     ptrdiff_t offset;
-    uint8_t *ptr;
+    const uint8_t *ptr;
 
     if (s->quarter_sample) {
         mx /= 2;
@@ -1172,8 +1172,8 @@ static inline void chroma_4mv_motion_lowres(MpegEncContext *s,
 static inline void MPV_motion_lowres(MpegEncContext *s,
                                      uint8_t *dest_y, uint8_t *dest_cb,
                                      uint8_t *dest_cr,
-                                     int dir, uint8_t **ref_picture,
-                                     h264_chroma_mc_func *pix_op)
+                                     int dir, uint8_t *const *ref_picture,
+                                     const h264_chroma_mc_func *pix_op)
 {
     int mx, my;
     int mb_x, mb_y, i;
@@ -1242,7 +1242,7 @@ static inline void MPV_motion_lowres(MpegEncContext *s,
         break;
     case MV_TYPE_16X8:
         for (i = 0; i < 2; i++) {
-            uint8_t **ref2picture;
+            uint8_t *const *ref2picture;
 
             if (s->picture_structure == s->field_select[dir][i] + 1 ||
                 s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
@@ -1492,7 +1492,7 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64],
                 }
 
                 if(lowres_flag){
-                    h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
+                    const h264_chroma_mc_func *op_pix = s->h264chroma.put_h264_chroma_pixels_tab;
 
                     if (s->mv_dir & MV_DIR_FORWARD) {
                         MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 0, s->last_picture.f->data, op_pix);
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 82889a0edd..287fd38bd3 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -586,7 +586,7 @@ void ff_init_block_index(MpegEncContext *s);
 void ff_mpv_motion(MpegEncContext *s,
                    uint8_t *dest_y, uint8_t *dest_cb,
                    uint8_t *dest_cr, int dir,
-                   uint8_t **ref_picture,
+                   uint8_t *const *ref_picture,
                    op_pixels_func (*pix_op)[4],
                    qpel_mc_func (*qpix_op)[16]);
 
diff --git a/libavcodec/mpegvideo_motion.c b/libavcodec/mpegvideo_motion.c
index 9a450b7c8e..fe3bfc4454 100644
--- a/libavcodec/mpegvideo_motion.c
+++ b/libavcodec/mpegvideo_motion.c
@@ -36,9 +36,9 @@
 
 static void gmc1_motion(MpegEncContext *s,
                         uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                        uint8_t **ref_picture)
+                        uint8_t *const *ref_picture)
 {
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int src_x, src_y, motion_x, motion_y;
     ptrdiff_t offset, linesize, uvlinesize;
     int emu = 0;
@@ -133,9 +133,9 @@ static void gmc1_motion(MpegEncContext *s,
 
 static void gmc_motion(MpegEncContext *s,
                        uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                       uint8_t **ref_picture)
+                       uint8_t *const *ref_picture)
 {
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int linesize, uvlinesize;
     const int a = s->sprite_warping_accuracy;
     int ox, oy;
@@ -232,7 +232,7 @@ void mpeg_motion_internal(MpegEncContext *s,
                           int field_based,
                           int bottom_field,
                           int field_select,
-                          uint8_t **ref_picture,
+                          uint8_t *const *ref_picture,
                           op_pixels_func (*pix_op)[4],
                           int motion_x,
                           int motion_y,
@@ -241,7 +241,7 @@ void mpeg_motion_internal(MpegEncContext *s,
                           int is_16x8,
                           int mb_y)
 {
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
+    const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
     int dxy, uvdxy, mx, my, src_x, src_y,
         uvsrc_x, uvsrc_y, v_edge_pos, block_y_half;
     ptrdiff_t uvlinesize, linesize;
@@ -369,7 +369,7 @@ void mpeg_motion_internal(MpegEncContext *s,
 /* apply one mpeg motion vector to the three components */
 static void mpeg_motion(MpegEncContext *s,
                         uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                        int field_select, uint8_t **ref_picture,
+                        int field_select, uint8_t *const *ref_picture,
                         op_pixels_func (*pix_op)[4],
                         int motion_x, int motion_y, int h, int is_16x8, int mb_y)
 {
@@ -388,7 +388,7 @@ static void mpeg_motion(MpegEncContext *s,
 static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
                               uint8_t *dest_cb, uint8_t *dest_cr,
                               int bottom_field, int field_select,
-                              uint8_t **ref_picture,
+                              uint8_t *const *ref_picture,
                               op_pixels_func (*pix_op)[4],
                               int motion_x, int motion_y, int h, int mb_y)
 {
@@ -489,12 +489,12 @@ static inline void qpel_motion(MpegEncContext *s,
                                uint8_t *dest_cb,
                                uint8_t *dest_cr,
                                int field_based, int bottom_field,
-                               int field_select, uint8_t **ref_picture,
+                               int field_select, uint8_t *const *ref_picture,
                                op_pixels_func (*pix_op)[4],
                                qpel_mc_func (*qpix_op)[16],
                                int motion_x, int motion_y, int h)
 {
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
+    const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
     int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos;
     ptrdiff_t linesize, uvlinesize;
 
@@ -593,11 +593,11 @@ static inline void qpel_motion(MpegEncContext *s,
  */
 static void chroma_4mv_motion(MpegEncContext *s,
                               uint8_t *dest_cb, uint8_t *dest_cr,
-                              uint8_t **ref_picture,
+                              uint8_t *const *ref_picture,
                               op_pixels_func *pix_op,
                               int mx, int my)
 {
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int src_x, src_y, dxy, emu = 0;
     ptrdiff_t offset;
 
@@ -643,7 +643,7 @@ static void chroma_4mv_motion(MpegEncContext *s,
     pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
 }
 
-static inline void prefetch_motion(MpegEncContext *s, uint8_t **pix, int dir)
+static inline void prefetch_motion(MpegEncContext *s, uint8_t *const *pix, int dir)
 {
     /* fetch pixels for estimated mv 4 macroblocks ahead
      * optimized for 64byte cache lines */
@@ -661,11 +661,11 @@ static inline void apply_obmc(MpegEncContext *s,
                               uint8_t *dest_y,
                               uint8_t *dest_cb,
                               uint8_t *dest_cr,
-                              uint8_t **ref_picture,
+                              uint8_t *const *ref_picture,
                               op_pixels_func (*pix_op)[4])
 {
     LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]);
-    Picture *cur_frame   = &s->current_picture;
+    const Picture *cur_frame = &s->current_picture;
     int mb_x = s->mb_x;
     int mb_y = s->mb_y;
     const int xy         = mb_x + mb_y * s->mb_stride;
@@ -749,7 +749,7 @@ static inline void apply_8x8(MpegEncContext *s,
                              uint8_t *dest_cb,
                              uint8_t *dest_cr,
                              int dir,
-                             uint8_t **ref_picture,
+                             uint8_t *const *ref_picture,
                              qpel_mc_func (*qpix_op)[16],
                              op_pixels_func (*pix_op)[4])
 {
@@ -757,7 +757,8 @@ static inline void apply_8x8(MpegEncContext *s,
     int i;
     int mb_x = s->mb_x;
     int mb_y = s->mb_y;
-    uint8_t *ptr, *dest;
+    uint8_t *dest;
+    const uint8_t *ptr;
 
     mx = 0;
     my = 0;
@@ -833,7 +834,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s,
                                                  uint8_t *dest_cb,
                                                  uint8_t *dest_cr,
                                                  int dir,
-                                                 uint8_t **ref_picture,
+                                                 uint8_t *const *ref_picture,
                                                  op_pixels_func (*pix_op)[4],
                                                  qpel_mc_func (*qpix_op)[16],
                                                  int is_mpeg12)
@@ -912,7 +913,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s,
     case MV_TYPE_16X8:
         if (CONFIG_SMALL || is_mpeg12) {
             for (i = 0; i < 2; i++) {
-                uint8_t **ref2picture;
+                uint8_t *const *ref2picture;
 
                 if ((s->picture_structure == s->field_select[dir][i] + 1 ||
                      s->pict_type == AV_PICTURE_TYPE_B || s->first_field) &&
@@ -974,7 +975,7 @@ static av_always_inline void mpv_motion_internal(MpegEncContext *s,
 void ff_mpv_motion(MpegEncContext *s,
                    uint8_t *dest_y, uint8_t *dest_cb,
                    uint8_t *dest_cr, int dir,
-                   uint8_t **ref_picture,
+                   uint8_t *const *ref_picture,
                    op_pixels_func (*pix_op)[4],
                    qpel_mc_func (*qpix_op)[16])
 {
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
index 8d1d117dea..5fea009e12 100644
--- a/libavcodec/wmv2.c
+++ b/libavcodec/wmv2.c
@@ -49,11 +49,11 @@ av_cold void ff_wmv2_common_init(MpegEncContext *s)
 
 void ff_mspel_motion(MpegEncContext *s, uint8_t *dest_y,
                      uint8_t *dest_cb, uint8_t *dest_cr,
-                     uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
+                     uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4],
                      int motion_x, int motion_y, int h)
 {
     WMV2Context *const w = s->private_ctx;
-    uint8_t *ptr;
+    const uint8_t *ptr;
     int dxy, mx, my, src_x, src_y, v_edge_pos;
     ptrdiff_t offset, linesize, uvlinesize;
     int emu = 0;
diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h
index cdd58cf011..e49b81cdfb 100644
--- a/libavcodec/wmv2.h
+++ b/libavcodec/wmv2.h
@@ -39,7 +39,7 @@ void ff_wmv2_common_init(MpegEncContext *s);
 
 void ff_mspel_motion(MpegEncContext *s,
                      uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
-                     uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
+                     uint8_t *const *ref_picture, op_pixels_func (*pix_op)[4],
                      int motion_x, int motion_y, int h);
 
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 38/39] avcodec: Constify frame->data pointers for encoders where possible
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (35 preceding siblings ...)
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion Andreas Rheinhardt
@ 2022-07-26 22:08 ` Andreas Rheinhardt
  2022-07-26 22:08 ` [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index() Andreas Rheinhardt
  37 siblings, 0 replies; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/a64multienc.c        |  2 +-
 libavcodec/adpcmenc.c           |  4 ++--
 libavcodec/asvenc.c             |  6 +++---
 libavcodec/avuienc.c            |  2 +-
 libavcodec/bmpenc.c             |  3 ++-
 libavcodec/cfhdenc.c            | 15 ++++++++-------
 libavcodec/cinepakenc.c         |  2 +-
 libavcodec/cljrenc.c            |  6 +++---
 libavcodec/cngenc.c             |  2 +-
 libavcodec/dfpwmenc.c           |  2 +-
 libavcodec/dnxhdenc.c           |  6 +++---
 libavcodec/dnxhdenc.h           |  2 +-
 libavcodec/dvenc.c              | 11 +++++------
 libavcodec/exrenc.c             |  6 +++---
 libavcodec/ffv1enc.c            |  2 +-
 libavcodec/fitsenc.c            |  4 ++--
 libavcodec/flashsvenc.c         |  5 ++---
 libavcodec/huffyuvenc.c         | 18 +++++++++---------
 libavcodec/j2kenc.c             | 12 ++++++------
 libavcodec/libopusenc.c         | 12 ++++++------
 libavcodec/ljpegenc.c           |  6 +++---
 libavcodec/magicyuvenc.c        |  3 ++-
 libavcodec/mlpenc.c             |  4 ++--
 libavcodec/mpeg4videoenc.c      |  4 ++--
 libavcodec/mpegvideo_enc.c      | 24 ++++++++++++------------
 libavcodec/msvideo1enc.c        |  4 ++--
 libavcodec/pamenc.c             |  3 ++-
 libavcodec/pngenc.c             | 16 ++++++++--------
 libavcodec/pnmenc.c             | 18 ++++++++----------
 libavcodec/proresenc_anatoliy.c | 22 +++++++++++-----------
 libavcodec/qoienc.c             |  3 ++-
 libavcodec/r210enc.c            |  8 ++++----
 libavcodec/rpzaenc.c            | 29 +++++++++++++++--------------
 libavcodec/sgienc.c             |  6 +++---
 libavcodec/snow.h               |  2 +-
 libavcodec/snowenc.c            | 14 +++++++-------
 libavcodec/svq1enc.c            |  4 ++--
 libavcodec/targaenc.c           |  2 +-
 libavcodec/tiffenc.c            |  4 ++--
 libavcodec/utvideoenc.c         |  4 ++--
 libavcodec/v308enc.c            |  2 +-
 libavcodec/v408enc.c            |  2 +-
 libavcodec/v410enc.c            |  2 +-
 libavcodec/vbnenc.c             |  2 +-
 libavcodec/vc2enc.c             |  2 +-
 libavcodec/wmaenc.c             |  2 +-
 libavcodec/xbmenc.c             |  3 ++-
 libavcodec/xwdenc.c             |  3 ++-
 libavcodec/y41penc.c            |  2 +-
 libavcodec/yuv4enc.c            |  2 +-
 libavcodec/zmbvenc.c            | 11 ++++++-----
 51 files changed, 170 insertions(+), 165 deletions(-)

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index ba774bf59f..043ffabd7c 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -76,7 +76,7 @@ static void to_meta_with_crop(AVCodecContext *avctx,
     int luma = 0;
     int height = FFMIN(avctx->height, C64YRES);
     int width  = FFMIN(avctx->width , C64XRES);
-    uint8_t *src = p->data[0];
+    const uint8_t *src = p->data[0];
 
     for (blocky = 0; blocky < C64YRES; blocky += 8) {
         for (blockx = 0; blockx < C64XRES; blockx += 8) {
diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 169a95046d..e27febfd74 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -601,13 +601,13 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 {
     int st, pkt_size, ret;
     const int16_t *samples;
-    int16_t **samples_p;
+    const int16_t *const *samples_p;
     uint8_t *dst;
     ADPCMEncodeContext *c = avctx->priv_data;
     int channels = avctx->ch_layout.nb_channels;
 
     samples = (const int16_t *)frame->data[0];
-    samples_p = (int16_t **)frame->extended_data;
+    samples_p = (const int16_t *const *)frame->extended_data;
     st = channels == 2;
 
     if (avctx->codec_id == AV_CODEC_ID_ADPCM_IMA_SSI ||
diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
index c6fd6a519e..8b94868c93 100644
--- a/libavcodec/asvenc.c
+++ b/libavcodec/asvenc.c
@@ -190,9 +190,9 @@ static inline void dct_get(ASV1Context *a, const AVFrame *frame,
     int linesize = frame->linesize[0];
     int i;
 
-    uint8_t *ptr_y  = frame->data[0] + (mb_y * 16 * linesize)           + mb_x * 16;
-    uint8_t *ptr_cb = frame->data[1] + (mb_y *  8 * frame->linesize[1]) + mb_x *  8;
-    uint8_t *ptr_cr = frame->data[2] + (mb_y *  8 * frame->linesize[2]) + mb_x *  8;
+    const uint8_t *ptr_y  = frame->data[0] + (mb_y * 16 * linesize)           + mb_x * 16;
+    const uint8_t *ptr_cb = frame->data[1] + (mb_y *  8 * frame->linesize[1]) + mb_x *  8;
+    const uint8_t *ptr_cr = frame->data[2] + (mb_y *  8 * frame->linesize[2]) + mb_x *  8;
 
     a->pdsp.get_pixels(block[0], ptr_y,                    linesize);
     a->pdsp.get_pixels(block[1], ptr_y + 8,                linesize);
diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c
index a54612ff28..0357e682a9 100644
--- a/libavcodec/avuienc.c
+++ b/libavcodec/avuienc.c
@@ -72,7 +72,7 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     }
 
     for (i = 0; i <= interlaced; i++) {
-        uint8_t *src;
+        const uint8_t *src;
         if (interlaced && avctx->height == 486) {
             src = pic->data[0] + (1 - i) * pic->linesize[0];
         } else {
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
index 78f64edb1c..964f7cc2ad 100644
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -72,7 +72,8 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint32_t palette256[256];
     int pad_bytes_per_row, pal_entries = 0, compression = BMP_RGB;
     int bit_count = avctx->bits_per_coded_sample;
-    uint8_t *ptr, *buf;
+    const uint8_t *ptr;
+    uint8_t *buf;
 
     switch (avctx->pix_fmt) {
     case AV_PIX_FMT_RGB444:
diff --git a/libavcodec/cfhdenc.c b/libavcodec/cfhdenc.c
index 3aad4d060f..c2f42c14dd 100644
--- a/libavcodec/cfhdenc.c
+++ b/libavcodec/cfhdenc.c
@@ -437,7 +437,8 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         int a_width = s->plane[plane].band[2][0].a_width;
         int height = s->plane[plane].band[2][0].height;
         int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane;
-        int16_t *input = (int16_t *)frame->data[act_plane];
+        const int16_t *input = (int16_t *)frame->data[act_plane];
+        int16_t *buf;
         int16_t *low = s->plane[plane].l_h[6];
         int16_t *high = s->plane[plane].l_h[7];
         ptrdiff_t in_stride = frame->linesize[act_plane] / 2;
@@ -481,13 +482,13 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         high = s->plane[plane].l_h[4];
         high_stride = s->plane[plane].band[1][0].a_width;
 
+        buf = s->plane[plane].l_h[7];
         for (int i = 0; i < height * 2; i++) {
             for (int j = 0; j < width * 2; j++)
-                input[j] /= 4;
-            input += a_width * 2;
+                buf[j] /= 4;
+            buf += a_width * 2;
         }
 
-        input = s->plane[plane].l_h[7];
         dsp->horiz_filter(input, low, high,
                           a_width * 2, low_stride, high_stride,
                           width * 2, height * 2);
@@ -518,14 +519,14 @@ static int cfhd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         high_stride = s->plane[plane].band[0][0].a_width;
 
         if (avctx->pix_fmt != AV_PIX_FMT_YUV422P10) {
+            int16_t *buf = s->plane[plane].l_h[4];
             for (int i = 0; i < height * 2; i++) {
                 for (int j = 0; j < width * 2; j++)
-                    input[j] /= 4;
-                input += a_width * 2;
+                    buf[j] /= 4;
+                buf += a_width * 2;
             }
         }
 
-        input = s->plane[plane].l_h[4];
         dsp->horiz_filter(input, low, high,
                           a_width * 2, low_stride, high_stride,
                           width * 2, height * 2);
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index 1b7c901685..479e99389c 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -1019,7 +1019,7 @@ static int rd_frame(CinepakEncContext *s, const AVFrame *frame,
         // build a copy of the given frame in the correct colorspace
         for (y = 0; y < s->h; y += 2)
             for (x = 0; x < s->w; x += 2) {
-                uint8_t *ir[2];
+                const uint8_t *ir[2];
                 int32_t r, g, b, rr, gg, bb;
                 ir[0] = frame->data[0] + x * 3 + y * frame->linesize[0];
                 ir[1] = ir[0] + frame->linesize[0];
diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c
index 2d171a9376..f84191b427 100644
--- a/libavcodec/cljrenc.c
+++ b/libavcodec/cljrenc.c
@@ -63,9 +63,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     init_put_bits(&pb, pkt->data, pkt->size);
 
     for (y = 0; y < avctx->height; y++) {
-        uint8_t *luma = &p->data[0][y * p->linesize[0]];
-        uint8_t *cb   = &p->data[1][y * p->linesize[1]];
-        uint8_t *cr   = &p->data[2][y * p->linesize[2]];
+        const uint8_t *luma = &p->data[0][y * p->linesize[0]];
+        const uint8_t *cb   = &p->data[1][y * p->linesize[1]];
+        const uint8_t *cr   = &p->data[2][y * p->linesize[2]];
         uint8_t luma_tmp[4];
         for (x = 0; x < avctx->width; x += 4) {
             switch (a->dither_type) {
diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index 98987238dd..7bb4bee857 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -67,7 +67,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     int ret, i;
     double energy = 0;
     int qdbov;
-    int16_t *samples = (int16_t*) frame->data[0];
+    const int16_t *samples = (const int16_t*) frame->data[0];
 
     if ((ret = ff_get_encode_buffer(avctx, avpkt, 1 + p->order, 0))) {
         av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
diff --git a/libavcodec/dfpwmenc.c b/libavcodec/dfpwmenc.c
index 0465dc23ac..41ad645315 100644
--- a/libavcodec/dfpwmenc.c
+++ b/libavcodec/dfpwmenc.c
@@ -39,7 +39,7 @@ typedef struct {
 // Licensed in the public domain
 
 // note, len denotes how many compressed bytes there are (uncompressed bytes / 8).
-static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, uint8_t *inbuf)
+static void au_compress(DFPWMState *state, int len, uint8_t *outbuf, const uint8_t *inbuf)
 {
     unsigned d = 0;
     for (int i = 0; i < len; i++) {
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 7e02ff23d6..5029e510ef 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -944,7 +944,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
 
     ctx = ctx->thread[threadnr];
     if (ctx->bit_depth == 8) {
-        uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize);
+        const uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize);
         for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) {
             unsigned mb = mb_y * ctx->m.mb_width + mb_x;
             int sum;
@@ -973,8 +973,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
     } else { // 10-bit
         const int linesize = ctx->m.linesize >> 1;
         for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) {
-            uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] +
-                            ((mb_y << 4) * linesize) + (mb_x << 4);
+            const uint16_t *pix = (const uint16_t *)ctx->thread[0]->src[0] +
+                                     ((mb_y << 4) * linesize) + (mb_x << 4);
             unsigned mb  = mb_y * ctx->m.mb_width + mb_x;
             int sum = 0;
             int sqsum = 0;
diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h
index 7726a3915f..e581312ce4 100644
--- a/libavcodec/dnxhdenc.h
+++ b/libavcodec/dnxhdenc.h
@@ -86,7 +86,7 @@ typedef struct DNXHDEncContext {
     uint16_t (*qmatrix_c16)[2][64];
 
     unsigned frame_bits;
-    uint8_t *src[3];
+    const uint8_t *src[3];
 
     uint32_t *orig_vlc_codes;
     uint8_t  *orig_vlc_bits;
diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index f51bd82488..5ba4de3213 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -217,7 +217,7 @@ static av_always_inline PutBitContext *dv_encode_ac(EncBlockInfo *bi,
     return pb;
 }
 
-static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, uint8_t *data,
+static av_always_inline int dv_guess_dct_mode(DVVideoContext *s, const uint8_t *data,
                                               ptrdiff_t linesize)
 {
     if (s->avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT) {
@@ -506,7 +506,7 @@ static inline void dv_set_class_number_hd(DVVideoContext *s,
     bi->cno = 0;
 }
 
-static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, int linesize,
+static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, const uint8_t *data, int linesize,
                                               DVVideoContext *s, int chroma)
 {
     LOCAL_ALIGNED_16(int16_t, blk, [64]);
@@ -849,7 +849,7 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
     int mb_index, i, j;
     int mb_x, mb_y, c_offset;
     ptrdiff_t linesize, y_stride;
-    uint8_t *y_ptr;
+    const uint8_t *y_ptr;
     uint8_t *dif, *p;
     LOCAL_ALIGNED_8(uint8_t, scratch, [128]);
     EncBlockInfo enc_blks[5 * DV_MAX_BPM];
@@ -908,14 +908,13 @@ static int dv_encode_video_segment(AVCodecContext *avctx, void *arg)
         c_offset = ((mb_y >>  (s->sys->pix_fmt == AV_PIX_FMT_YUV420P)) * s->frame->linesize[1] +
                     (mb_x >> ((s->sys->pix_fmt == AV_PIX_FMT_YUV411P) ? 2 : 1))) * 8;
         for (j = 2; j; j--) {
-            uint8_t *c_ptr = s->frame->data[j] + c_offset;
+            const uint8_t *c_ptr = s->frame->data[j] + c_offset;
             linesize = s->frame->linesize[j];
             y_stride = (mb_y == 134) ? 8 : (s->frame->linesize[j] * (1 << (3*!enc_blk->dct_mode)));
             if (s->sys->pix_fmt == AV_PIX_FMT_YUV411P && mb_x >= (704 / 8)) {
-                uint8_t *d;
                 uint8_t *b = scratch;
                 for (i = 0; i < 8; i++) {
-                    d      = c_ptr + linesize * 8;
+                    const uint8_t *d = c_ptr + linesize * 8;
                     b[0]   = c_ptr[0];
                     b[1]   = c_ptr[1];
                     b[2]   = c_ptr[2];
diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c
index 708404b38f..8cf7827bb6 100644
--- a/libavcodec/exrenc.c
+++ b/libavcodec/exrenc.c
@@ -253,7 +253,7 @@ static int encode_scanline_rle(EXRContext *s, const AVFrame *frame)
             for (int p = 0; p < s->planes; p++) {
                 int ch = s->ch_order[p];
                 uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + frame->width * 2 * p);
-                uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
+                const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
 
                 for (int x = 0; x < frame->width; x++)
                     dst[x] = float2half(src[x], s->basetable, s->shifttable);
@@ -321,7 +321,7 @@ static int encode_scanline_zip(EXRContext *s, const AVFrame *frame)
                 for (int p = 0; p < s->planes; p++) {
                     int ch = s->ch_order[p];
                     uint16_t *dst = (uint16_t *)(scanline->uncompressed_data + scanline_size * l + p * frame->width * 2);
-                    uint32_t *src = (uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]);
+                    const uint32_t *src = (const uint32_t *)(frame->data[ch] + (y * s->scanline_height + l) * frame->linesize[ch]);
 
                     for (int x = 0; x < frame->width; x++)
                         dst[x] = float2half(src[x], s->basetable, s->shifttable);
@@ -479,7 +479,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                 bytestream2_put_le32(pb, s->planes * avctx->width * 2);
                 for (int p = 0; p < s->planes; p++) {
                     int ch = s->ch_order[p];
-                    uint32_t *src = (uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
+                    const uint32_t *src = (const uint32_t *)(frame->data[ch] + y * frame->linesize[ch]);
 
                     for (int x = 0; x < frame->width; x++)
                         bytestream2_put_le16(pb, float2half(src[x], s->basetable, s->shifttable));
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 96da4d0203..ec06636db5 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -270,7 +270,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState *const state,
 #define RENAME(name) name ## 32
 #include "ffv1enc_template.c"
 
-static int encode_plane(FFV1Context *s, uint8_t *src, int w, int h,
+static int encode_plane(FFV1Context *s, const uint8_t *src, int w, int h,
                          int stride, int plane_index, int pixel_stride)
 {
     int x, y, i, ret;
diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
index 6e0597c8ca..30395b0a43 100644
--- a/libavcodec/fitsenc.c
+++ b/libavcodec/fitsenc.c
@@ -38,7 +38,7 @@
 static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *p, int *got_packet)
 {
-    uint8_t *bytestream, *ptr;
+    uint8_t *bytestream;
     const uint16_t flip = (1 << 15);
     uint64_t data_size = 0, padded_data_size = 0;
     int ret, bitpix, naxis3 = 1, i, j, k, bytes_left;
@@ -87,7 +87,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     for (k = 0; k < naxis3; k++) {
         for (i = 0; i < avctx->height; i++) {
-            ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]];
+            const uint8_t *ptr = p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]];
             if (bitpix == 16) {
                 for (j = 0; j < avctx->width; j++) {
                     // subtracting bzero is equivalent to first bit flip
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index 12db53bb8f..11a6e2b134 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -66,16 +66,15 @@ typedef struct FlashSVContext {
     uint8_t         tmpblock[3 * 256 * 256];
 } FlashSVContext;
 
-static int copy_region_enc(uint8_t *sptr, uint8_t *dptr, int dx, int dy,
+static int copy_region_enc(const uint8_t *sptr, uint8_t *dptr, int dx, int dy,
                            int h, int w, int stride, uint8_t *pfptr)
 {
     int i, j;
-    uint8_t *nsptr;
     uint8_t *npfptr;
     int diff = 0;
 
     for (i = dx + h; i > dx; i--) {
-        nsptr  = sptr  + i * stride + dy * 3;
+        const uint8_t *nsptr = sptr  + i * stride + dy * 3;
         npfptr = pfptr + i * stride + dy * 3;
         for (j = 0; j < w * 3; j++) {
             diff    |= npfptr[j] ^ nsptr[j];
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index a9aa00a5df..c585d007b4 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -119,7 +119,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst,
 }
 
 static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
-                                             uint8_t *src, int w,
+                                             const uint8_t *src, int w,
                                              int *red, int *green, int *blue)
 {
     int i;
@@ -789,7 +789,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             y++; cy++;
 
             for (; y < height; y++,cy++) {
-                uint8_t *ydst, *udst, *vdst;
+                const uint8_t *ydst, *udst, *vdst;
 
                 if (s->bitstream_bpp == 12) {
                     while (2 * cy > y) {
@@ -812,7 +812,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             }
         } else {
             for (cy = y = 1; y < height; y++, cy++) {
-                uint8_t *ydst, *udst, *vdst;
+                const uint8_t *ydst, *udst, *vdst;
 
                 /* encode a luma only line & y++ */
                 if (s->bitstream_bpp == 12) {
@@ -852,7 +852,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             }
         }
     } else if(avctx->pix_fmt == AV_PIX_FMT_RGB32) {
-        uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
+        const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
         const int stride = -p->linesize[0];
         const int fake_stride = -fake_ystride;
         int y;
@@ -868,7 +868,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         encode_bgra_bitstream(s, width - 1, 4);
 
         for (y = 1; y < s->height; y++) {
-            uint8_t *dst = data + y*stride;
+            const uint8_t *dst = data + y*stride;
             if (s->predictor == PLANE && s->interlaced < y) {
                 s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4);
                 sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width,
@@ -880,7 +880,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             encode_bgra_bitstream(s, width, 4);
         }
     } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
-        uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
+        const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
         const int stride = -p->linesize[0];
         const int fake_stride = -fake_ystride;
         int y;
@@ -896,7 +896,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         encode_bgra_bitstream(s, width-1, 3);
 
         for (y = 1; y < s->height; y++) {
-            uint8_t *dst = data + y * stride;
+            const uint8_t *dst = data + y * stride;
             if (s->predictor == PLANE && s->interlaced < y) {
                 s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride,
                                       width * 3);
@@ -939,7 +939,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                 lefttop = p->data[plane][0];
 
                 for (; y < h; y++) {
-                    uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
+                    const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
 
                     sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop);
 
@@ -947,7 +947,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                 }
             } else {
                 for (y = 1; y < h; y++) {
-                    uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
+                    const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
 
                     if (s->predictor == PLANE && s->interlaced < y) {
                         diff_bytes(s, s->temp[1], dst, dst - fake_stride, w);
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 20eb336b8d..5ef7f24b6d 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -507,7 +507,7 @@ static int init_tiles(Jpeg2000EncoderContext *s)
     static void copy_frame_ ##D(Jpeg2000EncoderContext *s)                                                                  \
     {                                                                                                                       \
         int tileno, compno, i, y, x;                                                                                        \
-        PIXEL *line;                                                                                                        \
+        const PIXEL *line;                                                                                                  \
         for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++){                                                   \
             Jpeg2000Tile *tile = s->tile + tileno;                                                                          \
             if (s->planar){                                                                                                 \
@@ -515,23 +515,23 @@ static int init_tiles(Jpeg2000EncoderContext *s)
                     Jpeg2000Component *comp = tile->comp + compno;                                                          \
                     int *dst = comp->i_data;                                                                                \
                     int cbps = s->cbps[compno];                                                                             \
-                    line = (PIXEL*)s->picture->data[compno]                                                                 \
+                    line = (const PIXEL*)s->picture->data[compno]                                                           \
                            + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL))                             \
                            + comp->coord[0][0];                                                                             \
                     for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){                                                \
-                        PIXEL *ptr = line;                                                                                  \
+                        const PIXEL *ptr = line;                                                                            \
                         for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++)                                             \
                             *dst++ = *ptr++ - (1 << (cbps - 1));                                                            \
                         line += s->picture->linesize[compno] / sizeof(PIXEL);                                               \
                     }                                                                                                       \
                 }                                                                                                           \
             } else{                                                                                                         \
-                line = (PIXEL*)s->picture->data[0] + tile->comp[0].coord[1][0] * (s->picture->linesize[0] / sizeof(PIXEL))  \
+                line = (const PIXEL*)(s->picture->data[0] + tile->comp[0].coord[1][0] * s->picture->linesize[0])            \
                        + tile->comp[0].coord[0][0] * s->ncomponents;                                                        \
                                                                                                                             \
                 i = 0;                                                                                                      \
                 for (y = tile->comp[0].coord[1][0]; y < tile->comp[0].coord[1][1]; y++){                                    \
-                    PIXEL *ptr = line;                                                                                      \
+                    const PIXEL *ptr = line;                                                                                \
                     for (x = tile->comp[0].coord[0][0]; x < tile->comp[0].coord[0][1]; x++, i++){                           \
                         for (compno = 0; compno < s->ncomponents; compno++){                                                \
                             int cbps = s->cbps[compno];                                                                     \
@@ -1597,7 +1597,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         update_size(chunkstart, s->buf);
         if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
             int i;
-            uint8_t *palette = pict->data[1];
+            const uint8_t *palette = pict->data[1];
             chunkstart = s->buf;
             bytestream_put_be32(&s->buf, 0);
             bytestream_put_buffer(&s->buf, "pclr", 4);
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index 48dd32fc38..b8ab184109 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -459,7 +459,7 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
     const int bytes_per_sample = av_get_bytes_per_sample(avctx->sample_fmt);
     const int channels         = avctx->ch_layout.nb_channels;
     const int sample_size      = channels * bytes_per_sample;
-    uint8_t *audio;
+    const uint8_t *audio;
     int ret;
     int discard_padding;
 
@@ -470,18 +470,18 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
         if (opus->encoder_channel_map != NULL) {
             audio = opus->samples;
             libopus_copy_samples_with_channel_map(
-                audio, frame->data[0], opus->encoder_channel_map,
+                opus->samples, frame->data[0], opus->encoder_channel_map,
                 channels, frame->nb_samples, bytes_per_sample);
         } else if (frame->nb_samples < opus->opts.packet_size) {
             audio = opus->samples;
-            memcpy(audio, frame->data[0], frame->nb_samples * sample_size);
+            memcpy(opus->samples, frame->data[0], frame->nb_samples * sample_size);
         } else
             audio = frame->data[0];
     } else {
         if (!opus->afq.remaining_samples || (!opus->afq.frame_alloc && !opus->afq.frame_count))
             return 0;
         audio = opus->samples;
-        memset(audio, 0, opus->opts.packet_size * sample_size);
+        memset(opus->samples, 0, opus->opts.packet_size * sample_size);
     }
 
     /* Maximum packet size taken from opusenc in opus-tools. 120ms packets
@@ -491,11 +491,11 @@ static int libopus_encode(AVCodecContext *avctx, AVPacket *avpkt,
         return ret;
 
     if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT)
-        ret = opus_multistream_encode_float(opus->enc, (float *)audio,
+        ret = opus_multistream_encode_float(opus->enc, (const float *)audio,
                                             opus->opts.packet_size,
                                             avpkt->data, avpkt->size);
     else
-        ret = opus_multistream_encode(opus->enc, (opus_int16 *)audio,
+        ret = opus_multistream_encode(opus->enc, (const opus_int16 *)audio,
                                       opus->opts.packet_size,
                                       avpkt->data, avpkt->size);
 
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index a167d1780e..26f42a2db6 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -78,7 +78,7 @@ static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb,
 
     for (y = 0; y < height; y++) {
         const int modified_predictor = y ? s->pred : 1;
-        uint8_t *ptr = frame->data[0] + (linesize * y);
+        const uint8_t *ptr = frame->data[0] + (linesize * y);
 
         if (put_bytes_left(pb, 0) < width * 4 * 4) {
             av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n");
@@ -132,7 +132,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
 
     if (mb_x == 0 || mb_y == 0) {
         for (i = 0; i < 3; i++) {
-            uint8_t *ptr;
+            const uint8_t *ptr;
             int x, y, h, v, linesize;
             h = s->hsample[i];
             v = s->vsample[i];
@@ -166,7 +166,7 @@ static inline void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb,
         }
     } else {
         for (i = 0; i < 3; i++) {
-            uint8_t *ptr;
+            const uint8_t *ptr;
             int x, y, h, v, linesize;
             h = s->hsample[i];
             v = s->vsample[i];
diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 1be51f3e88..7d77ef7bba 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -458,11 +458,12 @@ static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     }
 
     if (s->correlate) {
-        uint8_t *r, *g, *b, *decorrelated[2] = { s->decorrelate_buf[0],
+        uint8_t *decorrelated[2] = { s->decorrelate_buf[0],
                                                  s->decorrelate_buf[1] };
         const int decorrelate_linesize = FFALIGN(width, 16);
         const uint8_t *const data[4] = { decorrelated[0], frame->data[0],
                                          decorrelated[1], frame->data[3] };
+        const uint8_t *r, *g, *b;
         const int linesize[4]  = { decorrelate_linesize, frame->linesize[0],
                                    decorrelate_linesize, frame->linesize[3] };
 
diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index b75151abef..c25f48fabe 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1202,7 +1202,7 @@ static void input_data_internal(MLPEncodeContext *ctx, const uint8_t *samples,
 }
 
 /** Wrapper function for inputting data in two different bit-depths. */
-static void input_data(MLPEncodeContext *ctx, void *samples, int nb_samples)
+static void input_data(MLPEncodeContext *ctx, const void *samples, int nb_samples)
 {
     input_data_internal(ctx, samples, nb_samples, ctx->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
 }
@@ -2069,7 +2069,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     int bytes_written = 0;
     int channels = avctx->ch_layout.nb_channels;
     int restart_frame, ret;
-    uint8_t *data;
+    const uint8_t *data;
 
     if (!frame && !ctx->last_frames)
         ctx->last_frames = (ctx->afq.remaining_samples + avctx->frame_size - 1) / avctx->frame_size;
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index b0825fd3e3..339a3c2152 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -639,7 +639,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
                 if (s->max_b_frames > 0) {
                     int i;
                     int x, y, offset;
-                    uint8_t *p_pic;
+                    const uint8_t *p_pic;
 
                     x = s->mb_x * 16;
                     y = s->mb_y * 16;
@@ -649,7 +649,7 @@ void ff_mpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64],
 
                     s->mb_skipped = 1;
                     for (i = 0; i < s->max_b_frames; i++) {
-                        uint8_t *b_pic;
+                        const uint8_t *b_pic;
                         int diff;
                         Picture *pic = s->reordered_input_picture[i + 1];
 
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index c9d9e2a764..4719a734c9 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -953,7 +953,7 @@ av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
     return 0;
 }
 
-static int get_sae(uint8_t *src, int ref, int stride)
+static int get_sae(const uint8_t *src, int ref, int stride)
 {
     int x,y;
     int acc = 0;
@@ -967,8 +967,8 @@ static int get_sae(uint8_t *src, int ref, int stride)
     return acc;
 }
 
-static int get_intra_count(MpegEncContext *s, uint8_t *src,
-                           uint8_t *ref, int stride)
+static int get_intra_count(MpegEncContext *s, const uint8_t *src,
+                           const uint8_t *ref, int stride)
 {
     int x, y, w, h;
     int acc = 0;
@@ -1087,7 +1087,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
                     int v_shift = i ? v_chroma_shift : 0;
                     int w = s->width  >> h_shift;
                     int h = s->height >> v_shift;
-                    uint8_t *src = pic_arg->data[i];
+                    const uint8_t *src = pic_arg->data[i];
                     uint8_t *dst = pic->f->data[i];
                     int vpad = 16;
 
@@ -1149,7 +1149,7 @@ static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
     return 0;
 }
 
-static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
+static int skip_check(MpegEncContext *s, const Picture *p, const Picture *ref)
 {
     int x, y, plane;
     int score = 0;
@@ -1161,8 +1161,8 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
         for (y = 0; y < s->mb_height * bw; y++) {
             for (x = 0; x < s->mb_width * bw; x++) {
                 int off = p->shared ? 0 : 16;
-                uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
-                uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
+                const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
+                const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
                 int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
 
                 switch (FFABS(s->frame_skip_exp)) {
@@ -1190,7 +1190,7 @@ static int skip_check(MpegEncContext *s, Picture *p, Picture *ref)
     return 0;
 }
 
-static int encode_frame(AVCodecContext *c, AVFrame *frame, AVPacket *pkt)
+static int encode_frame(AVCodecContext *c, const AVFrame *frame, AVPacket *pkt)
 {
     int ret;
     int size = 0;
@@ -1990,7 +1990,7 @@ static inline void clip_coeffs(MpegEncContext *s, int16_t *block,
                overflow, minlevel, maxlevel);
 }
 
-static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride)
+static void get_visual_weight(int16_t *weight, const uint8_t *ptr, int stride)
 {
     int x, y;
     // FIXME optimize
@@ -2035,7 +2035,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s,
     int skip_dct[12];
     int dct_offset = s->linesize * 8; // default for progressive frames
     int uv_dct_offset = s->uvlinesize * 8;
-    uint8_t *ptr_y, *ptr_cb, *ptr_cr;
+    const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
     ptrdiff_t wrap_y, wrap_c;
 
     for (i = 0; i < mb_block_count; i++)
@@ -2534,7 +2534,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
     }
 }
 
-static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
+static int sse(MpegEncContext *s, const uint8_t *src1, const uint8_t *src2, int w, int h, int stride){
     const uint32_t *sq = ff_square_tab + 256;
     int acc=0;
     int x,y;
@@ -2641,7 +2641,7 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
             int xx = mb_x * 16;
             int yy = mb_y * 16;
-            uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx;
+            const uint8_t *pix = s->new_picture->data[0] + (yy * s->linesize) + xx;
             int varc;
             int sum = s->mpvencdsp.pix_sum(pix, s->linesize);
 
diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c
index f14badde21..4e1e94e9ab 100644
--- a/libavcodec/msvideo1enc.c
+++ b/libavcodec/msvideo1enc.c
@@ -69,7 +69,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 {
     Msvideo1EncContext * const c = avctx->priv_data;
     const AVFrame *p = pict;
-    uint16_t *src;
+    const uint16_t *src;
     uint8_t *prevptr;
     uint8_t *dst, *buf;
     int keyframe = 0;
@@ -85,7 +85,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     if(!c->prev)
         c->prev = av_malloc(avctx->width * 3 * (avctx->height + 3));
     prevptr = c->prev + avctx->width * 3 * (FFALIGN(avctx->height, 4) - 1);
-    src = (uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1));
+    src = (const uint16_t*)(p->data[0] + p->linesize[0]*(FFALIGN(avctx->height, 4) - 1));
     if(c->keyint >= avctx->keyint_min)
         keyframe = 1;
 
diff --git a/libavcodec/pamenc.c b/libavcodec/pamenc.c
index df23afe67f..6e934ba7a1 100644
--- a/libavcodec/pamenc.c
+++ b/libavcodec/pamenc.c
@@ -28,7 +28,8 @@ static int pam_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                             const AVFrame *p, int *got_packet)
 {
     int i, h, w, n, linesize, depth, maxval, ret, header_size;
-    uint8_t *bytestream, *ptr;
+    uint8_t *bytestream;
+    const uint8_t *ptr;
     const char *tuple_type;
     char header[100];
 
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index c4742e293f..438457da26 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -120,7 +120,7 @@ static void png_get_interlaced_row(uint8_t *dst, int row_size,
     }
 }
 
-static void sub_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top,
+static void sub_png_paeth_prediction(uint8_t *dst, const uint8_t *src, const uint8_t *top,
                                      int w, int bpp)
 {
     int i;
@@ -165,7 +165,7 @@ static void sub_left_prediction(PNGEncContext *c, uint8_t *dst, const uint8_t *s
 }
 
 static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type,
-                           uint8_t *src, uint8_t *top, int size, int bpp)
+                           const uint8_t *src, const uint8_t *top, int size, int bpp)
 {
     int i;
 
@@ -194,7 +194,7 @@ static void png_filter_row(PNGEncContext *c, uint8_t *dst, int filter_type,
 }
 
 static uint8_t *png_choose_filter(PNGEncContext *s, uint8_t *dst,
-                                  uint8_t *src, uint8_t *top, int size, int bpp)
+                                  const uint8_t *src, const uint8_t *top, int size, int bpp)
 {
     int pred = s->filter_type;
     av_assert0(bpp || !pred);
@@ -486,7 +486,7 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
     const AVFrame *const p = pict;
     int y, len, ret;
     int row_size, pass_row_size;
-    uint8_t *ptr, *top, *crow_buf, *crow;
+    uint8_t *top, *crow_buf, *crow;
     uint8_t *crow_base       = NULL;
     uint8_t *progressive_buf = NULL;
     uint8_t *top_buf         = NULL;
@@ -523,7 +523,7 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
                 top = NULL;
                 for (y = 0; y < pict->height; y++)
                     if ((ff_png_pass_ymask[pass] << (y & 7)) & 0x80) {
-                        ptr = p->data[0] + y * p->linesize[0];
+                        const uint8_t *ptr = p->data[0] + y * p->linesize[0];
                         FFSWAP(uint8_t *, progressive_buf, top_buf);
                         png_get_interlaced_row(progressive_buf, pass_row_size,
                                                s->bits_per_pixel, pass,
@@ -536,9 +536,9 @@ static int encode_frame(AVCodecContext *avctx, const AVFrame *pict)
             }
         }
     } else {
-        top = NULL;
+        const uint8_t *top = NULL;
         for (y = 0; y < pict->height; y++) {
-            ptr = p->data[0] + y * p->linesize[0];
+            const uint8_t *ptr = p->data[0] + y * p->linesize[0];
             crow = png_choose_filter(s, crow_buf, ptr, top,
                                      row_size, s->bits_per_pixel >> 3);
             png_write_row(avctx, crow, row_size + 1);
@@ -723,7 +723,7 @@ static int apng_do_inverse_blend(AVFrame *output, const AVFrame *input,
         }
 
         for (y = topmost_y; y < bottommost_y; ++y) {
-            uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x;
+            const uint8_t *foreground = input->data[0] + input_linesize * y + bpp * leftmost_x;
             uint8_t *background = output->data[0] + output_linesize * y + bpp * leftmost_x;
             output_data = output->data[0] + output_linesize * (y - topmost_y);
             for (x = leftmost_x; x < rightmost_x; ++x, foreground += bpp, background += bpp, output_data += bpp) {
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 9de63b400f..b16c93c88f 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -40,7 +40,6 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     PHMEncContext *s = avctx->priv_data;
     uint8_t *bytestream, *bytestream_start, *bytestream_end;
     int i, h, h1, c, n, linesize, ret;
-    uint8_t *ptr, *ptr1, *ptr2;
     int size = av_image_get_buffer_size(avctx->pix_fmt,
                                         avctx->width, avctx->height, 1);
 
@@ -135,9 +134,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     if ((avctx->pix_fmt == AV_PIX_FMT_GBRPF32LE ||
          avctx->pix_fmt == AV_PIX_FMT_GBRPF32BE) && c == 'F') {
-        float *r = (float *)p->data[2];
-        float *g = (float *)p->data[0];
-        float *b = (float *)p->data[1];
+        const float *r = (const float *)p->data[2];
+        const float *g = (const float *)p->data[0];
+        const float *b = (const float *)p->data[1];
 
         for (int i = 0; i < avctx->height; i++) {
             for (int j = 0; j < avctx->width; j++) {
@@ -164,9 +163,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             g += p->linesize[0] / 4;
         }
     } else if (avctx->pix_fmt == AV_PIX_FMT_GBRPF32 && c == 'H') {
-        float *r = (float *)p->data[2];
-        float *g = (float *)p->data[0];
-        float *b = (float *)p->data[1];
+        const float *r = (const float *)p->data[2];
+        const float *g = (const float *)p->data[0];
+        const float *b = (const float *)p->data[1];
 
         for (int i = 0; i < avctx->height; i++) {
             for (int j = 0; j < avctx->width; j++) {
@@ -192,7 +191,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             g += p->linesize[0] / 4;
         }
     } else {
-        ptr      = p->data[0];
+        const uint8_t *ptr = p->data[0];
         linesize = p->linesize[0];
         for (i = 0; i < h; i++) {
             memcpy(bytestream, ptr, n);
@@ -202,10 +201,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     }
 
     if (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV420P16BE) {
+        const uint8_t *ptr1 = p->data[1], *ptr2 = p->data[2];
         h >>= 1;
         n >>= 1;
-        ptr1 = p->data[1];
-        ptr2 = p->data[2];
         for (i = 0; i < h; i++) {
             memcpy(bytestream, ptr1, n);
             bytestream += n;
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 95c0f1c244..cfc735bcec 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -305,7 +305,7 @@ static void encode_ac_coeffs(PutBitContext *pb,
     }
 }
 
-static void get(uint8_t *pixels, int stride, int16_t* block)
+static void get(const uint8_t *pixels, int stride, int16_t* block)
 {
     int i;
 
@@ -317,13 +317,13 @@ static void get(uint8_t *pixels, int stride, int16_t* block)
     }
 }
 
-static void fdct_get(FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t* block)
+static void fdct_get(FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t* block)
 {
     get(pixels, stride, block);
     fdsp->fdct(block);
 }
 
-static void calc_plane_dct(FDCTDSPContext *fdsp, uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422)
+static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422)
 {
     int16_t *block;
     int i;
@@ -473,7 +473,7 @@ static av_always_inline int encode_alpha_slice_data(AVCodecContext *avctx, int8_
     }
 }
 
-static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsigned y,
+static inline void subimage_with_fill_template(const uint16_t *src, unsigned x, unsigned y,
                                                unsigned stride, unsigned width, unsigned height, uint16_t *dst,
                                                unsigned dst_width, unsigned dst_height, int is_alpha_plane,
                                                int is_interlaced, int is_top_field)
@@ -521,7 +521,7 @@ static inline void subimage_with_fill_template(uint16_t *src, unsigned x, unsign
     }
 }
 
-static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y,
+static void subimage_with_fill(const uint16_t *src, unsigned x, unsigned y,
         unsigned stride, unsigned width, unsigned height, uint16_t *dst,
         unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
 {
@@ -529,7 +529,7 @@ static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y,
 }
 
 /* reorganize alpha data and convert 10b -> 16b */
-static void subimage_alpha_with_fill(uint16_t *src, unsigned x, unsigned y,
+static void subimage_alpha_with_fill(const uint16_t *src, unsigned x, unsigned y,
                                unsigned stride, unsigned width, unsigned height, uint16_t *dst,
                                unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
 {
@@ -544,7 +544,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
     ProresContext* ctx = avctx->priv_data;
     int hdr_size = 6 + (ctx->need_alpha * 2); /* v data size is write when there is alpha */
     int ret = 0, slice_size;
-    uint8_t *dest_y, *dest_u, *dest_v;
+    const uint8_t *dest_y, *dest_u, *dest_v;
     unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0, a_data_size = 0;
     FDCTDSPContext *fdsp = &ctx->fdsp;
     int tgt_bits   = (mb_count * bitrate_table[avctx->profile]) >> 2;
@@ -577,13 +577,13 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
     }
 
     if (unsafe) {
-        subimage_with_fill((uint16_t *) pic->data[0], mb_x << 4, mb_y << 4,
+        subimage_with_fill((const uint16_t *) pic->data[0], mb_x << 4, mb_y << 4,
                 luma_stride, avctx->width, avctx->height,
                 (uint16_t *) ctx->fill_y, mb_count << 4, 16, is_interlaced, is_top_field);
-        subimage_with_fill((uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4,
+        subimage_with_fill((const uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4,
                            chroma_stride, avctx->width >> ctx->is_422, avctx->height,
                            (uint16_t *) ctx->fill_u, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
-        subimage_with_fill((uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4,
+        subimage_with_fill((const uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4,
                            chroma_stride, avctx->width >> ctx->is_422, avctx->height,
                            (uint16_t *) ctx->fill_v, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
 
@@ -640,7 +640,7 @@ static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
     if (ctx->need_alpha) {
         AV_WB16(buf + 6, v_data_size); /* write v data size only if there is alpha */
 
-        subimage_alpha_with_fill((uint16_t *) pic->data[3], mb_x << 4, mb_y << 4,
+        subimage_alpha_with_fill((const uint16_t *) pic->data[3], mb_x << 4, mb_y << 4,
                            alpha_stride, avctx->width, avctx->height,
                            (uint16_t *) ctx->fill_a, mb_count << 4, 16, is_interlaced, is_top_field);
         ret = encode_alpha_slice_data(avctx, ctx->fill_a, mb_count,
diff --git a/libavcodec/qoienc.c b/libavcodec/qoienc.c
index 3f043872c5..110297dbda 100644
--- a/libavcodec/qoienc.c
+++ b/libavcodec/qoienc.c
@@ -33,7 +33,8 @@ static int qoi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint8_t px[4] = { 0, 0, 0, 255 };
     uint8_t index[64][4] = { 0 };
     int64_t packet_size;
-    uint8_t *buf, *src;
+    uint8_t *buf;
+    const uint8_t *src;
     int ret, run = 0;
 
     packet_size = avctx->width * avctx->height * (channels + 1LL) + 14LL + 8LL;
diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c
index dca6fa7197..139e5b75eb 100644
--- a/libavcodec/r210enc.c
+++ b/libavcodec/r210enc.c
@@ -47,7 +47,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int aligned_width = FFALIGN(avctx->width,
                                 avctx->codec_id == AV_CODEC_ID_R10K ? 1 : 64);
     int pad = (aligned_width - avctx->width) * 4;
-    uint8_t *srcr_line, *srcg_line, *srcb_line;
+    const uint8_t *srcr_line, *srcg_line, *srcb_line;
     uint8_t *dst;
 
     ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0);
@@ -60,9 +60,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     dst = pkt->data;
 
     for (i = 0; i < avctx->height; i++) {
-        uint16_t *srcr = (uint16_t *)srcr_line;
-        uint16_t *srcg = (uint16_t *)srcg_line;
-        uint16_t *srcb = (uint16_t *)srcb_line;
+        const uint16_t *srcr = (const uint16_t *)srcr_line;
+        const uint16_t *srcg = (const uint16_t *)srcg_line;
+        const uint16_t *srcb = (const uint16_t *)srcb_line;
         for (j = 0; j < avctx->width; j++) {
             uint32_t pixel;
             unsigned r = *srcr++;
diff --git a/libavcodec/rpzaenc.c b/libavcodec/rpzaenc.c
index f01103fe11..a470f5d101 100644
--- a/libavcodec/rpzaenc.c
+++ b/libavcodec/rpzaenc.c
@@ -84,7 +84,7 @@ typedef struct BlockInfo {
     int total_blocks;
 } BlockInfo;
 
-static void get_colors(uint8_t *min, uint8_t *max, uint8_t color4[4][3])
+static void get_colors(const uint8_t *min, const uint8_t *max, uint8_t color4[4][3])
 {
     uint8_t step;
 
@@ -135,7 +135,7 @@ static int get_block_info(BlockInfo *bi, int block)
     return block ? (bi->col * 4) + (bi->row * bi->rowstride * 4) : 0;
 }
 
-static uint16_t rgb24_to_rgb555(uint8_t *rgb24)
+static uint16_t rgb24_to_rgb555(const uint8_t *rgb24)
 {
     uint16_t rgb555 = 0;
     uint32_t r, g, b;
@@ -154,7 +154,7 @@ static uint16_t rgb24_to_rgb555(uint8_t *rgb24)
 /*
  * Returns the total difference between two 24 bit color values
  */
-static int diff_colors(uint8_t *colorA, uint8_t *colorB)
+static int diff_colors(const uint8_t *colorA, const uint8_t *colorB)
 {
     int tot;
 
@@ -168,7 +168,7 @@ static int diff_colors(uint8_t *colorA, uint8_t *colorB)
 /*
  * Returns the maximum channel difference
  */
-static int max_component_diff(uint16_t *colorA, uint16_t *colorB)
+static int max_component_diff(const uint16_t *colorA, const uint16_t *colorB)
 {
     int diff, max = 0;
 
@@ -192,7 +192,7 @@ static int max_component_diff(uint16_t *colorA, uint16_t *colorB)
  * color values. Put the minimum value in min, maximum in max and the channel
  * in chan.
  */
-static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr,
+static void get_max_component_diff(const BlockInfo *bi, const uint16_t *block_ptr,
                                    uint8_t *min, uint8_t *max, channel_offset *chan)
 {
     int x, y;
@@ -242,7 +242,8 @@ static void get_max_component_diff(BlockInfo *bi, uint16_t *block_ptr,
  * blocks is greater than the thresh parameter. Returns -1 if difference
  * exceeds threshold or zero otherwise.
  */
-static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int thresh)
+static int compare_blocks(const uint16_t *block1, const uint16_t *block2,
+                          const BlockInfo *bi, int thresh)
 {
     int x, y, diff = 0;
     for (y = 0; y < bi->block_height; y++) {
@@ -262,7 +263,7 @@ static int compare_blocks(uint16_t *block1, uint16_t *block2, BlockInfo *bi, int
  * Determine the fit of one channel to another within a 4x4 block. This
  * is used to determine the best palette choices for 4-color encoding.
  */
-static int leastsquares(uint16_t *block_ptr, BlockInfo *bi,
+static int leastsquares(const uint16_t *block_ptr, const BlockInfo *bi,
                         channel_offset xchannel, channel_offset ychannel,
                         double *slope, double *y_intercept, double *correlation_coef)
 {
@@ -315,7 +316,7 @@ static int leastsquares(uint16_t *block_ptr, BlockInfo *bi,
 /*
  * Determine the amount of error in the leastsquares fit.
  */
-static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi,
+static int calc_lsq_max_fit_error(const uint16_t *block_ptr, const BlockInfo *bi,
                                   int min, int max, int tmp_min, int tmp_max,
                                   channel_offset xchannel, channel_offset ychannel)
 {
@@ -356,7 +357,7 @@ static int calc_lsq_max_fit_error(uint16_t *block_ptr, BlockInfo *bi,
 /*
  * Find the closest match to a color within the 4-color palette
  */
-static int match_color(uint16_t *color, uint8_t colors[4][3])
+static int match_color(const uint16_t *color, uint8_t colors[4][3])
 {
     int ret = 0;
     int smallest_variance = INT_MAX;
@@ -383,8 +384,8 @@ static int match_color(uint16_t *color, uint8_t colors[4][3])
  * blocks encoded (until we implement multi-block 4 color runs this will
  * always be 1)
  */
-static int encode_four_color_block(uint8_t *min_color, uint8_t *max_color,
-                                   PutBitContext *pb, uint16_t *block_ptr, BlockInfo *bi)
+static int encode_four_color_block(const uint8_t *min_color, const uint8_t *max_color,
+                                   PutBitContext *pb, const uint16_t *block_ptr, const BlockInfo *bi)
 {
     int x, y, idx;
     uint8_t color4[4][3];
@@ -441,7 +442,7 @@ static void update_block_in_prev_frame(const uint16_t *src_pixels,
  * the statistics of this block. Otherwise, the stats are unchanged
  * and don't include the current block.
  */
-static int update_block_stats(RpzaContext *s, BlockInfo *bi, uint16_t *block,
+static int update_block_stats(RpzaContext *s, const BlockInfo *bi, const uint16_t *block,
                               uint8_t min_color[3], uint8_t max_color[3],
                               int *total_rgb, int *total_pixels,
                               uint8_t avg_color[3], int first_block)
@@ -562,7 +563,7 @@ static void rpza_encode_stream(RpzaContext *s, const AVFrame *pict)
     int pixel_count;
     uint8_t min_color[3], max_color[3];
     double slope, y_intercept, correlation_coef;
-    uint16_t *src_pixels = (uint16_t *)pict->data[0];
+    const uint16_t *src_pixels = (const uint16_t *)pict->data[0];
     uint16_t *prev_pixels = (uint16_t *)s->prev_frame->data[0];
 
     /* Number of 4x4 blocks in frame. */
@@ -728,7 +729,7 @@ post_skip :
             }
 
             if (err > s->sixteen_color_thresh) { // DO SIXTEEN COLOR BLOCK
-                uint16_t *row_ptr;
+                const uint16_t *row_ptr;
                 int rgb555;
 
                 block_offset = get_block_info(&bi, block_counter);
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
index 5d2cc7e3b9..7edc7cca83 100644
--- a/libavcodec/sgienc.c
+++ b/libavcodec/sgienc.c
@@ -96,7 +96,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     SgiContext *s = avctx->priv_data;
     const AVFrame * const p = frame;
     PutByteContext pbc;
-    uint8_t *in_buf, *encode_buf;
+    uint8_t *encode_buf;
     int x, y, z, length, tablesize, ret, i;
     unsigned int width, height, depth, dimension;
     unsigned int bytes_per_channel, pixmax, put_be;
@@ -200,7 +200,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             return AVERROR(ENOMEM);
 
         for (z = 0; z < depth; z++) {
-            in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
+            const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
 
             for (y = 0; y < height; y++) {
                 bytestream2_put_be32(&taboff_pcb, bytestream2_tell_p(&pbc));
@@ -231,7 +231,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         av_free(encode_buf);
     } else {
         for (z = 0; z < depth; z++) {
-            in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
+            const uint8_t *in_buf = p->data[0] + p->linesize[0] * (height - 1) + z * bytes_per_channel;
 
             for (y = 0; y < height; y++) {
                 for (x = 0; x < width * depth; x += depth)
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
index 709fef6be5..ed0f9abb42 100644
--- a/libavcodec/snow.h
+++ b/libavcodec/snow.h
@@ -486,7 +486,7 @@ static inline void set_blocks(SnowContext *s, int level, int x, int y, int l, in
     }
 }
 
-static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3], uint8_t *ref2[3], int x, int y, int ref_index){
+static inline void init_ref(MotionEstContext *c, const uint8_t *const src[3], uint8_t *const ref[3], uint8_t *const ref2[3], int x, int y, int ref_index){
     SnowContext *s = c->avctx->priv_data;
     const int offset[3]= {
           y*c->  stride + x,
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 27f5d3c941..50e03439a4 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -151,7 +151,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 }
 
 //near copy & paste from dsputil, FIXME
-static int pix_sum(uint8_t * pix, int line_size, int w, int h)
+static int pix_sum(const uint8_t * pix, int line_size, int w, int h)
 {
     int s, i, j;
 
@@ -167,7 +167,7 @@ static int pix_sum(uint8_t * pix, int line_size, int w, int h)
 }
 
 //near copy & paste from dsputil, FIXME
-static int pix_norm1(uint8_t * pix, int line_size, int w)
+static int pix_norm1(const uint8_t * pix, int line_size, int w)
 {
     int s, i, j;
     const uint32_t *sq = ff_square_tab + 256;
@@ -245,7 +245,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
     int l,cr,cb;
     const int stride= s->current_picture->linesize[0];
     const int uvstride= s->current_picture->linesize[1];
-    uint8_t *current_data[3]= { s->input_picture->data[0] + (x + y*  stride)*block_w,
+    const uint8_t *current_data[3] = { s->input_picture->data[0] + (x + y*  stride)*block_w,
                                 s->input_picture->data[1] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift),
                                 s->input_picture->data[2] + ((x*block_w)>>s->chroma_h_shift) + ((y*uvstride*block_w)>>s->chroma_v_shift)};
     int P[10][2];
@@ -508,7 +508,7 @@ static int get_dc(SnowContext *s, int mb_x, int mb_y, int plane_index){
     const uint8_t *obmc  = plane_index ? ff_obmc_tab[s->block_max_depth+s->chroma_h_shift] : ff_obmc_tab[s->block_max_depth];
     const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
     const int ref_stride= s->current_picture->linesize[plane_index];
-    uint8_t *src= s-> input_picture->data[plane_index];
+    const uint8_t *src = s-> input_picture->data[plane_index];
     IDWTELEM *dst= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned
     const int b_stride = s->b_width << s->block_max_depth;
     const int w= p->width;
@@ -603,7 +603,7 @@ static int get_block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index, uin
     const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
     const int ref_stride= s->current_picture->linesize[plane_index];
     uint8_t *dst= s->current_picture->data[plane_index];
-    uint8_t *src= s->  input_picture->data[plane_index];
+    const uint8_t *src = s->input_picture->data[plane_index];
     IDWTELEM *pred= (IDWTELEM*)s->m.sc.obmc_scratchpad + plane_index*block_size*block_size*4;
     uint8_t *cur = s->scratchbuf;
     uint8_t *tmp = s->emu_edge_buffer;
@@ -706,7 +706,7 @@ static int get_4block_rd(SnowContext *s, int mb_x, int mb_y, int plane_index){
     const int obmc_stride= plane_index ? (2*block_size)>>s->chroma_h_shift : 2*block_size;
     const int ref_stride= s->current_picture->linesize[plane_index];
     uint8_t *dst= s->current_picture->data[plane_index];
-    uint8_t *src= s-> input_picture->data[plane_index];
+    const uint8_t *src = s-> input_picture->data[plane_index];
     //FIXME zero_dst is const but add_yblock changes dst if add is 0 (this is never the case for dst=zero_dst
     // const has only been removed from zero_dst to suppress a warning
     static IDWTELEM zero_dst[4096]; //FIXME
@@ -1076,7 +1076,7 @@ static void iterative_me(SnowContext *s){
 
                 //skip stuff outside the picture
                 if(mb_x==0 || mb_y==0 || mb_x==b_width-1 || mb_y==b_height-1){
-                    uint8_t *src= s->  input_picture->data[0];
+                    const uint8_t *src = s->  input_picture->data[0];
                     uint8_t *dst= s->current_picture->data[0];
                     const int stride= s->current_picture->linesize[0];
                     const int block_w= MB_SIZE >> s->block_max_depth;
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index f188111699..e5216a99cd 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -248,7 +248,7 @@ static void init_block_index(MpegEncContext *s){
 }
 
 static int svq1_encode_plane(SVQ1EncContext *s, int plane,
-                             unsigned char *src_plane,
+                             const unsigned char *src_plane,
                              unsigned char *ref_plane,
                              unsigned char *decoded_plane,
                              int width, int height, int src_stride, int stride)
@@ -371,7 +371,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
             int count[2][6];
             int offset       = y * 16 * stride + x * 16;
             uint8_t *decoded = decoded_plane + offset;
-            uint8_t *ref     = ref_plane + offset;
+            const uint8_t *ref = ref_plane + offset;
             int score[4]     = { 0, 0, 0, 0 }, best;
             uint8_t *temp    = s->scratchbuf;
 
diff --git a/libavcodec/targaenc.c b/libavcodec/targaenc.c
index f439ba0dc6..7fb8e28c85 100644
--- a/libavcodec/targaenc.c
+++ b/libavcodec/targaenc.c
@@ -72,7 +72,7 @@ static int targa_encode_normal(uint8_t *outbuf, const AVFrame *pic, int bpp, int
 {
     int i, n = bpp * w;
     uint8_t *out = outbuf;
-    uint8_t *ptr = pic->data[0];
+    const uint8_t *ptr = pic->data[0];
 
     for(i=0; i < h; i++) {
         memcpy(out, ptr, n);
diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 7228f66e2d..dba0e89640 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -207,8 +207,8 @@ static void pack_yuv(TiffEncoderContext *s, const AVFrame *p,
 {
     int i, j, k;
     int w       = (s->width - 1) / s->subsampling[0] + 1;
-    uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
-    uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
+    const uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
+    const uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
     if (s->width % s->subsampling[0] || s->height % s->subsampling[1]) {
         for (i = 0; i < w; i++) {
             for (j = 0; j < s->subsampling[1]; j++)
diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 2c1189ed07..f38db96e51 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -277,7 +277,7 @@ static void mangle_rgb_planes(uint8_t *dst[4], ptrdiff_t dst_stride,
 #undef B
 
 /* Write data to a plane with median prediction */
-static void median_predict(UtvideoContext *c, uint8_t *src, uint8_t *dst,
+static void median_predict(UtvideoContext *c, const uint8_t *src, uint8_t *dst,
                            ptrdiff_t stride, int width, int height)
 {
     int i, j;
@@ -376,7 +376,7 @@ static int write_huff_codes(uint8_t *src, uint8_t *dst, int dst_size,
     return put_bytes_output(&pb);
 }
 
-static int encode_plane(AVCodecContext *avctx, uint8_t *src,
+static int encode_plane(AVCodecContext *avctx, const uint8_t *src,
                         uint8_t *dst, ptrdiff_t stride, int plane_no,
                         int width, int height, PutByteContext *pb)
 {
diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c
index bd73b2e95a..c6a270a883 100644
--- a/libavcodec/v308enc.c
+++ b/libavcodec/v308enc.c
@@ -43,7 +43,7 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *pic, int *got_packet)
 {
     uint8_t *dst;
-    uint8_t *y, *u, *v;
+    const uint8_t *y, *u, *v;
     int i, j, ret;
 
     ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0);
diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c
index c53fa4e2a4..77d2b026b3 100644
--- a/libavcodec/v408enc.c
+++ b/libavcodec/v408enc.c
@@ -40,7 +40,7 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *pic, int *got_packet)
 {
     uint8_t *dst;
-    uint8_t *y, *u, *v, *a;
+    const uint8_t *y, *u, *v, *a;
     int i, j, ret;
 
     ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0);
diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c
index a78402c054..f08ccb2147 100644
--- a/libavcodec/v410enc.c
+++ b/libavcodec/v410enc.c
@@ -44,7 +44,7 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *pic, int *got_packet)
 {
     uint8_t *dst;
-    uint16_t *y, *u, *v;
+    const uint16_t *y, *u, *v;
     uint32_t val;
     int i, j, ret;
 
diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c
index ea33005114..c93b4e37be 100644
--- a/libavcodec/vbnenc.c
+++ b/libavcodec/vbnenc.c
@@ -116,7 +116,7 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt,
         ctx->enc.tex_data.out = pkt->data + VBN_HEADER_SIZE;
         avctx->execute2(avctx, ff_texturedsp_compress_thread, &ctx->enc, NULL, ctx->enc.slice_count);
     } else {
-        uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1);
+        const uint8_t *flipped = frame->data[0] + frame->linesize[0] * (frame->height - 1);
         av_image_copy_plane(pkt->data + VBN_HEADER_SIZE, linesize, flipped, -frame->linesize[0], linesize, frame->height);
     }
 
diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
index f776d25b91..e1fd5fa608 100644
--- a/libavcodec/vc2enc.c
+++ b/libavcodec/vc2enc.c
@@ -117,7 +117,7 @@ typedef struct SliceArgs {
 typedef struct TransformArgs {
     void *ctx;
     Plane *plane;
-    void *idata;
+    const void *idata;
     ptrdiff_t istride;
     int field;
     VC2TransformContext t;
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 02572d6796..03a5d788c8 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -110,7 +110,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
 {
     WMACodecContext *s = avctx->priv_data;
-    float **audio      = (float **) frame->extended_data;
+    const float *const *audio = (const float *const *) frame->extended_data;
     int len            = frame->nb_samples;
     int window_index   = s->frame_len_bits - s->block_len_bits;
     FFTContext *mdct   = &s->mdct_ctx[window_index];
diff --git a/libavcodec/xbmenc.c b/libavcodec/xbmenc.c
index 60fb169457..8369f5370c 100644
--- a/libavcodec/xbmenc.c
+++ b/libavcodec/xbmenc.c
@@ -32,7 +32,8 @@ static int xbm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                             const AVFrame *p, int *got_packet)
 {
     int i, j, l, commas, ret, size, linesize, lineout, rowsout;
-    uint8_t *ptr, *buf;
+    const uint8_t *ptr;
+    uint8_t *buf;
 
     linesize = lineout = (avctx->width + 7) / 8;
     commas   = avctx->height * linesize;
diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c
index a28fca08e0..01c43c1d81 100644
--- a/libavcodec/xwdenc.c
+++ b/libavcodec/xwdenc.c
@@ -39,7 +39,8 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     uint32_t rgb[3] = { 0 }, bitorder = 0;
     uint32_t header_size;
     int i, out_size, ret;
-    uint8_t *ptr, *buf;
+    const uint8_t *ptr;
+    uint8_t *buf;
     uint32_t pal[256];
 
     pixdepth = av_get_bits_per_pixel(desc);
diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c
index 77864909a1..f7ac58c30e 100644
--- a/libavcodec/y41penc.c
+++ b/libavcodec/y41penc.c
@@ -42,7 +42,7 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *pic, int *got_packet)
 {
     uint8_t *dst;
-    uint8_t *y, *u, *v;
+    const uint8_t *y, *u, *v;
     int i, j, ret;
 
     ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 1.5, 0);
diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c
index 8d72382197..94e9b5dc1b 100644
--- a/libavcodec/yuv4enc.c
+++ b/libavcodec/yuv4enc.c
@@ -28,7 +28,7 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                              const AVFrame *pic, int *got_packet)
 {
     uint8_t *dst;
-    uint8_t *y, *u, *v;
+    const uint8_t *y, *u, *v;
     int i, j, ret;
 
     ret = ff_get_encode_buffer(avctx, pkt, 6 * (avctx->width  + 1 >> 1)
diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index c63f411eb5..cc8578afea 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -84,8 +84,8 @@ typedef struct ZmbvEncContext {
 /** Block comparing function
  * XXX should be optimized and moved to DSPContext
  */
-static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
-                            uint8_t *src2, int stride2, int bw, int bh,
+static inline int block_cmp(ZmbvEncContext *c, const uint8_t *src, int stride,
+                            const uint8_t *src2, int stride2, int bw, int bh,
                             int *xored)
 {
     int sum = 0;
@@ -119,7 +119,7 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
 /** Motion estimation function
  * TODO make better ME decisions
  */
-static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
+static int zmbv_me(ZmbvEncContext *c, const uint8_t *src, int sstride, const uint8_t *prev,
                    int pstride, int x, int y, int *mx, int *my, int *xored)
 {
     int dx, dy, txored, tv, bv, bw, bh;
@@ -171,7 +171,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     ZmbvEncContext * const c = avctx->priv_data;
     z_stream  *const zstream = &c->zstream.zstream;
     const AVFrame * const p = pict;
-    uint8_t *src, *prev, *buf;
+    const uint8_t *src;
+    uint8_t *prev, *buf;
     uint32_t *palptr;
     int keyframe, chpal;
     int fl;
@@ -218,7 +219,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         }
     }else{
         int x, y, bh2, bw2, xored;
-        uint8_t *tsrc, *tprev;
+        const uint8_t *tsrc, *tprev;
         uint8_t *mv;
         int mx = 0, my = 0;
 
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index()
  2022-07-26 21:47 [FFmpeg-devel] [PATCH 01/39] avcodec/hevcdsp: Constify src pointers Andreas Rheinhardt
                   ` (36 preceding siblings ...)
  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 ` Andreas Rheinhardt
  2022-07-28 22:02   ` Michael Niedermayer
  37 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-26 22:08 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

This is possible for most of the callers, because e.g. only
the MPEG-4 decoder can have bits_per_raw_sample > 8.
Also most mpegvideo-based codecs are 420 only.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h261dec.c       |  4 ++--
 libavcodec/h261enc.c       |  2 +-
 libavcodec/h263dec.c       |  3 ++-
 libavcodec/mpeg4videodec.c |  6 ++++--
 libavcodec/mpeg_er.c       |  3 ++-
 libavcodec/mpegvideo.h     | 12 +++++++-----
 libavcodec/mpegvideo_enc.c |  2 +-
 libavcodec/rv10.c          |  2 +-
 libavcodec/rv34.c          |  2 +-
 libavcodec/vc1_block.c     | 17 ++++++++++++-----
 10 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index af9ccbbd70..97c126ab5a 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -214,7 +214,7 @@ static int h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
         s->mb_y = ((h->gob_number - 1) / 2) * 3 + i / 11;
         xy      = s->mb_x + s->mb_y * s->mb_stride;
         ff_init_block_index(s);
-        ff_update_block_index(s);
+        ff_update_block_index(s, 8, s->avctx->lowres, 1);
 
         for (j = 0; j < 6; j++)
             s->block_last_index[j] = -1;
@@ -400,7 +400,7 @@ static int h261_decode_mb(H261DecContext *h)
     s->mb_y = ((h->gob_number - 1) / 2) * 3 + ((h->current_mba - 1) / 11);
     xy      = s->mb_x + s->mb_y * s->mb_stride;
     ff_init_block_index(s);
-    ff_update_block_index(s);
+    ff_update_block_index(s, 8, s->avctx->lowres, 1);
 
     // Read mtype
     com->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index a7fb666faa..a1fba968a4 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -139,7 +139,7 @@ void ff_h261_reorder_mb_index(MpegEncContext *s)
         s->mb_y += 3 * index;
 
         ff_init_block_index(s);
-        ff_update_block_index(s);
+        ff_update_block_index(s, 8, 0, 1);
     }
 }
 
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 39183c8b27..b4f9fa5022 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -258,7 +258,8 @@ static int decode_slice(MpegEncContext *s)
         for (; s->mb_x < s->mb_width; s->mb_x++) {
             int ret;
 
-            ff_update_block_index(s);
+            ff_update_block_index(s, s->avctx->bits_per_raw_sample,
+                                  s->avctx->lowres, s->chroma_x_shift);
 
             if (s->resync_mb_x == s->mb_x && s->resync_mb_y + 1 == s->mb_y)
                 s->first_slice_line = 0;
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 5591816db5..bfebc3806c 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -772,7 +772,8 @@ static int mpeg4_decode_partition_a(Mpeg4DecContext *ctx)
             int dir = 0;
 
             mb_num++;
-            ff_update_block_index(s);
+            ff_update_block_index(s, s->avctx->bits_per_raw_sample,
+                                  s->avctx->lowres, s->chroma_x_shift);
             if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1)
                 s->first_slice_line = 0;
 
@@ -963,7 +964,8 @@ static int mpeg4_decode_partition_b(MpegEncContext *s, int mb_count)
             const int xy = s->mb_x + s->mb_y * s->mb_stride;
 
             mb_num++;
-            ff_update_block_index(s);
+            ff_update_block_index(s, s->avctx->bits_per_raw_sample,
+                                  s->avctx->lowres, s->chroma_x_shift);
             if (s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y + 1)
                 s->first_slice_line = 0;
 
diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c
index f54cb8548b..02f407d8ea 100644
--- a/libavcodec/mpeg_er.c
+++ b/libavcodec/mpeg_er.c
@@ -75,7 +75,8 @@ static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
     memcpy(s->mv, mv, sizeof(*mv));
 
     ff_init_block_index(s);
-    ff_update_block_index(s);
+    ff_update_block_index(s, s->avctx->bits_per_raw_sample,
+                          s->avctx->lowres, s->chroma_x_shift);
 
     s->bdsp.clear_blocks(s->block[0]);
     if (!s->chroma_y_shift)
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 287fd38bd3..b1b2727535 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -590,9 +590,11 @@ void ff_mpv_motion(MpegEncContext *s,
                    op_pixels_func (*pix_op)[4],
                    qpel_mc_func (*qpix_op)[16]);
 
-static inline void ff_update_block_index(MpegEncContext *s){
-    const int bytes_per_pixel = 1 + (s->avctx->bits_per_raw_sample > 8);
-    const int block_size= (8*bytes_per_pixel) >> s->avctx->lowres;
+static inline void ff_update_block_index(MpegEncContext *s, int bits_per_raw_sample,
+                                         int lowres, int chroma_x_shift)
+{
+    const int bytes_per_pixel = 1 + (bits_per_raw_sample > 8);
+    const int block_size = (8 * bytes_per_pixel) >> lowres;
 
     s->block_index[0]+=2;
     s->block_index[1]+=2;
@@ -601,8 +603,8 @@ static inline void ff_update_block_index(MpegEncContext *s){
     s->block_index[4]++;
     s->block_index[5]++;
     s->dest[0]+= 2*block_size;
-    s->dest[1]+= (2 >> s->chroma_x_shift) * block_size;
-    s->dest[2]+= (2 >> s->chroma_x_shift) * block_size;
+    s->dest[1] += (2 >> chroma_x_shift) * block_size;
+    s->dest[2] += (2 >> chroma_x_shift) * block_size;
 }
 
 #endif /* AVCODEC_MPEGVIDEO_H */
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 4719a734c9..b04616f84d 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2852,7 +2852,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
 
             s->mb_x = mb_x;
             s->mb_y = mb_y;  // moved into loop, can get changed by H.261
-            ff_update_block_index(s);
+            ff_update_block_index(s, 8, 0, s->chroma_x_shift);
 
             if(CONFIG_H261_ENCODER && s->codec_id == AV_CODEC_ID_H261){
                 ff_h261_reorder_mb_index(s);
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 23947201a4..abf42612cb 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -531,7 +531,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
     /* decode each macroblock */
     for (s->mb_num_left = mb_count; s->mb_num_left > 0; s->mb_num_left--) {
         int ret;
-        ff_update_block_index(s);
+        ff_update_block_index(s, 8, s->avctx->lowres, 1);
         ff_tlog(avctx, "**mb x=%d y=%d\n", s->mb_x, s->mb_y);
 
         s->mv_dir  = MV_DIR_FORWARD;
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 2ac3f2c7b2..61d1e4c527 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1445,7 +1445,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
 
     ff_init_block_index(s);
     while(!check_slice_end(r, s)) {
-        ff_update_block_index(s);
+        ff_update_block_index(s, 8, 0, 1);
 
         if(r->si.type)
             res = rv34_decode_inter_macroblock(r, r->intra_types + s->mb_x * 4 + 4);
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
index 119df4081d..3267fc269b 100644
--- a/libavcodec/vc1_block.c
+++ b/libavcodec/vc1_block.c
@@ -68,6 +68,13 @@ static inline void init_block_index(VC1Context *v)
     }
 }
 
+static inline void update_block_index(MpegEncContext *s)
+{
+    /* VC1 is always 420 except when using AV_CODEC_FLAG_GRAY
+     * (or a HWAccel). Shall we inline this value? */
+    ff_update_block_index(s, 8, 0, s->chroma_x_shift);
+}
+
 /** @} */ //Bitplane group
 
 static void vc1_put_blocks_clamped(VC1Context *v, int put_signed)
@@ -2570,7 +2577,7 @@ static void vc1_decode_i_blocks(VC1Context *v)
         s->mb_x = 0;
         init_block_index(v);
         for (; s->mb_x < v->end_mb_x; s->mb_x++) {
-            ff_update_block_index(s);
+            update_block_index(s);
             s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
             mb_pos = s->mb_x + s->mb_y * s->mb_width;
             s->current_picture.mb_type[mb_pos]                     = MB_TYPE_INTRA;
@@ -2705,7 +2712,7 @@ static int vc1_decode_i_blocks_adv(VC1Context *v)
         init_block_index(v);
         for (;s->mb_x < s->mb_width; s->mb_x++) {
             mquant = v->pq;
-            ff_update_block_index(s);
+            update_block_index(s);
             s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
             mb_pos = s->mb_x + s->mb_y * s->mb_stride;
             s->current_picture.mb_type[mb_pos + v->mb_off]                         = MB_TYPE_INTRA;
@@ -2830,7 +2837,7 @@ static void vc1_decode_p_blocks(VC1Context *v)
         s->mb_x = 0;
         init_block_index(v);
         for (; s->mb_x < s->mb_width; s->mb_x++) {
-            ff_update_block_index(s);
+            update_block_index(s);
 
             if (v->fcm == ILACE_FIELD || (v->fcm == PROGRESSIVE && v->mv_type_is_raw) || v->skip_is_raw)
                 if (get_bits_left(&v->s.gb) <= 1) {
@@ -2919,7 +2926,7 @@ static void vc1_decode_b_blocks(VC1Context *v)
         s->mb_x = 0;
         init_block_index(v);
         for (; s->mb_x < s->mb_width; s->mb_x++) {
-            ff_update_block_index(s);
+            update_block_index(s);
 
             if (v->fcm == ILACE_FIELD || v->skip_is_raw || v->dmb_is_raw)
                 if (get_bits_left(&v->s.gb) <= 1) {
@@ -2981,7 +2988,7 @@ static void vc1_decode_skip_blocks(VC1Context *v)
     for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
         s->mb_x = 0;
         init_block_index(v);
-        ff_update_block_index(s);
+        update_block_index(s);
         memcpy(s->dest[0], s->last_picture.f->data[0] + s->mb_y * 16 * s->linesize,   s->linesize   * 16);
         memcpy(s->dest[1], s->last_picture.f->data[1] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
         memcpy(s->dest[2], s->last_picture.f->data[2] + s->mb_y *  8 * s->uvlinesize, s->uvlinesize *  8);
-- 
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: Constify slice threads' ptr to main context
  2022-07-26 22:07 ` [FFmpeg-devel] [PATCH 07/39] avcodec/vp8: " Andreas Rheinhardt
@ 2022-07-27 10:24   ` Ronald S. Bultje
  0 siblings, 0 replies; 51+ messages in thread
From: Ronald S. Bultje @ 2022-07-27 10:24 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

Hi,

On Wed, Jul 27, 2022 at 5:31 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Modifying the main context from a slice thread is (usually)
> a data race, so it must not happen. So only use a pointer to const
> to access the main context.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/vp8.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index e474fc5de5..d0c26ba00d 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -2582,7 +2582,7 @@ static av_always_inline
>  int vp78_decode_mb_row_sliced(AVCodecContext *avctx, void *tdata, int
> jobnr,
>                                int threadnr, int is_vp7)
>  {
> -    VP8Context *s = avctx->priv_data;
> +    const VP8Context *s = avctx->priv_data;
>      VP8ThreadData *td = &s->thread_data[jobnr];
>      VP8ThreadData *next_td = NULL, *prev_td = NULL;
>      VP8Frame *curframe = s->curframe;
> --
> 2.34.1
>

OK.

Ronald
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 05/39] avcodec/vp9dec: Constify VP9TileData->VP9Context pointer target
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Ronald S. Bultje @ 2022-07-27 10:25 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

Hi,

On Wed, Jul 27, 2022 at 5:32 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> This is possible now that ff_thread_await_progress() accepts
> a const ThreadFrame*.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/vp9_mc_template.c |  2 +-
>  libavcodec/vp9block.c        | 30 +++++++++++++++---------------
>  libavcodec/vp9dec.h          |  4 +---
>  libavcodec/vp9mvs.c          |  6 +++---
>  libavcodec/vp9recon.c        | 22 +++++++++++-----------
>  5 files changed, 31 insertions(+), 33 deletions(-)
>

OK.

Ronald
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index()
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Michael Niedermayer @ 2022-07-28 22:02 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1169 bytes --]

On Wed, Jul 27, 2022 at 12:08:14AM +0200, Andreas Rheinhardt wrote:
> This is possible for most of the callers, because e.g. only
> the MPEG-4 decoder can have bits_per_raw_sample > 8.
> Also most mpegvideo-based codecs are 420 only.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/h261dec.c       |  4 ++--
>  libavcodec/h261enc.c       |  2 +-
>  libavcodec/h263dec.c       |  3 ++-
>  libavcodec/mpeg4videodec.c |  6 ++++--
>  libavcodec/mpeg_er.c       |  3 ++-
>  libavcodec/mpegvideo.h     | 12 +++++++-----
>  libavcodec/mpegvideo_enc.c |  2 +-
>  libavcodec/rv10.c          |  2 +-
>  libavcodec/rv34.c          |  2 +-
>  libavcodec/vc1_block.c     | 17 ++++++++++++-----
>  10 files changed, 33 insertions(+), 20 deletions(-)

ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Michael Niedermayer @ 2022-07-28 22:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1252 bytes --]

On Wed, Jul 27, 2022 at 12:08:12AM +0200, Andreas Rheinhardt wrote:
> Also constify the corresponding code in mpegvideo.c that handles
> lowres.
> (Unfortunately, not everything that is const could be constified:
> ref_picture could be made const uint8_t* const* if C allowed the
> safe automatic conversion from uint8_t**; and pix_op, qpix_op
> could be made to point to const function pointers, but C's handling
> of const in pointers to arrays is broken.)
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/mpegvideo.c        | 24 ++++++++++----------
>  libavcodec/mpegvideo.h        |  2 +-
>  libavcodec/mpegvideo_motion.c | 41 ++++++++++++++++++-----------------
>  libavcodec/wmv2.c             |  4 ++--
>  libavcodec/wmv2.h             |  2 +-
>  5 files changed, 37 insertions(+), 36 deletions(-)

LGTM

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 36/39] avcodec/motion_est: Constify pointers to frame data
  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
  0 siblings, 0 replies; 51+ messages in thread
From: Michael Niedermayer @ 2022-07-28 22:04 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 459 bytes --]

On Wed, Jul 27, 2022 at 12:08:11AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/motion_est.c | 31 +++++++++++++++++--------------
>  libavcodec/motion_est.h |  4 ++--
>  2 files changed, 19 insertions(+), 16 deletions(-)

LGTM

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

You can kill me, but you cannot change the truth.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  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
  0 siblings, 1 reply; 51+ messages in thread
From: Michael Niedermayer @ 2022-07-28 22:05 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1152 bytes --]

On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
>  libavcodec/mips/h263dsp_mips.h             |  2 +-
>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
>  9 files changed, 26 insertions(+), 26 deletions(-)

LGTM, also all similar things should be ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Any man who breaks a law that conscience tells him is unjust and willingly 
accepts the penalty by staying in jail in order to arouse the conscience of 
the community on the injustice of the law is at that moment expressing the 
very highest respect for law. - Martin Luther King Jr

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-07-28 22:05   ` Michael Niedermayer
@ 2022-07-30  9:55     ` Andreas Rheinhardt
  2022-07-30 17:12       ` Michael Niedermayer
  0 siblings, 1 reply; 51+ messages in thread
From: Andreas Rheinhardt @ 2022-07-30  9:55 UTC (permalink / raw)
  To: ffmpeg-devel

Michael Niedermayer:
> On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
>>  libavcodec/mips/h263dsp_mips.h             |  2 +-
>>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
>>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
>>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
>>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
>>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
>>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
>>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
>>  9 files changed, 26 insertions(+), 26 deletions(-)
> 
> LGTM, also all similar things should be ok
> 
> [...]
> 

Unfortunately, it is not so easy. The first version of this patchset
(this here) forgot to update the definitions of several loongarch
functions, leading to lots of red on patchwork. The second version fixed
the compilation error, but forgot some constifications due to
unfortunate oversights. For the third version, I wanted to actually
compile loongarch instead of just staring at the code; but the
GCC-cross-compiler does not seem to support lsx and lasx (and looking at
the loongarch-code in GCC makes me believe that they are just not
supported (yet)). Therefore I resorted to creating dummy-functions for
all the __lasx_* and __lsx_* functions (they show no more
const-warnings). I wanted to let the FATE-loongarch-box test this once
more (and tell me whether there are still any issues left), yet this box
is no longer active since a few days (for reasons unknown). Can you
compile the lsx and lasx code (after all, you committed all the
loongarch code)?

- Andreas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-07-30  9:55     ` Andreas Rheinhardt
@ 2022-07-30 17:12       ` Michael Niedermayer
  2022-08-02  9:30         ` Anton Khirnov
  0 siblings, 1 reply; 51+ messages in thread
From: Michael Niedermayer @ 2022-07-30 17:12 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 3093 bytes --]

On Sat, Jul 30, 2022 at 11:55:45AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> >> ---
> >>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
> >>  libavcodec/mips/h263dsp_mips.h             |  2 +-
> >>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
> >>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
> >>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
> >>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
> >>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
> >>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
> >>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
> >>  9 files changed, 26 insertions(+), 26 deletions(-)
> > 
> > LGTM, also all similar things should be ok
> > 
> > [...]
> > 
> 
> Unfortunately, it is not so easy. The first version of this patchset
> (this here) forgot to update the definitions of several loongarch
> functions, leading to lots of red on patchwork. The second version fixed
> the compilation error, but forgot some constifications due to
> unfortunate oversights. For the third version, I wanted to actually
> compile loongarch instead of just staring at the code; but the
> GCC-cross-compiler does not seem to support lsx and lasx (and looking at
> the loongarch-code in GCC makes me believe that they are just not
> supported (yet)). Therefore I resorted to creating dummy-functions for
> all the __lasx_* and __lsx_* functions (they show no more
> const-warnings). I wanted to let the FATE-loongarch-box test this once
> more (and tell me whether there are still any issues left), yet this box
> is no longer active since a few days (for reasons unknown). Can you
> compile the lsx and lasx code (after all, you committed all the
> loongarch code)?

i have no easy way to test loongarch, what i can test is qemu-mips.
i think i have said that a few times already.

I do have a loongson box that is IIRC ready to be shipped (within EU) to
whoever volunteers to maintain that box for FFmpeg. I dont know if that
box would help with the current code. The OS will liklely need to be updated
and IIRC this has no normal update mechanism) I didnt touch this box for a
really long time.

I apply loongarch patches when they are reviewed and approved by the loongson
maintainers.
I do test that they do not break qemu-mips and give them a quick look also
so they dont contains obvious mistakes like changing non mips things

about patchwork, please talk with Andriy.
If you want to help maintain patchwork and or look into that yourself,
again talk with Andriy.
Also paul on IRC said Andriy left ffmpeg, i havent heared anything from
Andriy in that direction. So this may be a joke from paul i do not know

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-07-30 17:12       ` Michael Niedermayer
@ 2022-08-02  9:30         ` Anton Khirnov
  2022-08-03 15:28           ` Michael Niedermayer
  0 siblings, 1 reply; 51+ messages in thread
From: Anton Khirnov @ 2022-08-02  9:30 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Michael Niedermayer (2022-07-30 19:12:39)
> On Sat, Jul 30, 2022 at 11:55:45AM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> > >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > >> ---
> > >>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
> > >>  libavcodec/mips/h263dsp_mips.h             |  2 +-
> > >>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
> > >>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
> > >>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
> > >>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
> > >>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
> > >>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
> > >>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
> > >>  9 files changed, 26 insertions(+), 26 deletions(-)
> > > 
> > > LGTM, also all similar things should be ok
> > > 
> > > [...]
> > > 
> > 
> > Unfortunately, it is not so easy. The first version of this patchset
> > (this here) forgot to update the definitions of several loongarch
> > functions, leading to lots of red on patchwork. The second version fixed
> > the compilation error, but forgot some constifications due to
> > unfortunate oversights. For the third version, I wanted to actually
> > compile loongarch instead of just staring at the code; but the
> > GCC-cross-compiler does not seem to support lsx and lasx (and looking at
> > the loongarch-code in GCC makes me believe that they are just not
> > supported (yet)). Therefore I resorted to creating dummy-functions for
> > all the __lasx_* and __lsx_* functions (they show no more
> > const-warnings). I wanted to let the FATE-loongarch-box test this once
> > more (and tell me whether there are still any issues left), yet this box
> > is no longer active since a few days (for reasons unknown). Can you
> > compile the lsx and lasx code (after all, you committed all the
> > loongarch code)?
> 
> i have no easy way to test loongarch, what i can test is qemu-mips.
> i think i have said that a few times already.
> 
> I do have a loongson box that is IIRC ready to be shipped (within EU) to
> whoever volunteers to maintain that box for FFmpeg. I dont know if that
> box would help with the current code. The OS will liklely need to be updated
> and IIRC this has no normal update mechanism) I didnt touch this box for a
> really long time.

What OS is it?

I could conceivably host such a machine and give other devs SSH access
to it, if it does not require too much maintenance and/or electricity.

-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  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
  0 siblings, 2 replies; 51+ messages in thread
From: Michael Niedermayer @ 2022-08-03 15:28 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 3815 bytes --]

On Tue, Aug 02, 2022 at 11:30:39AM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2022-07-30 19:12:39)
> > On Sat, Jul 30, 2022 at 11:55:45AM +0200, Andreas Rheinhardt wrote:
> > > Michael Niedermayer:
> > > > On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> > > >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > > >> ---
> > > >>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
> > > >>  libavcodec/mips/h263dsp_mips.h             |  2 +-
> > > >>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
> > > >>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
> > > >>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
> > > >>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
> > > >>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
> > > >>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
> > > >>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
> > > >>  9 files changed, 26 insertions(+), 26 deletions(-)
> > > > 
> > > > LGTM, also all similar things should be ok
> > > > 
> > > > [...]
> > > > 
> > > 
> > > Unfortunately, it is not so easy. The first version of this patchset
> > > (this here) forgot to update the definitions of several loongarch
> > > functions, leading to lots of red on patchwork. The second version fixed
> > > the compilation error, but forgot some constifications due to
> > > unfortunate oversights. For the third version, I wanted to actually
> > > compile loongarch instead of just staring at the code; but the
> > > GCC-cross-compiler does not seem to support lsx and lasx (and looking at
> > > the loongarch-code in GCC makes me believe that they are just not
> > > supported (yet)). Therefore I resorted to creating dummy-functions for
> > > all the __lasx_* and __lsx_* functions (they show no more
> > > const-warnings). I wanted to let the FATE-loongarch-box test this once
> > > more (and tell me whether there are still any issues left), yet this box
> > > is no longer active since a few days (for reasons unknown). Can you
> > > compile the lsx and lasx code (after all, you committed all the
> > > loongarch code)?
> > 
> > i have no easy way to test loongarch, what i can test is qemu-mips.
> > i think i have said that a few times already.
> > 
> > I do have a loongson box that is IIRC ready to be shipped (within EU) to
> > whoever volunteers to maintain that box for FFmpeg. I dont know if that
> > box would help with the current code. The OS will liklely need to be updated
> > and IIRC this has no normal update mechanism) I didnt touch this box for a
> > really long time.
> 
> What OS is it?

looking thorugh past emails (so i dont have to get the box and unpack it again)

its some custom fedora/redhat
that additional info i found while double checking the OS:

 according to /proc/cpuinfo, 4 core
 system type             : lst-loongson3-eva
 machine                 : Unknown
 processor               : 0
 cpu model               : ICT Loongson-3A V0.5  FPU V0.1
 BogoMIPS                : 717.28
 ...
 with 500gb 7200rpm WD Caviar Blue HDD
 4gb memory


> 
> I could conceivably host such a machine and give other devs SSH access
> to it, if it does not require too much maintenance and/or electricity.

given the tiny heatsink/fan on the CPU i dont think it would require alot of power
send me teh target address and ill get it shipped to you assuming the box is still where
it was and i find it

thx


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-08-03 15:28           ` Michael Niedermayer
@ 2022-08-03 15:48             ` Michael Niedermayer
  2022-08-06 13:07             ` Anton Khirnov
  1 sibling, 0 replies; 51+ messages in thread
From: Michael Niedermayer @ 2022-08-03 15:48 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 4505 bytes --]

On Wed, Aug 03, 2022 at 05:28:16PM +0200, Michael Niedermayer wrote:
> On Tue, Aug 02, 2022 at 11:30:39AM +0200, Anton Khirnov wrote:
> > Quoting Michael Niedermayer (2022-07-30 19:12:39)
> > > On Sat, Jul 30, 2022 at 11:55:45AM +0200, Andreas Rheinhardt wrote:
> > > > Michael Niedermayer:
> > > > > On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote:
> > > > >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> > > > >> ---
> > > > >>  libavcodec/arm/mpegvideoencdsp_init_arm.c  |  4 ++--
> > > > >>  libavcodec/mips/h263dsp_mips.h             |  2 +-
> > > > >>  libavcodec/mips/mpegvideoencdsp_msa.c      |  4 ++--
> > > > >>  libavcodec/mpegvideoencdsp.c               | 10 +++++-----
> > > > >>  libavcodec/mpegvideoencdsp.h               | 10 +++++-----
> > > > >>  libavcodec/ppc/mpegvideoencdsp.c           |  8 ++++----
> > > > >>  libavcodec/x86/mpegvideoenc_qns_template.c |  4 ++--
> > > > >>  libavcodec/x86/mpegvideoencdsp.asm         |  4 ++--
> > > > >>  libavcodec/x86/mpegvideoencdsp_init.c      |  6 +++---
> > > > >>  9 files changed, 26 insertions(+), 26 deletions(-)
> > > > > 
> > > > > LGTM, also all similar things should be ok
> > > > > 
> > > > > [...]
> > > > > 
> > > > 
> > > > Unfortunately, it is not so easy. The first version of this patchset
> > > > (this here) forgot to update the definitions of several loongarch
> > > > functions, leading to lots of red on patchwork. The second version fixed
> > > > the compilation error, but forgot some constifications due to
> > > > unfortunate oversights. For the third version, I wanted to actually
> > > > compile loongarch instead of just staring at the code; but the
> > > > GCC-cross-compiler does not seem to support lsx and lasx (and looking at
> > > > the loongarch-code in GCC makes me believe that they are just not
> > > > supported (yet)). Therefore I resorted to creating dummy-functions for
> > > > all the __lasx_* and __lsx_* functions (they show no more
> > > > const-warnings). I wanted to let the FATE-loongarch-box test this once
> > > > more (and tell me whether there are still any issues left), yet this box
> > > > is no longer active since a few days (for reasons unknown). Can you
> > > > compile the lsx and lasx code (after all, you committed all the
> > > > loongarch code)?
> > > 
> > > i have no easy way to test loongarch, what i can test is qemu-mips.
> > > i think i have said that a few times already.
> > > 
> > > I do have a loongson box that is IIRC ready to be shipped (within EU) to
> > > whoever volunteers to maintain that box for FFmpeg. I dont know if that
> > > box would help with the current code. The OS will liklely need to be updated
> > > and IIRC this has no normal update mechanism) I didnt touch this box for a
> > > really long time.
> > 
> > What OS is it?
> 
> looking thorugh past emails (so i dont have to get the box and unpack it again)
> 
> its some custom fedora/redhat
> that additional info i found while double checking the OS:
> 
>  according to /proc/cpuinfo, 4 core
>  system type             : lst-loongson3-eva
>  machine                 : Unknown
>  processor               : 0
>  cpu model               : ICT Loongson-3A V0.5  FPU V0.1
>  BogoMIPS                : 717.28
>  ...
>  with 500gb 7200rpm WD Caviar Blue HDD
>  4gb memory
> 
> 
> > 
> > I could conceivably host such a machine and give other devs SSH access
> > to it, if it does not require too much maintenance and/or electricity.
> 
> given the tiny heatsink/fan on the CPU i dont think it would require alot of power
> send me teh target address and ill get it shipped to you assuming the box is still where
> it was and i find it

more precisse power usage: (from 2015)

~1W when OFF
~44W when IDLE
~48W when running fate tests

in 2015 with FFmpeg from 2015:

4m49.192s for time ./configure --enable-gpl --enable-pthreads --samples=/home/loongson/fate/ --enable-nonfree --enable-version3 --assert-level=2 --cpu=loongson3a --enable-loongson3
19m31.114s for make -j4

time make fate -j4 -k >& fatelist8
real 28m32.631s
user 98m50.422s
sys 12m53.547s

CPU coolong fan was also replaced with a Noctua NF-A6x25 FLX as the original was really loud

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

* Re: [FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
  2022-08-03 15:28           ` Michael Niedermayer
  2022-08-03 15:48             ` Michael Niedermayer
@ 2022-08-06 13:07             ` Anton Khirnov
  1 sibling, 0 replies; 51+ messages in thread
From: Anton Khirnov @ 2022-08-06 13:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,
Quoting Michael Niedermayer (2022-08-03 17:28:16)
> 
> looking thorugh past emails (so i dont have to get the box and unpack it again)
> 
> its some custom fedora/redhat
> that additional info i found while double checking the OS:
> 
>  according to /proc/cpuinfo, 4 core
>  system type             : lst-loongson3-eva
>  machine                 : Unknown
>  processor               : 0
>  cpu model               : ICT Loongson-3A V0.5  FPU V0.1
>  BogoMIPS                : 717.28
>  ...
>  with 500gb 7200rpm WD Caviar Blue HDD
>  4gb memory
> 
> 
> > 
> > I could conceivably host such a machine and give other devs SSH access
> > to it, if it does not require too much maintenance and/or electricity.
> 
> given the tiny heatsink/fan on the CPU i dont think it would require alot of power
> send me teh target address and ill get it shipped to you assuming the box is still where

Please send it to:
Anton Khirnov
K Bohnicim 57/2
17100 Praha-Troja
Czech Republic

Thanks,
-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2022-08-06 13:07 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 23/39] avcodec/ilbcdec: Fix const correctness Andreas Rheinhardt
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

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