chromium/third_party/libaom/source/libaom/av1/encoder/block.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.
 */

/*! \file
 * Declares various structs used to encode the current partition block.
 */
#ifndef AOM_AV1_ENCODER_BLOCK_H_
#define AOM_AV1_ENCODER_BLOCK_H_

#include "av1/common/blockd.h"
#include "av1/common/entropymv.h"
#include "av1/common/entropy.h"
#include "av1/common/enums.h"
#include "av1/common/mvref_common.h"

#include "av1/encoder/enc_enums.h"
#include "av1/encoder/mcomp_structs.h"
#if !CONFIG_REALTIME_ONLY
#include "av1/encoder/partition_cnn_weights.h"
#endif

#include "av1/encoder/hash_motion.h"

#ifdef __cplusplus
extern "C" {
#endif

//! Minimum linear dimension of a tpl block
#define MIN_TPL_BSIZE_1D
//! Maximum number of tpl block in a super block
#define MAX_TPL_BLK_IN_SB
//! Number of txfm hash records kept for the partition block.
#define RD_RECORD_BUFFER_LEN

/*! Maximum value taken by transform type probabilities */
#define MAX_TX_TYPE_PROB

//! Compute color sensitivity index for given plane
#define COLOR_SENS_IDX(plane)

//! Enable timer statistics of mode search in non-rd
#define COLLECT_NONRD_PICK_MODE_STAT

/*!\cond */
#if COLLECT_NONRD_PICK_MODE_STAT
#include "aom_ports/aom_timer.h"

typedef struct _mode_search_stat_nonrd {
  int32_t num_blocks[BLOCK_SIZES];
  int64_t total_block_times[BLOCK_SIZES];
  int32_t num_searches[BLOCK_SIZES][MB_MODE_COUNT];
  int32_t num_nonskipped_searches[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t search_times[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t nonskipped_search_times[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t ms_time[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t ifs_time[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t model_rd_time[BLOCK_SIZES][MB_MODE_COUNT];
  int64_t txfm_time[BLOCK_SIZES][MB_MODE_COUNT];
  struct aom_usec_timer timer1;
  struct aom_usec_timer timer2;
  struct aom_usec_timer bsize_timer;
} mode_search_stat_nonrd;
#endif  // COLLECT_NONRD_PICK_MODE_STAT
/*!\endcond */

/*! \brief Superblock level encoder info
 *
 * SuperblockEnc stores superblock level information used by the encoder for
 * more efficient encoding. Currently this is mostly used to store TPL data
 * for the current superblock.
 */
SuperBlockEnc;

/*! \brief Stores the best performing modes.
 */
WinnerModeStats;

/*! \brief Each source plane of the current macroblock
 *
 * This struct also stores the txfm buffers and quantizer settings.
 */
MACROBLOCK_PLANE;

/*! \brief Costs for encoding the coefficients within a level.
 *
 * Covers everything including txb_skip, eob, dc_sign,
 */
LV_MAP_COEFF_COST;

/*! \brief Costs for encoding the eob.
 */
LV_MAP_EOB_COST;

/*! \brief Stores the transforms coefficients for the whole superblock.
 */
CB_COEFF_BUFFER;

/*! \brief Extended mode info derived from mbmi.
 */
MB_MODE_INFO_EXT;

/*! \brief Stores best extended mode information at frame level.
 *
 * The frame level in here is used in bitstream preparation stage. The
 * information in \ref MB_MODE_INFO_EXT are copied to this struct to save
 * memory.
 */
MB_MODE_INFO_EXT_FRAME;

/*! \brief Inter-mode txfm results for a partition block.
 */
MB_RD_INFO;

/*! \brief Hash records of the inter-mode transform results
 *
 * Hash records of the inter-mode transform results for a whole partition block
 * based on the residue. Since this operates on the partition block level, this
 * can give us a whole txfm partition tree.
 */
MB_RD_RECORD;

//! Number of compound rd stats
#define MAX_COMP_RD_STATS
/*! \brief Rdcost stats in compound mode.
 */
COMP_RD_STATS;

/*! \brief Contains buffers used to speed up rdopt for obmc.
 *
 * See the comments for calc_target_weighted_pred for details.
 */
OBMCBuffer;

/*! \brief Contains color maps used in palette mode.
 */
PALETTE_BUFFER;

/*! \brief Contains buffers used by av1_compound_type_rd()
 *
 * For sizes and alignment of these arrays, refer to
 * alloc_compound_type_rd_buffers() function.
 */
CompoundTypeRdBuffers;

/*! \brief Holds some parameters related to partitioning schemes in AV1.
 */
// TODO([email protected]): Consolidate this with SIMPLE_MOTION_DATA_TREE
PartitionSearchInfo;

/*!\cond */
enum {} UENUM1BYTE();
/*!\endcond */

/*! \brief Defines the parameters used to perform txfm search.
 *
 * For the most part, this determines how various speed features are used.
 */
TxfmSearchParams;

/*!\cond */
#define MAX_NUM_8X8_TXBS
#define MAX_NUM_16X16_TXBS
#define MAX_NUM_32X32_TXBS
#define MAX_NUM_64X64_TXBS
/*!\endcond */

/*! \brief Stores various encoding/search decisions related to txfm search.
 *
 * This struct contains a cache of previous txfm results, and some buffers for
 * the current txfm decision.
 */
TxfmSearchInfo;
#undef MAX_NUM_8X8_TXBS
#undef MAX_NUM_16X16_TXBS
#undef MAX_NUM_32X32_TXBS
#undef MAX_NUM_64X64_TXBS

/*! \brief Holds the entropy costs for various modes sent to the bitstream.
 *
 * \attention This does not include the costs for mv and transformed
 * coefficients.
 */
ModeCosts;

/*! \brief Holds mv costs for encoding and motion search.
 */
MvCosts;

/*! \brief Holds mv costs for intrabc.
 */
IntraBCMVCosts;

/*! \brief Holds the costs needed to encode the coefficients
 */
CoeffCosts;

/*!\cond */
// 4: NEAREST, NEW, NEAR, GLOBAL
#define SINGLE_REF_MODES
/*!\endcond */
struct inter_modes_info;

/*! \brief Holds the motion samples for warp motion model estimation
 */
WARP_SAMPLE_INFO;

/*!\cond */
SOURCE_SAD;

CONTENT_STATE_SB;

// Structure to hold pixel level gradient info.
PixelLevelGradientInfo;

// Structure to hold the variance and log(1 + variance) for 4x4 sub-blocks.
Block4x4VarInfo;

#ifndef NDEBUG
SetOffsetsLoc;
#endif  // NDEBUG

/*!\endcond */

/*! \brief Encoder's parameters related to the current coding block.
 *
 * This struct contains most of the information the encoder needs to encode the
 * current coding block. This includes the src and pred buffer, a copy of the
 * decoder's view of the current block, the txfm coefficients. This struct also
 * contains various buffers and data used to speed up the encoding process.
 */
MACROBLOCK;
#undef SINGLE_REF_MODES

/*!\cond */
// Zeroes out 'n_stats' elements in the array x->winner_mode_stats.
// It only zeroes out what is necessary in 'color_index_map' (just the block
// size, not the whole array).
static inline void zero_winner_mode_stats(BLOCK_SIZE bsize, int n_stats,
                                          WinnerModeStats *stats) {}

static inline int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {}

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

static inline int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {}

static inline void set_blk_skip(uint8_t txb_skip[], int plane, int blk_idx,
                                int skip) {}

static inline int is_blk_skip(uint8_t *txb_skip, int plane, int blk_idx) {}

/*!\endcond */

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

#endif  // AOM_AV1_ENCODER_BLOCK_H_