diff --git a/AMBuilder b/AMBuilder index eb276d0..e832f0a 100644 --- a/AMBuilder +++ b/AMBuilder @@ -18,10 +18,10 @@ for sdk_name in SM.sdks: binary = SM.HL2Config(project, projectName + '.ext', sdk) binary.compiler.cxxincludes += [ os.path.join(SM.sm_root, 'public', 'extensions'), - os.path.join(builder.sourcePath, 'silk') + os.path.join(builder.sourcePath, 'celt') ] binary.compiler.linkflags += [ - os.path.join(builder.sourcePath, 'silk', 'libSKP_SILK_SDK.a') + os.path.join(builder.sourcePath, 'celt', 'libcelt0.a') ] SM.extensions += builder.Add(project) diff --git a/celt/celt.h b/celt/celt.h new file mode 100644 index 0000000..2bbf506 --- /dev/null +++ b/celt/celt.h @@ -0,0 +1,325 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2009 Xiph.Org Foundation + Copyright (c) 2008 Gregory Maxwell + Written by Jean-Marc Valin and Gregory Maxwell */ +/** + @file celt.h + @brief Contains all the functions for encoding and decoding audio + */ + +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CELT_H +#define CELT_H + +#include "celt_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) && defined(CELT_BUILD) +#define EXPORT __attribute__ ((visibility ("default"))) +#elif defined(WIN32) +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +#define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x)) +#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr))) +#define _celt_check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr))) + +/* Error codes */ +/** No error */ +#define CELT_OK 0 +/** An (or more) invalid argument (e.g. out of range) */ +#define CELT_BAD_ARG -1 +/** The mode struct passed is invalid */ +#define CELT_BUFFER_TOO_SMALL -2 +/** An internal error was detected */ +#define CELT_INTERNAL_ERROR -3 +/** The data passed (e.g. compressed data to decoder) is corrupted */ +#define CELT_CORRUPTED_DATA -4 +/** Invalid/unsupported request number */ +#define CELT_UNIMPLEMENTED -5 +/** An encoder or decoder structure is invalid or already freed */ +#define CELT_INVALID_STATE -6 +/** Memory allocation has failed */ +#define CELT_ALLOC_FAIL -7 + + +/* Encoder/decoder Requests */ + +#define CELT_SET_COMPLEXITY_REQUEST 2 +/** Controls the complexity from 0-10 (int) */ +#define CELT_SET_COMPLEXITY(x) CELT_SET_COMPLEXITY_REQUEST, _celt_check_int(x) + +#define CELT_SET_PREDICTION_REQUEST 4 +/** Controls the use of interframe prediction. + 0=Independent frames + 1=Short term interframe prediction allowed + 2=Long term prediction allowed + */ +#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, _celt_check_int(x) + +#define CELT_SET_BITRATE_REQUEST 6 +/** Set the target VBR rate in bits per second(int); 0=CBR (default) */ +#define CELT_SET_BITRATE(x) CELT_SET_BITRATE_REQUEST, _celt_check_int(x) + +#define CELT_RESET_STATE_REQUEST 8 +/** Reset the encoder/decoder memories to zero*/ +#define CELT_RESET_STATE CELT_RESET_STATE_REQUEST + +#define CELT_SET_VBR_CONSTRAINT_REQUEST 10 +#define CELT_SET_VBR_CONSTRAINT(x) CELT_SET_VBR_CONSTRAINT_REQUEST, _celt_check_int(x) + +#define CELT_SET_VBR_REQUEST 12 +#define CELT_SET_VBR(x) CELT_SET_VBR_REQUEST, _celt_check_int(x) + +#define CELT_SET_INPUT_CLIPPING_REQUEST 14 +#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, _celt_check_int(x) + +#define CELT_GET_AND_CLEAR_ERROR_REQUEST 15 +#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, _celt_check_int_ptr(x) + +#define CELT_GET_LOOKAHEAD_REQUEST 17 +#define CELT_GET_LOOKAHEAD(x) CELT_GET_LOOKAHEAD_REQUEST, _celt_check_int_ptr(x) + +#define CELT_SET_CHANNELS_REQUEST 18 +#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, _celt_check_int(x) + +#define CELT_SET_LOSS_PERC_REQUEST 20 +#define CELT_SET_LOSS_PERC(x) CELT_SET_LOSS_PERC_REQUEST, _celt_check_int(x) + +/* Internal */ +#define CELT_SET_START_BAND_REQUEST 10000 +#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, _celt_check_int(x) + +#define CELT_SET_END_BAND_REQUEST 10001 +#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, _celt_check_int(x) + + + +/** Contains the state of an encoder. One encoder state is needed + for each stream. It is initialised once at the beginning of the + stream. Do *not* re-initialise the state for every frame. + @brief Encoder state + */ +typedef struct CELTEncoder CELTEncoder; + +/** State of the decoder. One decoder state is needed for each stream. + It is initialised once at the beginning of the stream. Do *not* + re-initialise the state for every frame */ +typedef struct CELTDecoder CELTDecoder; + +/** The mode contains all the information necessary to create an + encoder. Both the encoder and decoder need to be initialised + with exactly the same mode, otherwise the quality will be very + bad */ +typedef struct CELTMode CELTMode; + + +/** \defgroup codec Encoding and decoding */ +/* @{ */ + +/* Mode calls */ + +/** Creates a new mode struct. This will be passed to an encoder or + decoder. The mode MUST NOT BE DESTROYED until the encoders and + decoders that use it are destroyed as well. + @param Fs Sampling rate (32000 to 96000 Hz) + @param frame_size Number of samples (per channel) to encode in each + packet (even values; 64 - 512) + @param error Returned error code (if NULL, no error will be returned) + @return A newly created mode +*/ +EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error); + +/** Destroys a mode struct. Only call this after all encoders and + decoders using this mode are destroyed as well. + @param mode Mode to be destroyed +*/ +EXPORT void celt_mode_destroy(CELTMode *mode); + +/* Encoder stuff */ + +EXPORT int celt_encoder_get_size(int channels); + +EXPORT int celt_encoder_get_size_custom(const CELTMode *mode, int channels); + +/** Creates a new encoder state. Each stream needs its own encoder + state (can't be shared across simultaneous streams). + @param channels Number of channels + @param error Returns an error code + @return Newly created encoder state. +*/ +EXPORT CELTEncoder *celt_encoder_create(int sampling_rate, int channels, int *error); + +/** Creates a new encoder state. Each stream needs its own encoder + state (can't be shared across simultaneous streams). + @param mode Contains all the information about the characteristics of + * the stream (must be the same characteristics as used for the + * decoder) + @param channels Number of channels + @param error Returns an error code + @return Newly created encoder state. +*/ +EXPORT CELTEncoder *celt_encoder_create_custom(const CELTMode *mode, int channels, int *error); + +EXPORT CELTEncoder *celt_encoder_init(CELTEncoder *st, int sampling_rate, int channels, int *error); + +EXPORT CELTEncoder *celt_encoder_init_custom(CELTEncoder *st, const CELTMode *mode, int channels, int *error); + +/** Destroys a an encoder state. + @param st Encoder state to be destroyed + */ +EXPORT void celt_encoder_destroy(CELTEncoder *st); + +/** Encodes a frame of audio. + @param st Encoder state + @param pcm PCM audio in float format, with a normal range of ±1.0. + * Samples with a range beyond ±1.0 are supported but will + * be clipped by decoders using the integer API and should + * only be used if it is known that the far end supports + * extended dynmaic range. There must be exactly + * frame_size samples per channel. + @param compressed The compressed data is written here. This may not alias pcm or + * optional_synthesis. + @param nbCompressedBytes Maximum number of bytes to use for compressing the frame + * (can change from one frame to another) + @return Number of bytes written to "compressed". Will be the same as + * "nbCompressedBytes" unless the stream is VBR and will never be larger. + * If negative, an error has occurred (see error codes). It is IMPORTANT that + * the length returned be somehow transmitted to the decoder. Otherwise, no + * decoding is possible. +*/ +EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes); + +/** Encodes a frame of audio. + @param st Encoder state + @param pcm PCM audio in signed 16-bit format (native endian). There must be + * exactly frame_size samples per channel. + @param compressed The compressed data is written here. This may not alias pcm or + * optional_synthesis. + @param nbCompressedBytes Maximum number of bytes to use for compressing the frame + * (can change from one frame to another) + @return Number of bytes written to "compressed". Will be the same as + * "nbCompressedBytes" unless the stream is VBR and will never be larger. + * If negative, an error has occurred (see error codes). It is IMPORTANT that + * the length returned be somehow transmitted to the decoder. Otherwise, no + * decoding is possible. + */ +EXPORT int celt_encode(CELTEncoder *st, const celt_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes); + +/** Query and set encoder parameters + @param st Encoder state + @param request Parameter to change or query + @param value Pointer to a 32-bit int value + @return Error code +*/ +EXPORT int celt_encoder_ctl(CELTEncoder * st, int request, ...); + +/* Decoder stuff */ + +EXPORT int celt_decoder_get_size(int channels); + +EXPORT int celt_decoder_get_size_custom(const CELTMode *mode, int channels); + +/** Creates a new decoder state. Each stream needs its own decoder state (can't + be shared across simultaneous streams). + @param mode Contains all the information about the characteristics of the + stream (must be the same characteristics as used for the encoder) + @param channels Number of channels + @param error Returns an error code + @return Newly created decoder state. + */ +EXPORT CELTDecoder *celt_decoder_create(int sampling_rate, int channels, int *error); + +/** Creates a new decoder state. Each stream needs its own decoder state (can't + be shared across simultaneous streams). + @param mode Contains all the information about the characteristics of the + stream (must be the same characteristics as used for the encoder) + @param channels Number of channels + @param error Returns an error code + @return Newly created decoder state. + */ +EXPORT CELTDecoder *celt_decoder_create_custom(const CELTMode *mode, int channels, int *error); + +EXPORT CELTDecoder *celt_decoder_init(CELTDecoder *st, int sampling_rate, int channels, int *error); + +EXPORT CELTDecoder *celt_decoder_init_custom(CELTDecoder *st, const CELTMode *mode, int channels, int *error); + +/** Destroys a a decoder state. + @param st Decoder state to be destroyed + */ +EXPORT void celt_decoder_destroy(CELTDecoder *st); + +/** Decodes a frame of audio. + @param st Decoder state + @param data Compressed data produced by an encoder + @param len Number of bytes to read from "data". This MUST be exactly the number + of bytes returned by the encoder. Using a larger value WILL NOT WORK. + @param pcm One frame (frame_size samples per channel) of decoded PCM will be + returned here in float format. + @return Error code. + */ +EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, int len, float *pcm, int frame_size); + +/** Decodes a frame of audio. + @param st Decoder state + @param data Compressed data produced by an encoder + @param len Number of bytes to read from "data". This MUST be exactly the number + of bytes returned by the encoder. Using a larger value WILL NOT WORK. + @param pcm One frame (frame_size samples per channel) of decoded PCM will be + returned here in 16-bit PCM format (native endian). + @return Error code. + */ +EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm, int frame_size); + +/** Query and set decoder parameters + @param st Decoder state + @param request Parameter to change or query + @param value Pointer to a 32-bit int value + @return Error code + */ +EXPORT int celt_decoder_ctl(CELTDecoder * st, int request, ...); + + +/** Returns the English string that corresponds to an error code + * @param error Error code (negative for an error, 0 for success + * @return Constant string (must NOT be freed) + */ +EXPORT const char *celt_strerror(int error); + +/* @} */ + + +#ifdef __cplusplus +} +#endif + +#endif /*CELT_H */ diff --git a/celt/celt_header.h b/celt/celt_header.h new file mode 100644 index 0000000..3777484 --- /dev/null +++ b/celt/celt_header.h @@ -0,0 +1,66 @@ +/* Copyright (c) 2007 CSIRO + Copyright (c) 2007-2008 Xiph.Org Foundation + Written by Jean-Marc Valin */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef CELT_HEADER_H +#define CELT_HEADER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "celt.h" +#include "celt_types.h" + +/** Header data to be used for Ogg files (or possibly other encapsulation) + @brief Header data + */ +typedef struct { + char codec_id[8]; /**< MUST be "CELT " (four spaces) */ + char codec_version[20]; /**< Version used (as string) */ + celt_int32 version_id; /**< Version id (negative for until stream is frozen) */ + celt_int32 header_size; /**< Size of this header */ + celt_int32 sample_rate; /**< Sampling rate of the original audio */ + celt_int32 nb_channels; /**< Number of channels */ + celt_int32 frame_size; /**< Samples per frame (per channel) */ + celt_int32 overlap; /**< Overlapping samples (per channel) */ + celt_int32 bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */ + celt_int32 extra_headers; /**< Number of additional headers that follow this header */ +} CELTHeader; + +/** Creates a basic header struct */ +EXPORT int celt_header_init(CELTHeader *header, const CELTMode *m, int frame_size, int channels); + +EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size); + +EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header); + +#ifdef __cplusplus +} +#endif + +#endif /* CELT_HEADER_H */ diff --git a/celt/celt_types.h b/celt/celt_types.h new file mode 100644 index 0000000..bfd498a --- /dev/null +++ b/celt/celt_types.h @@ -0,0 +1,151 @@ +/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ +/* Modified by Jean-Marc Valin */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +/* celt_types.h taken from libogg */ + +/** + @file celt_types.h + @brief CELT types +*/ +#ifndef _CELT_TYPES_H +#define _CELT_TYPES_H + +/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ +#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) +#include + + typedef int16_t celt_int16; + typedef uint16_t celt_uint16; + typedef int32_t celt_int32; + typedef uint32_t celt_uint32; +#elif defined(_WIN32) + +# if defined(__CYGWIN__) +# include <_G_config.h> + typedef _G_int32_t celt_int32; + typedef _G_uint32_t celt_uint32; + typedef _G_int16 celt_int16; + typedef _G_uint16 celt_uint16; +# elif defined(__MINGW32__) + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; +# elif defined(__MWERKS__) + typedef int celt_int32; + typedef unsigned int celt_uint32; + typedef short celt_int16; + typedef unsigned short celt_uint16; +# else + /* MSVC/Borland */ + typedef __int32 celt_int32; + typedef unsigned __int32 celt_uint32; + typedef __int16 celt_int16; + typedef unsigned __int16 celt_uint16; +# endif + +#elif defined(__MACOS__) + +# include + typedef SInt16 celt_int16; + typedef UInt16 celt_uint16; + typedef SInt32 celt_int32; + typedef UInt32 celt_uint32; + +#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ + +# include + typedef int16_t celt_int16; + typedef u_int16_t celt_uint16; + typedef int32_t celt_int32; + typedef u_int32_t celt_uint32; + +#elif defined(__BEOS__) + + /* Be */ +# include + typedef int16 celt_int16; + typedef u_int16 celt_uint16; + typedef int32_t celt_int32; + typedef u_int32_t celt_uint32; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; + +#elif defined(R5900) + + /* PS2 EE */ + typedef int celt_int32; + typedef unsigned celt_uint32; + typedef short celt_int16; + typedef unsigned short celt_uint16; + +#elif defined(__SYMBIAN32__) + + /* Symbian GCC */ + typedef signed short celt_int16; + typedef unsigned short celt_uint16; + typedef signed int celt_int32; + typedef unsigned int celt_uint32; + +#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) + + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef long celt_int32; + typedef unsigned long celt_uint32; + +#elif defined(CONFIG_TI_C6X) + + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; + +#else + + /* Give up, take a reasonable guess */ + typedef short celt_int16; + typedef unsigned short celt_uint16; + typedef int celt_int32; + typedef unsigned int celt_uint32; + +#endif + +#endif /* _CELT_TYPES_H */ diff --git a/celt/libcelt0.a b/celt/libcelt0.a new file mode 100644 index 0000000..0c73b68 Binary files /dev/null and b/celt/libcelt0.a differ diff --git a/extension.cpp b/extension.cpp index 64e7d1c..03f75ef 100644 --- a/extension.cpp +++ b/extension.cpp @@ -55,69 +55,6 @@ ConVar g_SmVoicePort("sm_voice_port", "27020", FCVAR_PROTECTED, "Voice server li template inline T min(T a, T b) { return a> 8); - } - - return ~crc; -} - CVoice g_Interface; SMEXT_LINK(&g_Interface); @@ -151,7 +88,8 @@ CVoice::CVoice() m_AvailableTime = 0.0; - m_Silk_EncoderState = NULL; + m_pMode = NULL; + m_pCodec = NULL; m_SV_BroadcastVoiceData = NULL; } @@ -295,44 +233,34 @@ bool CVoice::SDK_OnLoad(char *error, size_t maxlength, bool late) m_PollFds++; // Encoder settings - m_EncoderSettings.InputSampleRate_kHz = 48; // 8, 12, 16, 24, 32, 44.1, 48 - m_EncoderSettings.OutputSampleRate_kHz = 16; // 8, 12, 16, 24 - m_EncoderSettings.TargetBitRate_Kbps = 100; // 6 - 40 - m_EncoderSettings.PacketSize_ms = 20; // 20, 40, 60, 80, 100 - m_EncoderSettings.FrameSize_ms = 20; // - m_EncoderSettings.PacketLoss_perc = 0; // 0 - 100 - m_EncoderSettings.Complexity = 2; // 0 - 2 - m_EncoderSettings.InBandFEC = 0; // 0, 1 - m_EncoderSettings.DTX = 0; // 0, 1 + m_EncoderSettings.SampleRate_Hz = 22050; + m_EncoderSettings.TargetBitRate_Kbps = 64; + m_EncoderSettings.FrameSize = 512; // samples + m_EncoderSettings.PacketSize = 64; + m_EncoderSettings.Complexity = 10; // 0 - 10 + m_EncoderSettings.FrameTime = (double)m_EncoderSettings.FrameSize / (double)m_EncoderSettings.SampleRate_Hz; - // Init SILK encoder - int encoderSize; - SKP_Silk_SDK_Get_Encoder_Size(&encoderSize); - - m_Silk_EncoderState = malloc(encoderSize); - if(!m_Silk_EncoderState) + // Init CELT encoder + int theError; + m_pMode = celt_mode_create(m_EncoderSettings.SampleRate_Hz, m_EncoderSettings.FrameSize, &theError); + if(!m_pMode) { - g_SMAPI->Format(error, maxlength, "Failed to malloc %d bytes for silk encoder.", encoderSize); + g_SMAPI->Format(error, maxlength, "celt_mode_create error: %d", theError); SDK_OnUnload(); return false; } - int retEnc = SKP_Silk_SDK_InitEncoder(m_Silk_EncoderState, &m_Silk_EncoderControl); - if(retEnc != SKP_SILK_NO_ERROR) + m_pCodec = celt_encoder_create_custom(m_pMode, 1, &theError); + if(!m_pCodec) { - g_SMAPI->Format(error, maxlength, "Silk encoder initialization failed with: %d", retEnc); + g_SMAPI->Format(error, maxlength, "celt_encoder_create_custom error: %d", theError); SDK_OnUnload(); return false; } - m_Silk_EncoderControl.API_sampleRate = m_EncoderSettings.InputSampleRate_kHz * 1000; - m_Silk_EncoderControl.maxInternalSampleRate = m_EncoderSettings.OutputSampleRate_kHz * 1000; - m_Silk_EncoderControl.bitRate = m_EncoderSettings.TargetBitRate_Kbps * 1000; - m_Silk_EncoderControl.packetSize = m_EncoderSettings.PacketSize_ms * m_EncoderSettings.InputSampleRate_kHz; - m_Silk_EncoderControl.packetLossPercentage = m_EncoderSettings.PacketLoss_perc; - m_Silk_EncoderControl.complexity = m_EncoderSettings.Complexity; - m_Silk_EncoderControl.useInBandFEC = m_EncoderSettings.InBandFEC; - m_Silk_EncoderControl.useDTX = m_EncoderSettings.DTX; + celt_encoder_ctl(m_pCodec, CELT_RESET_STATE_REQUEST, NULL); + celt_encoder_ctl(m_pCodec, CELT_SET_BITRATE(m_EncoderSettings.TargetBitRate_Kbps * 1000)); + celt_encoder_ctl(m_pCodec, CELT_SET_COMPLEXITY(m_EncoderSettings.Complexity)); smutils->AddGameFrameHook(::OnGameFrame); @@ -379,11 +307,11 @@ void CVoice::SDK_OnUnload() } } - if(m_Silk_EncoderState) - { - free(m_Silk_EncoderState); - m_Silk_EncoderState = NULL; - } + if(m_pCodec) + celt_encoder_destroy(m_pCodec); + + if(m_pMode) + celt_mode_destroy(m_pMode); } void CVoice::OnGameFrame(bool simulating) @@ -550,21 +478,12 @@ void CVoice::OnDataReceived(CClient *pClient, int16_t *pData, size_t Samples) pClient->m_LastValidData = getTime(); } -struct SteamVoiceHeader -{ - uint32_t iSteamAccountID : 32; - uint32_t iSteamCommunity : 32; - uint32_t nPayload1 : 8; - uint32_t iSampleRate : 16; - uint32_t nPayload2 : 8; - uint32_t iDataLength : 16; -}; - void CVoice::HandleVoiceData() { - int SamplesPerFrame = m_EncoderSettings.FrameSize_ms * m_EncoderSettings.InputSampleRate_kHz; + int SamplesPerFrame = m_EncoderSettings.FrameSize; + int PacketSize = m_EncoderSettings.PacketSize; int FramesAvailable = m_Buffer.TotalLength() / SamplesPerFrame; - float TimeAvailable = (float)m_Buffer.TotalLength() / (m_EncoderSettings.InputSampleRate_kHz * 1000.0); + float TimeAvailable = (float)m_Buffer.TotalLength() / (float)m_EncoderSettings.SampleRate_Hz; if(!FramesAvailable) return; @@ -585,20 +504,6 @@ void CVoice::HandleVoiceData() if(!pClient) return; - SteamVoiceHeader Header; - size_t HeaderSize = 14; - - Header.iSteamAccountID = 1; // Steam Account ID - Header.iSteamCommunity = 0x01100001; // Steam Community ID part: 0x01100001 << 32 - Header.nPayload1 = 11; // nPayLoad | Type 11 = Samplerate - Header.iSampleRate = m_EncoderSettings.OutputSampleRate_kHz * 1000; // Samplerate - Header.nPayload2 = 4; // nPayLoad | Type 4 = Silk Frames - Header.iDataLength = 0; // Silk Frames total length - - // Header + Frames + CRC32 - unsigned char aFinal[HeaderSize + 8192 + sizeof(uint32_t)]; - size_t FinalSize = HeaderSize; - for(int Frame = 0; Frame < FramesAvailable; Frame++) { // Get data into buffer from ringbuffer. @@ -610,29 +515,22 @@ void CVoice::HandleVoiceData() if(!m_Buffer.Pop(aBuffer, SamplesPerFrame)) { - smutils->LogError(myself, "Buffer pop failed!!! Samples: %u, Length: %u\n", SamplesPerFrame, m_Buffer.TotalLength()); + printf("Buffer pop failed!!! Samples: %u, Length: %u\n", SamplesPerFrame, m_Buffer.TotalLength()); return; } - // Frame Size - int16_t *pFrameSize = (int16_t *)(&aFinal[FinalSize]); - FinalSize += sizeof(int16_t); - Header.iDataLength += sizeof(int16_t); - *pFrameSize = sizeof(aFinal) - HeaderSize - sizeof(uint32_t) - FinalSize; - // Encode it! - int Ret = SKP_Silk_SDK_Encode(m_Silk_EncoderState, &m_Silk_EncoderControl, aBuffer, - SamplesPerFrame, &aFinal[FinalSize], pFrameSize); + unsigned char aFinal[PacketSize]; + size_t FinalSize = 0; - if(Ret) + FinalSize = celt_encode(m_pCodec, aBuffer, SamplesPerFrame, aFinal, sizeof(aFinal)); + + if(FinalSize <= 0) { - smutils->LogError(myself, "SKP_Silk_SDK_Encode returned %d\n", Ret); + smutils->LogError(myself, "Compress returned %d\n", FinalSize); return; } - FinalSize += *pFrameSize; - Header.iDataLength += *pFrameSize; - // Check for buffer underruns for(int Client = 0; Client < MAX_CLIENTS; Client++) { @@ -649,21 +547,14 @@ void CVoice::HandleVoiceData() pClient->m_LastLength = m_Buffer.CurrentLength(); } } + + SV_BroadcastVoiceData(pClient, FinalSize, aFinal); } - // Header - memcpy(aFinal, &Header, HeaderSize); - - // CRC32 - *(uint32_t *)(&aFinal[FinalSize]) = UTIL_CRC32(aFinal, FinalSize); - FinalSize += sizeof(uint32_t); - - SV_BroadcastVoiceData(pClient, FinalSize, aFinal); - if(m_AvailableTime < getTime()) m_AvailableTime = getTime(); - m_AvailableTime += (double)FramesAvailable * ((double)m_EncoderSettings.FrameSize_ms / 1000.0); + m_AvailableTime += (double)FramesAvailable * m_EncoderSettings.FrameTime; } void CVoice::SV_BroadcastVoiceData(IClient *pClient, int nBytes, unsigned char *pData) diff --git a/extension.h b/extension.h index 339023a..a864fdd 100644 --- a/extension.h +++ b/extension.h @@ -33,7 +33,7 @@ #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ #include "smsdk_ext.h" -#include +#include "celt_header.h" #include "ringbuffer.h" /** @@ -157,19 +157,16 @@ private: struct CEncoderSettings { - SKP_int InputSampleRate_kHz; - SKP_int OutputSampleRate_kHz; - SKP_int TargetBitRate_Kbps; - SKP_int PacketSize_ms; - SKP_int FrameSize_ms; - SKP_int PacketLoss_perc; - SKP_int Complexity; - SKP_int InBandFEC; - SKP_int DTX; + celt_int32 SampleRate_Hz; + celt_int32 TargetBitRate_Kbps; + celt_int32 FrameSize; + celt_int32 PacketSize; + celt_int32 Complexity; + double FrameTime; } m_EncoderSettings; - void *m_Silk_EncoderState; - SKP_SILK_SDK_EncControlStruct m_Silk_EncoderControl; + CELTMode *m_pMode; + CELTEncoder *m_pCodec; t_SV_BroadcastVoiceData m_SV_BroadcastVoiceData; diff --git a/silk/SKP_Silk_FLP_Win32_mt.lib b/silk/SKP_Silk_FLP_Win32_mt.lib deleted file mode 100644 index 31a0ef1..0000000 Binary files a/silk/SKP_Silk_FLP_Win32_mt.lib and /dev/null differ diff --git a/silk/SKP_Silk_SDK_API.h b/silk/SKP_Silk_SDK_API.h deleted file mode 100644 index aa911f2..0000000 --- a/silk/SKP_Silk_SDK_API.h +++ /dev/null @@ -1,152 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2012, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#ifndef SKP_SILK_SDK_API_H -#define SKP_SILK_SDK_API_H - -#include "SKP_Silk_control.h" -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_errors.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define SILK_MAX_FRAMES_PER_PACKET 5 - -/* Struct for TOC (Table of Contents) */ -typedef struct { - SKP_int framesInPacket; /* Number of 20 ms frames in packet */ - SKP_int fs_kHz; /* Sampling frequency in packet */ - SKP_int inbandLBRR; /* Does packet contain LBRR information */ - SKP_int corrupt; /* Packet is corrupt */ - SKP_int vadFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* VAD flag for each frame in packet */ - SKP_int sigtypeFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Signal type for each frame in packet */ -} SKP_Silk_TOC_struct; - -/****************************************/ -/* Encoder functions */ -/****************************************/ - -/***********************************************/ -/* Get size in bytes of the Silk encoder state */ -/***********************************************/ -SKP_int SKP_Silk_SDK_Get_Encoder_Size( - SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */ -); - -/*************************/ -/* Init or reset encoder */ -/*************************/ -SKP_int SKP_Silk_SDK_InitEncoder( - void *encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ -); - -/***************************************/ -/* Read control structure from encoder */ -/***************************************/ -SKP_int SKP_Silk_SDK_QueryEncoder( - const void *encState, /* I: State */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ -); - -/**************************/ -/* Encode frame with Silk */ -/**************************/ -SKP_int SKP_Silk_SDK_Encode( - void *encState, /* I/O: State */ - const SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */ - const SKP_int16 *samplesIn, /* I: Speech sample input vector */ - SKP_int nSamplesIn, /* I: Number of samples in input vector */ - SKP_uint8 *outData, /* O: Encoded output vector */ - SKP_int16 *nBytesOut /* I/O: Number of bytes in outData (input: Max bytes) */ -); - -/****************************************/ -/* Decoder functions */ -/****************************************/ - -/***********************************************/ -/* Get size in bytes of the Silk decoder state */ -/***********************************************/ -SKP_int SKP_Silk_SDK_Get_Decoder_Size( - SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */ -); - -/*************************/ -/* Init or Reset decoder */ -/*************************/ -SKP_int SKP_Silk_SDK_InitDecoder( - void *decState /* I/O: State */ -); - -/******************/ -/* Decode a frame */ -/******************/ -SKP_int SKP_Silk_SDK_Decode( - void* decState, /* I/O: State */ - SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */ - SKP_int lostFlag, /* I: 0: no loss, 1 loss */ - const SKP_uint8 *inData, /* I: Encoded input vector */ - const SKP_int nBytesIn, /* I: Number of input bytes */ - SKP_int16 *samplesOut, /* O: Decoded output speech vector */ - SKP_int16 *nSamplesOut /* I/O: Number of samples (vector/decoded) */ -); - -/***************************************************************/ -/* Find Low Bit Rate Redundancy (LBRR) information in a packet */ -/***************************************************************/ -void SKP_Silk_SDK_search_for_LBRR( - const SKP_uint8 *inData, /* I: Encoded input vector */ - const SKP_int nBytesIn, /* I: Number of input Bytes */ - SKP_int lost_offset, /* I: Offset from lost packet */ - SKP_uint8 *LBRRData, /* O: LBRR payload */ - SKP_int16 *nLBRRBytes /* O: Number of LBRR Bytes */ -); - -/**************************************/ -/* Get table of contents for a packet */ -/**************************************/ -void SKP_Silk_SDK_get_TOC( - const SKP_uint8 *inData, /* I: Encoded input vector */ - const SKP_int nBytesIn, /* I: Number of input bytes */ - SKP_Silk_TOC_struct *Silk_TOC /* O: Table of contents */ -); - -/**************************/ -/* Get the version number */ -/**************************/ -/* Return a pointer to string specifying the version */ -const char *SKP_Silk_SDK_get_version(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/silk/SKP_Silk_control.h b/silk/SKP_Silk_control.h deleted file mode 100644 index ee446aa..0000000 --- a/silk/SKP_Silk_control.h +++ /dev/null @@ -1,91 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2012, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#ifndef SKP_SILK_CONTROL_H -#define SKP_SILK_CONTROL_H - -#include "SKP_Silk_typedef.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/***********************************************/ -/* Structure for controlling encoder operation */ -/***********************************************/ -typedef struct { - /* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000 */ - SKP_int32 API_sampleRate; - - /* I: Maximum internal sampling rate in Hertz; 8000/12000/16000/24000 */ - SKP_int32 maxInternalSampleRate; - - /* I: Number of samples per packet; must be equivalent of 20, 40, 60, 80 or 100 ms */ - SKP_int packetSize; - - /* I: Bitrate during active speech in bits/second; internally limited */ - SKP_int32 bitRate; - - /* I: Uplink packet loss in percent (0-100) */ - SKP_int packetLossPercentage; - - /* I: Complexity mode; 0 is lowest; 1 is medium and 2 is highest complexity */ - SKP_int complexity; - - /* I: Flag to enable in-band Forward Error Correction (FEC); 0/1 */ - SKP_int useInBandFEC; - - /* I: Flag to enable discontinuous transmission (DTX); 0/1 */ - SKP_int useDTX; -} SKP_SILK_SDK_EncControlStruct; - -/**************************************************************************/ -/* Structure for controlling decoder operation and reading decoder status */ -/**************************************************************************/ -typedef struct { - /* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000 */ - SKP_int32 API_sampleRate; - - /* O: Number of samples per frame */ - SKP_int frameSize; - - /* O: Frames per packet 1, 2, 3, 4, 5 */ - SKP_int framesPerPacket; - - /* O: Flag to indicate that the decoder has remaining payloads internally */ - SKP_int moreInternalDecoderFrames; - - /* O: Distance between main payload and redundant payload in packets */ - SKP_int inBandFECOffset; -} SKP_SILK_SDK_DecControlStruct; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/silk/SKP_Silk_errors.h b/silk/SKP_Silk_errors.h deleted file mode 100644 index bcf1c2a..0000000 --- a/silk/SKP_Silk_errors.h +++ /dev/null @@ -1,89 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2012, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#ifndef SKP_SILK_ERRORS_H -#define SKP_SILK_ERRORS_H - -#ifdef __cplusplus -extern "C" -{ -#endif - -/******************/ -/* Error messages */ -/******************/ -#define SKP_SILK_NO_ERROR 0 - -/**************************/ -/* Encoder error messages */ -/**************************/ - -/* Input length is not a multiplum of 10 ms, or length is longer than the packet length */ -#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -1 - -/* Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */ -#define SKP_SILK_ENC_FS_NOT_SUPPORTED -2 - -/* Packet size not 20, 40, 60, 80 or 100 ms */ -#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -3 - -/* Allocated payload buffer too short */ -#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -4 - -/* Loss rate not between 0 and 100 percent */ -#define SKP_SILK_ENC_INVALID_LOSS_RATE -5 - -/* Complexity setting not valid, use 0, 1 or 2 */ -#define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -6 - -/* Inband FEC setting not valid, use 0 or 1 */ -#define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -7 - -/* DTX setting not valid, use 0 or 1 */ -#define SKP_SILK_ENC_INVALID_DTX_SETTING -8 - -/* Internal encoder error */ -#define SKP_SILK_ENC_INTERNAL_ERROR -9 - -/**************************/ -/* Decoder error messages */ -/**************************/ - -/* Output sampling frequency lower than internal decoded sampling frequency */ -#define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -10 - -/* Payload size exceeded the maximum allowed 1024 bytes */ -#define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -11 - -/* Payload has bit errors */ -#define SKP_SILK_DEC_PAYLOAD_ERROR -12 - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/silk/SKP_Silk_typedef.h b/silk/SKP_Silk_typedef.h deleted file mode 100644 index 6790897..0000000 --- a/silk/SKP_Silk_typedef.h +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2012, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#ifndef _SKP_SILK_API_TYPDEF_H_ -#define _SKP_SILK_API_TYPDEF_H_ - -#ifndef SKP_USE_DOUBLE_PRECISION_FLOATS -#define SKP_USE_DOUBLE_PRECISION_FLOATS 0 -#endif - -#include -#if defined( __GNUC__ ) -#include -#endif - -#define SKP_int int /* used for counters etc; at least 16 bits */ -#ifdef __GNUC__ -# define SKP_int64 int64_t -#else -# define SKP_int64 long long -#endif -#define SKP_int32 int -#define SKP_int16 short -#define SKP_int8 signed char - -#define SKP_uint unsigned int /* used for counters etc; at least 16 bits */ -#ifdef __GNUC__ -# define SKP_uint64 uint64_t -#else -# define SKP_uint64 unsigned long long -#endif -#define SKP_uint32 unsigned int -#define SKP_uint16 unsigned short -#define SKP_uint8 unsigned char - -#define SKP_int_ptr_size intptr_t - -#if SKP_USE_DOUBLE_PRECISION_FLOATS -# define SKP_float double -# define SKP_float_MAX DBL_MAX -#else -# define SKP_float float -# define SKP_float_MAX FLT_MAX -#endif - -#define SKP_INLINE static __inline - -#ifdef _WIN32 -# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y) -#else -# define SKP_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y) -#endif - -#define SKP_int64_MAX ((SKP_int64)0x7FFFFFFFFFFFFFFFLL) /* 2^63 - 1 */ -#define SKP_int64_MIN ((SKP_int64)0x8000000000000000LL) /* -2^63 */ -#define SKP_int32_MAX 0x7FFFFFFF /* 2^31 - 1 = 2147483647*/ -#define SKP_int32_MIN ((SKP_int32)0x80000000) /* -2^31 = -2147483648*/ -#define SKP_int16_MAX 0x7FFF /* 2^15 - 1 = 32767*/ -#define SKP_int16_MIN ((SKP_int16)0x8000) /* -2^15 = -32768*/ -#define SKP_int8_MAX 0x7F /* 2^7 - 1 = 127*/ -#define SKP_int8_MIN ((SKP_int8)0x80) /* -2^7 = -128*/ - -#define SKP_uint32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4294967295 */ -#define SKP_uint32_MIN 0x00000000 -#define SKP_uint16_MAX 0xFFFF /* 2^16 - 1 = 65535 */ -#define SKP_uint16_MIN 0x0000 -#define SKP_uint8_MAX 0xFF /* 2^8 - 1 = 255 */ -#define SKP_uint8_MIN 0x00 - -#define SKP_TRUE 1 -#define SKP_FALSE 0 - -/* assertions */ -#if (defined _WIN32 && !defined _WINCE && !defined(__GNUC__) && !defined(NO_ASSERTS)) -# ifndef SKP_assert -# include /* ASSERTE() */ -# define SKP_assert(COND) _ASSERTE(COND) -# endif -#else -# define SKP_assert(COND) -#endif - -#endif diff --git a/silk/libSKP_SILK_SDK.a b/silk/libSKP_SILK_SDK.a deleted file mode 100644 index cc72e94..0000000 Binary files a/silk/libSKP_SILK_SDK.a and /dev/null differ diff --git a/voice_packet.bt.txt b/voice_packet.bt.txt deleted file mode 100644 index 6738963..0000000 --- a/voice_packet.bt.txt +++ /dev/null @@ -1,68 +0,0 @@ -//-------------------------------------- -//--- 010 Editor v6.0.3 Binary Template -// -// File: -// Author: -// Revision: -// Purpose: -//-------------------------------------- - -// CClientAudio::DecompressVoice -local int64 crcLength = FileSize() - sizeof(uint32); - -uint64 steamId; - -FSeek(crcLength); -uint32 crc; - -local int64 crc_calc = Checksum(CHECKSUM_CRC32, 0, crcLength); -if (crc != crc_calc) { - Warning("CRC mismatch!"); - return; -} - -// CVoiceDecoder::ProcessVoicePayload -FSeek(sizeof(uint64)); - -while (FTell() < crcLength) { - char payloadType; - - switch (payloadType) { - default: - Warning("Unhandled payload!"); - return; - case 11: // Sample Rate - short sampleRate; - break; - case 10: // Unknown / Unused - char unk1; - char unk2; - break; - case 1: // Unknown Codec??? - case 2: // Speex Data (Unsupported) - case 3: // Uncompressed Data - case 4: // SILK Data - short dataLength; - char data[dataLength]; - break; - case 0: // Silence - short numSamples; - break; - } -} - -// CVoiceDecoder::AddIncomingData -FSeek(startof(data)); - -// VoiceEncoder_SILK::Decompress - -// chunkLength == -1 means ResetState - -while ((FTell() - startof(data)) < dataLength) { - struct Chunk { - short chunkLength; - if (chunkLength != -1) { - char chunk[chunkLength]; - } - } chunk; -}