blob: 2284a171a43e37f465265f6aaffe3e3a5108b682 [file] [log] [blame]
Neil Birkbecked25a612017-12-21 13:18:32 -08001/*
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 Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_NOISE_UTIL_H_
13#define AOM_AOM_DSP_NOISE_UTIL_H_
Neil Birkbecked25a612017-12-21 13:18:32 -080014
15#ifdef __cplusplus
16extern "C" {
17#endif // __cplusplus
18
Neil Birkbeck04721792018-06-12 08:03:48 -070019// 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).
22struct 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.
27struct aom_noise_tx_t *aom_noise_tx_malloc(int block_size);
28void 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.
33void 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.
40void 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.
45void 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.
48void 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.
55float aom_noise_psd_get_default_value(int block_size, float factor);
56
Neil Birkbecked25a612017-12-21 13:18:32 -080057// Computes normalized cross correlation of two vectors a and b of length n.
58double aom_normalized_cross_correlation(const double *a, const double *b,
59 int n);
60
Neil Birkbecked25a612017-12-21 13:18:32 -080061// Validates the correlated noise in the data buffer of size (w, h).
62int aom_noise_data_validate(const double *data, int w, int h);
63
64#ifdef __cplusplus
65} // extern "C"
66#endif // __cplusplus
67
James Zerne1cbb132018-08-22 14:10:36 -070068#endif // AOM_AOM_DSP_NOISE_UTIL_H_