ReactOS  0.4.14-dev-342-gdc047f9
common.h
Go to the documentation of this file.
1 /*
2 ** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
3 ** All rights reserved.
4 **
5 ** This code is released under 2-clause BSD license. Please see the
6 ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
7 */
8 
9 #ifndef COMMON_H_INCLUDED
10 #define COMMON_H_INCLUDED
11 
12 #ifdef HAVE_STDINT_H
13 #include <stdint.h>
14 #elif (SIZEOF_INT == 4)
15 typedef int int32_t ;
16 #elif (SIZEOF_LONG == 4)
17 typedef long int32_t ;
18 #endif
19 
20 #define SRC_MAX_RATIO 256
21 #define SRC_MAX_RATIO_STR "256"
22 
23 #define SRC_MIN_RATIO_DIFF (1e-20)
24 
25 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
26 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
27 
28 #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
29 #define OFFSETOF(type,member) ((int) (&((type*) 0)->member))
30 
31 #define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
32 
33 /*
34 ** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html
35 */
36 #ifdef UNUSED
37 #elif defined (__GNUC__)
38 # define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
39 #elif defined (__LCLINT__)
40 # define UNUSED(x) /*@unused@*/ x
41 #else
42 # define UNUSED(x) x
43 #endif
44 
45 #ifdef __GNUC__
46 # define WARN_UNUSED __attribute__ ((warn_unused_result))
47 #else
48 # define WARN_UNUSED
49 #endif
50 
51 
52 #include "samplerate.h"
53 
54 enum
55 { SRC_FALSE = 0,
56  SRC_TRUE = 1,
57 
60 } ;
61 
62 enum
64 
87 
88  /* This must be the last error number. */
90 } ;
91 
92 typedef struct SRC_PRIVATE_tag
94 
95  int error ;
96  int channels ;
97 
98  /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
99  int mode ;
100 
101  /* Pointer to data to converter specific data. */
102  void *private_data ;
103 
104  /* Varispeed process function. */
106 
107  /* Constant speed process function. */
109 
110  /* State reset. */
111  void (*reset) (struct SRC_PRIVATE_tag *psrc) ;
112 
113  /* Data specific to SRC_MODE_CALLBACK. */
117  const float *saved_data ;
118 } SRC_PRIVATE ;
119 
120 /* In src_sinc.c */
121 const char* sinc_get_name (int src_enum) ;
122 const char* sinc_get_description (int src_enum) ;
123 
124 int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
125 
126 /* In src_linear.c */
127 const char* linear_get_name (int src_enum) ;
128 const char* linear_get_description (int src_enum) ;
129 
130 int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
131 
132 /* In src_zoh.c */
133 const char* zoh_get_name (int src_enum) ;
134 const char* zoh_get_description (int src_enum) ;
135 
136 int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
137 
138 /*----------------------------------------------------------
139 ** Common static inline functions.
140 */
141 
142 static inline double
143 fmod_one (double x)
144 { double res ;
145 
146  res = x - lrint (x) ;
147  if (res < 0.0)
148  return res + 1.0 ;
149 
150  return res ;
151 } /* fmod_one */
152 
153 static inline int
154 is_bad_src_ratio (double ratio)
155 { return (ratio < (1.0 / SRC_MAX_RATIO) || ratio > (1.0 * SRC_MAX_RATIO)) ;
156 } /* is_bad_src_ratio */
157 
158 
159 #endif /* COMMON_H_INCLUDED */
160 
struct SRC_PRIVATE_tag SRC_PRIVATE
int sinc_set_converter(SRC_PRIVATE *psrc, int src_enum)
Definition: src_sinc.c:133
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define int32_t
Definition: nsiface.idl:56
int zoh_set_converter(SRC_PRIVATE *psrc, int src_enum)
Definition: src_zoh.c:146
const char * linear_get_description(int src_enum)
Definition: src_linear.c:146
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static double fmod_one(double x)
Definition: common.h:143
_Check_return_ __CRT_INLINE long lrint(_In_ double x)
Definition: math.h:267
int(* vari_process)(struct SRC_PRIVATE_tag *psrc, SRC_DATA *data)
Definition: common.h:105
#define SRC_MAX_RATIO
Definition: common.h:20
const char * sinc_get_description(int src_enum)
Definition: src_sinc.c:113
src_callback_t callback_func
Definition: common.h:114
double last_ratio
Definition: common.h:93
const char * linear_get_name(int src_enum)
Definition: src_linear.c:137
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const char * zoh_get_description(int src_enum)
Definition: src_zoh.c:137
double last_position
Definition: common.h:93
void * user_callback_data
Definition: common.h:115
const char * zoh_get_name(int src_enum)
Definition: src_zoh.c:128
const char * sinc_get_name(int src_enum)
Definition: src_sinc.c:94
int(* const_process)(struct SRC_PRIVATE_tag *psrc, SRC_DATA *data)
Definition: common.h:108
GLboolean reset
Definition: glext.h:5666
long saved_frames
Definition: common.h:116
int channels
Definition: common.h:96
int linear_set_converter(SRC_PRIVATE *psrc, int src_enum)
Definition: src_linear.c:155
GLuint res
Definition: glext.h:9613
const float * saved_data
Definition: common.h:117
long(* src_callback_t)(void *cb_data, float **data)
Definition: samplerate.h:47
void * private_data
Definition: common.h:102
static int is_bad_src_ratio(double ratio)
Definition: common.h:154
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31