media/libopus/celt/bands.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial