/* * Copyright (c) 2017 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
staticINLINE __m256i convolve8_16_avx2(const __m256i *const s, const __m256i *const f) { // multiply 2 adjacent elements with the filter and add the result const __m256i k_64 = _mm256_set1_epi16(1 << 6); const __m256i x0 = _mm256_maddubs_epi16(s[0], f[0]); const __m256i x1 = _mm256_maddubs_epi16(s[1], f[1]); const __m256i x2 = _mm256_maddubs_epi16(s[2], f[2]); const __m256i x3 = _mm256_maddubs_epi16(s[3], f[3]);
__m256i sum1, sum2;
// sum the results together, saturating only on the final step // adding x0 with x2 and x1 with x3 is the only order that prevents // outranges for all filters
sum1 = _mm256_add_epi16(x0, x2);
sum2 = _mm256_add_epi16(x1, x3); // add the rounding offset early to avoid another saturated add
sum1 = _mm256_add_epi16(sum1, k_64);
sum1 = _mm256_adds_epi16(sum1, sum2); // round and shift by 7 bit each 16 bit
sum1 = _mm256_srai_epi16(sum1, 7); return sum1;
}
staticINLINE __m128i convolve8_8_avx2(const __m256i *const s, const __m256i *const f) { // multiply 2 adjacent elements with the filter and add the result const __m128i k_64 = _mm_set1_epi16(1 << 6); const __m128i x0 = _mm_maddubs_epi16(_mm256_castsi256_si128(s[0]),
_mm256_castsi256_si128(f[0])); const __m128i x1 = _mm_maddubs_epi16(_mm256_castsi256_si128(s[1]),
_mm256_castsi256_si128(f[1])); const __m128i x2 = _mm_maddubs_epi16(_mm256_castsi256_si128(s[2]),
_mm256_castsi256_si128(f[2])); const __m128i x3 = _mm_maddubs_epi16(_mm256_castsi256_si128(s[3]),
_mm256_castsi256_si128(f[3]));
__m128i sum1, sum2;
// sum the results together, saturating only on the final step // adding x0 with x2 and x1 with x3 is the only order that prevents // outranges for all filters
sum1 = _mm_add_epi16(x0, x2);
sum2 = _mm_add_epi16(x1, x3); // add the rounding offset early to avoid another saturated add
sum1 = _mm_add_epi16(sum1, k_64);
sum1 = _mm_adds_epi16(sum1, sum2); // shift by 7 bit each 16 bit
sum1 = _mm_srai_epi16(sum1, 7); return sum1;
}
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.