cannam@154: /* Copyright (c) 2007-2008 CSIRO cannam@154: Copyright (c) 2007-2009 Xiph.Org Foundation cannam@154: Written by Jean-Marc Valin */ cannam@154: /** cannam@154: @file vq.h cannam@154: @brief Vector quantisation of the residual cannam@154: */ cannam@154: /* cannam@154: Redistribution and use in source and binary forms, with or without cannam@154: modification, are permitted provided that the following conditions cannam@154: are met: cannam@154: cannam@154: - Redistributions of source code must retain the above copyright cannam@154: notice, this list of conditions and the following disclaimer. cannam@154: cannam@154: - Redistributions in binary form must reproduce the above copyright cannam@154: notice, this list of conditions and the following disclaimer in the cannam@154: documentation and/or other materials provided with the distribution. cannam@154: cannam@154: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS cannam@154: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT cannam@154: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR cannam@154: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER cannam@154: OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, cannam@154: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, cannam@154: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR cannam@154: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF cannam@154: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING cannam@154: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS cannam@154: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cannam@154: */ cannam@154: cannam@154: #ifndef VQ_H cannam@154: #define VQ_H cannam@154: cannam@154: #include "entenc.h" cannam@154: #include "entdec.h" cannam@154: #include "modes.h" cannam@154: cannam@154: #if (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT)) cannam@154: #include "x86/vq_sse.h" cannam@154: #endif cannam@154: cannam@154: #if defined(MIPSr1_ASM) cannam@154: #include "mips/vq_mipsr1.h" cannam@154: #endif cannam@154: cannam@154: void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread); cannam@154: cannam@154: opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch); cannam@154: cannam@154: #if !defined(OVERRIDE_OP_PVQ_SEARCH) cannam@154: #define op_pvq_search(x, iy, K, N, arch) \ cannam@154: (op_pvq_search_c(x, iy, K, N, arch)) cannam@154: #endif cannam@154: cannam@154: /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of cannam@154: * the pitch and a combination of pulses such that its norm is still equal cannam@154: * to 1. This is the function that will typically require the most CPU. cannam@154: * @param X Residual signal to quantise/encode (returns quantised version) cannam@154: * @param N Number of samples to encode cannam@154: * @param K Number of pulses to use cannam@154: * @param enc Entropy encoder state cannam@154: * @ret A mask indicating which blocks in the band received pulses cannam@154: */ cannam@154: unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, cannam@154: opus_val16 gain, int resynth, int arch); cannam@154: cannam@154: /** Algebraic pulse decoder cannam@154: * @param X Decoded normalised spectrum (returned) cannam@154: * @param N Number of samples to decode cannam@154: * @param K Number of pulses to use cannam@154: * @param dec Entropy decoder state cannam@154: * @ret A mask indicating which blocks in the band received pulses cannam@154: */ cannam@154: unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, cannam@154: ec_dec *dec, opus_val16 gain); cannam@154: cannam@154: void renormalise_vector(celt_norm *X, int N, opus_val16 gain, int arch); cannam@154: cannam@154: int stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch); cannam@154: cannam@154: #endif /* VQ_H */