evrcc.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef _EVRC_CODEC_H_
  2. #define _EVRC_CODEC_H_
  3. #if defined _WIN32 || defined __CYGWIN__
  4. #ifdef EVRC_BUILDING_DLL
  5. #ifdef __GNUC__
  6. #define DLL_PUBLIC __attribute__ ((dllexport))
  7. #else
  8. #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
  9. #endif
  10. #else
  11. #ifdef __GNUC__
  12. #define DLL_PUBLIC __attribute__ ((dllimport))
  13. #else
  14. #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
  15. #endif
  16. #endif
  17. #define DLL_LOCAL
  18. #else
  19. #if __GNUC__ >= 4
  20. #define DLL_PUBLIC __attribute__ ((visibility ("default")))
  21. #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
  22. #else
  23. #define DLL_PUBLIC
  24. #define DLL_LOCAL
  25. #endif
  26. #endif
  27. #include <stddef.h>
  28. #if defined _WIN32
  29. #include "stdint_win32.h"
  30. #else
  31. #include <stdint.h>
  32. #endif
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. static const int EVRC_CODEC_ERROR = -1;
  37. static const int EVRC_CODEC_BUFFER_SMALL = -2;
  38. DLL_PUBLIC int evrc_get_stream_frame_count(const uint8_t* bits,size_t bits_bytes);
  39. DLL_PUBLIC int evrc_packet_to_stream(const uint8_t* packet,size_t packet_size,uint8_t* stream,size_t stream_size);
  40. DLL_PUBLIC int evrc_stream_to_packet(const uint8_t* stream,size_t frame_count,uint8_t* packet,size_t packet_size);
  41. // encoder interface
  42. DLL_PUBLIC void* evrc_encoder_init(int16_t min_rate,int16_t max_rate,int16_t noise_suppression);
  43. DLL_PUBLIC void evrc_encoder_uninit(void* c);
  44. DLL_PUBLIC int evrc_encoder_encode_to_packet(void* c,int16_t* speech,size_t speech_samples,uint8_t* packet,size_t packet_max_bytes);
  45. DLL_PUBLIC int evrc_encoder_encode_to_stream(void* c,int16_t* speech,size_t speech_samples,uint8_t* bits,size_t bits_max_bytes);
  46. DLL_PUBLIC int evrc_encoder_max_encode(void* c,size_t speech_samples);
  47. // decoder interface
  48. DLL_PUBLIC void* evrc_decoder_init();
  49. DLL_PUBLIC void evrc_decoder_uninit(void* c);
  50. DLL_PUBLIC int evrc_decoder_decode_from_packet(void* c,const uint8_t* packet,size_t packet_bytes,int16_t* speech,size_t speech_max_samples);
  51. DLL_PUBLIC int evrc_decoder_decode_from_stream(void* c,const uint8_t* stream,size_t stream_bytes,int16_t* speech,size_t speech_max_samples);
  52. DLL_PUBLIC int evrc_decoder_decode_stream_frame(void* c, const uint8_t* bits,size_t bits_bytes,int16_t* speech);
  53. DLL_PUBLIC int evrc_decoder_stream_max_sample(const uint8_t* bits,size_t bits_bytes);
  54. DLL_PUBLIC int evrc_decoder_stream_frame_bytes(const uint8_t* bits);
  55. DLL_PUBLIC int evrc_decoder_is_silence_stream_frame(const uint8_t* bits);
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif