aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-08-21 16:08:35 -0400
committerGregory Maxwell <greg@xiph.org>2012-08-21 16:08:35 -0400
commit582eba6f4f703929e646f6dc6e864d9b12f4f4af (patch)
treeb4e82b3f1428a525744784f26b3abc4ed2eaa086 /tests
parent635b5f2f76ed1950e978c373c8a2469ef0637354 (diff)
downloadlibopus-582eba6f4f703929e646f6dc6e864d9b12f4f4af.tar.gz
Additional multistream tests and reject channels<1 in MS API.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_opus_api.c108
-rw-r--r--tests/test_opus_encode.c9
2 files changed, 106 insertions, 11 deletions
diff --git a/tests/test_opus_api.c b/tests/test_opus_api.c
index 28ad3dc5..b5348c3a 100644
--- a/tests/test_opus_api.c
+++ b/tests/test_opus_api.c
@@ -316,7 +316,7 @@ opus_int32 test_msdec_api(void)
OpusDecoder *streamdec;
opus_int32 i,j,cfgs;
unsigned char packet[1276];
- unsigned char mapping[256] = {0,1};
+ unsigned char mapping[256];
#ifndef DISABLE_FLOAT_API
float fbuf[960*2];
#endif
@@ -328,6 +328,10 @@ opus_int32 test_msdec_api(void)
nullvalue=0;
#endif
+ mapping[0]=0;
+ mapping[1]=1;
+ for(i=2;i<256;i++)VG_UNDEF(&mapping[i],sizeof(unsigned char));
+
cfgs=0;
/*First test invalid configurations which should fail*/
fprintf(stdout,"\n Multistream decoder basic API tests\n");
@@ -373,12 +377,14 @@ opus_int32 test_msdec_api(void)
VG_UNDEF(&err,sizeof(err));
dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
if(err==OPUS_OK || dec!=NULL)test_failed();
cfgs++;
VG_UNDEF(&err,sizeof(err));
mapping[0]=mapping[1]=0;
dec = opus_multistream_decoder_create(48000, 2, 1, 0, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
if(err!=OPUS_OK || dec==NULL)test_failed();
cfgs++;
opus_multistream_decoder_destroy(dec);
@@ -386,22 +392,107 @@ opus_int32 test_msdec_api(void)
VG_UNDEF(&err,sizeof(err));
dec = opus_multistream_decoder_create(48000, 1, 4, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
if(err!=OPUS_OK || dec==NULL)test_failed();
cfgs++;
+
+ err = opus_multistream_decoder_init(dec,48000, 1, 0, 0, mapping);
+ if(err!=OPUS_BAD_ARG)test_failed();
+ cfgs++;
+
+ err = opus_multistream_decoder_init(dec,48000, 1, 1, -1, mapping);
+ if(err!=OPUS_BAD_ARG)test_failed();
+ cfgs++;
+
opus_multistream_decoder_destroy(dec);
cfgs++;
VG_UNDEF(&err,sizeof(err));
dec = opus_multistream_decoder_create(48000, 2, 1, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
if(err!=OPUS_OK || dec==NULL)test_failed();
cfgs++;
opus_multistream_decoder_destroy(dec);
cfgs++;
VG_UNDEF(&err,sizeof(err));
- mapping[0]=0;
+ dec = opus_multistream_decoder_create(48000, 255, 255, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, -1, 1, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, 0, 1, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, 1, -1, 2, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, 1, -1, -1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, 256, 255, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ dec = opus_multistream_decoder_create(48000, 256, 255, 0, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ mapping[0]=255;
mapping[1]=1;
- dec = opus_multistream_decoder_create(48000, 2, 2, 0, mapping, &err);
+ mapping[2]=2;
+ dec = opus_multistream_decoder_create(48000, 3, 2, 0, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_BAD_ARG || dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ mapping[0]=0;
+ mapping[1]=0;
+ mapping[2]=0;
+ dec = opus_multistream_decoder_create(48000, 3, 2, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
+ if(err!=OPUS_OK || dec==NULL)test_failed();
+ cfgs++;
+ opus_multistream_decoder_destroy(dec);
+ cfgs++;
+
+ mapping[0]=0;
+ mapping[1]=255;
+ mapping[2]=1;
+ mapping[3]=2;
+ mapping[4]=3;
+ dec = opus_multistream_decoder_create(48001, 5, 4, 1, mapping, 0);
+ if(dec!=NULL)test_failed();
+ cfgs++;
+
+ VG_UNDEF(&err,sizeof(err));
+ mapping[0]=0;
+ mapping[1]=255;
+ mapping[2]=1;
+ mapping[3]=2;
+ dec = opus_multistream_decoder_create(48000, 4, 2, 1, mapping, &err);
+ VG_CHECK(&err,sizeof(err));
if(err!=OPUS_OK || dec==NULL)test_failed();
cfgs++;
@@ -460,6 +551,12 @@ opus_int32 test_msdec_api(void)
}
fprintf(stdout," OPUS_GET_GAIN ................................ OK.\n");
+ VG_UNDEF(&i,sizeof(i));
+ err=opus_multistream_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i));
+ if(err != OPUS_OK || i!=0)test_failed();
+ fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
+ cfgs++;
+
err=opus_multistream_decoder_ctl(dec,OPUS_UNIMPLEMENTED);
if(err!=OPUS_UNIMPLEMENTED)test_failed();
fprintf(stdout," OPUS_UNIMPLEMENTED ........................... OK.\n");
@@ -467,11 +564,6 @@ opus_int32 test_msdec_api(void)
#if 0
/*Currently unimplemented for multistream*/
- VG_UNDEF(&i,sizeof(i));
- err=opus_multistream_decoder_ctl(dec, OPUS_GET_BANDWIDTH(&i));
- if(err != OPUS_OK || i!=0)test_failed();
- fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
- cfgs++;
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue));
if(err!=OPUS_BAD_ARG)test_failed();
diff --git a/tests/test_opus_encode.c b/tests/test_opus_encode.c
index 9e1565dc..ad634533 100644
--- a/tests/test_opus_encode.c
+++ b/tests/test_opus_encode.c
@@ -113,7 +113,7 @@ int run_test1(int no_fuzz)
{
static const int fsizes[6]={960*3,960*2,120,240,480,960};
static const char *mstrings[3] = {" LP","Hybrid"," MDCT"};
- unsigned char mapping[256] = {0,1};
+ unsigned char mapping[256] = {0,1,255};
unsigned char db62[36];
opus_int32 i;
int rc,j,err;
@@ -144,13 +144,16 @@ int run_test1(int no_fuzz)
MSenc = opus_multistream_encoder_create(8000, 2, 2, 0, mapping, OPUS_APPLICATION_AUDIO, &err);
if(err != OPUS_OK || MSenc==NULL)test_failed();
+ if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_BITRATE(&i))!=OPUS_OK)test_failed();
+ if(opus_multistream_encoder_ctl(MSenc, OPUS_GET_LSB_DEPTH(&i))!=OPUS_OK)test_failed();
+
dec = opus_decoder_create(48000, 2, &err);
if(err != OPUS_OK || dec==NULL)test_failed();
MSdec = opus_multistream_decoder_create(48000, 2, 2, 0, mapping, &err);
if(err != OPUS_OK || MSdec==NULL)test_failed();
- MSdec_err = opus_multistream_decoder_create(48000, 1, 2, 0, mapping, &err);
+ MSdec_err = opus_multistream_decoder_create(48000, 3, 2, 0, mapping, &err);
if(err != OPUS_OK || MSdec_err==NULL)test_failed();
dec_err[0]=(OpusDecoder *)malloc(opus_decoder_get_size(2));
@@ -178,7 +181,7 @@ int run_test1(int no_fuzz)
inbuf=(short *)malloc(sizeof(short)*SAMPLES*2);
outbuf=(short *)malloc(sizeof(short)*SAMPLES*2);
- out2buf=(short *)malloc(sizeof(short)*MAX_FRAME_SAMP*2);
+ out2buf=(short *)malloc(sizeof(short)*MAX_FRAME_SAMP*3);
if(inbuf==NULL || outbuf==NULL || out2buf==NULL)test_failed();
generate_music(inbuf,SAMPLES);