1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/celt/bands.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +/* Copyright (c) 2007-2008 CSIRO 1.5 + Copyright (c) 2007-2009 Xiph.Org Foundation 1.6 + Copyright (c) 2008-2009 Gregory Maxwell 1.7 + Written by Jean-Marc Valin and Gregory Maxwell */ 1.8 +/* 1.9 + Redistribution and use in source and binary forms, with or without 1.10 + modification, are permitted provided that the following conditions 1.11 + are met: 1.12 + 1.13 + - Redistributions of source code must retain the above copyright 1.14 + notice, this list of conditions and the following disclaimer. 1.15 + 1.16 + - Redistributions in binary form must reproduce the above copyright 1.17 + notice, this list of conditions and the following disclaimer in the 1.18 + documentation and/or other materials provided with the distribution. 1.19 + 1.20 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.21 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.22 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.23 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 1.24 + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.25 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.26 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.27 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.28 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.29 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.30 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.31 +*/ 1.32 + 1.33 +#ifndef BANDS_H 1.34 +#define BANDS_H 1.35 + 1.36 +#include "arch.h" 1.37 +#include "modes.h" 1.38 +#include "entenc.h" 1.39 +#include "entdec.h" 1.40 +#include "rate.h" 1.41 + 1.42 +/** Compute the amplitude (sqrt energy) in each of the bands 1.43 + * @param m Mode data 1.44 + * @param X Spectrum 1.45 + * @param bandE Square root of the energy for each band (returned) 1.46 + */ 1.47 +void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int M); 1.48 + 1.49 +/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bandE);*/ 1.50 + 1.51 +/** Normalise each band of X such that the energy in each band is 1.52 + equal to 1 1.53 + * @param m Mode data 1.54 + * @param X Spectrum (returned normalised) 1.55 + * @param bandE Square root of the energy for each band 1.56 + */ 1.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); 1.58 + 1.59 +/** Denormalise each band of X to restore full amplitude 1.60 + * @param m Mode data 1.61 + * @param X Spectrum (returned de-normalised) 1.62 + * @param bandE Square root of the energy for each band 1.63 + */ 1.64 +void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, 1.65 + celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandE, int start, int end, int C, int M); 1.66 + 1.67 +#define SPREAD_NONE (0) 1.68 +#define SPREAD_LIGHT (1) 1.69 +#define SPREAD_NORMAL (2) 1.70 +#define SPREAD_AGGRESSIVE (3) 1.71 + 1.72 +int spreading_decision(const CELTMode *m, celt_norm *X, int *average, 1.73 + int last_decision, int *hf_average, int *tapset_decision, int update_hf, 1.74 + int end, int C, int M); 1.75 + 1.76 +#ifdef MEASURE_NORM_MSE 1.77 +void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C); 1.78 +#endif 1.79 + 1.80 +void haar1(celt_norm *X, int N0, int stride); 1.81 + 1.82 +/** Quantisation/encoding of the residual spectrum 1.83 + * @param encode flag that indicates whether we're encoding (1) or decoding (0) 1.84 + * @param m Mode data 1.85 + * @param start First band to process 1.86 + * @param end Last band to process + 1 1.87 + * @param X Residual (normalised) 1.88 + * @param Y Residual (normalised) for second channel (or NULL for mono) 1.89 + * @param collapse_masks Anti-collapse tracking mask 1.90 + * @param bandE Square root of the energy for each band 1.91 + * @param pulses Bit allocation (per band) for PVQ 1.92 + * @param shortBlocks Zero for long blocks, non-zero for short blocks 1.93 + * @param spread Amount of spreading to use 1.94 + * @param dual_stereo Zero for MS stereo, non-zero for dual stereo 1.95 + * @param intensity First band to use intensity stereo 1.96 + * @param tf_res Time-frequency resolution change 1.97 + * @param total_bits Total number of bits that can be used for the frame (including the ones already spent) 1.98 + * @param balance Number of unallocated bits 1.99 + * @param en Entropy coder state 1.100 + * @param LM log2() of the number of 2.5 subframes in the frame 1.101 + * @param codedBands Last band to receive bits + 1 1.102 + * @param seed Random generator seed 1.103 + */ 1.104 +void quant_all_bands(int encode, const CELTMode *m, int start, int end, 1.105 + celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, 1.106 + int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, 1.107 + opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed); 1.108 + 1.109 +void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_masks, int LM, int C, int size, 1.110 + int start, int end, opus_val16 *logE, opus_val16 *prev1logE, 1.111 + opus_val16 *prev2logE, int *pulses, opus_uint32 seed); 1.112 + 1.113 +opus_uint32 celt_lcg_rand(opus_uint32 seed); 1.114 + 1.115 +int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev); 1.116 + 1.117 +#endif /* BANDS_H */