Rename some ima_oki_adpcm identifiers to reduce the possibility of symbol collision.

This commit is contained in:
Erik de Castro Lopo 2007-12-02 21:17:27 +11:00
parent fca4fb880e
commit df70be47b4
3 changed files with 25 additions and 31 deletions

View File

@ -26,6 +26,9 @@
#include "ima_oki_adpcm.h"
#define MIN_SAMPLE -0x8000
#define MAX_SAMPLE 0x7fff
static int const ima_steps [] = /* ~16-bit precision */
{ 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230,
@ -46,11 +49,11 @@ static int const oki_steps [] = /* ~12-bit precision */
static int const step_changes [] = { -1, -1, -1, -1, 2, 4, 6, 8 } ;
void
adpcm_init (IMA_OKI_ADPCM * state, adpcm_type type)
ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type)
{
memset (state, 0, sizeof (*state)) ;
if (type == ADPCM_IMA)
if (type == IMA_OKI_ADPCM_TYPE_IMA)
{ state->max_step_index = ARRAY_LEN (ima_steps) - 1 ;
state->steps = ima_steps ;
state->mask = (~0) ;
@ -61,10 +64,8 @@ adpcm_init (IMA_OKI_ADPCM * state, adpcm_type type)
state->mask = (~0) << 4 ;
} ;
} /* adpcm_init */
} /* ima_oki_adpcm_init */
#define MIN_SAMPLE -0x8000
#define MAX_SAMPLE 0x7fff
int
adpcm_decode (IMA_OKI_ADPCM * state, int code)
@ -115,7 +116,7 @@ adpcm_encode (IMA_OKI_ADPCM * state, int sample)
void
adpcm_decode_block (IMA_OKI_ADPCM * state)
ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state)
{ unsigned char code ;
int k ;
@ -126,11 +127,11 @@ adpcm_decode_block (IMA_OKI_ADPCM * state)
} ;
state->pcm_count = 2 * k ;
} /* adpcm_decode_block */
} /* ima_oki_adpcm_decode_block */
void
adpcm_encode_block (IMA_OKI_ADPCM * state)
ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state)
{ unsigned char code ;
int k ;
@ -141,7 +142,7 @@ adpcm_encode_block (IMA_OKI_ADPCM * state)
} ;
state->code_count = k ;
} /* adpcm_encode_block */
} /* ima_oki_adpcm_encode_block */
#ifdef TEST
@ -182,7 +183,7 @@ test_oki_adpcm (void)
printf (" Testing encoder : ") ;
fflush (stdout) ;
adpcm_init (&adpcm, ADPCM_OKI) ;
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
for (i = 0 ; i < ARRAY_LEN (test_codes) ; i++)
for (j = 0, code = test_codes [i] ; j < 2 ; j++, code <<= 4)
if (adpcm_decode (&adpcm, code >> 4) != test_pcm [2 * i + j])
@ -195,7 +196,7 @@ test_oki_adpcm (void)
printf (" Testing decoder : ") ;
fflush (stdout) ;
adpcm_init (&adpcm, ADPCM_OKI) ;
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
for (i = 0 ; i < ARRAY_LEN (test_pcm) ; i += j)
{ code = adpcm_encode (&adpcm, test_pcm [i]) ;
code = (code << 4) | adpcm_encode (&adpcm, test_pcm [i + 1]) ;
@ -227,13 +228,13 @@ test_oki_adpcm_block (void)
printf (" Testing block encoder : ") ;
fflush (stdout) ;
adpcm_init (&adpcm, ADPCM_OKI) ;
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
memcpy (adpcm.pcm, test_pcm, sizeof (adpcm.pcm [0]) * ARRAY_LEN (test_pcm)) ;
adpcm.pcm_count = ARRAY_LEN (test_pcm) ;
adpcm.code_count = 13 ;
adpcm_encode_block (&adpcm) ;
ima_oki_adpcm_encode_block (&adpcm) ;
if (adpcm.code_count * 2 != ARRAY_LEN (test_pcm))
{ printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.code_count * 2, ARRAY_LEN (test_pcm)) ;
@ -251,13 +252,13 @@ test_oki_adpcm_block (void)
printf (" Testing block decoder : ") ;
fflush (stdout) ;
adpcm_init (&adpcm, ADPCM_OKI) ;
ima_oki_adpcm_init (&adpcm, IMA_OKI_ADPCM_TYPE_OKI) ;
memcpy (adpcm.codes, test_codes, sizeof (adpcm.codes [0]) * ARRAY_LEN (test_codes)) ;
adpcm.code_count = ARRAY_LEN (test_codes) ;
adpcm.pcm_count = 13 ;
adpcm_decode_block (&adpcm) ;
ima_oki_adpcm_decode_block (&adpcm) ;
if (adpcm.pcm_count != 2 * ARRAY_LEN (test_codes))
{ printf ("\n\nLine %d : %d * 2 != %d\n\n", __LINE__, adpcm.pcm_count, 2 * ARRAY_LEN (test_codes)) ;

View File

@ -41,13 +41,14 @@ typedef struct
} IMA_OKI_ADPCM ;
typedef enum
{ ADPCM_IMA,
ADPCM_OKI
} adpcm_type ;
{ IMA_OKI_ADPCM_TYPE_IMA,
IMA_OKI_ADPCM_TYPE_OKI
} IMA_OKI_ADPCM_TYPE ;
void ima_oki_adpcm_init (IMA_OKI_ADPCM * state, IMA_OKI_ADPCM_TYPE type) ;
void adpcm_init (IMA_OKI_ADPCM * state, adpcm_type type) ;
int adpcm_decode (IMA_OKI_ADPCM * state, int /* 0..15 */ code) ;
int adpcm_encode (IMA_OKI_ADPCM * state, int /* -32768..32767 */ sample) ;
void adpcm_decode_block (IMA_OKI_ADPCM * state) ;
void adpcm_encode_block (IMA_OKI_ADPCM * state) ;
void ima_oki_adpcm_decode_block (IMA_OKI_ADPCM * state) ;
void ima_oki_adpcm_encode_block (IMA_OKI_ADPCM * state) ;

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2002-2007 Erik de Castro Lopo <erikd@mega-nerd.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
@ -127,7 +127,7 @@ vox_adpcm_init (SF_PRIVATE *psf)
if (psf_fseek (psf, 0 , SEEK_SET) == -1)
return SFE_BAD_SEEK ;
adpcm_init (&pvox->codec, ADPCM_OKI) ;
ima_oki_adpcm_init (&pvox->codec, IMA_OKI_ADPCM_TYPE_OKI) ;
return 0 ;
} /* vox_adpcm_init */
@ -445,11 +445,3 @@ vox_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
return total ;
} /* vox_write_d */
/*
** Do not edit or modify anything in this comment block.
** The arch-tag line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: e15e97fe-ff9d-4b46-a489-7059fb2d0b1e
*/