|
Packit |
664db3 |
/* (C) 2007 Jean-Marc Valin, CSIRO
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
/*
|
|
Packit |
664db3 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
664db3 |
modification, are permitted provided that the following conditions
|
|
Packit |
664db3 |
are met:
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
- Redistributions of source code must retain the above copyright
|
|
Packit |
664db3 |
notice, this list of conditions and the following disclaimer.
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
- Redistributions in binary form must reproduce the above copyright
|
|
Packit |
664db3 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
664db3 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
- Neither the name of the Xiph.org Foundation nor the names of its
|
|
Packit |
664db3 |
contributors may be used to endorse or promote products derived from
|
|
Packit |
664db3 |
this software without specific prior written permission.
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
664db3 |
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
664db3 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit |
664db3 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
|
Packit |
664db3 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
Packit |
664db3 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
Packit |
664db3 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
Packit |
664db3 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
Packit |
664db3 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
Packit |
664db3 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit |
664db3 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
#ifndef BANDS_H
|
|
Packit |
664db3 |
#define BANDS_H
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
#include "arch.h"
|
|
Packit |
664db3 |
#include "modes.h"
|
|
Packit |
664db3 |
#include "entenc.h"
|
|
Packit |
664db3 |
#include "entdec.h"
|
|
Packit |
664db3 |
#include "rate.h"
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Applies a series of rotations so that pulses are spread like a two-sided
|
|
Packit |
664db3 |
exponential. The effect of this is to reduce the tonal noise created by the
|
|
Packit |
664db3 |
sparse spectrum resulting from the pulse codebook */
|
|
Packit |
664db3 |
void exp_rotation(celt_norm_t *X, int len, int dir, int stride, int iter);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Compute the amplitude (sqrt energy) in each of the bands
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Spectrum
|
|
Packit |
664db3 |
* @param bands Square root of the energy for each band (returned)
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bands);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_word16_t *tonality, celt_ener_t *bank);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Normalise each band of X such that the energy in each band is
|
|
Packit |
664db3 |
equal to 1
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Spectrum (returned normalised)
|
|
Packit |
664db3 |
* @param bands Square root of the energy for each band
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bands);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Denormalise each band of X to restore full amplitude
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Spectrum (returned de-normalised)
|
|
Packit |
664db3 |
* @param bands Square root of the energy for each band
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_sig_t * restrict freq, const celt_ener_t *bands);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Compute the pitch predictor gain for each pitch band
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Spectrum to predict
|
|
Packit |
664db3 |
* @param P Pitch vector (normalised)
|
|
Packit |
664db3 |
* @param gains Gain computed for each pitch band (returned)
|
|
Packit |
664db3 |
* @param bank Square root of the energy for each band
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void compute_pitch_gain(const CELTMode *m, const celt_norm_t *X, const celt_norm_t *P, celt_pgain_t *gains);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
void pitch_quant_bands(const CELTMode *m, celt_norm_t * restrict P, const celt_pgain_t * restrict gains);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Quantisation/encoding of the residual spectrum
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Residual (normalised)
|
|
Packit |
664db3 |
* @param P Pitch vector (normalised)
|
|
Packit |
664db3 |
* @param W Perceptual weighting
|
|
Packit |
664db3 |
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
|
Packit |
664db3 |
* @param enc Entropy encoder
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, celt_mask_t *W, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int time_domain, int fold, int total_bits, ec_enc *enc);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
/** Decoding of the residual spectrum
|
|
Packit |
664db3 |
* @param m Mode data
|
|
Packit |
664db3 |
* @param X Residual (normalised)
|
|
Packit |
664db3 |
* @param P Pitch vector (normalised)
|
|
Packit |
664db3 |
* @param total_bits Total number of bits that can be used for the frame (including the ones already spent)
|
|
Packit |
664db3 |
* @param dec Entropy decoder
|
|
Packit |
664db3 |
*/
|
|
Packit |
664db3 |
void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, const celt_ener_t *bandE, const int *stereo_mode, int *pulses, int time_domain, int fold, int total_bits, ec_dec *dec);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
void stereo_decision(const CELTMode *m, celt_norm_t * restrict X, int *stereo_mode, int len);
|
|
Packit |
664db3 |
|
|
Packit |
664db3 |
#endif /* BANDS_H */
|