formats: clarify setting of reverse_bytes
[sox.git] / src / ima_rw.h
blob95debda9f1119a2acabbaa4c34ee4bc2622bf9e7
1 /* libSoX ima_rw.h -- codex utilities for WAV_FORMAT_IMA_ADPCM
2 * Copyright (C) 1999 Stanley J. Brooks <stabro@megsinet.net>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or (at
7 * your option) any later version.
9 * This library is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
12 * General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include "sox.h"
22 #ifndef SAMPL
23 #define SAMPL short
24 #endif
27 * call lsx_ima_init_table() before any other Ima* functions,
28 * to create the fast lookup tables
30 extern void lsx_ima_init_table(void);
32 /* lsx_ima_block_expand_i() outputs interleaved samples into one output buffer */
33 extern void lsx_ima_block_expand_i(
34 unsigned chans, /* total channels */
35 const unsigned char *ibuff,/* input buffer[blockAlign] */
36 SAMPL *obuff, /* output samples, n*chans */
37 int n /* samples to decode PER channel, REQUIRE n % 8 == 1 */
40 /* lsx_ima_block_expand_m() outputs non-interleaved samples into chan separate output buffers */
41 extern void lsx_ima_block_expand_m(
42 unsigned chans, /* total channels */
43 const unsigned char *ibuff,/* input buffer[blockAlign] */
44 SAMPL **obuffs, /* chan output sample buffers, each takes n samples */
45 int n /* samples to decode PER channel, REQUIRE n % 8 == 1 */
48 /* mash one block. if you want to use opt>0, 9 is a reasonable value */
49 extern void lsx_ima_block_mash_i(
50 unsigned chans, /* total channels */
51 const SAMPL *ip, /* ip[] is interleaved input samples */
52 int n, /* samples to encode PER channel, REQUIRE n % 8 == 1 */
53 int *st, /* input/output state[chans], REQUIRE 0 <= st[ch] <= ISSTMAX */
54 unsigned char *obuff, /* output buffer[blockAlign] */
55 int opt /* non-zero allows some cpu-intensive code to improve output */
58 /* Some helper functions for computing samples/block and blockalign */
61 * lsx_ima_samples_in(dataLen, chans, blockAlign, samplesPerBlock)
62 * returns the number of samples/channel which would go
63 * in the dataLen, given the other parameters ...
64 * if input samplesPerBlock is 0, then returns the max
65 * samplesPerBlock which would go into a block of size blockAlign
66 * Yes, it is confusing usage.
68 extern size_t lsx_ima_samples_in(
69 size_t dataLen,
70 size_t chans,
71 size_t blockAlign,
72 size_t samplesPerBlock
76 * size_t lsx_ima_bytes_per_block(chans, samplesPerBlock)
77 * return minimum blocksize which would be required
78 * to encode number of chans with given samplesPerBlock
80 extern size_t lsx_ima_bytes_per_block(
81 size_t chans,
82 size_t samplesPerBlock