blob: e570e4d243a26d86bc9802ff139dc7bb918e7485 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
2 * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Yaowu Xuf883b422016-08-30 14:01:10 -070011#ifndef AV1_ENCODER_PALETTE_H_
12#define AV1_ENCODER_PALETTE_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070013
14#include "av1/common/blockd.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
Yaowu Xuf883b422016-08-30 14:01:10 -070020void av1_calc_indices(const float *data, const float *centroids,
21 uint8_t *indices, int n, int k, int dim);
Yaowu Xuc27fc142016-08-22 16:08:15 -070022
23// Given 'data' of size 'n' and initial guess of 'centroids' of size 'k x dim',
24// runs up to 'max_itr' iterations of k-means algorithm to get updated
25// 'centroids' and the centroid 'indices' for elements in 'data'.
26// Note: the output centroids are rounded off to nearest integers.
Yaowu Xuf883b422016-08-30 14:01:10 -070027void av1_k_means(const float *data, float *centroids, uint8_t *indices, int n,
28 int k, int dim, int max_itr);
Yaowu Xuc27fc142016-08-22 16:08:15 -070029
30// Given a list of centroids, returns the unique number of centroids 'k', and
31// puts these unique centroids in first 'k' indices of 'centroids' array.
32// Ideally, the centroids should be rounded to integers before calling this
33// method.
Yaowu Xuf883b422016-08-30 14:01:10 -070034int av1_remove_duplicates(float *centroids, int num_centroids);
Yaowu Xuc27fc142016-08-22 16:08:15 -070035
Yaowu Xuf883b422016-08-30 14:01:10 -070036int av1_count_colors(const uint8_t *src, int stride, int rows, int cols);
37#if CONFIG_AOM_HIGHBITDEPTH
38int av1_count_colors_highbd(const uint8_t *src8, int stride, int rows, int cols,
39 int bit_depth);
40#endif // CONFIG_AOM_HIGHBITDEPTH
Yaowu Xuc27fc142016-08-22 16:08:15 -070041
42#ifdef __cplusplus
43} // extern "C"
44#endif
45
Yaowu Xuf883b422016-08-30 14:01:10 -070046#endif /* AV1_ENCODER_PALETTE_H_ */