 |
AOMedia AV1 Codec
|
Go to the documentation of this file.
15 #ifndef AOM_AV1_ENCODER_PALETTE_H_
16 #define AOM_AV1_ENCODER_PALETTE_H_
18 #include "av1/common/blockd.h"
25 struct PICK_MODE_CONTEXT;
29 #define AV1_K_MEANS_RENAME(func, dim) func##_dim##dim##_c
31 void AV1_K_MEANS_RENAME(
av1_k_means, 1)(
const int *data,
int *centroids,
32 uint8_t *indices,
int n,
int k,
34 void AV1_K_MEANS_RENAME(
av1_k_means, 2)(
const int *data,
int *centroids,
35 uint8_t *indices,
int n,
int k,
55 uint8_t *indices,
int n,
int k,
int dim) {
59 av1_calc_indices_dim1(data, centroids, indices, n, k);
60 }
else if (dim == 2) {
61 av1_calc_indices_dim2(data, centroids, indices, n, k);
63 assert(0 &&
"Untemplated k means dimension");
87 static INLINE
void av1_k_means(
const int *data,
int *centroids,
88 uint8_t *indices,
int n,
int k,
int dim,
93 AV1_K_MEANS_RENAME(
av1_k_means, 1)(data, centroids, indices, n, k, max_itr);
94 }
else if (dim == 2) {
95 AV1_K_MEANS_RENAME(
av1_k_means, 2)(data, centroids, indices, n, k, max_itr);
97 assert(0 &&
"Untemplated k means dimension");
131 const uint16_t *colors,
int n_colors,
132 uint8_t *cache_color_found,
int *out_cache_colors);
147 int bit_depth,
int *zero_count,
int *min_bits);
161 const uint16_t *color_cache,
int n_cache,
176 const uint16_t *color_cache,
int n_cache,
187 int dc_mode_cost,
MB_MODE_INFO *best_mbmi, uint8_t *best_palette_color_map,
188 int64_t *best_rd, int64_t *best_model_rd,
int *rate,
int *rate_tokenonly,
189 int64_t *distortion,
int *skippable,
int *beat_best_rd,
190 struct PICK_MODE_CONTEXT *ctx, uint8_t *best_blk_skip,
191 uint8_t *tx_type_map);
201 uint8_t *best_palette_color_map,
203 int64_t *best_rd,
int *rate,
204 int *rate_tokenonly, int64_t *distortion,
215 #endif // AOM_AV1_ENCODER_PALETTE_H_
void av1_rd_pick_palette_intra_sby(const struct AV1_COMP *cpi, struct macroblock *x, BLOCK_SIZE bsize, int dc_mode_cost, MB_MODE_INFO *best_mbmi, uint8_t *best_palette_color_map, int64_t *best_rd, int64_t *best_model_rd, int *rate, int *rate_tokenonly, int64_t *distortion, int *skippable, int *beat_best_rd, struct PICK_MODE_CONTEXT *ctx, uint8_t *best_blk_skip, uint8_t *tx_type_map)
Search for the best palette in the luma plane.
REAL_TIME_SPEED_FEATURES rt_sf
Definition: speed_features.h:1184
int16_t mode_context[MODE_CTX_REF_FRAMES]
Context used to encode the current mode.
Definition: block.h:207
int av1_index_color_cache(const uint16_t *color_cache, int n_cache, const uint16_t *colors, int n_colors, uint8_t *cache_color_found, int *out_cache_colors)
Checks what colors are in the color cache.
Definition: palette.c:78
Declares top-level encoder structures and functions.
InterpFilter interp_filter
Definition: av1_common_int.h:383
int y_dc_delta_q
Definition: av1_common_int.h:592
static int intra_mode_info_cost_y(const AV1_COMP *cpi, const MACROBLOCK *x, const MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, int mode_cost)
Returns the rate cost for luma prediction mode info of intra blocks.
Definition: intra_mode_search_utils.h:275
int ** mv_cost_stack
Points to the nmv_cost_hp in use.
Definition: block.h:777
uint8_t ref_mv_idx
Which ref_mv to use.
Definition: blockd.h:308
int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]
zeromv_mode_cost
Definition: block.h:645
Holds the entropy costs for various modes sent to the bitstream.
Definition: block.h:583
int av1_palette_color_cost_uv(const PALETTE_MODE_INFO *const pmi, const uint16_t *color_cache, int n_cache, int bit_depth)
Gets the rate cost for transmitting luma palette chroma values.
Definition: palette.c:139
struct macroblock_plane plane[3]
Each of the encoding plane.
Definition: block.h:856
TX_SIZE tx_size
Transform size when fixed size txfm is used (e.g. intra modes).
Definition: blockd.h:284
int8_t angle_delta[PLANE_TYPES]
Directional mode delta: the angle is base angle + (angle_delta * step).
Definition: blockd.h:266
Declares functions used in palette search.
int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2]
Cost for signaling ref_frame[0] in bidir-comp mode.
Definition: block.h:670
int height
Definition: encoder.h:1782
#define AOM_PLANE_Y
Definition: aom_image.h:199
uint8_t blk_skip[MAX_MIB_SIZE *MAX_MIB_SIZE]
Whether to skip transform and quantization on a txfm block level.
Definition: block.h:531
int_interpfilters interp_filters
Filter used in subpel interpolation.
Definition: blockd.h:242
Defines utility functions used in intra mode search.
MB_MODE_INFO_EXT mbmi_ext
Derived coding information.
Definition: block.h:871
static int intra_mode_info_cost_uv(const AV1_COMP *cpi, const MACROBLOCK *x, const MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, int mode_cost)
Return the rate cost for chroma prediction mode info of intra blocks.
Definition: intra_mode_search_utils.h:340
MB_MODE_INFO * above_mbmi
Definition: blockd.h:643
@ AOM_BITS_8
Definition: aom_codec.h:319
Defines the parameters used to perform txfm search.
Definition: block.h:425
FILTER_INTRA_MODE_INFO filter_intra_mode_info
The type of filter intra mode used (if applicable).
Definition: blockd.h:268
#define AOM_PLANE_U
Definition: aom_image.h:200
int mi_col
Definition: blockd.h:574
int speed
Definition: encoder.h:2309
int mb_to_bottom_edge
Definition: blockd.h:678
int use_svc
Definition: encoder.h:2632
SPEED_FEATURES sf
Definition: encoder.h:2314
int is_key_frame
Definition: svc_layercontext.h:80
int skip_txfm
Whether to skip transform and quantization on a partition block level.
Definition: block.h:522
struct segmentation seg
Definition: av1_common_int.h:904
static void estimate_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int use_modeled_non_rd_cost, int best_early_term, unsigned int ref_cost_intra, int reuse_prediction, struct buf_2d *orig_dst, PRED_BUFFER *tmp_buffers, PRED_BUFFER **this_mode_pred, RD_STATS *best_rdc, BEST_PICKMODE *best_pickmode)
Estimates best intra mode for inter mode search.
Definition: nonrd_pickmode.c:1812
int bd
Definition: blockd.h:806
CONTENT_STATE_SB content_state_sb
Characteristics of the current superblock.
Definition: block.h:1025
int nonrd_prune_ref_frame_search
Prune ref frames in real-time mode.
Definition: block.h:1069
void av1_nonrd_pick_intra_mode(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
AV1 intra mode selection based on Non-RD optimized model.
Definition: nonrd_pickmode.c:1657
const int16_t * quant_fp_QTX
Quantization step size used by AV1_XFORM_QUANT_FP.
Definition: block.h:127
LAYER_CONTEXT layer_context[32]
Definition: svc_layercontext.h:126
bool allow_screen_content_tools
Definition: av1_common_int.h:351
void av1_restore_uv_color_map(const struct AV1_COMP *cpi, struct macroblock *x)
Resets palette color map for chroma channels.
static void av1_k_means(const int *data, int *centroids, uint8_t *indices, int n, int k, int dim, int max_itr)
Performs k-means cluster on the data.
Definition: palette.h:87
int rdmult
Rate-distortion multiplier.
Definition: block.h:951
int kmeans_data_buf[2 *MAX_PALETTE_SQUARE]
A temporary buffer used for k-means clustering.
Definition: block.h:364
MB_MODE_INFO * left_mbmi
Definition: blockd.h:638
Top level encoder structure.
Definition: encoder.h:2095
PartitionSearchInfo part_search_info
Stores some partition-search related buffers.
Definition: block.h:1077
int height
Definition: av1_common_int.h:749
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]
The reference mv list for the current block.
Definition: block.h:199
The stucture of SVC.
Definition: svc_layercontext.h:91
const int16_t * round_fp_QTX
Offset used for rounding in the quantizer process by AV1_XFORM_QUANT_FP.
Definition: block.h:129
@ AOM_CBR
Definition: aom_encoder.h:167
int mb_to_right_edge
Definition: blockd.h:676
INTERINTRA_MODE interintra_mode
The type of intra mode used by inter-intra.
Definition: blockd.h:253
PALETTE_BUFFER * palette_buffer
Buffer to store the best palette map.
Definition: block.h:907
static int model_intra_yrd_and_prune(const AV1_COMP *const cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int64_t *best_model_rd)
Estimate the luma rdcost of a given intra mode and try to prune it.
Definition: intra_mode_search_utils.h:463
int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2]
Cost for signaling ref_frame[1] in bidir-comp mode.
Definition: block.h:675
PALETTE_MODE_INFO palette_mode_info
Stores the size and colors of palette mode.
Definition: blockd.h:274
enum aom_rc_mode mode
Definition: encoder.h:514
uint16_t * eobs
Location of the end of qcoeff (end of block).
Definition: block.h:113
search_site_config search_site_cfg[SS_CFG_TOTAL][NUM_DISTINCT_SEARCH_METHODS]
Definition: encoder.h:1756
MvCosts * mv_costs
Definition: block.h:963
AV1_COMMON common
Definition: encoder.h:2138
int pred_mv_sad[REF_FRAMES]
Sum absolute distortion of the predicted mv for each ref frame.
Definition: block.h:1036
MV_REFERENCE_FRAME ref_frame[2]
The reference frames for the MV.
Definition: blockd.h:240
UV_PREDICTION_MODE uv_mode
The UV mode when intra is used.
Definition: blockd.h:228
int mv_step_param
Definition: encoder.h:1740
Each source plane of the current macroblock.
Definition: block.h:103
const YV12_BUFFER_CONFIG * cur_buf
Definition: blockd.h:693
int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][((2)+1)]
uni_comp_ref_cost
Definition: block.h:665
MotionVectorSearchParams mv_search_params
Definition: encoder.h:2319
int frames_since_golden
Definition: ratectrl.h:184
aom_variance_fn_ptr_t fn_ptr[BLOCK_SIZES_ALL]
Definition: encoder.h:2347
int av1_remove_duplicates(int *centroids, int num_centroids)
Removes duplicated centroid indices.
Definition: palette.c:38
WINNER_MODE_SPEED_FEATURES winner_mode_sf
Definition: speed_features.h:1174
int mi_rows
Definition: av1_common_int.h:498
int16_t * src_diff
Stores source - pred so the txfm can be computed later.
Definition: block.h:105
Parameters related to quantization at the frame level.
Definition: av1_common_int.h:582
tran_low_t * dqcoeff
Dequantized coefficients.
Definition: block.h:107
const int16_t * dequant_QTX
Dequantizer.
Definition: block.h:139
static void search_filter_ref(AV1_COMP *cpi, MACROBLOCK *x, RD_STATS *this_rdc, int mi_row, int mi_col, PRED_BUFFER *tmp, BLOCK_SIZE bsize, int reuse_inter_pred, PRED_BUFFER **this_mode_pred, int *this_early_term, int use_model_yrd_large)
Searches for the best intrpolation filter.
Definition: nonrd_pickmode.c:1535
void av1_count_colors_highbd(const uint8_t *src8, int stride, int rows, int cols, int bit_depth, int *val_count, int *val_count_8bit, int *num_color_bins, int *num_colors)
See av1_count_colors(), but for highbd.
Definition: intra_mode_search.c:219
int av1_get_palette_delta_bits_v(const PALETTE_MODE_INFO *const pmi, int bit_depth, int *zero_count, int *min_bits)
Gets the rate cost for each delta-encoding v palette.
Definition: palette.c:106
INTER_MODE_SPEED_FEATURES inter_sf
Definition: speed_features.h:1149
Extended mode info derived from mbmi.
Definition: block.h:196
BLOCK_SIZE bsize
The block size of the current coding block.
Definition: blockd.h:222
tran_low_t * qcoeff
Quantized coefficients.
Definition: block.h:109
MOTION_MODE motion_mode
The motion mode used by the inter prediction.
Definition: blockd.h:244
RD_OPT rd
Definition: encoder.h:2268
fractional_mv_step_fp * find_fractional_mv_step
Definition: encoder.h:1749
uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]
Number of ref mvs in the drl.
Definition: block.h:203
static void estimate_block_intra(int plane, int block, int row, int col, BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg)
Estimation of RD cost of an intra mode for Non-RD optimized case.
Definition: nonrd_pickmode.c:1235
static void av1_calc_indices(const int *data, const int *centroids, uint8_t *indices, int n, int k, int dim)
Calculates the cluster to which each data point belong.
Definition: palette.h:54
uint8_t color_sensitivity[2]
Whether there is a strong color activity.
Definition: block.h:1220
static void palette_rd_y(const AV1_COMP *const cpi, MACROBLOCK *x, MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, int dc_mode_cost, const int *data, int *centroids, int n, uint16_t *color_cache, int n_cache, MB_MODE_INFO *best_mbmi, uint8_t *best_palette_color_map, int64_t *best_rd, int64_t *best_model_rd, int *rate, int *rate_tokenonly, int64_t *distortion, int *skippable, int *beat_best_rd, PICK_MODE_CONTEXT *ctx, uint8_t *blk_skip, uint8_t *tx_type_map, int *beat_best_palette_rd)
Calculate the luma palette cost from a given color palette.
Definition: palette.c:217
CommonQuantParams quant_params
Definition: av1_common_int.h:899
YV12 frame buffer data structure.
Definition: yv12config.h:38
uint8_t variance_low[105]
Variance of the subblocks in the superblock.
Definition: block.h:418
tran_low_t * coeff
Transformed coefficients.
Definition: block.h:111
PREDICTION_MODE mode
The prediction mode used.
Definition: blockd.h:226
int_mv mv[2]
The motion vectors used by the current inter mode.
Definition: blockd.h:238
struct buf_2d src
A buffer containing the source frame.
Definition: block.h:117
RATE_CONTROL rc
Definition: encoder.h:2294
int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]
refmv_mode_cost
Definition: block.h:647
int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS][((COMP_REFERENCE_TYPES)+1)]
comp_ref_type_cost
Definition: block.h:662
int base_qindex
Definition: av1_common_int.h:586
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:723
int angle_delta_cost[DIRECTIONAL_MODES][2 *MAX_ANGLE_DELTA+1]
angle_delta_cost
Definition: block.h:607
int ref_frame_flags
Definition: encoder.h:2304
int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES]
Factors used for rd-thresholding.
Definition: block.h:1107
INTRA_MODE_SPEED_FEATURES intra_sf
Definition: speed_features.h:1159
int lossless[8]
Definition: blockd.h:815
static void find_predictors(AV1_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int_mv frame_mv[MB_MODE_COUNT][REF_FRAMES], TileDataEnc *tile_data, struct buf_2d yv12_mb[8][3], BLOCK_SIZE bsize, int force_skip_low_temp_var)
Finds predicted motion vectors for a block.
Definition: nonrd_pickmode.c:340
uint8_t num_proj_ref
Number of samples used by warp causal.
Definition: blockd.h:246
TxfmSearchInfo txfm_search_info
Results of the txfm searches that have been done.
Definition: block.h:1213
int av1_palette_color_cost_y(const PALETTE_MODE_INFO *const pmi, const uint16_t *color_cache, int n_cache, int bit_depth)
Gets the rate cost for transmitting luma palette color values.
Definition: palette.c:125
int nmv_joint_cost[4]
Costs for coding the zero components.
Definition: block.h:766
TX_MODE tx_mode_search_type
How to search for the optimal tx_size.
Definition: block.h:468
unsigned int pred_sse[REF_FRAMES]
SSE of the current predictor.
Definition: block.h:1230
int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]
Luma mode cost for intra frame.
Definition: block.h:599
int_mv global_mvs[REF_FRAMES]
Global mvs.
Definition: block.h:205
#define AOM_PLANE_V
Definition: aom_image.h:201
int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]
newmv_mode_cost
Definition: block.h:643
Stores various encoding/search decisions related to txfm search.
Definition: block.h:520
int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2]
single_ref_cost
Definition: block.h:657
int mi_row
Definition: blockd.h:573
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]
inter_compound_mode_cost
Definition: block.h:685
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:216
Variables related to current coding block.
Definition: blockd.h:568
ResizePendingParams resize_pending_params
Definition: encoder.h:2466
int intra_inter_cost[INTRA_INTER_CONTEXTS][2]
intra_inter_cost
Definition: block.h:683
MACROBLOCKD e_mbd
Decoder's view of current coding block.
Definition: block.h:864
int mi_cols
Definition: av1_common_int.h:503
TxfmSearchParams txfm_search_params
Parameters that control how motion search is done.
Definition: block.h:1206
CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:774
uint8_t segment_id
The segment id.
Definition: blockd.h:304
int width
Definition: encoder.h:1781
static void block_yrd(AV1_COMP *cpi, MACROBLOCK *x, int mi_row, int mi_col, RD_STATS *this_rdc, int *skippable, BLOCK_SIZE bsize, TX_SIZE tx_size)
Calculates RD Cost using Hadamard transform.
Definition: nonrd_pickmode.c:824
int width
Definition: av1_common_int.h:748
int downsample_filter_phase[4]
Definition: svc_layercontext.h:137
AV1EncoderConfig oxcf
Definition: encoder.h:2143
const int16_t * zbin_QTX
Size of the quantization bin around 0. Only Used by QUANT_B.
Definition: block.h:137
SequenceHeader seq_params
Definition: av1_common_int.h:953
ModeCosts mode_costs
The rate needed to signal a mode to the bitstream.
Definition: block.h:959
const int16_t * quant_shift_QTX
Scale factor to shift coefficients toward zero. Only used by QUANT_B.
Definition: block.h:135
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]
Transform size when recursive txfm tree is on.
Definition: blockd.h:286
bool allow_high_precision_mv
Definition: av1_common_int.h:343
struct macroblockd_plane plane[3]
Definition: blockd.h:604
RateControlCfg rc_cfg
Definition: encoder.h:827
INTERP_FILTER_SPEED_FEATURES interp_sf
Definition: speed_features.h:1154
void av1_rd_pick_palette_intra_sbuv(const struct AV1_COMP *cpi, struct macroblock *x, int dc_mode_cost, uint8_t *best_palette_color_map, MB_MODE_INFO *const best_mbmi, int64_t *best_rd, int *rate, int *rate_tokenonly, int64_t *distortion, int *skippable)
Search for the best palette in the chroma plane.
static int search_new_mv(AV1_COMP *cpi, MACROBLOCK *x, int_mv frame_mv[][REF_FRAMES], MV_REFERENCE_FRAME ref_frame, int gf_temporal_ref, BLOCK_SIZE bsize, int mi_row, int mi_col, int *rate_mv, RD_STATS *best_rdc)
Searches for the best New Motion Vector.
Definition: nonrd_pickmode.c:264
Declares high level functions to search through intra modes.
CurrentFrame current_frame
Definition: av1_common_int.h:727
FeatureFlags features
Definition: av1_common_int.h:882
static int combined_motion_search(AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, int mi_col, int_mv *tmp_mv, int *rate_mv, int64_t best_rd_sofar, int use_base_mv)
Runs Motion Estimation for a specific block and specific ref frame.
Definition: nonrd_pickmode.c:153
void av1_count_colors(const uint8_t *src, int stride, int rows, int cols, int *val_count, int *num_colors)
Return the number of colors in src. Used by palette mode.
Definition: intra_mode_search.c:201
int filter_intra_cost[BLOCK_SIZES_ALL][2]
filter_intra_cost
Definition: block.h:603
uint16_t weight[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]
Definition: blockd.h:779
CommonModeInfoParams mi_params
Definition: av1_common_int.h:887
unsigned int source_variance
Variance of the source frame.
Definition: block.h:1228
Encoder's parameters related to the current coding block.
Definition: block.h:846
uint8_t * tx_type_map
Definition: blockd.h:664
NOISE_ESTIMATE noise_estimate
Definition: encoder.h:2679
MB_MODE_INFO ** mi
Definition: blockd.h:615
int skip_txfm_cost[SKIP_CONTEXTS][2]
skip_txfm_cost
Definition: block.h:725
void av1_nonrd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data, MACROBLOCK *x, RD_STATS *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx)
AV1 inter mode selection based on Non-RD optimized model.
Definition: nonrd_pickmode.c:2066
SVC svc
Definition: encoder.h:2636