Corrects many places where int was used where opus_int32 was needed.

This commit is contained in:
Gregory Maxwell 2011-09-02 10:31:17 -04:00
parent bafbd08db1
commit 64a3541aa9
10 changed files with 85 additions and 87 deletions

View file

@ -215,7 +215,7 @@ CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int
} }
#endif /* CUSTOM_MODES */ #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; int ret;
ret = opus_custom_encoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels); ret = opus_custom_encoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels);
@ -1928,7 +1928,7 @@ CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int
} }
#endif /* CUSTOM_MODES */ #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; int ret;
ret = opus_custom_decoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels); ret = opus_custom_decoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels);

View file

@ -85,7 +85,7 @@ extern "C" {
int celt_encoder_get_size(int channels); 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_encoder_init(CELTEncoder *st, int sampling_rate, int channels);
int celt_decoder_get_size(int channels); 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);
/* @} */ /* @} */

View file

@ -48,10 +48,9 @@ int main(int argc, char *argv[])
OpusCustomEncoder *enc; OpusCustomEncoder *enc;
OpusCustomDecoder *dec; OpusCustomDecoder *dec;
int len; int len;
opus_int32 frame_size, channels; opus_int32 frame_size, channels, rate;
int bytes_per_packet; int bytes_per_packet;
unsigned char data[MAX_PACKET]; unsigned char data[MAX_PACKET];
int rate;
int complexity; int complexity;
#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) #if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH)
int i; int i;
@ -68,7 +67,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
rate = atoi(argv[1]); rate = (opus_int32)atol(argv[1]);
channels = atoi(argv[2]); channels = atoi(argv[2]);
frame_size = atoi(argv[3]); frame_size = atoi(argv[3]);
mode = opus_custom_mode_create(rate, frame_size, NULL); mode = opus_custom_mode_create(rate, frame_size, NULL);

View file

@ -56,7 +56,7 @@ typedef struct {
/* Get size in bytes of the Silk encoder state */ /* Get size in bytes of the Silk encoder state */
/***********************************************/ /***********************************************/
opus_int silk_Get_Encoder_Size( /* O: Returns error code */ 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 @@ opus_int silk_Encode( /* O: Returns error c
const opus_int16 *samplesIn, /* I: Speech sample input vector */ const opus_int16 *samplesIn, /* I: Speech sample input vector */
opus_int nSamplesIn, /* I: Number of samples in input vector */ opus_int nSamplesIn, /* I: Number of samples in input vector */
ec_enc *psRangeEnc, /* I/O Compressor data structure */ 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 */ const opus_int prefillFlag /* I: Flag to indicate prefilling buffers no coding */
); );
@ -98,7 +98,7 @@ opus_int silk_Encode( /* O: Returns error c
/* Get size in bytes of the Silk decoder state */ /* Get size in bytes of the Silk decoder state */
/***********************************************/ /***********************************************/
opus_int silk_Get_Decoder_Size( /* O: Returns error code */ 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 */
); );
/*************************/ /*************************/

View file

@ -45,7 +45,7 @@ typedef struct {
/* Decoder functions */ /* 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; opus_int ret = SILK_NO_ERROR;
@ -84,7 +84,7 @@ opus_int silk_Decode(
opus_int32 nSamplesOutDec, LBRR_symbol; opus_int32 nSamplesOutDec, LBRR_symbol;
opus_int16 samplesOut1_tmp[ 2 ][ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS + 2 ]; 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_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; opus_int16 *resample_out_ptr;
silk_decoder *psDec = ( silk_decoder * )decState; silk_decoder *psDec = ( silk_decoder * )decState;
silk_decoder_state *channel_state = psDec->channel_state; silk_decoder_state *channel_state = psDec->channel_state;

View file

@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* Encoder functions */ /* 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; opus_int ret = SILK_NO_ERROR;
@ -128,7 +128,7 @@ opus_int silk_Encode(
const opus_int16 *samplesIn, /* I: Speech sample input vector */ const opus_int16 *samplesIn, /* I: Speech sample input vector */
opus_int nSamplesIn, /* I: Number of samples in input vector */ opus_int nSamplesIn, /* I: Number of samples in input vector */
ec_enc *psRangeEnc, /* I/O Compressor data structure */ 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 */ const opus_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */
) )
{ {

View file

@ -75,7 +75,7 @@ OPUS_EXPORT int opus_encoder_get_size(int channels);
/* Returns initialized encoder state */ /* Returns initialized encoder state */
OPUS_EXPORT OpusEncoder *opus_encoder_create( 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 channels, /* Number of channels (1/2) in input signal */
int application, /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */ int application, /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
int *error /* Error code */ int *error /* Error code */
@ -83,7 +83,7 @@ OPUS_EXPORT OpusEncoder *opus_encoder_create(
OPUS_EXPORT int opus_encoder_init( OPUS_EXPORT int opus_encoder_init(
OpusEncoder *st, /* Encoder state */ 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 channels, /* Number of channels (1/2) in input signal */
int application /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */ int application /* Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO) */
); );
@ -115,13 +115,13 @@ OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...);
OPUS_EXPORT int opus_decoder_get_size(int channels); OPUS_EXPORT int opus_decoder_get_size(int channels);
OPUS_EXPORT OpusDecoder *opus_decoder_create( 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 channels, /* Number of channels (1/2) in output signal */
int *error /* Error code*/ int *error /* Error code*/
); );
OPUS_EXPORT int opus_decoder_init(OpusDecoder *st, 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 */ int channels /* Number of channels (1/2) in output signal */
); );
@ -156,7 +156,7 @@ OPUS_EXPORT int opus_packet_parse(const unsigned char *data, int len,
short size[48], int *payload_offset); short size[48], int *payload_offset);
OPUS_EXPORT int opus_packet_get_bandwidth(const unsigned char *data); 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_channels(const unsigned char *data);
OPUS_EXPORT int opus_packet_get_nb_frames(const unsigned char packet[], int len); 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); OPUS_EXPORT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], int len);

View file

@ -44,7 +44,7 @@ struct OpusDecoder {
int celt_dec_offset; int celt_dec_offset;
int silk_dec_offset; int silk_dec_offset;
int channels; 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 */ /* Everything beyond this point gets cleared on a reset */
#define OPUS_DECODER_RESET_START stream_channels #define OPUS_DECODER_RESET_START stream_channels
@ -56,7 +56,7 @@ struct OpusDecoder {
int frame_size; int frame_size;
int prev_redundancy; int prev_redundancy;
int rangeFinal; opus_uint32 rangeFinal;
}; };
#ifdef FIXED_POINT #ifdef FIXED_POINT
@ -76,10 +76,9 @@ int opus_decoder_get_size(int channels)
silkDecSizeBytes = align(silkDecSizeBytes); silkDecSizeBytes = align(silkDecSizeBytes);
celtDecSizeBytes = celt_decoder_get_size(channels); celtDecSizeBytes = celt_decoder_get_size(channels);
return align(sizeof(OpusDecoder))+silkDecSizeBytes+celtDecSizeBytes; 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; void *silk_dec;
CELTDecoder *celt_dec; CELTDecoder *celt_dec;
@ -122,7 +121,7 @@ failure:
return OPUS_INTERNAL_ERROR; 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; int ret;
OpusDecoder *st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels)); OpusDecoder *st = (OpusDecoder *)opus_alloc(opus_decoder_get_size(channels));
@ -142,7 +141,7 @@ OpusDecoder *opus_decoder_create(int Fs, int channels, int *error)
} }
static void smooth_fade(const opus_val16 *in1, const opus_val16 *in2, opus_val16 *out, 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 i, c;
int inc = 48000/Fs; int inc = 48000/Fs;
@ -806,7 +805,7 @@ int opus_packet_get_bandwidth(const unsigned char *data)
return bandwidth; 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) if (data[0]&0x80)
@ -859,4 +858,3 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char pack
else else
return samples; return samples;
} }

View file

@ -61,7 +61,7 @@ struct OpusEncoder {
int signal_type; int signal_type;
int user_bandwidth; int user_bandwidth;
int voice_ratio; int voice_ratio;
int Fs; opus_int32 Fs;
int use_vbr; int use_vbr;
int vbr_constraint; int vbr_constraint;
int bitrate_bps; int bitrate_bps;
@ -80,19 +80,19 @@ struct OpusEncoder {
int first; int first;
opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2]; 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 /* Transition tables for the voice and audio modes. First column is the
middle (memoriless) threshold. The second column is the hysteresis middle (memoriless) threshold. The second column is the hysteresis
(difference with the middle) */ (difference with the middle) */
static const int voice_bandwidth_thresholds[10] = { static const opus_int32 voice_bandwidth_thresholds[10] = {
11000, 1000, /* NB<->MB */ 11000, 1000, /* NB<->MB */
14000, 1000, /* MB<->WB */ 14000, 1000, /* MB<->WB */
21000, 2000, /* WB<->SWB */ 21000, 2000, /* WB<->SWB */
29000, 2000, /* SWB<->FB */ 29000, 2000, /* SWB<->FB */
}; };
static const int audio_bandwidth_thresholds[10] = { static const opus_int32 audio_bandwidth_thresholds[10] = {
30000, 0, /* MB not allowed */ 30000, 0, /* MB not allowed */
20000, 2000, /* MB<->WB */ 20000, 2000, /* MB<->WB */
26000, 2000, /* WB<->SWB */ 26000, 2000, /* WB<->SWB */
@ -112,7 +112,7 @@ int opus_encoder_get_size(int channels)
return align(sizeof(OpusEncoder))+silkEncSizeBytes+celtEncSizeBytes; 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; void *silk_enc;
CELTEncoder *celt_enc; CELTEncoder *celt_enc;
@ -306,7 +306,7 @@ static void hp_cutoff(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *ou
#endif #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; int ret;
OpusEncoder *st = (OpusEncoder *)opus_alloc(opus_encoder_get_size(channels)); OpusEncoder *st = (OpusEncoder *)opus_alloc(opus_encoder_get_size(channels));
@ -491,7 +491,7 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
/* Automatic (rate-dependent) bandwidth selection */ /* Automatic (rate-dependent) bandwidth selection */
if (st->mode == MODE_CELT_ONLY || st->first || st->silk_mode.allowBandwidthSwitch) 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; int bandwidth = OPUS_BANDWIDTH_FULLBAND;
bandwidth_thresholds = st->mode == MODE_CELT_ONLY ? audio_bandwidth_thresholds : voice_bandwidth_thresholds; bandwidth_thresholds = st->mode == MODE_CELT_ONLY ? audio_bandwidth_thresholds : voice_bandwidth_thresholds;

View file

@ -90,9 +90,9 @@ int main(int argc, char *argv[])
int args; int args;
int len[2]; int len[2];
int frame_size, channels; int frame_size, channels;
int bitrate_bps; opus_int32 bitrate_bps;
unsigned char *data[2]; unsigned char *data[2];
int sampling_rate; opus_int32 sampling_rate;
int use_vbr; int use_vbr;
int max_payload_bytes; int max_payload_bytes;
int complexity; int complexity;
@ -101,7 +101,8 @@ int main(int argc, char *argv[])
int forcemono; int forcemono;
int cvbr = 0; int cvbr = 0;
int packet_loss_perc; int packet_loss_perc;
int count=0, count_act=0, k; opus_int32 count=0, count_act=0;
int k;
int skip; int skip;
int stop=0; int stop=0;
short *in, *out; short *in, *out;
@ -137,9 +138,9 @@ int main(int argc, char *argv[])
argc--; argc--;
} }
application = atoi(argv[1]) + OPUS_APPLICATION_VOIP; application = atoi(argv[1]) + OPUS_APPLICATION_VOIP;
sampling_rate = atoi(argv[2]); sampling_rate = (opus_int32)atol(argv[2]);
channels = atoi(argv[3]); 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 if (sampling_rate != 8000 && sampling_rate != 12000 && sampling_rate != 16000
&& sampling_rate != 24000 && sampling_rate != 48000) && sampling_rate != 24000 && sampling_rate != 48000)
@ -321,7 +322,7 @@ int main(int argc, char *argv[])
break; 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)); in = (short*)malloc(frame_size*channels*sizeof(short));
out = (short*)malloc(max_frame_size*channels*sizeof(short)); out = (short*)malloc(max_frame_size*channels*sizeof(short));
@ -409,7 +410,7 @@ int main(int argc, char *argv[])
/* compare final range encoder rng values of encoder and decoder */ /* compare final range encoder rng values of encoder and decoder */
if( enc_final_range[toggle^use_inbandfec]!=0 && !encode_only && !lost && !lost_prev && if( enc_final_range[toggle^use_inbandfec]!=0 && !encode_only && !lost && !lost_prev &&
dec_final_range != enc_final_range[toggle^use_inbandfec] ) { 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; return 0;
} }