1 /* adpcm.h  codex functions for MS_ADPCM data
2  *          (hopefully) provides interoperability with
3  *          Microsoft's ADPCM format, but, as usual,
4  *          see LACK-OF-WARRANTY information below.
5  *
6  *      Copyright (C) 1999 Stanley J. Brooks <stabro@megsinet.net>
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or (at
11  * your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23 #include "sox.h"
24 
25 #ifndef SAMPL
26 #define SAMPL short
27 #endif
28 
29 /* default coef sets */
30 extern const short lsx_ms_adpcm_i_coef[7][2];
31 
32 extern void *lsx_ms_adpcm_alloc(unsigned chans);
33 
34 /* lsx_ms_adpcm_block_expand_i() outputs interleaved samples into one output buffer */
35 extern const char *lsx_ms_adpcm_block_expand_i(
36 	void *priv,
37 	unsigned chans,          /* total channels             */
38 	int nCoef,
39 	const short *coef,
40 	const unsigned char *ibuff,/* input buffer[blockAlign]   */
41 	SAMPL *obuff,       /* output samples, n*chans    */
42 	int n               /* samples to decode PER channel, REQUIRE n % 8 == 1  */
43 );
44 
45 extern void lsx_ms_adpcm_block_mash_i(
46 	unsigned chans,          /* total channels */
47 	const SAMPL *ip,    /* ip[n*chans] is interleaved input samples */
48 	int n,              /* samples to encode PER channel, REQUIRE */
49 	int *st,            /* input/output steps, 16<=st[i] */
50 	unsigned char *obuff,      /* output buffer[blockAlign] */
51 	int blockAlign      /* >= 7*chans + n/2          */
52 );
53 
54 /* Some helper functions for computing samples/block and blockalign */
55 
56 /*
57  * lsx_ms_adpcm_samples_in(dataLen, chans, blockAlign, samplesPerBlock)
58  *  returns the number of samples/channel which would be
59  *  in the dataLen, given the other parameters ...
60  *  if input samplesPerBlock is 0, then returns the max
61  *  samplesPerBlock which would go into a block of size blockAlign
62  *  Yes, it is confusing usage.
63  */
64 extern size_t lsx_ms_adpcm_samples_in(
65 	size_t dataLen,
66 	size_t chans,
67 	size_t blockAlign,
68 	size_t samplesPerBlock
69 );
70 
71 /*
72  * size_t lsx_ms_adpcm_bytes_per_block(chans, samplesPerBlock)
73  *   return minimum blocksize which would be required
74  *   to encode number of chans with given samplesPerBlock
75  */
76 extern size_t lsx_ms_adpcm_bytes_per_block(
77 	size_t chans,
78 	size_t samplesPerBlock
79 );
80