1/*
2 * Copyright (c) 2012-2014 Christophe Gisquet <christophe.gisquet@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_X86_DCA_H
22#define AVCODEC_X86_DCA_H
23
24#include "config.h"
25
26#if ARCH_X86_64 && HAVE_SSE2_INLINE
27# include "libavutil/x86/asm.h"
28# include "libavutil/mem.h"
29#include "libavcodec/dcadsp.h"
30
31# define int8x8_fmul_int32 int8x8_fmul_int32
32static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
33                                     float *dst, const int8_t *src, int scale)
34{
35    DECLARE_ALIGNED(16, static const uint32_t, inverse16) = 0x3D800000;
36    __asm__ volatile (
37        "cvtsi2ss        %2, %%xmm0 \n\t"
38        "mulss           %3, %%xmm0 \n\t"
39        "movq          (%1), %%xmm1 \n\t"
40        "punpcklbw   %%xmm1, %%xmm1 \n\t"
41        "movaps      %%xmm1, %%xmm2 \n\t"
42        "punpcklwd   %%xmm1, %%xmm1 \n\t"
43        "punpckhwd   %%xmm2, %%xmm2 \n\t"
44        "psrad          $24, %%xmm1 \n\t"
45        "psrad          $24, %%xmm2 \n\t"
46        "shufps  $0, %%xmm0, %%xmm0 \n\t"
47        "cvtdq2ps    %%xmm1, %%xmm1 \n\t"
48        "cvtdq2ps    %%xmm2, %%xmm2 \n\t"
49        "mulps       %%xmm0, %%xmm1 \n\t"
50        "mulps       %%xmm0, %%xmm2 \n\t"
51        "movaps      %%xmm1,  0(%0) \n\t"
52        "movaps      %%xmm2, 16(%0) \n\t"
53        :: "r"(dst), "r"(src), "m"(scale), "m"(inverse16)
54        XMM_CLOBBERS_ONLY("xmm0", "xmm1", "xmm2")
55    );
56}
57
58#endif /* ARCH_X86_64 && HAVE_SSE2_INLINE */
59
60#endif /* AVCODEC_X86_DCA_H */
61