summaryrefslogtreecommitdiff
path: root/libavcodec/x86
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2014-02-03 11:13:59 -0800
committerDiego Biurrun <diego@biurrun.de>2014-07-06 14:48:50 -0700
commit3c650efb81aaa3b395ba4606ee68a47ee4efb57b (patch)
tree1f72694cf002091051d5f13bf25ec212dbbc5a01 /libavcodec/x86
parentc166148409fe8f0dbccef2fe684286a40ba1e37d (diff)
dsputil: Move draw_edges() to mpegvideoencdsp
Diffstat (limited to 'libavcodec/x86')
-rw-r--r--libavcodec/x86/Makefile1
-rw-r--r--libavcodec/x86/dsputil_init.c15
-rw-r--r--libavcodec/x86/dsputil_mmx.c128
-rw-r--r--libavcodec/x86/dsputil_x86.h3
-rw-r--r--libavcodec/x86/mpegvideoencdsp_init.c99
5 files changed, 99 insertions, 147 deletions
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 701aad7916..58b27b5d5b 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -51,7 +51,6 @@ OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o
OBJS-$(CONFIG_VP9_DECODER) += x86/vp9dsp_init.o
MMX-OBJS-$(CONFIG_AUDIODSP) += x86/audiodsp_mmx.o
-MMX-OBJS-$(CONFIG_DSPUTIL) += x86/dsputil_mmx.o
MMX-OBJS-$(CONFIG_ENCODERS) += x86/fdct.o
MMX-OBJS-$(CONFIG_HPELDSP) += x86/fpel_mmx.o \
x86/hpeldsp_mmx.o
diff --git a/libavcodec/x86/dsputil_init.c b/libavcodec/x86/dsputil_init.c
index adc7aa95d6..137f9258ad 100644
--- a/libavcodec/x86/dsputil_init.c
+++ b/libavcodec/x86/dsputil_init.c
@@ -24,24 +24,9 @@
#include "libavcodec/dsputil.h"
#include "dsputil_x86.h"
-static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
- int cpu_flags, unsigned high_bit_depth)
-{
-#if HAVE_MMX_INLINE
- if (!high_bit_depth) {
- c->draw_edges = ff_draw_edges_mmx;
- }
-#endif /* HAVE_MMX_INLINE */
-}
-
av_cold void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth)
{
- int cpu_flags = av_get_cpu_flags();
-
- if (X86_MMX(cpu_flags))
- dsputil_init_mmx(c, avctx, cpu_flags, high_bit_depth);
-
if (CONFIG_ENCODERS)
ff_dsputilenc_init_mmx(c, avctx, high_bit_depth);
}
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
deleted file mode 100644
index d205a48ea4..0000000000
--- a/libavcodec/x86/dsputil_mmx.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * MMX optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
- *
- * This file is part of Libav.
- *
- * Libav 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.
- *
- * Libav 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 Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
-#include "dsputil_x86.h"
-#include "inline_asm.h"
-
-#if HAVE_INLINE_ASM
-
-/* Draw the edges of width 'w' of an image of size width, height
- * this MMX version can only handle w == 8 || w == 16. */
-void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
- int w, int h, int sides)
-{
- uint8_t *ptr, *last_line;
- int i;
-
- last_line = buf + (height - 1) * wrap;
- /* left and right */
- ptr = buf;
- if (w == 8) {
- __asm__ volatile (
- "1: \n\t"
- "movd (%0), %%mm0 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t"
- "punpckldq %%mm0, %%mm0 \n\t"
- "movq %%mm0, -8(%0) \n\t"
- "movq -8(%0, %2), %%mm1 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpckhwd %%mm1, %%mm1 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movq %%mm1, (%0, %2) \n\t"
- "add %1, %0 \n\t"
- "cmp %3, %0 \n\t"
- "jb 1b \n\t"
- : "+r" (ptr)
- : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
- "r" (ptr + wrap * height));
- } else {
- __asm__ volatile (
- "1: \n\t"
- "movd (%0), %%mm0 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpcklwd %%mm0, %%mm0 \n\t"
- "punpckldq %%mm0, %%mm0 \n\t"
- "movq %%mm0, -8(%0) \n\t"
- "movq %%mm0, -16(%0) \n\t"
- "movq -8(%0, %2), %%mm1 \n\t"
- "punpckhbw %%mm1, %%mm1 \n\t"
- "punpckhwd %%mm1, %%mm1 \n\t"
- "punpckhdq %%mm1, %%mm1 \n\t"
- "movq %%mm1, (%0, %2) \n\t"
- "movq %%mm1, 8(%0, %2) \n\t"
- "add %1, %0 \n\t"
- "cmp %3, %0 \n\t"
- "jb 1b \n\t"
- : "+r" (ptr)
- : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
- "r" (ptr + wrap * height));
- }
-
- /* top and bottom (and hopefully also the corners) */
- if (sides & EDGE_TOP) {
- for (i = 0; i < h; i += 4) {
- ptr = buf - (i + 1) * wrap - w;
- __asm__ volatile (
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq %%mm0, (%0) \n\t"
- "movq %%mm0, (%0, %2) \n\t"
- "movq %%mm0, (%0, %2, 2) \n\t"
- "movq %%mm0, (%0, %3) \n\t"
- "add $8, %0 \n\t"
- "cmp %4, %0 \n\t"
- "jb 1b \n\t"
- : "+r" (ptr)
- : "r" ((x86_reg) buf - (x86_reg) ptr - w),
- "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3),
- "r" (ptr + width + 2 * w));
- }
- }
-
- if (sides & EDGE_BOTTOM) {
- for (i = 0; i < h; i += 4) {
- ptr = last_line + (i + 1) * wrap - w;
- __asm__ volatile (
- "1: \n\t"
- "movq (%1, %0), %%mm0 \n\t"
- "movq %%mm0, (%0) \n\t"
- "movq %%mm0, (%0, %2) \n\t"
- "movq %%mm0, (%0, %2, 2) \n\t"
- "movq %%mm0, (%0, %3) \n\t"
- "add $8, %0 \n\t"
- "cmp %4, %0 \n\t"
- "jb 1b \n\t"
- : "+r" (ptr)
- : "r" ((x86_reg) last_line - (x86_reg) ptr - w),
- "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3),
- "r" (ptr + width + 2 * w));
- }
- }
-}
-
-#endif /* HAVE_INLINE_ASM */
diff --git a/libavcodec/x86/dsputil_x86.h b/libavcodec/x86/dsputil_x86.h
index 7e1e8af051..b6bddf2228 100644
--- a/libavcodec/x86/dsputil_x86.h
+++ b/libavcodec/x86/dsputil_x86.h
@@ -31,7 +31,4 @@ void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth);
void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx);
-void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
- int w, int h, int sides);
-
#endif /* AVCODEC_X86_DSPUTIL_X86_H */
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index 4ef2f34961..7732e7307f 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -93,6 +93,101 @@ int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
#undef PHADDD
#endif /* HAVE_SSSE3_INLINE */
+/* Draw the edges of width 'w' of an image of size width, height
+ * this MMX version can only handle w == 8 || w == 16. */
+static void draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
+ int w, int h, int sides)
+{
+ uint8_t *ptr, *last_line;
+ int i;
+
+ last_line = buf + (height - 1) * wrap;
+ /* left and right */
+ ptr = buf;
+ if (w == 8) {
+ __asm__ volatile (
+ "1: \n\t"
+ "movd (%0), %%mm0 \n\t"
+ "punpcklbw %%mm0, %%mm0 \n\t"
+ "punpcklwd %%mm0, %%mm0 \n\t"
+ "punpckldq %%mm0, %%mm0 \n\t"
+ "movq %%mm0, -8(%0) \n\t"
+ "movq -8(%0, %2), %%mm1 \n\t"
+ "punpckhbw %%mm1, %%mm1 \n\t"
+ "punpckhwd %%mm1, %%mm1 \n\t"
+ "punpckhdq %%mm1, %%mm1 \n\t"
+ "movq %%mm1, (%0, %2) \n\t"
+ "add %1, %0 \n\t"
+ "cmp %3, %0 \n\t"
+ "jb 1b \n\t"
+ : "+r" (ptr)
+ : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+ "r" (ptr + wrap * height));
+ } else {
+ __asm__ volatile (
+ "1: \n\t"
+ "movd (%0), %%mm0 \n\t"
+ "punpcklbw %%mm0, %%mm0 \n\t"
+ "punpcklwd %%mm0, %%mm0 \n\t"
+ "punpckldq %%mm0, %%mm0 \n\t"
+ "movq %%mm0, -8(%0) \n\t"
+ "movq %%mm0, -16(%0) \n\t"
+ "movq -8(%0, %2), %%mm1 \n\t"
+ "punpckhbw %%mm1, %%mm1 \n\t"
+ "punpckhwd %%mm1, %%mm1 \n\t"
+ "punpckhdq %%mm1, %%mm1 \n\t"
+ "movq %%mm1, (%0, %2) \n\t"
+ "movq %%mm1, 8(%0, %2) \n\t"
+ "add %1, %0 \n\t"
+ "cmp %3, %0 \n\t"
+ "jb 1b \n\t"
+ : "+r" (ptr)
+ : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+ "r" (ptr + wrap * height));
+ }
+
+ /* top and bottom (and hopefully also the corners) */
+ if (sides & EDGE_TOP) {
+ for (i = 0; i < h; i += 4) {
+ ptr = buf - (i + 1) * wrap - w;
+ __asm__ volatile (
+ "1: \n\t"
+ "movq (%1, %0), %%mm0 \n\t"
+ "movq %%mm0, (%0) \n\t"
+ "movq %%mm0, (%0, %2) \n\t"
+ "movq %%mm0, (%0, %2, 2) \n\t"
+ "movq %%mm0, (%0, %3) \n\t"
+ "add $8, %0 \n\t"
+ "cmp %4, %0 \n\t"
+ "jb 1b \n\t"
+ : "+r" (ptr)
+ : "r" ((x86_reg) buf - (x86_reg) ptr - w),
+ "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3),
+ "r" (ptr + width + 2 * w));
+ }
+ }
+
+ if (sides & EDGE_BOTTOM) {
+ for (i = 0; i < h; i += 4) {
+ ptr = last_line + (i + 1) * wrap - w;
+ __asm__ volatile (
+ "1: \n\t"
+ "movq (%1, %0), %%mm0 \n\t"
+ "movq %%mm0, (%0) \n\t"
+ "movq %%mm0, (%0, %2) \n\t"
+ "movq %%mm0, (%0, %2, 2) \n\t"
+ "movq %%mm0, (%0, %3) \n\t"
+ "add $8, %0 \n\t"
+ "cmp %4, %0 \n\t"
+ "jb 1b \n\t"
+ : "+r" (ptr)
+ : "r" ((x86_reg) last_line - (x86_reg) ptr - w),
+ "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3),
+ "r" (ptr + width + 2 * w));
+ }
+ }
+}
+
#endif /* HAVE_INLINE_ASM */
av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
@@ -112,6 +207,10 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
c->try_8x8basis = try_8x8basis_mmx;
}
c->add_8x8basis = add_8x8basis_mmx;
+
+ if (avctx->bits_per_raw_sample <= 8) {
+ c->draw_edges = draw_edges_mmx;
+ }
}
if (INLINE_AMD3DNOW(cpu_flags)) {