/* * Copyright (c) 2020, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
uint64_t aom_sum_squares_2d_i16_neon(const int16_t *src, int stride, int width, int height) { // 4 elements per row only requires half an SIMD register, so this // must be a special case, but also note that over 75% of all calls // are with size == 4, so it is also the common case. if (LIKELY(width == 4 && height == 4)) { return aom_sum_squares_2d_i16_4x4_neon(src, stride);
} elseif (LIKELY(width == 4 && (height & 3) == 0)) { return aom_sum_squares_2d_i16_4xn_neon(src, stride, height);
} elseif (LIKELY((width & 7) == 0 && (height & 3) == 0)) { // Generic case return aom_sum_squares_2d_i16_nxn_neon(src, stride, width, height);
} else { return aom_sum_squares_2d_i16_c(src, stride, width, height);
}
}
if (i > 0) { return horizontal_add_u64x2(vaddq_u64(sum_u64[0], sum_u64[1])) +
aom_sum_squares_i16_c(src, i);
} return horizontal_add_u64x2(vaddq_u64(sum_u64[0], sum_u64[1]));
}
uint64_t aom_sum_squares_i16_neon(const int16_t *src, uint32_t n) { // This function seems to be called only for values of N >= 64. See // av1/encoder/compound_type.c. if (LIKELY(n >= 8)) { return aom_sum_squares_i16_8xn_neon(src, n);
} if (n >= 4) { return aom_sum_squares_i16_4xn_neon(src, n);
} return aom_sum_squares_i16_c(src, n);
}
staticinline uint64_t aom_var_2d_u8_4xh_neon(uint8_t *src, int src_stride, int width, int height) {
uint64_t sum = 0;
uint64_t sse = 0;
uint32x2_t sum_u32 = vdup_n_u32(0);
uint32x4_t sse_u32 = vdupq_n_u32(0);
// 255*256 = 65280, so we can accumulate up to 256 8-bit elements in a 16-bit // element before we need to accumulate to 32-bit elements. Since we're // accumulating in uint16x4_t vectors, this means we can accumulate up to 4 // rows of 256 elements. Therefore the limit can be computed as: h_limit = (4 // * 256) / width. int h_limit = (4 * 256) / width; int h_tmp = height > h_limit ? h_limit : height;
int h = 0; do {
uint16x4_t sum_u16 = vdup_n_u16(0); do {
uint8_t *src_ptr = src; int w = width; do {
uint8x8_t s0 = load_unaligned_u8(src_ptr, src_stride);
sum_u16 = vpadal_u8(sum_u16, s0);
uint16x8_t sse_u16 = vmull_u8(s0, s0);
sse_u32 = vpadalq_u16(sse_u32, sse_u16);
src_ptr += 8;
w -= 8;
} while (w >= 8);
// Process remaining columns in the row using C. while (w > 0) { int idx = width - w; const uint8_t v = src[idx];
sum += v;
sse += v * v;
w--;
}
src += 2 * src_stride;
h += 2;
} while (h < h_tmp && h < height);
sum += horizontal_long_add_u32x2(sum_u32);
sse += horizontal_long_add_u32x4(sse_u32);
return sse - sum * sum / (width * height);
}
staticinline uint64_t aom_var_2d_u8_8xh_neon(uint8_t *src, int src_stride, int width, int height) {
uint64_t sum = 0;
uint64_t sse = 0;
uint32x2_t sum_u32 = vdup_n_u32(0);
uint32x4_t sse_u32 = vdupq_n_u32(0);
// 255*256 = 65280, so we can accumulate up to 256 8-bit elements in a 16-bit // element before we need to accumulate to 32-bit elements. Since we're // accumulating in uint16x4_t vectors, this means we can accumulate up to 4 // rows of 256 elements. Therefore the limit can be computed as: h_limit = (4 // * 256) / width. int h_limit = (4 * 256) / width; int h_tmp = height > h_limit ? h_limit : height;
int h = 0; do {
uint16x4_t sum_u16 = vdup_n_u16(0); do {
uint8_t *src_ptr = src; int w = width; do {
uint8x8_t s0 = vld1_u8(src_ptr);
sum_u16 = vpadal_u8(sum_u16, s0);
uint16x8_t sse_u16 = vmull_u8(s0, s0);
sse_u32 = vpadalq_u16(sse_u32, sse_u16);
src_ptr += 8;
w -= 8;
} while (w >= 8);
// Process remaining columns in the row using C. while (w > 0) { int idx = width - w; const uint8_t v = src[idx];
sum += v;
sse += v * v;
w--;
}
src += src_stride;
++h;
} while (h < h_tmp && h < height);
sum += horizontal_long_add_u32x2(sum_u32);
sse += horizontal_long_add_u32x4(sse_u32);
return sse - sum * sum / (width * height);
}
staticinline uint64_t aom_var_2d_u8_16xh_neon(uint8_t *src, int src_stride, int width, int height) {
uint64_t sum = 0;
uint64_t sse = 0;
uint32x4_t sum_u32 = vdupq_n_u32(0);
uint32x4_t sse_u32[2] = { vdupq_n_u32(0), vdupq_n_u32(0) };
// 255*256 = 65280, so we can accumulate up to 256 8-bit elements in a 16-bit // element before we need to accumulate to 32-bit elements. Since we're // accumulating in uint16x8_t vectors, this means we can accumulate up to 8 // rows of 256 elements. Therefore the limit can be computed as: h_limit = (8 // * 256) / width. int h_limit = (8 * 256) / width; int h_tmp = height > h_limit ? h_limit : height;
int h = 0; do {
uint16x8_t sum_u16 = vdupq_n_u16(0); do { int w = width;
uint8_t *src_ptr = src; do {
uint8x16_t s0 = vld1q_u8(src_ptr);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.