Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
27 //Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
33 #include <liboil/liboilfunction.h>
34 #include "liboil/simdpack/simdpack.h"
36 OIL_DECLARE_CLASS (recon8x8_intra);
37 OIL_DECLARE_CLASS (recon8x8_inter);
38 OIL_DECLARE_CLASS (recon8x8_inter2);
40 const uint8_t c0x80[8] = {
41 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
45 recon8x8_intra_i386_mmx (uint8_t *dest, int ds, int16_t *change)
47 #if !defined(__WINSCW__) && !defined(__WINS__)
48 __asm__ __volatile__ (
49 " movq (%3), %%mm0 \n\t" /* Set mm0 to 0x8080808080808080 */
51 " lea 128(%1), %%edi \n\t" /* Endpoint in input buffer */
53 " movq (%1), %%mm2 \n\t" /* First four input values */
55 " packsswb 8(%1), %%mm2 \n\t" /* pack with next(high) four values */
56 " por %%mm0, %%mm0 \n\t"
57 " pxor %%mm0, %%mm2 \n\t" /* Convert result to unsigned (same as add 128) */
58 " lea 16(%1), %1 \n\t" /* Step source buffer */
59 " cmp %%edi, %1 \n\t" /* are we done */
61 " movq %%mm2, (%0) \n\t" /* store results */
63 " lea (%0, %2), %0 \n\t" /* Step output buffer */
64 " jc 1b \n\t" /* Loop back if we are not done */
75 OIL_DEFINE_IMPL_FULL (recon8x8_intra_i386_mmx, recon8x8_intra, OIL_IMPL_FLAG_MMX);
79 recon8x8_inter_i386_mmx (uint8_t *dest, int ds, uint8_t *src, int ss, int16_t *change)
81 /* FIXME doesn't handle ss */
82 __asm__ __volatile__ (
83 " pxor %%mm0, %%mm0 \n\t"
84 " lea 128(%1), %%edi \n\t"
87 " movq (%2), %%mm2 \n\t" /* (+3 misaligned) 8 reference pixels */
89 " movq (%1), %%mm4 \n\t" /* first 4 changes */
90 " movq %%mm2, %%mm3 \n\t"
91 " movq 8(%1), %%mm5 \n\t" /* last 4 changes */
92 " punpcklbw %%mm0, %%mm2 \n\t" /* turn first 4 refs into positive 16-bit #s */
93 " paddsw %%mm4, %%mm2 \n\t" /* add in first 4 changes */
94 " punpckhbw %%mm0, %%mm3 \n\t" /* turn last 4 refs into positive 16-bit #s */
95 " paddsw %%mm5, %%mm3 \n\t" /* add in last 4 changes */
96 " add %3, %2 \n\t" /* next row of reference pixels */
97 " packuswb %%mm3, %%mm2 \n\t" /* pack result to unsigned 8-bit values */
98 " lea 16(%1), %1 \n\t" /* next row of changes */
99 " cmp %%edi, %1 \n\t" /* are we done? */
101 " movq %%mm2, (%0) \n\t" /* store result */
103 " lea (%0, %3), %0 \n\t" /* next row of output */
114 OIL_DEFINE_IMPL_FULL (recon8x8_inter_i386_mmx, recon8x8_inter, OIL_IMPL_FLAG_MMX);
117 recon8x8_inter2_i386_mmx (uint8_t *dest, int ds, uint8_t *s1, int ss1, uint8_t *s2, int ss2, int16_t *change)
119 /* FIXME doesn't handle ss1, ss2 */
120 __asm__ __volatile__ (
121 " pxor %%mm0, %%mm0 \n\t"
122 " lea 128(%1), %%edi \n\t"
125 " movq (%2), %%mm2 \n\t" /* (+3 misaligned) 8 reference pixels */
126 " movq (%3), %%mm4 \n\t" /* (+3 misaligned) 8 reference pixels */
128 " movq %%mm2, %%mm3 \n\t"
129 " punpcklbw %%mm0, %%mm2 \n\t" /* mm2 = start ref1 as positive 16-bit #s */
130 " movq %%mm4, %%mm5 \n\t"
131 " movq (%1), %%mm6 \n\t" /* first 4 changes */
132 " punpckhbw %%mm0, %%mm3 \n\t" /* mm3 = end ref1 as positive 16-bit #s */
133 " movq 8(%1), %%mm7 \n\t" /* last 4 changes */
134 " punpcklbw %%mm0, %%mm4 \n\t" /* mm4 = start ref2 as positive 16-bit #s */
135 " punpckhbw %%mm0, %%mm5 \n\t" /* mm5 = end ref2 as positive 16-bit #s */
136 " paddw %%mm4, %%mm2 \n\t" /* mm2 = start (ref1 + ref2) */
137 " paddw %%mm5, %%mm3 \n\t" /* mm3 = end (ref1 + ref2) */
138 " psrlw $1, %%mm2 \n\t" /* mm2 = start (ref1 + ref2)/2 */
139 " psrlw $1, %%mm3 \n\t" /* mm3 = end (ref1 + ref2)/2 */
140 " paddw %%mm6, %%mm2 \n\t" /* add changes to start */
141 " paddw %%mm7, %%mm3 \n\t" /* add changes to end */
142 " lea 16(%1), %1 \n\t" /* next row of changes */
143 " packuswb %%mm3, %%mm2 \n\t" /* pack start|end to unsigned 8-bit */
144 " add %4, %2 \n\t" /* next row of reference pixels */
145 " add %4, %3 \n\t" /* next row of reference pixels */
146 " movq %%mm2, (%0) \n\t" /* store result */
147 " add %4, %0 \n\t" /* next row of output */
148 " cmp %%edi, %1 \n\t" /* are we done? */
160 OIL_DEFINE_IMPL_FULL (recon8x8_inter2_i386_mmx, recon8x8_inter2, OIL_IMPL_FLAG_MMX);
166 OilFunctionImpl* __oil_function_impl_recon8x8_intra_i386_mmx, recon8x8_intra() {
167 return &_oil_function_impl_recon8x8_intra_i386_mmx, recon8x8_intra;
173 OilFunctionImpl* __oil_function_impl_recon8x8_inter_i386_mmx, recon8x8_inter() {
174 return &_oil_function_impl_recon8x8_inter_i386_mmx, recon8x8_inter;
180 OilFunctionImpl* __oil_function_impl_recon8x8_inter2_i386_mmx, recon8x8_inter2() {
181 return &_oil_function_impl_recon8x8_inter2_i386_mmx, recon8x8_inter2;