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