mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-15 10:42:19 +03:00
Apply clang-format
This commit is contained in:
parent
f5f809196f
commit
2481c6782c
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter3x3f_4u8(Imaging imOut, Imaging im, const float* kernel,
|
||||
float offset)
|
||||
{
|
||||
ImagingFilter3x3f_4u8(Imaging imOut, Imaging im, const float *kernel, float offset) {
|
||||
#define MM_KERNEL1x3_LOAD(row, x) \
|
||||
pix0##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in1[x])); \
|
||||
pix1##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in0[x])); \
|
||||
|
@ -40,22 +38,21 @@ ImagingFilter3x3f_4u8(Imaging imOut, Imaging im, const float* kernel,
|
|||
pix2##row = _mm256_permute2f128_ps(pix2##from0, pix2##from1, control);
|
||||
|
||||
#define MM256_OUT(x) \
|
||||
_mm_cvtps_epi32(_mm_add_ps( \
|
||||
_mm256_extractf128_ps(ss, 0), \
|
||||
_mm256_extractf128_ps(ss, 1) \
|
||||
))
|
||||
_mm_cvtps_epi32( \
|
||||
_mm_add_ps(_mm256_extractf128_ps(ss, 0), _mm256_extractf128_ps(ss, 1)) \
|
||||
)
|
||||
|
||||
__m256 kernel00 = _mm256_insertf128_ps(
|
||||
_mm256_set1_ps(kernel[0+0]),
|
||||
_mm_set1_ps(kernel[0+1]), 1);
|
||||
_mm256_set1_ps(kernel[0 + 0]), _mm_set1_ps(kernel[0 + 1]), 1
|
||||
);
|
||||
__m256 kernel01 = _mm256_castps128_ps256(_mm_set1_ps(kernel[0 + 2]));
|
||||
__m256 kernel10 = _mm256_insertf128_ps(
|
||||
_mm256_set1_ps(kernel[3+0]),
|
||||
_mm_set1_ps(kernel[3+1]), 1);
|
||||
_mm256_set1_ps(kernel[3 + 0]), _mm_set1_ps(kernel[3 + 1]), 1
|
||||
);
|
||||
__m256 kernel11 = _mm256_castps128_ps256(_mm_set1_ps(kernel[3 + 2]));
|
||||
__m256 kernel20 = _mm256_insertf128_ps(
|
||||
_mm256_set1_ps(kernel[6+0]),
|
||||
_mm_set1_ps(kernel[6+1]), 1);
|
||||
_mm256_set1_ps(kernel[6 + 0]), _mm_set1_ps(kernel[6 + 1]), 1
|
||||
);
|
||||
__m256 kernel21 = _mm256_castps128_ps256(_mm_set1_ps(kernel[6 + 2]));
|
||||
__m256 pix00, pix10, pix20;
|
||||
__m256 pix01, pix11, pix21;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter3x3f_u8(Imaging imOut, Imaging im, const float* kernel,
|
||||
float offset)
|
||||
{
|
||||
ImagingFilter3x3f_u8(Imaging imOut, Imaging im, const float *kernel, float offset) {
|
||||
#define MM_KERNEL1x3_SUM1(ss, row, kernel) \
|
||||
ss = _mm_mul_ps(pix0##row, kernel0##kernel); \
|
||||
ss = _mm_add_ps(ss, _mm_mul_ps(pix1##row, kernel1##kernel)); \
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
||||
INT32 offset)
|
||||
{
|
||||
ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16 *kernel, INT32 offset) {
|
||||
int x, y;
|
||||
|
||||
offset += 1 << (PRECISION_BITS - 1);
|
||||
|
@ -17,37 +15,92 @@ ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
#if defined(__AVX2__)
|
||||
|
||||
#define MM_KERNEL_LOAD(x) \
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in1[x]), shuffle)); \
|
||||
source = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in1[x]), shuffle) \
|
||||
); \
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1); \
|
||||
pix00 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256()); \
|
||||
pix01 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256()); \
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in0[x]), shuffle)); \
|
||||
source = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in0[x]), shuffle) \
|
||||
); \
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1); \
|
||||
pix10 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256()); \
|
||||
pix11 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256()); \
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in_1[x]), shuffle)); \
|
||||
source = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in_1[x]), shuffle) \
|
||||
); \
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1); \
|
||||
pix20 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256()); \
|
||||
pix21 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256());
|
||||
|
||||
#define MM_KERNEL_SUM(ss, row, kctl) \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
pix0##row, _mm256_shuffle_epi32(kernel00, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
pix1##row, _mm256_shuffle_epi32(kernel10, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
pix2##row, _mm256_shuffle_epi32(kernel20, kctl)));
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, _mm256_madd_epi16(pix0##row, _mm256_shuffle_epi32(kernel00, kctl)) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, _mm256_madd_epi16(pix1##row, _mm256_shuffle_epi32(kernel10, kctl)) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, _mm256_madd_epi16(pix2##row, _mm256_shuffle_epi32(kernel20, kctl)) \
|
||||
);
|
||||
|
||||
__m128i shuffle = _mm_set_epi8(15,11,14,10,13,9,12,8, 7,3,6,2,5,1,4,0);
|
||||
__m128i shuffle =
|
||||
_mm_set_epi8(15, 11, 14, 10, 13, 9, 12, 8, 7, 3, 6, 2, 5, 1, 4, 0);
|
||||
__m256i kernel00 = _mm256_set_epi16(
|
||||
0, 0, 0, 0, kernel[2], kernel[1], kernel[0], 0,
|
||||
0, 0, 0, 0, 0, kernel[2], kernel[1], kernel[0]);
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[2],
|
||||
kernel[1],
|
||||
kernel[0],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[2],
|
||||
kernel[1],
|
||||
kernel[0]
|
||||
);
|
||||
__m256i kernel10 = _mm256_set_epi16(
|
||||
0, 0, 0, 0, kernel[5], kernel[4], kernel[3], 0,
|
||||
0, 0, 0, 0, 0, kernel[5], kernel[4], kernel[3]);
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[5],
|
||||
kernel[4],
|
||||
kernel[3],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[5],
|
||||
kernel[4],
|
||||
kernel[3]
|
||||
);
|
||||
__m256i kernel20 = _mm256_set_epi16(
|
||||
0, 0, 0, 0, kernel[8], kernel[7], kernel[6], 0,
|
||||
0, 0, 0, 0, 0, kernel[8], kernel[7], kernel[6]);
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[8],
|
||||
kernel[7],
|
||||
kernel[6],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[8],
|
||||
kernel[7],
|
||||
kernel[6]
|
||||
);
|
||||
__m256i pix00, pix10, pix20;
|
||||
__m256i pix01, pix11, pix21;
|
||||
__m256i source;
|
||||
|
@ -76,29 +129,41 @@ ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
|
||||
ss0 = _mm256_packs_epi32(ss0, ss2);
|
||||
ssout = _mm_packus_epi16(
|
||||
_mm256_extracti128_si256(ss0, 0),
|
||||
_mm256_extracti128_si256(ss0, 1));
|
||||
_mm256_extracti128_si256(ss0, 0), _mm256_extracti128_si256(ss0, 1)
|
||||
);
|
||||
ssout = _mm_shuffle_epi32(ssout, 0xd8);
|
||||
_mm_storeu_si128((__m128i *)&out[x], ssout);
|
||||
}
|
||||
for (; x < im->xsize - 1; x++) {
|
||||
__m256i ss = _mm256_set1_epi32(offset);
|
||||
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_or_si128(
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(
|
||||
_mm_or_si128(
|
||||
_mm_slli_si128(_mm_cvtsi32_si128(*(INT32 *)&in1[x + 1]), 8),
|
||||
_mm_loadl_epi64((__m128i*) &in1[x-1])), shuffle));
|
||||
_mm_loadl_epi64((__m128i *)&in1[x - 1])
|
||||
),
|
||||
shuffle
|
||||
));
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1);
|
||||
pix00 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256());
|
||||
pix01 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256());
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_or_si128(
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(
|
||||
_mm_or_si128(
|
||||
_mm_slli_si128(_mm_cvtsi32_si128(*(INT32 *)&in0[x + 1]), 8),
|
||||
_mm_loadl_epi64((__m128i*) &in0[x-1])), shuffle));
|
||||
_mm_loadl_epi64((__m128i *)&in0[x - 1])
|
||||
),
|
||||
shuffle
|
||||
));
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1);
|
||||
pix10 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256());
|
||||
pix11 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256());
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_or_si128(
|
||||
source = _mm256_castsi128_si256(_mm_shuffle_epi8(
|
||||
_mm_or_si128(
|
||||
_mm_slli_si128(_mm_cvtsi32_si128(*(INT32 *)&in_1[x + 1]), 8),
|
||||
_mm_loadl_epi64((__m128i*) &in_1[x-1])), shuffle));
|
||||
_mm_loadl_epi64((__m128i *)&in_1[x - 1])
|
||||
),
|
||||
shuffle
|
||||
));
|
||||
source = _mm256_inserti128_si256(source, _mm256_castsi256_si128(source), 1);
|
||||
pix20 = _mm256_unpacklo_epi8(source, _mm256_setzero_si256());
|
||||
pix21 = _mm256_unpackhi_epi8(source, _mm256_setzero_si256());
|
||||
|
@ -130,23 +195,27 @@ ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
pix21 = _mm_unpackhi_epi8(source, _mm_setzero_si128());
|
||||
|
||||
#define MM_KERNEL_SUM(ss, row, kctl) \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
pix0##row, _mm_shuffle_epi32(kernel00, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
pix1##row, _mm_shuffle_epi32(kernel10, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
pix2##row, _mm_shuffle_epi32(kernel20, kctl)));
|
||||
ss = _mm_add_epi32( \
|
||||
ss, _mm_madd_epi16(pix0##row, _mm_shuffle_epi32(kernel00, kctl)) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, _mm_madd_epi16(pix1##row, _mm_shuffle_epi32(kernel10, kctl)) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, _mm_madd_epi16(pix2##row, _mm_shuffle_epi32(kernel20, kctl)) \
|
||||
);
|
||||
|
||||
__m128i shuffle = _mm_set_epi8(15,11,14,10,13,9,12,8, 7,3,6,2,5,1,4,0);
|
||||
__m128i shuffle =
|
||||
_mm_set_epi8(15, 11, 14, 10, 13, 9, 12, 8, 7, 3, 6, 2, 5, 1, 4, 0);
|
||||
__m128i kernel00 = _mm_set_epi16(
|
||||
kernel[2], kernel[1], kernel[0], 0,
|
||||
0, kernel[2], kernel[1], kernel[0]);
|
||||
kernel[2], kernel[1], kernel[0], 0, 0, kernel[2], kernel[1], kernel[0]
|
||||
);
|
||||
__m128i kernel10 = _mm_set_epi16(
|
||||
kernel[5], kernel[4], kernel[3], 0,
|
||||
0, kernel[5], kernel[4], kernel[3]);
|
||||
kernel[5], kernel[4], kernel[3], 0, 0, kernel[5], kernel[4], kernel[3]
|
||||
);
|
||||
__m128i kernel20 = _mm_set_epi16(
|
||||
kernel[8], kernel[7], kernel[6], 0,
|
||||
0, kernel[8], kernel[7], kernel[6]);
|
||||
kernel[8], kernel[7], kernel[6], 0, 0, kernel[8], kernel[7], kernel[6]
|
||||
);
|
||||
__m128i pix00, pix10, pix20;
|
||||
__m128i pix01, pix11, pix21;
|
||||
__m128i source;
|
||||
|
@ -198,7 +267,8 @@ ImagingFilter3x3i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
pix10 = _mm_unpacklo_epi8(source, _mm_setzero_si128());
|
||||
source = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(int *)&in0[x + 1]), shuffle);
|
||||
pix11 = _mm_unpacklo_epi8(source, _mm_setzero_si128());
|
||||
source = _mm_shuffle_epi8(_mm_loadl_epi64((__m128i*) &in_1[x-1]), shuffle);
|
||||
source =
|
||||
_mm_shuffle_epi8(_mm_loadl_epi64((__m128i *)&in_1[x - 1]), shuffle);
|
||||
pix20 = _mm_unpacklo_epi8(source, _mm_setzero_si128());
|
||||
source = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(int *)&in_1[x + 1]), shuffle);
|
||||
pix21 = _mm_unpacklo_epi8(source, _mm_setzero_si128());
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter5x5f_4u8(Imaging imOut, Imaging im, const float* kernel,
|
||||
float offset)
|
||||
{
|
||||
ImagingFilter5x5f_4u8(Imaging imOut, Imaging im, const float *kernel, float offset) {
|
||||
#define MM_KERNEL1x5_LOAD(row, x) \
|
||||
pix0##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in2[x])); \
|
||||
pix1##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in1[x])); \
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter5x5f_u8(Imaging imOut, Imaging im, const float* kernel,
|
||||
float offset)
|
||||
{
|
||||
ImagingFilter5x5f_u8(Imaging imOut, Imaging im, const float *kernel, float offset) {
|
||||
#define MM_KERNEL1x5_LOAD(row, x) \
|
||||
pix0##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in2[x])); \
|
||||
pix1##row = _mm_cvtepi32_ps(mm_cvtepu8_epi32(&in1[x])); \
|
||||
|
@ -50,19 +48,30 @@ ImagingFilter5x5f_u8(Imaging imOut, Imaging im, const float* kernel,
|
|||
|
||||
MM_KERNEL1x5_LOAD(0, x - 1);
|
||||
MM_KERNEL1x5_SUM(ss0, 0, 0);
|
||||
ss0 = _mm_add_ps(ss0, _mm_mul_ps(
|
||||
ss0 = _mm_add_ps(
|
||||
ss0,
|
||||
_mm_mul_ps(
|
||||
_mm_set_ps(in_1[x - 2], in0[x - 2], in1[x - 2], in2[x - 2]),
|
||||
kernelx0));
|
||||
kernelx0
|
||||
)
|
||||
);
|
||||
|
||||
MM_KERNEL1x5_SUM(ss1, 0, 1);
|
||||
ss1 = _mm_add_ps(ss1, _mm_mul_ps(
|
||||
ss1 = _mm_add_ps(
|
||||
ss1,
|
||||
_mm_mul_ps(
|
||||
_mm_set_ps(in_1[x + 3], in0[x + 3], in1[x + 3], in2[x + 3]),
|
||||
kernelx1));
|
||||
kernelx1
|
||||
)
|
||||
);
|
||||
|
||||
ss0 = _mm_hadd_ps(ss0, ss1);
|
||||
ss0 = _mm_add_ps(ss0, _mm_set_ps(
|
||||
offset, kernel[24] * in_2[x+3],
|
||||
offset, kernel[20] * in_2[x-2]));
|
||||
ss0 = _mm_add_ps(
|
||||
ss0,
|
||||
_mm_set_ps(
|
||||
offset, kernel[24] * in_2[x + 3], offset, kernel[20] * in_2[x - 2]
|
||||
)
|
||||
);
|
||||
ss0 = _mm_hadd_ps(ss0, ss0);
|
||||
ssi0 = _mm_cvtps_epi32(ss0);
|
||||
ssi0 = _mm_packs_epi32(ssi0, ssi0);
|
||||
|
@ -76,12 +85,15 @@ ImagingFilter5x5f_u8(Imaging imOut, Imaging im, const float* kernel,
|
|||
|
||||
MM_KERNEL1x5_LOAD(0, x - 2);
|
||||
MM_KERNEL1x5_SUM(ss0, 0, 1);
|
||||
ss0 = _mm_add_ps(ss0, _mm_mul_ps(
|
||||
ss0 = _mm_add_ps(
|
||||
ss0,
|
||||
_mm_mul_ps(
|
||||
_mm_set_ps(in_1[x + 2], in0[x + 2], in1[x + 2], in2[x + 2]),
|
||||
kernelx1));
|
||||
kernelx1
|
||||
)
|
||||
);
|
||||
|
||||
ss0 = _mm_add_ps(ss0, _mm_set_ps(
|
||||
0, 0, offset, kernel[24] * in_2[x+2]));
|
||||
ss0 = _mm_add_ps(ss0, _mm_set_ps(0, 0, offset, kernel[24] * in_2[x + 2]));
|
||||
ss0 = _mm_hadd_ps(ss0, ss0);
|
||||
ss0 = _mm_hadd_ps(ss0, ss0);
|
||||
ssi0 = _mm_cvtps_epi32(ss0);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
void
|
||||
ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
||||
INT32 offset)
|
||||
{
|
||||
ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16 *kernel, INT32 offset) {
|
||||
int x, y;
|
||||
|
||||
offset += 1 << (PRECISION_BITS - 1);
|
||||
|
@ -18,45 +16,156 @@ ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
#if defined(__AVX2__)
|
||||
|
||||
#define MM_KERNEL_LOAD(row, x) \
|
||||
pix0##row = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in2[x]), shuffle)); \
|
||||
pix0##row = _mm256_inserti128_si256(pix0##row, _mm256_castsi256_si128(pix0##row), 1); \
|
||||
pix1##row = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in1[x]), shuffle)); \
|
||||
pix1##row = _mm256_inserti128_si256(pix1##row, _mm256_castsi256_si128(pix1##row), 1); \
|
||||
pix2##row = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in0[x]), shuffle)); \
|
||||
pix2##row = _mm256_inserti128_si256(pix2##row, _mm256_castsi256_si128(pix2##row), 1); \
|
||||
pix3##row = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in_1[x]), shuffle)); \
|
||||
pix3##row = _mm256_inserti128_si256(pix3##row, _mm256_castsi256_si128(pix3##row), 1); \
|
||||
pix4##row = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_loadu_si128((__m128i*) &in_2[x]), shuffle)); \
|
||||
pix4##row = _mm256_inserti128_si256(pix4##row, _mm256_castsi256_si128(pix4##row), 1);
|
||||
pix0##row = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in2[x]), shuffle) \
|
||||
); \
|
||||
pix0##row = \
|
||||
_mm256_inserti128_si256(pix0##row, _mm256_castsi256_si128(pix0##row), 1); \
|
||||
pix1##row = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in1[x]), shuffle) \
|
||||
); \
|
||||
pix1##row = \
|
||||
_mm256_inserti128_si256(pix1##row, _mm256_castsi256_si128(pix1##row), 1); \
|
||||
pix2##row = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in0[x]), shuffle) \
|
||||
); \
|
||||
pix2##row = \
|
||||
_mm256_inserti128_si256(pix2##row, _mm256_castsi256_si128(pix2##row), 1); \
|
||||
pix3##row = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in_1[x]), shuffle) \
|
||||
); \
|
||||
pix3##row = \
|
||||
_mm256_inserti128_si256(pix3##row, _mm256_castsi256_si128(pix3##row), 1); \
|
||||
pix4##row = _mm256_castsi128_si256( \
|
||||
_mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in_2[x]), shuffle) \
|
||||
); \
|
||||
pix4##row = \
|
||||
_mm256_inserti128_si256(pix4##row, _mm256_castsi256_si128(pix4##row), 1);
|
||||
|
||||
#define MM_KERNEL_SUM(ss, row, unpack_epi8, krow, kctl) \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
unpack_epi8(pix0##row, zero), _mm256_shuffle_epi32(kernel0##krow, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
unpack_epi8(pix1##row, zero), _mm256_shuffle_epi32(kernel1##krow, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
unpack_epi8(pix2##row, zero), _mm256_shuffle_epi32(kernel2##krow, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
unpack_epi8(pix3##row, zero), _mm256_shuffle_epi32(kernel3##krow, kctl))); \
|
||||
ss = _mm256_add_epi32(ss, _mm256_madd_epi16( \
|
||||
unpack_epi8(pix4##row, zero), _mm256_shuffle_epi32(kernel4##krow, kctl)));
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, \
|
||||
_mm256_madd_epi16( \
|
||||
unpack_epi8(pix0##row, zero), _mm256_shuffle_epi32(kernel0##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, \
|
||||
_mm256_madd_epi16( \
|
||||
unpack_epi8(pix1##row, zero), _mm256_shuffle_epi32(kernel1##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, \
|
||||
_mm256_madd_epi16( \
|
||||
unpack_epi8(pix2##row, zero), _mm256_shuffle_epi32(kernel2##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, \
|
||||
_mm256_madd_epi16( \
|
||||
unpack_epi8(pix3##row, zero), _mm256_shuffle_epi32(kernel3##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm256_add_epi32( \
|
||||
ss, \
|
||||
_mm256_madd_epi16( \
|
||||
unpack_epi8(pix4##row, zero), _mm256_shuffle_epi32(kernel4##krow, kctl) \
|
||||
) \
|
||||
);
|
||||
|
||||
__m128i shuffle = _mm_set_epi8(15,11,14,10,13,9,12,8, 7,3,6,2,5,1,4,0);
|
||||
__m128i shuffle =
|
||||
_mm_set_epi8(15, 11, 14, 10, 13, 9, 12, 8, 7, 3, 6, 2, 5, 1, 4, 0);
|
||||
__m256i kernel00 = _mm256_set_epi16(
|
||||
0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0], 0,
|
||||
0, 0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0]);
|
||||
0,
|
||||
0,
|
||||
kernel[4],
|
||||
kernel[3],
|
||||
kernel[2],
|
||||
kernel[1],
|
||||
kernel[0],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[4],
|
||||
kernel[3],
|
||||
kernel[2],
|
||||
kernel[1],
|
||||
kernel[0]
|
||||
);
|
||||
__m256i kernel10 = _mm256_set_epi16(
|
||||
0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5], 0,
|
||||
0, 0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5]);
|
||||
0,
|
||||
0,
|
||||
kernel[9],
|
||||
kernel[8],
|
||||
kernel[7],
|
||||
kernel[6],
|
||||
kernel[5],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[9],
|
||||
kernel[8],
|
||||
kernel[7],
|
||||
kernel[6],
|
||||
kernel[5]
|
||||
);
|
||||
__m256i kernel20 = _mm256_set_epi16(
|
||||
0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10], 0,
|
||||
0, 0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10]);
|
||||
0,
|
||||
0,
|
||||
kernel[14],
|
||||
kernel[13],
|
||||
kernel[12],
|
||||
kernel[11],
|
||||
kernel[10],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[14],
|
||||
kernel[13],
|
||||
kernel[12],
|
||||
kernel[11],
|
||||
kernel[10]
|
||||
);
|
||||
__m256i kernel30 = _mm256_set_epi16(
|
||||
0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15], 0,
|
||||
0, 0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15]);
|
||||
0,
|
||||
0,
|
||||
kernel[19],
|
||||
kernel[18],
|
||||
kernel[17],
|
||||
kernel[16],
|
||||
kernel[15],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[19],
|
||||
kernel[18],
|
||||
kernel[17],
|
||||
kernel[16],
|
||||
kernel[15]
|
||||
);
|
||||
__m256i kernel40 = _mm256_set_epi16(
|
||||
0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20], 0,
|
||||
0, 0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20]);
|
||||
0,
|
||||
0,
|
||||
kernel[24],
|
||||
kernel[23],
|
||||
kernel[22],
|
||||
kernel[21],
|
||||
kernel[20],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
kernel[24],
|
||||
kernel[23],
|
||||
kernel[22],
|
||||
kernel[21],
|
||||
kernel[20]
|
||||
);
|
||||
__m256i zero = _mm256_setzero_si256();
|
||||
__m256i pix00, pix10, pix20, pix30, pix40;
|
||||
__m256i pix01, pix11, pix21, pix31, pix41;
|
||||
|
@ -93,8 +202,8 @@ ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
|
||||
ss0 = _mm256_packs_epi32(ss0, ss2);
|
||||
ssout = _mm_packus_epi16(
|
||||
_mm256_extracti128_si256(ss0, 0),
|
||||
_mm256_extracti128_si256(ss0, 1));
|
||||
_mm256_extracti128_si256(ss0, 0), _mm256_extracti128_si256(ss0, 1)
|
||||
);
|
||||
ssout = _mm_shuffle_epi32(ssout, 0xd8);
|
||||
_mm_storeu_si128((__m128i *)&out[x], ssout);
|
||||
}
|
||||
|
@ -102,15 +211,25 @@ ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
__m256i ss0;
|
||||
|
||||
MM_KERNEL_LOAD(0, x - 2);
|
||||
pix01 = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in2[x+2]), shuffle));
|
||||
pix01 = _mm256_castsi128_si256(
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in2[x + 2]), shuffle)
|
||||
);
|
||||
pix01 = _mm256_inserti128_si256(pix01, _mm256_castsi256_si128(pix01), 1);
|
||||
pix11 = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in1[x+2]), shuffle));
|
||||
pix11 = _mm256_castsi128_si256(
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in1[x + 2]), shuffle)
|
||||
);
|
||||
pix11 = _mm256_inserti128_si256(pix11, _mm256_castsi256_si128(pix11), 1);
|
||||
pix21 = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in0[x+2]), shuffle));
|
||||
pix21 = _mm256_castsi128_si256(
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in0[x + 2]), shuffle)
|
||||
);
|
||||
pix21 = _mm256_inserti128_si256(pix21, _mm256_castsi256_si128(pix21), 1);
|
||||
pix31 = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in_1[x+2]), shuffle));
|
||||
pix31 = _mm256_castsi128_si256(
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in_1[x + 2]), shuffle)
|
||||
);
|
||||
pix31 = _mm256_inserti128_si256(pix31, _mm256_castsi256_si128(pix31), 1);
|
||||
pix41 = _mm256_castsi128_si256(_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in_2[x+2]), shuffle));
|
||||
pix41 = _mm256_castsi128_si256(
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in_2[x + 2]), shuffle)
|
||||
);
|
||||
pix41 = _mm256_inserti128_si256(pix41, _mm256_castsi256_si128(pix41), 1);
|
||||
|
||||
ss0 = _mm256_set1_epi32(offset);
|
||||
|
@ -138,38 +257,69 @@ ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
pix4##row = _mm_shuffle_epi8(_mm_loadu_si128((__m128i *)&in_2[x]), shuffle);
|
||||
|
||||
#define MM_KERNEL_SUM(ss, row, unpack_epi8, krow, kctl) \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
unpack_epi8(pix0##row, zero), _mm_shuffle_epi32(kernel0##krow, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
unpack_epi8(pix1##row, zero), _mm_shuffle_epi32(kernel1##krow, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
unpack_epi8(pix2##row, zero), _mm_shuffle_epi32(kernel2##krow, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
unpack_epi8(pix3##row, zero), _mm_shuffle_epi32(kernel3##krow, kctl))); \
|
||||
ss = _mm_add_epi32(ss, _mm_madd_epi16( \
|
||||
unpack_epi8(pix4##row, zero), _mm_shuffle_epi32(kernel4##krow, kctl)));
|
||||
ss = _mm_add_epi32( \
|
||||
ss, \
|
||||
_mm_madd_epi16( \
|
||||
unpack_epi8(pix0##row, zero), _mm_shuffle_epi32(kernel0##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, \
|
||||
_mm_madd_epi16( \
|
||||
unpack_epi8(pix1##row, zero), _mm_shuffle_epi32(kernel1##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, \
|
||||
_mm_madd_epi16( \
|
||||
unpack_epi8(pix2##row, zero), _mm_shuffle_epi32(kernel2##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, \
|
||||
_mm_madd_epi16( \
|
||||
unpack_epi8(pix3##row, zero), _mm_shuffle_epi32(kernel3##krow, kctl) \
|
||||
) \
|
||||
); \
|
||||
ss = _mm_add_epi32( \
|
||||
ss, \
|
||||
_mm_madd_epi16( \
|
||||
unpack_epi8(pix4##row, zero), _mm_shuffle_epi32(kernel4##krow, kctl) \
|
||||
) \
|
||||
);
|
||||
|
||||
__m128i shuffle = _mm_set_epi8(15,11,14,10,13,9,12,8, 7,3,6,2,5,1,4,0);
|
||||
__m128i shuffle =
|
||||
_mm_set_epi8(15, 11, 14, 10, 13, 9, 12, 8, 7, 3, 6, 2, 5, 1, 4, 0);
|
||||
__m128i kernel00 = _mm_set_epi16(
|
||||
0, 0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0]);
|
||||
0, 0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0]
|
||||
);
|
||||
__m128i kernel10 = _mm_set_epi16(
|
||||
0, 0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5]);
|
||||
0, 0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5]
|
||||
);
|
||||
__m128i kernel20 = _mm_set_epi16(
|
||||
0, 0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10]);
|
||||
0, 0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10]
|
||||
);
|
||||
__m128i kernel30 = _mm_set_epi16(
|
||||
0, 0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15]);
|
||||
0, 0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15]
|
||||
);
|
||||
__m128i kernel40 = _mm_set_epi16(
|
||||
0, 0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20]);
|
||||
0, 0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20]
|
||||
);
|
||||
__m128i kernel01 = _mm_set_epi16(
|
||||
0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0], 0);
|
||||
0, 0, kernel[4], kernel[3], kernel[2], kernel[1], kernel[0], 0
|
||||
);
|
||||
__m128i kernel11 = _mm_set_epi16(
|
||||
0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5], 0);
|
||||
0, 0, kernel[9], kernel[8], kernel[7], kernel[6], kernel[5], 0
|
||||
);
|
||||
__m128i kernel21 = _mm_set_epi16(
|
||||
0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10], 0);
|
||||
0, 0, kernel[14], kernel[13], kernel[12], kernel[11], kernel[10], 0
|
||||
);
|
||||
__m128i kernel31 = _mm_set_epi16(
|
||||
0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15], 0);
|
||||
0, 0, kernel[19], kernel[18], kernel[17], kernel[16], kernel[15], 0
|
||||
);
|
||||
__m128i kernel41 = _mm_set_epi16(
|
||||
0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20], 0);
|
||||
0, 0, kernel[24], kernel[23], kernel[22], kernel[21], kernel[20], 0
|
||||
);
|
||||
__m128i zero = _mm_setzero_si128();
|
||||
__m128i pix00, pix10, pix20, pix30, pix40;
|
||||
__m128i pix01, pix11, pix21, pix31, pix41;
|
||||
|
@ -225,8 +375,10 @@ ImagingFilter5x5i_4u8(Imaging imOut, Imaging im, const INT16* kernel,
|
|||
pix01 = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in2[x + 2]), shuffle);
|
||||
pix11 = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in1[x + 2]), shuffle);
|
||||
pix21 = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in0[x + 2]), shuffle);
|
||||
pix31 = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in_1[x+2]), shuffle);
|
||||
pix41 = _mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32*) &in_2[x+2]), shuffle);
|
||||
pix31 =
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in_1[x + 2]), shuffle);
|
||||
pix41 =
|
||||
_mm_shuffle_epi8(_mm_cvtsi32_si128(*(INT32 *)&in_2[x + 2]), shuffle);
|
||||
|
||||
ss0 = _mm_set1_epi32(offset);
|
||||
MM_KERNEL_SUM(ss0, 0, _mm_unpacklo_epi8, 0, 0x00);
|
||||
|
|
Loading…
Reference in New Issue
Block a user