Signed-off-by: James Almer <jamr...@gmail.com> --- Untested like previous Alpha patches.
libavcodec/alpha/Makefile | 1 + libavcodec/alpha/dsputil_alpha.c | 5 --- libavcodec/alpha/dsputil_alpha.h | 4 -- libavcodec/alpha/motion_est_alpha.c | 45 -------------------- libavcodec/alpha/pixblockdsp_alpha.c | 80 ++++++++++++++++++++++++++++++++++++ libavcodec/pixblockdsp.c | 2 + libavcodec/pixblockdsp.h | 2 + 7 files changed, 85 insertions(+), 54 deletions(-) create mode 100644 libavcodec/alpha/pixblockdsp_alpha.c diff --git a/libavcodec/alpha/Makefile b/libavcodec/alpha/Makefile index 34e5275..42cabfe 100644 --- a/libavcodec/alpha/Makefile +++ b/libavcodec/alpha/Makefile @@ -8,3 +8,4 @@ OBJS-$(CONFIG_IDCTDSP) += alpha/idctdsp_alpha.o \ alpha/idctdsp_alpha_asm.o \ alpha/simple_idct_alpha.o OBJS-$(CONFIG_MPEGVIDEO) += alpha/mpegvideo_alpha.o +OBJS-$(CONFIG_PIXBLOCKDSP) += alpha/pixblockdsp_alpha.o diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c index 06a1a6d..d99a74b 100644 --- a/libavcodec/alpha/dsputil_alpha.c +++ b/libavcodec/alpha/dsputil_alpha.c @@ -98,13 +98,8 @@ void add_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels, av_cold void ff_dsputil_init_alpha(DSPContext *c, AVCodecContext *avctx) { - const int high_bit_depth = avctx->bits_per_raw_sample > 8; - /* amask clears all bits that correspond to present features. */ if (amask(AMASK_MVI) == 0) { - if (!high_bit_depth) - c->get_pixels = get_pixels_mvi; - c->diff_pixels = diff_pixels_mvi; c->sad[0] = pix_abs16x16_mvi_asm; c->sad[1] = pix_abs8x8_mvi; c->pix_abs[0][0] = pix_abs16x16_mvi_asm; diff --git a/libavcodec/alpha/dsputil_alpha.h b/libavcodec/alpha/dsputil_alpha.h index bc29469..a48765f 100644 --- a/libavcodec/alpha/dsputil_alpha.h +++ b/libavcodec/alpha/dsputil_alpha.h @@ -22,10 +22,6 @@ #include <stddef.h> #include <stdint.h> -void get_pixels_mvi(int16_t *restrict block, - const uint8_t *restrict pixels, int line_size); -void diff_pixels_mvi(int16_t *block, const uint8_t *s1, const uint8_t *s2, - int stride); int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); int pix_abs16x16_mvi_asm(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h); diff --git a/libavcodec/alpha/motion_est_alpha.c b/libavcodec/alpha/motion_est_alpha.c index a7c33e4..246b4a7 100644 --- a/libavcodec/alpha/motion_est_alpha.c +++ b/libavcodec/alpha/motion_est_alpha.c @@ -22,51 +22,6 @@ #include "dsputil_alpha.h" #include "asm.h" -void get_pixels_mvi(int16_t *restrict block, - const uint8_t *restrict pixels, int line_size) -{ - int h = 8; - - do { - uint64_t p; - - p = ldq(pixels); - stq(unpkbw(p), block); - stq(unpkbw(p >> 32), block + 4); - - pixels += line_size; - block += 8; - } while (--h); -} - -void diff_pixels_mvi(int16_t *block, const uint8_t *s1, const uint8_t *s2, - int stride) { - int h = 8; - uint64_t mask = 0x4040; - - mask |= mask << 16; - mask |= mask << 32; - do { - uint64_t x, y, c, d, a; - uint64_t signs; - - x = ldq(s1); - y = ldq(s2); - c = cmpbge(x, y); - d = x - y; - a = zap(mask, c); /* We use 0x4040404040404040 here... */ - d += 4 * a; /* ...so we can use s4addq here. */ - signs = zap(-1, c); - - stq(unpkbw(d) | (unpkbw(signs) << 8), block); - stq(unpkbw(d >> 32) | (unpkbw(signs >> 32) << 8), block + 4); - - s1 += stride; - s2 += stride; - block += 8; - } while (--h); -} - static inline uint64_t avg2(uint64_t a, uint64_t b) { return (a | b) - (((a ^ b) & BYTE_VEC(0xfe)) >> 1); diff --git a/libavcodec/alpha/pixblockdsp_alpha.c b/libavcodec/alpha/pixblockdsp_alpha.c new file mode 100644 index 0000000..69b1be5 --- /dev/null +++ b/libavcodec/alpha/pixblockdsp_alpha.c @@ -0,0 +1,80 @@ +/* + * SIMD-optimized pixel operations + * + * This file is part of FFmpeg. + * + * FFmpeg 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.1 of the License, or (at your option) any later version. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/attributes.h" +#include "libavcodec/dsputil.h" +#include "asm.h" + +static void get_pixels_mvi(int16_t *restrict block, + const uint8_t *restrict pixels, int line_size) +{ + int h = 8; + + do { + uint64_t p; + + p = ldq(pixels); + stq(unpkbw(p), block); + stq(unpkbw(p >> 32), block + 4); + + pixels += line_size; + block += 8; + } while (--h); +} + +static void diff_pixels_mvi(int16_t *block, const uint8_t *s1, const uint8_t *s2, + int stride) { + int h = 8; + uint64_t mask = 0x4040; + + mask |= mask << 16; + mask |= mask << 32; + do { + uint64_t x, y, c, d, a; + uint64_t signs; + + x = ldq(s1); + y = ldq(s2); + c = cmpbge(x, y); + d = x - y; + a = zap(mask, c); /* We use 0x4040404040404040 here... */ + d += 4 * a; /* ...so we can use s4addq here. */ + signs = zap(-1, c); + + stq(unpkbw(d) | (unpkbw(signs) << 8), block); + stq(unpkbw(d >> 32) | (unpkbw(signs >> 32) << 8), block + 4); + + s1 += stride; + s2 += stride; + block += 8; + } while (--h); +} + +av_cold void ff_pixblockdsp_init_alpha(PixblockDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ + int cpu_flags = av_get_cpu_flags(); + + if (amask(AMASK_MVI) == 0) { + if (!high_bit_depth) + c->get_pixels = get_pixels_mvi; + c->diff_pixels = diff_pixels_mvi; + } +} diff --git a/libavcodec/pixblockdsp.c b/libavcodec/pixblockdsp.c index a69948e..ebde68b 100644 --- a/libavcodec/pixblockdsp.c +++ b/libavcodec/pixblockdsp.c @@ -71,6 +71,8 @@ av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) break; } + if (ARCH_ALPHA) + ff_pixblockdsp_init_alpha(c, avctx, high_bit_depth); if (ARCH_ARM) ff_pixblockdsp_init_arm(c, avctx, high_bit_depth); if (ARCH_PPC) diff --git a/libavcodec/pixblockdsp.h b/libavcodec/pixblockdsp.h index a724ffb..2f94f8b 100644 --- a/libavcodec/pixblockdsp.h +++ b/libavcodec/pixblockdsp.h @@ -34,6 +34,8 @@ typedef struct PixblockDSPContext { } PixblockDSPContext; void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx); +void ff_pixblockdsp_init_alpha(PixblockDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth); void ff_pixblockdsp_init_arm(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth); void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx, -- 1.8.5.5 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel