2001-07-22 16:18:56 +02:00
|
|
|
/*
|
|
|
|
* MMX optimized DSP utils
|
2009-01-19 16:46:40 +01:00
|
|
|
* Copyright (c) 2000, 2001 Fabrice Bellard
|
2004-01-10 17:04:55 +01:00
|
|
|
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2012-03-06 13:00:42 +01:00
|
|
|
* MMX optimization by Nick Kurshev <nickols_k@mail.ru>
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* This file is part of Libav.
|
2006-10-07 17:30:46 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2002-05-26 00:45:33 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 17:30:46 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2001-07-22 16:18:56 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2002-05-26 00:45:33 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-07-22 16:18:56 +02:00
|
|
|
*
|
2002-05-26 00:45:33 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2011-03-18 18:35:10 +01:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2006-01-12 23:43:26 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-07-22 16:18:56 +02:00
|
|
|
*/
|
|
|
|
|
2013-05-08 01:45:39 +02:00
|
|
|
#include "config.h"
|
2010-09-04 11:59:08 +02:00
|
|
|
#include "libavutil/cpu.h"
|
2012-08-08 14:51:52 +02:00
|
|
|
#include "libavutil/x86/asm.h"
|
2013-05-08 01:52:57 +02:00
|
|
|
#include "dsputil_x86.h"
|
2014-01-27 15:06:54 +01:00
|
|
|
#include "inline_asm.h"
|
2013-01-27 04:45:43 +01:00
|
|
|
|
2012-07-22 23:14:20 +02:00
|
|
|
#if HAVE_INLINE_ASM
|
|
|
|
|
2012-03-06 13:00:42 +01:00
|
|
|
/* Draw the edges of width 'w' of an image of size width, height
|
|
|
|
* this MMX version can only handle w == 8 || w == 16. */
|
2013-05-08 01:45:39 +02:00
|
|
|
void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
|
|
|
|
int w, int h, int sides)
|
2008-03-04 01:07:41 +01:00
|
|
|
{
|
|
|
|
uint8_t *ptr, *last_line;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
last_line = buf + (height - 1) * wrap;
|
|
|
|
/* left and right */
|
|
|
|
ptr = buf;
|
2012-03-06 13:00:42 +01:00
|
|
|
if (w == 8) {
|
2012-03-16 18:42:01 +01:00
|
|
|
__asm__ volatile (
|
|
|
|
"1: \n\t"
|
|
|
|
"movd (%0), %%mm0 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm0 \n\t"
|
|
|
|
"punpcklwd %%mm0, %%mm0 \n\t"
|
|
|
|
"punpckldq %%mm0, %%mm0 \n\t"
|
|
|
|
"movq %%mm0, -8(%0) \n\t"
|
|
|
|
"movq -8(%0, %2), %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm1, %%mm1 \n\t"
|
|
|
|
"punpckhwd %%mm1, %%mm1 \n\t"
|
|
|
|
"punpckhdq %%mm1, %%mm1 \n\t"
|
|
|
|
"movq %%mm1, (%0, %2) \n\t"
|
|
|
|
"add %1, %0 \n\t"
|
|
|
|
"cmp %3, %0 \n\t"
|
|
|
|
"jb 1b \n\t"
|
2013-12-25 15:49:31 +01:00
|
|
|
: "+r" (ptr)
|
|
|
|
: "r" ((x86_reg) wrap), "r" ((x86_reg) width),
|
|
|
|
"r" (ptr + wrap * height));
|
2012-03-06 13:00:42 +01:00
|
|
|
} else {
|
2012-03-16 18:42:01 +01:00
|
|
|
__asm__ volatile (
|
|
|
|
"1: \n\t"
|
|
|
|
"movd (%0), %%mm0 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm0 \n\t"
|
|
|
|
"punpcklwd %%mm0, %%mm0 \n\t"
|
|
|
|
"punpckldq %%mm0, %%mm0 \n\t"
|
|
|
|
"movq %%mm0, -8(%0) \n\t"
|
|
|
|
"movq %%mm0, -16(%0) \n\t"
|
|
|
|
"movq -8(%0, %2), %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm1, %%mm1 \n\t"
|
|
|
|
"punpckhwd %%mm1, %%mm1 \n\t"
|
|
|
|
"punpckhdq %%mm1, %%mm1 \n\t"
|
|
|
|
"movq %%mm1, (%0, %2) \n\t"
|
|
|
|
"movq %%mm1, 8(%0, %2) \n\t"
|
|
|
|
"add %1, %0 \n\t"
|
|
|
|
"cmp %3, %0 \n\t"
|
|
|
|
"jb 1b \n\t"
|
2013-12-25 15:49:31 +01:00
|
|
|
: "+r" (ptr)
|
|
|
|
: "r" ((x86_reg) wrap), "r" ((x86_reg) width),
|
|
|
|
"r" (ptr + wrap * height));
|
2008-03-04 01:07:41 +01:00
|
|
|
}
|
|
|
|
|
2011-03-26 22:31:13 +01:00
|
|
|
/* top and bottom (and hopefully also the corners) */
|
2012-03-06 13:00:42 +01:00
|
|
|
if (sides & EDGE_TOP) {
|
|
|
|
for (i = 0; i < h; i += 4) {
|
|
|
|
ptr = buf - (i + 1) * wrap - w;
|
2012-03-16 18:42:01 +01:00
|
|
|
__asm__ volatile (
|
|
|
|
"1: \n\t"
|
|
|
|
"movq (%1, %0), %%mm0 \n\t"
|
|
|
|
"movq %%mm0, (%0) \n\t"
|
|
|
|
"movq %%mm0, (%0, %2) \n\t"
|
|
|
|
"movq %%mm0, (%0, %2, 2) \n\t"
|
|
|
|
"movq %%mm0, (%0, %3) \n\t"
|
|
|
|
"add $8, %0 \n\t"
|
|
|
|
"cmp %4, %0 \n\t"
|
|
|
|
"jb 1b \n\t"
|
2013-12-25 15:49:31 +01:00
|
|
|
: "+r" (ptr)
|
|
|
|
: "r" ((x86_reg) buf - (x86_reg) ptr - w),
|
|
|
|
"r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3),
|
|
|
|
"r" (ptr + width + 2 * w));
|
2011-03-26 22:31:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:00:42 +01:00
|
|
|
if (sides & EDGE_BOTTOM) {
|
|
|
|
for (i = 0; i < h; i += 4) {
|
|
|
|
ptr = last_line + (i + 1) * wrap - w;
|
2012-03-16 18:42:01 +01:00
|
|
|
__asm__ volatile (
|
|
|
|
"1: \n\t"
|
|
|
|
"movq (%1, %0), %%mm0 \n\t"
|
|
|
|
"movq %%mm0, (%0) \n\t"
|
|
|
|
"movq %%mm0, (%0, %2) \n\t"
|
|
|
|
"movq %%mm0, (%0, %2, 2) \n\t"
|
|
|
|
"movq %%mm0, (%0, %3) \n\t"
|
|
|
|
"add $8, %0 \n\t"
|
|
|
|
"cmp %4, %0 \n\t"
|
|
|
|
"jb 1b \n\t"
|
2013-12-25 15:49:31 +01:00
|
|
|
: "+r" (ptr)
|
|
|
|
: "r" ((x86_reg) last_line - (x86_reg) ptr - w),
|
|
|
|
"r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3),
|
|
|
|
"r" (ptr + width + 2 * w));
|
2011-03-26 22:31:13 +01:00
|
|
|
}
|
2008-03-04 01:07:41 +01:00
|
|
|
}
|
|
|
|
}
|
2003-01-05 16:57:10 +01:00
|
|
|
|
2012-07-22 23:14:20 +02:00
|
|
|
#endif /* HAVE_INLINE_ASM */
|