Commit 17c59660 authored by Jean-Marc Valin's avatar Jean-Marc Valin

Last updates for draft -11

- Draft updates
- Updated code to produce and check test vectors
- Making sure that the test vectors pass at all rates as well as for mono and stereo
parent c4ff3a04
......@@ -20,7 +20,7 @@ CFLAGS := -Drestrict= $(CFLAGS)
###################### END OF OPTIONS ######################
CFLAGS += -DOPUS_VERSION='"0.9.8"'
CFLAGS += -DOPUS_VERSION='"0.9.9"'
include silk_sources.mk
include celt_sources.mk
include opus_sources.mk
......
......@@ -238,22 +238,22 @@ void anti_collapse(const CELTMode *m, celt_norm *X_, unsigned char *collapse_mas
celt_norm *X;
opus_val16 prev1;
opus_val16 prev2;
opus_val16 Ediff;
opus_val32 Ediff;
opus_val16 r;
int renormalize=0;
prev1 = prev1logE[c*m->nbEBands+i];
prev2 = prev2logE[c*m->nbEBands+i];
if (C<CC)
if (C==1)
{
prev1 = MAX16(prev1,prev1logE[m->nbEBands+i]);
prev2 = MAX16(prev2,prev2logE[m->nbEBands+i]);
}
Ediff = logE[c*m->nbEBands+i]-MIN16(prev1,prev2);
Ediff = EXTEND32(logE[c*m->nbEBands+i])-EXTEND32(MIN16(prev1,prev2));
Ediff = MAX16(0, Ediff);
#ifdef FIXED_POINT
if (Ediff < 16384)
r = 2*MIN16(16383,SHR32(celt_exp2(-Ediff),1));
r = 2*MIN16(16383,SHR32(celt_exp2(-EXTRACT16(Ediff)),1));
else
r = 0;
if (LM==3)
......
......@@ -2392,7 +2392,7 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
dec = &_dec;
}
if (C<CC)
if (C==1)
{
for (i=0;i<st->mode->nbEBands;i++)
oldBandE[i]=MAX16(oldBandE[i],oldBandE[st->mode->nbEBands+i]);
......
......@@ -9,7 +9,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
OPUS_MAJOR_VERSION=0
OPUS_MINOR_VERSION=9
OPUS_MICRO_VERSION=8
OPUS_MICRO_VERSION=9
OPUS_EXTRA_VERSION=
OPUS_VERSION="$OPUS_MAJOR_VERSION.$OPUS_MINOR_VERSION.$OPUS_MICRO_VERSION$OPUS_EXTRA_VERSION"
......
......@@ -50,6 +50,17 @@ cat opus_source.tar.gz| base64 | tr -d '\n' | fold -w 64 | \
#echo '</artwork>' >> opus_compare_escaped.c
#echo '</figure>' >> opus_compare_escaped.c
echo '<figure>' > testvectors_sha1
echo '<artwork>' >> testvectors_sha1
echo '<![CDATA[' >> testvectors_sha1
(cd ../opus_testvectors; sha1sum *.bit *.dec) >> testvectors_sha1
#cd opus_testvectors
#sha1sum *.bit *.dec >> ../testvectors_sha1
#cd ..
echo ']]>' >> testvectors_sha1
echo '</artwork>' >> testvectors_sha1
echo '</figure>' >> testvectors_sha1
echo running xml2rfc
xml2rfc draft-ietf-codec-opus.xml draft-ietf-codec-opus.html &
xml2rfc draft-ietf-codec-opus.xml
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -92,6 +92,7 @@ opus_int silk_Decode( /* O Returns error co
silk_decoder *psDec = ( silk_decoder * )decState;
silk_decoder_state *channel_state = psDec->channel_state;
opus_int has_side;
opus_int stereo_to_mono;
/**********************************/
/* Test if first frame in payload */
......@@ -107,6 +108,9 @@ opus_int silk_Decode( /* O Returns error co
ret += silk_init_decoder( &channel_state[ 1 ] );
}
stereo_to_mono = decControl->nChannelsInternal == 1 && psDec->nChannelsInternal == 2 &&
( decControl->internalSampleRate == 1000*channel_state[ 0 ].fs_kHz );
if( channel_state[ 0 ].nFramesDecoded == 0 ) {
for( n = 0; n < decControl->nChannelsInternal; n++ ) {
opus_int fs_kHz_dec;
......@@ -293,7 +297,7 @@ opus_int silk_Decode( /* O Returns error co
ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec );
/* Interleave if stereo output and stereo stream */
if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) {
if( decControl->nChannelsAPI == 2 ) {
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ n + 2 * i ] = resample_out_ptr[ i ];
}
......@@ -302,8 +306,18 @@ opus_int silk_Decode( /* O Returns error co
/* Create two channel output from mono stream */
if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 1 ) {
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ 0 + 2 * i ] = samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ];
if ( stereo_to_mono ){
/* Resample right channel for newly collapsed stereo just in case
we weren't doing collapsing when switching to mono */
ret += silk_resampler( &channel_state[ 1 ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ 0 ][ 1 ], nSamplesOutDec );
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ];
}
} else {
for( i = 0; i < *nSamplesOut; i++ ) {
samplesOut[ 1 + 2 * i ] = samplesOut[ 0 + 2 * i ];
}
}
}
......
......@@ -49,25 +49,9 @@ opus_int silk_decoder_set_fs(
/* Initialize resampler when switching internal or external sampling frequency */
if( psDec->fs_kHz != fs_kHz || psDec->fs_API_hz != fs_API_Hz ) {
/* Allocate worst case space for temporary upsampling, 8 to 48 kHz, so a factor 6 */
opus_int16 temp_buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
silk_resampler_state_struct temp_resampler_state;
if( psDec->fs_kHz != fs_kHz && psDec->fs_kHz > 0 ) {
/* Initialize resampler for temporary resampling of outBuf data to the new internal sampling rate */
ret += silk_resampler_init( &temp_resampler_state, silk_SMULBB( psDec->fs_kHz, 1000 ), silk_SMULBB( fs_kHz, 1000 ), 0 );
/* Temporary resampling of outBuf data to the new internal sampling rate */
silk_memcpy( temp_buf, psDec->outBuf, psDec->frame_length * sizeof( opus_int16 ) );
ret += silk_resampler( &temp_resampler_state, psDec->outBuf, temp_buf, psDec->frame_length );
}
/* Initialize the resampler for dec_API.c preparing resampling from fs_kHz to API_fs_Hz */
ret += silk_resampler_init( &psDec->resampler_state, silk_SMULBB( fs_kHz, 1000 ), fs_API_Hz, 0 );
/* Correct resampler state by resampling buffered data from fs_kHz to API_fs_Hz */
ret += silk_resampler( &psDec->resampler_state, temp_buf, psDec->outBuf, frame_length );
psDec->fs_API_hz = fs_API_Hz;
}
......
......@@ -133,7 +133,7 @@ static const int BANDS[NBANDS+1]={
};
#define TEST_WIN_SIZE (480)
#define TEST_WIN_STEP (TEST_WIN_SIZE>>1)
#define TEST_WIN_STEP (120)
int main(int _argc,const char **_argv){
FILE *fin1;
......@@ -143,7 +143,7 @@ int main(int _argc,const char **_argv){
float *xb;
float *X;
float *Y;
float err;
double err;
float Q;
size_t xlength;
size_t ylength;
......@@ -246,14 +246,15 @@ int main(int _argc,const char **_argv){
}
}
if(xi>0){
/*Temporal masking: 5 dB/5ms slope.*/
/*Temporal masking: -3 dB/2.5ms slope.*/
for(bi=0;bi<NBANDS;bi++){
for(ci=0;ci<nchannels;ci++){
xb[(xi*NBANDS+bi)*nchannels+ci]+=
0.3F*xb[((xi-1)*NBANDS+bi)*nchannels+ci];
0.5F*xb[((xi-1)*NBANDS+bi)*nchannels+ci];
}
}
}
/* Allowing some cross-talk */
if(nchannels==2){
for(bi=0;bi<NBANDS;bi++){
float l,r;
......@@ -263,17 +264,42 @@ int main(int _argc,const char **_argv){
xb[(xi*NBANDS+bi)*nchannels+1]+=0.01F*l;
}
}
/* Apply masking */
for(bi=0;bi<ybands;bi++){
for(xj=BANDS[bi];xj<BANDS[bi+1];xj++){
for(ci=0;ci<nchannels;ci++){
X[(xi*NFREQS+xj)*nchannels+ci]+=
0.01F*xb[(xi*NBANDS+bi)*nchannels+ci];
0.1F*xb[(xi*NBANDS+bi)*nchannels+ci];
Y[(xi*yfreqs+xj)*nchannels+ci]+=
0.01F*xb[(xi*NBANDS+bi)*nchannels+ci];
0.1F*xb[(xi*NBANDS+bi)*nchannels+ci];
}
}
}
}
/* Average of consecutive frames to make comparison slightly less sensitive */
for(bi=0;bi<ybands;bi++){
for(xj=BANDS[bi];xj<BANDS[bi+1];xj++){
for(ci=0;ci<nchannels;ci++){
float xtmp;
float ytmp;
xtmp = X[xj*nchannels+ci];
ytmp = Y[xj*nchannels+ci];
for(xi=1;xi<nframes;xi++){
float xtmp2;
float ytmp2;
xtmp2 = X[(xi*NFREQS+xj)*nchannels+ci];
ytmp2 = Y[(xi*yfreqs+xj)*nchannels+ci];
X[(xi*NFREQS+xj)*nchannels+ci] += xtmp;
Y[(xi*yfreqs+xj)*nchannels+ci] += ytmp;
xtmp = xtmp2;
ytmp = ytmp2;
}
}
}
}
/*If working at a lower sampling rate, don't take into account the last
300 Hz to allow for different transition bands.
For 12 kHz, we don't skip anything, because the last band already skips
......@@ -283,24 +309,30 @@ int main(int _argc,const char **_argv){
else max_compare=BANDS[ybands]-3;
err=0;
for(xi=0;xi<nframes;xi++){
float Ef;
double Ef;
Ef=0;
for(xj=0;xj<max_compare;xj++){
for(ci=0;ci<nchannels;ci++){
float re;
float im;
re=Y[(xi*yfreqs+xj)*nchannels+ci]/X[(xi*NFREQS+xj)*nchannels+ci];
im=re-log(re)-1;
/*Make comparison less sensitive around the SILK/CELT cross-over to
allow for mode freedom in the filters.*/
if(xj>=79&&xj<=81)im*=0.1F;
if(xj==80)im*=0.1F;
Ef+=im*im;
for(bi=0;bi<ybands;bi++){
double Eb;
Eb=0;
for(xj=BANDS[bi];xj<BANDS[bi+1]&&xj<max_compare;xj++){
for(ci=0;ci<nchannels;ci++){
float re;
float im;
re=Y[(xi*yfreqs+xj)*nchannels+ci]/X[(xi*NFREQS+xj)*nchannels+ci];
im=re-log(re)-1;
/*Make comparison less sensitive around the SILK/CELT cross-over to
allow for mode freedom in the filters.*/
if(xj>=79&&xj<=81)im*=0.1F;
if(xj==80)im*=0.1F;
Eb+=im;
}
}
Eb /= (BANDS[bi+1]-BANDS[bi])*nchannels;
Ef += Eb*Eb;
}
/*Using a fixed normalization value means we're willing to accept slightly
lower quality for lower sampling rates.*/
Ef/=200*nchannels;
Ef/=NBANDS;
Ef*=Ef;
err+=Ef*Ef;
}
......
......@@ -427,7 +427,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
pcm[i] = 0;
/* For hybrid -> SILK transitions, we let the CELT MDCT
do a fade-out by decoding a silence frame */
if (st->prev_mode == MODE_HYBRID)
if (st->prev_mode == MODE_HYBRID && !(redundancy && celt_to_silk && st->prev_redundancy) )
{
celt_decoder_ctl(celt_dec, CELT_SET_START_BAND(0));
celt_decode_with_ec(celt_dec, silence, 2, pcm, F2_5, NULL);
......
......@@ -102,6 +102,103 @@ static void check_encoder_option(int decode_only, const char *opt)
}
}
int silk8_test[][4] = {
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*3, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960*2, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2}
};
int silk12_test[][4] = {
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*3, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960*2, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 960, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_MEDIUMBAND, 480, 2}
};
int silk16_test[][4] = {
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*3, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960*2, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2}
};
int hybrid24_test[][4] = {
{MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2}
};
int hybrid48_test[][4] = {
{MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2},
{MODE_SILK_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2}
};
int celt_test[][4] = {
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 1},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 960, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 960, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 960, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 480, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 480, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 480, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 240, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 240, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 240, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_SUPERWIDEBAND, 120, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_WIDEBAND, 120, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_NARROWBAND, 120, 2},
};
int celt_hq_test[][4] = {
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 960, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 480, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 240, 2},
{MODE_CELT_ONLY, OPUS_BANDWIDTH_FULLBAND, 120, 2},
};
int main(int argc, char *argv[])
{
int err;
......@@ -143,6 +240,11 @@ int main(int argc, char *argv[])
int random_framesize=0, newsize=0, delayed_celt=0;
int sweep_max=0, sweep_min=0;
int random_fec=0;
int (*mode_list)[4]=NULL;
int nb_modes_in_list=0;
int curr_mode=0;
int curr_mode_count=0;
int mode_switch_time = 48000;
if (argc < 5 )
{
......@@ -302,6 +404,41 @@ int main(int argc, char *argv[])
check_encoder_option(decode_only, "-random_fec");
random_fec = 1;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-silk8k_test" ) == 0 ) {
check_encoder_option(decode_only, "-silk8k_test");
mode_list = silk8_test;
nb_modes_in_list = 8;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-silk12k_test" ) == 0 ) {
check_encoder_option(decode_only, "-silk12k_test");
mode_list = silk12_test;
nb_modes_in_list = 8;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-silk16k_test" ) == 0 ) {
check_encoder_option(decode_only, "-silk16k_test");
mode_list = silk16_test;
nb_modes_in_list = 8;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-hybrid24k_test" ) == 0 ) {
check_encoder_option(decode_only, "-hybrid24k_test");
mode_list = hybrid24_test;
nb_modes_in_list = 4;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-hybrid48k_test" ) == 0 ) {
check_encoder_option(decode_only, "-hybrid48k_test");
mode_list = hybrid48_test;
nb_modes_in_list = 4;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-celt_test" ) == 0 ) {
check_encoder_option(decode_only, "-celt_test");
mode_list = celt_test;
nb_modes_in_list = 32;
args++;
} else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-celt_hq_test" ) == 0 ) {
check_encoder_option(decode_only, "-celt_hq_test");
mode_list = celt_hq_test;
nb_modes_in_list = 4;
args++;
} else {
printf( "Error: unrecognized setting: %s\n\n", argv[ args ] );
print_usage( argv );
......@@ -326,6 +463,17 @@ int main(int argc, char *argv[])
fprintf (stderr, "Could not open input file %s\n", argv[argc-2]);
return EXIT_FAILURE;
}
if (mode_list)
{
int size;
fseek(fin, 0, SEEK_END);
size = ftell(fin);
fprintf(stderr, "File size is %d bytes\n", size);
fseek(fin, 0, SEEK_SET);
mode_switch_time = size/sizeof(short)/channels/nb_modes_in_list;
fprintf(stderr, "Switching mode every %d samples\n", mode_switch_time);
}
outFile = argv[argc-1];
fout = fopen(outFile, "wb+");
if (!fout)
......@@ -428,6 +576,8 @@ int main(int argc, char *argv[])
case 4: newsize=sampling_rate/25; break;
case 5: newsize=3*sampling_rate/50; break;
}
while (newsize < sampling_rate/25 && bitrate_bps-fabs(sweep_bps) <= 3*12*sampling_rate/newsize)
newsize*=2;
if (newsize < sampling_rate/100 && frame_size >= sampling_rate/100)
{
opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(MODE_CELT_ONLY));
......@@ -463,6 +613,13 @@ int main(int argc, char *argv[])
break;
}
} else {
if (mode_list!=NULL)
{
opus_encoder_ctl(enc, OPUS_SET_BANDWIDTH(mode_list[curr_mode][1]));
opus_encoder_ctl(enc, OPUS_SET_FORCE_MODE(mode_list[curr_mode][0]));
opus_encoder_ctl(enc, OPUS_SET_FORCE_CHANNELS(mode_list[curr_mode][3]));
frame_size = mode_list[curr_mode][2];
}
err = fread(in, sizeof(short)*channels, frame_size, fin);
curr_read = err;
if (curr_read < frame_size)
......@@ -472,7 +629,6 @@ int main(int argc, char *argv[])
in[i] = 0;
stop = 1;
}
len[toggle] = opus_encode(enc, in, frame_size, data[toggle], max_payload_bytes);
if (sweep_bps!=0)
{
......@@ -497,6 +653,12 @@ int main(int argc, char *argv[])
fclose(fout);
return EXIT_FAILURE;
}
curr_mode_count += frame_size;
if (curr_mode_count > mode_switch_time && curr_mode < nb_modes_in_list-1)
{
curr_mode++;
curr_mode_count = 0;
}
}
if (encode_only)
......
#!/bin/sh
if [ "$#" -ne "2" ]; then
echo "usage: run_vectors.sh <exec path> <vector path>"
rm logs_mono.txt
rm logs_stereo.txt
if [ "$#" -ne "3" ]; then
echo "usage: run_vectors.sh <exec path> <vector path> <rate>"
exit 1
fi
CMD_PATH=$1
VECTOR_PATH=$2
RATE=$3
OPUS_DEMO=$CMD_PATH/opus_demo
OPUS_COMPARE=$CMD_PATH/opus_compare
......@@ -32,24 +36,23 @@ echo Testing mono
echo "=============="
echo
for file in test1_mono test2_mono test3_mono test4_mono test5_mono
for file in `seq -w 1 11`
do
if [ -e $VECTOR_PATH/$file.bit ]; then
echo Testing $file
if [ -e $VECTOR_PATH/testvector$file.bit ]; then
echo Testing testvector$file
else
echo Bitstream file not found: $file
echo Bitstream file not found: testvector$file.bit
fi
if $OPUS_DEMO -d 48000 1 $VECTOR_PATH/$file.bit tmp.out > /dev/null 2>&1; then
if $OPUS_DEMO -d $RATE 1 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_mono.txt 2>&1; then
echo successfully decoded
else
echo ERROR: decoding failed
exit 1
fi
$OPUS_COMPARE $VECTOR_PATH/$file.float tmp.out > /dev/null 2>&1
$OPUS_COMPARE -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_mono.txt 2>&1
true
float_ret=$?
$OPUS_COMPARE $VECTOR_PATH/$file.fixed tmp.out > /dev/null 2>&1
fixed_ret=$?
if [ "$float_ret" -eq "0" -o "$fixed_ret" -eq "0" ]; then
if [ "$float_ret" -eq "0" ]; then
echo output matches reference
else
echo ERROR: output does not match reference
......@@ -63,24 +66,22 @@ echo Testing stereo
echo "=============="
echo
for file in test1_stereo test2_stereo test3_stereo test4_stereo
for file in `seq -w 1 11`
do
if [ -e $VECTOR_PATH/$file.bit ]; then
echo Testing $file
if [ -e $VECTOR_PATH/testvector$file.bit ]; then
echo Testing testvector$file
else
echo Bitstream file not found: $file
echo Bitstream file not found: testvector$file
fi
if $OPUS_DEMO -d 48000 2 $VECTOR_PATH/$file.bit tmp.out > /dev/null 2>&1; then
if $OPUS_DEMO -d $RATE 2 $VECTOR_PATH/testvector$file.bit tmp.out >> logs_stereo.txt 2>&1; then
echo successfully decoded
else
echo ERROR: decoding failed
exit 1
fi
$OPUS_COMPARE -s $VECTOR_PATH/$file.float tmp.out > /dev/null 2>&1
$OPUS_COMPARE -s -r $RATE $VECTOR_PATH/testvector$file.dec tmp.out >> logs_stereo.txt 2>&1
float_ret=$?
$OPUS_COMPARE -s $VECTOR_PATH/$file.fixed tmp.out > /dev/null 2>&1
fixed_ret=$?
if [ "$float_ret" -eq "0" -o "$fixed_ret" -eq "0" ]; then
if [ "$float_ret" -eq "0" ]; then
echo output matches reference
else
echo ERROR: output does not match reference
......@@ -92,3 +93,5 @@ done
echo All tests have passed successfully
grep quality logs_mono.txt | awk '{sum+=$4}END{print "Average mono quality is", sum/NR, "%"}'
grep quality logs_stereo.txt | awk '{sum+=$4}END{print "Average stereo quality is", sum/NR, "%"}'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment