SKP_Silk_SDK_API.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /***********************************************************************
  2. Copyright (c) 2006-2011, Skype Limited. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, (subject to the limitations in the disclaimer below)
  5. are permitted provided that the following conditions are met:
  6. - Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. - Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. - Neither the name of Skype Limited, nor the names of specific
  12. contributors, may be used to endorse or promote products derived from
  13. this software without specific prior written permission.
  14. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
  15. BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  16. CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  17. BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  18. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  19. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  22. USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  23. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. ***********************************************************************/
  27. #ifndef SKP_SILK_SDK_API_H
  28. #define SKP_SILK_SDK_API_H
  29. #include "SKP_Silk_control.h"
  30. #include "SKP_Silk_typedef.h"
  31. #include "SKP_Silk_errors.h"
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. #define SILK_MAX_FRAMES_PER_PACKET 5
  37. /* Struct for TOC (Table of Contents) */
  38. typedef struct {
  39. SKP_int framesInPacket; /* Number of 20 ms frames in packet */
  40. SKP_int fs_kHz; /* Sampling frequency in packet */
  41. SKP_int inbandLBRR; /* Does packet contain LBRR information */
  42. SKP_int corrupt; /* Packet is corrupt */
  43. SKP_int vadFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* VAD flag for each frame in packet */
  44. SKP_int sigtypeFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Signal type for each frame in packet */
  45. } SKP_Silk_TOC_struct;
  46. /****************************************/
  47. /* Encoder functions */
  48. /****************************************/
  49. /***********************************************/
  50. /* Get size in bytes of the Silk encoder state */
  51. /***********************************************/
  52. SKP_int SKP_Silk_SDK_Get_Encoder_Size(
  53. SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
  54. );
  55. /*************************/
  56. /* Init or reset encoder */
  57. /*************************/
  58. SKP_int SKP_Silk_SDK_InitEncoder(
  59. void *encState, /* I/O: State */
  60. SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
  61. );
  62. /***************************************/
  63. /* Read control structure from encoder */
  64. /***************************************/
  65. SKP_int SKP_Silk_SDK_QueryEncoder(
  66. const void *encState, /* I: State */
  67. SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
  68. );
  69. /**************************/
  70. /* Encode frame with Silk */
  71. /**************************/
  72. SKP_int SKP_Silk_SDK_Encode(
  73. void *encState, /* I/O: State */
  74. const SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */
  75. const SKP_int16 *samplesIn, /* I: Speech sample input vector */
  76. SKP_int nSamplesIn, /* I: Number of samples in input vector */
  77. SKP_uint8 *outData, /* O: Encoded output vector */
  78. SKP_int16 *nBytesOut /* I/O: Number of bytes in outData (input: Max bytes) */
  79. );
  80. /****************************************/
  81. /* Decoder functions */
  82. /****************************************/
  83. /***********************************************/
  84. /* Get size in bytes of the Silk decoder state */
  85. /***********************************************/
  86. SKP_int SKP_Silk_SDK_Get_Decoder_Size(
  87. SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
  88. );
  89. /*************************/
  90. /* Init or Reset decoder */
  91. /*************************/
  92. SKP_int SKP_Silk_SDK_InitDecoder(
  93. void *decState /* I/O: State */
  94. );
  95. /******************/
  96. /* Decode a frame */
  97. /******************/
  98. SKP_int SKP_Silk_SDK_Decode(
  99. void* decState, /* I/O: State */
  100. SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */
  101. SKP_int lostFlag, /* I: 0: no loss, 1 loss */
  102. const SKP_uint8 *inData, /* I: Encoded input vector */
  103. const SKP_int nBytesIn, /* I: Number of input bytes */
  104. SKP_int16 *samplesOut, /* O: Decoded output speech vector */
  105. SKP_int16 *nSamplesOut /* I/O: Number of samples (vector/decoded) */
  106. );
  107. /***************************************************************/
  108. /* Find Low Bit Rate Redundancy (LBRR) information in a packet */
  109. /***************************************************************/
  110. void SKP_Silk_SDK_search_for_LBRR(
  111. const SKP_uint8 *inData, /* I: Encoded input vector */
  112. const SKP_int nBytesIn, /* I: Number of input Bytes */
  113. SKP_int lost_offset, /* I: Offset from lost packet */
  114. SKP_uint8 *LBRRData, /* O: LBRR payload */
  115. SKP_int16 *nLBRRBytes /* O: Number of LBRR Bytes */
  116. );
  117. /**************************************/
  118. /* Get table of contents for a packet */
  119. /**************************************/
  120. void SKP_Silk_SDK_get_TOC(
  121. const SKP_uint8 *inData, /* I: Encoded input vector */
  122. const SKP_int nBytesIn, /* I: Number of input bytes */
  123. SKP_Silk_TOC_struct *Silk_TOC /* O: Table of contents */
  124. );
  125. /**************************/
  126. /* Get the version number */
  127. /**************************/
  128. /* Return a pointer to string specifying the version */
  129. const char *SKP_Silk_SDK_get_version();
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif