mirror of
https://github.com/xiph/opus.git
synced 2025-05-15 16:08:30 +00:00
Testing tools improvements (no impact on draft)
This commit is contained in:
parent
10ebc02ecf
commit
e699c1989c
6 changed files with 44 additions and 11 deletions
|
@ -35,16 +35,20 @@ int main(int _argc,char **_argv){
|
||||||
unsigned int sym;
|
unsigned int sym;
|
||||||
unsigned int seed;
|
unsigned int seed;
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
|
const char *env_seed;
|
||||||
ret=0;
|
ret=0;
|
||||||
entropy=0;
|
entropy=0;
|
||||||
if (_argc > 2) {
|
if (_argc > 2) {
|
||||||
fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]);
|
fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (_argc > 1)
|
env_seed = getenv("SEED");
|
||||||
seed = atoi(_argv[1]);
|
if (_argc > 1)
|
||||||
else
|
seed = atoi(_argv[1]);
|
||||||
seed = time(NULL);
|
else if (env_seed)
|
||||||
|
seed = atoi(env_seed);
|
||||||
|
else
|
||||||
|
seed = time(NULL);
|
||||||
/*Testing encoding of raw bit values.*/
|
/*Testing encoding of raw bit values.*/
|
||||||
ptr = (unsigned char *)malloc(DATA_SIZE);
|
ptr = (unsigned char *)malloc(DATA_SIZE);
|
||||||
ec_enc_init(&enc,ptr, DATA_SIZE);
|
ec_enc_init(&enc,ptr, DATA_SIZE);
|
||||||
|
|
|
@ -753,6 +753,8 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
|
||||||
int ret, i;
|
int ret, i;
|
||||||
ALLOC_STACK;
|
ALLOC_STACK;
|
||||||
|
|
||||||
|
if(frame_size<0)return OPUS_BAD_ARG;
|
||||||
|
|
||||||
ALLOC(out, frame_size*st->channels, float);
|
ALLOC(out, frame_size*st->channels, float);
|
||||||
|
|
||||||
ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL);
|
ret = opus_decode_native(st, data, len, out, frame_size, decode_fec, 0, NULL);
|
||||||
|
|
|
@ -1206,6 +1206,8 @@ int opus_encode_float(OpusEncoder *st, const float *pcm, int frame_size,
|
||||||
VARDECL(opus_int16, in);
|
VARDECL(opus_int16, in);
|
||||||
ALLOC_STACK;
|
ALLOC_STACK;
|
||||||
|
|
||||||
|
if(frame_size<0)return OPUS_BAD_ARG;
|
||||||
|
|
||||||
ALLOC(in, frame_size*st->channels, opus_int16);
|
ALLOC(in, frame_size*st->channels, opus_int16);
|
||||||
|
|
||||||
for (i=0;i<frame_size*st->channels;i++)
|
for (i=0;i<frame_size*st->channels;i++)
|
||||||
|
|
|
@ -92,8 +92,8 @@ opus_int32 test_dec_api(void)
|
||||||
#endif
|
#endif
|
||||||
short sbuf[960*2];
|
short sbuf[960*2];
|
||||||
int c,err;
|
int c,err;
|
||||||
int *nullptr;
|
int *nullvalue;
|
||||||
nullptr=0;
|
nullvalue=0;
|
||||||
|
|
||||||
cfgs=0;
|
cfgs=0;
|
||||||
/*First test invalid configurations which should fail*/
|
/*First test invalid configurations which should fail*/
|
||||||
|
@ -163,7 +163,7 @@ opus_int32 test_dec_api(void)
|
||||||
cfgs++;
|
cfgs++;
|
||||||
|
|
||||||
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
||||||
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullptr));
|
err=opus_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue));
|
||||||
if(err!=OPUS_BAD_ARG)test_failed();
|
if(err!=OPUS_BAD_ARG)test_failed();
|
||||||
cfgs++;
|
cfgs++;
|
||||||
VG_UNDEF(&i,sizeof(i));
|
VG_UNDEF(&i,sizeof(i));
|
||||||
|
@ -297,8 +297,11 @@ opus_int32 test_msdec_api(void)
|
||||||
#endif
|
#endif
|
||||||
short sbuf[960*2];
|
short sbuf[960*2];
|
||||||
int a,b,c,err;
|
int a,b,c,err;
|
||||||
int *nullptr;
|
#if 0
|
||||||
nullptr=0;
|
/*Relevant test not enabled for multistream*/
|
||||||
|
int *nullvalue;
|
||||||
|
nullvalue=0;
|
||||||
|
#endif
|
||||||
|
|
||||||
cfgs=0;
|
cfgs=0;
|
||||||
/*First test invalid configurations which should fail*/
|
/*First test invalid configurations which should fail*/
|
||||||
|
@ -414,7 +417,7 @@ opus_int32 test_msdec_api(void)
|
||||||
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
|
fprintf(stdout," OPUS_GET_BANDWIDTH ........................... OK.\n");
|
||||||
cfgs++;
|
cfgs++;
|
||||||
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
/*GET_PITCH has different execution paths depending on the previously decoded frame.*/
|
||||||
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(nullptr));
|
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue));
|
||||||
if(err!=OPUS_BAD_ARG)test_failed();
|
if(err!=OPUS_BAD_ARG)test_failed();
|
||||||
cfgs++;
|
cfgs++;
|
||||||
VG_UNDEF(&i,sizeof(i));
|
VG_UNDEF(&i,sizeof(i));
|
||||||
|
|
|
@ -91,7 +91,7 @@ int test_decoder_code0(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decsize=opus_decoder_get_size(2);
|
decsize=opus_decoder_get_size(1);
|
||||||
decbak=(OpusDecoder *)malloc(decsize);
|
decbak=(OpusDecoder *)malloc(decsize);
|
||||||
if(decbak==NULL)test_failed();
|
if(decbak==NULL)test_failed();
|
||||||
|
|
||||||
|
@ -335,19 +335,30 @@ int test_decoder_code0(void)
|
||||||
int main(int _argc, char **_argv)
|
int main(int _argc, char **_argv)
|
||||||
{
|
{
|
||||||
const char * oversion;
|
const char * oversion;
|
||||||
|
const char * env_seed;
|
||||||
|
int env_used;
|
||||||
|
|
||||||
if(_argc>2)
|
if(_argc>2)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env_used=0;
|
||||||
|
env_seed=getenv("SEED");
|
||||||
if(_argc>1)iseed=atoi(_argv[1]);
|
if(_argc>1)iseed=atoi(_argv[1]);
|
||||||
|
else if(env_seed)
|
||||||
|
{
|
||||||
|
iseed=atoi(env_seed);
|
||||||
|
env_used=1;
|
||||||
|
}
|
||||||
else iseed=(opus_uint32)time(NULL)^((getpid()&65535)<<16);
|
else iseed=(opus_uint32)time(NULL)^((getpid()&65535)<<16);
|
||||||
Rw=Rz=iseed;
|
Rw=Rz=iseed;
|
||||||
|
|
||||||
oversion=opus_get_version_string();
|
oversion=opus_get_version_string();
|
||||||
if(!oversion)test_failed();
|
if(!oversion)test_failed();
|
||||||
fprintf(stderr,"Testing %s decoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535);
|
fprintf(stderr,"Testing %s decoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535);
|
||||||
|
if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s).\n", env_seed);
|
||||||
|
|
||||||
test_decoder_code0();
|
test_decoder_code0();
|
||||||
|
|
||||||
|
|
|
@ -366,19 +366,30 @@ int run_test1(void)
|
||||||
int main(int _argc, char **_argv)
|
int main(int _argc, char **_argv)
|
||||||
{
|
{
|
||||||
const char * oversion;
|
const char * oversion;
|
||||||
|
const char * env_seed;
|
||||||
|
int env_used;
|
||||||
|
|
||||||
if(_argc>2)
|
if(_argc>2)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env_used=0;
|
||||||
|
env_seed=getenv("SEED");
|
||||||
if(_argc>1)iseed=atoi(_argv[1]);
|
if(_argc>1)iseed=atoi(_argv[1]);
|
||||||
|
else if(env_seed)
|
||||||
|
{
|
||||||
|
iseed=atoi(env_seed);
|
||||||
|
env_used=1;
|
||||||
|
}
|
||||||
else iseed=(opus_uint32)time(NULL)^((getpid()&65535)<<16);
|
else iseed=(opus_uint32)time(NULL)^((getpid()&65535)<<16);
|
||||||
Rw=Rz=iseed;
|
Rw=Rz=iseed;
|
||||||
|
|
||||||
oversion=opus_get_version_string();
|
oversion=opus_get_version_string();
|
||||||
if(!oversion)test_failed();
|
if(!oversion)test_failed();
|
||||||
fprintf(stderr,"Testing %s encoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535);
|
fprintf(stderr,"Testing %s encoder. Random seed: %u (%.4X)\n", oversion, iseed, fast_rand() % 65535);
|
||||||
|
if(env_used)fprintf(stderr," Random seed set from the environment (SEED=%s).\n", env_seed);
|
||||||
|
|
||||||
run_test1();
|
run_test1();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue