Merge remote-tracking branch 'greg/master'

Conflicts:
	src/opus_encoder.c
This commit is contained in:
Jean-Marc Valin 2011-09-02 17:23:22 -04:00
commit 6268300c5e
10 changed files with 82 additions and 84 deletions

View file

@ -215,7 +215,7 @@ CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int
}
#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 @@ CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int
}
#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);

View file

@ -85,7 +85,7 @@ extern "C" {
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_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;
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 @@ int main(int argc, char *argv[])
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);

View file

@ -56,7 +56,7 @@ typedef struct {
/* 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 @@ opus_int silk_Encode( /* O: Returns error c
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 @@ opus_int silk_Encode( /* O: Returns error c
/* 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 */
);
/*************************/

View file

@ -45,7 +45,7 @@ typedef struct {
/* 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_int silk_Decode(
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;

View file

@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/* 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 @@ opus_int silk_Encode(
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 */
)
{

View file

@ -75,7 +75,7 @@ OPUS_EXPORT int opus_encoder_get_size(int channels);
/* 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 OpusEncoder *opus_encoder_create(
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_encoder_ctl(OpusEncoder *st, int request, ...);
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 @@ OPUS_EXPORT int opus_packet_parse(const unsigned char *data, int len,
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);

View file

@ -44,7 +44,7 @@ struct OpusDecoder {
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 @@ struct OpusDecoder {
int frame_size;
int prev_redundancy;
int rangeFinal;
opus_uint32 rangeFinal;
};
#ifdef FIXED_POINT
@ -76,10 +76,9 @@ int opus_decoder_get_size(int channels)
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;
@ -122,7 +121,7 @@ failure:
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 @@ 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,
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;
@ -806,7 +805,7 @@ int opus_packet_get_bandwidth(const unsigned char *data)
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;
if (data[0]&0x80)
@ -859,4 +858,3 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char pack
else
return samples;
}

View file

@ -61,7 +61,7 @@ struct OpusEncoder {
int signal_type;
int user_bandwidth;
int voice_ratio;
int Fs;
opus_int32 Fs;
int use_vbr;
int vbr_constraint;
int bitrate_bps;
@ -80,7 +80,7 @@ struct OpusEncoder {
int first;
opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2];
int rangeFinal;
opus_uint32 rangeFinal;
};
/* Transition tables for the voice and music. First column is the
@ -132,7 +132,7 @@ int opus_encoder_get_size(int channels)
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;
@ -326,7 +326,7 @@ static void hp_cutoff(const opus_val16 *in, opus_int32 cutoff_Hz, opus_val16 *ou
#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));

View file

@ -90,9 +90,9 @@ int main(int argc, char *argv[])
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 main(int argc, char *argv[])
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;
@ -138,9 +139,9 @@ int main(int argc, char *argv[])
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)
@ -325,7 +326,7 @@ int main(int argc, char *argv[])
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));
@ -421,7 +422,7 @@ int main(int argc, char *argv[])
/* 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;
}