#ifndef WEBP_DSP_QUANT_H_
#define WEBP_DSP_QUANT_H_
#include <string.h>
#include "src/dsp/dsp.h"
#include "src/webp/types.h"
#if defined(WEBP_USE_NEON) && !defined(WEBP_ANDROID_NEON) && \
!defined(WEBP_HAVE_NEON_RTCD)
#include <arm_neon.h>
#define IsFlat …
static uint32_t horizontal_add_uint32x4(const uint32x4_t a) {
#if WEBP_AARCH64
return vaddvq_u32(a);
#else
const uint64x2_t b = vpaddlq_u32(a);
const uint32x2_t c = vadd_u32(vreinterpret_u32_u64(vget_low_u64(b)),
vreinterpret_u32_u64(vget_high_u64(b)));
return vget_lane_u32(c, 0);
#endif
}
static WEBP_INLINE int IsFlat(const int16_t* levels, int num_blocks,
int thresh) {
const int16x8_t tst_ones = vdupq_n_s16(-1);
uint32x4_t sum = vdupq_n_u32(0);
int i;
for (i = 0; i < num_blocks; ++i) {
const int16x8_t a_0 = vsetq_lane_s16(0, vld1q_s16(levels), 0);
const int16x8_t a_1 = vld1q_s16(levels + 8);
const uint16x8_t b_0 = vshrq_n_u16(vtstq_s16(a_0, tst_ones), 15);
const uint16x8_t b_1 = vshrq_n_u16(vtstq_s16(a_1, tst_ones), 15);
sum = vpadalq_u16(sum, b_0);
sum = vpadalq_u16(sum, b_1);
levels += 16;
}
return thresh >= (int)horizontal_add_uint32x4(sum);
}
#else
#define IsFlat …
static WEBP_INLINE int IsFlat(const int16_t* levels, int num_blocks,
int thresh) { … }
#endif
static WEBP_INLINE int IsFlatSource16(const uint8_t* src) { … }
#endif