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"
26 v210_enc_min_10: times 8 dw 0x4
27 v210_enc_max_10: times 8 dw 0x3fb
29 v210_enc_luma_mult_10: dw 4,1,16,4,1,16,0,0
30 v210_enc_luma_shuf_10: db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11
32 v210_enc_chroma_mult_10: dw 1,4,16,0,16,1,4,0
33 v210_enc_chroma_shuf_10: db 0,1,8,9,-1,2,3,-1,10,11,4,5,-1,12,13,-1
35 v210_enc_min_8: times 16 db 0x1
36 v210_enc_max_8: times 16 db 0xfe
38 v210_enc_luma_shuf_8: db 6,-1,7,-1,8,-1,9,-1,10,-1,11,-1,-1,-1,-1,-1
39 v210_enc_luma_mult_8: dw 16,4,64,16,4,64,0,0
41 v210_enc_chroma_shuf1_8: db 0,-1,1,-1,2,-1,3,-1,8,-1,9,-1,10,-1,11,-1
42 v210_enc_chroma_shuf2_8: db 3,-1,4,-1,5,-1,7,-1,11,-1,12,-1,13,-1,15,-1
44 v210_enc_chroma_mult_8: dw 4,16,64,0,64,4,16,0
48 %macro v210_planar_pack_10 0
50 ; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
51 cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width
57 mova m2, [v210_enc_min_10]
58 mova m3, [v210_enc_max_10]
61 movu m0, [yq+2*widthq]
65 movhps m1, [vq+widthq]
68 pmullw m0, [v210_enc_luma_mult_10]
69 pshufb m0, [v210_enc_luma_shuf_10]
71 pmullw m1, [v210_enc_chroma_mult_10]
72 pshufb m1, [v210_enc_chroma_shuf_10]
88 %macro v210_planar_pack_8 0
90 ; v210_planar_pack_8(const uint8_t *y, const uint8_t *u, const uint8_t *v, uint8_t *dst, ptrdiff_t width)
91 cglobal v210_planar_pack_8, 5, 5, 7, y, u, v, dst, width
98 mova m4, [v210_enc_min_8]
99 mova m5, [v210_enc_max_8]
103 movu m1, [yq+2*widthq]
107 ; can't unpack high bytes in the same way because we process
108 ; only six bytes at a time
109 pshufb m1, [v210_enc_luma_shuf_8]
111 pmullw m0, [v210_enc_luma_mult_8]
112 pmullw m1, [v210_enc_luma_mult_8]
113 pshufb m0, [v210_enc_luma_shuf_10]
114 pshufb m1, [v210_enc_luma_shuf_10]
117 movhps m3, [vq+widthq]
120 ; shuffle and multiply to get the same packing as in 10-bit
121 pshufb m2, m3, [v210_enc_chroma_shuf1_8]
122 pshufb m3, [v210_enc_chroma_shuf2_8]
124 pmullw m2, [v210_enc_chroma_mult_8]
125 pmullw m3, [v210_enc_chroma_mult_8]
126 pshufb m2, [v210_enc_chroma_shuf_10]
127 pshufb m3, [v210_enc_chroma_shuf_10]
133 movu [dstq+mmsize], m1