jack1 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

682 lines
18KB

  1. /*
  2. Copyright (C) 2000 Paul Davis
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #define _ISOC9X_SOURCE 1
  16. #define _ISOC99_SOURCE 1
  17. #define __USE_ISOC9X 1
  18. #define __USE_ISOC99 1
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <math.h>
  22. #include <memory.h>
  23. #include <stdlib.h>
  24. #include <stdint.h>
  25. #include <limits.h>
  26. #include <endian.h>
  27. #include "memops.h"
  28. /* Notes about these *_SCALING values.
  29. the MAX_<N>BIT values are floating point. when multiplied by
  30. a full-scale normalized floating point sample value (-1.0..+1.0)
  31. they should give the maxium value representable with an integer
  32. sample type of N bits. Note that this is asymmetric. Sample ranges
  33. for signed integer, 2's complement values are -(2^(N-1) to +(2^(N-1)-1)
  34. Complications
  35. -------------
  36. If we use +2^(N-1) for the scaling factors, we run into a problem:
  37. if we start with a normalized float value of -1.0, scaling
  38. to 24 bits would give -8388608 (-2^23), which is ideal.
  39. But with +1.0, we get +8388608, which is technically out of range.
  40. We never multiply a full range normalized value by this constant,
  41. but we could multiply it by a positive value that is close enough to +1.0
  42. to produce a value > +(2^(N-1)-1.
  43. There is no way around this paradox without wasting CPU cycles to determine
  44. which scaling factor to use (i.e. determine if its negative or not,
  45. use the right factor).
  46. So, for now (October 2008) we use 2^(N-1)-1 as the scaling factor.
  47. */
  48. #define SAMPLE_24BIT_SCALING 8388607.0f
  49. #define SAMPLE_16BIT_SCALING 32767.0f
  50. /* these are just values to use if the floating point value was out of range
  51. advice from Fons Adriaensen: make the limits symmetrical
  52. */
  53. #define SAMPLE_24BIT_MAX 8388607
  54. #define SAMPLE_24BIT_MIN -8388607
  55. #define SAMPLE_24BIT_MAX_F 8388607.0f
  56. #define SAMPLE_24BIT_MIN_F -8388607.0f
  57. #define SAMPLE_16BIT_MAX 32767
  58. #define SAMPLE_16BIT_MIN -32767
  59. #define SAMPLE_16BIT_MAX_F 32767.0f
  60. #define SAMPLE_16BIT_MIN_F -32767.0f
  61. /* these mark the outer edges of the range considered "within" range
  62. for a floating point sample value. values outside (and on the boundaries)
  63. of this range will be clipped before conversion; values within this
  64. range will be scaled to appropriate values for the target sample
  65. type.
  66. */
  67. #define NORMALIZED_FLOAT_MIN -1.0f
  68. #define NORMALIZED_FLOAT_MAX 1.0f
  69. /* define this in case we end up on a platform that is missing
  70. the real lrintf functions
  71. */
  72. #define f_round(f) lrintf (f)
  73. #define float_16(s, d) \
  74. if ((s) <= NORMALIZED_FLOAT_MIN) { \
  75. (d) = SAMPLE_16BIT_MIN; \
  76. } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
  77. (d) = SAMPLE_16BIT_MAX; \
  78. } else { \
  79. (d) = f_round ((s) * SAMPLE_16BIT_SCALING); \
  80. }
  81. /* call this when "s" has already been scaled (e.g. when dithering)
  82. */
  83. #define float_16_scaled(s, d) \
  84. if ((s) <= SAMPLE_16BIT_MIN_F) { \
  85. (d) = SAMPLE_16BIT_MIN_F; \
  86. } else if ((s) >= SAMPLE_16BIT_MAX_F) { \
  87. (d) = SAMPLE_16BIT_MAX; \
  88. } else { \
  89. (d) = f_round ((s)); \
  90. }
  91. #define float_24u32(s, d) \
  92. if ((s) <= NORMALIZED_FLOAT_MIN) { \
  93. (d) = SAMPLE_24BIT_MIN << 8; \
  94. } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
  95. (d) = SAMPLE_24BIT_MAX << 8; \
  96. } else { \
  97. (d) = f_round ((s) * SAMPLE_24BIT_SCALING) << 8; \
  98. }
  99. /* call this when "s" has already been scaled (e.g. when dithering)
  100. */
  101. #define float_24u32_scaled(s, d) \
  102. if ((s) <= SAMPLE_24BIT_MIN_F) { \
  103. (d) = SAMPLE_24BIT_MIN << 8; \
  104. } else if ((s) >= SAMPLE_24BIT_MAX_F) { \
  105. (d) = SAMPLE_24BIT_MAX << 8; \
  106. } else { \
  107. (d) = f_round ((s)) << 8; \
  108. }
  109. #define float_24(s, d) \
  110. if ((s) <= NORMALIZED_FLOAT_MIN) { \
  111. (d) = SAMPLE_24BIT_MIN; \
  112. } else if ((s) >= NORMALIZED_FLOAT_MAX) { \
  113. (d) = SAMPLE_24BIT_MAX; \
  114. } else { \
  115. (d) = f_round ((s) * SAMPLE_24BIT_SCALING); \
  116. }
  117. /* call this when "s" has already been scaled (e.g. when dithering)
  118. */
  119. #define float_24_scaled(s, d) \
  120. if ((s) <= SAMPLE_24BIT_MIN_F) { \
  121. (d) = SAMPLE_24BIT_MIN; \
  122. } else if ((s) >= SAMPLE_24BIT_MAX_F) { \
  123. (d) = SAMPLE_24BIT_MAX; \
  124. } else { \
  125. (d) = f_round ((s)); \
  126. }
  127. /* Linear Congruential noise generator. From the music-dsp list
  128. * less random than rand(), but good enough and 10x faster
  129. */
  130. static inline unsigned int fast_rand ()
  131. {
  132. static unsigned int seed = 22222;
  133. seed = (seed * 96314165) + 907633515;
  134. return seed;
  135. }
  136. /* functions for native float sample data */
  137. void sample_move_floatLE_sSs (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  138. {
  139. while (nsamples--) {
  140. *dst = *((float*)src);
  141. dst++;
  142. src += src_skip;
  143. }
  144. }
  145. void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  146. {
  147. while (nsamples--) {
  148. *((float*)dst) = *src;
  149. dst += dst_skip;
  150. src++;
  151. }
  152. }
  153. /* NOTES on function naming:
  154. foo_bar_d<TYPE>_s<TYPE>
  155. the "d<TYPE>" component defines the destination type for the operation
  156. the "s<TYPE>" component defines the source type for the operation
  157. TYPE can be one of:
  158. S - sample is a jack_default_audio_sample_t, currently (October 2008) a 32 bit floating point value
  159. Ss - like S but reverse endian from the host CPU
  160. 32u24 - sample is an signed 32 bit integer value, but data is in upper 24 bits only
  161. 32u24s - like 32u24 but reverse endian from the host CPU
  162. 24 - sample is an signed 24 bit integer value
  163. 24s - like 24 but reverse endian from the host CPU
  164. 16 - sample is an signed 16 bit integer value
  165. 16s - like 16 but reverse endian from the host CPU
  166. For obvious reasons, the reverse endian versions only show as source types.
  167. This covers all known sample formats at 16 bits or larger.
  168. */
  169. /* functions for native integer sample data */
  170. void sample_move_d32u24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  171. {
  172. int32_t z;
  173. while (nsamples--) {
  174. float_24u32 (*src, z);
  175. #if __BYTE_ORDER == __LITTLE_ENDIAN
  176. dst[0] = (char)(z >> 24);
  177. dst[1] = (char)(z >> 16);
  178. dst[2] = (char)(z >> 8);
  179. dst[3] = (char)(z);
  180. #elif __BYTE_ORDER == __BIG_ENDIAN
  181. dst[0] = (char)(z);
  182. dst[1] = (char)(z >> 8);
  183. dst[2] = (char)(z >> 16);
  184. dst[3] = (char)(z >> 24);
  185. #endif
  186. dst += dst_skip;
  187. src++;
  188. }
  189. }
  190. void sample_move_d32u24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  191. {
  192. while (nsamples--) {
  193. float_24u32 (*src, *((int32_t*)dst));
  194. dst += dst_skip;
  195. src++;
  196. }
  197. }
  198. void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  199. {
  200. /* ALERT: signed sign-extension portability !!! */
  201. while (nsamples--) {
  202. int x;
  203. #if __BYTE_ORDER == __LITTLE_ENDIAN
  204. x = (unsigned char)(src[0]);
  205. x <<= 8;
  206. x |= (unsigned char)(src[1]);
  207. x <<= 8;
  208. x |= (unsigned char)(src[2]);
  209. x <<= 8;
  210. x |= (unsigned char)(src[3]);
  211. #elif __BYTE_ORDER == __BIG_ENDIAN
  212. x = (unsigned char)(src[3]);
  213. x <<= 8;
  214. x |= (unsigned char)(src[2]);
  215. x <<= 8;
  216. x |= (unsigned char)(src[1]);
  217. x <<= 8;
  218. x |= (unsigned char)(src[0]);
  219. #endif
  220. *dst = (x >> 8) / SAMPLE_24BIT_SCALING;
  221. dst++;
  222. src += src_skip;
  223. }
  224. }
  225. void sample_move_dS_s32u24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  226. {
  227. /* ALERT: signed sign-extension portability !!! */
  228. while (nsamples--) {
  229. *dst = (*((int*)src) >> 8) / SAMPLE_24BIT_SCALING;
  230. dst++;
  231. src += src_skip;
  232. }
  233. }
  234. void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  235. {
  236. int32_t z;
  237. while (nsamples--) {
  238. float_24 (*src, z);
  239. #if __BYTE_ORDER == __LITTLE_ENDIAN
  240. dst[0] = (char)(z >> 16);
  241. dst[1] = (char)(z >> 8);
  242. dst[2] = (char)(z);
  243. #elif __BYTE_ORDER == __BIG_ENDIAN
  244. dst[0] = (char)(z);
  245. dst[1] = (char)(z >> 8);
  246. dst[2] = (char)(z >> 16);
  247. #endif
  248. dst += dst_skip;
  249. src++;
  250. }
  251. }
  252. void sample_move_d24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  253. {
  254. int32_t z;
  255. while (nsamples--) {
  256. float_24 (*src, z);
  257. #if __BYTE_ORDER == __LITTLE_ENDIAN
  258. memcpy (dst, &z, 3);
  259. #elif __BYTE_ORDER == __BIG_ENDIAN
  260. memcpy (dst, (char*)&z + 1, 3);
  261. #endif
  262. dst += dst_skip;
  263. src++;
  264. }
  265. }
  266. void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  267. {
  268. /* ALERT: signed sign-extension portability !!! */
  269. while (nsamples--) {
  270. int x;
  271. #if __BYTE_ORDER == __LITTLE_ENDIAN
  272. x = (unsigned char)(src[0]);
  273. x <<= 8;
  274. x |= (unsigned char)(src[1]);
  275. x <<= 8;
  276. x |= (unsigned char)(src[2]);
  277. /* correct sign bit and the rest of the top byte */
  278. if (src[0] & 0x80) {
  279. x |= 0xff << 24;
  280. }
  281. #elif __BYTE_ORDER == __BIG_ENDIAN
  282. x = (unsigned char)(src[2]);
  283. x <<= 8;
  284. x |= (unsigned char)(src[1]);
  285. x <<= 8;
  286. x |= (unsigned char)(src[0]);
  287. /* correct sign bit and the rest of the top byte */
  288. if (src[2] & 0x80) {
  289. x |= 0xff << 24;
  290. }
  291. #endif
  292. *dst = x / SAMPLE_24BIT_SCALING;
  293. dst++;
  294. src += src_skip;
  295. }
  296. }
  297. void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  298. {
  299. /* ALERT: signed sign-extension portability !!! */
  300. while (nsamples--) {
  301. int x;
  302. #if __BYTE_ORDER == __LITTLE_ENDIAN
  303. memcpy ((char*)&x + 1, src, 3);
  304. #elif __BYTE_ORDER == __BIG_ENDIAN
  305. memcpy (&x, src, 3);
  306. #endif
  307. x >>= 8;
  308. *dst = x / SAMPLE_24BIT_SCALING;
  309. dst++;
  310. src += src_skip;
  311. }
  312. }
  313. void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  314. {
  315. int16_t tmp;
  316. while (nsamples--) {
  317. // float_16 (*src, tmp);
  318. if (*src <= NORMALIZED_FLOAT_MIN) {
  319. tmp = SAMPLE_16BIT_MIN;
  320. } else if (*src >= NORMALIZED_FLOAT_MAX) {
  321. tmp = SAMPLE_16BIT_MAX;
  322. } else {
  323. tmp = (int16_t)f_round (*src * SAMPLE_16BIT_SCALING);
  324. }
  325. #if __BYTE_ORDER == __LITTLE_ENDIAN
  326. dst[0] = (char)(tmp >> 8);
  327. dst[1] = (char)(tmp);
  328. #elif __BYTE_ORDER == __BIG_ENDIAN
  329. dst[0] = (char)(tmp);
  330. dst[1] = (char)(tmp >> 8);
  331. #endif
  332. dst += dst_skip;
  333. src++;
  334. }
  335. }
  336. void sample_move_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  337. {
  338. while (nsamples--) {
  339. float_16 (*src, *((int16_t*)dst));
  340. dst += dst_skip;
  341. src++;
  342. }
  343. }
  344. void sample_move_dither_rect_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  345. {
  346. jack_default_audio_sample_t val;
  347. int16_t tmp;
  348. while (nsamples--) {
  349. val = (*src * SAMPLE_16BIT_SCALING) + fast_rand () / (float)UINT_MAX - 0.5f;
  350. float_16_scaled (val, tmp);
  351. #if __BYTE_ORDER == __LITTLE_ENDIAN
  352. dst[0] = (char)(tmp >> 8);
  353. dst[1] = (char)(tmp);
  354. #elif __BYTE_ORDER == __BIG_ENDIAN
  355. dst[0] = (char)(tmp);
  356. dst[1] = (char)(tmp >> 8);
  357. #endif
  358. dst += dst_skip;
  359. src++;
  360. }
  361. }
  362. void sample_move_dither_rect_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  363. {
  364. jack_default_audio_sample_t val;
  365. while (nsamples--) {
  366. val = (*src * SAMPLE_16BIT_SCALING) + fast_rand () / (float)UINT_MAX - 0.5f;
  367. float_16_scaled (val, *((int16_t*)dst));
  368. dst += dst_skip;
  369. src++;
  370. }
  371. }
  372. void sample_move_dither_tri_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  373. {
  374. jack_default_audio_sample_t val;
  375. int16_t tmp;
  376. while (nsamples--) {
  377. val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
  378. float_16_scaled (val, tmp);
  379. #if __BYTE_ORDER == __LITTLE_ENDIAN
  380. dst[0] = (char)(tmp >> 8);
  381. dst[1] = (char)(tmp);
  382. #elif __BYTE_ORDER == __BIG_ENDIAN
  383. dst[0] = (char)(tmp);
  384. dst[1] = (char)(tmp >> 8);
  385. #endif
  386. dst += dst_skip;
  387. src++;
  388. }
  389. }
  390. void sample_move_dither_tri_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  391. {
  392. jack_default_audio_sample_t val;
  393. while (nsamples--) {
  394. val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
  395. float_16_scaled (val, *((int16_t*)dst));
  396. dst += dst_skip;
  397. src++;
  398. }
  399. }
  400. void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  401. {
  402. jack_default_audio_sample_t x;
  403. jack_default_audio_sample_t xe; /* the innput sample - filtered error */
  404. jack_default_audio_sample_t xp; /* x' */
  405. float r;
  406. float rm1 = state->rm1;
  407. unsigned int idx = state->idx;
  408. int16_t tmp;
  409. while (nsamples--) {
  410. x = *src * SAMPLE_16BIT_SCALING;
  411. r = ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
  412. /* Filter the error with Lipshitz's minimally audible FIR:
  413. [2.033 -2.165 1.959 -1.590 0.6149] */
  414. xe = x
  415. - state->e[idx] * 2.033f
  416. + state->e[(idx - 1) & DITHER_BUF_MASK] * 2.165f
  417. - state->e[(idx - 2) & DITHER_BUF_MASK] * 1.959f
  418. + state->e[(idx - 3) & DITHER_BUF_MASK] * 1.590f
  419. - state->e[(idx - 4) & DITHER_BUF_MASK] * 0.6149f;
  420. xp = xe + r - rm1;
  421. rm1 = r;
  422. float_16_scaled (xp, tmp);
  423. /* Intrinsic z^-1 delay */
  424. idx = (idx + 1) & DITHER_BUF_MASK;
  425. state->e[idx] = xp - xe;
  426. #if __BYTE_ORDER == __LITTLE_ENDIAN
  427. dst[0] = (char)(tmp >> 8);
  428. dst[1] = (char)(tmp);
  429. #elif __BYTE_ORDER == __BIG_ENDIAN
  430. dst[0] = (char)(tmp);
  431. dst[1] = (char)(tmp >> 8);
  432. #endif
  433. dst += dst_skip;
  434. src++;
  435. }
  436. state->rm1 = rm1;
  437. state->idx = idx;
  438. }
  439. void sample_move_dither_shaped_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  440. {
  441. jack_default_audio_sample_t x;
  442. jack_default_audio_sample_t xe; /* the innput sample - filtered error */
  443. jack_default_audio_sample_t xp; /* x' */
  444. float r;
  445. float rm1 = state->rm1;
  446. unsigned int idx = state->idx;
  447. while (nsamples--) {
  448. x = *src * SAMPLE_16BIT_SCALING;
  449. r = ((float)fast_rand () + (float)fast_rand ()) / (float)UINT_MAX - 1.0f;
  450. /* Filter the error with Lipshitz's minimally audible FIR:
  451. [2.033 -2.165 1.959 -1.590 0.6149] */
  452. xe = x
  453. - state->e[idx] * 2.033f
  454. + state->e[(idx - 1) & DITHER_BUF_MASK] * 2.165f
  455. - state->e[(idx - 2) & DITHER_BUF_MASK] * 1.959f
  456. + state->e[(idx - 3) & DITHER_BUF_MASK] * 1.590f
  457. - state->e[(idx - 4) & DITHER_BUF_MASK] * 0.6149f;
  458. xp = xe + r - rm1;
  459. rm1 = r;
  460. float_16_scaled (xp, *((int16_t*)dst));
  461. /* Intrinsic z^-1 delay */
  462. idx = (idx + 1) & DITHER_BUF_MASK;
  463. state->e[idx] = *((int16_t*)dst) - xe;
  464. dst += dst_skip;
  465. src++;
  466. }
  467. state->rm1 = rm1;
  468. state->idx = idx;
  469. }
  470. void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  471. {
  472. short z;
  473. /* ALERT: signed sign-extension portability !!! */
  474. while (nsamples--) {
  475. #if __BYTE_ORDER == __LITTLE_ENDIAN
  476. z = (unsigned char)(src[0]);
  477. z <<= 8;
  478. z |= (unsigned char)(src[1]);
  479. #elif __BYTE_ORDER == __BIG_ENDIAN
  480. z = (unsigned char)(src[1]);
  481. z <<= 8;
  482. z |= (unsigned char)(src[0]);
  483. #endif
  484. *dst = z / SAMPLE_16BIT_SCALING;
  485. dst++;
  486. src += src_skip;
  487. }
  488. }
  489. void sample_move_dS_s16 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  490. {
  491. /* ALERT: signed sign-extension portability !!! */
  492. while (nsamples--) {
  493. *dst = (*((short*)src)) / SAMPLE_16BIT_SCALING;
  494. dst++;
  495. src += src_skip;
  496. }
  497. }
  498. void memset_interleave (char *dst, char val, unsigned long bytes,
  499. unsigned long unit_bytes,
  500. unsigned long skip_bytes)
  501. {
  502. switch (unit_bytes) {
  503. case 1:
  504. while (bytes--) {
  505. *dst = val;
  506. dst += skip_bytes;
  507. }
  508. break;
  509. case 2:
  510. while (bytes) {
  511. *((short*)dst) = (short)val;
  512. dst += skip_bytes;
  513. bytes -= 2;
  514. }
  515. break;
  516. case 4:
  517. while (bytes) {
  518. *((int*)dst) = (int)val;
  519. dst += skip_bytes;
  520. bytes -= 4;
  521. }
  522. break;
  523. default:
  524. while (bytes) {
  525. memset (dst, val, unit_bytes);
  526. dst += skip_bytes;
  527. bytes -= unit_bytes;
  528. }
  529. break;
  530. }
  531. }
  532. /* COPY FUNCTIONS: used to move data from an input channel to an
  533. output channel. Note that we assume that the skip distance
  534. is the same for both channels. This is completely fine
  535. unless the input and output were on different audio interfaces that
  536. were interleaved differently. We don't try to handle that.
  537. */
  538. void
  539. memcpy_fake (char *dst, char *src, unsigned long src_bytes, unsigned long foo, unsigned long bar)
  540. {
  541. memcpy (dst, src, src_bytes);
  542. }
  543. void
  544. memcpy_interleave_d16_s16 (char *dst, char *src, unsigned long src_bytes,
  545. unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
  546. {
  547. while (src_bytes) {
  548. *((short*)dst) = *((short*)src);
  549. dst += dst_skip_bytes;
  550. src += src_skip_bytes;
  551. src_bytes -= 2;
  552. }
  553. }
  554. void
  555. memcpy_interleave_d24_s24 (char *dst, char *src, unsigned long src_bytes,
  556. unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
  557. {
  558. while (src_bytes) {
  559. memcpy (dst, src, 3);
  560. dst += dst_skip_bytes;
  561. src += src_skip_bytes;
  562. src_bytes -= 3;
  563. }
  564. }
  565. void
  566. memcpy_interleave_d32_s32 (char *dst, char *src, unsigned long src_bytes,
  567. unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
  568. {
  569. while (src_bytes) {
  570. *((int*)dst) = *((int*)src);
  571. dst += dst_skip_bytes;
  572. src += src_skip_bytes;
  573. src_bytes -= 4;
  574. }
  575. }