1 /* 2 ** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com> 3 ** Copyright (c) 2007 <robs@users.sourceforge.net> 4 ** 5 ** This library is free software; you can redistribute it and/or modify it 6 ** under the terms of the GNU Lesser General Public License as published by 7 ** the Free Software Foundation; either version 2 of the License, or (at 8 ** your option) any later version. 9 ** 10 ** This library is distributed in the hope that it will be useful, but 11 ** WITHOUT ANY WARRANTY; without even the implied warranty of 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 13 ** General Public License for more details. 14 ** 15 ** You should have received a copy of the GNU Lesser General Public License 16 ** along with this library. If not, write to the Free Software Foundation, 17 ** Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301, USA. 18 */ 19 20 /* ADPCM: IMA, OKI <==> 16-bit PCM. */ 21 22 23 #define IMA_OKI_ADPCM_CODE_LEN 256 24 #define IMA_OKI_ADPCM_PCM_LEN (IMA_OKI_ADPCM_CODE_LEN *2) 25 26 typedef struct 27 { 28 /* private: */ 29 int mask ; 30 int last_output ; 31 int step_index ; 32 int max_step_index ; 33 int const * steps ; 34 35 /* public: */ 36 int errors ; 37 int code_count, pcm_count ; 38 39 unsigned char codes [IMA_OKI_ADPCM_CODE_LEN] ; 40 short pcm [IMA_OKI_ADPCM_PCM_LEN] ; 41 } IMA_OKI_ADPCM ; 42 43 typedef enum 44 { IMA_OKI_ADPCM_TYPE_IMA, 45 IMA_OKI_ADPCM_TYPE_OKI 46 } IMA_OKI_ADPCM_TYPE ; 47 48 void ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type) ; 49 50 int adpcm_decode (IMA_OKI_ADPCM * state, int /* 0..15 */ code) ; 51 int adpcm_encode (IMA_OKI_ADPCM * state, int /* -32768..32767 */ sample) ; 52 53 void ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state) ; 54 void ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) ; 55