ReactOS  0.4.14-dev-606-g14ebc0b
dsound_convert.c File Reference
#include "dsound_private.h"
Include dependency graph for dsound_convert.c:

Go to the source code of this file.

Macros

#define le16(x)   (x)
 
#define le32(x)   (x)
 

Functions

static void src_advance (const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
 
static void convert_8_to_8 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_8_to_16 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_8_to_24 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_8_to_32 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_16_to_8 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_16_to_16 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_16_to_24 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_16_to_32 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_24_to_8 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_24_to_16 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_24_to_24 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_24_to_32 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_32_to_8 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_32_to_16 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_32_to_24 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_32_to_32 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_ieee_32_to_8 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_ieee_32_to_16 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_ieee_32_to_24 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void convert_ieee_32_to_32 (const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
 
static void mix8 (signed char *src, INT *dst, unsigned len)
 
static void mix16 (SHORT *src, INT *dst, unsigned len)
 
static void mix24 (BYTE *src, INT *dst, unsigned len)
 
static void mix32 (INT *src, LONGLONG *dst, unsigned len)
 
static void norm8 (INT *src, signed char *dst, unsigned len)
 
static void norm16 (INT *src, SHORT *dst, unsigned len)
 
static void norm24 (INT *src, BYTE *dst, unsigned len)
 
static void norm32 (LONGLONG *src, INT *dst, unsigned len)
 

Variables

const bitsconvertfunc convertbpp [5][4]
 
const mixfunc mixfunctions [4]
 
const normfunc normfunctions [4]
 

Macro Definition Documentation

◆ le16

#define le16 (   x)    (x)

Definition at line 43 of file dsound_convert.c.

◆ le32

#define le32 (   x)    (x)

Definition at line 44 of file dsound_convert.c.

Function Documentation

◆ convert_16_to_16()

static void convert_16_to_16 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 127 of file dsound_convert.c.

129 {
130  while (count > 0)
131  {
132  *(WORD *)dst = *(const WORD *)src;
133 
134  dst = (char *)dst + dst_stride;
135  src_advance(&src, src_stride, &count, &freqAcc, adj);
136  }
137 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_16_to_24()

static void convert_16_to_24 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 139 of file dsound_convert.c.

141 {
142  while (count > 0)
143  {
144  WORD dest = le16(*(const WORD *)src);
145  BYTE *dest24 = dst;
146 
147  dest24[0] = dest / 256;
148  dest24[1] = dest;
149  dest24[2] = dest / 256;
150 
151  dst = (char *)dst + dst_stride;
152  src_advance(&src, src_stride, &count, &freqAcc, adj);
153  }
154 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ convert_16_to_32()

static void convert_16_to_32 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 156 of file dsound_convert.c.

158 {
159  while (count > 0)
160  {
161  DWORD dest = *(const WORD *)src, *dest32 = dst;
162  *dest32 = dest * 65537;
163 
164  dst = (char *)dst + dst_stride;
165  src_advance(&src, src_stride, &count, &freqAcc, adj);
166  }
167 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ convert_16_to_8()

static void convert_16_to_8 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 113 of file dsound_convert.c.

115 {
116  while (count > 0)
117  {
118  BYTE *dst8 = dst;
119  *dst8 = (le16(*(const WORD *)src)) / 256;
120  *dst8 -= 0x80;
121 
122  dst = (char *)dst + dst_stride;
123  src_advance(&src, src_stride, &count, &freqAcc, adj);
124  }
125 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_24_to_16()

static void convert_24_to_16 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 182 of file dsound_convert.c.

184 {
185  while (count > 0)
186  {
187  WORD *dest16 = dst;
188  const BYTE *source = src;
189  *dest16 = le16(source[2] * 256 + source[1]);
190 
191  dst = (char *)dst + dst_stride;
192  src_advance(&src, src_stride, &count, &freqAcc, adj);
193  }
194 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_24_to_24()

static void convert_24_to_24 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 196 of file dsound_convert.c.

198 {
199  while (count > 0)
200  {
201  BYTE *dest24 = dst;
202  const BYTE *src24 = src;
203 
204  dest24[0] = src24[0];
205  dest24[1] = src24[1];
206  dest24[2] = src24[2];
207 
208  dst = (char *)dst + dst_stride;
209  src_advance(&src, src_stride, &count, &freqAcc, adj);
210  }
211 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_24_to_32()

static void convert_24_to_32 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 213 of file dsound_convert.c.

215 {
216  while (count > 0)
217  {
218  DWORD *dest32 = dst;
219  const BYTE *source = src;
220  *dest32 = le32(source[2] * 16777217 + source[1] * 65536 + source[0] * 256);
221 
222  dst = (char *)dst + dst_stride;
223  src_advance(&src, src_stride, &count, &freqAcc, adj);
224  }
225 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ convert_24_to_8()

static void convert_24_to_8 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 169 of file dsound_convert.c.

171 {
172  while (count > 0)
173  {
174  BYTE *dst8 = dst;
175  *dst8 = ((const BYTE *)src)[2];
176 
177  dst = (char *)dst + dst_stride;
178  src_advance(&src, src_stride, &count, &freqAcc, adj);
179  }
180 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_32_to_16()

static void convert_32_to_16 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 241 of file dsound_convert.c.

243 {
244  while (count > 0)
245  {
246  WORD *dest16 = dst;
247  *dest16 = le16(le32(*(const DWORD *)src) / 65536);
248 
249  dst = (char *)dst + dst_stride;
250  src_advance(&src, src_stride, &count, &freqAcc, adj);
251  }
252 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ convert_32_to_24()

static void convert_32_to_24 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 254 of file dsound_convert.c.

256 {
257  while (count > 0)
258  {
259  DWORD dest = le32(*(const DWORD *)src);
260  BYTE *dest24 = dst;
261 
262  dest24[0] = dest / 256;
263  dest24[1] = dest / 65536;
264  dest24[2] = dest / 16777216;
265 
266  dst = (char *)dst + dst_stride;
267  src_advance(&src, src_stride, &count, &freqAcc, adj);
268  }
269 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
#define le32(x)

◆ convert_32_to_32()

static void convert_32_to_32 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 271 of file dsound_convert.c.

273 {
274  while (count > 0)
275  {
276  DWORD *dest = dst;
277  *dest = *(const DWORD *)src;
278 
279  dst = (char *)dst + dst_stride;
280  src_advance(&src, src_stride, &count, &freqAcc, adj);
281  }
282 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ convert_32_to_8()

static void convert_32_to_8 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 227 of file dsound_convert.c.

229 {
230  while (count > 0)
231  {
232  BYTE *dst8 = dst;
233  *dst8 = (le32(*(const DWORD *)src) / 16777216);
234  *dst8 -= 0x80;
235 
236  dst = (char *)dst + dst_stride;
237  src_advance(&src, src_stride, &count, &freqAcc, adj);
238  }
239 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ convert_8_to_16()

static void convert_8_to_16 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 71 of file dsound_convert.c.

73 {
74  while (count > 0)
75  {
76  WORD dest = *(const BYTE *)src, *dest16 = dst;
77  *dest16 = le16(dest * 257 - 32768);
78 
79  dst = (char *)dst + dst_stride;
80  src_advance(&src, src_stride, &count, &freqAcc, adj);
81  }
82 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ convert_8_to_24()

static void convert_8_to_24 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 84 of file dsound_convert.c.

86 {
87  while (count > 0)
88  {
89  BYTE dest = *(const BYTE *)src;
90  BYTE *dest24 = dst;
91  dest24[0] = dest;
92  dest24[1] = dest;
93  dest24[2] = dest - 0x80;
94 
95  dst = (char *)dst + dst_stride;
96  src_advance(&src, src_stride, &count, &freqAcc, adj);
97  }
98 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ convert_8_to_32()

static void convert_8_to_32 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 100 of file dsound_convert.c.

102 {
103  while (count > 0)
104  {
105  DWORD dest = *(const BYTE *)src, *dest32 = dst;
106  *dest32 = le32(dest * 16843009 - 2147483648U);
107 
108  dst = (char *)dst + dst_stride;
109  src_advance(&src, src_stride, &count, &freqAcc, adj);
110  }
111 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define U(x)
Definition: wordpad.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
#define le32(x)

◆ convert_8_to_8()

static void convert_8_to_8 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 59 of file dsound_convert.c.

61 {
62  while (count > 0)
63  {
64  *(BYTE *)dst = *(const BYTE *)src;
65 
66  dst = (char *)dst + dst_stride;
67  src_advance(&src, src_stride, &count, &freqAcc, adj);
68  }
69 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ convert_ieee_32_to_16()

static void convert_ieee_32_to_16 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 307 of file dsound_convert.c.

309 {
310  while (count > 0)
311  {
312  DWORD src_le = le32(*(DWORD *) src);
313  float v = *((float *) &src_le);
314 
315  INT16 *d = (INT16 *) dst;
316 
317  if (v < -1.0f)
318  *d = -32768;
319  else if (v > 1.0f)
320  *d = 32767;
321  else
322  *d = v * 32767.5f - 0.5f;
323 
324  *d = le16(*d);
325 
326  dst = (char *)dst + dst_stride;
327  src_advance(&src, src_stride, &count, &freqAcc, adj);
328  }
329 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
#define le16(x)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
const GLdouble * v
Definition: gl.h:2040
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)
signed short INT16

◆ convert_ieee_32_to_24()

static void convert_ieee_32_to_24 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 331 of file dsound_convert.c.

333 {
334  while (count > 0)
335  {
336  DWORD src_le = le32(*(DWORD *) src);
337  float v = *((float *) &src_le);
338  BYTE *dest24 = dst;
339 
340  if (v < -1.0f)
341  {
342  dest24[0] = 0;
343  dest24[1] = 0;
344  dest24[2] = 0x80;
345  }
346  else if (v > 1.0f)
347  {
348  dest24[0] = 0xff;
349  dest24[1] = 0xff;
350  dest24[2] = 0x7f;
351  }
352  else if (v < 0.0f)
353  {
354  dest24[0] = v * 8388608.0f;
355  dest24[1] = v * 32768.0f;
356  dest24[2] = v * 128.0f;
357  }
358  else if (v >= 0.0f)
359  {
360  dest24[0] = v * 8388608.0f;
361  dest24[1] = v * 32768.0f;
362  dest24[2] = v * 127.0f;
363  }
364 
365  dst = (char *)dst + dst_stride;
366  src_advance(&src, src_stride, &count, &freqAcc, adj);
367  }
368 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
const GLdouble * v
Definition: gl.h:2040
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ convert_ieee_32_to_32()

static void convert_ieee_32_to_32 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 370 of file dsound_convert.c.

372 {
373  while (count > 0)
374  {
375  DWORD src_le = le32(*(DWORD *) src);
376  float v = *((float *) &src_le);
377  INT32 *d = (INT32 *) dst;
378 
379  if (v < -1.0f)
380  *d = -2147483647 - 1; /* silence warning */
381  else if (v > 1.0f)
382  *d = 2147483647;
383  else
384  *d = v * 2147483647.5f - 0.5f;
385 
386  *d = le32(*d);
387 
388  dst = (char *)dst + dst_stride;
389  src_advance(&src, src_stride, &count, &freqAcc, adj);
390  }
391 }
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
const GLdouble * v
Definition: gl.h:2040
GLenum GLenum dst
Definition: glext.h:6340
signed int INT32
#define le32(x)

◆ convert_ieee_32_to_8()

static void convert_ieee_32_to_8 ( const void src,
void dst,
UINT  src_stride,
UINT  dst_stride,
INT  count,
UINT  freqAcc,
UINT  adj 
)
static

Definition at line 284 of file dsound_convert.c.

286 {
287  while (count > 0)
288  {
289  DWORD src_le = le32(*(DWORD *) src);
290  float v = *((float *) &src_le);
291  INT8 d = 0;
292 
293  if (v < -1.0f)
294  d = -128;
295  else if (v > 1.0f)
296  d = 127;
297  else
298  d = v * 127.5f - 0.5f;
299 
300  *(BYTE *) dst = d ^ 0x80;
301 
302  dst = (char *)dst + dst_stride;
303  src_advance(&src, src_stride, &count, &freqAcc, adj);
304  }
305 }
signed char INT8
static void src_advance(const void **src, UINT stride, INT *count, UINT *freqAcc, UINT adj)
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
const GLdouble * v
Definition: gl.h:2040
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ mix16()

static void mix16 ( SHORT src,
INT dst,
unsigned  len 
)
static

Definition at line 409 of file dsound_convert.c.

410 {
411  TRACE("%p - %p %d\n", src, dst, len);
412  len /= 2;
413  while (len--)
414  {
415  *dst += le16(*src);
416  ++dst; ++src;
417  }
418 }
#define le16(x)
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ mix24()

static void mix24 ( BYTE src,
INT dst,
unsigned  len 
)
static

Definition at line 420 of file dsound_convert.c.

421 {
422  TRACE("%p - %p %d\n", src, dst, len);
423  len /= 3;
424  while (len--)
425  {
426  DWORD field;
427  field = ((DWORD)src[2] << 16) + ((DWORD)src[1] << 8) + (DWORD)src[0];
428  if (src[2] & 0x80)
429  field |= 0xFF000000U;
430  *(dst++) += field;
431  ++src;
432  }
433 }
#define U(x)
Definition: wordpad.c:44
#define DWORD
Definition: nt_native.h:44
#define TRACE(s)
Definition: solgame.cpp:4
Definition: parser.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ mix32()

static void mix32 ( INT src,
LONGLONG dst,
unsigned  len 
)
static

Definition at line 435 of file dsound_convert.c.

436 {
437  TRACE("%p - %p %d\n", src, dst, len);
438  len /= 4;
439  while (len--)
440  *(dst++) += le32(*(src++));
441 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ mix8()

static void mix8 ( signed char src,
INT dst,
unsigned  len 
)
static

Definition at line 401 of file dsound_convert.c.

402 {
403  TRACE("%p - %p %d\n", src, dst, len);
404  while (len--)
405  /* 8-bit WAV is unsigned, it's here converted to signed, normalize function will convert it back again */
406  *(dst++) += (signed char)((BYTE)*(src++) - (BYTE)0x80);
407 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ norm16()

static void norm16 ( INT src,
SHORT dst,
unsigned  len 
)
static

Definition at line 465 of file dsound_convert.c.

466 {
467  TRACE("%p - %p %d\n", src, dst, len);
468  len /= 2;
469  while (len--)
470  {
471  *dst = le16(*src);
472  if (*src <= -0x8000)
473  *dst = le16(0x8000);
474  else if (*src > 0x7fff)
475  *dst = le16(0x7fff);
476  ++dst;
477  ++src;
478  }
479 }
#define le16(x)
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ norm24()

static void norm24 ( INT src,
BYTE dst,
unsigned  len 
)
static

Definition at line 481 of file dsound_convert.c.

482 {
483  TRACE("%p - %p %d\n", src, dst, len);
484  len /= 3;
485  while (len--)
486  {
487  if (*src <= -0x800000)
488  {
489  dst[0] = 0;
490  dst[1] = 0;
491  dst[2] = 0x80;
492  }
493  else if (*src > 0x7fffff)
494  {
495  dst[0] = 0xff;
496  dst[1] = 0xff;
497  dst[2] = 0x7f;
498  }
499  else
500  {
501  dst[0] = *src;
502  dst[1] = *src >> 8;
503  dst[2] = *src >> 16;
504  }
505  ++dst;
506  ++src;
507  }
508 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ norm32()

static void norm32 ( LONGLONG src,
INT dst,
unsigned  len 
)
static

Definition at line 510 of file dsound_convert.c.

511 {
512  TRACE("%p - %p %d\n", src, dst, len);
513  len /= 4;
514  while (len--)
515  {
516  *dst = le32(*src);
517  if (*src <= -(LONGLONG)0x80000000)
518  *dst = le32(0x80000000);
519  else if (*src > 0x7fffffff)
520  *dst = le32(0x7fffffff);
521  ++dst;
522  ++src;
523  }
524 }
int64_t LONGLONG
Definition: typedefs.h:66
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define le32(x)

◆ norm8()

static void norm8 ( INT src,
signed char dst,
unsigned  len 
)
static

Definition at line 450 of file dsound_convert.c.

451 {
452  TRACE("%p - %p %d\n", src, dst, len);
453  while (len--)
454  {
455  *dst = (*src) + 0x80;
456  if (*src < -0x80)
457  *dst = 0;
458  else if (*src > 0x7f)
459  *dst = 0xff;
460  ++dst;
461  ++src;
462  }
463 }
#define TRACE(s)
Definition: solgame.cpp:4
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ src_advance()

static void src_advance ( const void **  src,
UINT  stride,
INT count,
UINT freqAcc,
UINT  adj 
)
inlinestatic

Definition at line 47 of file dsound_convert.c.

48 {
49  *freqAcc += adj;
50  if (*freqAcc >= (1 << DSOUND_FREQSHIFT))
51  {
52  ULONG adv = (*freqAcc >> DSOUND_FREQSHIFT);
53  *freqAcc &= (1 << DSOUND_FREQSHIFT) - 1;
54  *(const char **)src += adv * stride;
55  *count -= adv;
56  }
57 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define DSOUND_FREQSHIFT
GLsizei stride
Definition: glext.h:5848
GLenum src
Definition: glext.h:6340
unsigned int ULONG
Definition: retypes.h:1

Referenced by convert_16_to_16(), convert_16_to_24(), convert_16_to_32(), convert_16_to_8(), convert_24_to_16(), convert_24_to_24(), convert_24_to_32(), convert_24_to_8(), convert_32_to_16(), convert_32_to_24(), convert_32_to_32(), convert_32_to_8(), convert_8_to_16(), convert_8_to_24(), convert_8_to_32(), convert_8_to_8(), convert_ieee_32_to_16(), convert_ieee_32_to_24(), convert_ieee_32_to_32(), and convert_ieee_32_to_8().

Variable Documentation

◆ convertbpp

const bitsconvertfunc convertbpp
Initial value:
= {
}
static void convert_32_to_8(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_24_to_8(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_32_to_24(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_16_to_32(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_16_to_24(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_24_to_16(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_ieee_32_to_24(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_ieee_32_to_8(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_8_to_16(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_32_to_16(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_ieee_32_to_16(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_16_to_16(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_8_to_32(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_8_to_8(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_24_to_32(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_ieee_32_to_32(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_8_to_24(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_32_to_32(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_24_to_24(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)
static void convert_16_to_8(const void *src, void *dst, UINT src_stride, UINT dst_stride, INT count, UINT freqAcc, UINT adj)

Definition at line 393 of file dsound_convert.c.

Referenced by DSOUND_RecalcFormat().

◆ mixfunctions

const mixfunc mixfunctions
Initial value:
= {
}
static void mix24(BYTE *src, INT *dst, unsigned len)
static void mix16(SHORT *src, INT *dst, unsigned len)
static void mix32(INT *src, LONGLONG *dst, unsigned len)
static void mix8(signed char *src, INT *dst, unsigned len)
void(* mixfunc)(const void *, void *, unsigned)

Definition at line 443 of file dsound_convert.c.

Referenced by DSOUND_PrimaryOpen(), and primarybuffer_SetFormat().

◆ normfunctions

const normfunc normfunctions
Initial value:
= {
}
void(* normfunc)(const void *, void *, unsigned)
static void norm16(INT *src, SHORT *dst, unsigned len)
static void norm32(LONGLONG *src, INT *dst, unsigned len)
static void norm8(INT *src, signed char *dst, unsigned len)
static void norm24(INT *src, BYTE *dst, unsigned len)

Definition at line 526 of file dsound_convert.c.

Referenced by DSOUND_PrimaryOpen(), and primarybuffer_SetFormat().