#include <math.h>
#include <stdbool.h>
#include <string.h>
#include "config/aom_dsp_rtcd.h"
#include "config/aom_scale_rtcd.h"
#include "aom/aom_integer.h"
#include "av1/common/av1_common_int.h"
#include "av1/common/reconinter.h"
#include "av1/encoder/encoder.h"
#include "av1/encoder/ethread.h"
#include "av1/encoder/pickcdef.h"
#include "av1/encoder/mcomp.h"
static inline void get_cdef_filter_strengths(CDEF_PICK_METHOD pick_method,
int *pri_strength,
int *sec_strength,
int strength_idx) { … }
#define STORE_CDEF_FILTER_STRENGTH(cdef_strength, pick_method, strength_idx) …
static uint64_t search_one(int *lev, int nb_strengths,
uint64_t mse[][TOTAL_STRENGTHS], int sb_count,
CDEF_PICK_METHOD pick_method) { … }
static uint64_t search_one_dual(int *lev0, int *lev1, int nb_strengths,
uint64_t (**mse)[TOTAL_STRENGTHS], int sb_count,
CDEF_PICK_METHOD pick_method) { … }
static uint64_t joint_strength_search(int *best_lev, int nb_strengths,
uint64_t mse[][TOTAL_STRENGTHS],
int sb_count,
CDEF_PICK_METHOD pick_method) { … }
static uint64_t joint_strength_search_dual(int *best_lev0, int *best_lev1,
int nb_strengths,
uint64_t (**mse)[TOTAL_STRENGTHS],
int sb_count,
CDEF_PICK_METHOD pick_method) { … }
static inline void init_src_params(int *src_stride, int *width, int *height,
int *width_log2, int *height_log2,
BLOCK_SIZE bsize) { … }
#if CONFIG_AV1_HIGHBITDEPTH
static uint64_t compute_cdef_dist_highbd(void *dst, int dstride, uint16_t *src,
cdef_list *dlist, int cdef_count,
BLOCK_SIZE bsize, int coeff_shift,
int row, int col) {
assert(bsize == BLOCK_4X4 || bsize == BLOCK_4X8 || bsize == BLOCK_8X4 ||
bsize == BLOCK_8X8);
uint64_t sum = 0;
int bi, bx, by;
uint16_t *dst16 = CONVERT_TO_SHORTPTR((uint8_t *)dst);
uint16_t *dst_buff = &dst16[row * dstride + col];
int src_stride, width, height, width_log2, height_log2;
init_src_params(&src_stride, &width, &height, &width_log2, &height_log2,
bsize);
for (bi = 0; bi < cdef_count; bi++) {
by = dlist[bi].by;
bx = dlist[bi].bx;
sum += aom_mse_wxh_16bit_highbd(
&dst_buff[(by << height_log2) * dstride + (bx << width_log2)], dstride,
&src[bi << (height_log2 + width_log2)], src_stride, width, height);
}
return sum >> 2 * coeff_shift;
}
#endif
static inline int is_dual_or_quad_applicable(cdef_list *dlist, int width,
int cdef_count, int bi, int iter) { … }
static uint64_t compute_cdef_dist(void *dst, int dstride, uint16_t *src,
cdef_list *dlist, int cdef_count,
BLOCK_SIZE bsize, int coeff_shift, int row,
int col) { … }
static inline void fill_borders_for_fbs_on_frame_boundary(
uint16_t *inbuf, int hfilt_size, int vfilt_size,
bool is_fb_on_frm_left_boundary, bool is_fb_on_frm_right_boundary,
bool is_fb_on_frm_top_boundary, bool is_fb_on_frm_bottom_boundary) { … }
static AOM_FORCE_INLINE int get_error_calc_width_in_filt_units(
cdef_list *dlist, int cdef_count, int bi, int subsampling_x,
int subsampling_y) { … }
static inline uint64_t get_filt_error(
const CdefSearchCtx *cdef_search_ctx, const struct macroblockd_plane *pd,
cdef_list *dlist, int dir[CDEF_NBLOCKS][CDEF_NBLOCKS], int *dirinit,
int var[CDEF_NBLOCKS][CDEF_NBLOCKS], uint16_t *in, uint8_t *ref_buffer,
int ref_stride, int row, int col, int pri_strength, int sec_strength,
int cdef_count, int pli, int coeff_shift, BLOCK_SIZE bs) { … }
void av1_cdef_mse_calc_block(CdefSearchCtx *cdef_search_ctx,
struct aom_internal_error_info *error_info,
int fbr, int fbc, int sb_count) { … }
static void cdef_mse_calc_frame(CdefSearchCtx *cdef_search_ctx,
struct aom_internal_error_info *error_info) { … }
static void cdef_alloc_data(AV1_COMMON *cm, CdefSearchCtx *cdef_search_ctx) { … }
void av1_cdef_dealloc_data(CdefSearchCtx *cdef_search_ctx) { … }
static inline void cdef_params_init(const YV12_BUFFER_CONFIG *frame,
const YV12_BUFFER_CONFIG *ref,
AV1_COMMON *cm, MACROBLOCKD *xd,
CdefSearchCtx *cdef_search_ctx,
CDEF_PICK_METHOD pick_method) { … }
void av1_pick_cdef_from_qp(AV1_COMMON *const cm, int skip_cdef,
int is_screen_content) { … }
void av1_cdef_search(AV1_COMP *cpi) { … }