00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #if !defined(_SPANDSP_TELEPHONY_H_)
00027 #define _SPANDSP_TELEPHONY_H_
00028
00029 #if defined(_M_IX86) || defined(_M_X64)
00030 #if defined(LIBSPANDSP_EXPORTS)
00031 #define SPAN_DECLARE(type) __declspec(dllexport) type __stdcall
00032 #define SPAN_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
00033 #define SPAN_DECLARE_DATA __declspec(dllexport)
00034 #else
00035 #define SPAN_DECLARE(type) __declspec(dllimport) type __stdcall
00036 #define SPAN_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
00037 #define SPAN_DECLARE_DATA __declspec(dllimport)
00038 #endif
00039 #elif defined(SPANDSP_USE_EXPORT_CAPABILITY) && (defined(__GNUC__) || defined(__SUNCC__))
00040 #define SPAN_DECLARE(type) __attribute__((visibility("default"))) type
00041 #define SPAN_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
00042 #define SPAN_DECLARE_DATA __attribute__((visibility("default")))
00043 #else
00044 #define SPAN_DECLARE(type) type
00045 #define SPAN_DECLARE_NONSTD(type) type
00046 #define SPAN_DECLARE_DATA
00047 #endif
00048
00049 #define SAMPLE_RATE 8000
00050
00051
00052 #define DBM0_MAX_POWER (3.14f + 3.02f)
00053 #define DBM0_MAX_SINE_POWER (3.14f)
00054
00055 #define DBOV_MAX_POWER (0.0f)
00056 #define DBOV_MAX_SINE_POWER (-3.02f)
00057
00058
00059 typedef int (*span_rx_handler_t)(void *s, const int16_t amp[], int len);
00060
00061
00062 typedef int (*span_mod_handler_t)(void *s, int16_t amp[], int len);
00063
00064
00065 typedef int (*span_rx_fillin_handler_t)(void *s, int len);
00066
00067
00068 typedef int (*span_tx_handler_t)(void *s, int16_t amp[], int max_len);
00069
00070 #define ms_to_samples(t) ((t)*(SAMPLE_RATE/1000))
00071 #define us_to_samples(t) ((t)/(1000000/SAMPLE_RATE))
00072
00073 #if !defined(FALSE)
00074 #define FALSE 0
00075 #endif
00076 #if !defined(TRUE)
00077 #define TRUE (!FALSE)
00078 #endif
00079
00080
00081 #define FP_Q_9_7(x) ((int16_t) (128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00082 #define FP_Q_8_8(x) ((int16_t) (256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00083 #define FP_Q_7_9(x) ((int16_t) (512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00084 #define FP_Q_6_10(x) ((int16_t) (1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00085 #define FP_Q_5_11(x) ((int16_t) (2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00086 #define FP_Q_4_12(x) ((int16_t) (4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00087 #define FP_Q_3_13(x) ((int16_t) (8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00088 #define FP_Q_2_14(x) ((int16_t) (16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00089 #define FP_Q_1_15(x) ((int16_t) (32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00090
00091 #define FP_Q_9_23(x) ((int32_t) (65536.0*128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00092 #define FP_Q_8_24(x) ((int32_t) (65536.0*256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00093 #define FP_Q_7_25(x) ((int32_t) (65536.0*512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00094 #define FP_Q_6_26(x) ((int32_t) (65536.0*1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00095 #define FP_Q_5_27(x) ((int32_t) (65536.0*2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00096 #define FP_Q_4_28(x) ((int32_t) (65536.0*4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00097 #define FP_Q_3_29(x) ((int32_t) (65536.0*8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00098 #define FP_Q_2_30(x) ((int32_t) (65536.0*16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00099 #define FP_Q_1_31(x) ((int32_t) (65536.0*32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
00100
00101 #if defined(__cplusplus)
00102
00103 #if !defined(WIN32)
00104 #define lrint(x) ((long int) (x))
00105 #define lrintf(x) ((long int) (x))
00106 #endif
00107 #endif
00108
00109 #endif
00110