]> git.sesse.net Git - ffmpeg/blob - libswscale/x86/rgb_2_rgb.asm
Merge commit 'b9ea301e02472d0982b0fa0f80294bd95885bde8'
[ffmpeg] / libswscale / x86 / rgb_2_rgb.asm
1 ;******************************************************************************
2 ;* Copyright Nick Kurshev
3 ;* Copyright Michael (michaelni@gmx.at)
4 ;* Copyright 2018 Jokyo Images
5 ;*
6 ;* This file is part of FFmpeg.
7 ;*
8 ;* FFmpeg is free software; you can redistribute it and/or
9 ;* modify it under the terms of the GNU Lesser General Public
10 ;* License as published by the Free Software Foundation; either
11 ;* version 2.1 of the License, or (at your option) any later version.
12 ;*
13 ;* FFmpeg is distributed in the hope that it will be useful,
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;* Lesser General Public License for more details.
17 ;*
18 ;* You should have received a copy of the GNU Lesser General Public
19 ;* License along with FFmpeg; if not, write to the Free Software
20 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 ;******************************************************************************
22
23 %include "libavutil/x86/x86util.asm"
24
25 SECTION_RODATA
26
27 pb_shuffle2103: db 2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15
28 pb_shuffle0321: db 0, 3, 2, 1, 4, 7, 6, 5, 8, 11, 10, 9, 12, 15, 14, 13
29 pb_shuffle1230: db 1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12
30 pb_shuffle3012: db 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14
31 pb_shuffle3210: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
32
33 SECTION .text
34
35 ;------------------------------------------------------------------------------
36 ; shuffle_bytes_## (const uint8_t *src, uint8_t *dst, int src_size)
37 ;------------------------------------------------------------------------------
38 ; %1-4 index shuffle
39 %macro SHUFFLE_BYTES 4
40 cglobal shuffle_bytes_%1%2%3%4, 3, 5, 2, src, dst, w, tmp, x
41     VBROADCASTI128    m0, [pb_shuffle%1%2%3%4]
42     movsxdifnidn wq, wd
43     mov xq, wq
44
45     add        srcq, wq
46     add        dstq, wq
47     neg          wq
48
49 ;calc scalar loop
50     and xq, mmsize-4
51     je .loop_simd
52
53 .loop_scalar:
54    mov          tmpb, [srcq + wq + %1]
55    mov [dstq+wq + 0], tmpb
56    mov          tmpb, [srcq + wq + %2]
57    mov [dstq+wq + 1], tmpb
58    mov          tmpb, [srcq + wq + %3]
59    mov [dstq+wq + 2], tmpb
60    mov          tmpb, [srcq + wq + %4]
61    mov [dstq+wq + 3], tmpb
62    add            wq, 4
63    sub            xq, 4
64    jg .loop_scalar
65
66 ;check if src_size < mmsize
67 cmp wq, 0
68 jge .end
69
70 .loop_simd:
71     movu           m1, [srcq+wq]
72     pshufb         m1, m0
73     movu    [dstq+wq], m1
74     add            wq, mmsize
75     jl .loop_simd
76
77 .end:
78     RET
79 %endmacro
80
81 INIT_XMM ssse3
82 SHUFFLE_BYTES 2, 1, 0, 3
83 SHUFFLE_BYTES 0, 3, 2, 1
84 SHUFFLE_BYTES 1, 2, 3, 0
85 SHUFFLE_BYTES 3, 0, 1, 2
86 SHUFFLE_BYTES 3, 2, 1, 0