#include <assert.h>
#include <math.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/intrapred_common.h"
#include "aom_mem/aom_mem.h"
#include "aom_ports/bitops.h"
static inline void v_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
const uint8_t *above, const uint8_t *left) { … }
static inline void h_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
const uint8_t *above, const uint8_t *left) { … }
static inline int abs_diff(int a, int b) { … }
static inline uint16_t paeth_predictor_single(uint16_t left, uint16_t top,
uint16_t top_left) { … }
static inline void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
#define sm_weights_sanity_checks(weights_w, weights_h, weights_scale, \
pred_scale) …
#define divide_round(value, bits) …
static inline void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left) { … }
static inline void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
const uint8_t *above, const uint8_t *left) { … }
static inline int divide_using_multiply_shift(int num, int shift1,
int multiplier, int shift2) { … }
#define DC_MULTIPLIER_1X2 …
#define DC_MULTIPLIER_1X4 …
#define DC_SHIFT2 …
static inline void dc_predictor_rect(uint8_t *dst, ptrdiff_t stride, int bw,
int bh, const uint8_t *above,
const uint8_t *left, int shift1,
int multiplier) { … }
#undef DC_SHIFT2
void aom_dc_predictor_4x8_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_8x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_4x16_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_16x4_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_8x16_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_16x8_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_8x32_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_32x8_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_16x32_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_32x16_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_16x64_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_64x16_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_32x64_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
void aom_dc_predictor_64x32_c(uint8_t *dst, ptrdiff_t stride,
const uint8_t *above, const uint8_t *left) { … }
#undef DC_MULTIPLIER_1X2
#undef DC_MULTIPLIER_1X4
#if CONFIG_AV1_HIGHBITDEPTH
static inline void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
int bh, const uint16_t *above,
const uint16_t *left, int bd) {
int r;
(void)left;
(void)bd;
for (r = 0; r < bh; r++) {
memcpy(dst, above, bw * sizeof(uint16_t));
dst += stride;
}
}
static inline void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
int bh, const uint16_t *above,
const uint16_t *left, int bd) {
int r;
(void)above;
(void)bd;
for (r = 0; r < bh; r++) {
aom_memset16(dst, left[r], bw);
dst += stride;
}
}
static inline void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh, const uint16_t *above,
const uint16_t *left, int bd) {
int r, c;
const uint16_t ytop_left = above[-1];
(void)bd;
for (r = 0; r < bh; r++) {
for (c = 0; c < bw; c++)
dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
dst += stride;
}
}
static inline void highbd_smooth_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
(void)bd;
const uint16_t below_pred = left[bh - 1];
const uint16_t right_pred = above[bw - 1];
const uint8_t *const sm_weights_w = smooth_weights + bw - 4;
const uint8_t *const sm_weights_h = smooth_weights + bh - 4;
const int log2_scale = 1 + SMOOTH_WEIGHT_LOG2_SCALE;
const uint16_t scale = (1 << SMOOTH_WEIGHT_LOG2_SCALE);
sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
log2_scale + sizeof(*dst));
int r;
for (r = 0; r < bh; ++r) {
int c;
for (c = 0; c < bw; ++c) {
const uint16_t pixels[] = { above[c], below_pred, left[r], right_pred };
const uint8_t weights[] = { sm_weights_h[r], scale - sm_weights_h[r],
sm_weights_w[c], scale - sm_weights_w[c] };
uint32_t this_pred = 0;
int i;
assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
for (i = 0; i < 4; ++i) {
this_pred += weights[i] * pixels[i];
}
dst[c] = divide_round(this_pred, log2_scale);
}
dst += stride;
}
}
static inline void highbd_smooth_v_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
(void)bd;
const uint16_t below_pred = left[bh - 1];
const uint8_t *const sm_weights = smooth_weights + bh - 4;
const int log2_scale = SMOOTH_WEIGHT_LOG2_SCALE;
const uint16_t scale = (1 << SMOOTH_WEIGHT_LOG2_SCALE);
sm_weights_sanity_checks(sm_weights, sm_weights, scale,
log2_scale + sizeof(*dst));
int r;
for (r = 0; r < bh; r++) {
int c;
for (c = 0; c < bw; ++c) {
const uint16_t pixels[] = { above[c], below_pred };
const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r] };
uint32_t this_pred = 0;
assert(scale >= sm_weights[r]);
int i;
for (i = 0; i < 2; ++i) {
this_pred += weights[i] * pixels[i];
}
dst[c] = divide_round(this_pred, log2_scale);
}
dst += stride;
}
}
static inline void highbd_smooth_h_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
(void)bd;
const uint16_t right_pred = above[bw - 1];
const uint8_t *const sm_weights = smooth_weights + bw - 4;
const int log2_scale = SMOOTH_WEIGHT_LOG2_SCALE;
const uint16_t scale = (1 << SMOOTH_WEIGHT_LOG2_SCALE);
sm_weights_sanity_checks(sm_weights, sm_weights, scale,
log2_scale + sizeof(*dst));
int r;
for (r = 0; r < bh; r++) {
int c;
for (c = 0; c < bw; ++c) {
const uint16_t pixels[] = { left[r], right_pred };
const uint8_t weights[] = { sm_weights[c], scale - sm_weights[c] };
uint32_t this_pred = 0;
assert(scale >= sm_weights[c]);
int i;
for (i = 0; i < 2; ++i) {
this_pred += weights[i] * pixels[i];
}
dst[c] = divide_round(this_pred, log2_scale);
}
dst += stride;
}
}
static inline void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
int r;
(void)above;
(void)left;
for (r = 0; r < bh; r++) {
aom_memset16(dst, 128 << (bd - 8), bw);
dst += stride;
}
}
static inline void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
int i, r, expected_dc, sum = 0;
(void)above;
(void)bd;
for (i = 0; i < bh; i++) sum += left[i];
expected_dc = (sum + (bh >> 1)) / bh;
for (r = 0; r < bh; r++) {
aom_memset16(dst, expected_dc, bw);
dst += stride;
}
}
static inline void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd) {
int i, r, expected_dc, sum = 0;
(void)left;
(void)bd;
for (i = 0; i < bw; i++) sum += above[i];
expected_dc = (sum + (bw >> 1)) / bw;
for (r = 0; r < bh; r++) {
aom_memset16(dst, expected_dc, bw);
dst += stride;
}
}
static inline void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
int bh, const uint16_t *above,
const uint16_t *left, int bd) {
int i, r, expected_dc, sum = 0;
const int count = bw + bh;
(void)bd;
for (i = 0; i < bw; i++) {
sum += above[i];
}
for (i = 0; i < bh; i++) {
sum += left[i];
}
expected_dc = (sum + (count >> 1)) / count;
for (r = 0; r < bh; r++) {
aom_memset16(dst, expected_dc, bw);
dst += stride;
}
}
#define HIGHBD_DC_MULTIPLIER_1X2 …
#define HIGHBD_DC_MULTIPLIER_1X4 …
#define HIGHBD_DC_SHIFT2 …
static inline void highbd_dc_predictor_rect(uint16_t *dst, ptrdiff_t stride,
int bw, int bh,
const uint16_t *above,
const uint16_t *left, int bd,
int shift1, uint32_t multiplier) {
int sum = 0;
(void)bd;
for (int i = 0; i < bw; i++) {
sum += above[i];
}
for (int i = 0; i < bh; i++) {
sum += left[i];
}
const int expected_dc = divide_using_multiply_shift(
sum + ((bw + bh) >> 1), shift1, multiplier, HIGHBD_DC_SHIFT2);
assert(expected_dc < (1 << bd));
for (int r = 0; r < bh; r++) {
aom_memset16(dst, expected_dc, bw);
dst += stride;
}
}
#undef HIGHBD_DC_SHIFT2
void aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 4, 8, above, left, bd, 2,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 8, 4, above, left, bd, 2,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_4x16_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 4, 16, above, left, bd, 2,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_16x4_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 16, 4, above, left, bd, 2,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 8, 16, above, left, bd, 3,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 16, 8, above, left, bd, 3,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_8x32_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 8, 32, above, left, bd, 3,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_32x8_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above, const uint16_t *left,
int bd) {
highbd_dc_predictor_rect(dst, stride, 32, 8, above, left, bd, 3,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 16, 32, above, left, bd, 4,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 32, 16, above, left, bd, 4,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_16x64_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 16, 64, above, left, bd, 4,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_64x16_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 64, 16, above, left, bd, 4,
HIGHBD_DC_MULTIPLIER_1X4);
}
void aom_highbd_dc_predictor_32x64_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 32, 64, above, left, bd, 5,
HIGHBD_DC_MULTIPLIER_1X2);
}
void aom_highbd_dc_predictor_64x32_c(uint16_t *dst, ptrdiff_t stride,
const uint16_t *above,
const uint16_t *left, int bd) {
highbd_dc_predictor_rect(dst, stride, 64, 32, above, left, bd, 5,
HIGHBD_DC_MULTIPLIER_1X2);
}
#undef HIGHBD_DC_MULTIPLIER_1X2
#undef HIGHBD_DC_MULTIPLIER_1X4
#endif
#define intra_pred_sized(type, width, height) …
#if CONFIG_AV1_HIGHBITDEPTH
#define intra_pred_highbd_sized …
#else
#define intra_pred_highbd_sized(type, width, height) …
#endif
#define intra_pred_rectangular(type) …
#define intra_pred_above_4x4(type) …
#define intra_pred_allsizes …
#define intra_pred_square(type) …
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_allsizes
intra_pred_square(…)
#undef intra_pred_allsizes