1 ;******************************************************************************
3 ;* Copyright (c) 2014 Kieran Kunhya <kierank@obe.tv>
5 ;* This file is part of FFmpeg.
7 ;* FFmpeg 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 ;* FFmpeg 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 FFmpeg; 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"
27 %define v210_enc_min_10 pw_4
28 v210_enc_max_10: times 16 dw 0x3fb
30 v210_enc_luma_mult_10: times 2 dw 4,1,16,4,1,16,0,0
31 v210_enc_luma_shuf_10: times 2 db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11
33 v210_enc_chroma_mult_10: times 2 dw 1,4,16,0,16,1,4,0
34 v210_enc_chroma_shuf_10: times 2 db 0,1,8,9,-1,2,3,-1,10,11,4,5,-1,12,13,-1
37 %define v210_enc_min_8 pb_1
39 %define v210_enc_max_8 pb_FE
41 v210_enc_luma_shuf_8: times 2 db 6,-1,7,-1,8,-1,9,-1,10,-1,11,-1,-1,-1,-1,-1
42 v210_enc_luma_mult_8: times 2 dw 16,4,64,16,4,64,0,0
44 v210_enc_chroma_shuf1_8: times 2 db 0,-1,1,-1,2,-1,3,-1,8,-1,9,-1,10,-1,11,-1
45 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 v210_enc_chroma_mult_8: times 2 dw 4,16,64,0,64,4,16,0
51 %macro v210_planar_pack_10 0
53 ; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
54 cglobal v210_planar_pack_10, 5, 5, 4+cpuflag(avx2), y, u, v, dst, width
60 mova m2, [v210_enc_min_10]
61 mova m3, [v210_enc_max_10]
64 movu xm0, [yq+2*widthq]
66 vinserti128 m0, m0, [yq+widthq*2+12], 1
71 movhps xm1, [vq+widthq]
73 movq xm4, [uq+widthq+6]
74 movhps xm4, [vq+widthq+6]
75 vinserti128 m1, m1, xm4, 1
79 pmullw m0, [v210_enc_luma_mult_10]
80 pshufb m0, [v210_enc_luma_shuf_10]
82 pmullw m1, [v210_enc_chroma_mult_10]
83 pshufb m1, [v210_enc_chroma_shuf_10]
90 add widthq, (mmsize*3)/8
96 %if HAVE_SSSE3_EXTERNAL
101 %if HAVE_AVX2_EXTERNAL
106 %macro v210_planar_pack_8 0
108 ; v210_planar_pack_8(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
109 cglobal v210_planar_pack_8, 5, 5, 7, y, u, v, dst, width
116 mova m4, [v210_enc_min_8]
117 mova m5, [v210_enc_max_8]
121 movu xm1, [yq+widthq*2]
123 vinserti128 m1, m1, [yq+widthq*2+12], 1
128 ; can't unpack high bytes in the same way because we process
129 ; only six bytes at a time
130 pshufb m1, [v210_enc_luma_shuf_8]
132 pmullw m0, [v210_enc_luma_mult_8]
133 pmullw m1, [v210_enc_luma_mult_8]
134 pshufb m0, [v210_enc_luma_shuf_10]
135 pshufb m1, [v210_enc_luma_shuf_10]
137 movq xm3, [uq+widthq]
138 movhps xm3, [vq+widthq]
140 movq xm2, [uq+widthq+6]
141 movhps xm2, [vq+widthq+6]
142 vinserti128 m3, m3, xm2, 1
146 ; shuffle and multiply to get the same packing as in 10-bit
147 pshufb m2, m3, [v210_enc_chroma_shuf1_8]
148 pshufb m3, [v210_enc_chroma_shuf2_8]
150 pmullw m2, [v210_enc_chroma_mult_8]
151 pmullw m3, [v210_enc_chroma_mult_8]
152 pshufb m2, [v210_enc_chroma_shuf_10]
153 pshufb m3, [v210_enc_chroma_shuf_10]
161 vextracti128 [dstq+32], m0, 1
162 vextracti128 [dstq+48], m1, 1
166 add widthq, (mmsize*3)/8
172 %if HAVE_SSSE3_EXTERNAL
176 %if HAVE_AVX_EXTERNAL
181 %if HAVE_AVX2_EXTERNAL