chromium/third_party/libaom/source/libaom/av1/common/blockd.h

/*
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

#ifndef AOM_AV1_COMMON_BLOCKD_H_
#define AOM_AV1_COMMON_BLOCKD_H_

#include "config/aom_config.h"

#include "aom_dsp/aom_dsp_common.h"
#include "aom_ports/mem.h"
#include "aom_scale/yv12config.h"

#include "av1/common/common_data.h"
#include "av1/common/quant_common.h"
#include "av1/common/entropy.h"
#include "av1/common/entropymode.h"
#include "av1/common/mv.h"
#include "av1/common/scale.h"
#include "av1/common/seg_common.h"
#include "av1/common/tile_common.h"

#ifdef __cplusplus
extern "C" {
#endif

#define USE_B_QUANT_NO_TRELLIS

#define MAX_MB_PLANE

#define MAX_DIFFWTD_MASK_BITS

#define INTERINTRA_WEDGE_SIGN

#define DEFAULT_INTER_TX_TYPE

#define MAX_PALETTE_BLOCK_WIDTH

#define MAX_PALETTE_BLOCK_HEIGHT

/*!\cond */

// DIFFWTD_MASK_TYPES should not surpass 1 << MAX_DIFFWTD_MASK_BITS
enum {} UENUM1BYTE();

enum {} UENUM1BYTE();

static inline int is_comp_ref_allowed(BLOCK_SIZE bsize) {}

static inline int is_inter_mode(PREDICTION_MODE mode) {}

BUFFER_SET;

static inline int is_inter_singleref_mode(PREDICTION_MODE mode) {}
static inline int is_inter_compound_mode(PREDICTION_MODE mode) {}

static inline PREDICTION_MODE compound_ref0_mode(PREDICTION_MODE mode) {}

static inline PREDICTION_MODE compound_ref1_mode(PREDICTION_MODE mode) {}

static inline int have_nearmv_in_inter_mode(PREDICTION_MODE mode) {}

static inline int have_newmv_in_inter_mode(PREDICTION_MODE mode) {}

static inline int is_masked_compound_type(COMPOUND_TYPE type) {}

/* For keyframes, intra block modes are predicted by the (already decoded)
   modes for the Y blocks to the left and above us; for interframes, there
   is a single probability table. */

PALETTE_MODE_INFO;

FILTER_INTRA_MODE_INFO;

static const PREDICTION_MODE fimode_to_intradir[FILTER_INTRA_MODES] =;

#if CONFIG_RD_DEBUG
#define TXB_COEFF_COST_MAP_SIZE
#endif

RD_STATS;

// This struct is used to group function args that are commonly
// sent together in functions related to interinter compound modes
INTERINTER_COMPOUND_DATA;

#define INTER_TX_SIZE_BUF_LEN
#define TXK_TYPE_BUF_LEN
/*!\endcond */

/*! \brief Stores the prediction/txfm mode of the current coding block
 */
MB_MODE_INFO;

/*!\cond */

static inline int is_intrabc_block(const MB_MODE_INFO *mbmi) {}

static inline PREDICTION_MODE get_uv_mode(UV_PREDICTION_MODE mode) {}

static inline int is_inter_block(const MB_MODE_INFO *mbmi) {}

static inline int has_second_ref(const MB_MODE_INFO *mbmi) {}

static inline int has_uni_comp_refs(const MB_MODE_INFO *mbmi) {}

static inline MV_REFERENCE_FRAME comp_ref0(int ref_idx) {}

static inline MV_REFERENCE_FRAME comp_ref1(int ref_idx) {}

PREDICTION_MODE av1_left_block_mode(const MB_MODE_INFO *left_mi);

PREDICTION_MODE av1_above_block_mode(const MB_MODE_INFO *above_mi);

static inline int is_global_mv_block(const MB_MODE_INFO *const mbmi,
                                     TransformationType type) {}

#if CONFIG_MISMATCH_DEBUG
static inline void mi_to_pixel_loc(int *pixel_c, int *pixel_r, int mi_col,
                                   int mi_row, int tx_blk_col, int tx_blk_row,
                                   int subsampling_x, int subsampling_y) {
  *pixel_c = ((mi_col >> subsampling_x) << MI_SIZE_LOG2) +
             (tx_blk_col << MI_SIZE_LOG2);
  *pixel_r = ((mi_row >> subsampling_y) << MI_SIZE_LOG2) +
             (tx_blk_row << MI_SIZE_LOG2);
}
#endif

enum {} UENUM1BYTE();

struct buf_2d {};

eob_info;

CB_BUFFER;

MACROBLOCKD_PLANE;

#define BLOCK_OFFSET(i)

/*!\endcond */

/*!\brief Parameters related to Wiener Filter */
WienerInfo;

/*!\brief Parameters related to Sgrproj Filter */
SgrprojInfo;

/*!\cond */

#define CFL_MAX_BLOCK_SIZE
#define CFL_BUF_LINE
#define CFL_BUF_LINE_I128
#define CFL_BUF_LINE_I256
#define CFL_BUF_SQUARE
CFL_CTX;

DIST_WTD_COMP_PARAMS;

struct scale_factors;

/*!\endcond */

/*! \brief Variables related to current coding block.
 *
 * This is a common set of variables used by both encoder and decoder.
 * Most/all of the pointers are mere pointers to actual arrays are allocated
 * elsewhere. This is mostly for coding convenience.
 */
MACROBLOCKD;

/*!\cond */

static inline int is_cur_buf_hbd(const MACROBLOCKD *xd) {}

static inline uint8_t *get_buf_by_bd(const MACROBLOCKD *xd, uint8_t *buf16) {}

BitDepthInfo;

static inline BitDepthInfo get_bit_depth_info(const MACROBLOCKD *xd) {}

static inline int get_sqr_bsize_idx(BLOCK_SIZE bsize) {}

// For a square block size 'bsize', returns the size of the sub-blocks used by
// the given partition type. If the partition produces sub-blocks of different
// sizes, then the function returns the largest sub-block size.
// Implements the Partition_Subsize lookup table in the spec (Section 9.3.
// Conversion tables).
// Note: the input block size should be square.
// Otherwise it's considered invalid.
static inline BLOCK_SIZE get_partition_subsize(BLOCK_SIZE bsize,
                                               PARTITION_TYPE partition) {}

static TX_TYPE intra_mode_to_tx_type(const MB_MODE_INFO *mbmi,
                                     PLANE_TYPE plane_type) {}

static inline int is_rect_tx(TX_SIZE tx_size) {}

static inline int block_signals_txsize(BLOCK_SIZE bsize) {}

// Number of transform types in each set type
static const int av1_num_ext_tx_set[EXT_TX_SET_TYPES] =;

static const int av1_ext_tx_used[EXT_TX_SET_TYPES][TX_TYPES] =;

// The bitmask corresponds to the transform types as defined in
// enums.h TX_TYPE enumeration type. Setting the bit 0 means to disable
// the use of the corresponding transform type in that table.
// The av1_derived_intra_tx_used_flag table is used when
// use_reduced_intra_txset is set to 2, where one only searches
// the transform types derived from residual statistics.
static const uint16_t av1_derived_intra_tx_used_flag[INTRA_MODES] =;

static const uint16_t av1_reduced_intra_tx_used_flag[INTRA_MODES] =;

static const uint16_t av1_ext_tx_used_flag[EXT_TX_SET_TYPES] =;

static const TxSetType av1_ext_tx_set_lookup[2][2] =;

static inline TxSetType av1_get_ext_tx_set_type(TX_SIZE tx_size, int is_inter,
                                                int use_reduced_set) {}

// Maps tx set types to the indices.
static const int ext_tx_set_index[2][EXT_TX_SET_TYPES] =;

static inline int get_ext_tx_set(TX_SIZE tx_size, int is_inter,
                                 int use_reduced_set) {}

static inline int get_ext_tx_types(TX_SIZE tx_size, int is_inter,
                                   int use_reduced_set) {}

#define TXSIZEMAX(t1, t2)
#define TXSIZEMIN(t1, t2)

static inline TX_SIZE tx_size_from_tx_mode(BLOCK_SIZE bsize, TX_MODE tx_mode) {}

static const uint8_t mode_to_angle_map[INTRA_MODES] =;

// Converts block_index for given transform size to index of the block in raster
// order.
static inline int av1_block_index_to_raster_order(TX_SIZE tx_size,
                                                  int block_idx) {}

// Inverse of above function.
// Note: only implemented for transform sizes 4x4, 4x8 and 8x4 right now.
static inline int av1_raster_order_to_block_index(TX_SIZE tx_size,
                                                  int raster_order) {}

static inline TX_TYPE get_default_tx_type(PLANE_TYPE plane_type,
                                          const MACROBLOCKD *xd,
                                          TX_SIZE tx_size,
                                          int use_screen_content_tools) {}

// Implements the get_plane_residual_size() function in the spec (Section
// 5.11.38. Get plane residual size function).
static inline BLOCK_SIZE get_plane_block_size(BLOCK_SIZE bsize,
                                              int subsampling_x,
                                              int subsampling_y) {}

/*
 * Logic to generate the lookup tables:
 *
 * TX_SIZE txs = max_txsize_rect_lookup[bsize];
 * for (int level = 0; level < MAX_VARTX_DEPTH - 1; ++level)
 *   txs = sub_tx_size_map[txs];
 * const int tx_w_log2 = tx_size_wide_log2[txs] - MI_SIZE_LOG2;
 * const int tx_h_log2 = tx_size_high_log2[txs] - MI_SIZE_LOG2;
 * const int bw_uint_log2 = mi_size_wide_log2[bsize];
 * const int stride_log2 = bw_uint_log2 - tx_w_log2;
 */
static inline int av1_get_txb_size_index(BLOCK_SIZE bsize, int blk_row,
                                         int blk_col) {}

#if CONFIG_INSPECTION
/*
 * Here is the logic to generate the lookup tables:
 *
 * TX_SIZE txs = max_txsize_rect_lookup[bsize];
 * for (int level = 0; level < MAX_VARTX_DEPTH; ++level)
 *   txs = sub_tx_size_map[txs];
 * const int tx_w_log2 = tx_size_wide_log2[txs] - MI_SIZE_LOG2;
 * const int tx_h_log2 = tx_size_high_log2[txs] - MI_SIZE_LOG2;
 * const int bw_uint_log2 = mi_size_wide_log2[bsize];
 * const int stride_log2 = bw_uint_log2 - tx_w_log2;
 */
static inline int av1_get_txk_type_index(BLOCK_SIZE bsize, int blk_row,
                                         int blk_col) {
  static const uint8_t tw_w_log2_table[BLOCK_SIZES_ALL] = {
    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2,
  };
  static const uint8_t tw_h_log2_table[BLOCK_SIZES_ALL] = {
    0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2,
  };
  static const uint8_t stride_log2_table[BLOCK_SIZES_ALL] = {
    0, 0, 1, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 3, 3, 0, 2, 0, 2, 0, 2,
  };
  const int index =
      ((blk_row >> tw_h_log2_table[bsize]) << stride_log2_table[bsize]) +
      (blk_col >> tw_w_log2_table[bsize]);
  assert(index < TXK_TYPE_BUF_LEN);
  return index;
}
#endif  // CONFIG_INSPECTION

static inline void update_txk_array(MACROBLOCKD *const xd, int blk_row,
                                    int blk_col, TX_SIZE tx_size,
                                    TX_TYPE tx_type) {}

static inline TX_TYPE av1_get_tx_type(const MACROBLOCKD *xd,
                                      PLANE_TYPE plane_type, int blk_row,
                                      int blk_col, TX_SIZE tx_size,
                                      int reduced_tx_set) {}

void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y,
                            const int num_planes);

/*
 * Logic to generate the lookup table:
 *
 * TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
 * int depth = 0;
 * while (depth < MAX_TX_DEPTH && tx_size != TX_4X4) {
 *   depth++;
 *   tx_size = sub_tx_size_map[tx_size];
 * }
 */
static inline int bsize_to_max_depth(BLOCK_SIZE bsize) {}

/*
 * Logic to generate the lookup table:
 *
 * TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
 * assert(tx_size != TX_4X4);
 * int depth = 0;
 * while (tx_size != TX_4X4) {
 *   depth++;
 *   tx_size = sub_tx_size_map[tx_size];
 * }
 * assert(depth < 10);
 */
static inline int bsize_to_tx_size_cat(BLOCK_SIZE bsize) {}

static inline TX_SIZE depth_to_tx_size(int depth, BLOCK_SIZE bsize) {}

static inline TX_SIZE av1_get_adjusted_tx_size(TX_SIZE tx_size) {}

static inline TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int subsampling_x,
                                            int subsampling_y) {}

static inline TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) {}

void av1_reset_entropy_context(MACROBLOCKD *xd, BLOCK_SIZE bsize,
                               const int num_planes);

void av1_reset_loop_filter_delta(MACROBLOCKD *xd, int num_planes);

void av1_reset_loop_restoration(MACROBLOCKD *xd, const int num_planes);

foreach_transformed_block_visitor;

void av1_set_entropy_contexts(const MACROBLOCKD *xd,
                              struct macroblockd_plane *pd, int plane,
                              BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
                              int has_eob, int aoff, int loff);

#define MAX_INTERINTRA_SB_SQUARE
static inline int is_interintra_mode(const MB_MODE_INFO *mbmi) {}

static inline int is_interintra_allowed_bsize(const BLOCK_SIZE bsize) {}

static inline int is_interintra_allowed_mode(const PREDICTION_MODE mode) {}

static inline int is_interintra_allowed_ref(const MV_REFERENCE_FRAME rf[2]) {}

static inline int is_interintra_allowed(const MB_MODE_INFO *mbmi) {}

static inline int is_interintra_allowed_bsize_group(int group) {}

static inline int is_interintra_pred(const MB_MODE_INFO *mbmi) {}

static inline int get_vartx_max_txsize(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
                                       int plane) {}

static inline int is_motion_variation_allowed_bsize(BLOCK_SIZE bsize) {}

static inline int is_motion_variation_allowed_compound(
    const MB_MODE_INFO *mbmi) {}

// input: log2 of length, 0(4), 1(8), ...
static const int max_neighbor_obmc[6] =;

static inline int check_num_overlappable_neighbors(const MB_MODE_INFO *mbmi) {}

static inline MOTION_MODE motion_mode_allowed(
    const WarpedMotionParams *gm_params, const MACROBLOCKD *xd,
    const MB_MODE_INFO *mbmi, int allow_warped_motion) {}

static inline int is_neighbor_overlappable(const MB_MODE_INFO *mbmi) {}

static inline int av1_allow_palette(int allow_screen_content_tools,
                                    BLOCK_SIZE sb_type) {}

// Returns sub-sampled dimensions of the given block.
// The output values for 'rows_within_bounds' and 'cols_within_bounds' will
// differ from 'height' and 'width' when part of the block is outside the
// right
// and/or bottom image boundary.
static inline void av1_get_block_dimensions(BLOCK_SIZE bsize, int plane,
                                            const MACROBLOCKD *xd, int *width,
                                            int *height,
                                            int *rows_within_bounds,
                                            int *cols_within_bounds) {}

/* clang-format off */
// Pointer to a three-dimensional array whose first dimension is PALETTE_SIZES.
MapCdf;
// Pointer to a const three-dimensional array whose first dimension is
// PALETTE_SIZES.
ColorCost;
/* clang-format on */

Av1ColorMapParam;

static inline int is_nontrans_global_motion(const MACROBLOCKD *xd,
                                            const MB_MODE_INFO *mbmi) {}

static inline PLANE_TYPE get_plane_type(int plane) {}

static inline int av1_get_max_eob(TX_SIZE tx_size) {}

/*!\endcond */

#ifdef __cplusplus
}  // extern "C"
#endif

#endif  // AOM_AV1_COMMON_BLOCKD_H_