2 * MMX-optimized avg/put pixel routines
4 * Copyright (c) 2000, 2001 Fabrice Bellard
5 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
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
28 #include "dsputil_mmx.h"
32 // in case more speed is needed - unrolling would certainly help
33 void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
34 ptrdiff_t line_size, int h)
42 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
53 void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
54 ptrdiff_t line_size, int h)
62 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
64 "movq 8%0, %%mm0 \n\t"
65 "movq 8%1, %%mm1 \n\t"
66 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
67 "movq %%mm2, 8%0 \n\t"
77 void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
78 ptrdiff_t line_size, int h)
81 "lea (%3, %3), %%"REG_a" \n\t"
84 "movq (%1 ), %%mm0 \n\t"
85 "movq (%1, %3), %%mm1 \n\t"
86 "movq %%mm0, (%2) \n\t"
87 "movq %%mm1, (%2, %3) \n\t"
88 "add %%"REG_a", %1 \n\t"
89 "add %%"REG_a", %2 \n\t"
90 "movq (%1 ), %%mm0 \n\t"
91 "movq (%1, %3), %%mm1 \n\t"
92 "movq %%mm0, (%2) \n\t"
93 "movq %%mm1, (%2, %3) \n\t"
94 "add %%"REG_a", %1 \n\t"
95 "add %%"REG_a", %2 \n\t"
98 : "+g"(h), "+r"(pixels), "+r"(block)
99 : "r"((x86_reg)line_size)
104 void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
105 ptrdiff_t line_size, int h)
108 "lea (%3, %3), %%"REG_a" \n\t"
111 "movq (%1 ), %%mm0 \n\t"
112 "movq 8(%1 ), %%mm4 \n\t"
113 "movq (%1, %3), %%mm1 \n\t"
114 "movq 8(%1, %3), %%mm5 \n\t"
115 "movq %%mm0, (%2) \n\t"
116 "movq %%mm4, 8(%2) \n\t"
117 "movq %%mm1, (%2, %3) \n\t"
118 "movq %%mm5, 8(%2, %3) \n\t"
119 "add %%"REG_a", %1 \n\t"
120 "add %%"REG_a", %2 \n\t"
121 "movq (%1 ), %%mm0 \n\t"
122 "movq 8(%1 ), %%mm4 \n\t"
123 "movq (%1, %3), %%mm1 \n\t"
124 "movq 8(%1, %3), %%mm5 \n\t"
125 "movq %%mm0, (%2) \n\t"
126 "movq %%mm4, 8(%2) \n\t"
127 "movq %%mm1, (%2, %3) \n\t"
128 "movq %%mm5, 8(%2, %3) \n\t"
129 "add %%"REG_a", %1 \n\t"
130 "add %%"REG_a", %2 \n\t"
133 : "+g"(h), "+r"(pixels), "+r"(block)
134 : "r"((x86_reg)line_size)
139 #endif /* HAVE_MMX_INLINE */