Chris@69: /*********************************************************************** Chris@69: Copyright (c) 2006-2011, Skype Limited. All rights reserved. Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions Chris@69: are met: Chris@69: - Redistributions of source code must retain the above copyright notice, Chris@69: this list of conditions and the following disclaimer. Chris@69: - Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: - Neither the name of Internet Society, IETF or IETF Trust, nor the Chris@69: names of specific contributors, may be used to endorse or promote Chris@69: products derived from this software without specific prior written Chris@69: permission. Chris@69: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" Chris@69: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE Chris@69: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE Chris@69: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE Chris@69: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR Chris@69: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF Chris@69: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS Chris@69: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN Chris@69: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) Chris@69: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE Chris@69: POSSIBILITY OF SUCH DAMAGE. Chris@69: ***********************************************************************/ Chris@69: Chris@69: #ifndef SILK_API_H Chris@69: #define SILK_API_H Chris@69: Chris@69: #include "control.h" Chris@69: #include "typedef.h" Chris@69: #include "errors.h" Chris@69: #include "entenc.h" Chris@69: #include "entdec.h" Chris@69: Chris@69: #ifdef __cplusplus Chris@69: extern "C" Chris@69: { Chris@69: #endif Chris@69: Chris@69: #define SILK_MAX_FRAMES_PER_PACKET 3 Chris@69: Chris@69: /* Struct for TOC (Table of Contents) */ Chris@69: typedef struct { Chris@69: opus_int VADFlag; /* Voice activity for packet */ Chris@69: opus_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */ Chris@69: opus_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */ Chris@69: } silk_TOC_struct; Chris@69: Chris@69: /****************************************/ Chris@69: /* Encoder functions */ Chris@69: /****************************************/ Chris@69: Chris@69: /***********************************************/ Chris@69: /* Get size in bytes of the Silk encoder state */ Chris@69: /***********************************************/ Chris@69: opus_int silk_Get_Encoder_Size( /* O Returns error code */ Chris@69: opus_int *encSizeBytes /* O Number of bytes in SILK encoder state */ Chris@69: ); Chris@69: Chris@69: /*************************/ Chris@69: /* Init or reset encoder */ Chris@69: /*************************/ Chris@69: opus_int silk_InitEncoder( /* O Returns error code */ Chris@69: void *encState, /* I/O State */ Chris@69: int arch, /* I Run-time architecture */ Chris@69: silk_EncControlStruct *encStatus /* O Encoder Status */ Chris@69: ); Chris@69: Chris@69: /**************************/ Chris@69: /* Encode frame with Silk */ Chris@69: /**************************/ Chris@69: /* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */ Chris@69: /* encControl->payloadSize_ms is set to */ Chris@69: opus_int silk_Encode( /* O Returns error code */ Chris@69: void *encState, /* I/O State */ Chris@69: silk_EncControlStruct *encControl, /* I Control status */ Chris@69: const opus_int16 *samplesIn, /* I Speech sample input vector */ Chris@69: opus_int nSamplesIn, /* I Number of samples in input vector */ Chris@69: ec_enc *psRangeEnc, /* I/O Compressor data structure */ Chris@69: opus_int32 *nBytesOut, /* I/O Number of bytes in payload (input: Max bytes) */ Chris@69: const opus_int prefillFlag, /* I Flag to indicate prefilling buffers no coding */ Chris@69: int activity /* I Decision of Opus voice activity detector */ Chris@69: ); Chris@69: Chris@69: /****************************************/ Chris@69: /* Decoder functions */ Chris@69: /****************************************/ Chris@69: Chris@69: /***********************************************/ Chris@69: /* Get size in bytes of the Silk decoder state */ Chris@69: /***********************************************/ Chris@69: opus_int silk_Get_Decoder_Size( /* O Returns error code */ Chris@69: opus_int *decSizeBytes /* O Number of bytes in SILK decoder state */ Chris@69: ); Chris@69: Chris@69: /*************************/ Chris@69: /* Init or Reset decoder */ Chris@69: /*************************/ Chris@69: opus_int silk_InitDecoder( /* O Returns error code */ Chris@69: void *decState /* I/O State */ Chris@69: ); Chris@69: Chris@69: /******************/ Chris@69: /* Decode a frame */ Chris@69: /******************/ Chris@69: opus_int silk_Decode( /* O Returns error code */ Chris@69: void* decState, /* I/O State */ Chris@69: silk_DecControlStruct* decControl, /* I/O Control Structure */ Chris@69: opus_int lostFlag, /* I 0: no loss, 1 loss, 2 decode fec */ Chris@69: opus_int newPacketFlag, /* I Indicates first decoder call for this packet */ Chris@69: ec_dec *psRangeDec, /* I/O Compressor data structure */ Chris@69: opus_int16 *samplesOut, /* O Decoded output speech vector */ Chris@69: opus_int32 *nSamplesOut, /* O Number of samples decoded */ Chris@69: int arch /* I Run-time architecture */ Chris@69: ); Chris@69: Chris@69: #if 0 Chris@69: /**************************************/ Chris@69: /* Get table of contents for a packet */ Chris@69: /**************************************/ Chris@69: opus_int silk_get_TOC( Chris@69: const opus_uint8 *payload, /* I Payload data */ Chris@69: const opus_int nBytesIn, /* I Number of input bytes */ Chris@69: const opus_int nFramesPerPayload, /* I Number of SILK frames per payload */ Chris@69: silk_TOC_struct *Silk_TOC /* O Type of content */ Chris@69: ); Chris@69: #endif Chris@69: Chris@69: #ifdef __cplusplus Chris@69: } Chris@69: #endif Chris@69: Chris@69: #endif