]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/utvideodsp.asm
dxva: move d3d11 locking/unlocking to functions
[ffmpeg] / libavcodec / x86 / utvideodsp.asm
1 ;******************************************************************************
2 ;* SIMD-optimized UTVideo functions
3 ;* Copyright (c) 2017 Paul B Mahol
4 ;*
5 ;* This file is part of FFmpeg.
6 ;*
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.
11 ;*
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.
16 ;*
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 ;******************************************************************************
21
22 %include "libavutil/x86/x86util.asm"
23
24 %if ARCH_X86_64
25
26 SECTION_RODATA
27
28 pb_128:  times 16 db 128
29 pw_512:  times 8  dw 512
30 pw_1023: times 8  dw 1023
31
32 SECTION .text
33
34 INIT_XMM sse2
35
36 ; void restore_rgb_planes(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b,
37 ;                         ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b,
38 ;                         int width, int height)
39 cglobal restore_rgb_planes, 8,9,4, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x
40     movsxdifnidn wq, wd
41     add      src_rq, wq
42     add      src_gq, wq
43     add      src_bq, wq
44     neg          wq
45     mova         m3, [pb_128]
46 .nextrow:
47     mov          xq, wq
48
49     .loop:
50         mova           m0, [src_rq + xq]
51         mova           m1, [src_gq + xq]
52         mova           m2, [src_bq + xq]
53         psubb          m1, m3
54         paddb          m0, m1
55         paddb          m2, m1
56         mova  [src_rq+xq], m0
57         mova  [src_bq+xq], m2
58         add            xq, mmsize
59     jl .loop
60
61     add        src_rq, linesize_rq
62     add        src_gq, linesize_gq
63     add        src_bq, linesize_bq
64     sub        hd, 1
65     jg .nextrow
66     REP_RET
67
68 cglobal restore_rgb_planes10, 8,9,5, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x
69     shl          wd, 1
70     shl linesize_rq, 1
71     shl linesize_gq, 1
72     shl linesize_bq, 1
73     add      src_rq, wq
74     add      src_gq, wq
75     add      src_bq, wq
76     mova         m3, [pw_512]
77     mova         m4, [pw_1023]
78     neg          wq
79 .nextrow:
80     mov          xq, wq
81
82     .loop:
83         mova           m0, [src_rq + xq]
84         mova           m1, [src_gq + xq]
85         mova           m2, [src_bq + xq]
86         psubw          m1, m3
87         paddw          m0, m1
88         paddw          m2, m1
89         pand           m0, m4
90         pand           m2, m4
91         mova  [src_rq+xq], m0
92         mova  [src_bq+xq], m2
93         add            xq, mmsize
94     jl .loop
95
96     add        src_rq, linesize_rq
97     add        src_gq, linesize_gq
98     add        src_bq, linesize_bq
99     sub        hd, 1
100     jg .nextrow
101     REP_RET
102
103 %endif