diff mbox series

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

Message ID DB6PR0101MB2214194F1E9DCC5074799DC28F949@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 966fc1230a68d4107994038b71c3200b069ed22e
Headers show
Series [FFmpeg-devel,01/39] avcodec/hevcdsp: Constify src pointers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 26, 2022, 10:08 p.m. UTC
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(-)

Comments

Michael Niedermayer July 28, 2022, 10:05 p.m. UTC | #1
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

[...]
Andreas Rheinhardt July 30, 2022, 9:55 a.m. UTC | #2
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
Michael Niedermayer July 30, 2022, 5:12 p.m. UTC | #3
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

[...]
Anton Khirnov Aug. 2, 2022, 9:30 a.m. UTC | #4
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.
Michael Niedermayer Aug. 3, 2022, 3:28 p.m. UTC | #5
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 Niedermayer Aug. 3, 2022, 3:48 p.m. UTC | #6
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

[...]
Anton Khirnov Aug. 6, 2022, 1:07 p.m. UTC | #7
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,
diff mbox series

Patch

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