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