Corrects many places where int was used where opus_int32 was needed.
This commit is contained in:
parent
bafbd08db1
commit
64a3541aa9
10 changed files with 85 additions and 87 deletions
|
@ -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
|
||||
|
@ -68,61 +68,60 @@ static inline opus_int16 SAT16(opus_int32 x) {
|
|||
|
||||
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 @@ 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;
|
||||
|
@ -176,10 +175,10 @@ static int opus_packet_get_mode(const unsigned char *data)
|
|||
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 @@ 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;
|
||||
int audiosize;
|
||||
if (data[0]&0x80)
|
||||
{
|
||||
audiosize = ((data[0]>>3)&0x3);
|
||||
|
@ -859,4 +858,3 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char pack
|
|||
else
|
||||
return samples;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue