summaryrefslogtreecommitdiff
path: root/libavcodec/x86
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-12-30 19:56:07 +0100
committerDiego Biurrun <diego@biurrun.de>2014-07-06 14:26:53 -0700
commitc166148409fe8f0dbccef2fe684286a40ba1e37d (patch)
tree64db33e2555b5e96635f684c2a6e3959bf0d7de7 /libavcodec/x86
parent8d686ca59db14900ad5c12b547fb8a7afc8b0b94 (diff)
dsputil: Move pix_sum, pix_norm1, shrink function pointers to mpegvideoenc
Diffstat (limited to 'libavcodec/x86')
-rw-r--r--libavcodec/x86/Makefile1
-rw-r--r--libavcodec/x86/dsputilenc.asm69
-rw-r--r--libavcodec/x86/dsputilenc_mmx.c4
-rw-r--r--libavcodec/x86/mpegvideoencdsp.asm95
-rw-r--r--libavcodec/x86/mpegvideoencdsp_init.c11
5 files changed, 106 insertions, 74 deletions
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index bfc13737d1..701aad7916 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -92,6 +92,7 @@ YASM-OBJS-$(CONFIG_HPELDSP) += x86/fpel.o \
x86/hpeldsp.o
YASM-OBJS-$(CONFIG_HUFFYUVDSP) += x86/huffyuvdsp.o
YASM-OBJS-$(CONFIG_MPEGAUDIODSP) += x86/imdct36.o
+YASM-OBJS-$(CONFIG_MPEGVIDEOENC) += x86/mpegvideoencdsp.o
YASM-OBJS-$(CONFIG_QPELDSP) += x86/qpeldsp.o \
x86/fpel.o \
x86/qpel.o
diff --git a/libavcodec/x86/dsputilenc.asm b/libavcodec/x86/dsputilenc.asm
index f676ba63fd..d996962eac 100644
--- a/libavcodec/x86/dsputilenc.asm
+++ b/libavcodec/x86/dsputilenc.asm
@@ -418,72 +418,3 @@ cglobal diff_pixels, 4,5
add r4, 16
jne .loop
REP_RET
-
-INIT_MMX mmx
-; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
-cglobal pix_sum16, 2, 3
- movsxdifnidn r1, r1d
- mov r2, r1
- neg r2
- shl r2, 4
- sub r0, r2
- pxor m7, m7
- pxor m6, m6
-.loop:
- mova m0, [r0+r2+0]
- mova m1, [r0+r2+0]
- mova m2, [r0+r2+8]
- mova m3, [r0+r2+8]
- punpcklbw m0, m7
- punpckhbw m1, m7
- punpcklbw m2, m7
- punpckhbw m3, m7
- paddw m1, m0
- paddw m3, m2
- paddw m3, m1
- paddw m6, m3
- add r2, r1
- js .loop
- mova m5, m6
- psrlq m6, 32
- paddw m6, m5
- mova m5, m6
- psrlq m6, 16
- paddw m6, m5
- movd eax, m6
- and eax, 0xffff
- RET
-
-INIT_MMX mmx
-; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
-cglobal pix_norm1, 2, 4
- movsxdifnidn r1, r1d
- mov r2, 16
- pxor m0, m0
- pxor m7, m7
-.loop:
- mova m2, [r0+0]
- mova m3, [r0+8]
- mova m1, m2
- punpckhbw m1, m0
- punpcklbw m2, m0
- mova m4, m3
- punpckhbw m3, m0
- punpcklbw m4, m0
- pmaddwd m1, m1
- pmaddwd m2, m2
- pmaddwd m3, m3
- pmaddwd m4, m4
- paddd m2, m1
- paddd m4, m3
- paddd m7, m2
- add r0, r1
- paddd m7, m4
- dec r2
- jne .loop
- mova m1, m7
- psrlq m7, 32
- paddd m1, m7
- movd eax, m1
- RET
-
diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c
index 7af091365f..563543ee7d 100644
--- a/libavcodec/x86/dsputilenc_mmx.c
+++ b/libavcodec/x86/dsputilenc_mmx.c
@@ -35,8 +35,6 @@ void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size);
void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size);
void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
int stride);
-int ff_pix_sum16_mmx(uint8_t *pix, int line_size);
-int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
#if HAVE_INLINE_ASM
@@ -831,8 +829,6 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx,
if (!high_bit_depth)
c->get_pixels = ff_get_pixels_mmx;
c->diff_pixels = ff_diff_pixels_mmx;
- c->pix_sum = ff_pix_sum16_mmx;
- c->pix_norm1 = ff_pix_norm1_mmx;
}
if (EXTERNAL_SSE2(cpu_flags))
diff --git a/libavcodec/x86/mpegvideoencdsp.asm b/libavcodec/x86/mpegvideoencdsp.asm
new file mode 100644
index 0000000000..9326ee776d
--- /dev/null
+++ b/libavcodec/x86/mpegvideoencdsp.asm
@@ -0,0 +1,95 @@
+;*****************************************************************************
+;* SIMD-optimized MPEG encoding functions
+;*****************************************************************************
+;* Copyright (c) 2000, 2001 Fabrice Bellard
+;* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
+;*
+;* 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 "libavutil/x86/x86util.asm"
+
+SECTION .text
+
+INIT_MMX mmx
+; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
+cglobal pix_sum16, 2, 3
+ movsxdifnidn r1, r1d
+ mov r2, r1
+ neg r2
+ shl r2, 4
+ sub r0, r2
+ pxor m7, m7
+ pxor m6, m6
+.loop:
+ mova m0, [r0+r2+0]
+ mova m1, [r0+r2+0]
+ mova m2, [r0+r2+8]
+ mova m3, [r0+r2+8]
+ punpcklbw m0, m7
+ punpckhbw m1, m7
+ punpcklbw m2, m7
+ punpckhbw m3, m7
+ paddw m1, m0
+ paddw m3, m2
+ paddw m3, m1
+ paddw m6, m3
+ add r2, r1
+ js .loop
+ mova m5, m6
+ psrlq m6, 32
+ paddw m6, m5
+ mova m5, m6
+ psrlq m6, 16
+ paddw m6, m5
+ movd eax, m6
+ and eax, 0xffff
+ RET
+
+INIT_MMX mmx
+; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
+cglobal pix_norm1, 2, 4
+ movsxdifnidn r1, r1d
+ mov r2, 16
+ pxor m0, m0
+ pxor m7, m7
+.loop:
+ mova m2, [r0+0]
+ mova m3, [r0+8]
+ mova m1, m2
+ punpckhbw m1, m0
+ punpcklbw m2, m0
+ mova m4, m3
+ punpckhbw m3, m0
+ punpcklbw m4, m0
+ pmaddwd m1, m1
+ pmaddwd m2, m2
+ pmaddwd m3, m3
+ pmaddwd m4, m4
+ paddd m2, m1
+ paddd m4, m3
+ paddd m7, m2
+ add r0, r1
+ paddd m7, m4
+ dec r2
+ jne .loop
+ mova m1, m7
+ psrlq m7, 32
+ paddd m1, m7
+ movd eax, m1
+ RET
+
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index db2c37f43e..4ef2f34961 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -22,6 +22,9 @@
#include "libavcodec/avcodec.h"
#include "libavcodec/mpegvideoencdsp.h"
+int ff_pix_sum16_mmx(uint8_t *pix, int line_size);
+int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
+
#if HAVE_INLINE_ASM
#define PHADDD(a, t) \
@@ -95,9 +98,15 @@
av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
AVCodecContext *avctx)
{
-#if HAVE_INLINE_ASM
int cpu_flags = av_get_cpu_flags();
+ if (EXTERNAL_MMX(cpu_flags)) {
+ c->pix_sum = ff_pix_sum16_mmx;
+ c->pix_norm1 = ff_pix_norm1_mmx;
+ }
+
+#if HAVE_INLINE_ASM
+
if (INLINE_MMX(cpu_flags)) {
if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
c->try_8x8basis = try_8x8basis_mmx;