tx_search.h
/*
* Copyright (c) 2020, 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_ENCODER_TRANSFORM_SEARCH_H_
#define AOM_AV1_ENCODER_TRANSFORM_SEARCH_H_
#include "av1/common/pred_common.h"
#include "av1/encoder/encoder.h"
#ifdef __cplusplus
extern "C" {
#endif
// Set this macro as 1 to collect data about tx size selection.
#define COLLECT_TX_SIZE_DATA 0
#if COLLECT_TX_SIZE_DATA
static const char av1_tx_size_data_output_file[] = "tx_size_data.txt";
#endif
enum {
FTXS_NONE = 0,
FTXS_DCT_AND_1D_DCT_ONLY = 1 << 0,
FTXS_DISABLE_TRELLIS_OPT = 1 << 1,
FTXS_USE_TRANSFORM_DOMAIN = 1 << 2
} UENUM1BYTE(FAST_TX_SEARCH_MODE);
static inline int tx_size_cost(const MACROBLOCK *const x, BLOCK_SIZE bsize,
TX_SIZE tx_size) {
assert(bsize == x->e_mbd.mi[0]->bsize);
if (x->txfm_search_params.tx_mode_search_type != TX_MODE_SELECT ||
!block_signals_txsize(bsize))
return 0;
const int32_t tx_size_cat = bsize_to_tx_size_cat(bsize);
const int depth = tx_size_to_depth(tx_size, bsize);
const MACROBLOCKD *const xd = &x->e_mbd;
const int tx_size_ctx = get_tx_size_context(xd);
return x->mode_costs.tx_size_cost[tx_size_cat][tx_size_ctx][depth];
}
int64_t av1_pixel_diff_dist(const MACROBLOCK *x, int plane, int blk_row,
int blk_col, const BLOCK_SIZE plane_bsize,
const BLOCK_SIZE tx_bsize,
unsigned int *block_mse_q8);
int64_t av1_estimate_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
RD_STATS *rd_stats, int64_t ref_best_rd,
BLOCK_SIZE bs, TX_SIZE tx_size);
void av1_pick_recursive_tx_size_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
RD_STATS *rd_stats, BLOCK_SIZE bsize,
int64_t ref_best_rd);
void av1_pick_uniform_tx_size_type_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
RD_STATS *rd_stats, BLOCK_SIZE bs,
int64_t ref_best_rd);
int av1_txfm_uvrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats,
BLOCK_SIZE bsize, int64_t ref_best_rd);
void av1_txfm_rd_in_plane(MACROBLOCK *x, const AV1_COMP *cpi,
RD_STATS *rd_stats, int64_t ref_best_rd,
int64_t current_rd, int plane, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, FAST_TX_SEARCH_MODE ftxs_mode);
int av1_txfm_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
RD_STATS *rd_stats, RD_STATS *rd_stats_y,
RD_STATS *rd_stats_uv, int mode_rate, int64_t ref_best_rd);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AV1_ENCODER_TRANSFORM_SEARCH_H_
MACROBLOCK
struct macroblock MACROBLOCK
Encoder's parameters related to the current coding block.
encoder.h
Declares top-level encoder structures and functions.
av1_pick_recursive_tx_size_type_yrd
void av1_pick_recursive_tx_size_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bsize, int64_t ref_best_rd)
Recursive transform size and type search.
av1_txfm_uvrd
int av1_txfm_uvrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bsize, int64_t ref_best_rd)
Chroma block transform search.
av1_pixel_diff_dist
int64_t av1_pixel_diff_dist(const MACROBLOCK *x, int plane, int blk_row, int blk_col, const BLOCK_SIZE plane_bsize, const BLOCK_SIZE tx_bsize, unsigned int *block_mse_q8)
Compute the pixel domain distortion.
av1_pick_uniform_tx_size_type_yrd
void av1_pick_uniform_tx_size_type_yrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats, BLOCK_SIZE bs, int64_t ref_best_rd)
Uniform transform size and type search.
av1_txfm_search
int av1_txfm_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats, RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, int mode_rate, int64_t ref_best_rd)
Recursive transform size and type search.
av1_txfm_rd_in_plane
void av1_txfm_rd_in_plane(MACROBLOCK *x, const AV1_COMP *cpi, RD_STATS *rd_stats, int64_t ref_best_rd, int64_t current_rd, int plane, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, FAST_TX_SEARCH_MODE ftxs_mode)
Transform type search with fixed transform size.
AV1_COMP
Top level encoder structure.
Definition encoder.h:2897
MB_MODE_INFO::bsize
BLOCK_SIZE bsize
The block size of the current coding block.
Definition blockd.h:228
ModeCosts::tx_size_cost
int tx_size_cost[TX_SIZES - 1][3][TX_SIZES]
tx_size_cost
Definition block.h:731
TxfmSearchParams::tx_mode_search_type
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition block.h:485
macroblock::e_mbd
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition block.h:907
macroblock::mode_costs
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition block.h:1028
macroblock::txfm_search_params
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition block.h:1320
macroblockd::mi
MB_MODE_INFO ** mi
Definition blockd.h:617