1 /* Copyright (c) 2007-2008 CSIRO
2 Copyright (c) 2007-2009 Xiph.Org Foundation
3 Copyright (c) 2008-2009 Gregory Maxwell
4 Written by Jean-Marc Valin and Gregory Maxwell */
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 - Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 - Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 - Neither the name of the Xiph.org Foundation nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 /** Compute the amplitude (sqrt energy) in each of the bands
46 * @param bands Square root of the energy for each band (returned)
48 void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bands, int end, int _C, int M);
50 /*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const celt_word16 *tonality, celt_ener *bank);*/
52 /** Normalise each band of X such that the energy in each band is
55 * @param X Spectrum (returned normalised)
56 * @param bands Square root of the energy for each band
58 void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bands, int end, int _C, int M);
60 /** Denormalise each band of X to restore full amplitude
62 * @param X Spectrum (returned de-normalised)
63 * @param bands Square root of the energy for each band
65 void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bands, int end, int _C, int M);
67 #define SPREAD_NONE (0)
68 #define SPREAD_LIGHT (1)
69 #define SPREAD_NORMAL (2)
70 #define SPREAD_AGGRESSIVE (3)
72 int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
73 int last_decision, int *hf_average, int *tapset_decision, int update_hf,
74 int end, int _C, int M);
76 #ifdef MEASURE_NORM_MSE
77 void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C);
80 void haar1(celt_norm *X, int N0, int stride);
82 /** Quantisation/encoding of the residual spectrum
84 * @param X Residual (normalised)
85 * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
86 * @param enc Entropy encoder
88 void quant_all_bands(int encode, const CELTMode *m, int start, int end,
89 celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses,
90 int time_domain, int fold, int dual_stereo, int intensity, int *tf_res, int resynth,
91 int total_bits, void *enc, int M, int codedBands, ec_uint32 *seed);
94 void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M);
96 void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int size,
97 int start, int end, celt_word16 *logE, celt_word16 *prev1logE,
98 celt_word16 *prev2logE, int *pulses, celt_uint32 seed);