[FFmpeg-devel] [PATCH 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jul 27 01:08:09 EEST 2022


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at 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



More information about the ffmpeg-devel mailing list