palette.h
Go to the documentation of this file.
/*
* 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_ENCODER_PALETTE_H_
#define AOM_AV1_ENCODER_PALETTE_H_
#include "av1/common/blockd.h"
#ifdef __cplusplus
extern "C" {
#endif
struct AV1_COMP;
struct PICK_MODE_CONTEXT;
struct macroblock;
#define AV1_K_MEANS_RENAME(func, dim) func##_dim##dim
void AV1_K_MEANS_RENAME(av1_k_means, 1)(const int16_t *data, int16_t *centroids,
uint8_t *indices, int n, int k,
int max_itr);
void AV1_K_MEANS_RENAME(av1_k_means, 2)(const int16_t *data, int16_t *centroids,
uint8_t *indices, int n, int k,
int max_itr);
static inline void av1_calc_indices(const int16_t *data,
const int16_t *centroids, uint8_t *indices,
int n, int k, int dim) {
assert(n > 0);
assert(k > 0);
if (dim == 1) {
av1_calc_indices_dim1(data, centroids, indices, /*total_dist=*/NULL, n, k);
} else if (dim == 2) {
av1_calc_indices_dim2(data, centroids, indices, /*total_dist=*/NULL, n, k);
} else {
assert(0 && "Untemplated k means dimension");
}
}
static inline void av1_k_means(const int16_t *data, int16_t *centroids,
uint8_t *indices, int n, int k, int dim,
int max_itr) {
assert(n > 0);
assert(k > 0);
if (dim == 1) {
AV1_K_MEANS_RENAME(av1_k_means, 1)(data, centroids, indices, n, k, max_itr);
} else if (dim == 2) {
AV1_K_MEANS_RENAME(av1_k_means, 2)(data, centroids, indices, n, k, max_itr);
} else {
assert(0 && "Untemplated k means dimension");
}
}
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);
int av1_get_palette_delta_bits_v(const PALETTE_MODE_INFO *const pmi,
int bit_depth, int *zero_count, int *min_bits);
int av1_palette_color_cost_y(const PALETTE_MODE_INFO *const pmi,
const uint16_t *color_cache, int n_cache,
int bit_depth);
int av1_palette_color_cost_uv(const PALETTE_MODE_INFO *const pmi,
const uint16_t *color_cache, int n_cache,
int bit_depth);
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, int *rate, int *rate_tokenonly, int64_t *distortion,
uint8_t *skippable, int *beat_best_rd, struct PICK_MODE_CONTEXT *ctx,
uint8_t *tx_type_map);
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,
uint8_t *skippable);
void av1_restore_uv_color_map(const struct AV1_COMP *cpi, struct macroblock *x);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AV1_ENCODER_PALETTE_H_
av1_palette_color_cost_y
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:138
av1_index_color_cache
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:91
av1_rd_pick_palette_intra_sby
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, int *rate, int *rate_tokenonly, int64_t *distortion, uint8_t *skippable, int *beat_best_rd, struct PICK_MODE_CONTEXT *ctx, uint8_t *tx_type_map)
Search for the best palette in the luma plane.
av1_rd_pick_palette_intra_sbuv
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, uint8_t *skippable)
Search for the best palette in the chroma plane.
av1_get_palette_delta_bits_v
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:119
av1_k_means
static void av1_k_means(const int16_t *data, int16_t *centroids, uint8_t *indices, int n, int k, int dim, int max_itr)
Performs k-means cluster on the data.
Definition palette.h:88
av1_calc_indices
static void av1_calc_indices(const int16_t *data, const int16_t *centroids, uint8_t *indices, int n, int k, int dim)
Calculates the cluster to which each data point belong.
Definition palette.h:54
av1_palette_color_cost_uv
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:152
av1_restore_uv_color_map
void av1_restore_uv_color_map(const struct AV1_COMP *cpi, struct macroblock *x)
Resets palette color map for chroma channels.
AV1_COMP
Top level encoder structure.
Definition encoder.h:2897
MB_MODE_INFO
Stores the prediction/txfm mode of the current coding block.
Definition blockd.h:222
macroblock
Encoder's parameters related to the current coding block.
Definition block.h:889