1 ;******************************************************************************
3 ;* Copyright (c) 2014 Kieran Kunhya <kierank@obe.tv>
5 ;* This file is part of Libav.
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"
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
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
56 mova m2
, [v210_enc_min_10
]
57 mova m3
, [v210_enc_max_10
]
60 movu xm0
, [yq
+2*widthq
]
62 vinserti128 m0
, m0
, [yq
+2*widthq
+12], 1
67 movhps xm1
, [vq
+widthq
]
69 movq xm4
, [uq
+widthq
+6]
70 movhps xm4
, [vq
+widthq
+6]
71 vinserti128 m1
, m1
, xm4
, 1
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
]
86 add widthq
, (mmsize
*3)/8
92 %if HAVE_SSSE3_EXTERNAL
96 %if HAVE_AVX2_EXTERNAL
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
111 mova m4
, [v210_enc_min_8
]
112 mova m5
, [v210_enc_max_8
]
116 movu xm1
, [yq
+2*widthq
]
118 vinserti128 m1
, m1
, [yq
+2*widthq
+12], 1
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
]
135 movq xm2
, [uq
+widthq
+6]
136 movhps xm2
, [vq
+widthq
+6]
137 vinserti128 m3
, m3
, xm2
, 1
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
]
156 vextracti128
[dstq
+32], m0
, 1
157 vextracti128
[dstq
+48], m1
, 1
161 add widthq
, (mmsize
*3)/8
167 %if HAVE_SSSE3_EXTERNAL
171 %if HAVE_AVX_EXTERNAL
175 %if HAVE_AVX2_EXTERNAL