2012-05-21 16:58:41 +00:00
|
|
|
;*****************************************************************************
|
|
|
|
;* x86-optimized Float DSP functions
|
|
|
|
;*
|
2012-06-08 21:35:35 +00:00
|
|
|
;* Copyright 2006 Loren Merritt
|
2012-05-21 16:58:41 +00:00
|
|
|
;*
|
2012-06-08 21:35:35 +00:00
|
|
|
;* This file is part of FFmpeg.
|
|
|
|
;*
|
|
|
|
;* FFmpeg is free software; you can redistribute it and/or
|
2012-05-21 16:58:41 +00:00
|
|
|
;* 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.
|
|
|
|
;*
|
2012-06-08 21:35:35 +00:00
|
|
|
;* FFmpeg is distributed in the hope that it will be useful,
|
2012-05-21 16:58:41 +00:00
|
|
|
;* 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
|
2012-06-08 21:35:35 +00:00
|
|
|
;* License along with FFmpeg; if not, write to the Free Software
|
2012-05-21 16:58:41 +00:00
|
|
|
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
;******************************************************************************
|
|
|
|
|
2012-06-09 03:20:59 +00:00
|
|
|
%include "x86util.asm"
|
2012-05-21 16:58:41 +00:00
|
|
|
|
|
|
|
SECTION .text
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; void vector_fmul(float *dst, const float *src0, const float *src1, int len)
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
%macro VECTOR_FMUL 0
|
|
|
|
cglobal vector_fmul, 4,4,2, dst, src0, src1, len
|
|
|
|
lea lenq, [lend*4 - 2*mmsize]
|
|
|
|
ALIGN 16
|
2012-08-05 23:09:48 +00:00
|
|
|
.loop:
|
2012-05-21 16:58:41 +00:00
|
|
|
mova m0, [src0q + lenq]
|
|
|
|
mova m1, [src0q + lenq + mmsize]
|
|
|
|
mulps m0, m0, [src1q + lenq]
|
|
|
|
mulps m1, m1, [src1q + lenq + mmsize]
|
|
|
|
mova [dstq + lenq], m0
|
|
|
|
mova [dstq + lenq + mmsize], m1
|
|
|
|
|
|
|
|
sub lenq, 2*mmsize
|
|
|
|
jge .loop
|
|
|
|
REP_RET
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
INIT_XMM sse
|
|
|
|
VECTOR_FMUL
|
2012-08-28 12:53:33 +00:00
|
|
|
%if HAVE_AVX_EXTERNAL
|
2012-05-21 16:58:41 +00:00
|
|
|
INIT_YMM avx
|
|
|
|
VECTOR_FMUL
|
|
|
|
%endif
|
2012-06-09 03:20:59 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
%macro VECTOR_FMAC_SCALAR 0
|
|
|
|
%if UNIX64
|
|
|
|
cglobal vector_fmac_scalar, 3,3,3, dst, src, len
|
|
|
|
%else
|
|
|
|
cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
|
|
|
|
%endif
|
|
|
|
%if ARCH_X86_32
|
|
|
|
VBROADCASTSS m0, mulm
|
|
|
|
%else
|
2012-08-03 21:38:49 +00:00
|
|
|
%if WIN64
|
|
|
|
mova xmm0, xmm2
|
|
|
|
%endif
|
2012-06-09 03:20:59 +00:00
|
|
|
shufps xmm0, xmm0, 0
|
|
|
|
%if cpuflag(avx)
|
|
|
|
vinsertf128 m0, m0, xmm0, 1
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
lea lenq, [lend*4-2*mmsize]
|
2012-08-05 23:09:48 +00:00
|
|
|
.loop:
|
2012-06-09 03:20:59 +00:00
|
|
|
mulps m1, m0, [srcq+lenq ]
|
|
|
|
mulps m2, m0, [srcq+lenq+mmsize]
|
|
|
|
addps m1, m1, [dstq+lenq ]
|
|
|
|
addps m2, m2, [dstq+lenq+mmsize]
|
|
|
|
mova [dstq+lenq ], m1
|
|
|
|
mova [dstq+lenq+mmsize], m2
|
|
|
|
sub lenq, 2*mmsize
|
|
|
|
jge .loop
|
|
|
|
REP_RET
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
INIT_XMM sse
|
|
|
|
VECTOR_FMAC_SCALAR
|
2012-08-28 12:53:33 +00:00
|
|
|
%if HAVE_AVX_EXTERNAL
|
2012-06-09 03:20:59 +00:00
|
|
|
INIT_YMM avx
|
|
|
|
VECTOR_FMAC_SCALAR
|
|
|
|
%endif
|
2012-09-22 22:41:25 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; void ff_vector_fmul_scalar(float *dst, const float *src, float mul, int len)
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
%macro VECTOR_FMUL_SCALAR 0
|
|
|
|
%if UNIX64
|
|
|
|
cglobal vector_fmul_scalar, 3,3,2, dst, src, len
|
|
|
|
%else
|
|
|
|
cglobal vector_fmul_scalar, 4,4,3, dst, src, mul, len
|
|
|
|
%endif
|
|
|
|
%if ARCH_X86_32
|
|
|
|
movss m0, mulm
|
|
|
|
%elif WIN64
|
|
|
|
SWAP 0, 2
|
|
|
|
%endif
|
|
|
|
shufps m0, m0, 0
|
|
|
|
lea lenq, [lend*4-mmsize]
|
|
|
|
.loop:
|
|
|
|
mova m1, [srcq+lenq]
|
|
|
|
mulps m1, m0
|
|
|
|
mova [dstq+lenq], m1
|
|
|
|
sub lenq, mmsize
|
|
|
|
jge .loop
|
|
|
|
REP_RET
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
INIT_XMM sse
|
|
|
|
VECTOR_FMUL_SCALAR
|
2012-09-24 19:00:53 +00:00
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; void ff_vector_dmul_scalar(double *dst, const double *src, double mul,
|
|
|
|
; int len)
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
%macro VECTOR_DMUL_SCALAR 0
|
2012-12-05 17:51:34 +00:00
|
|
|
%if ARCH_X86_32
|
|
|
|
cglobal vector_dmul_scalar, 3,4,3, dst, src, mul, len, lenaddr
|
|
|
|
mov lenq, lenaddrm
|
|
|
|
%elif UNIX64
|
2012-09-24 19:00:53 +00:00
|
|
|
cglobal vector_dmul_scalar, 3,3,3, dst, src, len
|
|
|
|
%else
|
|
|
|
cglobal vector_dmul_scalar, 4,4,3, dst, src, mul, len
|
|
|
|
%endif
|
|
|
|
%if ARCH_X86_32
|
2012-12-05 16:53:21 +00:00
|
|
|
VBROADCASTSD m0, mulm
|
2012-09-24 19:00:53 +00:00
|
|
|
%else
|
|
|
|
%if WIN64
|
|
|
|
movlhps xmm2, xmm2
|
|
|
|
%if cpuflag(avx)
|
|
|
|
vinsertf128 ymm2, ymm2, xmm2, 1
|
|
|
|
%endif
|
|
|
|
SWAP 0, 2
|
|
|
|
%else
|
|
|
|
movlhps xmm0, xmm0
|
|
|
|
%if cpuflag(avx)
|
|
|
|
vinsertf128 ymm0, ymm0, xmm0, 1
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
lea lenq, [lend*8-2*mmsize]
|
|
|
|
.loop:
|
|
|
|
mulpd m1, m0, [srcq+lenq ]
|
|
|
|
mulpd m2, m0, [srcq+lenq+mmsize]
|
|
|
|
mova [dstq+lenq ], m1
|
|
|
|
mova [dstq+lenq+mmsize], m2
|
|
|
|
sub lenq, 2*mmsize
|
|
|
|
jge .loop
|
|
|
|
REP_RET
|
|
|
|
%endmacro
|
|
|
|
|
|
|
|
INIT_XMM sse2
|
|
|
|
VECTOR_DMUL_SCALAR
|
|
|
|
%if HAVE_AVX_EXTERNAL
|
|
|
|
INIT_YMM avx
|
|
|
|
VECTOR_DMUL_SCALAR
|
|
|
|
%endif
|