Commit 011402a2 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Merge commit 'silk-repo/master'

parents 93839b63 7d50a792
/***********************************************************************
Copyright (c) 2006-2011, 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"
#include "entenc.h"
#include "entdec.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define SILK_MAX_FRAMES_PER_PACKET 3
/* Struct for TOC (Table of Contents) */
typedef struct {
SKP_int VADFlag; /* Voice activity for packet */
SKP_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */
SKP_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */
} SKP_Silk_TOC_struct;
/****************************************/
/* Encoder functions */
/****************************************/
/***********************************************/
/* Get size in bytes of the Silk encoder state */
/***********************************************/
SKP_int SKP_Silk_SDK_Get_Encoder_Size( /* O: Returns error code */
SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
);
/*************************/
/* Init or reset encoder */
/*************************/
SKP_int SKP_Silk_SDK_InitEncoder( /* O: Returns error code */
void *encState, /* I/O: State */
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
);
/***************************************/
/* Read control structure from encoder */
/***************************************/
SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error code */
const void *encState, /* I: State */
SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */
);
/**************************/
/* Encode frame with Silk */
/**************************/
/* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */
/* encControl->payloadSize_ms is set to */
SKP_int SKP_Silk_SDK_Encode( /* O: Returns error code */
void *encState, /* I/O: State */
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 */
ec_enc *psRangeEnc, /* I/O Compressor data structure */
SKP_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
);
/****************************************/
/* Decoder functions */
/****************************************/
/***********************************************/
/* Get size in bytes of the Silk decoder state */
/***********************************************/
SKP_int SKP_Silk_SDK_Get_Decoder_Size( /* O: Returns error code */
SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
);
/*************************/
/* Init or Reset decoder */
/*************************/
SKP_int SKP_Silk_SDK_InitDecoder( /* O: Returns error code */
void *decState /* I/O: State */
);
/******************/
/* Decode a frame */
/******************/
SKP_int SKP_Silk_SDK_Decode( /* O: Returns error code */
void* decState, /* I/O: State */
SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */
SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */
SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */
ec_dec *psRangeDec, /* I/O Compressor data structure */
SKP_int16 *samplesOut, /* O: Decoded output speech vector */
SKP_int32 *nSamplesOut /* O: Number of samples 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_int16 nBytesIn, /* I: Number of input bytes */
SKP_int lost_offset, /* I: Offset from lost packet */
SKP_uint8 *LBRRData, /* O: LBRR payload */
SKP_int32 *nLBRRBytes /* O: Number of LBRR Bytes */
);
/**************************************/
/* Get table of contents for a packet */
/**************************************/
SKP_int SKP_Silk_SDK_get_TOC(
const SKP_uint8 *payload, /* I Payload data */
const SKP_int nBytesIn, /* I: Number of input bytes */
const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */
SKP_Silk_TOC_struct *Silk_TOC /* O: Type of content */
);
#ifdef __cplusplus
}
#endif
#endif
/***********************************************************************
Copyright (c) 2006-2011, 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
/* Decoder API flags */
#define FLAG_DECODE_NORMAL 0
#define FLAG_PACKET_LOST 1
#define FLAG_DECODE_LBRR 2
/***********************************************/
/* Structure for controlling encoder operation */
/***********************************************/
typedef struct {
/* I: Number of channels; 1/2 */
SKP_int32 nChannels;
/* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
SKP_int32 API_sampleRate;
/* I: Maximum internal sampling rate in Hertz; 8000/12000/16000 */
SKP_int32 maxInternalSampleRate;
/* I: Minimum internal sampling rate in Hertz; 8000/12000/16000 */
SKP_int32 minInternalSampleRate;
/* I: Soft request for internal sampling rate in Hertz; 8000/12000/16000 */
SKP_int32 desiredInternalSampleRate;
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
SKP_int payloadSize_ms;
/* 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, 10 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;
/* I: Flag to use constant bitrate */
SKP_int useCBR;
/* O: Internal sampling rate used, in Hertz; 8000/12000/16000 */
SKP_int32 internalSampleRate;
/* O: Flag that bandwidth switching is allowed (because low voice activity) */
SKP_int allowBandwidthSwitch;
/* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */
SKP_int inWBmodeWithoutVariableLP;
} SKP_SILK_SDK_EncControlStruct;
/**************************************************************************/
/* Structure for controlling decoder operation and reading decoder status */
/**************************************************************************/
typedef struct {
/* I: Number of channels; 1/2 */
SKP_int32 nChannels;
/* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */
SKP_int32 API_sampleRate;
/* I: Number of samples per packet in milliseconds; 10/20/40/60 */
SKP_int payloadSize_ms;
/* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */
SKP_int32 internalSampleRate;
/* O: Number of samples per frame */
SKP_int frameSize;
/* O: Frames per payload 1, 2, 3 */
SKP_int framesPerPayload;
} SKP_SILK_SDK_DecControlStruct;
#ifdef __cplusplus
}
#endif
#endif
/***********************************************************************
Copyright (c) 2006-2011, 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 multiple of 10 ms, or length is longer than the packet length */
#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101
/* Sampling frequency not 8000, 12000 or 16000 Hertz */
#define SKP_SILK_ENC_FS_NOT_SUPPORTED -102
/* Packet size not 10, 20, 40, or 60 ms */
#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103
/* Allocated payload buffer too short */
#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -104
/* Loss rate not between 0 and 100 percent */
#define SKP_SILK_ENC_INVALID_LOSS_RATE -105
/* Complexity setting not valid, use 0...10 */
#define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -106
/* Inband FEC setting not valid, use 0 or 1 */
#define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -107
/* DTX setting not valid, use 0 or 1 */
#define SKP_SILK_ENC_INVALID_DTX_SETTING -108
/* CBR setting not valid, use 0 or 1 */
#define SKP_SILK_ENC_INVALID_CBR_SETTING -109
/* Internal encoder error */
#define SKP_SILK_ENC_INTERNAL_ERROR -110
/* Internal encoder error */
#define SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR -111
/**************************/
/* Decoder error messages */
/**************************/
/* Output sampling frequency lower than internal decoded sampling frequency */
#define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -200
/* Payload size exceeded the maximum allowed 1024 bytes */
#define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -201
/* Payload has bit errors */
#define SKP_SILK_DEC_PAYLOAD_ERROR -202
/* Payload has bit errors */
#define SKP_SILK_DEC_INVALID_FRAME_SIZE -203
#ifdef __cplusplus
}
#endif
#endif
/***********************************************************************
Copyright (c) 2006-2011, 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 <float.h>
#if defined( __GNUC__ )
#include <stdint.h>
#endif
#define SKP_int int /* used for counters etc; at least 16 bits */
#define SKP_int64 long long
#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 */
#define SKP_uint64 unsigned long long
#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 <crtdbg.h> /* ASSERTE() */
# define SKP_assert(COND) _ASSERTE(COND)
# endif
#else
# define SKP_assert(COND)
#endif
#endif
/***********************************************************************
Copyright (c) 2006-2011, 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_DEBUG_H_
#define _SKP_DEBUG_H_
#ifdef _WIN32
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#include "SKP_Silk_typedef.h"
#include <stdio.h> /* file writing */
#include <string.h> /* strcpy, strcmp */
#ifdef __cplusplus
extern "C"
{
#endif
unsigned long GetHighResolutionTime(void); /* O: time in usec*/
/* make SKP_DEBUG dependent on compiler's _DEBUG */
#if defined _WIN32
#ifdef _DEBUG
#define SKP_DEBUG 1
#else
#define SKP_DEBUG 0
#endif
/* overrule the above */
#if 0
// #define NO_ASSERTS
#undef SKP_DEBUG
#define SKP_DEBUG 1
#endif
#else
#define SKP_DEBUG 0
#endif
/* Flag for using timers */
#define SKP_TIC_TOC 0
#if SKP_TIC_TOC
#if (defined(_WIN32) || defined(_WINCE))
#include <windows.h> /* timer */
#pragma warning( disable : 4996 ) // stop bitching about strcpy in TIC()
#else // Linux or Mac
#include <sys/time.h>
#endif
/*********************************/
/* timer functions for profiling */
/*********************************/
/* example: */
/* */
/* TIC(LPC) */
/* do_LPC(in_vec, order, acoef); // do LPC analysis */
/* TOC(LPC) */
/* */
/* and call the following just before exiting (from main) */
/* */
/* SKP_TimerSave("SKP_TimingData.txt"); */
/* */
/* results are now in SKP_TimingData.txt */
void SKP_TimerSave(char *file_name);
/* max number of timers (in different locations) */
#define SKP_NUM_TIMERS_MAX 50
/* max length of name tags in TIC(..), TOC(..) */
#define SKP_NUM_TIMERS_MAX_TAG_LEN 30
extern int SKP_Timer_nTimers;
extern int SKP_Timer_depth_ctr;
extern char SKP_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN];
#ifdef _WIN32
extern LARGE_INTEGER SKP_Timer_start[SKP_NUM_TIMERS_MAX];
#else
extern unsigned long SKP_Timer_start[SKP_NUM_TIMERS_MAX];
#endif
extern unsigned int SKP_Timer_cnt[SKP_NUM_TIMERS_MAX];
extern SKP_int64 SKP_Timer_sum[SKP_NUM_TIMERS_MAX];
extern SKP_int64 SKP_Timer_max[SKP_NUM_TIMERS_MAX];
extern SKP_int64 SKP_Timer_min[SKP_NUM_TIMERS_MAX];
extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX];
/* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */
#ifdef _WIN32
#define TIC(TAG_NAME) { \
static int init = 0; \
static int ID = -1; \
if( init == 0 ) \
{ \
int k; \
init = 1; \
for( k = 0; k < SKP_Timer_nTimers; k++ ) { \
if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
if (ID == -1) { \
ID = SKP_Timer_nTimers; \
SKP_Timer_nTimers++; \
SKP_Timer_depth[ID] = SKP_Timer_depth_ctr; \
strcpy(SKP_Timer_tags[ID], #TAG_NAME); \
SKP_Timer_cnt[ID] = 0; \
SKP_Timer_sum[ID] = 0; \
SKP_Timer_min[ID] = 0xFFFFFFFF; \
SKP_Timer_max[ID] = 0; \
} \
} \
SKP_Timer_depth_ctr++; \
QueryPerformanceCounter(&SKP_Timer_start[ID]); \
}
#else
#define TIC(TAG_NAME) { \
static int init = 0; \
static int ID = -1; \
if( init == 0 ) \
{ \
int k; \
init = 1; \
for( k = 0; k < SKP_Timer_nTimers; k++ ) { \
if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \
ID = k; \
break; \
} \
} \
if (ID == -1) { \
ID = SKP_Timer_nTimers; \
SKP_Timer_nTimers++; \
SKP_Timer_depth[ID] = SKP_Timer_depth_ctr; \
strcpy(SKP_Timer_tags[ID], #TAG_NAME); \
SKP_Timer_cnt[ID] = 0; \