]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/exrdsp.asm
lavfi/paletteuse: move "new" option before debugging options
[ffmpeg] / libavcodec / x86 / exrdsp.asm
1 ;******************************************************************************
2 ;* X86 Optimized functions for Open Exr Decoder
3 ;* Copyright (c) 2006 Industrial Light & Magic, a division of Lucas Digital Ltd. LLC
4 ;*
5 ;* reorder_pixels, predictor based on patch by John Loy
6 ;* port to ASM by Jokyo Images support by CNC - French National Center for Cinema
7 ;*
8 ;* predictor AVX/AVX2 by Henrik Gramner
9 ;*
10 ;* This file is part of FFmpeg.
11 ;*
12 ;* FFmpeg is free software; you can redistribute it and/or
13 ;* modify it under the terms of the GNU Lesser General Public
14 ;* License as published by the Free Software Foundation; either
15 ;* version 2.1 of the License, or (at your option) any later version.
16 ;*
17 ;* FFmpeg is distributed in the hope that it will be useful,
18 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;* Lesser General Public License for more details.
21 ;*
22 ;* You should have received a copy of the GNU Lesser General Public
23 ;* License along with FFmpeg; if not, write to the Free Software
24 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 ;******************************************************************************
26
27 %include "libavutil/x86/x86util.asm"
28
29 cextern pb_15
30 cextern pb_80
31
32 SECTION .text
33
34 ;------------------------------------------------------------------------------
35 ; void ff_reorder_pixels(uint8_t *dst, const uint8_t *src, ptrdiff_t size);
36 ;------------------------------------------------------------------------------
37
38 %macro REORDER_PIXELS 0
39 cglobal reorder_pixels, 3,4,3, dst, src1, size, src2
40     lea                              src2q, [src1q+sizeq] ; src2 = src + 2 * half_size
41     add                               dstq, sizeq         ; dst offset by size
42     shr                              sizeq, 1             ; half_size
43     add                              src1q, sizeq         ; offset src by half_size
44     neg                              sizeq                ; size = offset for dst, src1, src2
45 .loop:
46
47     mova                                m0, [src1q+sizeq]        ; load first part
48     movu                                m1, [src2q+sizeq]        ; load second part
49     SBUTTERFLY bw, 0, 1, 2                                       ; interleaved
50     mova                 [dstq+2*sizeq   ], xm0                  ; copy to dst
51     mova                 [dstq+2*sizeq+16], xm1
52 %if cpuflag(avx2)
53     vperm2i128                          m0, m0, m1, q0301
54     mova                 [dstq+2*sizeq+32], m0
55 %endif
56     add     sizeq, mmsize
57     jl .loop
58     RET
59 %endmacro
60
61 INIT_XMM sse2
62 REORDER_PIXELS
63
64 %if HAVE_AVX2_EXTERNAL
65 INIT_YMM avx2
66 REORDER_PIXELS
67 %endif
68
69
70 ;------------------------------------------------------------------------------
71 ; void ff_predictor(uint8_t *src, ptrdiff_t size);
72 ;------------------------------------------------------------------------------
73
74 %macro PREDICTOR 0
75 cglobal predictor, 2,2,5, src, size
76 %if mmsize == 32
77     vbroadcasti128   m0, [pb_80]
78 %else
79     mova            xm0, [pb_80]
80 %endif
81     mova            xm1, [pb_15]
82     mova            xm2, xm0
83     add            srcq, sizeq
84     neg           sizeq
85 .loop:
86     pxor             m3, m0, [srcq + sizeq]
87     pslldq           m4, m3, 1
88     paddb            m3, m4
89     pslldq           m4, m3, 2
90     paddb            m3, m4
91     pslldq           m4, m3, 4
92     paddb            m3, m4
93     pslldq           m4, m3, 8
94 %if mmsize == 32
95     paddb            m3, m4
96     paddb           xm2, xm3
97     vextracti128    xm4, m3, 1
98     mova [srcq + sizeq], xm2
99     pshufb          xm2, xm1
100     paddb           xm2, xm4
101     mova [srcq + sizeq + 16], xm2
102 %else
103     paddb            m2, m3
104     paddb            m2, m4
105     mova [srcq + sizeq], m2
106 %endif
107     pshufb          xm2, xm1
108     add           sizeq, mmsize
109     jl .loop
110     RET
111 %endmacro
112
113 INIT_XMM ssse3
114 PREDICTOR
115
116 INIT_XMM avx
117 PREDICTOR
118
119 %if HAVE_AVX2_EXTERNAL
120 INIT_YMM avx2
121 PREDICTOR
122 %endif