#include <assert.h>
#include <stdio.h>
#include <limits.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "config/aom_scale_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_dsp/blend.h"
#include "aom_ports/aom_once.h"
#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
#include "av1/common/mvref_common.h"
#include "av1/common/obmc.h"
#include "av1/common/reconinter.h"
#include "av1/common/reconintra.h"
static int allow_warp(const MB_MODE_INFO *const mbmi,
const WarpTypesAllowed *const warp_types,
const WarpedMotionParams *const gm_params,
int build_for_obmc, const struct scale_factors *const sf,
WarpedMotionParams *final_warp_params) { … }
void av1_init_warp_params(InterPredParams *inter_pred_params,
const WarpTypesAllowed *warp_types, int ref,
const MACROBLOCKD *xd, const MB_MODE_INFO *mi) { … }
void av1_make_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
int dst_stride,
InterPredParams *inter_pred_params,
const SubpelParams *subpel_params) { … }
static const uint8_t wedge_master_oblique_odd[MASK_MASTER_SIZE] = …;
static const uint8_t wedge_master_oblique_even[MASK_MASTER_SIZE] = …;
static const uint8_t wedge_master_vertical[MASK_MASTER_SIZE] = …;
static inline void shift_copy(const uint8_t *src, uint8_t *dst, int shift,
int width) { … }
DECLARE_ALIGNED(16, static uint8_t,
wedge_signflip_lookup[BLOCK_SIZES_ALL][MAX_WEDGE_TYPES]) = …;
DECLARE_ALIGNED(…);
DECLARE_ALIGNED(…);
DECLARE_ALIGNED(…);
static wedge_masks_type wedge_masks[BLOCK_SIZES_ALL][2];
static const wedge_code_type wedge_codebook_16_hgtw[16] = …;
static const wedge_code_type wedge_codebook_16_hltw[16] = …;
static const wedge_code_type wedge_codebook_16_heqw[16] = …;
const wedge_params_type av1_wedge_params_lookup[BLOCK_SIZES_ALL] = …;
static const uint8_t *get_wedge_mask_inplace(int wedge_index, int neg,
BLOCK_SIZE sb_type) { … }
const uint8_t *av1_get_compound_type_mask(
const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type) { … }
static inline void diffwtd_mask_d16(uint8_t *mask, int which_inverse,
int mask_base, const CONV_BUF_TYPE *src0,
int src0_stride, const CONV_BUF_TYPE *src1,
int src1_stride, int h, int w,
ConvolveParams *conv_params, int bd) { … }
void av1_build_compound_diffwtd_mask_d16_c(
uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const CONV_BUF_TYPE *src0,
int src0_stride, const CONV_BUF_TYPE *src1, int src1_stride, int h, int w,
ConvolveParams *conv_params, int bd) { … }
static inline void diffwtd_mask(uint8_t *mask, int which_inverse, int mask_base,
const uint8_t *src0, int src0_stride,
const uint8_t *src1, int src1_stride, int h,
int w) { … }
void av1_build_compound_diffwtd_mask_c(uint8_t *mask,
DIFFWTD_MASK_TYPE mask_type,
const uint8_t *src0, int src0_stride,
const uint8_t *src1, int src1_stride,
int h, int w) { … }
#if CONFIG_AV1_HIGHBITDEPTH
static AOM_FORCE_INLINE void diffwtd_mask_highbd(
uint8_t *mask, int which_inverse, int mask_base, const uint16_t *src0,
int src0_stride, const uint16_t *src1, int src1_stride, int h, int w,
const unsigned int bd) {
assert(bd >= 8);
if (bd == 8) {
if (which_inverse) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
int diff = abs((int)src0[j] - (int)src1[j]) / DIFF_FACTOR;
unsigned int m = negative_to_zero(mask_base + diff);
m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
mask[j] = AOM_BLEND_A64_MAX_ALPHA - m;
}
src0 += src0_stride;
src1 += src1_stride;
mask += w;
}
} else {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
int diff = abs((int)src0[j] - (int)src1[j]) / DIFF_FACTOR;
unsigned int m = negative_to_zero(mask_base + diff);
m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
mask[j] = m;
}
src0 += src0_stride;
src1 += src1_stride;
mask += w;
}
}
} else {
const unsigned int bd_shift = bd - 8;
if (which_inverse) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
int diff =
(abs((int)src0[j] - (int)src1[j]) >> bd_shift) / DIFF_FACTOR;
unsigned int m = negative_to_zero(mask_base + diff);
m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
mask[j] = AOM_BLEND_A64_MAX_ALPHA - m;
}
src0 += src0_stride;
src1 += src1_stride;
mask += w;
}
} else {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
int diff =
(abs((int)src0[j] - (int)src1[j]) >> bd_shift) / DIFF_FACTOR;
unsigned int m = negative_to_zero(mask_base + diff);
m = AOMMIN(m, AOM_BLEND_A64_MAX_ALPHA);
mask[j] = m;
}
src0 += src0_stride;
src1 += src1_stride;
mask += w;
}
}
}
}
void av1_build_compound_diffwtd_mask_highbd_c(
uint8_t *mask, DIFFWTD_MASK_TYPE mask_type, const uint8_t *src0,
int src0_stride, const uint8_t *src1, int src1_stride, int h, int w,
int bd) {
switch (mask_type) {
case DIFFWTD_38:
diffwtd_mask_highbd(mask, 0, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
break;
case DIFFWTD_38_INV:
diffwtd_mask_highbd(mask, 1, 38, CONVERT_TO_SHORTPTR(src0), src0_stride,
CONVERT_TO_SHORTPTR(src1), src1_stride, h, w, bd);
break;
default: assert(0);
}
}
#endif
static inline void init_wedge_master_masks(void) { … }
static inline void init_wedge_masks(void) { … }
static const uint8_t ii_weights1d[MAX_SB_SIZE] = …;
static uint8_t ii_size_scales[BLOCK_SIZES_ALL] = …;
static inline void build_smooth_interintra_mask(uint8_t *mask, int stride,
BLOCK_SIZE plane_bsize,
INTERINTRA_MODE mode) { … }
static inline void init_smooth_interintra_masks(void) { … }
static void init_all_wedge_masks(void) { … }
void av1_init_wedge_masks(void) { … }
static inline void build_masked_compound_no_round(
uint8_t *dst, int dst_stride, const CONV_BUF_TYPE *src0, int src0_stride,
const CONV_BUF_TYPE *src1, int src1_stride,
const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
int w, InterPredParams *inter_pred_params) { … }
void av1_make_masked_inter_predictor(const uint8_t *pre, int pre_stride,
uint8_t *dst, int dst_stride,
InterPredParams *inter_pred_params,
const SubpelParams *subpel_params) { … }
void av1_dist_wtd_comp_weight_assign(const AV1_COMMON *cm,
const MB_MODE_INFO *mbmi, int *fwd_offset,
int *bck_offset,
int *use_dist_wtd_comp_avg,
int is_compound) { … }
void av1_setup_dst_planes(struct macroblockd_plane *planes, BLOCK_SIZE bsize,
const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col,
const int plane_start, const int plane_end) { … }
void av1_setup_pre_planes(MACROBLOCKD *xd, int idx,
const YV12_BUFFER_CONFIG *src, int mi_row, int mi_col,
const struct scale_factors *sf,
const int num_planes) { … }
static const uint8_t obmc_mask_1[1] = …;
DECLARE_ALIGNED(2, static const uint8_t, obmc_mask_2[2]) = …;
DECLARE_ALIGNED(4, static const uint8_t, obmc_mask_4[4]) = …;
static const uint8_t obmc_mask_8[8] = …;
static const uint8_t obmc_mask_16[16] = …;
static const uint8_t obmc_mask_32[32] = …;
static const uint8_t obmc_mask_64[64] = …;
const uint8_t *av1_get_obmc_mask(int length) { … }
static inline void increment_int_ptr(MACROBLOCKD *xd, int rel_mi_row,
int rel_mi_col, uint8_t op_mi_size,
int dir, MB_MODE_INFO *mi, void *fun_ctxt,
const int num_planes) { … }
void av1_count_overlappable_neighbors(const AV1_COMMON *cm, MACROBLOCKD *xd) { … }
#define DISABLE_CHROMA_U8X8_OBMC …
int av1_skip_u4x4_pred_in_obmc(BLOCK_SIZE bsize,
const struct macroblockd_plane *pd, int dir) { … }
static void modify_neighbor_predictor_for_obmc(MB_MODE_INFO *mbmi) { … }
struct obmc_inter_pred_ctxt { … };
static inline void build_obmc_inter_pred_above(
MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
int dir, MB_MODE_INFO *above_mi, void *fun_ctxt, const int num_planes) { … }
static inline void build_obmc_inter_pred_left(
MACROBLOCKD *xd, int rel_mi_row, int rel_mi_col, uint8_t op_mi_size,
int dir, MB_MODE_INFO *left_mi, void *fun_ctxt, const int num_planes) { … }
void av1_build_obmc_inter_prediction(const AV1_COMMON *cm, MACROBLOCKD *xd,
uint8_t *above[MAX_MB_PLANE],
int above_stride[MAX_MB_PLANE],
uint8_t *left[MAX_MB_PLANE],
int left_stride[MAX_MB_PLANE]) { … }
void av1_setup_obmc_dst_bufs(MACROBLOCKD *xd, uint8_t **dst_buf1,
uint8_t **dst_buf2) { … }
void av1_setup_build_prediction_by_above_pred(
MACROBLOCKD *xd, int rel_mi_col, uint8_t above_mi_width,
MB_MODE_INFO *above_mbmi, struct build_prediction_ctxt *ctxt,
const int num_planes) { … }
void av1_setup_build_prediction_by_left_pred(MACROBLOCKD *xd, int rel_mi_row,
uint8_t left_mi_height,
MB_MODE_INFO *left_mbmi,
struct build_prediction_ctxt *ctxt,
const int num_planes) { … }
static inline void combine_interintra(
INTERINTRA_MODE mode, int8_t use_wedge_interintra, int8_t wedge_index,
int8_t wedge_sign, BLOCK_SIZE bsize, BLOCK_SIZE plane_bsize,
uint8_t *comppred, int compstride, const uint8_t *interpred,
int interstride, const uint8_t *intrapred, int intrastride) { … }
#if CONFIG_AV1_HIGHBITDEPTH
static inline void combine_interintra_highbd(
INTERINTRA_MODE mode, int8_t use_wedge_interintra, int8_t wedge_index,
int8_t wedge_sign, BLOCK_SIZE bsize, BLOCK_SIZE plane_bsize,
uint8_t *comppred8, int compstride, const uint8_t *interpred8,
int interstride, const uint8_t *intrapred8, int intrastride, int bd) {
const int bw = block_size_wide[plane_bsize];
const int bh = block_size_high[plane_bsize];
if (use_wedge_interintra) {
if (av1_is_wedge_used(bsize)) {
const uint8_t *mask =
av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
const int subh = 2 * mi_size_high[bsize] == bh;
const int subw = 2 * mi_size_wide[bsize] == bw;
aom_highbd_blend_a64_mask(comppred8, compstride, intrapred8, intrastride,
interpred8, interstride, mask,
block_size_wide[bsize], bw, bh, subw, subh, bd);
}
return;
}
uint8_t mask[MAX_SB_SQUARE];
build_smooth_interintra_mask(mask, bw, plane_bsize, mode);
aom_highbd_blend_a64_mask(comppred8, compstride, intrapred8, intrastride,
interpred8, interstride, mask, bw, bw, bh, 0, 0,
bd);
}
#endif
void av1_build_intra_predictors_for_interintra(const AV1_COMMON *cm,
MACROBLOCKD *xd,
BLOCK_SIZE bsize, int plane,
const BUFFER_SET *ctx,
uint8_t *dst, int dst_stride) { … }
void av1_combine_interintra(MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane,
const uint8_t *inter_pred, int inter_stride,
const uint8_t *intra_pred, int intra_stride) { … }
void av1_build_interintra_predictor(const AV1_COMMON *cm, MACROBLOCKD *xd,
uint8_t *pred, int stride,
const BUFFER_SET *ctx, int plane,
BLOCK_SIZE bsize) { … }