vp9_denoiser_sse2.c: improve code style.
denoiser_sse2.c: fix typos in comment. Change-Id: Ic0fb102331b0e533c058da3cab1fbc30de9a0070
This commit is contained in:
@@ -121,12 +121,12 @@ int vp8_denoiser_filter_sse2(unsigned char *mc_running_avg_y,
|
|||||||
if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH;
|
if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH;
|
||||||
if (abs_sum_diff > sum_diff_thresh) {
|
if (abs_sum_diff > sum_diff_thresh) {
|
||||||
// Before returning to copy the block (i.e., apply no denoising),
|
// Before returning to copy the block (i.e., apply no denoising),
|
||||||
// checK if we can still apply some (weaker) temporal filtering to
|
// check if we can still apply some (weaker) temporal filtering to
|
||||||
// this block, that would otherwise not be denoised at all. Simplest
|
// this block, that would otherwise not be denoised at all. Simplest
|
||||||
// is to apply an additional adjustment to running_avg_y to bring it
|
// is to apply an additional adjustment to running_avg_y to bring it
|
||||||
// closer to sig. The adjustment is capped by a maximum delta, and
|
// closer to sig. The adjustment is capped by a maximum delta, and
|
||||||
// chosen such that in most cases the resulting sum_diff will be
|
// chosen such that in most cases the resulting sum_diff will be
|
||||||
// within the accceptable range given by sum_diff_thresh.
|
// within the acceptable range given by sum_diff_thresh.
|
||||||
|
|
||||||
// The delta is set by the excess of absolute pixel diff over the
|
// The delta is set by the excess of absolute pixel diff over the
|
||||||
// threshold.
|
// threshold.
|
||||||
@@ -302,12 +302,12 @@ int vp8_denoiser_filter_uv_sse2(unsigned char *mc_running_avg,
|
|||||||
if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH_UV;
|
if (increase_denoising) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH_UV;
|
||||||
if (abs_sum_diff > sum_diff_thresh) {
|
if (abs_sum_diff > sum_diff_thresh) {
|
||||||
// Before returning to copy the block (i.e., apply no denoising),
|
// Before returning to copy the block (i.e., apply no denoising),
|
||||||
// checK if we can still apply some (weaker) temporal filtering to
|
// check if we can still apply some (weaker) temporal filtering to
|
||||||
// this block, that would otherwise not be denoised at all. Simplest
|
// this block, that would otherwise not be denoised at all. Simplest
|
||||||
// is to apply an additional adjustment to running_avg_y to bring it
|
// is to apply an additional adjustment to running_avg_y to bring it
|
||||||
// closer to sig. The adjustment is capped by a maximum delta, and
|
// closer to sig. The adjustment is capped by a maximum delta, and
|
||||||
// chosen such that in most cases the resulting sum_diff will be
|
// chosen such that in most cases the resulting sum_diff will be
|
||||||
// within the accceptable range given by sum_diff_thresh.
|
// within the acceptable range given by sum_diff_thresh.
|
||||||
|
|
||||||
// The delta is set by the excess of absolute pixel diff over the
|
// The delta is set by the excess of absolute pixel diff over the
|
||||||
// threshold.
|
// threshold.
|
||||||
|
|||||||
@@ -23,18 +23,17 @@
|
|||||||
// Compute the sum of all pixel differences of this MB.
|
// Compute the sum of all pixel differences of this MB.
|
||||||
static INLINE int sum_diff_16x1(__m128i acc_diff) {
|
static INLINE int sum_diff_16x1(__m128i acc_diff) {
|
||||||
const __m128i k_1 = _mm_set1_epi16(1);
|
const __m128i k_1 = _mm_set1_epi16(1);
|
||||||
const __m128i acc_diff_lo = _mm_srai_epi16(
|
const __m128i acc_diff_lo =
|
||||||
_mm_unpacklo_epi8(acc_diff, acc_diff), 8);
|
_mm_srai_epi16(_mm_unpacklo_epi8(acc_diff, acc_diff), 8);
|
||||||
const __m128i acc_diff_hi = _mm_srai_epi16(
|
const __m128i acc_diff_hi =
|
||||||
_mm_unpackhi_epi8(acc_diff, acc_diff), 8);
|
_mm_srai_epi16(_mm_unpackhi_epi8(acc_diff, acc_diff), 8);
|
||||||
const __m128i acc_diff_16 = _mm_add_epi16(acc_diff_lo, acc_diff_hi);
|
const __m128i acc_diff_16 = _mm_add_epi16(acc_diff_lo, acc_diff_hi);
|
||||||
const __m128i hg_fe_dc_ba = _mm_madd_epi16(acc_diff_16, k_1);
|
const __m128i hg_fe_dc_ba = _mm_madd_epi16(acc_diff_16, k_1);
|
||||||
const __m128i hgfe_dcba = _mm_add_epi32(hg_fe_dc_ba,
|
const __m128i hgfe_dcba =
|
||||||
_mm_srli_si128(hg_fe_dc_ba, 8));
|
_mm_add_epi32(hg_fe_dc_ba, _mm_srli_si128(hg_fe_dc_ba, 8));
|
||||||
const __m128i hgfedcba = _mm_add_epi32(hgfe_dcba,
|
const __m128i hgfedcba =
|
||||||
_mm_srli_si128(hgfe_dcba, 4));
|
_mm_add_epi32(hgfe_dcba, _mm_srli_si128(hgfe_dcba, 4));
|
||||||
int sum_diff = _mm_cvtsi128_si32(hgfedcba);
|
return _mm_cvtsi128_si32(hgfedcba);
|
||||||
return sum_diff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Denoise a 16x1 vector.
|
// Denoise a 16x1 vector.
|
||||||
@@ -51,8 +50,8 @@ static INLINE __m128i vp9_denoiser_16x1_sse2(const uint8_t *sig,
|
|||||||
__m128i acc_diff) {
|
__m128i acc_diff) {
|
||||||
// Calculate differences
|
// Calculate differences
|
||||||
const __m128i v_sig = _mm_loadu_si128((const __m128i *)(&sig[0]));
|
const __m128i v_sig = _mm_loadu_si128((const __m128i *)(&sig[0]));
|
||||||
const __m128i v_mc_running_avg_y = _mm_loadu_si128(
|
const __m128i v_mc_running_avg_y =
|
||||||
(const __m128i *)(&mc_running_avg_y[0]));
|
_mm_loadu_si128((const __m128i *)(&mc_running_avg_y[0]));
|
||||||
__m128i v_running_avg_y;
|
__m128i v_running_avg_y;
|
||||||
const __m128i pdiff = _mm_subs_epu8(v_mc_running_avg_y, v_sig);
|
const __m128i pdiff = _mm_subs_epu8(v_mc_running_avg_y, v_sig);
|
||||||
const __m128i ndiff = _mm_subs_epu8(v_sig, v_mc_running_avg_y);
|
const __m128i ndiff = _mm_subs_epu8(v_sig, v_mc_running_avg_y);
|
||||||
@@ -60,8 +59,8 @@ static INLINE __m128i vp9_denoiser_16x1_sse2(const uint8_t *sig,
|
|||||||
const __m128i diff_sign = _mm_cmpeq_epi8(pdiff, *k_0);
|
const __m128i diff_sign = _mm_cmpeq_epi8(pdiff, *k_0);
|
||||||
// Clamp absolute difference to 16 to be used to get mask. Doing this
|
// Clamp absolute difference to 16 to be used to get mask. Doing this
|
||||||
// allows us to use _mm_cmpgt_epi8, which operates on signed byte.
|
// allows us to use _mm_cmpgt_epi8, which operates on signed byte.
|
||||||
const __m128i clamped_absdiff = _mm_min_epu8(
|
const __m128i clamped_absdiff =
|
||||||
_mm_or_si128(pdiff, ndiff), *k_16);
|
_mm_min_epu8(_mm_or_si128(pdiff, ndiff), *k_16);
|
||||||
// Get masks for l2 l1 and l0 adjustments.
|
// Get masks for l2 l1 and l0 adjustments.
|
||||||
const __m128i mask2 = _mm_cmpgt_epi8(*k_16, clamped_absdiff);
|
const __m128i mask2 = _mm_cmpgt_epi8(*k_16, clamped_absdiff);
|
||||||
const __m128i mask1 = _mm_cmpgt_epi8(*k_8, clamped_absdiff);
|
const __m128i mask1 = _mm_cmpgt_epi8(*k_8, clamped_absdiff);
|
||||||
@@ -95,12 +94,10 @@ static INLINE __m128i vp9_denoiser_16x1_sse2(const uint8_t *sig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Denoise a 16x1 vector with a weaker filter.
|
// Denoise a 16x1 vector with a weaker filter.
|
||||||
static INLINE __m128i vp9_denoiser_adj_16x1_sse2(const uint8_t *sig,
|
static INLINE __m128i vp9_denoiser_adj_16x1_sse2(
|
||||||
const uint8_t *mc_running_avg_y,
|
const uint8_t *sig, const uint8_t *mc_running_avg_y,
|
||||||
uint8_t *running_avg_y,
|
uint8_t *running_avg_y, const __m128i k_0,
|
||||||
const __m128i k_0,
|
const __m128i k_delta, __m128i acc_diff) {
|
||||||
const __m128i k_delta,
|
|
||||||
__m128i acc_diff) {
|
|
||||||
__m128i v_running_avg_y = _mm_loadu_si128((__m128i *)(&running_avg_y[0]));
|
__m128i v_running_avg_y = _mm_loadu_si128((__m128i *)(&running_avg_y[0]));
|
||||||
// Calculate differences.
|
// Calculate differences.
|
||||||
const __m128i v_sig = _mm_loadu_si128((const __m128i *)(&sig[0]));
|
const __m128i v_sig = _mm_loadu_si128((const __m128i *)(&sig[0]));
|
||||||
@@ -135,12 +132,11 @@ static int vp9_denoiser_4xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
int increase_denoising,
|
int increase_denoising,
|
||||||
BLOCK_SIZE bs,
|
BLOCK_SIZE bs,
|
||||||
int motion_magnitude) {
|
int motion_magnitude) {
|
||||||
int sum_diff_thresh;
|
int sum_diff_thresh, r, sum_diff = 0;
|
||||||
int r;
|
const int shift_inc = (increase_denoising &&
|
||||||
int shift_inc = (increase_denoising &&
|
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
||||||
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 1 : 0;
|
1 : 0;
|
||||||
unsigned char sig_buffer[2][16], mc_running_buffer[2][16],
|
uint8_t sig_buffer[2][16], mc_running_buffer[2][16], running_buffer[2][16];
|
||||||
running_buffer[2][16];
|
|
||||||
__m128i acc_diff = _mm_setzero_si128();
|
__m128i acc_diff = _mm_setzero_si128();
|
||||||
const __m128i k_0 = _mm_setzero_si128();
|
const __m128i k_0 = _mm_setzero_si128();
|
||||||
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
||||||
@@ -148,13 +144,11 @@ static int vp9_denoiser_4xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
const __m128i k_16 = _mm_set1_epi8(16);
|
const __m128i k_16 = _mm_set1_epi8(16);
|
||||||
// Modify each level's adjustment according to motion_magnitude.
|
// Modify each level's adjustment according to motion_magnitude.
|
||||||
const __m128i l3 = _mm_set1_epi8(
|
const __m128i l3 = _mm_set1_epi8(
|
||||||
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 7 + shift_inc : 6);
|
||||||
7 + shift_inc : 6);
|
|
||||||
// Difference between level 3 and level 2 is 2.
|
// Difference between level 3 and level 2 is 2.
|
||||||
const __m128i l32 = _mm_set1_epi8(2);
|
const __m128i l32 = _mm_set1_epi8(2);
|
||||||
// Difference between level 2 and level 1 is 1.
|
// Difference between level 2 and level 1 is 1.
|
||||||
const __m128i l21 = _mm_set1_epi8(1);
|
const __m128i l21 = _mm_set1_epi8(1);
|
||||||
int sum_diff = 0;
|
|
||||||
|
|
||||||
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 2); ++r) {
|
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 2); ++r) {
|
||||||
vpx_memcpy(sig_buffer[r], sig, 4);
|
vpx_memcpy(sig_buffer[r], sig, 4);
|
||||||
@@ -197,17 +191,17 @@ static int vp9_denoiser_4xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
||||||
if (abs(sum_diff) > sum_diff_thresh) {
|
if (abs(sum_diff) > sum_diff_thresh) {
|
||||||
// Before returning to copy the block (i.e., apply no denoising),
|
// Before returning to copy the block (i.e., apply no denoising),
|
||||||
// checK if we can still apply some (weaker) temporal filtering to
|
// check if we can still apply some (weaker) temporal filtering to
|
||||||
// this block, that would otherwise not be denoised at all. Simplest
|
// this block, that would otherwise not be denoised at all. Simplest
|
||||||
// is to apply an additional adjustment to running_avg_y to bring it
|
// is to apply an additional adjustment to running_avg_y to bring it
|
||||||
// closer to sig. The adjustment is capped by a maximum delta, and
|
// closer to sig. The adjustment is capped by a maximum delta, and
|
||||||
// chosen such that in most cases the resulting sum_diff will be
|
// chosen such that in most cases the resulting sum_diff will be
|
||||||
// within the accceptable range given by sum_diff_thresh.
|
// within the acceptable range given by sum_diff_thresh.
|
||||||
|
|
||||||
// The delta is set by the excess of absolute pixel diff over the
|
// The delta is set by the excess of absolute pixel diff over the
|
||||||
// threshold.
|
// threshold.
|
||||||
int delta = ((abs(sum_diff) - sum_diff_thresh)
|
const int delta = ((abs(sum_diff) - sum_diff_thresh) >>
|
||||||
>> num_pels_log2_lookup[bs]) + 1;
|
num_pels_log2_lookup[bs]) + 1;
|
||||||
// Only apply the adjustment for max delta up to 3.
|
// Only apply the adjustment for max delta up to 3.
|
||||||
if (delta < 4) {
|
if (delta < 4) {
|
||||||
const __m128i k_delta = _mm_set1_epi8(delta);
|
const __m128i k_delta = _mm_set1_epi8(delta);
|
||||||
@@ -215,9 +209,8 @@ static int vp9_denoiser_4xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
sum_diff = 0;
|
sum_diff = 0;
|
||||||
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 2); ++r) {
|
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 2); ++r) {
|
||||||
acc_diff = vp9_denoiser_adj_16x1_sse2(
|
acc_diff = vp9_denoiser_adj_16x1_sse2(
|
||||||
sig_buffer[r], mc_running_buffer[r],
|
sig_buffer[r], mc_running_buffer[r], running_buffer[r],
|
||||||
running_buffer[r], k_0, k_delta,
|
k_0, k_delta, acc_diff);
|
||||||
acc_diff);
|
|
||||||
vpx_memcpy(running_avg_y, running_buffer[r], 4);
|
vpx_memcpy(running_avg_y, running_buffer[r], 4);
|
||||||
vpx_memcpy(running_avg_y + avg_y_stride, running_buffer[r] + 4, 4);
|
vpx_memcpy(running_avg_y + avg_y_stride, running_buffer[r] + 4, 4);
|
||||||
vpx_memcpy(running_avg_y + avg_y_stride * 2,
|
vpx_memcpy(running_avg_y + avg_y_stride * 2,
|
||||||
@@ -246,12 +239,11 @@ static int vp9_denoiser_8xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
int increase_denoising,
|
int increase_denoising,
|
||||||
BLOCK_SIZE bs,
|
BLOCK_SIZE bs,
|
||||||
int motion_magnitude) {
|
int motion_magnitude) {
|
||||||
int sum_diff_thresh;
|
int sum_diff_thresh, r, sum_diff = 0;
|
||||||
int r;
|
const int shift_inc = (increase_denoising &&
|
||||||
int shift_inc = (increase_denoising &&
|
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
||||||
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 1 : 0;
|
1 : 0;
|
||||||
unsigned char sig_buffer[8][16], mc_running_buffer[8][16],
|
uint8_t sig_buffer[8][16], mc_running_buffer[8][16], running_buffer[8][16];
|
||||||
running_buffer[8][16];
|
|
||||||
__m128i acc_diff = _mm_setzero_si128();
|
__m128i acc_diff = _mm_setzero_si128();
|
||||||
const __m128i k_0 = _mm_setzero_si128();
|
const __m128i k_0 = _mm_setzero_si128();
|
||||||
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
||||||
@@ -259,13 +251,11 @@ static int vp9_denoiser_8xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
const __m128i k_16 = _mm_set1_epi8(16);
|
const __m128i k_16 = _mm_set1_epi8(16);
|
||||||
// Modify each level's adjustment according to motion_magnitude.
|
// Modify each level's adjustment according to motion_magnitude.
|
||||||
const __m128i l3 = _mm_set1_epi8(
|
const __m128i l3 = _mm_set1_epi8(
|
||||||
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 7 + shift_inc : 6);
|
||||||
7 + shift_inc : 6);
|
|
||||||
// Difference between level 3 and level 2 is 2.
|
// Difference between level 3 and level 2 is 2.
|
||||||
const __m128i l32 = _mm_set1_epi8(2);
|
const __m128i l32 = _mm_set1_epi8(2);
|
||||||
// Difference between level 2 and level 1 is 1.
|
// Difference between level 2 and level 1 is 1.
|
||||||
const __m128i l21 = _mm_set1_epi8(1);
|
const __m128i l21 = _mm_set1_epi8(1);
|
||||||
int sum_diff = 0;
|
|
||||||
|
|
||||||
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
|
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
|
||||||
vpx_memcpy(sig_buffer[r], sig, 8);
|
vpx_memcpy(sig_buffer[r], sig, 8);
|
||||||
@@ -294,16 +284,16 @@ static int vp9_denoiser_8xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
||||||
if (abs(sum_diff) > sum_diff_thresh) {
|
if (abs(sum_diff) > sum_diff_thresh) {
|
||||||
// Before returning to copy the block (i.e., apply no denoising),
|
// Before returning to copy the block (i.e., apply no denoising),
|
||||||
// checK if we can still apply some (weaker) temporal filtering to
|
// check if we can still apply some (weaker) temporal filtering to
|
||||||
// this block, that would otherwise not be denoised at all. Simplest
|
// this block, that would otherwise not be denoised at all. Simplest
|
||||||
// is to apply an additional adjustment to running_avg_y to bring it
|
// is to apply an additional adjustment to running_avg_y to bring it
|
||||||
// closer to sig. The adjustment is capped by a maximum delta, and
|
// closer to sig. The adjustment is capped by a maximum delta, and
|
||||||
// chosen such that in most cases the resulting sum_diff will be
|
// chosen such that in most cases the resulting sum_diff will be
|
||||||
// within the accceptable range given by sum_diff_thresh.
|
// within the acceptable range given by sum_diff_thresh.
|
||||||
|
|
||||||
// The delta is set by the excess of absolute pixel diff over the
|
// The delta is set by the excess of absolute pixel diff over the
|
||||||
// threshold.
|
// threshold.
|
||||||
int delta = ((abs(sum_diff) - sum_diff_thresh)
|
const int delta = ((abs(sum_diff) - sum_diff_thresh)
|
||||||
>> num_pels_log2_lookup[bs]) + 1;
|
>> num_pels_log2_lookup[bs]) + 1;
|
||||||
// Only apply the adjustment for max delta up to 3.
|
// Only apply the adjustment for max delta up to 3.
|
||||||
if (delta < 4) {
|
if (delta < 4) {
|
||||||
@@ -311,9 +301,8 @@ static int vp9_denoiser_8xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
running_avg_y -= avg_y_stride * (4 << b_height_log2_lookup[bs]);
|
running_avg_y -= avg_y_stride * (4 << b_height_log2_lookup[bs]);
|
||||||
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
|
for (r = 0; r < ((4 << b_height_log2_lookup[bs]) >> 1); ++r) {
|
||||||
acc_diff = vp9_denoiser_adj_16x1_sse2(
|
acc_diff = vp9_denoiser_adj_16x1_sse2(
|
||||||
sig_buffer[r], mc_running_buffer[r],
|
sig_buffer[r], mc_running_buffer[r], running_buffer[r],
|
||||||
running_buffer[r], k_0, k_delta,
|
k_0, k_delta, acc_diff);
|
||||||
acc_diff);
|
|
||||||
vpx_memcpy(running_avg_y, running_buffer[r], 8);
|
vpx_memcpy(running_avg_y, running_buffer[r], 8);
|
||||||
vpx_memcpy(running_avg_y + avg_y_stride, running_buffer[r] + 8, 8);
|
vpx_memcpy(running_avg_y + avg_y_stride, running_buffer[r] + 8, 8);
|
||||||
// Update pointers for next iteration.
|
// Update pointers for next iteration.
|
||||||
@@ -338,10 +327,10 @@ static int vp9_denoiser_64_32_16xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
int avg_y_stride,
|
int avg_y_stride,
|
||||||
int increase_denoising, BLOCK_SIZE bs,
|
int increase_denoising, BLOCK_SIZE bs,
|
||||||
int motion_magnitude) {
|
int motion_magnitude) {
|
||||||
int sum_diff_thresh;
|
int sum_diff_thresh, r, c, sum_diff = 0;
|
||||||
int r, c;
|
const int shift_inc = (increase_denoising &&
|
||||||
int shift_inc = (increase_denoising &&
|
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
||||||
motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 1 : 0;
|
1 : 0;
|
||||||
__m128i acc_diff[4][4];
|
__m128i acc_diff[4][4];
|
||||||
const __m128i k_0 = _mm_setzero_si128();
|
const __m128i k_0 = _mm_setzero_si128();
|
||||||
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
const __m128i k_4 = _mm_set1_epi8(4 + shift_inc);
|
||||||
@@ -349,13 +338,11 @@ static int vp9_denoiser_64_32_16xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
const __m128i k_16 = _mm_set1_epi8(16);
|
const __m128i k_16 = _mm_set1_epi8(16);
|
||||||
// Modify each level's adjustment according to motion_magnitude.
|
// Modify each level's adjustment according to motion_magnitude.
|
||||||
const __m128i l3 = _mm_set1_epi8(
|
const __m128i l3 = _mm_set1_epi8(
|
||||||
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ?
|
(motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD) ? 7 + shift_inc : 6);
|
||||||
7 + shift_inc : 6);
|
|
||||||
// Difference between level 3 and level 2 is 2.
|
// Difference between level 3 and level 2 is 2.
|
||||||
const __m128i l32 = _mm_set1_epi8(2);
|
const __m128i l32 = _mm_set1_epi8(2);
|
||||||
// Difference between level 2 and level 1 is 1.
|
// Difference between level 2 and level 1 is 1.
|
||||||
const __m128i l21 = _mm_set1_epi8(1);
|
const __m128i l21 = _mm_set1_epi8(1);
|
||||||
int sum_diff = 0;
|
|
||||||
|
|
||||||
for (c = 0; c < 4; ++c) {
|
for (c = 0; c < 4; ++c) {
|
||||||
for (r = 0; r < 4; ++r) {
|
for (r = 0; r < 4; ++r) {
|
||||||
@@ -363,13 +350,11 @@ static int vp9_denoiser_64_32_16xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (r = 0; r < (4 << b_height_log2_lookup[bs]); r++) {
|
for (r = 0; r < (4 << b_height_log2_lookup[bs]); ++r) {
|
||||||
for (c = 0; c < (4 << b_width_log2_lookup[bs]); c += 16) {
|
for (c = 0; c < (4 << b_width_log2_lookup[bs]); c += 16) {
|
||||||
acc_diff[c>>4][r>>4] = vp9_denoiser_16x1_sse2(
|
acc_diff[c>>4][r>>4] = vp9_denoiser_16x1_sse2(
|
||||||
sig, mc_running_avg_y,
|
sig, mc_running_avg_y, running_avg_y, &k_0, &k_4,
|
||||||
running_avg_y,
|
&k_8, &k_16, &l3, &l32, &l21, acc_diff[c>>4][r>>4]);
|
||||||
&k_0, &k_4, &k_8, &k_16,
|
|
||||||
&l3, &l32, &l21, acc_diff[c>>4][r>>4]);
|
|
||||||
// Update pointers for next iteration.
|
// Update pointers for next iteration.
|
||||||
sig += 16;
|
sig += 16;
|
||||||
mc_running_avg_y += 16;
|
mc_running_avg_y += 16;
|
||||||
@@ -395,8 +380,8 @@ static int vp9_denoiser_64_32_16xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
{
|
{
|
||||||
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
sum_diff_thresh = total_adj_strong_thresh(bs, increase_denoising);
|
||||||
if (abs(sum_diff) > sum_diff_thresh) {
|
if (abs(sum_diff) > sum_diff_thresh) {
|
||||||
int delta = ((abs(sum_diff) - sum_diff_thresh)
|
const int delta = ((abs(sum_diff) - sum_diff_thresh) >>
|
||||||
>> num_pels_log2_lookup[bs]) + 1;
|
num_pels_log2_lookup[bs]) + 1;
|
||||||
|
|
||||||
// Only apply the adjustment for max delta up to 3.
|
// Only apply the adjustment for max delta up to 3.
|
||||||
if (delta < 4) {
|
if (delta < 4) {
|
||||||
@@ -408,8 +393,7 @@ static int vp9_denoiser_64_32_16xM_sse2(const uint8_t *sig, int sig_stride,
|
|||||||
for (r = 0; r < (4 << b_height_log2_lookup[bs]); ++r) {
|
for (r = 0; r < (4 << b_height_log2_lookup[bs]); ++r) {
|
||||||
for (c = 0; c < (4 << b_width_log2_lookup[bs]); c += 16) {
|
for (c = 0; c < (4 << b_width_log2_lookup[bs]); c += 16) {
|
||||||
acc_diff[c>>4][r>>4] = vp9_denoiser_adj_16x1_sse2(
|
acc_diff[c>>4][r>>4] = vp9_denoiser_adj_16x1_sse2(
|
||||||
sig, mc_running_avg_y,
|
sig, mc_running_avg_y, running_avg_y, k_0,
|
||||||
running_avg_y, k_0,
|
|
||||||
k_delta, acc_diff[c>>4][r>>4]);
|
k_delta, acc_diff[c>>4][r>>4]);
|
||||||
// Update pointers for next iteration.
|
// Update pointers for next iteration.
|
||||||
sig += 16;
|
sig += 16;
|
||||||
|
|||||||
Reference in New Issue
Block a user