WebRtc_Word32 => int32_t etc. in audio_coding/

BUG=314

Review URL: https://webrtc-codereview.appspot.com/1271006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3789 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2013-04-09 00:28:06 +00:00
parent 6faf71d27b
commit 0946a56023
382 changed files with 8469 additions and 8488 deletions

View File

@ -49,12 +49,12 @@
#define TRUE (!FALSE)
#endif
static __inline WebRtc_Word16 saturate(WebRtc_Word32 amp)
static __inline int16_t saturate(int32_t amp)
{
WebRtc_Word16 amp16;
int16_t amp16;
/* Hopefully this is optimised for the common case - not clipping */
amp16 = (WebRtc_Word16) amp;
amp16 = (int16_t) amp;
if (amp == amp16)
return amp16;
if (amp > WEBRTC_INT16_MAX)
@ -190,8 +190,8 @@ int WebRtc_g722_decode_release(g722_decode_state_t *s)
}
/*- End of function --------------------------------------------------------*/
int WebRtc_g722_decode(g722_decode_state_t *s, WebRtc_Word16 amp[],
const WebRtc_UWord8 g722_data[], int len)
int WebRtc_g722_decode(g722_decode_state_t *s, int16_t amp[],
const uint8_t g722_data[], int len)
{
static const int wl[8] = {-60, -30, 58, 172, 334, 538, 1198, 3042 };
static const int rl42[16] = {0, 7, 6, 5, 4, 3, 2, 1,
@ -372,14 +372,14 @@ int WebRtc_g722_decode(g722_decode_state_t *s, WebRtc_Word16 amp[],
if (s->itu_test_mode)
{
amp[outlen++] = (WebRtc_Word16) (rlow << 1);
amp[outlen++] = (WebRtc_Word16) (rhigh << 1);
amp[outlen++] = (int16_t) (rlow << 1);
amp[outlen++] = (int16_t) (rhigh << 1);
}
else
{
if (s->eight_k)
{
amp[outlen++] = (WebRtc_Word16) (rlow << 1);
amp[outlen++] = (int16_t) (rlow << 1);
}
else
{

View File

@ -138,8 +138,8 @@ g722_encode_state_t *WebRtc_g722_encode_init(g722_encode_state_t *s,
int options);
int WebRtc_g722_encode_release(g722_encode_state_t *s);
int WebRtc_g722_encode(g722_encode_state_t *s,
WebRtc_UWord8 g722_data[],
const WebRtc_Word16 amp[],
uint8_t g722_data[],
const int16_t amp[],
int len);
g722_decode_state_t *WebRtc_g722_decode_init(g722_decode_state_t *s,
@ -147,8 +147,8 @@ g722_decode_state_t *WebRtc_g722_decode_init(g722_decode_state_t *s,
int options);
int WebRtc_g722_decode_release(g722_decode_state_t *s);
int WebRtc_g722_decode(g722_decode_state_t *s,
WebRtc_Word16 amp[],
const WebRtc_UWord8 g722_data[],
int16_t amp[],
const uint8_t g722_data[],
int len);
#ifdef __cplusplus

View File

@ -48,12 +48,12 @@
#define TRUE (!FALSE)
#endif
static __inline WebRtc_Word16 saturate(WebRtc_Word32 amp)
static __inline int16_t saturate(int32_t amp)
{
WebRtc_Word16 amp16;
int16_t amp16;
/* Hopefully this is optimised for the common case - not clipping */
amp16 = (WebRtc_Word16) amp;
amp16 = (int16_t) amp;
if (amp == amp16)
return amp16;
if (amp > WEBRTC_INT16_MAX)
@ -191,10 +191,10 @@ int WebRtc_g722_encode_release(g722_encode_state_t *s)
*/
//#define RUN_LIKE_REFERENCE_G722
#ifdef RUN_LIKE_REFERENCE_G722
WebRtc_Word16 limitValues (WebRtc_Word16 rl)
int16_t limitValues (int16_t rl)
{
WebRtc_Word16 yl;
int16_t yl;
yl = (rl > 16383) ? 16383 : ((rl < -16384) ? -16384 : rl);
@ -202,8 +202,8 @@ WebRtc_Word16 limitValues (WebRtc_Word16 rl)
}
#endif
int WebRtc_g722_encode(g722_encode_state_t *s, WebRtc_UWord8 g722_data[],
const WebRtc_Word16 amp[], int len)
int WebRtc_g722_encode(g722_encode_state_t *s, uint8_t g722_data[],
const int16_t amp[], int len)
{
static const int q6[32] =
{
@ -418,14 +418,14 @@ int WebRtc_g722_encode(g722_encode_state_t *s, WebRtc_UWord8 g722_data[],
s->out_bits += s->bits_per_sample;
if (s->out_bits >= 8)
{
g722_data[g722_bytes++] = (WebRtc_UWord8) (s->out_buffer & 0xFF);
g722_data[g722_bytes++] = (uint8_t) (s->out_buffer & 0xFF);
s->out_bits -= 8;
s->out_buffer >>= 8;
}
}
else
{
g722_data[g722_bytes++] = (WebRtc_UWord8) code;
g722_data[g722_bytes++] = (uint8_t) code;
}
}
return g722_bytes;

View File

@ -17,7 +17,7 @@
#include "typedefs.h"
WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst)
int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst)
{
*G722enc_inst=(G722EncInst*)malloc(sizeof(g722_encode_state_t));
if (*G722enc_inst!=NULL) {
@ -27,7 +27,7 @@ WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst)
}
}
WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst)
int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst)
{
// Create and/or reset the G.722 encoder
// Bitrate 64 kbps and wideband mode (2)
@ -40,16 +40,16 @@ WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst)
}
}
WebRtc_Word16 WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst)
int16_t WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst)
{
// Free encoder memory
return WebRtc_g722_encode_release((g722_encode_state_t*) G722enc_inst);
}
WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst,
WebRtc_Word16 *speechIn,
WebRtc_Word16 len,
WebRtc_Word16 *encoded)
int16_t WebRtcG722_Encode(G722EncInst *G722enc_inst,
int16_t *speechIn,
int16_t len,
int16_t *encoded)
{
unsigned char *codechar = (unsigned char*) encoded;
// Encode the input speech vector
@ -57,7 +57,7 @@ WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst,
codechar, speechIn, len);
}
WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst)
int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst)
{
*G722dec_inst=(G722DecInst*)malloc(sizeof(g722_decode_state_t));
if (*G722dec_inst!=NULL) {
@ -67,7 +67,7 @@ WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst)
}
}
WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst)
int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst)
{
// Create and/or reset the G.722 decoder
// Bitrate 64 kbps and wideband mode (2)
@ -80,25 +80,25 @@ WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst)
}
}
WebRtc_Word16 WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst)
int16_t WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst)
{
// Free encoder memory
return WebRtc_g722_decode_release((g722_decode_state_t*) G722dec_inst);
}
WebRtc_Word16 WebRtcG722_Decode(G722DecInst *G722dec_inst,
WebRtc_Word16 *encoded,
WebRtc_Word16 len,
WebRtc_Word16 *decoded,
WebRtc_Word16 *speechType)
int16_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
int16_t *encoded,
int16_t len,
int16_t *decoded,
int16_t *speechType)
{
// Decode the G.722 encoder stream
*speechType=G722_WEBRTC_SPEECH;
return WebRtc_g722_decode((g722_decode_state_t*) G722dec_inst,
decoded, (WebRtc_UWord8*) encoded, len);
decoded, (uint8_t*) encoded, len);
}
WebRtc_Word16 WebRtcG722_Version(char *versionStr, short len)
int16_t WebRtcG722_Version(char *versionStr, short len)
{
// Get version string
char version[30] = "2.0.0\n";

View File

@ -43,7 +43,7 @@ extern "C" {
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
/****************************************************************************
@ -59,7 +59,7 @@ WebRtc_Word16 WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
/****************************************************************************
@ -73,7 +73,7 @@ WebRtc_Word16 WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
int16_t WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
@ -95,10 +95,10 @@ WebRtc_Word16 WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst,
WebRtc_Word16 *speechIn,
WebRtc_Word16 len,
WebRtc_Word16 *encoded);
int16_t WebRtcG722_Encode(G722EncInst *G722enc_inst,
int16_t *speechIn,
int16_t len,
int16_t *encoded);
/****************************************************************************
@ -112,7 +112,7 @@ WebRtc_Word16 WebRtcG722_Encode(G722EncInst *G722enc_inst,
* Return value : 0 - Ok
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
/****************************************************************************
@ -128,7 +128,7 @@ WebRtc_Word16 WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst);
int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst);
/****************************************************************************
@ -143,7 +143,7 @@ WebRtc_Word16 WebRtcG722_DecoderInit(G722DecInst *G722dec_inst);
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
int16_t WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
/****************************************************************************
@ -167,11 +167,11 @@ WebRtc_Word16 WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
* -1 - Error
*/
WebRtc_Word16 WebRtcG722_Decode(G722DecInst *G722dec_inst,
WebRtc_Word16 *encoded,
WebRtc_Word16 len,
WebRtc_Word16 *decoded,
WebRtc_Word16 *speechType);
int16_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
int16_t *encoded,
int16_t len,
int16_t *decoded,
int16_t *speechType);
/****************************************************************************
* WebRtcG722_Version(...)
@ -179,7 +179,7 @@ WebRtc_Word16 WebRtcG722_Decode(G722DecInst *G722dec_inst,
* Get a string with the current version of the codec
*/
WebRtc_Word16 WebRtcG722_Version(char *versionStr, short len);
int16_t WebRtcG722_Version(char *versionStr, short len);
#ifdef __cplusplus

View File

@ -29,11 +29,11 @@ typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
/* function for reading audio data from PCM file */
int readframe(WebRtc_Word16 *data, FILE *inp, int length)
int readframe(int16_t *data, FILE *inp, int length)
{
short k, rlen, status = 0;
rlen = (short)fread(data, sizeof(WebRtc_Word16), length, inp);
rlen = (short)fread(data, sizeof(int16_t), length, inp);
if (rlen < length) {
for (k = rlen; k < length; k++)
data[k] = 0;
@ -49,7 +49,7 @@ int main(int argc, char* argv[])
FILE *inp, *outbitp, *outp;
int framecnt, endfile;
WebRtc_Word16 framelength = 160;
int16_t framelength = 160;
G722EncInst *G722enc_inst;
G722DecInst *G722dec_inst;
int err;
@ -59,11 +59,11 @@ int main(int argc, char* argv[])
double runtime = 0;
double length_file;
WebRtc_Word16 stream_len = 0;
WebRtc_Word16 shortdata[960];
WebRtc_Word16 decoded[960];
WebRtc_Word16 streamdata[80*3];
WebRtc_Word16 speechType[1];
int16_t stream_len = 0;
int16_t shortdata[960];
int16_t decoded[960];
int16_t streamdata[80*3];
int16_t speechType[1];
/* handling wrong input arguments in the command line */
if (argc!=5) {