update libaom to rev 76574b6c09515d6687ebfa9760319e521f5abeb3 (without moz.build and aom_ports/aom_once.h)

This commit is contained in:
Roy Tam 2019-04-19 13:08:28 +08:00
commit ef35212f8b
128 changed files with 9426 additions and 4984 deletions

View file

@ -207,6 +207,7 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/masked_sad_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/subtract_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/adaptive_quantize_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad4d_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c"

View file

@ -519,7 +519,7 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
specialize qw/aom_quantize_b sse2/, "$ssse3_x86_64", "$avx_x86_64";
add_proto qw/void aom_quantize_b_adaptive/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/aom_quantize_b_adaptive sse2/;
specialize qw/aom_quantize_b_adaptive sse2 avx2/;
add_proto qw/void aom_quantize_b_32x32/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/aom_quantize_b_32x32/, "$ssse3_x86_64", "$avx_x86_64";
@ -529,6 +529,9 @@ if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {
add_proto qw/void aom_quantize_b_64x64/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/aom_quantize_b_64x64 ssse3/;
add_proto qw/void aom_quantize_b_64x64_adaptive/, "const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr, const int16_t *round_ptr, const int16_t *quant_ptr, const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan";
specialize qw/aom_quantize_b_64x64_adaptive sse2/;
} # CONFIG_AV1_ENCODER
if (aom_config("CONFIG_AV1_ENCODER") eq "yes") {

View file

@ -1078,7 +1078,7 @@ int av1_add_film_grain_run(const aom_film_grain_t *params, uint8_t *luma,
const int grain_center = 128 << (bit_depth - 8);
grain_min = 0 - grain_center;
grain_max = (256 << (bit_depth - 8)) - 1 - grain_center;
grain_max = grain_center - 1;
init_arrays(params, luma_stride, chroma_stride, &pred_pos_luma,
&pred_pos_chroma, &luma_grain_block, &cb_grain_block,

View file

@ -214,6 +214,7 @@ static void set_chroma_coefficient_fallback_soln(aom_equation_system_t *eqns) {
int aom_noise_strength_lut_init(aom_noise_strength_lut_t *lut, int num_points) {
if (!lut) return 0;
lut->num_points = 0;
lut->points = (double(*)[2])aom_malloc(num_points * sizeof(*lut->points));
if (!lut->points) return 0;
lut->num_points = num_points;
@ -426,6 +427,9 @@ int aom_flat_block_finder_init(aom_flat_block_finder_t *block_finder,
double *AtA_inv = 0;
double *A = 0;
int x = 0, y = 0, i = 0, j = 0;
block_finder->A = NULL;
block_finder->AtA_inv = NULL;
if (!equation_system_init(&eqns, kLowPolyNumParams)) {
fprintf(stderr, "Failed to init equation system for block_size=%d\n",
block_size);

View file

@ -140,7 +140,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
been normalized and then squared." Their CSF matrix (from PSNR-HVS)
was also constructed from the JPEG matrices. I can not find any obvious
scheme of normalizing to produce their table, but if I multiply their
CSF by 0.38857 and square the result I get their masking table.
CSF by 0.3885746225901003 and square the result I get their masking table.
I have no idea where this constant comes from, but deviating from it
too greatly hurts MOS agreement.
@ -148,11 +148,15 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
Jaakko Astola, Vladimir Lukin, "On between-coefficient contrast masking
of DCT basis functions", CD-ROM Proceedings of the Third
International Workshop on Video Processing and Quality Metrics for Consumer
Electronics VPQM-07, Scottsdale, Arizona, USA, 25-26 January, 2007, 4 p.*/
Electronics VPQM-07, Scottsdale, Arizona, USA, 25-26 January, 2007, 4 p.
Suggested in aomedia issue#2363:
0.3885746225901003 is a reciprocal of the maximum coefficient (2.573509)
of the old JPEG based matrix from the paper. Since you are not using that,
divide by actual maximum coefficient. */
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
mask[x][y] =
(_csf[x][y] * 0.3885746225901003) * (_csf[x][y] * 0.3885746225901003);
mask[x][y] = (_csf[x][y] / _csf[1][0]) * (_csf[x][y] / _csf[1][0]);
for (y = 0; y < _h - 7; y += _step) {
for (x = 0; x < _w - 7; x += _step) {
int i;

View file

@ -0,0 +1,244 @@
/*
* Copyright (c) 2019, 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.
*/
#include <immintrin.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "av1/encoder/av1_quantize.h"
#include "aom_dsp/x86/quantize_x86.h"
static INLINE void load_b_values_avx2(const int16_t *zbin_ptr, __m256i *zbin,
const int16_t *round_ptr, __m256i *round,
const int16_t *quant_ptr, __m256i *quant,
const int16_t *dequant_ptr,
__m256i *dequant,
const int16_t *shift_ptr,
__m256i *shift) {
*zbin = _mm256_castsi128_si256(_mm_load_si128((const __m128i *)zbin_ptr));
*zbin = _mm256_permute4x64_epi64(*zbin, 0x54);
*zbin = _mm256_sub_epi16(*zbin, _mm256_set1_epi16(1));
*round = _mm256_castsi128_si256(_mm_load_si128((const __m128i *)round_ptr));
*round = _mm256_permute4x64_epi64(*round, 0x54);
*quant = _mm256_castsi128_si256(_mm_load_si128((const __m128i *)quant_ptr));
*quant = _mm256_permute4x64_epi64(*quant, 0x54);
*dequant =
_mm256_castsi128_si256(_mm_load_si128((const __m128i *)dequant_ptr));
*dequant = _mm256_permute4x64_epi64(*dequant, 0x54);
*shift = _mm256_castsi128_si256(_mm_load_si128((const __m128i *)shift_ptr));
*shift = _mm256_permute4x64_epi64(*shift, 0x54);
}
static INLINE __m256i load_coefficients_avx2(const tran_low_t *coeff_ptr) {
const __m256i coeff1 = _mm256_load_si256((__m256i *)(coeff_ptr));
const __m256i coeff2 = _mm256_load_si256((__m256i *)(coeff_ptr + 8));
return _mm256_packs_epi32(coeff1, coeff2);
}
static INLINE void update_mask1_avx2(__m256i *cmp_mask,
const int16_t *iscan_ptr, int *is_found,
__m256i *mask) {
__m256i temp_mask = _mm256_setzero_si256();
if (_mm256_movemask_epi8(*cmp_mask)) {
__m256i iscan = _mm256_loadu_si256((const __m256i *)(iscan_ptr));
temp_mask = _mm256_and_si256(*cmp_mask, iscan);
*is_found = 1;
}
*mask = _mm256_max_epi16(temp_mask, *mask);
}
static INLINE void update_mask0_avx2(__m256i *qcoeff, __m256i *threshold,
const int16_t *iscan_ptr, int *is_found,
__m256i *mask) {
__m256i zero = _mm256_setzero_si256();
__m256i coeff[2], cmp_mask0, cmp_mask1;
coeff[0] = _mm256_unpacklo_epi16(*qcoeff, zero);
coeff[1] = _mm256_unpackhi_epi16(*qcoeff, zero);
coeff[0] = _mm256_slli_epi32(coeff[0], AOM_QM_BITS);
cmp_mask0 = _mm256_cmpgt_epi32(coeff[0], threshold[0]);
coeff[1] = _mm256_slli_epi32(coeff[1], AOM_QM_BITS);
cmp_mask1 = _mm256_cmpgt_epi32(coeff[1], threshold[1]);
cmp_mask0 =
_mm256_permute4x64_epi64(_mm256_packs_epi32(cmp_mask0, cmp_mask1), 0xd8);
update_mask1_avx2(&cmp_mask0, iscan_ptr, is_found, mask);
}
static INLINE void calculate_qcoeff_avx2(__m256i *coeff, const __m256i *round,
const __m256i *quant,
const __m256i *shift) {
__m256i tmp, qcoeff;
qcoeff = _mm256_adds_epi16(*coeff, *round);
tmp = _mm256_mulhi_epi16(qcoeff, *quant);
qcoeff = _mm256_add_epi16(tmp, qcoeff);
*coeff = _mm256_mulhi_epi16(qcoeff, *shift);
}
static INLINE __m256i calculate_dqcoeff_avx2(__m256i qcoeff, __m256i dequant) {
return _mm256_mullo_epi16(qcoeff, dequant);
}
static INLINE void store_coefficients_avx2(__m256i coeff_vals,
tran_low_t *coeff_ptr) {
__m256i coeff_sign = _mm256_srai_epi16(coeff_vals, 15);
__m256i coeff_vals_lo = _mm256_unpacklo_epi16(coeff_vals, coeff_sign);
__m256i coeff_vals_hi = _mm256_unpackhi_epi16(coeff_vals, coeff_sign);
_mm256_store_si256((__m256i *)(coeff_ptr), coeff_vals_lo);
_mm256_store_si256((__m256i *)(coeff_ptr + 8), coeff_vals_hi);
}
void aom_quantize_b_adaptive_avx2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 16;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m256i zero = _mm256_setzero_si256();
__m256i zbin, round, quant, dequant, shift;
__m256i coeff, qcoeff;
__m256i cmp_mask, mask0 = zero, mask1 = zero;
__m128i temp_mask0, temp_mask1;
int prescan_add[2];
int thresh[2];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbin_ptr[i] * wt + prescan_add[i]) - 1;
}
__m256i threshold[2];
threshold[0] = _mm256_set1_epi32(thresh[0]);
threshold[1] = _mm256_set1_epi32(thresh[1]);
threshold[0] = _mm256_blend_epi32(threshold[0], threshold[1], 0xfe);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
load_b_values_avx2(zbin_ptr, &zbin, round_ptr, &round, quant_ptr, &quant,
dequant_ptr, &dequant, quant_shift_ptr, &shift);
// Do DC and first 15 AC.
coeff = load_coefficients_avx2(coeff_ptr);
qcoeff = _mm256_abs_epi16(coeff);
update_mask0_avx2(&qcoeff, threshold, iscan, &is_found0, &mask0);
__m256i temp0 = _mm256_cmpgt_epi16(qcoeff, zbin);
zbin = _mm256_unpackhi_epi64(zbin, zbin);
cmp_mask = _mm256_permute4x64_epi64(temp0, 0xd8);
update_mask1_avx2(&cmp_mask, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + 8), zero);
round = _mm256_unpackhi_epi64(round, round);
quant = _mm256_unpackhi_epi64(quant, quant);
shift = _mm256_unpackhi_epi64(shift, shift);
dequant = _mm256_unpackhi_epi64(dequant, dequant);
} else {
calculate_qcoeff_avx2(&qcoeff, &round, &quant, &shift);
round = _mm256_unpackhi_epi64(round, round);
quant = _mm256_unpackhi_epi64(quant, quant);
shift = _mm256_unpackhi_epi64(shift, shift);
// Reinsert signs
qcoeff = _mm256_sign_epi16(qcoeff, coeff);
// Mask out zbin threshold coeffs
qcoeff = _mm256_and_si256(qcoeff, temp0);
store_coefficients_avx2(qcoeff, qcoeff_ptr);
coeff = calculate_dqcoeff_avx2(qcoeff, dequant);
dequant = _mm256_unpackhi_epi64(dequant, dequant);
store_coefficients_avx2(coeff, dqcoeff_ptr);
}
// AC only loop.
while (index < n_coeffs) {
coeff = load_coefficients_avx2(coeff_ptr + index);
qcoeff = _mm256_abs_epi16(coeff);
update_mask0_avx2(&qcoeff, threshold, iscan + index, &is_found0, &mask0);
temp0 = _mm256_cmpgt_epi16(qcoeff, zbin);
cmp_mask = _mm256_permute4x64_epi64(temp0, 0xd8);
update_mask1_avx2(&cmp_mask, iscan + index, &is_found1, &mask1);
if (_mm256_movemask_epi8(cmp_mask) == 0) {
_mm256_store_si256((__m256i *)(qcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(qcoeff_ptr + index + 8), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index), zero);
_mm256_store_si256((__m256i *)(dqcoeff_ptr + index + 8), zero);
index += 16;
continue;
}
calculate_qcoeff_avx2(&qcoeff, &round, &quant, &shift);
qcoeff = _mm256_sign_epi16(qcoeff, coeff);
qcoeff = _mm256_and_si256(qcoeff, temp0);
store_coefficients_avx2(qcoeff, qcoeff_ptr + index);
coeff = calculate_dqcoeff_avx2(qcoeff, dequant);
store_coefficients_avx2(coeff, dqcoeff_ptr + index);
index += 16;
}
if (is_found0) {
temp_mask0 = _mm_max_epi16(_mm256_castsi256_si128(mask0),
_mm256_extracti128_si256(mask0, 1));
non_zero_count = calculate_non_zero_count(temp_mask0);
}
if (is_found1) {
temp_mask1 = _mm_max_epi16(_mm256_castsi256_si128(mask1),
_mm256_extracti128_si256(mask1, 1));
non_zero_count_prescan_add_zero = calculate_non_zero_count(temp_mask1);
}
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff0 = qcoeff_ptr[rc];
if (qcoeff0) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff0 = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff0 >> 31);
const int abs_coeff = (coeff0 ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff <
(zbin_ptr[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}

View file

@ -22,41 +22,31 @@ void aom_quantize_b_adaptive_sse2(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
const __m128i zero = _mm_setzero_si128();
int index = 16;
int non_zero_count = (int)n_coeffs;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
__m128i zbin, round, quant, dequant, shift;
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1;
__m128i eob = zero, eob0, prescan0, prescan1, all_zero;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], 0),
ROUND_POWER_OF_TWO(zbin_ptr[1], 0) };
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
int prescan_add[2];
for (int i = 0; i < 2; ++i)
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
// max buffer is of size 256 as this functions calls with
// maximum n_coeffs as 256
int16_t prescan[256];
memset(prescan, -1, n_coeffs * sizeof(int16_t));
// TODO(Aniket): Experiment the following loop with intrinsic
for (int i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const qm_val_t wt = 1 << AOM_QM_BITS;
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int prescan_add_val = prescan_add[rc != 0];
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
prescan[rc] = 0;
non_zero_count--;
} else {
break;
}
thresh[i] = (zbin_ptr[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
@ -74,13 +64,15 @@ void aom_quantize_b_adaptive_sse2(
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
prescan0 = _mm_loadu_si128((const __m128i *)prescan);
prescan1 = _mm_loadu_si128((const __m128i *)(prescan + 8));
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_and_si128(prescan0, _mm_cmpgt_epi16(qcoeff0, zbin));
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_and_si128(prescan1, _mm_cmpgt_epi16(qcoeff1, zbin));
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
@ -121,13 +113,9 @@ void aom_quantize_b_adaptive_sse2(
store_coefficients(coeff0, dqcoeff_ptr);
store_coefficients(coeff1, dqcoeff_ptr + 8);
eob = scan_for_eob(&coeff0, &coeff1, cmp_mask0, cmp_mask1, iscan, 0, zero);
}
// AC only loop.
// TODO(Aniket): Reduce the processing of coeff quatization
// based on eob logic
while (index < n_coeffs) {
coeff0 = load_coefficients(coeff_ptr + index);
coeff1 = load_coefficients(coeff_ptr + index + 8);
@ -137,11 +125,13 @@ void aom_quantize_b_adaptive_sse2(
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
prescan0 = _mm_loadu_si128((const __m128i *)(prescan + index));
prescan1 = _mm_loadu_si128((const __m128i *)(prescan + index + 8));
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index, &is_found0,
&mask0);
cmp_mask0 = _mm_and_si128(prescan0, _mm_cmpgt_epi16(qcoeff0, zbin));
cmp_mask1 = _mm_and_si128(prescan1, _mm_cmpgt_epi16(qcoeff1, zbin));
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
@ -174,14 +164,27 @@ void aom_quantize_b_adaptive_sse2(
store_coefficients(coeff0, dqcoeff_ptr + index);
store_coefficients(coeff1, dqcoeff_ptr + index + 8);
eob0 = scan_for_eob(&coeff0, &coeff1, cmp_mask0, cmp_mask1, iscan, index,
zero);
eob = _mm_max_epi16(eob, eob0);
index += 16;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
*eob_ptr = accumulate_eob(eob);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
@ -196,14 +199,14 @@ void aom_quantize_b_adaptive_sse2(
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const qm_val_t wt = (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
if (abs_coeff <
(zbin_ptr[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
@ -220,8 +223,11 @@ void aom_quantize_b_32x32_adaptive_sse2(
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 16;
int non_zero_count = (int)n_coeffs;
const int log_scale = 1;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi16(1);
const __m128i log_scale_vec = _mm_set1_epi16(log_scale);
@ -229,34 +235,23 @@ void aom_quantize_b_32x32_adaptive_sse2(
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1;
__m128i eob = zero, eob0, prescan0, prescan1, all_zero;
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
int prescan_add[2];
for (int i = 0; i < 2; ++i)
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
// max buffer is of size 1024 as this functions calls with
// maximum n_coeffs as 1024
int16_t prescan[1024];
memset(prescan, -1, n_coeffs * sizeof(int16_t));
// TODO(Aniket): Experiment the following loop with intrinsic
for (int i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const qm_val_t wt = 1 << AOM_QM_BITS;
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int prescan_add_val = prescan_add[rc != 0];
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
prescan[rc] = 0;
non_zero_count--;
} else {
break;
}
thresh[i] = (zbins[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
@ -273,6 +268,7 @@ void aom_quantize_b_32x32_adaptive_sse2(
zbin = _mm_srli_epi16(zbin, log_scale);
round = _mm_srli_epi16(round, log_scale);
zbin = _mm_sub_epi16(zbin, one);
// Do DC and first 15 AC.
coeff0 = load_coefficients(coeff_ptr);
coeff1 = load_coefficients(coeff_ptr + 8);
@ -282,13 +278,15 @@ void aom_quantize_b_32x32_adaptive_sse2(
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
prescan0 = _mm_loadu_si128((const __m128i *)prescan);
prescan1 = _mm_loadu_si128((const __m128i *)(prescan + 8));
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_and_si128(prescan0, _mm_cmpgt_epi16(qcoeff0, zbin));
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_and_si128(prescan1, _mm_cmpgt_epi16(qcoeff1, zbin));
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
@ -305,11 +303,9 @@ void aom_quantize_b_32x32_adaptive_sse2(
dequant = _mm_unpackhi_epi64(dequant, dequant);
} else {
calculate_qcoeff_log_scale(&qcoeff0, round, quant, &shift, &log_scale);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
calculate_qcoeff_log_scale(&qcoeff1, round, quant, &shift, &log_scale);
// Reinsert signs
@ -328,14 +324,9 @@ void aom_quantize_b_32x32_adaptive_sse2(
dequant = _mm_unpackhi_epi64(dequant, dequant);
calculate_dqcoeff_and_store_log_scale(qcoeff1, dequant, zero,
dqcoeff_ptr + 8, &log_scale);
eob =
scan_for_eob(&qcoeff0, &qcoeff1, cmp_mask0, cmp_mask1, iscan, 0, zero);
}
// AC only loop.
// TODO(Aniket): Reduce the processing of coeff quatization
// based on eob logic
while (index < n_coeffs) {
coeff0 = load_coefficients(coeff_ptr + index);
coeff1 = load_coefficients(coeff_ptr + index + 8);
@ -345,11 +336,13 @@ void aom_quantize_b_32x32_adaptive_sse2(
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
prescan0 = _mm_loadu_si128((const __m128i *)(prescan + index));
prescan1 = _mm_loadu_si128((const __m128i *)(prescan + index + 8));
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index, &is_found0,
&mask0);
cmp_mask0 = _mm_and_si128(prescan0, _mm_cmpgt_epi16(qcoeff0, zbin));
cmp_mask1 = _mm_and_si128(prescan1, _mm_cmpgt_epi16(qcoeff1, zbin));
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
@ -380,15 +373,235 @@ void aom_quantize_b_32x32_adaptive_sse2(
dqcoeff_ptr + index, &log_scale);
calculate_dqcoeff_and_store_log_scale(qcoeff1, dequant, zero,
dqcoeff_ptr + index + 8, &log_scale);
eob0 = scan_for_eob(&qcoeff0, &qcoeff1, cmp_mask0, cmp_mask1, iscan, index,
zero);
eob = _mm_max_epi16(eob, eob0);
index += 16;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
*eob_ptr = accumulate_eob(eob);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
for (int i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int qcoeff = qcoeff_ptr[rc];
if (qcoeff) {
first = i;
break;
}
}
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (abs_coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
*eob_ptr = 0;
}
}
}
#endif
}
void aom_quantize_b_64x64_adaptive_sse2(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int index = 16;
const int log_scale = 2;
int non_zero_count = 0;
int non_zero_count_prescan_add_zero = 0;
int is_found0 = 0, is_found1 = 0;
int eob = -1;
const __m128i zero = _mm_setzero_si128();
const __m128i one = _mm_set1_epi16(1);
const __m128i log_scale_vec = _mm_set1_epi16(log_scale);
__m128i zbin, round, quant, dequant, shift;
__m128i coeff0, coeff1, coeff0_sign, coeff1_sign;
__m128i qcoeff0, qcoeff1;
__m128i cmp_mask0, cmp_mask1;
__m128i all_zero;
__m128i mask0 = zero, mask1 = zero;
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
int prescan_add[2];
int thresh[4];
const qm_val_t wt = (1 << AOM_QM_BITS);
for (int i = 0; i < 2; ++i) {
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
thresh[i] = (zbins[i] * wt + prescan_add[i]) - 1;
}
thresh[2] = thresh[3] = thresh[1];
__m128i threshold[2];
threshold[0] = _mm_loadu_si128((__m128i *)&thresh[0]);
threshold[1] = _mm_unpackhi_epi64(threshold[0], threshold[0]);
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif
// Setup global values.
zbin = _mm_load_si128((const __m128i *)zbin_ptr);
round = _mm_load_si128((const __m128i *)round_ptr);
quant = _mm_load_si128((const __m128i *)quant_ptr);
dequant = _mm_load_si128((const __m128i *)dequant_ptr);
shift = _mm_load_si128((const __m128i *)quant_shift_ptr);
// Shift with rounding.
zbin = _mm_add_epi16(zbin, log_scale_vec);
round = _mm_add_epi16(round, log_scale_vec);
zbin = _mm_srli_epi16(zbin, log_scale);
round = _mm_srli_epi16(round, log_scale);
zbin = _mm_sub_epi16(zbin, one);
// Do DC and first 15 AC.
coeff0 = load_coefficients(coeff_ptr);
coeff1 = load_coefficients(coeff_ptr + 8);
coeff0_sign = _mm_srai_epi16(coeff0, 15);
coeff1_sign = _mm_srai_epi16(coeff1, 15);
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan, &is_found0, &mask0);
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
zbin = _mm_unpackhi_epi64(zbin, zbin); // Switch DC to AC
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan, &is_found1, &mask1);
threshold[0] = threshold[1];
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 4), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 8), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + 12), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 8), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + 12), zero);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
dequant = _mm_unpackhi_epi64(dequant, dequant);
} else {
calculate_qcoeff_log_scale(&qcoeff0, round, quant, &shift, &log_scale);
round = _mm_unpackhi_epi64(round, round);
quant = _mm_unpackhi_epi64(quant, quant);
shift = _mm_unpackhi_epi64(shift, shift);
calculate_qcoeff_log_scale(&qcoeff1, round, quant, &shift, &log_scale);
// Reinsert signs
qcoeff0 = invert_sign_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(qcoeff1, coeff1_sign);
// Mask out zbin threshold coeffs
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
store_coefficients(qcoeff0, qcoeff_ptr);
store_coefficients(qcoeff1, qcoeff_ptr + 8);
calculate_dqcoeff_and_store_log_scale(qcoeff0, dequant, zero, dqcoeff_ptr,
&log_scale);
dequant = _mm_unpackhi_epi64(dequant, dequant);
calculate_dqcoeff_and_store_log_scale(qcoeff1, dequant, zero,
dqcoeff_ptr + 8, &log_scale);
}
// AC only loop.
while (index < n_coeffs) {
coeff0 = load_coefficients(coeff_ptr + index);
coeff1 = load_coefficients(coeff_ptr + index + 8);
coeff0_sign = _mm_srai_epi16(coeff0, 15);
coeff1_sign = _mm_srai_epi16(coeff1, 15);
qcoeff0 = invert_sign_sse2(coeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(coeff1, coeff1_sign);
update_mask0(&qcoeff0, &qcoeff1, threshold, iscan + index, &is_found0,
&mask0);
cmp_mask0 = _mm_cmpgt_epi16(qcoeff0, zbin);
cmp_mask1 = _mm_cmpgt_epi16(qcoeff1, zbin);
update_mask1(&cmp_mask0, &cmp_mask1, iscan + index, &is_found1, &mask1);
all_zero = _mm_or_si128(cmp_mask0, cmp_mask1);
if (_mm_movemask_epi8(all_zero) == 0) {
_mm_store_si128((__m128i *)(qcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 4), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 8), zero);
_mm_store_si128((__m128i *)(qcoeff_ptr + index + 12), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 4), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 8), zero);
_mm_store_si128((__m128i *)(dqcoeff_ptr + index + 12), zero);
index += 16;
continue;
}
calculate_qcoeff_log_scale(&qcoeff0, round, quant, &shift, &log_scale);
calculate_qcoeff_log_scale(&qcoeff1, round, quant, &shift, &log_scale);
qcoeff0 = invert_sign_sse2(qcoeff0, coeff0_sign);
qcoeff1 = invert_sign_sse2(qcoeff1, coeff1_sign);
qcoeff0 = _mm_and_si128(qcoeff0, cmp_mask0);
qcoeff1 = _mm_and_si128(qcoeff1, cmp_mask1);
store_coefficients(qcoeff0, qcoeff_ptr + index);
store_coefficients(qcoeff1, qcoeff_ptr + index + 8);
calculate_dqcoeff_and_store_log_scale(qcoeff0, dequant, zero,
dqcoeff_ptr + index, &log_scale);
calculate_dqcoeff_and_store_log_scale(qcoeff1, dequant, zero,
dqcoeff_ptr + index + 8, &log_scale);
index += 16;
}
if (is_found0) non_zero_count = calculate_non_zero_count(mask0);
if (is_found1)
non_zero_count_prescan_add_zero = calculate_non_zero_count(mask1);
for (int i = non_zero_count_prescan_add_zero - 1; i >= non_zero_count; i--) {
const int rc = scan[i];
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
}
for (int i = non_zero_count - 1; i >= 0; i--) {
const int rc = scan[i];
if (qcoeff_ptr[rc]) {
eob = i;
break;
}
}
*eob_ptr = eob + 1;
#if SKIP_EOB_FACTOR_ADJUST
// TODO(Aniket): Experiment the following loop with intrinsic by combining
// with the quantization loop above
@ -403,7 +616,6 @@ void aom_quantize_b_32x32_adaptive_sse2(
if ((*eob_ptr - 1) >= 0 && first == (*eob_ptr - 1)) {
const int rc = scan[(*eob_ptr - 1)];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const qm_val_t wt = (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int coeff_sign = (coeff >> 31);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;

View file

@ -20,30 +20,30 @@
#include "aom_ports/emmintrin_compat.h"
// filters only for the 4_h8 convolution
DECLARE_ALIGNED(16, static const uint8_t, filt1_4_h8[16]) = {
0, 1, 1, 2, 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, 5, 6
};
DECLARE_ALIGNED(16, static const uint8_t, filt1_4_h8[16]) = { 0, 1, 1, 2, 2, 3,
3, 4, 2, 3, 3, 4,
4, 5, 5, 6 };
DECLARE_ALIGNED(16, static const uint8_t, filt2_4_h8[16]) = {
4, 5, 5, 6, 6, 7, 7, 8, 6, 7, 7, 8, 8, 9, 9, 10
};
DECLARE_ALIGNED(16, static const uint8_t, filt2_4_h8[16]) = { 4, 5, 5, 6, 6, 7,
7, 8, 6, 7, 7, 8,
8, 9, 9, 10 };
// filters for 8_h8 and 16_h8
DECLARE_ALIGNED(16, static const uint8_t, filt1_global[16]) = {
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8
};
DECLARE_ALIGNED(16, static const uint8_t,
filt1_global[16]) = { 0, 1, 1, 2, 2, 3, 3, 4,
4, 5, 5, 6, 6, 7, 7, 8 };
DECLARE_ALIGNED(16, static const uint8_t, filt2_global[16]) = {
2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10
};
DECLARE_ALIGNED(16, static const uint8_t,
filt2_global[16]) = { 2, 3, 3, 4, 4, 5, 5, 6,
6, 7, 7, 8, 8, 9, 9, 10 };
DECLARE_ALIGNED(16, static const uint8_t, filt3_global[16]) = {
4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12
};
DECLARE_ALIGNED(16, static const uint8_t,
filt3_global[16]) = { 4, 5, 5, 6, 6, 7, 7, 8,
8, 9, 9, 10, 10, 11, 11, 12 };
DECLARE_ALIGNED(16, static const uint8_t, filt4_global[16]) = {
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14
};
DECLARE_ALIGNED(16, static const uint8_t,
filt4_global[16]) = { 6, 7, 7, 8, 8, 9, 9, 10,
10, 11, 11, 12, 12, 13, 13, 14 };
DECLARE_ALIGNED(32, static const uint8_t, filt_h4[]) = {
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 0, 1, 1,

View file

@ -34,6 +34,31 @@ DECLARE_ALIGNED(32, static const uint8_t, filt4_d4_global_avx2[]) = {
2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 5, 6, 7, 8,
};
DECLARE_ALIGNED(32, static const uint8_t, filt_center_global_avx2[32]) = {
3, 255, 4, 255, 5, 255, 6, 255, 7, 255, 8, 255, 9, 255, 10, 255,
3, 255, 4, 255, 5, 255, 6, 255, 7, 255, 8, 255, 9, 255, 10, 255
};
DECLARE_ALIGNED(32, static const uint8_t,
filt1_global_avx2[32]) = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
6, 6, 7, 7, 8, 0, 1, 1, 2, 2, 3,
3, 4, 4, 5, 5, 6, 6, 7, 7, 8 };
DECLARE_ALIGNED(32, static const uint8_t,
filt2_global_avx2[32]) = { 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
8, 8, 9, 9, 10, 2, 3, 3, 4, 4, 5,
5, 6, 6, 7, 7, 8, 8, 9, 9, 10 };
DECLARE_ALIGNED(32, static const uint8_t, filt3_global_avx2[32]) = {
4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12,
4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12
};
DECLARE_ALIGNED(32, static const uint8_t, filt4_global_avx2[32]) = {
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14,
6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14
};
#define CONVOLVE_SR_HORIZONTAL_FILTER_8TAP \
for (i = 0; i < (im_h - 2); i += 2) { \
__m256i data = _mm256_castsi128_si256( \

File diff suppressed because it is too large Load diff

View file

@ -143,3 +143,60 @@ static INLINE void store_coefficients(__m128i coeff_vals,
_mm_store_si128((__m128i *)(coeff_ptr), coeff_vals_1);
_mm_store_si128((__m128i *)(coeff_ptr + 4), coeff_vals_2);
}
static INLINE void update_mask1(__m128i *cmp_mask0, __m128i *cmp_mask1,
const int16_t *iscan_ptr, int *is_found,
__m128i *mask) {
__m128i all_zero;
__m128i temp_mask = _mm_setzero_si128();
all_zero = _mm_or_si128(*cmp_mask0, *cmp_mask1);
if (_mm_movemask_epi8(all_zero)) {
__m128i iscan0 = _mm_load_si128((const __m128i *)(iscan_ptr));
__m128i mask0 = _mm_and_si128(*cmp_mask0, iscan0);
__m128i iscan1 = _mm_load_si128((const __m128i *)(iscan_ptr + 8));
__m128i mask1 = _mm_and_si128(*cmp_mask1, iscan1);
temp_mask = _mm_max_epi16(mask0, mask1);
*is_found = 1;
}
*mask = _mm_max_epi16(temp_mask, *mask);
}
static INLINE void update_mask0(__m128i *qcoeff0, __m128i *qcoeff1,
__m128i *threshold, const int16_t *iscan_ptr,
int *is_found, __m128i *mask) {
__m128i zero = _mm_setzero_si128();
__m128i coeff[4], cmp_mask0, cmp_mask1, cmp_mask2, cmp_mask3;
coeff[0] = _mm_unpacklo_epi16(*qcoeff0, zero);
coeff[1] = _mm_unpackhi_epi16(*qcoeff0, zero);
coeff[2] = _mm_unpacklo_epi16(*qcoeff1, zero);
coeff[3] = _mm_unpackhi_epi16(*qcoeff1, zero);
coeff[0] = _mm_slli_epi32(coeff[0], AOM_QM_BITS);
cmp_mask0 = _mm_cmpgt_epi32(coeff[0], threshold[0]);
coeff[1] = _mm_slli_epi32(coeff[1], AOM_QM_BITS);
cmp_mask1 = _mm_cmpgt_epi32(coeff[1], threshold[1]);
coeff[2] = _mm_slli_epi32(coeff[2], AOM_QM_BITS);
cmp_mask2 = _mm_cmpgt_epi32(coeff[2], threshold[1]);
coeff[3] = _mm_slli_epi32(coeff[3], AOM_QM_BITS);
cmp_mask3 = _mm_cmpgt_epi32(coeff[3], threshold[1]);
cmp_mask0 = _mm_packs_epi32(cmp_mask0, cmp_mask1);
cmp_mask1 = _mm_packs_epi32(cmp_mask2, cmp_mask3);
update_mask1(&cmp_mask0, &cmp_mask1, iscan_ptr, is_found, mask);
}
static INLINE int calculate_non_zero_count(__m128i mask) {
__m128i mask0, mask1;
int non_zero_count = 0;
mask0 = _mm_unpackhi_epi64(mask, mask);
mask1 = _mm_max_epi16(mask0, mask);
mask0 = _mm_shuffle_epi32(mask1, 1);
mask0 = _mm_max_epi16(mask0, mask1);
mask1 = _mm_srli_epi32(mask0, 16);
mask0 = _mm_max_epi16(mask0, mask1);
non_zero_count = _mm_extract_epi16(mask0, 0) + 1;
return non_zero_count;
}