celt.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Copyright (c) 2007-2008 CSIRO
  2. Copyright (c) 2007-2009 Xiph.Org Foundation
  3. Copyright (c) 2008 Gregory Maxwell
  4. Written by Jean-Marc Valin and Gregory Maxwell */
  5. /**
  6. @file celt.h
  7. @brief Contains all the functions for encoding and decoding audio
  8. */
  9. /*
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. - Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. - Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in the
  17. documentation and/or other materials provided with the distribution.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  22. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef CELT_H
  31. #define CELT_H
  32. #include "opus_types.h"
  33. #include "opus_defines.h"
  34. #include "opus_custom.h"
  35. #include "entenc.h"
  36. #include "entdec.h"
  37. #include "arch.h"
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #define CELTEncoder OpusCustomEncoder
  42. #define CELTDecoder OpusCustomDecoder
  43. #define CELTMode OpusCustomMode
  44. #define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
  45. /* Encoder/decoder Requests */
  46. #define CELT_SET_PREDICTION_REQUEST 10002
  47. /** Controls the use of interframe prediction.
  48. 0=Independent frames
  49. 1=Short term interframe prediction allowed
  50. 2=Long term prediction allowed
  51. */
  52. #define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, __opus_check_int(x)
  53. #define CELT_SET_INPUT_CLIPPING_REQUEST 10004
  54. #define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, __opus_check_int(x)
  55. #define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007
  56. #define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, __opus_check_int_ptr(x)
  57. #define CELT_SET_CHANNELS_REQUEST 10008
  58. #define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, __opus_check_int(x)
  59. /* Internal */
  60. #define CELT_SET_START_BAND_REQUEST 10010
  61. #define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, __opus_check_int(x)
  62. #define CELT_SET_END_BAND_REQUEST 10012
  63. #define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, __opus_check_int(x)
  64. #define CELT_GET_MODE_REQUEST 10015
  65. /** Get the CELTMode used by an encoder or decoder */
  66. #define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x)
  67. #define CELT_SET_SIGNALLING_REQUEST 10016
  68. #define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, __opus_check_int(x)
  69. /* Encoder stuff */
  70. int celt_encoder_get_size(int channels);
  71. int celt_encode_with_ec(OpusCustomEncoder * restrict st, const opus_val16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
  72. int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels);
  73. /* Decoder stuff */
  74. int celt_decoder_get_size(int channels);
  75. int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels);
  76. int celt_decode_with_ec(OpusCustomDecoder * restrict st, const unsigned char *data, int len, opus_val16 * restrict pcm, int frame_size, ec_dec *dec);
  77. #define celt_encoder_ctl opus_custom_encoder_ctl
  78. #define celt_decoder_ctl opus_custom_decoder_ctl
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /*CELT_H */