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.

671 lines
17KB

  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 <jack/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_24(s, d) \
  92. if ((s) <= NORMALIZED_FLOAT_MIN) {\
  93. (d) = SAMPLE_24BIT_MIN;\
  94. } else if ((s) >= NORMALIZED_FLOAT_MAX) {\
  95. (d) = SAMPLE_24BIT_MAX;\
  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_24_scaled(s, d)\
  102. if ((s) <= SAMPLE_24BIT_MIN_F) {\
  103. (d) = SAMPLE_24BIT_MIN;\
  104. } else if ((s) >= SAMPLE_24BIT_MAX_F) { \
  105. (d) = SAMPLE_24BIT_MAX; \
  106. } else {\
  107. (d) = f_round ((s)) << 8; \
  108. }
  109. /* Linear Congruential noise generator. From the music-dsp list
  110. * less random than rand(), but good enough and 10x faster
  111. */
  112. inline unsigned int fast_rand() {
  113. static unsigned int seed = 22222;
  114. seed = (seed * 96314165) + 907633515;
  115. return seed;
  116. }
  117. /* functions for native float sample data */
  118. void sample_move_floatLE_sSs (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip) {
  119. while (nsamples--) {
  120. *dst = *((float *) src);
  121. dst++;
  122. src += src_skip;
  123. }
  124. }
  125. void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state) {
  126. while (nsamples--) {
  127. *((float *) dst) = *src;
  128. dst += dst_skip;
  129. src++;
  130. }
  131. }
  132. /* NOTES on function naming:
  133. foo_bar_d<TYPE>_s<TYPE>
  134. the "d<TYPE>" component defines the destination type for the operation
  135. the "s<TYPE>" component defines the source type for the operation
  136. TYPE can be one of:
  137. S - sample is a jack_default_audio_sample_t, currently (October 2008) a 32 bit floating point value
  138. Ss - like S but reverse endian from the host CPU
  139. 32u24 - sample is an signed 32 bit integer value, but data is in upper 24 bits only
  140. 32u24s - like 32u24 but reverse endian from the host CPU
  141. 24 - sample is an signed 24 bit integer value
  142. 24s - like 24 but reverse endian from the host CPU
  143. 16 - sample is an signed 16 bit integer value
  144. 16s - like 16 but reverse endian from the host CPU
  145. For obvious reasons, the reverse endian versions only show as source types.
  146. This covers all known sample formats at 16 bits or larger.
  147. */
  148. /* functions for native integer sample data */
  149. void sample_move_d32u24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  150. {
  151. int32_t z;
  152. while (nsamples--) {
  153. float_24 (*src, z);
  154. #if __BYTE_ORDER == __LITTLE_ENDIAN
  155. dst[0]=(char)(z>>24);
  156. dst[1]=(char)(z>>16);
  157. dst[2]=(char)(z>>8);
  158. dst[3]=(char)(z);
  159. #elif __BYTE_ORDER == __BIG_ENDIAN
  160. dst[0]=(char)(z);
  161. dst[1]=(char)(z>>8);
  162. dst[2]=(char)(z>>16);
  163. dst[3]=(char)(z>>24);
  164. #endif
  165. dst += dst_skip;
  166. src++;
  167. }
  168. }
  169. void sample_move_d32u24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  170. {
  171. while (nsamples--) {
  172. float_24 (*src, *((int32_t*) dst));
  173. dst += dst_skip;
  174. src++;
  175. }
  176. }
  177. void sample_move_dS_s32u24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  178. {
  179. /* ALERT: signed sign-extension portability !!! */
  180. while (nsamples--) {
  181. int x;
  182. #if __BYTE_ORDER == __LITTLE_ENDIAN
  183. x = (unsigned char)(src[0]);
  184. x <<= 8;
  185. x |= (unsigned char)(src[1]);
  186. x <<= 8;
  187. x |= (unsigned char)(src[2]);
  188. x <<= 8;
  189. x |= (unsigned char)(src[3]);
  190. #elif __BYTE_ORDER == __BIG_ENDIAN
  191. x = (unsigned char)(src[3]);
  192. x <<= 8;
  193. x |= (unsigned char)(src[2]);
  194. x <<= 8;
  195. x |= (unsigned char)(src[1]);
  196. x <<= 8;
  197. x |= (unsigned char)(src[0]);
  198. #endif
  199. *dst = (x >> 8) / SAMPLE_24BIT_SCALING;
  200. dst++;
  201. src += src_skip;
  202. }
  203. }
  204. void sample_move_dS_s32u24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  205. {
  206. /* ALERT: signed sign-extension portability !!! */
  207. while (nsamples--) {
  208. *dst = (*((int *) src) >> 8) / SAMPLE_24BIT_SCALING;
  209. dst++;
  210. src += src_skip;
  211. }
  212. }
  213. void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  214. {
  215. int32_t z;
  216. while (nsamples--) {
  217. float_24 (*src, z);
  218. #if __BYTE_ORDER == __LITTLE_ENDIAN
  219. dst[0]=(char)(z>>16);
  220. dst[1]=(char)(z>>8);
  221. dst[2]=(char)(z);
  222. #elif __BYTE_ORDER == __BIG_ENDIAN
  223. dst[0]=(char)(z);
  224. dst[1]=(char)(z>>8);
  225. dst[2]=(char)(z>>16);
  226. #endif
  227. dst += dst_skip;
  228. src++;
  229. }
  230. }
  231. void sample_move_d24_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  232. {
  233. int32_t z;
  234. while (nsamples--) {
  235. float_24 (*src, z);
  236. #if __BYTE_ORDER == __LITTLE_ENDIAN
  237. memcpy (dst, &z, 3);
  238. #elif __BYTE_ORDER == __BIG_ENDIAN
  239. memcpy (dst, (char *)&z + 1, 3);
  240. #endif
  241. dst += dst_skip;
  242. src++;
  243. }
  244. }
  245. void sample_move_dS_s24s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  246. {
  247. /* ALERT: signed sign-extension portability !!! */
  248. while (nsamples--) {
  249. int x;
  250. #if __BYTE_ORDER == __LITTLE_ENDIAN
  251. x = (unsigned char)(src[0]);
  252. x <<= 8;
  253. x |= (unsigned char)(src[1]);
  254. x <<= 8;
  255. x |= (unsigned char)(src[2]);
  256. /* correct sign bit and the rest of the top byte */
  257. if (src[0] & 0x80) {
  258. x |= 0xff << 24;
  259. }
  260. #elif __BYTE_ORDER == __BIG_ENDIAN
  261. x = (unsigned char)(src[2]);
  262. x <<= 8;
  263. x |= (unsigned char)(src[1]);
  264. x <<= 8;
  265. x |= (unsigned char)(src[0]);
  266. /* correct sign bit and the rest of the top byte */
  267. if (src[0] & 0x80) {
  268. x |= 0xff << 24;
  269. }
  270. #endif
  271. *dst = x / SAMPLE_24BIT_SCALING;
  272. dst++;
  273. src += src_skip;
  274. }
  275. }
  276. void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  277. {
  278. /* ALERT: signed sign-extension portability !!! */
  279. while (nsamples--) {
  280. int x;
  281. #if __BYTE_ORDER == __LITTLE_ENDIAN
  282. memcpy((char*)&x + 1, src, 3);
  283. #elif __BYTE_ORDER == __BIG_ENDIAN
  284. memcpy(&x, src, 3);
  285. #endif
  286. x >>= 8;
  287. *dst = x / SAMPLE_24BIT_SCALING;
  288. dst++;
  289. src += src_skip;
  290. }
  291. }
  292. void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  293. {
  294. int16_t tmp;
  295. while (nsamples--) {
  296. // float_16 (*src, tmp);
  297. if (*src <= NORMALIZED_FLOAT_MIN) {
  298. tmp = SAMPLE_16BIT_MIN;
  299. } else if (*src >= NORMALIZED_FLOAT_MAX) {
  300. tmp = SAMPLE_16BIT_MAX;
  301. } else {
  302. tmp = (int16_t) f_round (*src * SAMPLE_16BIT_SCALING);
  303. }
  304. #if __BYTE_ORDER == __LITTLE_ENDIAN
  305. dst[0]=(char)(tmp>>8);
  306. dst[1]=(char)(tmp);
  307. #elif __BYTE_ORDER == __BIG_ENDIAN
  308. dst[0]=(char)(tmp);
  309. dst[1]=(char)(tmp>>8);
  310. #endif
  311. dst += dst_skip;
  312. src++;
  313. }
  314. }
  315. void sample_move_d16_sS (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
  316. {
  317. while (nsamples--) {
  318. float_16 (*src, *((int16_t*) dst));
  319. dst += dst_skip;
  320. src++;
  321. }
  322. }
  323. 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)
  324. {
  325. jack_default_audio_sample_t val;
  326. int16_t tmp;
  327. while (nsamples--) {
  328. val = (*src * SAMPLE_16BIT_SCALING) + fast_rand() / (float) INT_MAX - 1.0f;
  329. float_16_scaled (val, tmp);
  330. #if __BYTE_ORDER == __LITTLE_ENDIAN
  331. dst[0]=(char)(tmp>>8);
  332. dst[1]=(char)(tmp);
  333. #elif __BYTE_ORDER == __BIG_ENDIAN
  334. dst[0]=(char)(tmp);
  335. dst[1]=(char)(tmp>>8);
  336. #endif
  337. dst += dst_skip;
  338. src++;
  339. }
  340. }
  341. 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)
  342. {
  343. jack_default_audio_sample_t val;
  344. while (nsamples--) {
  345. val = (*src * SAMPLE_16BIT_SCALING) + fast_rand() / (float)INT_MAX - 1.0f;
  346. float_16_scaled (val, *((int16_t*) dst));
  347. dst += dst_skip;
  348. src++;
  349. }
  350. }
  351. 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)
  352. {
  353. jack_default_audio_sample_t val;
  354. float r;
  355. float rm1 = state->rm1;
  356. int16_t y;
  357. while (nsamples--) {
  358. r = 2.0f * (fast_rand() / (float)INT_MAX - 1.0f);
  359. val = (*src * SAMPLE_16BIT_SCALING) + (r - rm1);
  360. rm1 = r;
  361. float_16_scaled (*src, y);
  362. #if __BYTE_ORDER == __LITTLE_ENDIAN
  363. dst[0]=(char)(y>>8);
  364. dst[1]=(char)(y);
  365. #elif __BYTE_ORDER == __BIG_ENDIAN
  366. dst[0]=(char)(y);
  367. dst[1]=(char)(y>>8);
  368. #endif
  369. dst += dst_skip;
  370. src++;
  371. }
  372. state->rm1 = rm1;
  373. }
  374. 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)
  375. {
  376. jack_default_audio_sample_t val;
  377. float r;
  378. float rm1 = state->rm1;
  379. while (nsamples--) {
  380. r = 2.0f * (float)fast_rand() / (float)INT_MAX - 1.0f;
  381. val = (*src * SAMPLE_16BIT_SCALING) + (r - rm1);
  382. rm1 = r;
  383. float_16_scaled (val, *((int16_t*) dst));
  384. dst += dst_skip;
  385. src++;
  386. }
  387. state->rm1 = rm1;
  388. }
  389. 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)
  390. {
  391. jack_default_audio_sample_t x;
  392. jack_default_audio_sample_t xe; /* the innput sample - filtered error */
  393. jack_default_audio_sample_t xp; /* x' */
  394. float r;
  395. float rm1 = state->rm1;
  396. unsigned int idx = state->idx;
  397. int16_t tmp;
  398. while (nsamples--) {
  399. x = *src * SAMPLE_16BIT_SCALING;
  400. r = 2.0f * (float)fast_rand() / (float)INT_MAX - 1.0f;
  401. /* Filter the error with Lipshitz's minimally audible FIR:
  402. [2.033 -2.165 1.959 -1.590 0.6149] */
  403. xe = x
  404. - state->e[idx] * 2.033f
  405. + state->e[(idx - 1) & DITHER_BUF_MASK] * 2.165f
  406. - state->e[(idx - 2) & DITHER_BUF_MASK] * 1.959f
  407. + state->e[(idx - 3) & DITHER_BUF_MASK] * 1.590f
  408. - state->e[(idx - 4) & DITHER_BUF_MASK] * 0.6149f;
  409. xp = xe + r - rm1;
  410. rm1 = r;
  411. float_16_scaled (xp, tmp);
  412. /* Intrinsic z^-1 delay */
  413. idx = (idx + 1) & DITHER_BUF_MASK;
  414. state->e[idx] = xp - xe;
  415. #if __BYTE_ORDER == __LITTLE_ENDIAN
  416. dst[0]=(char)(tmp>>8);
  417. dst[1]=(char)(tmp);
  418. #elif __BYTE_ORDER == __BIG_ENDIAN
  419. dst[0]=(char)(tmp);
  420. dst[1]=(char)(tmp>>8);
  421. #endif
  422. dst += dst_skip;
  423. src++;
  424. }
  425. state->rm1 = rm1;
  426. state->idx = idx;
  427. }
  428. 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)
  429. {
  430. jack_default_audio_sample_t x;
  431. jack_default_audio_sample_t xe; /* the innput sample - filtered error */
  432. jack_default_audio_sample_t xp; /* x' */
  433. float r;
  434. float rm1 = state->rm1;
  435. unsigned int idx = state->idx;
  436. while (nsamples--) {
  437. x = *src * SAMPLE_16BIT_SCALING;
  438. r = 2.0f * (float)fast_rand() / (float)INT_MAX - 1.0f;
  439. /* Filter the error with Lipshitz's minimally audible FIR:
  440. [2.033 -2.165 1.959 -1.590 0.6149] */
  441. xe = x
  442. - state->e[idx] * 2.033f
  443. + state->e[(idx - 1) & DITHER_BUF_MASK] * 2.165f
  444. - state->e[(idx - 2) & DITHER_BUF_MASK] * 1.959f
  445. + state->e[(idx - 3) & DITHER_BUF_MASK] * 1.590f
  446. - state->e[(idx - 4) & DITHER_BUF_MASK] * 0.6149f;
  447. xp = xe + r - rm1;
  448. rm1 = r;
  449. float_16_scaled (xp, *((int16_t*) dst));
  450. /* Intrinsic z^-1 delay */
  451. idx = (idx + 1) & DITHER_BUF_MASK;
  452. state->e[idx] = *((int16_t*) dst) - xe;
  453. dst += dst_skip;
  454. src++;
  455. }
  456. state->rm1 = rm1;
  457. state->idx = idx;
  458. }
  459. void sample_move_dS_s16s (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  460. {
  461. short z;
  462. /* ALERT: signed sign-extension portability !!! */
  463. while (nsamples--) {
  464. #if __BYTE_ORDER == __LITTLE_ENDIAN
  465. z = (unsigned char)(src[0]);
  466. z <<= 8;
  467. z |= (unsigned char)(src[1]);
  468. #elif __BYTE_ORDER == __BIG_ENDIAN
  469. z = (unsigned char)(src[1]);
  470. z <<= 8;
  471. z |= (unsigned char)(src[0]);
  472. #endif
  473. *dst = z / SAMPLE_16BIT_SCALING;
  474. dst++;
  475. src += src_skip;
  476. }
  477. }
  478. void sample_move_dS_s16 (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip)
  479. {
  480. /* ALERT: signed sign-extension portability !!! */
  481. while (nsamples--) {
  482. *dst = (*((short *) src)) / SAMPLE_16BIT_SCALING;
  483. dst++;
  484. src += src_skip;
  485. }
  486. }
  487. void memset_interleave (char *dst, char val, unsigned long bytes,
  488. unsigned long unit_bytes,
  489. unsigned long skip_bytes)
  490. {
  491. switch (unit_bytes) {
  492. case 1:
  493. while (bytes--) {
  494. *dst = val;
  495. dst += skip_bytes;
  496. }
  497. break;
  498. case 2:
  499. while (bytes) {
  500. *((short *) dst) = (short) val;
  501. dst += skip_bytes;
  502. bytes -= 2;
  503. }
  504. break;
  505. case 4:
  506. while (bytes) {
  507. *((int *) dst) = (int) val;
  508. dst += skip_bytes;
  509. bytes -= 4;
  510. }
  511. break;
  512. default:
  513. while (bytes) {
  514. memset(dst, val, unit_bytes);
  515. dst += skip_bytes;
  516. bytes -= unit_bytes;
  517. }
  518. break;
  519. }
  520. }
  521. /* COPY FUNCTIONS: used to move data from an input channel to an
  522. output channel. Note that we assume that the skip distance
  523. is the same for both channels. This is completely fine
  524. unless the input and output were on different audio interfaces that
  525. were interleaved differently. We don't try to handle that.
  526. */
  527. void
  528. memcpy_fake (char *dst, char *src, unsigned long src_bytes, unsigned long foo, unsigned long bar)
  529. {
  530. memcpy (dst, src, src_bytes);
  531. }
  532. void
  533. memcpy_interleave_d16_s16 (char *dst, char *src, unsigned long src_bytes,
  534. unsigned long dst_skip_bytes, unsigned long src_skip_bytes)
  535. {
  536. while (src_bytes) {
  537. *((short *) dst) = *((short *) src);
  538. dst += dst_skip_bytes;
  539. src += src_skip_bytes;
  540. src_bytes -= 2;
  541. }
  542. }
  543. void
  544. memcpy_interleave_d24_s24 (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. memcpy(dst, src, 3);
  549. dst += dst_skip_bytes;
  550. src += src_skip_bytes;
  551. src_bytes -= 3;
  552. }
  553. }
  554. void
  555. memcpy_interleave_d32_s32 (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. *((int *) dst) = *((int *) src);
  560. dst += dst_skip_bytes;
  561. src += src_skip_bytes;
  562. src_bytes -= 4;
  563. }
  564. }