/* * 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.
*/
// Process horizontal and vertical correlations in a 4x4 block of pixels. // We actually use the 4x4 pixels to calculate correlations corresponding to // the top-left 3x3 pixels, so this function must be called with 1x1 overlap, // moving the window along/down by 3 pixels at a time. staticinlinevoid horver_correlation_4x4(const int16_t *diff, int stride,
int32x4_t *xy_sum_32,
int32x4_t *xz_sum_32,
int32x4_t *x_sum_32,
int32x4_t *x2_sum_32) { // Pixels in this 4x4 [ a b c d ] // are referred to as: [ e f g h ] // [ i j k l ] // [ m n o p ]
// Now calculate the straight sums, x_sum += a+b+c+e+f+g+i+j+k // (sum up every element in slli_a and swap_b)
*x_sum_32 = vpadalq_s16(*x_sum_32, slli_a);
*x_sum_32 = vaddw_s16(*x_sum_32, pixelsb_2_sli);
// Also sum their squares
*x2_sum_32 = vmlal_s16(*x2_sum_32, pixelsa_1_sli, pixelsa_1_sli);
*x2_sum_32 = vmlal_s16(*x2_sum_32, pixelsa_2_sli, pixelsa_2_sli);
*x2_sum_32 = vmlal_s16(*x2_sum_32, pixelsb_2_sli, pixelsb_2_sli);
}
void av1_get_horver_correlation_full_neon(const int16_t *diff, int stride, int width, int height, float *hcorr, float *vcorr) { // The following notation is used: // x - current pixel // y - right neighbour pixel // z - below neighbour pixel // w - down-right neighbour pixel
int64_t xy_sum = 0, xz_sum = 0;
int64_t x_sum = 0, x2_sum = 0;
int32x4_t zero = vdupq_n_s32(0);
int64x2_t v_x_sum = vreinterpretq_s64_s32(zero);
int64x2_t v_xy_sum = vreinterpretq_s64_s32(zero);
int64x2_t v_xz_sum = vreinterpretq_s64_s32(zero);
int64x2_t v_x2_sum = vreinterpretq_s64_s32(zero); // Process horizontal and vertical correlations through the body in 4x4 // blocks. This excludes the final row and column and possibly one extra // column depending how 3 divides into width and height
// Horizontal and vertical correlations for the penultimate row:
xy_sum += x * y;
xz_sum += x * z;
// Now just horizontal correlations for the final row:
xy_sum += z * w;
x_sum += y + w;
x2_sum += y * y + w * w;
x_finalrow += w;
x2_finalrow += w * w;
}
}
}
// Do we have 2 columns remaining or just the one? if (width % 3 == 1) { // Just vert corrs on the final col const int16_t x0 = diff[width - 1];
x_sum += x0;
x_finalcol += x0;
x2_sum += x0 * x0;
x2_finalcol += x0 * x0; for (int i = 0; i < height - 1; ++i) { const int16_t x = diff[i * stride + width - 1]; const int16_t z = diff[(i + 1) * stride + width - 1];
xz_sum += x * z;
x_finalcol += z;
x2_finalcol += z * z; // So the bottom-right elements don't get counted twice: if (i < height - (height % 3 == 1 ? 2 : 3)) {
x_sum += z;
x2_sum += z * z;
}
}
} else { // Two cols remaining const int16_t x0 = diff[width - 2]; const int16_t y0 = diff[width - 1];
x_sum += x0 + y0;
x2_sum += x0 * x0 + y0 * y0;
x_finalcol += y0;
x2_finalcol += y0 * y0; for (int i = 0; i < height - 1; ++i) { const int16_t x = diff[i * stride + width - 2]; const int16_t y = diff[i * stride + width - 1]; const int16_t z = diff[(i + 1) * stride + width - 2]; const int16_t w = diff[(i + 1) * stride + width - 1];
// Horizontal and vertical correlations for the penultimate col: // Skip these on the last iteration of this loop if we also had two // rows remaining, otherwise the final horizontal and vertical correlation // get erroneously processed twice if (i < height - 2 || height % 3 == 1) {
xy_sum += x * y;
xz_sum += x * z;
}
x_finalcol += w;
x2_finalcol += w * w; // So the bottom-right elements don't get counted twice: if (i < height - (height % 3 == 1 ? 2 : 3)) {
x_sum += z + w;
x2_sum += z * z + w * w;
}
// Now just vertical correlations for the final column:
xz_sum += y * w;
}
}
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.