vq.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. - Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. - Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  21. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  22. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  23. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  25. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  26. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef VQ_H
  30. #define VQ_H
  31. #include "entenc.h"
  32. #include "entdec.h"
  33. #include "modes.h"
  34. /** Algebraic pulse-vector quantiser. The signal x is replaced by the sum of
  35. * the pitch and a combination of pulses such that its norm is still equal
  36. * to 1. This is the function that will typically require the most CPU.
  37. * @param x Residual signal to quantise/encode (returns quantised version)
  38. * @param W Perceptual weight to use when optimising (currently unused)
  39. * @param N Number of samples to encode
  40. * @param K Number of pulses to use
  41. * @param p Pitch vector (it is assumed that p+x is a unit vector)
  42. * @param enc Entropy encoder state
  43. * @ret A mask indicating which blocks in the band received pulses
  44. */
  45. unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B,
  46. ec_enc *enc
  47. #ifdef RESYNTH
  48. , opus_val16 gain
  49. #endif
  50. );
  51. /** Algebraic pulse decoder
  52. * @param x Decoded normalised spectrum (returned)
  53. * @param N Number of samples to decode
  54. * @param K Number of pulses to use
  55. * @param p Pitch vector (automatically added to x)
  56. * @param dec Entropy decoder state
  57. * @ret A mask indicating which blocks in the band received pulses
  58. */
  59. unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B,
  60. ec_dec *dec, opus_val16 gain);
  61. void renormalise_vector(celt_norm *X, int N, opus_val16 gain);
  62. int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N);
  63. #endif /* VQ_H */