annotate src/opus-1.3/celt/bands.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 /* Copyright (c) 2007-2008 CSIRO
Chris@69 2 Copyright (c) 2007-2009 Xiph.Org Foundation
Chris@69 3 Copyright (c) 2008-2009 Gregory Maxwell
Chris@69 4 Written by Jean-Marc Valin and Gregory Maxwell */
Chris@69 5 /*
Chris@69 6 Redistribution and use in source and binary forms, with or without
Chris@69 7 modification, are permitted provided that the following conditions
Chris@69 8 are met:
Chris@69 9
Chris@69 10 - Redistributions of source code must retain the above copyright
Chris@69 11 notice, this list of conditions and the following disclaimer.
Chris@69 12
Chris@69 13 - Redistributions in binary form must reproduce the above copyright
Chris@69 14 notice, this list of conditions and the following disclaimer in the
Chris@69 15 documentation and/or other materials provided with the distribution.
Chris@69 16
Chris@69 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Chris@69 18 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Chris@69 19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Chris@69 20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
Chris@69 21 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Chris@69 22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Chris@69 23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Chris@69 24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Chris@69 25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Chris@69 26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Chris@69 27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Chris@69 28 */
Chris@69 29
Chris@69 30 #ifndef BANDS_H
Chris@69 31 #define BANDS_H
Chris@69 32
Chris@69 33 #include "arch.h"
Chris@69 34 #include "modes.h"
Chris@69 35 #include "entenc.h"
Chris@69 36 #include "entdec.h"
Chris@69 37 #include "rate.h"
Chris@69 38
Chris@69 39 opus_int16 bitexact_cos(opus_int16 x);
Chris@69 40 int bitexact_log2tan(int isin,int icos);
Chris@69 41
Chris@69 42 /** Compute the amplitude (sqrt energy) in each of the bands
Chris@69 43 * @param m Mode data
Chris@69 44 * @param X Spectrum
Chris@69 45 * @param bandE Square root of the energy for each band (returned)
Chris@69 46 */
Chris@69 47 void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch);
Chris@69 48
Chris@69 49 /*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bandE);*/
Chris@69 50
Chris@69 51 /** Normalise each band of X such that the energy in each band is
Chris@69 52 equal to 1
Chris@69 53 * @param m Mode data
Chris@69 54 * @param X Spectrum (returned normalised)
Chris@69 55 * @param bandE Square root of the energy for each band
Chris@69 56 */
Chris@69 57 void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M);
Chris@69 58
Chris@69 59 /** Denormalise each band of X to restore full amplitude
Chris@69 60 * @param m Mode data
Chris@69 61 * @param X Spectrum (returned de-normalised)
Chris@69 62 * @param bandE Square root of the energy for each band
Chris@69 63 */
Chris@69 64 void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
Chris@69 65 celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandE, int start,
Chris@69 66 int end, int M, int downsample, int silence);
Chris@69 67
Chris@69 68 #define SPREAD_NONE (0)
Chris@69 69 #define SPREAD_LIGHT (1)
Chris@69 70 #define SPREAD_NORMAL (2)
Chris@69 71 #define SPREAD_AGGRESSIVE (3)
Chris@69 72
Chris@69 73 int spreading_decision(const CELTMode *m, const celt_norm *X, int *average,
Chris@69 74 int last_decision, int *hf_average, int *tapset_decision, int update_hf,
Chris@69 75 int end, int C, int M, const int *spread_weight);
Chris@69 76
Chris@69 77 #ifdef MEASURE_NORM_MSE
Chris@69 78 void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C);
Chris@69 79 #endif
Chris@69 80
Chris@69 81 void haar1(celt_norm *X, int N0, int stride);
Chris@69 82
Chris@69 83 /** Quantisation/encoding of the residual spectrum
Chris@69 84 * @param encode flag that indicates whether we're encoding (1) or decoding (0)
Chris@69 85 * @param m Mode data
Chris@69 86 * @param start First band to process
Chris@69 87 * @param end Last band to process + 1
Chris@69 88 * @param X Residual (normalised)
Chris@69 89 * @param Y Residual (normalised) for second channel (or NULL for mono)
Chris@69 90 * @param collapse_masks Anti-collapse tracking mask
Chris@69 91 * @param bandE Square root of the energy for each band
Chris@69 92 * @param pulses Bit allocation (per band) for PVQ
Chris@69 93 * @param shortBlocks Zero for long blocks, non-zero for short blocks
Chris@69 94 * @param spread Amount of spreading to use
Chris@69 95 * @param dual_stereo Zero for MS stereo, non-zero for dual stereo
Chris@69 96 * @param intensity First band to use intensity stereo
Chris@69 97 * @param tf_res Time-frequency resolution change
Chris@69 98 * @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
Chris@69 99 * @param balance Number of unallocated bits
Chris@69 100 * @param en Entropy coder state
Chris@69 101 * @param LM log2() of the number of 2.5 subframes in the frame
Chris@69 102 * @param codedBands Last band to receive bits + 1
Chris@69 103 * @param seed Random generator seed
Chris@69 104 * @param arch Run-time architecture (see opus_select_arch())
Chris@69 105 */
Chris@69 106 void quant_all_bands(int encode, const CELTMode *m, int start, int end,
Chris@69 107 celt_norm * X, celt_norm * Y, unsigned char *collapse_masks,
Chris@69 108 const celt_ener *bandE, int *pulses, int shortBlocks, int spread,
Chris@69 109 int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits,
Chris@69 110 opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed,
Chris@69 111 int complexity, int arch, int disable_inv);
Chris@69 112
Chris@69 113 void anti_collapse(const CELTMode *m, celt_norm *X_,
Chris@69 114 unsigned char *collapse_masks, int LM, int C, int size, int start,
Chris@69 115 int end, const opus_val16 *logE, const opus_val16 *prev1logE,
Chris@69 116 const opus_val16 *prev2logE, const int *pulses, opus_uint32 seed,
Chris@69 117 int arch);
Chris@69 118
Chris@69 119 opus_uint32 celt_lcg_rand(opus_uint32 seed);
Chris@69 120
Chris@69 121 int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev);
Chris@69 122
Chris@69 123 #endif /* BANDS_H */