mirror of
https://github.com/xiph/opus.git
synced 2025-05-15 07:58:29 +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 seed;
|
||||
unsigned char *ptr;
|
||||
const char *env_seed;
|
||||
ret=0;
|
||||
entropy=0;
|
||||
if (_argc > 2) {
|
||||
fprintf(stderr, "Usage: %s [<seed>]\n", _argv[0]);
|
||||
return 1;
|
||||
}
|
||||
if (_argc > 1)
|
||||
seed = atoi(_argv[1]);
|
||||
else
|
||||
seed = time(NULL);
|
||||
env_seed = getenv("SEED");
|
||||
if (_argc > 1)
|
||||
seed = atoi(_argv[1]);
|
||||
else if (env_seed)
|
||||
seed = atoi(env_seed);
|
||||
else
|
||||
seed = time(NULL);
|
||||
/*Testing encoding of raw bit values.*/
|
||||
ptr = (unsigned char *)malloc(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;
|
||||
ALLOC_STACK;
|
||||
|
||||
if(frame_size<0)return OPUS_BAD_ARG;
|
||||
|
||||
ALLOC(out, frame_size*st->channels, float);
|
||||
|
||||
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);
|
||||
ALLOC_STACK;
|
||||
|
||||
if(frame_size<0)return OPUS_BAD_ARG;
|
||||
|
||||
ALLOC(in, frame_size*st->channels, opus_int16);
|
||||
|
||||
for (i=0;i<frame_size*st->channels;i++)
|
||||
|
|
|
@ -92,8 +92,8 @@ opus_int32 test_dec_api(void)
|
|||
#endif
|
||||
short sbuf[960*2];
|
||||
int c,err;
|
||||
int *nullptr;
|
||||
nullptr=0;
|
||||
int *nullvalue;
|
||||
nullvalue=0;
|
||||
|
||||
cfgs=0;
|
||||
/*First test invalid configurations which should fail*/
|
||||
|
@ -163,7 +163,7 @@ opus_int32 test_dec_api(void)
|
|||
cfgs++;
|
||||
|
||||
/*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();
|
||||
cfgs++;
|
||||
VG_UNDEF(&i,sizeof(i));
|
||||
|
@ -297,8 +297,11 @@ opus_int32 test_msdec_api(void)
|
|||
#endif
|
||||
short sbuf[960*2];
|
||||
int a,b,c,err;
|
||||
int *nullptr;
|
||||
nullptr=0;
|
||||
#if 0
|
||||
/*Relevant test not enabled for multistream*/
|
||||
int *nullvalue;
|
||||
nullvalue=0;
|
||||
#endif
|
||||
|
||||
cfgs=0;
|
||||
/*First test invalid configurations which should fail*/
|
||||
|
@ -414,7 +417,7 @@ opus_int32 test_msdec_api(void)
|
|||
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(nullptr));
|
||||
err=opus_multistream_decoder_ctl(dec, OPUS_GET_PITCH(nullvalue));
|
||||
if(err!=OPUS_BAD_ARG)test_failed();
|
||||
cfgs++;
|
||||
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);
|
||||
if(decbak==NULL)test_failed();
|
||||
|
||||
|
@ -335,19 +335,30 @@ int test_decoder_code0(void)
|
|||
int main(int _argc, char **_argv)
|
||||
{
|
||||
const char * oversion;
|
||||
const char * env_seed;
|
||||
int env_used;
|
||||
|
||||
if(_argc>2)
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
env_used=0;
|
||||
env_seed=getenv("SEED");
|
||||
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);
|
||||
Rw=Rz=iseed;
|
||||
|
||||
oversion=opus_get_version_string();
|
||||
if(!oversion)test_failed();
|
||||
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();
|
||||
|
||||
|
|
|
@ -366,19 +366,30 @@ int run_test1(void)
|
|||
int main(int _argc, char **_argv)
|
||||
{
|
||||
const char * oversion;
|
||||
const char * env_seed;
|
||||
int env_used;
|
||||
|
||||
if(_argc>2)
|
||||
{
|
||||
fprintf(stderr,"Usage: %s [<seed>]\n",_argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
env_used=0;
|
||||
env_seed=getenv("SEED");
|
||||
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);
|
||||
Rw=Rz=iseed;
|
||||
|
||||
oversion=opus_get_version_string();
|
||||
if(!oversion)test_failed();
|
||||
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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue