[FFmpeg-devel] [PATCH 4/5] x86/opusdsp: implement FMA3 accelerated postfilter and deemphasis

James Almer jamrial at gmail.com
Mon Apr 1 01:49:50 EEST 2019


On 3/16/2019 1:33 PM, Lynne wrote:
> diff --git a/libavcodec/x86/opusdsp.asm b/libavcodec/x86/opusdsp.asm
> new file mode 100644
> index 0000000000..ed65614e06
> --- /dev/null
> +++ b/libavcodec/x86/opusdsp.asm
> @@ -0,0 +1,114 @@
> +;******************************************************************************
> +;* Opus SIMD functions
> +;*
> +;* 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/x86/x86util.asm"
> +
> +SECTION_RODATA
> +
> +         ; 0.85..^1    0.85..^2    0.85..^3    0.85..^4
> +tab_st: dd 0x3f599a00, 0x3f38f671, 0x3f1d382a, 0x3f05a32f
> +tab_x0: dd 0x0,        0x3f599a00, 0x3f599a00, 0x3f599a00
> +tab_x1: dd 0x0,        0x0,        0x3f38f671, 0x3f38f671
> +tab_x2: dd 0x0,        0x0,        0x0,        0x3f1d382a
> +
> +SECTION .text
> +
> +INIT_XMM fma3
> +%if UNIX64
> +cglobal opus_deemphasis, 3, 3, 8, out, in, len
> +%else
> +cglobal opus_deemphasis, 4, 4, 8, out, in, coeff, len
> +%endif
> +%if ARCH_X86_32
> +    VBROADCASTSS m0, coeffm
> +%else
> +%if WIN64
> +    SWAP 0, 2
> +%endif
> +    shufps m0, m0, 0
> +%endif
> +
> +    movaps m4, [tab_st]
> +    movaps m5, [tab_x0]
> +    movaps m6, [tab_x1]
> +    movaps m7, [tab_x2]
> +
> +.loop:
> +    movaps  m1, [inq]                ; x0, x1, x2, x3
> +
> +    pslldq  m2, m1, 4                ;  0, x0, x1, x2
> +    pslldq  m3, m1, 8                ;  0,  0, x0, x1
> +
> +    fmaddps m2, m2, m5, m1           ; x + c1*x[0-2]
> +    pslldq  m1, 12                   ;  0,  0,  0, x0
> +
> +    fmaddps m2, m3, m6, m2           ; x + c1*x[0-2] + c2*x[0-1]
> +    fmaddps m1, m1, m7, m2           ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0]
> +    fmaddps m0, m0, m4, m1           ; x + c1*x[0-2] + c2*x[0-1] + c3*x[0] + c*s
> +
> +    movaps [outq], m0
> +    shufps m0, m0, q3333             ; new state
> +
> +    add inq,  mmsize
> +    add outq, mmsize
> +    sub lenq, mmsize >> 2
> +    jg .loop
> +
> +%if ARCH_X86_64 == 0
> +    movss r0m, m0
> +    fld dword r0m
> +%endif
> +    RET

A float ret value needs to be in xmm0, and you swapped m0 with m2 on
Win64. This is the source of the fate failure.


More information about the ffmpeg-devel mailing list