]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/utvideodsp.asm
lavfi/paletteuse: move "new" option before debugging options
[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 SECTION_RODATA
25
26 pb_128:  times 16 db 128
27 pw_512:  times 8  dw 512
28 pw_1023: times 8  dw 1023
29
30 SECTION .text
31
32 INIT_XMM sse2
33
34 ; void restore_rgb_planes(uint8_t *src_r, uint8_t *src_g, uint8_t *src_b,
35 ;                         ptrdiff_t linesize_r, ptrdiff_t linesize_g, ptrdiff_t linesize_b,
36 ;                         int width, int height)
37 cglobal restore_rgb_planes, 7 + ARCH_X86_64, 7 + ARCH_X86_64 * 2, 4, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x
38     movsxdifnidn wq, wd
39     add      src_rq, wq
40     add      src_gq, wq
41     add      src_bq, wq
42     neg          wq
43 %if ARCH_X86_64 == 0
44     mov          wm, wq
45 DEFINE_ARGS src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, x
46 %define wq r6m
47 %define hd r7mp
48 %endif
49     mova         m3, [pb_128]
50 .nextrow:
51     mov          xq, wq
52
53     .loop:
54         mova           m0, [src_rq + xq]
55         mova           m1, [src_gq + xq]
56         mova           m2, [src_bq + xq]
57         psubb          m1, m3
58         paddb          m0, m1
59         paddb          m2, m1
60         mova  [src_rq+xq], m0
61         mova  [src_bq+xq], m2
62         add            xq, mmsize
63     jl .loop
64
65     add        src_rq, linesize_rq
66     add        src_gq, linesize_gq
67     add        src_bq, linesize_bq
68     sub        hd, 1
69     jg .nextrow
70     REP_RET
71
72 cglobal restore_rgb_planes10, 7 + ARCH_X86_64, 7 + ARCH_X86_64 * 2, 5, src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, w, h, x
73     shl          wd, 1
74     shl linesize_rq, 1
75     shl linesize_gq, 1
76     shl linesize_bq, 1
77     add      src_rq, wq
78     add      src_gq, wq
79     add      src_bq, wq
80     mova         m3, [pw_512]
81     mova         m4, [pw_1023]
82     neg          wq
83 %if ARCH_X86_64 == 0
84     mov          wm, wq
85 DEFINE_ARGS src_r, src_g, src_b, linesize_r, linesize_g, linesize_b, x
86 %define wq r6m
87 %define hd r7mp
88 %endif
89 .nextrow:
90     mov          xq, wq
91
92     .loop:
93         mova           m0, [src_rq + xq]
94         mova           m1, [src_gq + xq]
95         mova           m2, [src_bq + xq]
96         psubw          m1, m3
97         paddw          m0, m1
98         paddw          m2, m1
99         pand           m0, m4
100         pand           m2, m4
101         mova  [src_rq+xq], m0
102         mova  [src_bq+xq], m2
103         add            xq, mmsize
104     jl .loop
105
106     add        src_rq, linesize_rq
107     add        src_gq, linesize_gq
108     add        src_bq, linesize_bq
109     sub        hd, 1
110     jg .nextrow
111     REP_RET