Neil Birkbeck | ed25a61 | 2017-12-21 13:18:32 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, 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 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AOM_DSP_NOISE_UTIL_H_ |
| 13 | #define AOM_AOM_DSP_NOISE_UTIL_H_ |
Neil Birkbeck | ed25a61 | 2017-12-21 13:18:32 -0800 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif // __cplusplus |
| 18 | |
Neil Birkbeck | 0472179 | 2018-06-12 08:03:48 -0700 | [diff] [blame] | 19 | // aom_noise_tx_t is an abstraction of a transform that is used for denoising. |
| 20 | // It is meant to be lightweight and does hold the transformed data (as |
| 21 | // the user should not be manipulating the transformed data directly). |
| 22 | struct aom_noise_tx_t; |
| 23 | |
| 24 | // Allocates and returns a aom_noise_tx_t useful for denoising the given |
| 25 | // block_size. The resulting aom_noise_tx_t should be free'd with |
| 26 | // aom_noise_tx_free. |
| 27 | struct aom_noise_tx_t *aom_noise_tx_malloc(int block_size); |
| 28 | void aom_noise_tx_free(struct aom_noise_tx_t *aom_noise_tx); |
| 29 | |
| 30 | // Transforms the internal data and holds it in the aom_noise_tx's internal |
| 31 | // buffer. For compatibility with existing SIMD implementations, "data" must |
| 32 | // be 32-byte aligned. |
| 33 | void aom_noise_tx_forward(struct aom_noise_tx_t *aom_noise_tx, |
| 34 | const float *data); |
| 35 | |
| 36 | // Filters aom_noise_tx's internal data using the provided noise power spectral |
| 37 | // density. The PSD must be at least block_size * block_size and should be |
| 38 | // populated with a constant or via estimates taken from |
| 39 | // aom_noise_tx_add_energy. |
| 40 | void aom_noise_tx_filter(struct aom_noise_tx_t *aom_noise_tx, const float *psd); |
| 41 | |
| 42 | // Performs an inverse transform using the internal transform data. |
| 43 | // For compatibility with existing SIMD implementations, "data" must be 32-byte |
| 44 | // aligned. |
| 45 | void aom_noise_tx_inverse(struct aom_noise_tx_t *aom_noise_tx, float *data); |
| 46 | |
| 47 | // Aggregates the power of the buffered transform data into the psd buffer. |
| 48 | void aom_noise_tx_add_energy(const struct aom_noise_tx_t *aom_noise_tx, |
| 49 | float *psd); |
| 50 | |
| 51 | // Returns a default value suitable for denosing a transform of the given |
| 52 | // block_size. The noise "factor" determines the strength of the noise to |
| 53 | // be removed. A value of about 2.5 can be used for moderate denoising, |
| 54 | // where a value of 5.0 can be used for a high level of denoising. |
| 55 | float aom_noise_psd_get_default_value(int block_size, float factor); |
| 56 | |
Neil Birkbeck | ed25a61 | 2017-12-21 13:18:32 -0800 | [diff] [blame] | 57 | // Computes normalized cross correlation of two vectors a and b of length n. |
| 58 | double aom_normalized_cross_correlation(const double *a, const double *b, |
| 59 | int n); |
| 60 | |
Neil Birkbeck | ed25a61 | 2017-12-21 13:18:32 -0800 | [diff] [blame] | 61 | // Validates the correlated noise in the data buffer of size (w, h). |
| 62 | int aom_noise_data_validate(const double *data, int w, int h); |
| 63 | |
| 64 | #ifdef __cplusplus |
| 65 | } // extern "C" |
| 66 | #endif // __cplusplus |
| 67 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 68 | #endif // AOM_AOM_DSP_NOISE_UTIL_H_ |