ref: 64a3541aa9912d9f60684c7e2fde19e86d41907a
parent: bafbd08db132d387bcef0637258f90e862a8e4ea
author: Gregory Maxwell <[email protected]>
date: Fri Sep 2 06:31:17 EDT 2011
Corrects many places where int was used where opus_int32 was needed.
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -215,7 +215,7 @@
}
#endif /* CUSTOM_MODES */
-int celt_encoder_init(CELTEncoder *st, int sampling_rate, int channels)
+int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels)
{
int ret;
ret = opus_custom_encoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels);
@@ -1928,7 +1928,7 @@
}
#endif /* CUSTOM_MODES */
-int celt_decoder_init(CELTDecoder *st, int sampling_rate, int channels)
+int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels)
{
int ret;
ret = opus_custom_decoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels);
--- a/libcelt/celt.h
+++ b/libcelt/celt.h
@@ -85,7 +85,7 @@
int celt_encoder_get_size(int channels);
-int celt_encoder_init(CELTEncoder *st, int sampling_rate, int channels);
+int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels);
@@ -94,7 +94,7 @@
int celt_decoder_get_size(int channels);
-int celt_decoder_init(CELTDecoder *st, int sampling_rate, int channels);
+int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels);
/* @} */
--- a/libcelt/test_opus_custom.c
+++ b/libcelt/test_opus_custom.c
@@ -48,10 +48,9 @@
OpusCustomEncoder *enc;
OpusCustomDecoder *dec;
int len;
- opus_int32 frame_size, channels;
+ opus_int32 frame_size, channels, rate;
int bytes_per_packet;
unsigned char data[MAX_PACKET];
- int rate;
int complexity;
#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH)
int i;
@@ -68,7 +67,7 @@
return 1;
}
- rate = atoi(argv[1]);
+ rate = (opus_int32)atol(argv[1]);
channels = atoi(argv[2]);
frame_size = atoi(argv[3]);
mode = opus_custom_mode_create(rate, frame_size, NULL);
--- a/silk/silk_API.h
+++ b/silk/silk_API.h
@@ -56,7 +56,7 @@
/* Get size in bytes of the Silk encoder state */
/***********************************************/
opus_int silk_Get_Encoder_Size( /* O: Returns error code */
- opus_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */
+ int *encSizeBytes /* O: Number of bytes in SILK encoder state */
);
/*************************/
@@ -86,7 +86,7 @@
const opus_int16 *samplesIn, /* I: Speech sample input vector */
opus_int nSamplesIn, /* I: Number of samples in input vector */
ec_enc *psRangeEnc, /* I/O Compressor data structure */
- opus_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
+ opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
const opus_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
);
@@ -98,7 +98,7 @@
/* Get size in bytes of the Silk decoder state */
/***********************************************/
opus_int silk_Get_Decoder_Size( /* O: Returns error code */
- opus_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */
+ int *decSizeBytes /* O: Number of bytes in SILK decoder state */
);
/*************************/
--- a/silk/silk_dec_API.c
+++ b/silk/silk_dec_API.c
@@ -45,7 +45,7 @@
/* Decoder functions */
/*********************/
-opus_int silk_Get_Decoder_Size( opus_int32 *decSizeBytes )
+opus_int silk_Get_Decoder_Size( int *decSizeBytes )
{
opus_int ret = SILK_NO_ERROR;
@@ -84,7 +84,7 @@
opus_int32 nSamplesOutDec, LBRR_symbol;
opus_int16 samplesOut1_tmp[ 2 ][ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS + 2 ];
opus_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
- opus_int MS_pred_Q13[ 2 ] = { 0 };
+ opus_int32 MS_pred_Q13[ 2 ] = { 0 };
opus_int16 *resample_out_ptr;
silk_decoder *psDec = ( silk_decoder * )decState;
silk_decoder_state *channel_state = psDec->channel_state;
--- a/silk/silk_enc_API.c
+++ b/silk/silk_enc_API.c
@@ -44,7 +44,7 @@
/* Encoder functions */
/****************************************/
-opus_int silk_Get_Encoder_Size( opus_int32 *encSizeBytes )
+opus_int silk_Get_Encoder_Size( int *encSizeBytes )
{
opus_int ret = SILK_NO_ERROR;
@@ -128,7 +128,7 @@
const opus_int16 *samplesIn, /* I: Speech sample input vector */
opus_int nSamplesIn, /* I: Number of samples in input vector */
ec_enc *psRangeEnc, /* I/O Compressor data structure */
- opus_int32 *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
+ opus_int *nBytesOut, /* I/O: Number of bytes in payload (input: Max bytes) */
const opus_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
)
{
--- a/src/opus.h
+++ b/src/opus.h
@@ -75,7 +75,7 @@
/* Returns initialized encoder state */
OPUS_EXPORT OpusEncoder *opus_encoder_create(
- int Fs, /* Sampling rate of input signal (Hz) */
+ opus_int32 Fs, /* Sampling rate of input signal (Hz) */
int channels, /* Number of channels (1/2) in input signal */
int application, /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
int *error /* Error code */
@@ -83,7 +83,7 @@
OPUS_EXPORT int opus_encoder_init(
OpusEncoder *st, /* Encoder state */
- int Fs, /* Sampling rate of input signal (Hz) */
+ opus_int32 Fs, /* Sampling rate of input signal (Hz) */
int channels, /* Number of channels (1/2) in input signal */
int application /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
);
@@ -115,13 +115,13 @@
OPUS_EXPORT int opus_decoder_get_size(int channels);
OPUS_EXPORT OpusDecoder *opus_decoder_create(
- int Fs, /* Sampling rate of output signal (Hz) */
+ opus_int32 Fs, /* Sampling rate of output signal (Hz) */
int channels, /* Number of channels (1/2) in output signal */
int *error /* Error code*/
);
OPUS_EXPORT int opus_decoder_init(OpusDecoder *st,
- int Fs, /* Sampling rate of output signal (Hz) */
+ opus_int32 Fs, /* Sampling rate of output signal (Hz) */
int channels /* Number of channels (1/2) in output signal */
);
@@ -156,7 +156,7 @@
short size[48], int *payload_offset);
OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data);
-OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, int Fs);
+OPUS_EXPORT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs);
OPUS_EXPORT int opus_packet_get_nb_channels(const unsigned char *data);
OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int len);
OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], int len);
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -44,7 +44,7 @@
int celt_dec_offset;
int silk_dec_offset;
int channels;
- int Fs; /** Sampling rate (at the API level) */
+ opus_int32 Fs; /** Sampling rate (at the API level) */
/* Everything beyond this point gets cleared on a reset */
#define OPUS_DECODER_RESET_START stream_channels
@@ -56,7 +56,7 @@
int frame_size;
int prev_redundancy;
- int rangeFinal;
+ opus_uint32 rangeFinal;
};
#ifdef FIXED_POINT
@@ -68,61 +68,60 @@
int opus_decoder_get_size(int channels)
{
- int silkDecSizeBytes, celtDecSizeBytes;
- int ret;
- ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
- if(ret)
- return 0;
- silkDecSizeBytes = align(silkDecSizeBytes);
- celtDecSizeBytes = celt_decoder_get_size(channels);
- return align(sizeof(OpusDecoder))+silkDecSizeBytes+celtDecSizeBytes;
-
+ int silkDecSizeBytes, celtDecSizeBytes;
+ int ret;
+ ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
+ if(ret)
+ return 0;
+ silkDecSizeBytes = align(silkDecSizeBytes);
+ celtDecSizeBytes = celt_decoder_get_size(channels);
+ return align(sizeof(OpusDecoder))+silkDecSizeBytes+celtDecSizeBytes;
}
-int opus_decoder_init(OpusDecoder *st, int Fs, int channels)
+int opus_decoder_init(OpusDecoder *st, opus_int32 Fs, int channels)
{
- void *silk_dec;
- CELTDecoder *celt_dec;
- int ret, silkDecSizeBytes;
+ void *silk_dec;
+ CELTDecoder *celt_dec;
+ int ret, silkDecSizeBytes;
- if (channels<1 || channels > 2)
- return OPUS_BAD_ARG;
- OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
- /* Initialize SILK encoder */
- ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
- if( ret ) {
- return OPUS_INTERNAL_ERROR;
- }
- silkDecSizeBytes = align(silkDecSizeBytes);
- st->silk_dec_offset = align(sizeof(OpusDecoder));
- st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes;
- silk_dec = (char*)st+st->silk_dec_offset;
- celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
- st->stream_channels = st->channels = channels;
+ if (channels<1 || channels > 2)
+ return OPUS_BAD_ARG;
+ OPUS_CLEAR((char*)st, opus_decoder_get_size(channels));
+ /* Initialize SILK encoder */
+ ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
+ if( ret ) {
+ return OPUS_INTERNAL_ERROR;
+ }
+ silkDecSizeBytes = align(silkDecSizeBytes);
+ st->silk_dec_offset = align(sizeof(OpusDecoder));
+ st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes;
+ silk_dec = (char*)st+st->silk_dec_offset;
+ celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);
+ st->stream_channels = st->channels = channels;
- st->Fs = Fs;
+ st->Fs = Fs;
- /* Reset decoder */
- ret = silk_InitDecoder( silk_dec );
- if( ret ) {
- goto failure;
- }
+ /* Reset decoder */
+ ret = silk_InitDecoder( silk_dec );
+ if( ret ) {
+ goto failure;
+ }
- /* Initialize CELT decoder */
- ret = celt_decoder_init(celt_dec, Fs, channels);
- if (ret != OPUS_OK)
- goto failure;
- celt_decoder_ctl(celt_dec, CELT_SET_SIGNALLING(0));
+ /* Initialize CELT decoder */
+ ret = celt_decoder_init(celt_dec, Fs, channels);
+ if (ret != OPUS_OK)
+ goto failure;
+ celt_decoder_ctl(celt_dec, CELT_SET_SIGNALLING(0));
- st->prev_mode = 0;
- st->frame_size = Fs/400;
- return OPUS_OK;
+ st->prev_mode = 0;
+ st->frame_size = Fs/400;
+ return OPUS_OK;
failure:
- opus_free(st);
- return OPUS_INTERNAL_ERROR;
+ opus_free(st);
+ return OPUS_INTERNAL_ERROR;
}
-OpusDecoder *opus_decoder_create(int Fs, int channels, int *error)
+OpusDecoder *opus_decoder_create(opus_int32 Fs, int channels, int *error)
{
int ret;
OpusDecoder *st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
@@ -142,7 +141,7 @@
}
static void smooth_fade(const opus_val16 *in1, const opus_val16 *in2, opus_val16 *out,
- int overlap, int channels, const opus_val16 *window, int Fs)
+ int overlap, int channels, const opus_val16 *window, opus_int32 Fs)
{
int i, c;
int inc = 48000/Fs;
@@ -176,10 +175,10 @@
static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
int len, opus_val16 *pcm, int frame_size, int decode_fec)
{
- void *silk_dec;
- CELTDecoder *celt_dec;
- int i, silk_ret=0, celt_ret=0;
- ec_dec dec;
+ void *silk_dec;
+ CELTDecoder *celt_dec;
+ int i, silk_ret=0, celt_ret=0;
+ ec_dec dec;
silk_DecControlStruct DecControl;
opus_int32 silk_frame_size;
VARDECL(opus_int16, pcm_silk);
@@ -806,9 +805,9 @@
return bandwidth;
}
-int opus_packet_get_samples_per_frame(const unsigned char *data, int Fs)
+int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs)
{
- int audiosize;
+ int audiosize;
if (data[0]&0x80)
{
audiosize = ((data[0]>>3)&0x3);
@@ -859,4 +858,3 @@
else
return samples;
}
-
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -61,7 +61,7 @@
int signal_type;
int user_bandwidth;
int voice_ratio;
- int Fs;
+ opus_int32 Fs;
int use_vbr;
int vbr_constraint;
int bitrate_bps;
@@ -80,19 +80,19 @@
int first;
opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2];
- int rangeFinal;
+ opus_uint32 rangeFinal;
};
/* Transition tables for the voice and audio modes. First column is the
middle (memoriless) threshold. The second column is the hysteresis
(difference with the middle) */
-static const int voice_bandwidth_thresholds[10] = {
+static const opus_int32 voice_bandwidth_thresholds[10] = {
11000, 1000, /* NB<->MB */
14000, 1000, /* MB<->WB */
21000, 2000, /* WB<->SWB */
29000, 2000, /* SWB<->FB */
};
-static const int audio_bandwidth_thresholds[10] = {
+static const opus_int32 audio_bandwidth_thresholds[10] = {
30000, 0, /* MB not allowed */
20000, 2000, /* MB<->WB */
26000, 2000, /* WB<->SWB */
@@ -112,7 +112,7 @@
return align(sizeof(OpusEncoder))+silkEncSizeBytes+celtEncSizeBytes;
}
-int opus_encoder_init(OpusEncoder* st, int Fs, int channels, int application)
+int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int application)
{
void *silk_enc;
CELTEncoder *celt_enc;
@@ -306,7 +306,7 @@
#endif
}
-OpusEncoder *opus_encoder_create(int Fs, int channels, int mode, int *error)
+OpusEncoder *opus_encoder_create(opus_int32 Fs, int channels, int mode, int *error)
{
int ret;
OpusEncoder *st = (OpusEncoder *)opus_alloc(opus_encoder_get_size(channels));
@@ -491,7 +491,7 @@
/* Automatic (rate-dependent) bandwidth selection */
if (st->mode == MODE_CELT_ONLY || st->first || st->silk_mode.allowBandwidthSwitch)
{
- const int *bandwidth_thresholds;
+ const opus_int32 *bandwidth_thresholds;
int bandwidth = OPUS_BANDWIDTH_FULLBAND;
bandwidth_thresholds = st->mode == MODE_CELT_ONLY ? audio_bandwidth_thresholds : voice_bandwidth_thresholds;
--- a/src/test_opus.c
+++ b/src/test_opus.c
@@ -90,9 +90,9 @@
int args;
int len[2];
int frame_size, channels;
- int bitrate_bps;
+ opus_int32 bitrate_bps;
unsigned char *data[2];
- int sampling_rate;
+ opus_int32 sampling_rate;
int use_vbr;
int max_payload_bytes;
int complexity;
@@ -101,7 +101,8 @@
int forcemono;
int cvbr = 0;
int packet_loss_perc;
- int count=0, count_act=0, k;
+ opus_int32 count=0, count_act=0;
+ int k;
int skip;
int stop=0;
short *in, *out;
@@ -137,9 +138,9 @@
argc--;
}
application = atoi(argv[1]) + OPUS_APPLICATION_VOIP;
- sampling_rate = atoi(argv[2]);
+ sampling_rate = (opus_int32)atol(argv[2]);
channels = atoi(argv[3]);
- bitrate_bps = atoi(argv[4]);
+ bitrate_bps = (opus_int32)atol(argv[4]);
if (sampling_rate != 8000 && sampling_rate != 12000 && sampling_rate != 16000
&& sampling_rate != 24000 && sampling_rate != 48000)
@@ -321,7 +322,7 @@
break;
}
- fprintf(stderr, "Encoding %d Hz input at %.3f kb/s in %s mode with %d-sample frames.\n", sampling_rate, bitrate_bps*0.001, bandwidth_string, frame_size);
+ fprintf(stderr, "Encoding %ld Hz input at %.3f kb/s in %s mode with %d-sample frames.\n", (long)sampling_rate, bitrate_bps*0.001, bandwidth_string, frame_size);
in = (short*)malloc(frame_size*channels*sizeof(short));
out = (short*)malloc(max_frame_size*channels*sizeof(short));
@@ -409,7 +410,7 @@
/* compare final range encoder rng values of encoder and decoder */
if( enc_final_range[toggle^use_inbandfec]!=0 && !encode_only && !lost && !lost_prev &&
dec_final_range != enc_final_range[toggle^use_inbandfec] ) {
- fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder in frame %d: 0x%8x vs 0x%8x\n", count, enc_final_range[toggle^use_inbandfec], dec_final_range);
+ fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder in frame %ld: 0x%8lx vs 0x%8lx\n", (long)count, (unsigned long)enc_final_range[toggle^use_inbandfec], (unsigned long)dec_final_range);
return 0;
}