Including config.h (fixes the fixed-point)
[opus.git] / silk / SKP_Silk_SDK_API.h
1 /***********************************************************************\r
2 Copyright (c) 2006-2011, 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 #include "entenc.h"\r
35 #include "entdec.h"\r
36 \r
37 #ifdef __cplusplus\r
38 extern "C"\r
39 {\r
40 #endif\r
41 \r
42 #define SILK_MAX_FRAMES_PER_PACKET  3\r
43 \r
44 /* Struct for TOC (Table of Contents) */\r
45 typedef struct {\r
46     SKP_int     VADFlag;                                /* Voice activity for packet                            */\r
47     SKP_int     VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet              */\r
48     SKP_int     inbandFECFlag;                          /* Flag indicating if packet contains in-band FEC       */\r
49 } SKP_Silk_TOC_struct;\r
50 \r
51 /****************************************/\r
52 /* Encoder functions                    */\r
53 /****************************************/\r
54 \r
55 /***********************************************/\r
56 /* Get size in bytes of the Silk encoder state */\r
57 /***********************************************/\r
58 SKP_int SKP_Silk_SDK_Get_Encoder_Size(                  /* O:   Returns error code                              */\r
59     SKP_int32                           *encSizeBytes   /* O:   Number of bytes in SILK encoder state           */\r
60 );\r
61 \r
62 /*************************/\r
63 /* Init or reset encoder */\r
64 /*************************/\r
65 SKP_int SKP_Silk_SDK_InitEncoder(                       /* O:   Returns error code                              */\r
66     void                                *encState,      /* I/O: State                                           */\r
67     SKP_SILK_SDK_EncControlStruct       *encStatus      /* O:   Encoder Status                                  */\r
68 );\r
69 \r
70 /***************************************/\r
71 /* Read control structure from encoder */\r
72 /***************************************/\r
73 SKP_int SKP_Silk_SDK_QueryEncoder(                      /* O:   Returns error code                              */\r
74     const void                          *encState,      /* I:   State                                           */\r
75     SKP_SILK_SDK_EncControlStruct       *encStatus      /* O:   Encoder Status                                  */\r
76 );\r
77 \r
78 /**************************/\r
79 /* Encode frame with Silk */\r
80 /**************************/\r
81 /* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what                                     */\r
82 /* encControl->payloadSize_ms is set to                                                                                                                                                 */\r
83 SKP_int SKP_Silk_SDK_Encode(                            /* O:   Returns error code                              */\r
84     void                                *encState,      /* I/O: State                                           */\r
85     SKP_SILK_SDK_EncControlStruct       *encControl,    /* I:   Control status                                  */\r
86     const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector                      */\r
87     SKP_int                             nSamplesIn,     /* I:   Number of samples in input vector               */\r
88     ec_enc                              *psRangeEnc,    /* I/O  Compressor data structure                       */\r
89     SKP_int32                           *nBytesOut,     /* I/O: Number of bytes in payload (input: Max bytes)   */\r
90     const SKP_int                       prefillFlag     /* I:   Flag to indicate prefilling buffers no coding   */\r
91 );\r
92 \r
93 /****************************************/\r
94 /* Decoder functions                    */\r
95 /****************************************/\r
96 \r
97 /***********************************************/\r
98 /* Get size in bytes of the Silk decoder state */\r
99 /***********************************************/\r
100 SKP_int SKP_Silk_SDK_Get_Decoder_Size(                  /* O:   Returns error code                              */\r
101     SKP_int32                           *decSizeBytes   /* O:   Number of bytes in SILK decoder state           */\r
102 );\r
103 \r
104 /*************************/\r
105 /* Init or Reset decoder */\r
106 /*************************/\r
107 SKP_int SKP_Silk_SDK_InitDecoder(                       /* O:   Returns error code                              */\r
108     void                                *decState       /* I/O: State                                           */\r
109 );\r
110 \r
111 /******************/\r
112 /* Decode a frame */\r
113 /******************/\r
114 SKP_int SKP_Silk_SDK_Decode(                            /* O:   Returns error code                              */\r
115     void*                               decState,       /* I/O: State                                           */\r
116     SKP_SILK_SDK_DecControlStruct*      decControl,     /* I/O: Control Structure                               */\r
117     SKP_int                             lostFlag,       /* I:   0: no loss, 1 loss, 2 decode fec                */\r
118     SKP_int                             newPacketFlag,  /* I:   Indicates first decoder call for this packet    */\r
119     ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                       */\r
120     SKP_int16                           *samplesOut,    /* O:   Decoded output speech vector                    */\r
121     SKP_int32                           *nSamplesOut    /* O:   Number of samples decoded                       */\r
122 );\r
123 \r
124 /***************************************************************/\r
125 /* Find Low Bit Rate Redundancy (LBRR) information in a packet */\r
126 /***************************************************************/\r
127 void SKP_Silk_SDK_search_for_LBRR(\r
128     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
129     const SKP_int16                     nBytesIn,       /* I:   Number of input bytes                           */\r
130     SKP_int                             lost_offset,    /* I:   Offset from lost packet                         */\r
131     SKP_uint8                           *LBRRData,      /* O:   LBRR payload                                    */\r
132     SKP_int32                           *nLBRRBytes     /* O:   Number of LBRR Bytes                            */\r
133 );\r
134 \r
135 /**************************************/\r
136 /* Get table of contents for a packet */\r
137 /**************************************/\r
138 SKP_int SKP_Silk_SDK_get_TOC(\r
139     const SKP_uint8                     *payload,           /* I    Payload data                                */\r
140     const SKP_int                       nBytesIn,           /* I:   Number of input bytes                       */\r
141     const SKP_int                       nFramesPerPayload,  /* I:   Number of SILK frames per payload           */\r
142     SKP_Silk_TOC_struct                 *Silk_TOC           /* O:   Type of content                             */\r
143 );\r
144 \r
145 #ifdef __cplusplus\r
146 }\r
147 #endif\r
148 \r
149 #endif\r