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 Libav.
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.
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.
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
29 #include "inline_asm.h"
33 // in case more speed is needed - unrolling would certainly help
34 void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
35 ptrdiff_t line_size, int h)
43 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
54 void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
55 ptrdiff_t line_size, int h)
63 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
65 "movq 8%0, %%mm0 \n\t"
66 "movq 8%1, %%mm1 \n\t"
67 PAVGB_MMX(%%mm0, %%mm1, %%mm2, %%mm6)
68 "movq %%mm2, 8%0 \n\t"
78 void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
79 ptrdiff_t line_size, int h)
82 "lea (%3, %3), %%"FF_REG_a" \n\t"
85 "movq (%1 ), %%mm0 \n\t"
86 "movq (%1, %3), %%mm1 \n\t"
87 "movq %%mm0, (%2) \n\t"
88 "movq %%mm1, (%2, %3) \n\t"
89 "add %%"FF_REG_a", %1 \n\t"
90 "add %%"FF_REG_a", %2 \n\t"
91 "movq (%1 ), %%mm0 \n\t"
92 "movq (%1, %3), %%mm1 \n\t"
93 "movq %%mm0, (%2) \n\t"
94 "movq %%mm1, (%2, %3) \n\t"
95 "add %%"FF_REG_a", %1 \n\t"
96 "add %%"FF_REG_a", %2 \n\t"
99 : "+g"(h), "+r"(pixels), "+r"(block)
100 : "r"((x86_reg)line_size)
101 : "%"FF_REG_a, "memory"
105 void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
106 ptrdiff_t line_size, int h)
109 "lea (%3, %3), %%"FF_REG_a" \n\t"
112 "movq (%1 ), %%mm0 \n\t"
113 "movq 8(%1 ), %%mm4 \n\t"
114 "movq (%1, %3), %%mm1 \n\t"
115 "movq 8(%1, %3), %%mm5 \n\t"
116 "movq %%mm0, (%2) \n\t"
117 "movq %%mm4, 8(%2) \n\t"
118 "movq %%mm1, (%2, %3) \n\t"
119 "movq %%mm5, 8(%2, %3) \n\t"
120 "add %%"FF_REG_a", %1 \n\t"
121 "add %%"FF_REG_a", %2 \n\t"
122 "movq (%1 ), %%mm0 \n\t"
123 "movq 8(%1 ), %%mm4 \n\t"
124 "movq (%1, %3), %%mm1 \n\t"
125 "movq 8(%1, %3), %%mm5 \n\t"
126 "movq %%mm0, (%2) \n\t"
127 "movq %%mm4, 8(%2) \n\t"
128 "movq %%mm1, (%2, %3) \n\t"
129 "movq %%mm5, 8(%2, %3) \n\t"
130 "add %%"FF_REG_a", %1 \n\t"
131 "add %%"FF_REG_a", %2 \n\t"
134 : "+g"(h), "+r"(pixels), "+r"(block)
135 : "r"((x86_reg)line_size)
136 : "%"FF_REG_a, "memory"
140 #endif /* HAVE_MMX_INLINE */