MythTV  master
inlines.h
Go to the documentation of this file.
1 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
2 //
3 // Use, modification and distribution is allowed without limitation,
4 // warranty, or liability of any kind.
5 //
6 
7 #ifndef INLINES_H
8 #define INLINES_H
9 
10 #include "config.h"
11 
12 // *fast* convenience functions
13 
14 static inline void stereo16_from_stereopcm8(short *l,
15  short *r,
16  uchar *c,
17  long cnt)
18 {
19  while (cnt >= 4L) {
20  l[0] = c[0];
21  r[0] = c[1];
22  l[1] = c[2];
23  r[1] = c[3];
24  l[2] = c[4];
25  r[2] = c[5];
26  l[3] = c[6];
27  r[3] = c[7];
28  l += 4;
29  r += 4;
30  c += 8;
31  cnt -= 4L;
32  }
33 
34  if (cnt > 0L) {
35  l[0] = c[0];
36  r[0] = c[1];
37  if (cnt > 1L) {
38  l[1] = c[2];
39  r[1] = c[3];
40  if (cnt > 2L) {
41  l[2] = c[4];
42  r[2] = c[5];
43  }
44  }
45  }
46 }
47 
48 
49 static inline void stereo16_from_stereopcm16(short *l,
50  short *r,
51  short *s,
52  long cnt)
53 {
54  while (cnt >= 4L) {
55  l[0] = s[0];
56  r[0] = s[1];
57  l[1] = s[2];
58  r[1] = s[3];
59  l[2] = s[4];
60  r[2] = s[5];
61  l[3] = s[6];
62  r[3] = s[7];
63  l += 4;
64  r += 4;
65  s += 8;
66  cnt -= 4L;
67  }
68 
69  if (cnt > 0L) {
70  l[0] = s[0];
71  r[0] = s[1];
72  if (cnt > 1L) {
73  l[1] = s[2];
74  r[1] = s[3];
75  if (cnt > 2L) {
76  l[2] = s[4];
77  r[2] = s[5];
78  }
79  }
80  }
81 }
82 
83 
84 static inline void stereo16_from_stereopcm32(short *l,
85  short *r,
86  int *s,
87  long cnt)
88 {
89  while (cnt--) {
90  *l++ = (short)(*s++ >> 16);
91  *r++ = (short)(*s++ >> 16);
92  }
93 }
94 
95 
96 static inline void stereo16_from_stereopcmfloat(short *l,
97  short *r,
98  float *s,
99  long cnt)
100 {
101  while (cnt--) {
102  *l++ = (short)(*s++ * 32767.0F);
103  *r++ = (short)(*s++ * 32767.0F);
104  }
105 }
106 
107 
108 static inline void mono16_from_monopcm8(short *l,
109  uchar *c,
110  long cnt)
111 {
112  while (cnt >= 4L) {
113  l[0] = c[0];
114  l[1] = c[1];
115  l[2] = c[2];
116  l[3] = c[3];
117  l += 4;
118  c += 4;
119  cnt -= 4L;
120  }
121 
122  if (cnt > 0L) {
123  l[0] = c[0];
124  if (cnt > 1L) {
125  l[1] = c[1];
126  if (cnt > 2L) {
127  l[2] = c[2];
128  }
129  }
130  }
131 }
132 
133 
134 static inline void mono16_from_monopcm16(short *l,
135  short *s,
136  long cnt)
137 {
138  while (cnt >= 4L) {
139  l[0] = s[0];
140  l[1] = s[1];
141  l[2] = s[2];
142  l[3] = s[3];
143  l += 4;
144  s += 4;
145  cnt -= 4L;
146  }
147 
148  if (cnt > 0L) {
149  l[0] = s[0];
150  if (cnt > 1L) {
151  l[1] = s[1];
152  if (cnt > 2L) {
153  l[2] = s[2];
154  }
155  }
156  }
157 }
158 
159 
160 static inline void mono16_from_monopcm32(short *l,
161  int *s,
162  long cnt)
163 {
164  while (cnt--)
165  *l++ = (short)(*s++ >> 16);
166 }
167 
168 
169 static inline void mono16_from_monopcmfloat(short *l,
170  float *s,
171  long cnt)
172 {
173  while (cnt--)
174  *l++ = (short)(*s++ * 32767.0F);
175 }
176 
177 
178 #if FFTW3_SUPPORT
179 static inline void fast_short_set(short *p,
180  short v,
181  long c)
182 {
183  while (c >= 4L) {
184  p[0] = v;
185  p[1] = v;
186  p[2] = v;
187  p[3] = v;
188  p += 4;
189  c -= 4L;
190  }
191 
192  if (c > 0L) {
193  p[0] = v;
194  if (c > 1L) {
195  p[1] = v;
196  if (c > 2L) {
197  p[2] = v;
198  }
199  }
200  }
201 }
202 
203 
204 static inline void fast_real_set_from_short(fftw_real *d,
205  short *s,
206  long c)
207 {
208  while (c >= 4L) {
209  d[0] = fftw_real(s[0]);
210  d[1] = fftw_real(s[1]);
211  d[2] = fftw_real(s[2]);
212  d[3] = fftw_real(s[3]);
213  d += 4;
214  s += 4;
215  c -= 4L;
216  }
217 
218  if (c > 0L) {
219  d[0] = fftw_real(s[0]);
220  if (c > 1L) {
221  d[1] = fftw_real(s[1]);
222  if (c > 2L) {
223  d[2] = fftw_real(s[2]);
224  }
225  }
226  }
227 }
228 
229 static inline void fast_reals_set(fftw_real *p1,
230  fftw_real *p2,
231  fftw_real v,
232  long c)
233 {
234  while (c >= 4L) {
235  p1[0] = v;
236  p1[1] = v;
237  p1[2] = v;
238  p1[3] = v;
239  p2[0] = v;
240  p2[1] = v;
241  p2[2] = v;
242  p2[3] = v;
243  p1 += 4;
244  p2 += 4;
245  c -= 4L;
246  }
247 
248  if (c > 0L) {
249  p1[0] = v;
250  p2[0] = v;
251  if (c > 1L) {
252  p1[1] = v;
253  p2[1] = v;
254  if (c > 2L) {
255  p1[2] = v;
256  p2[2] = v;
257  }
258  }
259  }
260 }
261 #endif // FFTW3_SUPPORT
262 
263 #endif // INLINES_H
static void stereo16_from_stereopcm8(short *l, short *r, uchar *c, long cnt)
Definition: inlines.h:14
static void mono16_from_monopcm8(short *l, uchar *c, long cnt)
Definition: inlines.h:108
unsigned char r
Definition: ParseText.cpp:329
static void stereo16_from_stereopcm16(short *l, short *r, short *s, long cnt)
Definition: inlines.h:49
static const uint16_t * d
static void stereo16_from_stereopcmfloat(short *l, short *r, float *s, long cnt)
Definition: inlines.h:96
static void stereo16_from_stereopcm32(short *l, short *r, int *s, long cnt)
Definition: inlines.h:84
static void mono16_from_monopcm32(short *l, int *s, long cnt)
Definition: inlines.h:160
static guint32 * p2
Definition: goom_core.c:35
static void mono16_from_monopcmfloat(short *l, float *s, long cnt)
Definition: inlines.h:169
static void mono16_from_monopcm16(short *l, short *s, long cnt)
Definition: inlines.h:134
static guint32 * p1
Definition: goom_core.c:35