wamr.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _WAMR_CODEC_H_
  2. #define _WAMR_CODEC_H_
  3. #if 0
  4. #if defined _WIN32 || defined __CYGWIN__
  5. #ifdef EVRC_BUILDING_DLL
  6. #ifdef __GNUC__
  7. #define DLL_PUBLIC __attribute__ ((dllexport))
  8. #else
  9. #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
  10. #endif
  11. #else
  12. #ifdef __GNUC__
  13. #define DLL_PUBLIC __attribute__ ((dllimport))
  14. #else
  15. #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
  16. #endif
  17. #endif
  18. #define DLL_LOCAL
  19. #else
  20. #if __GNUC__ >= 4
  21. #define DLL_PUBLIC __attribute__ ((visibility ("default")))
  22. #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
  23. #else
  24. #define DLL_PUBLIC
  25. #define DLL_LOCAL
  26. #endif
  27. #endif
  28. #endif
  29. #include <stddef.h>
  30. #include "cnst.h"
  31. #define MMS_IO
  32. #if defined _WIN32
  33. #include "stdint_win32.h"
  34. #else
  35. #include <stdint.h>
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /* frame size in serial bitstream file (frame type + serial stream + flags) */
  41. #define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5)
  42. #define MAX_PACKED_SIZE (MAX_SERIAL_SIZE / 8 + 2)
  43. #define UMR475 0
  44. #define UMR515 1
  45. #define UMR59 2
  46. #define UMR67 3
  47. #define UMR74 4
  48. #define UMR795 5
  49. #define UMR102 6
  50. #define UMR122 7
  51. #define UMRDTX 8
  52. #define UN_MODES 9 /* number of (SPC) modes */
  53. #define AMRC_INIT_OK 0
  54. #define AMRC_INIT_FAILED 1
  55. #define AMRC_CODEC_SUCC 0
  56. #define AMRC_CODEC_ERROR -1
  57. #define AMRC_CODEC_BUFFER_SMALL -2
  58. #define AMRC_CODEC_BUFFER_ERR -3
  59. #define PACKED_SIZE_ITEM 16 //packed_size的元素个数
  60. extern const short packed_size[16];
  61. int wamr_encoder_init();
  62. void wamr_encoder_uninit();
  63. int wamr_decoder_init();
  64. void wamr_decoder_uninit();
  65. //new_speech,input pcm speech
  66. //speech_size, has to be 160
  67. //outPacked, output amr packed buffer
  68. //outPacked_size, size of outPacked, can not small than 32
  69. //outLen, real output size number for outPacked
  70. //mode, encode mode
  71. //return AMRC_CODEC_SUCC for if no error
  72. int wamr_encoder_encode_frame(short *new_speech, int speech_size, unsigned char *outPacked, int outPacked_size, unsigned short *outLen, int mode);
  73. int wamr_decoder_decode_frame(unsigned char *inpackedBits, unsigned short inpacked_size, short *outSpeech, unsigned short out_size);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif