Commit 6f2ce267 authored by Gregory Maxwell's avatar Gregory Maxwell Committed by Jean-Marc Valin
Browse files

Add tests for GET_LAST_PACKET_DURATION.

Also remove a useless extern that crept into the tests from some
optimization driven testcase generation.
parent 23032b40
......@@ -47,7 +47,6 @@
#define MAX_PACKET (1500)
#define MAX_FRAME_SAMP (5760)
extern int jackpot;
int test_decoder_code0(int no_fuzz)
{
......@@ -105,9 +104,12 @@ int test_decoder_code0(int no_fuzz)
int factor=48000/fsv[t>>1];
for(fec=0;fec<2;fec++)
{
int dur;
/*Test PLC on a fresh decoder*/
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, fec);
if(out_samples!=120/factor)test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=120/factor)test_failed();
/*Test null pointer input*/
out_samples = opus_decode(dec[t], 0, -1, outbuf, 120/factor, fec);
......@@ -118,6 +120,8 @@ int test_decoder_code0(int no_fuzz)
if(out_samples!=120/factor)test_failed();
out_samples = opus_decode(dec[t], 0, fast_rand(), outbuf, 120/factor, fec);
if(out_samples!=120/factor)test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=120/factor)test_failed();
/*Zero lengths*/
out_samples = opus_decode(dec[t], packet, 0, outbuf, 120/factor, fec);
......@@ -152,6 +156,7 @@ int test_decoder_code0(int no_fuzz)
/*Count code 0 tests*/
for(i=0;i<64;i++)
{
int dur;
int j,expected[5*2];
packet[0]=i<<2;
packet[1]=255;
......@@ -171,6 +176,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], packet, 3, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=out_samples)test_failed();
opus_decoder_ctl(dec[t], OPUS_GET_FINAL_RANGE(&dec_final_range1));
if(t==0)dec_final_range2=dec_final_range1;
else if(dec_final_range1!=dec_final_range2)test_failed();
......@@ -184,6 +191,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], 0, 0, outbuf, expected[t], 0);
if(out_samples!=expected[t])test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=out_samples)test_failed();
}
/* Run the PLC once at 2.5ms, as a simulation of someone trying to
do small drift corrections. */
......@@ -191,6 +200,8 @@ int test_decoder_code0(int no_fuzz)
{
out_samples = opus_decode(dec[t], 0, 0, outbuf, 120/factor, 0);
if(out_samples!=120/factor)test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=out_samples)test_failed();
}
out_samples = opus_decode(dec[t], packet, 2, outbuf, expected[t]-1, 0);
if(out_samples>0)test_failed();
......@@ -299,10 +310,13 @@ int test_decoder_code0(int no_fuzz)
if(opus_decode(decbak, 0, 0, outbuf, MAX_FRAME_SAMP, 0)<20)test_failed();
for(t=0;t<5*2;t++)
{
int dur;
out_samples = opus_decode(dec[t], packet, plen+1, outbuf, MAX_FRAME_SAMP, 0);
if(out_samples!=expected[t])test_failed();
if(t==0)dec_final_range2=dec_final_range1;
else if(dec_final_range1!=dec_final_range2)test_failed();
if(opus_decoder_ctl(dec[t], OPUS_GET_LAST_PACKET_DURATION(&dur))!=OPUS_OK)test_failed();
if(dur!=out_samples)test_failed();
}
}
fprintf(stdout," dec[all] random packets, all mode pairs (4096), %d bytes/frame OK.\n",plen+1);
......
Supports Markdown
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