blob: 1ceeeeb268f737b8f93314f24aad3dd6503fa480 [file] [log] [blame]
Alexandre Lision744f7422013-09-25 11:39:37 -04001/* 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/** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of
41 * the pitch and a combination of pulses such that its norm is still equal
42 * to 1. This is the function that will typically require the most CPU.
43 * @param x Residual signal to quantise/encode (returns quantised version)
44 * @param W Perceptual weight to use when optimising (currently unused)
45 * @param N Number of samples to encode
46 * @param K Number of pulses to use
47 * @param p Pitch vector (it is assumed that p+x is a unit vector)
48 * @param enc Entropy encoder state
49 * @ret A mask indicating which blocks in the band received pulses
50*/
51unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B,
52 ec_enc *enc
53#ifdef RESYNTH
54 , opus_val16 gain
55#endif
56 );
57
58/** Algebraic pulse decoder
59 * @param x Decoded normalised spectrum (returned)
60 * @param N Number of samples to decode
61 * @param K Number of pulses to use
62 * @param p Pitch vector (automatically added to x)
63 * @param dec Entropy decoder state
64 * @ret A mask indicating which blocks in the band received pulses
65 */
66unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B,
67 ec_dec *dec, opus_val16 gain);
68
69void renormalise_vector(celt_norm *X, int N, opus_val16 gain);
70
71int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N);
72
73#endif /* VQ_H */