Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
| 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 11 | #ifndef AV1_ENCODER_PALETTE_H_ |
| 12 | #define AV1_ENCODER_PALETTE_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 13 | |
| 14 | #include "av1/common/blockd.h" |
| 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 20 | void av1_calc_indices(const float *data, const float *centroids, |
| 21 | uint8_t *indices, int n, int k, int dim); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | |
| 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 27 | void av1_k_means(const float *data, float *centroids, uint8_t *indices, int n, |
| 28 | int k, int dim, int max_itr); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 29 | |
| 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 Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 34 | int av1_remove_duplicates(float *centroids, int num_centroids); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 35 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 36 | int av1_count_colors(const uint8_t *src, int stride, int rows, int cols); |
| 37 | #if CONFIG_AOM_HIGHBITDEPTH |
| 38 | int av1_count_colors_highbd(const uint8_t *src8, int stride, int rows, int cols, |
| 39 | int bit_depth); |
| 40 | #endif // CONFIG_AOM_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 41 | |
| 42 | #ifdef __cplusplus |
| 43 | } // extern "C" |
| 44 | #endif |
| 45 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame^] | 46 | #endif /* AV1_ENCODER_PALETTE_H_ */ |