diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-04-06 16:36:02 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-04-06 16:36:02 +0000 |
commit | 0b6eb24b9a8034287f67f800fc61d07b7f018891 (patch) | |
tree | ee1e7fe1ba37e57d24b8604e1c53f38e7b67484c /libmpeg2/motion_comp_mmx.c | |
parent | 27ff6fa04a22e2a56848b3ff3e1d681a18bc98e4 (diff) | |
download | mpv-0b6eb24b9a8034287f67f800fc61d07b7f018891.tar.bz2 mpv-0b6eb24b9a8034287f67f800fc61d07b7f018891.tar.xz |
Importing libmpeg2 from mpeg2dec-0.3.1
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9853 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpeg2/motion_comp_mmx.c')
-rw-r--r-- | libmpeg2/motion_comp_mmx.c | 530 |
1 files changed, 259 insertions, 271 deletions
diff --git a/libmpeg2/motion_comp_mmx.c b/libmpeg2/motion_comp_mmx.c index 51b40bac55..33103e1738 100644 --- a/libmpeg2/motion_comp_mmx.c +++ b/libmpeg2/motion_comp_mmx.c @@ -1,8 +1,10 @@ /* * motion_comp_mmx.c - * Copyright (C) 1999-2001 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> + * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. + * See http://libmpeg2.sourceforge.net/ for updates. * * mpeg2dec is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +27,7 @@ #include <inttypes.h> +#include "mpeg2.h" #include "mpeg2_internal.h" #include "attributes.h" #include "mmx.h" @@ -35,15 +38,22 @@ /* MMX code - needs a rewrite */ - - - - - +/* + * Motion Compensation frequently needs to average values using the + * formula (x+y+1)>>1. Both MMXEXT and 3Dnow include one instruction + * to compute this, but it's been left out of classic MMX. + * + * We need to be careful of overflows when doing this computation. + * Rather than unpacking data to 16-bits, which reduces parallelism, + * we use the following formulas: + * + * (x+y)>>1 == (x&y)+((x^y)>>1) + * (x+y+1)>>1 == (x|y)-((x^y)>>1) + */ /* some rounding constants */ -mmx_t round1 = {0x0001000100010001LL}; -mmx_t round4 = {0x0002000200020002LL}; +static mmx_t mask1 = {0xfefefefefefefefeLL}; +static mmx_t round4 = {0x0002000200020002LL}; /* * This code should probably be compiled with loop unrolling @@ -59,202 +69,176 @@ static inline void mmx_zero_reg () pxor_r2r (mm0, mm0); } -static inline void mmx_average_2_U8 (uint8_t * dest, - uint8_t * src1, uint8_t * src2) +static inline void mmx_average_2_U8 (uint8_t * dest, const uint8_t * src1, + const uint8_t * src2) { /* *dest = (*src1 + *src2 + 1)/ 2; */ - movq_m2r (*src1, mm1); // load 8 src1 bytes - movq_r2r (mm1, mm2); // copy 8 src1 bytes - - movq_m2r (*src2, mm3); // load 8 src2 bytes - movq_r2r (mm3, mm4); // copy 8 src2 bytes - - punpcklbw_r2r (mm0, mm1); // unpack low src1 bytes - punpckhbw_r2r (mm0, mm2); // unpack high src1 bytes + movq_m2r (*src1, mm1); /* load 8 src1 bytes */ + movq_r2r (mm1, mm2); /* copy 8 src1 bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src2 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src2 bytes + movq_m2r (*src2, mm3); /* load 8 src2 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src2 bytes */ - paddw_r2r (mm3, mm1); // add lows to mm1 - paddw_m2r (round1, mm1); - psraw_i2r (1, mm1); // /2 - - paddw_r2r (mm4, mm2); // add highs to mm2 - paddw_m2r (round1, mm2); - psraw_i2r (1, mm2); // /2 - - packuswb_r2r (mm2, mm1); // pack (w/ saturation) - movq_r2m (mm1, *dest); // store result in dest + pxor_r2r (mm1, mm3); /* xor src1 and src2 */ + pand_m2r (mask1, mm3); /* mask lower bits */ + psrlq_i2r (1, mm3); /* /2 */ + por_r2r (mm2, mm4); /* or src1 and src2 */ + psubb_r2r (mm3, mm4); /* subtract subresults */ + movq_r2m (mm4, *dest); /* store result in dest */ } static inline void mmx_interp_average_2_U8 (uint8_t * dest, - uint8_t * src1, uint8_t * src2) + const uint8_t * src1, + const uint8_t * src2) { /* *dest = (*dest + (*src1 + *src2 + 1)/ 2 + 1)/ 2; */ - movq_m2r (*dest, mm1); // load 8 dest bytes - movq_r2r (mm1, mm2); // copy 8 dest bytes - - movq_m2r (*src1, mm3); // load 8 src1 bytes - movq_r2r (mm3, mm4); // copy 8 src1 bytes - - movq_m2r (*src2, mm5); // load 8 src2 bytes - movq_r2r (mm5, mm6); // copy 8 src2 bytes - - punpcklbw_r2r (mm0, mm1); // unpack low dest bytes - punpckhbw_r2r (mm0, mm2); // unpack high dest bytes + movq_m2r (*dest, mm1); /* load 8 dest bytes */ + movq_r2r (mm1, mm2); /* copy 8 dest bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src1 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src1 bytes + movq_m2r (*src1, mm3); /* load 8 src1 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src1 bytes */ - punpcklbw_r2r (mm0, mm5); // unpack low src2 bytes - punpckhbw_r2r (mm0, mm6); // unpack high src2 bytes + movq_m2r (*src2, mm5); /* load 8 src2 bytes */ + movq_r2r (mm5, mm6); /* copy 8 src2 bytes */ - paddw_r2r (mm5, mm3); // add lows - paddw_m2r (round1, mm3); - psraw_i2r (1, mm3); // /2 + pxor_r2r (mm3, mm5); /* xor src1 and src2 */ + pand_m2r (mask1, mm5); /* mask lower bits */ + psrlq_i2r (1, mm5); /* /2 */ + por_r2r (mm4, mm6); /* or src1 and src2 */ + psubb_r2r (mm5, mm6); /* subtract subresults */ + movq_r2r (mm6, mm5); /* copy subresult */ - paddw_r2r (mm6, mm4); // add highs - paddw_m2r (round1, mm4); - psraw_i2r (1, mm4); // /2 - - paddw_r2r (mm3, mm1); // add lows - paddw_m2r (round1, mm1); - psraw_i2r (1, mm1); // /2 - - paddw_r2r (mm4, mm2); // add highs - paddw_m2r (round1, mm2); - psraw_i2r (1, mm2); // /2 - - packuswb_r2r (mm2, mm1); // pack (w/ saturation) - movq_r2m (mm1, *dest); // store result in dest + pxor_r2r (mm1, mm5); /* xor srcavg and dest */ + pand_m2r (mask1, mm5); /* mask lower bits */ + psrlq_i2r (1, mm5); /* /2 */ + por_r2r (mm2, mm6); /* or srcavg and dest */ + psubb_r2r (mm5, mm6); /* subtract subresults */ + movq_r2m (mm6, *dest); /* store result in dest */ } -static inline void mmx_average_4_U8 (uint8_t * dest, - uint8_t * src1, uint8_t * src2, - uint8_t * src3, uint8_t * src4) +static inline void mmx_average_4_U8 (uint8_t * dest, const uint8_t * src1, + const uint8_t * src2, + const uint8_t * src3, + const uint8_t * src4) { /* *dest = (*src1 + *src2 + *src3 + *src4 + 2)/ 4; */ - movq_m2r (*src1, mm1); // load 8 src1 bytes - movq_r2r (mm1, mm2); // copy 8 src1 bytes + movq_m2r (*src1, mm1); /* load 8 src1 bytes */ + movq_r2r (mm1, mm2); /* copy 8 src1 bytes */ - punpcklbw_r2r (mm0, mm1); // unpack low src1 bytes - punpckhbw_r2r (mm0, mm2); // unpack high src1 bytes + punpcklbw_r2r (mm0, mm1); /* unpack low src1 bytes */ + punpckhbw_r2r (mm0, mm2); /* unpack high src1 bytes */ - movq_m2r (*src2, mm3); // load 8 src2 bytes - movq_r2r (mm3, mm4); // copy 8 src2 bytes + movq_m2r (*src2, mm3); /* load 8 src2 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src2 bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src2 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src2 bytes + punpcklbw_r2r (mm0, mm3); /* unpack low src2 bytes */ + punpckhbw_r2r (mm0, mm4); /* unpack high src2 bytes */ - paddw_r2r (mm3, mm1); // add lows - paddw_r2r (mm4, mm2); // add highs + paddw_r2r (mm3, mm1); /* add lows */ + paddw_r2r (mm4, mm2); /* add highs */ /* now have partials in mm1 and mm2 */ - movq_m2r (*src3, mm3); // load 8 src3 bytes - movq_r2r (mm3, mm4); // copy 8 src3 bytes + movq_m2r (*src3, mm3); /* load 8 src3 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src3 bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src3 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src3 bytes + punpcklbw_r2r (mm0, mm3); /* unpack low src3 bytes */ + punpckhbw_r2r (mm0, mm4); /* unpack high src3 bytes */ - paddw_r2r (mm3, mm1); // add lows - paddw_r2r (mm4, mm2); // add highs + paddw_r2r (mm3, mm1); /* add lows */ + paddw_r2r (mm4, mm2); /* add highs */ - movq_m2r (*src4, mm5); // load 8 src4 bytes - movq_r2r (mm5, mm6); // copy 8 src4 bytes + movq_m2r (*src4, mm5); /* load 8 src4 bytes */ + movq_r2r (mm5, mm6); /* copy 8 src4 bytes */ - punpcklbw_r2r (mm0, mm5); // unpack low src4 bytes - punpckhbw_r2r (mm0, mm6); // unpack high src4 bytes + punpcklbw_r2r (mm0, mm5); /* unpack low src4 bytes */ + punpckhbw_r2r (mm0, mm6); /* unpack high src4 bytes */ - paddw_r2r (mm5, mm1); // add lows - paddw_r2r (mm6, mm2); // add highs + paddw_r2r (mm5, mm1); /* add lows */ + paddw_r2r (mm6, mm2); /* add highs */ /* now have subtotal in mm1 and mm2 */ paddw_m2r (round4, mm1); - psraw_i2r (2, mm1); // /4 + psraw_i2r (2, mm1); /* /4 */ paddw_m2r (round4, mm2); - psraw_i2r (2, mm2); // /4 + psraw_i2r (2, mm2); /* /4 */ - packuswb_r2r (mm2, mm1); // pack (w/ saturation) - movq_r2m (mm1, *dest); // store result in dest + packuswb_r2r (mm2, mm1); /* pack (w/ saturation) */ + movq_r2m (mm1, *dest); /* store result in dest */ } static inline void mmx_interp_average_4_U8 (uint8_t * dest, - uint8_t * src1, uint8_t * src2, - uint8_t * src3, uint8_t * src4) + const uint8_t * src1, + const uint8_t * src2, + const uint8_t * src3, + const uint8_t * src4) { /* *dest = (*dest + (*src1 + *src2 + *src3 + *src4 + 2)/ 4 + 1)/ 2; */ - movq_m2r (*src1, mm1); // load 8 src1 bytes - movq_r2r (mm1, mm2); // copy 8 src1 bytes + movq_m2r (*src1, mm1); /* load 8 src1 bytes */ + movq_r2r (mm1, mm2); /* copy 8 src1 bytes */ - punpcklbw_r2r (mm0, mm1); // unpack low src1 bytes - punpckhbw_r2r (mm0, mm2); // unpack high src1 bytes + punpcklbw_r2r (mm0, mm1); /* unpack low src1 bytes */ + punpckhbw_r2r (mm0, mm2); /* unpack high src1 bytes */ - movq_m2r (*src2, mm3); // load 8 src2 bytes - movq_r2r (mm3, mm4); // copy 8 src2 bytes + movq_m2r (*src2, mm3); /* load 8 src2 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src2 bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src2 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src2 bytes + punpcklbw_r2r (mm0, mm3); /* unpack low src2 bytes */ + punpckhbw_r2r (mm0, mm4); /* unpack high src2 bytes */ - paddw_r2r (mm3, mm1); // add lows - paddw_r2r (mm4, mm2); // add highs + paddw_r2r (mm3, mm1); /* add lows */ + paddw_r2r (mm4, mm2); /* add highs */ /* now have partials in mm1 and mm2 */ - movq_m2r (*src3, mm3); // load 8 src3 bytes - movq_r2r (mm3, mm4); // copy 8 src3 bytes + movq_m2r (*src3, mm3); /* load 8 src3 bytes */ + movq_r2r (mm3, mm4); /* copy 8 src3 bytes */ - punpcklbw_r2r (mm0, mm3); // unpack low src3 bytes - punpckhbw_r2r (mm0, mm4); // unpack high src3 bytes + punpcklbw_r2r (mm0, mm3); /* unpack low src3 bytes */ + punpckhbw_r2r (mm0, mm4); /* unpack high src3 bytes */ - paddw_r2r (mm3, mm1); // add lows - paddw_r2r (mm4, mm2); // add highs + paddw_r2r (mm3, mm1); /* add lows */ + paddw_r2r (mm4, mm2); /* add highs */ - movq_m2r (*src4, mm5); // load 8 src4 bytes - movq_r2r (mm5, mm6); // copy 8 src4 bytes + movq_m2r (*src4, mm5); /* load 8 src4 bytes */ + movq_r2r (mm5, mm6); /* copy 8 src4 bytes */ - punpcklbw_r2r (mm0, mm5); // unpack low src4 bytes - punpckhbw_r2r (mm0, mm6); // unpack high src4 bytes + punpcklbw_r2r (mm0, mm5); /* unpack low src4 bytes */ + punpckhbw_r2r (mm0, mm6); /* unpack high src4 bytes */ - paddw_r2r (mm5, mm1); // add lows - paddw_r2r (mm6, mm2); // add highs + paddw_r2r (mm5, mm1); /* add lows */ + paddw_r2r (mm6, mm2); /* add highs */ paddw_m2r (round4, mm1); - psraw_i2r (2, mm1); // /4 + psraw_i2r (2, mm1); /* /4 */ paddw_m2r (round4, mm2); - psraw_i2r (2, mm2); // /4 + psraw_i2r (2, mm2); /* /4 */ /* now have subtotal/4 in mm1 and mm2 */ - movq_m2r (*dest, mm3); // load 8 dest bytes - movq_r2r (mm3, mm4); // copy 8 dest bytes - - punpcklbw_r2r (mm0, mm3); // unpack low dest bytes - punpckhbw_r2r (mm0, mm4); // unpack high dest bytes - - paddw_r2r (mm3, mm1); // add lows - paddw_r2r (mm4, mm2); // add highs + movq_m2r (*dest, mm3); /* load 8 dest bytes */ + movq_r2r (mm3, mm4); /* copy 8 dest bytes */ - paddw_m2r (round1, mm1); - psraw_i2r (1, mm1); // /2 - paddw_m2r (round1, mm2); - psraw_i2r (1, mm2); // /2 + packuswb_r2r (mm2, mm1); /* pack (w/ saturation) */ + movq_r2r (mm1,mm2); /* copy subresult */ - /* now have end value in mm1 and mm2 */ - - packuswb_r2r (mm2, mm1); // pack (w/ saturation) - movq_r2m (mm1,*dest); // store result in dest + pxor_r2r (mm1, mm3); /* xor srcavg and dest */ + pand_m2r (mask1, mm3); /* mask lower bits */ + psrlq_i2r (1, mm3); /* /2 */ + por_r2r (mm2, mm4); /* or srcavg and dest */ + psubb_r2r (mm3, mm4); /* subtract subresults */ + movq_r2m (mm4, *dest); /* store result in dest */ } /*-----------------------------------------------------------------------*/ -static inline void MC_avg_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_avg_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { mmx_zero_reg (); @@ -269,33 +253,33 @@ static inline void MC_avg_mmx (int width, int height, } while (--height); } -static void MC_avg_16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_mmx (16, height, dest, ref, stride); } -static void MC_avg_8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_put_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_put_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { mmx_zero_reg (); do { - movq_m2r (* ref, mm1); // load 8 ref bytes - movq_r2m (mm1,* dest); // store 8 bytes at curr + movq_m2r (* ref, mm1); /* load 8 ref bytes */ + movq_r2m (mm1,* dest); /* store 8 bytes at curr */ if (width == 16) { - movq_m2r (* (ref+8), mm1); // load 8 ref bytes - movq_r2m (mm1,* (dest+8)); // store 8 bytes at curr + movq_m2r (* (ref+8), mm1); /* load 8 ref bytes */ + movq_r2m (mm1,* (dest+8)); /* store 8 bytes at curr */ } dest += stride; @@ -303,14 +287,14 @@ static inline void MC_put_mmx (int width, int height, } while (--height); } -static void MC_put_16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_mmx (16, height, dest, ref, stride); } -static void MC_put_8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_mmx (8, height, dest, ref, stride); } @@ -318,8 +302,8 @@ static void MC_put_8_mmx (uint8_t * dest, uint8_t * ref, /*-----------------------------------------------------------------------*/ /* Half pixel interpolation in the x direction */ -static inline void MC_avg_x_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_avg_x_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { mmx_zero_reg (); @@ -334,22 +318,22 @@ static inline void MC_avg_x_mmx (int width, int height, } while (--height); } -static void MC_avg_x16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_x_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_x_mmx (16, height, dest, ref, stride); } -static void MC_avg_x8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_x_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_x_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_put_x_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_put_x_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { mmx_zero_reg (); @@ -364,24 +348,24 @@ static inline void MC_put_x_mmx (int width, int height, } while (--height); } -static void MC_put_x16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_x_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_x_mmx (16, height, dest, ref, stride); } -static void MC_put_x8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_x_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_x_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_avg_xy_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_avg_xy_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { - uint8_t * ref_next = ref+stride; + const uint8_t * ref_next = ref + stride; mmx_zero_reg (); @@ -398,24 +382,24 @@ static inline void MC_avg_xy_mmx (int width, int height, } while (--height); } -static void MC_avg_xy16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_xy_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_xy_mmx (16, height, dest, ref, stride); } -static void MC_avg_xy8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_xy_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_xy_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_put_xy_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_put_xy_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { - uint8_t * ref_next = ref+stride; + const uint8_t * ref_next = ref + stride; mmx_zero_reg (); @@ -431,24 +415,24 @@ static inline void MC_put_xy_mmx (int width, int height, } while (--height); } -static void MC_put_xy16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_xy_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_xy_mmx (16, height, dest, ref, stride); } -static void MC_put_xy8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_xy_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_xy_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_avg_y_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_avg_y_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { - uint8_t * ref_next = ref+stride; + const uint8_t * ref_next = ref + stride; mmx_zero_reg (); @@ -464,24 +448,24 @@ static inline void MC_avg_y_mmx (int width, int height, } while (--height); } -static void MC_avg_y16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_y_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_y_mmx (16, height, dest, ref, stride); } -static void MC_avg_y8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_y_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg_y_mmx (8, height, dest, ref, stride); } /*-----------------------------------------------------------------------*/ -static inline void MC_put_y_mmx (int width, int height, - uint8_t * dest, uint8_t * ref, int stride) +static inline void MC_put_y_mmx (const int width, int height, uint8_t * dest, + const uint8_t * ref, const int stride) { - uint8_t * ref_next = ref+stride; + const uint8_t * ref_next = ref + stride; mmx_zero_reg (); @@ -497,20 +481,20 @@ static inline void MC_put_y_mmx (int width, int height, } while (--height); } -static void MC_put_y16_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_y_16_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_y_mmx (16, height, dest, ref, stride); } -static void MC_put_y8_mmx (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_y_8_mmx (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put_y_mmx (8, height, dest, ref, stride); } -MOTION_COMP_EXTERN (mmx) +MPEG2_MC_EXTERN (mmx) @@ -540,8 +524,8 @@ do { \ /* CPU_MMXEXT code */ -static inline void MC_put1_8 (int height, uint8_t * dest, uint8_t * ref, - int stride) +static inline void MC_put1_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride) { do { movq_m2r (*ref, mm0); @@ -551,8 +535,8 @@ static inline void MC_put1_8 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_put1_16 (int height, uint8_t * dest, uint8_t * ref, - int stride) +static inline void MC_put1_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride) { do { movq_m2r (*ref, mm0); @@ -564,8 +548,8 @@ static inline void MC_put1_16 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg1_8 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_avg1_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { do { movq_m2r (*ref, mm0); @@ -576,8 +560,8 @@ static inline void MC_avg1_8 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg1_16 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_avg1_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { do { movq_m2r (*ref, mm0); @@ -591,8 +575,9 @@ static inline void MC_avg1_16 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_put2_8 (int height, uint8_t * dest, uint8_t * ref, - int stride, int offset, int cpu) +static inline void MC_put2_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int offset, + const int cpu) { do { movq_m2r (*ref, mm0); @@ -603,8 +588,9 @@ static inline void MC_put2_8 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_put2_16 (int height, uint8_t * dest, uint8_t * ref, - int stride, int offset, int cpu) +static inline void MC_put2_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int offset, + const int cpu) { do { movq_m2r (*ref, mm0); @@ -618,8 +604,9 @@ static inline void MC_put2_16 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg2_8 (int height, uint8_t * dest, uint8_t * ref, - int stride, int offset, int cpu) +static inline void MC_avg2_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int offset, + const int cpu) { do { movq_m2r (*ref, mm0); @@ -631,8 +618,9 @@ static inline void MC_avg2_8 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg2_16 (int height, uint8_t * dest, uint8_t * ref, - int stride, int offset, int cpu) +static inline void MC_avg2_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int offset, + const int cpu) { do { movq_m2r (*ref, mm0); @@ -650,8 +638,8 @@ static inline void MC_avg2_16 (int height, uint8_t * dest, uint8_t * ref, static mmx_t mask_one = {0x0101010101010101LL}; -static inline void MC_put4_8 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_put4_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { movq_m2r (*ref, mm0); movq_m2r (*(ref+1), mm1); @@ -684,13 +672,13 @@ static inline void MC_put4_8 (int height, uint8_t * dest, uint8_t * ref, movq_r2m (mm0, *dest); dest += stride; - movq_r2r (mm6, mm7); // unroll ! - movq_r2r (mm2, mm0); // unroll ! + movq_r2r (mm6, mm7); /* unroll ! */ + movq_r2r (mm2, mm0); /* unroll ! */ } while (--height); } -static inline void MC_put4_16 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_put4_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { do { movq_m2r (*ref, mm0); @@ -735,8 +723,8 @@ static inline void MC_put4_16 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg4_8 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_avg4_8 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { do { movq_m2r (*ref, mm0); @@ -764,8 +752,8 @@ static inline void MC_avg4_8 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static inline void MC_avg4_16 (int height, uint8_t * dest, uint8_t * ref, - int stride, int cpu) +static inline void MC_avg4_16 (int height, uint8_t * dest, const uint8_t * ref, + const int stride, const int cpu) { do { movq_m2r (*ref, mm0); @@ -814,204 +802,204 @@ static inline void MC_avg4_16 (int height, uint8_t * dest, uint8_t * ref, } while (--height); } -static void MC_avg_16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg1_16 (height, dest, ref, stride, CPU_MMXEXT); } -static void MC_avg_8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg1_8 (height, dest, ref, stride, CPU_MMXEXT); } -static void MC_put_16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put1_16 (height, dest, ref, stride); } -static void MC_put_8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put1_8 (height, dest, ref, stride); } -static void MC_avg_x16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_x_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg2_16 (height, dest, ref, stride, 1, CPU_MMXEXT); } -static void MC_avg_x8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_x_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg2_8 (height, dest, ref, stride, 1, CPU_MMXEXT); } -static void MC_put_x16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_x_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put2_16 (height, dest, ref, stride, 1, CPU_MMXEXT); } -static void MC_put_x8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_x_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put2_8 (height, dest, ref, stride, 1, CPU_MMXEXT); } -static void MC_avg_y16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_y_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg2_16 (height, dest, ref, stride, stride, CPU_MMXEXT); } -static void MC_avg_y8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_y_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg2_8 (height, dest, ref, stride, stride, CPU_MMXEXT); } -static void MC_put_y16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_y_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put2_16 (height, dest, ref, stride, stride, CPU_MMXEXT); } -static void MC_put_y8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_y_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put2_8 (height, dest, ref, stride, stride, CPU_MMXEXT); } -static void MC_avg_xy16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_xy_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg4_16 (height, dest, ref, stride, CPU_MMXEXT); } -static void MC_avg_xy8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_xy_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg4_8 (height, dest, ref, stride, CPU_MMXEXT); } -static void MC_put_xy16_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_xy_16_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put4_16 (height, dest, ref, stride, CPU_MMXEXT); } -static void MC_put_xy8_mmxext (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_xy_8_mmxext (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put4_8 (height, dest, ref, stride, CPU_MMXEXT); } -MOTION_COMP_EXTERN (mmxext) +MPEG2_MC_EXTERN (mmxext) -static void MC_avg_16_3dnow (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_16_3dnow (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg1_16 (height, dest, ref, stride, CPU_3DNOW); } -static void MC_avg_8_3dnow (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_avg_o_8_3dnow (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_avg1_8 (height, dest, ref, stride, CPU_3DNOW); } -static void MC_put_16_3dnow (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_16_3dnow (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put1_16 (height, dest, ref, stride); } -static void MC_put_8_3dnow (uint8_t * dest, uint8_t * ref, - int stride, int height) +static void MC_put_o_8_3dnow (uint8_t * dest, const uint8_t * ref, + int stride, int height) { MC_put1_8 (height, dest, ref, stride); } -static void MC_avg_x16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_x_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg2_16 (height, dest, ref, stride, 1, CPU_3DNOW); } -static void MC_avg_x8_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_x_8_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg2_8 (height, dest, ref, stride, 1, CPU_3DNOW); } -static void MC_put_x16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_put_x_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_put2_16 (height, dest, ref, stride, 1, CPU_3DNOW); } -static void MC_put_x8_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_put_x_8_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_put2_8 (height, dest, ref, stride, 1, CPU_3DNOW); } -static void MC_avg_y16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_y_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg2_16 (height, dest, ref, stride, stride, CPU_3DNOW); } -static void MC_avg_y8_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_y_8_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg2_8 (height, dest, ref, stride, stride, CPU_3DNOW); } -static void MC_put_y16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_put_y_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_put2_16 (height, dest, ref, stride, stride, CPU_3DNOW); } -static void MC_put_y8_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_put_y_8_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_put2_8 (height, dest, ref, stride, stride, CPU_3DNOW); } -static void MC_avg_xy16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_xy_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg4_16 (height, dest, ref, stride, CPU_3DNOW); } -static void MC_avg_xy8_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_avg_xy_8_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_avg4_8 (height, dest, ref, stride, CPU_3DNOW); } -static void MC_put_xy16_3dnow (uint8_t * dest, uint8_t * ref, +static void MC_put_xy_16_3dnow (uint8_t * dest, const uint8_t * ref, int stride, int height) { MC_put4_16 (height, dest, ref, stride, CPU_3DNOW); } -static void MC_put_xy8_3dnow (uint8_t * dest, uint8_t * re |