diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2002-10-29 16:29:16 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2002-10-29 16:29:16 +0000 |
commit | e69ac0f8052424e3ce344365b6be0c95f0e68db6 (patch) | |
tree | 9415d96331dc7ce2e910b69c59a445b957de1497 /src/libffmpeg/libavcodec/alpha | |
parent | 4f15163a94c863e3e0cf8a65f3ad6f88946f7670 (diff) | |
download | xine-lib-e69ac0f8052424e3ce344365b6be0c95f0e68db6.tar.gz xine-lib-e69ac0f8052424e3ce344365b6be0c95f0e68db6.tar.bz2 |
sync to ffmpeg cvs
CVS patchset: 3090
CVS date: 2002/10/29 16:29:16
Diffstat (limited to 'src/libffmpeg/libavcodec/alpha')
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/Makefile.am | 5 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/asm.h | 38 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/dsputil_alpha.c | 6 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/motion_est_alpha.c | 2 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/motion_est_mvi_asm.S | 186 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c | 27 | ||||
-rw-r--r-- | src/libffmpeg/libavcodec/alpha/pixops.h | 135 |
7 files changed, 245 insertions, 154 deletions
diff --git a/src/libffmpeg/libavcodec/alpha/Makefile.am b/src/libffmpeg/libavcodec/alpha/Makefile.am index 84ddab118..8b9553319 100644 --- a/src/libffmpeg/libavcodec/alpha/Makefile.am +++ b/src/libffmpeg/libavcodec/alpha/Makefile.am @@ -1,8 +1,9 @@ EXTRA_DIST = asm.h \ dsputil_alpha.c \ mpegvideo_alpha.c \ - pixops.h \ - motion_est_alpha.c + motion_est_alpha.c \ + motion_est_mvi_asm.S \ + regdef.h all: debug: diff --git a/src/libffmpeg/libavcodec/alpha/asm.h b/src/libffmpeg/libavcodec/alpha/asm.h index 2fdbdf13d..c2983125a 100644 --- a/src/libffmpeg/libavcodec/alpha/asm.h +++ b/src/libffmpeg/libavcodec/alpha/asm.h @@ -22,6 +22,21 @@ #include <inttypes.h> +#if defined __GNUC__ +# define GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GNUC_PREREQ(maj, min) 0 +#endif + +#if GNUC_PREREQ(2,96) +# define likely(x) __builtin_expect((x) != 0, 1) +# define unlikely(x) __builtin_expect((x) != 0, 0) +#else +# define likely(x) (x) +# define unlikely(x) (x) +#endif + #define AMASK_BWX (1 << 0) #define AMASK_FIX (1 << 1) #define AMASK_CIX (1 << 2) @@ -45,6 +60,7 @@ inline static uint64_t WORD_VEC(uint64_t x) #define ldl(p) (*(const int32_t *) (p)) #define stl(l, p) do { *(uint32_t *) (p) = (l); } while (0) #define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0) +#define sextw(x) ((int16_t) (x)) #ifdef __GNUC__ #define ASM_ACCEPT_MVI asm (".arch pca56") @@ -52,10 +68,26 @@ struct unaligned_long { uint64_t l; } __attribute__((packed)); #define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul)) #define uldq(a) (((const struct unaligned_long *) (a))->l) -#if __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 +#if GNUC_PREREQ(3,0) +/* Unfortunately, __builtin_prefetch is slightly buggy on Alpha. The + defines here are kludged so we still get the right + instruction. This needs to be adapted as soon as gcc is fixed. */ +# define prefetch(p) __builtin_prefetch((p), 0, 1) +# define prefetch_en(p) __builtin_prefetch((p), 1, 1) +# define prefetch_m(p) __builtin_prefetch((p), 0, 0) +# define prefetch_men(p) __builtin_prefetch((p), 1, 0) +#else +# define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory") +# define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory") +# define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory") +# define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory") +#endif + +#if GNUC_PREREQ(3,3) #define cmpbge __builtin_alpha_cmpbge /* Avoid warnings. */ #define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b)) +#define extwl(a, b) __builtin_alpha_extwl(a, (uint64_t) (b)) #define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b)) #define zap __builtin_alpha_zap #define zapnot __builtin_alpha_zapnot @@ -78,6 +110,7 @@ struct unaligned_long { uint64_t l; } __attribute__((packed)); #else #define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) #define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) +#define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) #define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) #define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) #define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) @@ -99,7 +132,7 @@ struct unaligned_long { uint64_t l; } __attribute__((packed)); #define unpkbw(a) ({ uint64_t __r; asm ("unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; }) #endif -#elif defined(__DECC) /* Digital/Compaq "ccc" compiler */ +#elif defined(__DECC) /* Digital/Compaq/hp "ccc" compiler */ #include <c_asm.h> #define ASM_ACCEPT_MVI @@ -107,6 +140,7 @@ struct unaligned_long { uint64_t l; } __attribute__((packed)); #define uldq(a) (*(const __unaligned uint64_t *) (a)) #define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b) #define extql(a, b) asm ("extql %a0,%a1,%v0", a, b) +#define extwl(a, b) asm ("extwl %a0,%a1,%v0", a, b) #define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b) #define zap(a, b) asm ("zap %a0,%a1,%v0", a, b) #define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b) diff --git a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c index fef86fe64..371e20269 100644 --- a/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c +++ b/src/libffmpeg/libavcodec/alpha/dsputil_alpha.c @@ -20,8 +20,6 @@ #include "asm.h" #include "../dsputil.h" -void simple_idct_axp(DCTELEM *block); - void put_pixels_axp_asm(uint8_t *block, const uint8_t *pixels, int line_size, int h); void put_pixels_clamped_mvi_asm(const DCTELEM *block, uint8_t *pixels, @@ -34,7 +32,7 @@ void get_pixels_mvi(DCTELEM *restrict block, void diff_pixels_mvi(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride); int pix_abs8x8_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); -int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); +int pix_abs16x16_mvi_asm(uint8_t *pix1, uint8_t *pix2, int line_size); int pix_abs16x16_x2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); int pix_abs16x16_y2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); int pix_abs16x16_xy2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size); @@ -335,7 +333,7 @@ void dsputil_init_alpha(void) get_pixels = get_pixels_mvi; diff_pixels = diff_pixels_mvi; pix_abs8x8 = pix_abs8x8_mvi; - pix_abs16x16 = pix_abs16x16_mvi; + pix_abs16x16 = pix_abs16x16_mvi_asm; pix_abs16x16_x2 = pix_abs16x16_x2_mvi; pix_abs16x16_y2 = pix_abs16x16_y2_mvi; pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi; diff --git a/src/libffmpeg/libavcodec/alpha/motion_est_alpha.c b/src/libffmpeg/libavcodec/alpha/motion_est_alpha.c index b0968d104..804e1d2b6 100644 --- a/src/libffmpeg/libavcodec/alpha/motion_est_alpha.c +++ b/src/libffmpeg/libavcodec/alpha/motion_est_alpha.c @@ -117,6 +117,7 @@ int pix_abs8x8_mvi(uint8_t *pix1, uint8_t *pix2, int line_size) return result; } +#if 0 /* now done in assembly */ int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size) { int result = 0; @@ -157,6 +158,7 @@ int pix_abs16x16_mvi(uint8_t *pix1, uint8_t *pix2, int line_size) return result; } +#endif int pix_abs16x16_x2_mvi(uint8_t *pix1, uint8_t *pix2, int line_size) { diff --git a/src/libffmpeg/libavcodec/alpha/motion_est_mvi_asm.S b/src/libffmpeg/libavcodec/alpha/motion_est_mvi_asm.S new file mode 100644 index 000000000..0042e7e82 --- /dev/null +++ b/src/libffmpeg/libavcodec/alpha/motion_est_mvi_asm.S @@ -0,0 +1,186 @@ +/* + * Alpha optimized DSP utils + * Copyright (c) 2002 Falk Hueffner <falk@debian.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "regdef.h" +#ifdef HAVE_AV_CONFIG_H +#include "config.h" +#endif + +/* Some nicer register names. */ +#define ta t10 +#define tb t11 +#define tc t12 +#define td AT +/* Danger: these overlap with the argument list and the return value */ +#define te a5 +#define tf a4 +#define tg a3 +#define th v0 + + .set noat + .set noreorder + .arch pca56 + .text + +/***************************************************************************** + * int pix_abs16x16_mvi_asm(uint8_t *pix1, 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 + * into account. + * + * It is important to keep the loading and first use of a register as + * far apart as possible, because if a register is accessed before it + * has been fetched from memory, the CPU will stall. + */ + .align 4 + .globl pix_abs16x16_mvi_asm + .ent pix_abs16x16_mvi_asm +pix_abs16x16_mvi_asm: + .frame sp, 0, ra, 0 + .prologue 0 + +#ifdef HAVE_GPROF + lda AT, _mcount + jsr AT, (AT), _mcount +#endif + + and a1, 7, t0 + clr v0 + lda a3, 16 + beq t0, $aligned + .align 4 +$unaligned: + /* Registers: + line 0: + t0: left_u -> left lo -> left + t1: mid + t2: right_u -> right hi -> right + t3: ref left + t4: ref right + line 1: + t5: left_u -> left lo -> left + t6: mid + t7: right_u -> right hi -> right + t8: ref left + t9: ref right + temp: + ta: left hi + tb: right lo + tc: error left + td: error right */ + + /* load line 0 */ + ldq_u t0, 0(a1) # left_u + ldq_u t1, 8(a1) # mid + ldq_u t2, 16(a1) # right_u + ldq t3, 0(a0) # ref left + ldq t4, 8(a0) # ref right + addq a0, a2, a0 # pix1 + addq a1, a2, a1 # pix2 + /* load line 1 */ + ldq_u t5, 0(a1) # left_u + ldq_u t6, 8(a1) # mid + ldq_u t7, 16(a1) # right_u + ldq t8, 0(a0) # ref left + ldq t9, 8(a0) # ref right + addq a0, a2, a0 # pix1 + addq a1, a2, a1 # pix2 + /* calc line 0 */ + extql t0, a1, t0 # left lo + extqh t1, a1, ta # left hi + extql t1, a1, tb # right lo + or t0, ta, t0 # left + extqh t2, a1, t2 # right hi + perr t3, t0, tc # error left + or t2, tb, t2 # right + perr t4, t2, td # error right + addq v0, tc, v0 # add error left + addq v0, td, v0 # add error left + /* calc line 1 */ + extql t5, a1, t5 # left lo + extqh t6, a1, ta # left hi + extql t6, a1, tb # right lo + or t5, ta, t5 # left + extqh t7, a1, t7 # right hi + perr t8, t5, tc # error left + or t7, tb, t7 # right + perr t9, t7, td # error right + addq v0, tc, v0 # add error left + addq v0, td, v0 # add error left + /* loop */ + subq a3, 2, a3 # h -= 2 + bne a3, $unaligned + ret + + .align 4 +$aligned: + /* load line 0 */ + ldq t0, 0(a1) # left + ldq t1, 8(a1) # right + addq a1, a2, a1 # pix2 + ldq t2, 0(a0) # ref left + ldq t3, 8(a0) # ref right + addq a0, a2, a0 # pix1 + /* load line 1 */ + ldq t4, 0(a1) # left + ldq t5, 8(a1) # right + addq a1, a2, a1 # pix2 + ldq t6, 0(a0) # ref left + ldq t7, 8(a0) # ref right + addq a0, a2, a0 # pix1 + /* load line 2 */ + ldq t8, 0(a1) # left + ldq t9, 8(a1) # right + addq a1, a2, a1 # pix2 + ldq ta, 0(a0) # ref left + ldq tb, 8(a0) # ref right + addq a0, a2, a0 # pix1 + /* load line 3 */ + ldq tc, 0(a1) # left + ldq td, 8(a1) # right + addq a1, a2, a1 # pix2 + ldq te, 0(a0) # ref left + ldq tf, 8(a0) # ref right + /* calc line 0 */ + perr t0, t2, t0 # error left + addq a0, a2, a0 # pix1 + perr t1, t3, t1 # error right + addq v0, t0, v0 # add error left + /* calc line 1 */ + perr t4, t6, t0 # error left + addq v0, t1, v0 # add error right + perr t5, t7, t1 # error right + addq v0, t0, v0 # add error left + /* calc line 2 */ + perr t8, ta, t0 # error left + addq v0, t1, v0 # add error right + perr t9, tb, t1 # error right + addq v0, t0, v0 # add error left + /* calc line 3 */ + perr tc, te, t0 # error left + addq v0, t1, v0 # add error right + perr td, tf, t1 # error right + addq v0, t0, v0 # add error left + addq v0, t1, v0 # add error right + /* loop */ + subq a3, 4, a3 # h -= 4 + bne a3, $aligned + ret + .end pix_abs16x16_mvi_asm diff --git a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c index 0be327079..350b53f62 100644 --- a/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c +++ b/src/libffmpeg/libavcodec/alpha/mpegvideo_alpha.c @@ -21,8 +21,9 @@ #include "../dsputil.h" #include "../mpegvideo.h" -extern UINT8 zigzag_end[64]; - +extern void simple_idct_put_axp(uint8_t *dest, int line_size, DCTELEM *block); +extern void simple_idct_add_axp(uint8_t *dest, int line_size, DCTELEM *block); + static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block, int n, int qscale) { @@ -32,24 +33,26 @@ static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block, DCTELEM *orig_block = block; DCTELEM block0; + qadd = WORD_VEC((qscale - 1) | 1); + qmul = qscale << 1; + /* This mask kills spill from negative subwords to the next subword. */ + correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */ + if (s->mb_intra) { if (!s->h263_aic) { if (n < 4) block0 = block[0] * s->y_dc_scale; else block0 = block[0] * s->c_dc_scale; - } - n_coeffs = 64; // does not always use zigzag table + } else { + qadd = 0; + } + n_coeffs = 63; // does not always use zigzag table } else { - n_coeffs = zigzag_end[s->block_last_index[n]]; + n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]]; } - qmul = qscale << 1; - qadd = WORD_VEC((qscale - 1) | 1); - /* This mask kills spill from negative subwords to the next subword. */ - correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */ - - for(i = 0; i < n_coeffs; block += 4, i += 4) { + for(i = 0; i <= n_coeffs; block += 4, i += 4) { uint64_t levels, negmask, zeros, add; levels = ldq(block); @@ -94,4 +97,6 @@ static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block, void MPV_common_init_axp(MpegEncContext *s) { s->dct_unquantize_h263 = dct_unquantize_h263_axp; + s->idct_put = simple_idct_put_axp; + s->idct_add = simple_idct_add_axp; } diff --git a/src/libffmpeg/libavcodec/alpha/pixops.h b/src/libffmpeg/libavcodec/alpha/pixops.h deleted file mode 100644 index 118d7ae23..000000000 --- a/src/libffmpeg/libavcodec/alpha/pixops.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Alpha optimized DSP utils - * Copyright (c) 2002 Falk Hueffner <falk@debian.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* This file is intended to be #included with proper definitions of - * PIXOPNAME, BTYPE, AVG2, AVG4 and STORE. */ - -static void PIXOPNAME(_pixels_axp)(BTYPE *block, const UINT8 *pixels, - int line_size, int h) -{ - if ((size_t) pixels & 0x7) { - do { - STORE(uldq(pixels), block); - pixels += line_size; - block += line_size; - } while (--h); - } else { - do { - STORE(ldq(pixels), block); - pixels += line_size; - block += line_size; - } while (--h); - } -} - -static void PIXOPNAME(_pixels_x2_axp)(BTYPE *block, const UINT8 *pixels, - int line_size, int h) -{ - if ((size_t) pixels & 0x7) { - do { - UINT64 pix1, pix2; - - pix1 = uldq(pixels); - pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56); - STORE(AVG2(pix1, pix2), block); - pixels += line_size; - block += line_size; - } while (--h); - } else { - do { - UINT64 pix1, pix2; - - pix1 = ldq(pixels); - pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56); - STORE(AVG2(pix1, pix2), block); - pixels += line_size; - block += line_size; - } while (--h); - } -} - -static void PIXOPNAME(_pixels_y2_axp)(BTYPE *block, const UINT8 *pixels, - int line_size, int h) -{ - if ((size_t) pixels & 0x7) { - UINT64 pix = uldq(pixels); - do { - UINT64 next_pix; - - pixels += line_size; - next_pix = uldq(pixels); - STORE(AVG2(pix, next_pix), block); - block += line_size; - pix = next_pix; - } while (--h); - } else { - UINT64 pix = ldq(pixels); - do { - UINT64 next_pix; - - pixels += line_size; - next_pix = ldq(pixels); - STORE(AVG2(pix, next_pix), block); - block += line_size; - pix = next_pix; - } while (--h); - } -} - -/* This could be further sped up by recycling AVG4 intermediate - results from the previous loop pass. */ -static void PIXOPNAME(_pixels_xy2_axp)(BTYPE *block, const UINT8 *pixels, - int line_size, int h) -{ - if ((size_t) pixels & 0x7) { - UINT64 pix1 = uldq(pixels); - UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56); - - do { - UINT64 next_pix1, next_pix2; - - pixels += line_size; - next_pix1 = uldq(pixels); - next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56); - - STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block); - - block += line_size; - pix1 = next_pix1; - pix2 = next_pix2; - } while (--h); - } else { - UINT64 pix1 = ldq(pixels); - UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56); - - do { - UINT64 next_pix1, next_pix2; - - pixels += line_size; - next_pix1 = ldq(pixels); - next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56); - - STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block); - - block += line_size; - pix1 = next_pix1; - pix2 = next_pix2; - } while (--h); - } -} |