vq.h (3921B)
1 /* Copyright (c) 2007-2008 CSIRO 2 Copyright (c) 2007-2009 Xiph.Org Foundation 3 Written by Jean-Marc Valin */ 4 /** 5 @file vq.h 6 @brief Vector quantisation of the residual 7 */ 8 /* 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions 11 are met: 12 13 - Redistributions of source code must retain the above copyright 14 notice, this list of conditions and the following disclaimer. 15 16 - Redistributions in binary form must reproduce the above copyright 17 notice, this list of conditions and the following disclaimer in the 18 documentation and/or other materials provided with the distribution. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 24 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef VQ_H 34 #define VQ_H 35 36 #include "entenc.h" 37 #include "entdec.h" 38 #include "modes.h" 39 40 #if (defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT)) 41 #include "x86/vq_sse.h" 42 #endif 43 44 #if defined(FIXED_POINT) 45 opus_val32 celt_inner_prod_norm(const celt_norm *x, const celt_norm *y, int len, int arch); 46 opus_val32 celt_inner_prod_norm_shift(const celt_norm *x, const celt_norm *y, int len, int arch); 47 48 void norm_scaleup(celt_norm *X, int N, int shift); 49 void norm_scaledown(celt_norm *X, int N, int shift); 50 51 #else 52 #define celt_inner_prod_norm celt_inner_prod 53 #define celt_inner_prod_norm_shift celt_inner_prod 54 #define norm_scaleup(X, N, shift) 55 #define norm_scaledown(X, N, shift) 56 #endif 57 58 void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread); 59 60 opus_val16 op_pvq_search_c(celt_norm *X, int *iy, int K, int N, int arch); 61 62 #if !defined(OVERRIDE_OP_PVQ_SEARCH) 63 #define op_pvq_search(x, iy, K, N, arch) \ 64 (op_pvq_search_c(x, iy, K, N, arch)) 65 #endif 66 67 /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of 68 * the pitch and a combination of pulses such that its norm is still equal 69 * to 1. This is the function that will typically require the most CPU. 70 * @param X Residual signal to quantise/encode (returns quantised version) 71 * @param N Number of samples to encode 72 * @param K Number of pulses to use 73 * @param enc Entropy encoder state 74 * @ret A mask indicating which blocks in the band received pulses 75 */ 76 unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, 77 opus_val32 gain, int resynth 78 ARG_QEXT(ec_enc *ext_enc) ARG_QEXT(int extra_bits), int arch); 79 80 /** Algebraic pulse decoder 81 * @param X Decoded normalised spectrum (returned) 82 * @param N Number of samples to decode 83 * @param K Number of pulses to use 84 * @param dec Entropy decoder state 85 * @ret A mask indicating which blocks in the band received pulses 86 */ 87 unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, 88 ec_dec *dec, opus_val32 gain 89 ARG_QEXT(ec_enc *ext_dec) ARG_QEXT(int extra_bits)); 90 91 void renormalise_vector(celt_norm *X, int N, opus_val32 gain, int arch); 92 93 opus_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch); 94 95 unsigned cubic_quant(celt_norm *X, int N, int K, int B, ec_enc *enc, opus_val32 gain, int resynth); 96 unsigned cubic_unquant(celt_norm *X, int N, int K, int B, ec_dec *dec, opus_val32 gain); 97 98 #endif /* VQ_H */