celt.h 4.2 KB

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