AOMedia AV1 Codec
tx_search.h
1/*
2 * Copyright (c) 2020, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12#ifndef AOM_AV1_ENCODER_TRANSFORM_SEARCH_H_
13#define AOM_AV1_ENCODER_TRANSFORM_SEARCH_H_
14
15#include "av1/common/pred_common.h"
16#include "av1/encoder/encoder.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22// Set this macro as 1 to collect data about tx size selection.
23#define COLLECT_TX_SIZE_DATA 0
24
25#if COLLECT_TX_SIZE_DATA
26static const char av1_tx_size_data_output_file[] = "tx_size_data.txt";
27#endif
28
29enum {
30 FTXS_NONE = 0,
31 FTXS_DCT_AND_1D_DCT_ONLY = 1 << 0,
32 FTXS_DISABLE_TRELLIS_OPT = 1 << 1,
33 FTXS_USE_TRANSFORM_DOMAIN = 1 << 2
34} UENUM1BYTE(FAST_TX_SEARCH_MODE);
35
36static AOM_INLINE int tx_size_cost(const MACROBLOCK *const x, BLOCK_SIZE bsize,
37 TX_SIZE tx_size) {
38 assert(bsize == x->e_mbd.mi[0]->bsize);
39 if (x->txfm_search_params.tx_mode_search_type != TX_MODE_SELECT ||
40 !block_signals_txsize(bsize))
41 return 0;
42
43 const int32_t tx_size_cat = bsize_to_tx_size_cat(bsize);
44 const int depth = tx_size_to_depth(tx_size, bsize);
45 const MACROBLOCKD *const xd = &x->e_mbd;
46 const int tx_size_ctx = get_tx_size_context(xd);
47 return x->mode_costs.tx_size_cost[tx_size_cat][tx_size_ctx][depth];
48}
49
50int64_t av1_estimate_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
51 RD_STATS *rd_stats, int64_t ref_best_rd,
52 BLOCK_SIZE bs, TX_SIZE tx_size);
53
73int64_t av1_uniform_txfm_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
74 RD_STATS *rd_stats, int64_t ref_best_rd,
75 BLOCK_SIZE bs, TX_SIZE tx_size,
76 FAST_TX_SEARCH_MODE ftxs_mode, int skip_trellis);
77
96 RD_STATS *rd_stats, BLOCK_SIZE bsize,
97 int64_t ref_best_rd);
98
117void av1_pick_uniform_tx_size_type_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
118 RD_STATS *rd_stats, BLOCK_SIZE bs,
119 int64_t ref_best_rd);
120
136int av1_txfm_uvrd(const AV1_COMP *const cpi, MACROBLOCK *x, RD_STATS *rd_stats,
137 BLOCK_SIZE bsize, int64_t ref_best_rd);
138
163void av1_txfm_rd_in_plane(MACROBLOCK *x, const AV1_COMP *cpi,
164 RD_STATS *rd_stats, int64_t ref_best_rd,
165 int64_t current_rd, int plane, BLOCK_SIZE plane_bsize,
166 TX_SIZE tx_size, FAST_TX_SEARCH_MODE ftxs_mode,
167 int skip_trellis);
168
197int av1_txfm_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
198 RD_STATS *rd_stats, RD_STATS *rd_stats_y,
199 RD_STATS *rd_stats_uv, int mode_rate, int64_t ref_best_rd);
200
201#ifdef __cplusplus
202} // extern "C"
203#endif
204
205#endif // AOM_AV1_ENCODER_TRANSFORM_SEARCH_H_
Declares top-level encoder structures and functions.
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.
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.
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.
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 skip_trellis)
Transform type search with fixed transform size.
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.
int64_t av1_uniform_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, FAST_TX_SEARCH_MODE ftxs_mode, int skip_trellis)
Transform type search for luma macroblock with fixed transform size.
BLOCK_SIZE bsize
The block size of the current coding block.
Definition: blockd.h:228
int tx_size_cost[TX_SIZES - 1][3][TX_SIZES]
tx_size_cost
Definition: block.h:659
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition: block.h:430
Encoder's parameters related to the current coding block.
Definition: block.h:813
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:831
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition: block.h:932
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition: block.h:1205
Variables related to current coding block.
Definition: blockd.h:577
MB_MODE_INFO ** mi
Definition: blockd.h:624