aarch64: Add assembly support for -fsanitize=hwaddress tagged globals.
[libav.git] / libavcodec / x86 / v210enc.asm
blob0db0196313ea3ad04cd05c88aab9ffd3682b13f6
1 ;******************************************************************************
2 ;* V210 SIMD pack
3 ;* Copyright (c) 2014 Kieran Kunhya <kierank@obe.tv>
4 ;*
5 ;* This file is part of Libav.
6 ;*
7 ;* Libav is free software; you can redistribute it and/or
8 ;* modify it under the terms of the GNU Lesser General Public
9 ;* License as published by the Free Software Foundation; either
10 ;* version 2.1 of the License, or (at your option) any later version.
12 ;* Libav is distributed in the hope that it will be useful,
13 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;* Lesser General Public License for more details.
17 ;* You should have received a copy of the GNU Lesser General Public
18 ;* License along with Libav; if not, write to the Free Software
19 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ;******************************************************************************
22 %include "libavutil/x86/x86util.asm"
24 SECTION_RODATA 32
26 v210_enc_min_10: times 32 dw 0x4
27 v210_enc_max_10: times 32 dw 0x3fb
29 v210_enc_luma_mult_10: times 2 dw 4,1,16,4,1,16,0,0
30 v210_enc_luma_shuf_10: times 2 db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11
32 v210_enc_chroma_mult_10: times 2 dw 1,4,16,0,16,1,4,0
33 v210_enc_chroma_shuf_10: times 2 db 0,1,8,9,-1,2,3,-1,10,11,4,5,-1,12,13,-1
35 v210_enc_min_8: times 32 db 0x1
36 v210_enc_max_8: times 32 db 0xfe
38 v210_enc_luma_mult_8: times 2 dw 16,4,64,16,4,64,0,0
39 v210_enc_luma_shuf_8: times 2 db 6,-1,7,-1,8,-1,9,-1,10,-1,11,-1,-1,-1,-1,-1
41 v210_enc_chroma_mult_8: times 2 dw 4,16,64,0,64,4,16,0
42 v210_enc_chroma_shuf1_8: times 2 db 0,-1,1,-1,2,-1,3,-1,8,-1,9,-1,10,-1,11,-1
43 v210_enc_chroma_shuf2_8: times 2 db 3,-1,4,-1,5,-1,7,-1,11,-1,12,-1,13,-1,15,-1
45 SECTION .text
47 %macro v210_planar_pack_10 0
49 ; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
50 cglobal v210_planar_pack_10, 5, 5, 4+cpuflag(avx2), y, u, v, dst, width
51 lea r0, [yq+2*widthq]
52 add uq, widthq
53 add vq, widthq
54 neg widthq
56 mova m2, [v210_enc_min_10]
57 mova m3, [v210_enc_max_10]
59 .loop:
60 movu xm0, [yq+2*widthq]
61 %if cpuflag(avx2)
62 vinserti128 m0, m0, [yq+2*widthq+12], 1
63 %endif
64 CLIPW m0, m2, m3
66 movq xm1, [uq+widthq]
67 movhps xm1, [vq+widthq]
68 %if cpuflag(avx2)
69 movq xm4, [uq+widthq+6]
70 movhps xm4, [vq+widthq+6]
71 vinserti128 m1, m1, xm4, 1
72 %endif
73 CLIPW m1, m2, m3
75 pmullw m0, [v210_enc_luma_mult_10]
76 pshufb m0, [v210_enc_luma_shuf_10]
78 pmullw m1, [v210_enc_chroma_mult_10]
79 pshufb m1, [v210_enc_chroma_shuf_10]
81 por m0, m1
83 movu [dstq], m0
85 add dstq, mmsize
86 add widthq, (mmsize*3)/8
87 jl .loop
89 RET
90 %endmacro
92 %if HAVE_SSSE3_EXTERNAL
93 INIT_XMM ssse3
94 v210_planar_pack_10
95 %endif
96 %if HAVE_AVX2_EXTERNAL
97 INIT_YMM avx2
98 v210_planar_pack_10
99 %endif
101 %macro v210_planar_pack_8 0
103 ; v210_planar_pack_8(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
104 cglobal v210_planar_pack_8, 5, 5, 7, y, u, v, dst, width
105 add yq, widthq
106 shr widthq, 1
107 add uq, widthq
108 add vq, widthq
109 neg widthq
111 mova m4, [v210_enc_min_8]
112 mova m5, [v210_enc_max_8]
113 pxor m6, m6
115 .loop:
116 movu xm1, [yq+2*widthq]
117 %if cpuflag(avx2)
118 vinserti128 m1, m1, [yq+2*widthq+12], 1
119 %endif
120 CLIPUB m1, m4, m5
122 punpcklbw m0, m1, m6
123 ; can't unpack high bytes in the same way because we process
124 ; only six bytes at a time
125 pshufb m1, [v210_enc_luma_shuf_8]
127 pmullw m0, [v210_enc_luma_mult_8]
128 pmullw m1, [v210_enc_luma_mult_8]
129 pshufb m0, [v210_enc_luma_shuf_10]
130 pshufb m1, [v210_enc_luma_shuf_10]
132 movq xm3, [uq+widthq]
133 movhps xm3, [vq+widthq]
134 %if cpuflag(avx2)
135 movq xm2, [uq+widthq+6]
136 movhps xm2, [vq+widthq+6]
137 vinserti128 m3, m3, xm2, 1
138 %endif
139 CLIPUB m3, m4, m5
141 ; shuffle and multiply to get the same packing as in 10-bit
142 pshufb m2, m3, [v210_enc_chroma_shuf1_8]
143 pshufb m3, [v210_enc_chroma_shuf2_8]
145 pmullw m2, [v210_enc_chroma_mult_8]
146 pmullw m3, [v210_enc_chroma_mult_8]
147 pshufb m2, [v210_enc_chroma_shuf_10]
148 pshufb m3, [v210_enc_chroma_shuf_10]
150 por m0, m2
151 por m1, m3
153 movu [dstq], xm0
154 movu [dstq+16], xm1
155 %if cpuflag(avx2)
156 vextracti128 [dstq+32], m0, 1
157 vextracti128 [dstq+48], m1, 1
158 %endif
160 add dstq, 2*mmsize
161 add widthq, (mmsize*3)/8
162 jl .loop
165 %endmacro
167 %if HAVE_SSSE3_EXTERNAL
168 INIT_XMM ssse3
169 v210_planar_pack_8
170 %endif
171 %if HAVE_AVX_EXTERNAL
172 INIT_XMM avx
173 v210_planar_pack_8
174 %endif
175 %if HAVE_AVX2_EXTERNAL
176 INIT_YMM avx2
177 v210_planar_pack_8
178 %endif