mirror of
https://github.com/xiph/opus.git
synced 2025-06-06 23:40:50 +00:00
Koen's decoder updates
This commit is contained in:
parent
9ed526cc84
commit
a70729c0b4
3 changed files with 20 additions and 12 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
AC_PREREQ([2.59])
|
AC_PREREQ([2.59])
|
||||||
AC_INIT(src/opus.h)
|
AC_INIT(src/opus.h)
|
||||||
AM_INIT_AUTOMAKE(opus,20110122)
|
AM_INIT_AUTOMAKE(opus,20110131)
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
|
@ -130,6 +130,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
|
|
||||||
if (st->mode != MODE_CELT_ONLY)
|
if (st->mode != MODE_CELT_ONLY)
|
||||||
{
|
{
|
||||||
|
SKP_int16 *pcm_ptr = pcm;
|
||||||
DecControl.API_sampleRate = st->Fs;
|
DecControl.API_sampleRate = st->Fs;
|
||||||
DecControl.payloadSize_ms = 1000 * audiosize / st->Fs;
|
DecControl.payloadSize_ms = 1000 * audiosize / st->Fs;
|
||||||
if( st->mode == MODE_SILK_ONLY ) {
|
if( st->mode == MODE_SILK_ONLY ) {
|
||||||
|
@ -147,15 +148,18 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
DecControl.internalSampleRate = 16000;
|
DecControl.internalSampleRate = 16000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We Should eventually have to set the bandwidth here */
|
/* FIXME: Add a check here to avoid a buffer overflow if there are more
|
||||||
|
samples in the SILK frame. In fact the TOC byte should tell us how many
|
||||||
/* Call SILK encoder for the low band */
|
frames there are */
|
||||||
silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, data == NULL, &dec, len, pcm, &silk_frame_size );
|
do {
|
||||||
if (silk_ret)
|
/* Call SILK decoder */
|
||||||
{
|
silk_ret = SKP_Silk_SDK_Decode( st->silk_dec, &DecControl, data == NULL, &dec, len, pcm_ptr, &silk_frame_size );
|
||||||
fprintf (stderr, "SILK decode error\n");
|
if( silk_ret ) {
|
||||||
/* Handle error */
|
fprintf (stderr, "SILK decode error\n");
|
||||||
}
|
/* Handle error */
|
||||||
|
}
|
||||||
|
pcm_ptr += silk_frame_size;
|
||||||
|
} while( DecControl.moreInternalDecoderFrames );
|
||||||
} else {
|
} else {
|
||||||
for (i=0;i<frame_size*st->channels;i++)
|
for (i=0;i<frame_size*st->channels;i++)
|
||||||
pcm[i] = 0;
|
pcm[i] = 0;
|
||||||
|
@ -169,7 +173,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
celt_decoder_ctl(st->celt_dec, CELT_SET_START_BAND(0));
|
celt_decoder_ctl(st->celt_dec, CELT_SET_START_BAND(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND)
|
if (st->mode != MODE_SILK_ONLY)
|
||||||
{
|
{
|
||||||
int endband;
|
int endband;
|
||||||
|
|
||||||
|
@ -194,7 +198,7 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
/* Encode high band with CELT */
|
/* Encode high band with CELT */
|
||||||
celt_ret = celt_decode_with_ec(st->celt_dec, data, len, pcm_celt, frame_size, &dec);
|
celt_ret = celt_decode_with_ec(st->celt_dec, data, len, pcm_celt, frame_size, &dec);
|
||||||
for (i=0;i<frame_size*st->channels;i++)
|
for (i=0;i<frame_size*st->channels;i++)
|
||||||
pcm[i] += pcm_celt[i];
|
pcm[i] = ADD_SAT16(pcm[i], pcm_celt[i]);
|
||||||
}
|
}
|
||||||
return celt_ret<0 ? celt_ret : audiosize;
|
return celt_ret<0 ? celt_ret : audiosize;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,10 @@ struct OpusDecoder {
|
||||||
int Fs;
|
int Fs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline short ADD_SAT16(a, b) {
|
||||||
|
int sum = a + b;
|
||||||
|
return sum > 32767 ? 32767 : sum < -32768 ? -32768 : (short)sum;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OPUS_DECODER_H */
|
#endif /* OPUS_DECODER_H */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue