1 ;******************************************************************************
2 ;* SIMD-optimized IDCT-related routines
3 ;* Copyright (c) 2008 Loren Merritt
4 ;* Copyright (c) 2003-2013 Michael Niedermayer
5 ;* Copyright (c) 2013 Daniel Kang
7 ;* This file is part of FFmpeg.
9 ;* FFmpeg 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.
14 ;* FFmpeg 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.
19 ;* You should have received a copy of the GNU Lesser General Public
20 ;* License along with FFmpeg; if not, write to the Free Software
21 ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 ;******************************************************************************
24 %include "libavutil/x86/x86util.asm"
32 ;--------------------------------------------------------------------------
33 ;void ff_put_signed_pixels_clamped(const int16_t *block, uint8_t *pixels,
34 ; ptrdiff_t line_size)
35 ;--------------------------------------------------------------------------
37 %macro PUT_SIGNED_PIXELS_CLAMPED_HALF 1
38 mova m1, [blockq+mmsize*0+%1]
39 mova m2, [blockq+mmsize*2+%1]
41 mova m3, [blockq+mmsize*4+%1]
42 mova m4, [blockq+mmsize*6+%1]
44 packsswb m1, [blockq+mmsize*1+%1]
45 packsswb m2, [blockq+mmsize*3+%1]
47 packsswb m3, [blockq+mmsize*5+%1]
48 packsswb m4, [blockq+mmsize*7+%1]
55 movq [pixelsq+lsizeq*0], m1
56 movq [pixelsq+lsizeq*1], m2
57 movq [pixelsq+lsizeq*2], m3
58 movq [pixelsq+lsize3q ], m4
60 movq [pixelsq+lsizeq*0], m1
61 movhps [pixelsq+lsizeq*1], m1
62 movq [pixelsq+lsizeq*2], m2
63 movhps [pixelsq+lsize3q ], m2
67 %macro PUT_SIGNED_PIXELS_CLAMPED 1
68 cglobal put_signed_pixels_clamped, 3, 4, %1, block, pixels, lsize, lsize3
70 lea lsize3q, [lsizeq*3]
71 PUT_SIGNED_PIXELS_CLAMPED_HALF 0
72 lea pixelsq, [pixelsq+lsizeq*4]
73 PUT_SIGNED_PIXELS_CLAMPED_HALF 64
78 PUT_SIGNED_PIXELS_CLAMPED 0
80 PUT_SIGNED_PIXELS_CLAMPED 3
82 ;--------------------------------------------------------------------------
83 ; void ff_put_pixels_clamped(const int16_t *block, uint8_t *pixels,
84 ; ptrdiff_t line_size);
85 ;--------------------------------------------------------------------------
87 %macro PUT_PIXELS_CLAMPED_HALF 1
88 mova m0, [blockq+mmsize*0+%1]
89 mova m1, [blockq+mmsize*2+%1]
91 mova m2, [blockq+mmsize*4+%1]
92 mova m3, [blockq+mmsize*6+%1]
94 packuswb m0, [blockq+mmsize*1+%1]
95 packuswb m1, [blockq+mmsize*3+%1]
97 packuswb m2, [blockq+mmsize*5+%1]
98 packuswb m3, [blockq+mmsize*7+%1]
100 movq [lsizeq+pixelsq], m1
101 movq [2*lsizeq+pixelsq], m2
102 movq [lsize3q+pixelsq], m3
105 movhps [lsizeq+pixelsq], m0
106 movq [2*lsizeq+pixelsq], m1
107 movhps [lsize3q+pixelsq], m1
111 %macro PUT_PIXELS_CLAMPED 0
112 cglobal put_pixels_clamped, 3, 4, 2, block, pixels, lsize, lsize3
113 lea lsize3q, [lsizeq*3]
114 PUT_PIXELS_CLAMPED_HALF 0
115 lea pixelsq, [pixelsq+lsizeq*4]
116 PUT_PIXELS_CLAMPED_HALF 64
125 ;--------------------------------------------------------------------------
126 ; void ff_add_pixels_clamped(const int16_t *block, uint8_t *pixels,
127 ; ptrdiff_t line_size);
128 ;--------------------------------------------------------------------------
130 %macro ADD_PIXELS_CLAMPED 1
131 mova m0, [blockq+mmsize*0+%1]
132 mova m1, [blockq+mmsize*1+%1]
134 mova m5, [blockq+mmsize*2+%1]
135 mova m6, [blockq+mmsize*3+%1]
138 movq m3, [pixelsq+lsizeq]
160 movq [pixelsq+lsizeq], m5
163 movhps [pixelsq+lsizeq], m0
167 %macro ADD_PIXELS_CLAMPED 0
168 cglobal add_pixels_clamped, 3, 3, 5, block, pixels, lsize
171 lea pixelsq, [pixelsq+lsizeq*2]
172 ADD_PIXELS_CLAMPED 32
173 lea pixelsq, [pixelsq+lsizeq*2]
174 ADD_PIXELS_CLAMPED 64
175 lea pixelsq, [pixelsq+lsizeq*2]
176 ADD_PIXELS_CLAMPED 96