]> git.sesse.net Git - ffmpeg/blob - libavcodec/x86/fpel.asm
utvideodec: Support UQRA and UQRG
[ffmpeg] / libavcodec / x86 / fpel.asm
1 ;******************************************************************************
2 ;* SIMD-optimized fullpel functions
3 ;* Copyright (c) 2008 Loren Merritt
4 ;* Copyright (c) 2003-2013 Michael Niedermayer
5 ;* Copyright (c) 2013 Daniel Kang
6 ;*
7 ;* This file is part of Libav.
8 ;*
9 ;* Libav is free software; you can redistribute it and/or
10 ;* modify it under the terms of the GNU Lesser General Public
11 ;* License as published by the Free Software Foundation; either
12 ;* version 2.1 of the License, or (at your option) any later version.
13 ;*
14 ;* Libav is distributed in the hope that it will be useful,
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;* Lesser General Public License for more details.
18 ;*
19 ;* You should have received a copy of the GNU Lesser General Public
20 ;* License along with Libav; if not, write to the Free Software
21 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 ;******************************************************************************
23
24 %include "libavutil/x86/x86util.asm"
25
26 SECTION .text
27
28 INIT_MMX mmxext
29 ; void ff_put/avg_pixels(uint8_t *block, const uint8_t *pixels,
30 ;                        ptrdiff_t line_size, int h)
31 %macro PIXELS48 2
32 %if %2 == 4
33 %define OP movh
34 %else
35 %define OP mova
36 %endif
37 cglobal %1_pixels%2, 4,5
38     lea          r4, [r2*3]
39 .loop:
40     OP           m0, [r1]
41     OP           m1, [r1+r2]
42     OP           m2, [r1+r2*2]
43     OP           m3, [r1+r4]
44     lea          r1, [r1+r2*4]
45 %ifidn %1, avg
46     pavgb        m0, [r0]
47     pavgb        m1, [r0+r2]
48     pavgb        m2, [r0+r2*2]
49     pavgb        m3, [r0+r4]
50 %endif
51     OP         [r0], m0
52     OP      [r0+r2], m1
53     OP    [r0+r2*2], m2
54     OP      [r0+r4], m3
55     sub         r3d, 4
56     lea          r0, [r0+r2*4]
57     jne       .loop
58     RET
59 %endmacro
60
61 PIXELS48 put, 4
62 PIXELS48 avg, 4
63 PIXELS48 put, 8
64 PIXELS48 avg, 8
65
66
67 INIT_XMM sse2
68 ; void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
69 ;                           ptrdiff_t line_size, int h)
70 cglobal put_pixels16, 4,5,4
71     lea          r4, [r2*3]
72 .loop:
73     movu         m0, [r1]
74     movu         m1, [r1+r2]
75     movu         m2, [r1+r2*2]
76     movu         m3, [r1+r4]
77     lea          r1, [r1+r2*4]
78     mova       [r0], m0
79     mova    [r0+r2], m1
80     mova  [r0+r2*2], m2
81     mova    [r0+r4], m3
82     sub         r3d, 4
83     lea          r0, [r0+r2*4]
84     jnz       .loop
85     REP_RET
86
87 ; void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
88 ;                           ptrdiff_t line_size, int h)
89 cglobal avg_pixels16, 4,5,4
90     lea          r4, [r2*3]
91 .loop:
92     movu         m0, [r1]
93     movu         m1, [r1+r2]
94     movu         m2, [r1+r2*2]
95     movu         m3, [r1+r4]
96     lea          r1, [r1+r2*4]
97     pavgb        m0, [r0]
98     pavgb        m1, [r0+r2]
99     pavgb        m2, [r0+r2*2]
100     pavgb        m3, [r0+r4]
101     mova       [r0], m0
102     mova    [r0+r2], m1
103     mova  [r0+r2*2], m2
104     mova    [r0+r4], m3
105     sub         r3d, 4
106     lea          r0, [r0+r2*4]
107     jnz       .loop
108     REP_RET