/usr/include/mapnik/sse.hpp is in libmapnik-dev 3.0.9+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | /*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_SSE_HPP
#define MAPNIK_SSE_HPP
#include <emmintrin.h>
#include <xmmintrin.h>
#define ROUND_DOWN(x, s) ((x) & ~((s)-1))
typedef union
{
__m128i v;
int32_t i32[4];
uint32_t u32[4];
uint16_t u16[8];
uint8_t u8[16];
} m128_int;
static inline __m128i
_mm_cmple_epu16 (__m128i x, __m128i y)
{
// Returns 0xFFFF where x <= y:
return _mm_cmpeq_epi16(_mm_subs_epu16(x, y), _mm_setzero_si128());
}
static inline __m128i
_mm_cmple_epu8 (__m128i x, __m128i y)
{
// Returns 0xFF where x <= y:
return _mm_cmpeq_epi8(_mm_min_epu8(x, y), x);
}
static inline __m128i
_mm_cmpgt_epu16 (__m128i x, __m128i y)
{
// Returns 0xFFFF where x > y:
return _mm_andnot_si128(_mm_cmpeq_epi16(x, y), _mm_cmple_epu16(y, x));
}
static inline __m128i
_mm_cmpgt_epu8 (__m128i x, __m128i y)
{
// Returns 0xFF where x > y:
return _mm_andnot_si128(
_mm_cmpeq_epi8(x, y),
_mm_cmpeq_epi8(_mm_max_epu8(x, y), x)
);
}
static inline __m128i
_mm_cmplt_epu16 (__m128i x, __m128i y)
{
// Returns 0xFFFF where x < y:
return _mm_cmpgt_epu16(y, x);
}
static inline __m128i
_mm_cmplt_epu8 (__m128i x, __m128i y)
{
// Returns 0xFF where x < y:
return _mm_cmpgt_epu8(y, x);
}
static inline __m128i
_mm_cmpge_epu16 (__m128i x, __m128i y)
{
// Returns 0xFFFF where x >= y:
return _mm_cmple_epu16(y, x);
}
static inline __m128i
_mm_cmpge_epu8 (__m128i x, __m128i y)
{
// Returns 0xFF where x >= y:
return _mm_cmple_epu8(y, x);
}
// Its not often that you want to use this!
static inline __m128i
_mm_not_si128 (__m128i x)
{
// Returns ~x, the bitwise complement of x:
return _mm_xor_si128(x, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
}
static inline __m128i
_mm_absdiff_epu16 (__m128i x, __m128i y)
{
// Calculate absolute difference: abs(x - y):
return _mm_or_si128(_mm_subs_epu16(x, y), _mm_subs_epu16(y, x));
}
static inline __m128i
_mm_absdiff_epu8 (__m128i x, __m128i y)
{
// Calculate absolute difference: abs(x - y):
return _mm_or_si128(_mm_subs_epu8(x, y), _mm_subs_epu8(y, x));
}
static inline __m128i
_mm_div255_epu16 (__m128i x)
{
// Divide 8 16-bit uints by 255:
// x := ((x + 1) + (x >> 8)) >> 8:
return _mm_srli_epi16(_mm_adds_epu16(
_mm_adds_epu16(x, _mm_set1_epi16(1)),
_mm_srli_epi16(x, 8)), 8);
}
static __m128i
_mm_scale_epu8 (__m128i x, __m128i y)
{
// Returns an "alpha blend" of x scaled by y/255;
// x := x * (y / 255)
// Reorder: x := (x * y) / 255
// Unpack x and y into 16-bit uints:
__m128i xlo = _mm_unpacklo_epi8(x, _mm_setzero_si128());
__m128i ylo = _mm_unpacklo_epi8(y, _mm_setzero_si128());
__m128i xhi = _mm_unpackhi_epi8(x, _mm_setzero_si128());
__m128i yhi = _mm_unpackhi_epi8(y, _mm_setzero_si128());
// Multiply x with y, keeping the low 16 bits:
xlo = _mm_mullo_epi16(xlo, ylo);
xhi = _mm_mullo_epi16(xhi, yhi);
// Divide by 255:
xlo = _mm_div255_epu16(xlo);
xhi = _mm_div255_epu16(xhi);
// Repack the 16-bit uints to clamped 8-bit values:
return _mm_packus_epi16(xlo, xhi);
}
#endif // MAPNIK_SSE_HPP
|